Commit Graph

145 Commits

Author SHA1 Message Date
Ryan Macnak 031069d2bd [vm] Avoid using a generated stub to get the current SP, since generated stubs aren't available during early start up.
Change-Id: Ib0d78965ba5ccb1fa2b084d82b2bb79485b7900f
Reviewed-on: https://dart-review.googlesource.com/12780
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-10-10 22:52:25 +00:00
Vyacheslav Egorov 579b06ed4c [VM] Improve code patterns for various SIMD instructions on ia32/x64.
There are three types of changes in this CL:

* If there is a repeated per-component sequence of instruction, it is
replaced with a loop (e.g. see Float32x4ConstructorInstr);
* When accessing components in the spilled SIMD values don't use 
hardcoded constants but instead compute the offset from op_kind() 
(e.g. kFloat32x4WithZ accesses component with index kFloat32x4WithZ - kFloat32x4WithX = 2).
This allows to share code.
* Use setcc and arithmetic to materialize result of the comparison instead of branches;
* Use the fact that true and false are consecutive values in the Thread structure to convert
0/1 to true/false (see Int32x4GetFlagInstr)
* Extract Int32x4 components without spilling the whole SIMD value to the 
stack (see Int32x4GetFlagInstr).

This extracted from a larger refactoring CL: https://dart-review.googlesource.com/c/sdk/+/10120

Bug: https://github.com/dart-lang/sdk/issues/30949
Change-Id: Ic3757789a1ca621b267150133991fed5b85da633
Reviewed-on: https://dart-review.googlesource.com/11080
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2017-10-04 20:03:41 +00:00
Ryan Macnak e9d358921d Revert "Puts TLABs back into the build and fixes assert failure."
This reverts commit 4c471b3f27.

This change regressed Flutter's velocity tracker benchmark by ~15%; reverting until this can be fixed or understood.

Issue #30521

R=danunez@google.com

Review-Url: https://codereview.chromium.org/3005623002 .
2017-08-25 10:48:23 -07:00
Diogenes Nunez 4c471b3f27 Puts TLABs back into the build and fixes assert failure.
This CL reintroduces the following commits (by reverting 91662ce57)

7568e1f18 : Reintroduces TLABs with fix for bug in 8b6fcf50e8
91470e721 : Scavenger::UsedInWords() is now accurate to TLABs
479db734e : Fixes IO regression casued by 7568e1f18

R=asiva@google.com, rmacnak@google.com

Furthermore, this CL fixes a bug where unscheduling the mutator thread
and then walking the heap results in the assertion in
Scavenger::MakeNewSpaceIterable() fail due to a null heap.
Review-Url: https://codereview.chromium.org/2995693002 .
2017-08-09 13:55:36 -07:00
Diogenes Nunez 91662ce579 Reverts CLs related to the TLAB due to heap exhaustion.
Revert "Attempts to fix bugs introduced in 8b6fcf50e85d."

This reverts commit 7568e1f18e.

Revert "Changes calculation of Scavenger's UsedInWords"

This reverts commit 91470e7211.

Revert "Fixes the regression caused by 7568e1f18e."

This reverts commit 479db734e3.

BUG=

Review-Url: https://codereview.chromium.org/2998663002 .
2017-08-08 14:49:50 -07:00
Diogenes Nunez 479db734e3 Fixes the regression caused by 7568e1f18e.
The IO tests unscheduled the mutator thread constantly, forcing the
isolate to fill new space and cause a GC.

Now, the mutator thread keeps its TLAB when unscheduled, taking
advantage of the fact the same thread object will always be the
mutator thread.

R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2993863002 .
2017-08-08 10:17:18 -07:00
Diogenes Nunez 7568e1f18e Attempts to fix bugs introduced in 8b6fcf50e8.
Removes a call that erroneously changes top_ in Scavenger.
Removes FlushTLS and UnflushTLS from UsedInWords.
Reverts commit 0b0f07d303.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2992343002 .
2017-08-05 09:46:04 -07:00
Diogenes Nunez 0b0f07d303 Reverted due to vm test failure.
Revert "Makes new space iterable by filling up the mutator's TLAB"

This reverts commit 8b6fcf50e8.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2998453002 .
2017-08-04 10:56:36 -07:00
Diogenes Nunez 8b6fcf50e8 Makes new space iterable by filling up the mutator's TLAB
This reverts commit bb6203dade and
adds changes FlushTLS.

Now, FlushTLS will fill the mutator thread's TLAB instead of
changing top_ in the Scavenger. This should prevent the assertion

(thread->end() == 0) || (thread->end() == top_)

in TryAllocateInTLAB in runtime/vm/scavenger.h due to a race on top_.

R=asiva@google.com, rmacnak@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2991343003 .
2017-08-04 10:36:45 -07:00
Diogenes Nunez bb6203dade These changes are suspects in the recent bot flakiness.
Revert "Changes new space allocation from simple bump pointer allocation from"

This reverts commit e6e378bb6e.

Revert "Fixes bug in calculation of memory used by new space"

This reverts commit 044f818f01.

BUG=

Review-Url: https://codereview.chromium.org/2992923002 .
2017-08-02 15:45:08 -07:00
Diogenes Nunez e6e378bb6e Changes new space allocation from simple bump pointer allocation from
mutator to thread local allocation buffer system used only by mutator.

The new allocation scheme is as follows:

- Mutator allocates an aligned buffer from the heap.
- For each object the mutator wishes to allocate
  - If the object fits in the overall space of the bufffer,
    bump allocate into the buffer.
  - If the object is larger than the buffer overall, allocate into old
    space.
  - If the object is not larger than the buffer but cannot fit,
    make the buffer iterable by GC and allocate a new buffer.
  - If the mutator cannot get a new buffer, do a GC and try again.
  - If the mutator still cannot get a new buffer, allocate the object
    in old space.
  - If the mutator does get a new buffer (before or after GC), allocate
    the object into the buffer.

BUG=
R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2985863002 .
2017-07-27 13:53:40 -07:00
Diogenes Nunez 699f84f941 Moves the top_ and end_ words of the Scavenger into mutator thread.
This is the first step to adding Thread Local Allocation Buffers to
the VM.

In this step, the mutator alone allocates to the new space, but keeps
track of the start and end of the space. This is akin to a single large
TLAB.

As a result, the generated code and the dbc simulator changed how they
allocate objects into the new space as well.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2980033002 .
2017-07-13 13:46:17 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Diogenes Nunez c0d4e02693 Revert "Moves the top_ and end_ words of the Scavenger into mutator thread."
This reverts commit 710544a907.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2974403002 .
2017-07-12 14:30:06 -07:00
Diogenes Nunez 710544a907 Moves the top_ and end_ words of the Scavenger into mutator thread.
This is the first step to adding Thread Local Allocation Buffers to
the VM.

In this step, the mutator alone allocates to the new space, but keeps
track of the start and end of the space. This is akin to a single large
TLAB.
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2951333002 .
2017-07-12 14:09:07 -07:00
Ryan Macnak 9ce48e63b2 Remove background finalization.
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2809863002 .
2017-04-11 09:54:25 -07:00
Ryan Macnak cbb8519a69 Do not embed is_auto_setup_scope into the compilation of native calls.
Rather, split NativeCallWrapper into variants that do or do not set up an API scope. This makes it safe for lazy link natives to also lazily resolve.

Issue #24686

R=zra@google.com

Review-Url: https://codereview.chromium.org/2793163002 .
2017-04-05 15:30:06 -07:00
Ben Konyi c0511ad2ef Reimplemented zone memory tracking to avoid race conditions that were causing crashes in the previous implementation and made some minor name changes.
BUG=
R=asiva@google.com, johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2762323002 .
2017-03-23 09:03:08 -07:00
John McCutchan a4adbffb50 Remove legacy restart code
Also fixes #29092 by threading Error objects back to the message handler.

BUG=
R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/2759533002 .
2017-03-20 08:47:39 -07:00
Ryan Macnak 877284947b Rename TARGET_OS_* to HOST_OS_*.
Like HOST_ARCH_*, HOST_OS_* describes the OS the VM is running on, which may be different from the OS the VM is generating code for during AOT compilation.

Currently we conflate the two when emitting AOT as assembly, and we get away with it because Flutter only uses assembly for targeting iOS and one can only target iOS from a Mac, but we expect to use assembly for Android as well so native tools can unwind Dart frames.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2750843003 .
2017-03-15 13:11:05 -07:00
John McCutchan a0ee5b24db Track async causal stack traces
This CL improves the stack traces that accompany exceptions. Whenever an
async function is entered, we remember how we got there. This is similar
in spirit to package:stack_trace but the implementation is more efficient
and memory usage can be more easily reasoned about.

Tracking causal stack traces:

- [x] Upon entry to an async function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Upon entry to an async* function, capture the synchronous stack trace prefix and store it into the closure.
- [x] Before returning from an async function, clear the Thread's asynchronous stack trace.
- [x] After resuming an async function, load the sychronous stack trace prefix into the Thread.
- [x] Filter stack traces to remove async machinery.

Service protocol changes:

- [x] Send causal async stack trace.

Observatory changes:

- [x] Display causal async stack trace below async functions.

Fixes https://github.com/dart-lang/sdk/issues/27661

R=asiva@google.com, rmacnak@google.com

Comparisons: https://docs.google.com/a/google.com/document/d/10r6jEqr8OCiDZ4y9SYU_uOimcHiOGAZMly2ghTErALI/edit?usp=sharing
Review-Url: https://codereview.chromium.org/2646443005 .
2017-02-09 15:39:44 -08:00
Ryan Macnak a0fe1a2f89 Explain requirements on fields accessed from generated code.
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2684683002 .
2017-02-07 11:26:54 -08:00
Ben Konyi 259c7ac2be Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid.
Updated the IS_VALID(handle) macro to also check if the handle is still in
scope or is a read-only handle.

BUG=
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2640573003 .
2017-01-20 15:50:15 -08:00
Ben Konyi 4024151adb Added isolate + thread high watermark tracking to Observatory
This is a fixed version of c84f30741c90d040254767ff769a40d2cba3fb1a that
resolves issues with comparing uint and intptr_t.

Original Commit Message:
Added tracking of memory usage inside of threads. In addition, the max memory usage is kept track of using a high watermark for both the threads and the isolates. Isolate high watermark information is updated when a thread exits the isolate. The isolate high watermark consists of the sum of all thread high watermarks (including the high watermark of the exiting thread). High watermark information for both threads and isolates is now visible in the isolate view in the Observatory.

BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2610253002 .
2017-01-05 14:24:53 -08:00
Ben Konyi ffda801791 Revert "Added isolate + thread high watermark tracking to Observatory"
This reverts commit c84f30741c90d040254767ff769a40d2cba3fb1a.

TBR=johnmccutchan@google.com

BUG=

Review-Url: https://codereview.chromium.org/2617513004 .
2017-01-04 15:21:35 -08:00
Ben Konyi b3c55f972f Added isolate + thread high watermark tracking to Observatory
Added tracking of memory usage inside of threads. In addition, the max memory usage is kept track of using a high watermark for both the threads and the isolates. Isolate high watermark information is updated when a thread exits the isolate. The isolate high watermark consists of the sum of all thread high watermarks (including the high watermark of the exiting thread). High watermark information for both threads and isolates is now visible in the isolate view in the Observatory.

BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2609253002 .
2017-01-04 15:08:02 -08:00
Ben Konyi 82cf4cc374 Added methods to surface number of zone and scoped handles for each isolate.
Added methods to surface number of zone and scoped handles in each isolate. These values are displayed in the isolate view page in the Observatory. These handle counts for the native IO isolate will be surfaced in another CL.

BUG=
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2601153002 .
2017-01-03 12:21:16 -08:00
Ben Konyi e28b3e3c60 Revert "Added isolate + thread high watermark tracking to Observatory"
This reverts commit 0a1a534fd9.

BUG=
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2605933003 .
2016-12-28 16:49:47 -08:00
Ben Konyi 0a1a534fd9 Added isolate + thread high watermark tracking to Observatory
Added tracking of memory usage inside of threads. In addition, the max memory usage is kept track of using a high watermark for both the threads and the isolates. Isolate high watermark information is updated when a thread exits the isolate. The isolate high watermark consists of the sum of all thread high watermarks (including the high watermark of the exiting thread). High watermark information for both threads and isolates is now visible in the isolate view in the Observatory.

BUG=
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2608463002 .
2016-12-28 14:59:22 -08:00
Ryan Macnak 4607e38d28 Reapply "Save and restore feedback from JIT."
Ensure ICData is attached to the callee flow graph in the inliner when built from kernel IR, not just from source.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2572423004 .
2016-12-16 16:00:17 -08:00
Ryan Macnak 176d732cc3 Revert "Save and restore feedback from JIT."
This reverts commit 31ee20297e.

Review-Url: https://codereview.chromium.org/2579413002 .
2016-12-16 13:53:20 -08:00
Ryan Macnak 31ee20297e Save and restore feedback from JIT.
- Adjust fingerprints to be independent of the library's private key, which varies with load order.
 - Use usage_counter in AOT inlining decisions if JIT feedback is available.
 - Reduce inlining in cold functions.

dart2js product aot snapshot 15841351 -> 14436273 (-8.86%)

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2562693003 .
2016-12-16 10:21:40 -08:00
Ben Konyi 9f8a85c19b Added task kind field to thread JSON output.
BUG=
R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2565253004 .
2016-12-12 17:08:45 -08:00
Ben Konyi 35a49bc1ff Created methods to surface zone memory information for each isolate and thread in JSON.
BUG=
R=asiva@google.com, johnmccutchan@google.com, zra@google.com

Review URL: https://codereview.chromium.org/2554983002 .
2016-12-12 09:56:49 -08:00
Todd Turnidge 2d22e85cf0 Revert "Revert "JumpToFrame refactor"" + Fix
This reverts commit 1cdb3d2155.

I have also added in a fix for the lazy-deopt in exception handler case.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2506503002 .
2016-11-21 08:49:18 -08:00
Todd Turnidge 1cdb3d2155 Revert "JumpToFrame refactor"
This reverts commit 5ed13d3298.

BUG=

Review URL: https://codereview.chromium.org/2503623003 .
2016-11-14 15:57:01 -08:00
Todd Turnidge 5ed13d3298 JumpToFrame refactor
- Refactor the JumpToExceptionHandle code so that it is now built from
  two pieces: JumpToFrame and RunExceptionHandler.

- Refactor the Simulator::Longjmp() code so that it is no longer
  exception-specific.  Instead it uses the RunExceptionHandler stub.

This makes it so that the JumpToFrame stub and Simulator::JumpToFrame
have the same semantics.  This will make it easier to land the Rewind
changes I am working on.

There are some oddities for dbc.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2503653002 .
2016-11-14 14:38:21 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Regis Crelier cf52536d09 Remove default monomorphic check code from functions and stubs that do not need it.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2463083002 .
2016-11-03 01:41:14 -07:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
Ryan Macnak 12b18466bb Reduce size of monomorphic checked entry.
Flutter gallery
VMIsolate(CodeSize): 112293
Isolate(CodeSize): 2065968
ReadOnlyData(CodeSize): 1721336
Instructions(CodeSize): 5625616
Total(CodeSize): 9525213
->
VMIsolate(CodeSize): 112292
Isolate(CodeSize): 2065966
ReadOnlyData(CodeSize): 1721336
Instructions(CodeSize): 5592336 -0.35%
Total(CodeSize): 9491930 -0.59%

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2403613002 .
2016-10-11 13:58:49 -07:00
Ryan Macnak 763daa9d06 Reapply "Lazy deopt without code patching."
When throwing to a frame scheduled for lazy deopt, update the continuation pc for that frame to be the catch handler.

Weaken new assert that the deopt pc belongs to the frame's code as the deopt pc for the last eager deopt in a function lies outside the code, after the call to the deopt stub.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2392613002 .
2016-10-03 11:31:48 -07:00
Ryan Macnak 4e9a473746 Revert "Lazy deopt without code patching."
This reverts commit 6cff17c59a.

Review URL: https://codereview.chromium.org/2382953004 .
2016-09-30 18:04:58 -07:00
Ryan Macnak 6cff17c59a Lazy deopt without code patching.
Keep a side table that maps a fp back to a deopt pc.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2380403003 .
2016-09-30 16:53:29 -07:00
John McCutchan bc119f28bb Relax zone allocation assertion
- [x] Allow allocation in any zone that is owned by the current thread not just the top zone.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2360963005 .
2016-09-23 13:06:14 -07:00
Ryan Macnak 6137d020b9 AOT: Use a cid range check when possible to implement type tests.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2314133003 .
2016-09-08 15:25:08 -07:00
Ryan Macnak e40b4fd2c5 Update some switchable call stub names and comments.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2272793004 .
2016-08-23 17:27:57 -07:00
Ryan Macnak 59c52a5b64 Partially implement DBC profiler.
- Fix setting exit frame info to indicate when we are executing Dart code.
 - Copy local pc to memory on call and return to make it accessible to the profiler. Since the profiler cannot access the local pc, the profiler is not accurate at the instruction level.
 - Teach the profiler's stack walker that the stack grows up for Dart frames on DBC.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2250823002 .
2016-08-19 16:48:34 -07:00
Ryan Macnak 7ff2dd4117 Optimize AOT's switchable calls for the monomorphic case.
The call sequence is very similar to a classic IC call, except the guarded class and the target are loaded indirectly from the constant pool instead of as immediates. In the monomorphic case, we call directly to the expected target with a class check in the callee. In the unlinked, polymorphic and megamorphic cases, we call a stub; these case are now call-through instead of call-and-return.

Every code, except stubs involved in switchable calls, includes the class check sequence at the beginning. So we now distinguish between a checked and an unchecked entry point. Generated code except the switchable call continues to use the unchecked entry point.

PC offsets are calculated relative to the beginning of the instruction stream, rather than either entry point.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2226893002 .
2016-08-12 11:18:35 -07:00
Lars Bak 4e7bb93773 - Optimized the call sequences for calling the megamorphic stub on all platforms.
- Optimized instructions in the megamorphic stubs on X64, IA32, ARM, and ARM64.
In a micro benchmark testing megamorphic calls using 71 different receiver types,
the execution times goes from 2.6 sec to 1.4 sec.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2131583002 .
2016-07-07 11:21:53 -07:00