Commit Graph

408 Commits

Author SHA1 Message Date
Alexander Markov f6d6766920 [VM] Restore disassembler in flutter/profile (dart/release) mode
This CL restores disassembler in precompiled mode after it was removed
in 8cb752f73b.
Without disassembler observatory is not able to show assembly code
in 'flutter run --profile' mode.

This CL also pulls BufferFormatter out of il_printer.h/.cc as it is also
used in disassembler.

Change-Id: I098ddb8d8f5a2426028c1f467d58e5c2d6a82d21
Reviewed-on: https://dart-review.googlesource.com/7486
Reviewed-by: Zach Anderson <zra@google.com>
2017-09-21 16:07:02 +00:00
Vyacheslav Egorov 8a179fb953 [VM, Compiler] Move compiler to a separate folder.
New folder structure (nested under vm/):

- compiler/
-   jit/         - JIT specific code
-   aot/         - AOT specific code
-   backend/     - all middle-end and back-end code (IL, flow graph)
-   assembler/   - assemblers and disassemblers
-   frontend/    - front ends (AST -> IL, Kernel -> IL)

compiler/README.md would be the documentation root for the compiler
pipeline

Bug: https://github.com/dart-lang/sdk/issues/30575
Change-Id: I2dfd9688793bff737f7632ddc77fca766875ce36
Reviewed-on: https://dart-review.googlesource.com/2940
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2017-09-04 15:15:18 +00:00
Aske Simon Christensen 8cb752f73b Revised "Eliminate dependencies on assemblers and code stubs in precompiled runtime."
Explicitly clear unbox_numeric_fields flag in PRODUCT builds. Fixes code bloat introduced by previous CL. New changes in Patch Set 2.

BUG= https://github.com/dart-lang/sdk/issues/30045
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/3006923002 .
2017-09-04 13:13:26 +02:00
Beeravolu Siva Chandra Reddy 245be6c74c Rename the class "KernelReader" to "KernelLoader".
There already exists a class named "Reader" in the "kernel" namespace
which reads bytes from a kernel binary. The class KernelLoader
(KernelReader before this change) creates VM heap objects and populates
them.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/3010543002 .
2017-08-29 10:59:18 +02:00
Ryan Macnak 9ce7fb5929 Revert "Reapply "Eliminate dependencies on assemblers and code stubs in precompiled runtime.""
This reverts commit 8ee4436355.

This change caused a 63% increase in AOT snapshot size of Flutter Gallery.

Issue #30472

Review-Url: https://codereview.chromium.org/2997993002 .
2017-08-17 13:33:37 -07:00
Beeravolu Siva Chandra Reddy ab6d7bba53 Fix stepping in when paused in async functions.
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2994983002 .
2017-08-15 14:14:11 +02:00
Aske Simon Christensen 8ee4436355 Reapply "Eliminate dependencies on assemblers and code stubs in precompiled runtime."
Also exclude references to disassembler in precompiled mode.

New edits are in patch set #2.

BUG= https://github.com/dart-lang/sdk/issues/30045
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2994863002 .
2017-08-12 02:15:23 +02:00
Siva Annamalai 73d30074b1 - Convert all isolate flags to a bit field.
- Add a new isolate specific flag to cause the isolate to run in kernel mode.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2995723002 .
2017-08-11 12:38:25 -07:00
Ryan Macnak 3afd223f90 [gardening] Revert "Eliminate dependencies on assemblers and code stubs in precompiled runtime."
This reverts commit 46c53882cc.

This changes introduced link errors on Windows.

Review-Url: https://codereview.chromium.org/3001463002 .
2017-08-09 15:49:51 -07:00
Aske Simon Christensen 46c53882cc Eliminate dependencies on assemblers and code stubs in precompiled runtime.
Guard all excluded code behind conditional compilation.

Removed precompiled runtime flag. Only preprocessor flag remains.

BUG= https://github.com/dart-lang/sdk/issues/30045
R=rmacnak@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2976723003 .
2017-08-09 22:21:34 +02:00
Siva Chandra cf07adc873 Allow setting breakpoints in function literal field initializers under --dfe.
The change 3b9cf7351b fixed #29581 for the
case when --dfe is not used. This change fixes the issue for the --dfe
configuration as well.

Tests which now pass have been taken out of the status files.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2979163002 .
2017-07-19 13:17:25 -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
Siva Chandra f0ef900fd3 Fix setting breakpoints in parts of a library.
This fixes the regression caused by
1eaa3dd84b and reported in #29988.

When picking a class to set a breakpoint, instead of rejecting classes
not defined in the script, we now reject classes which do not belong to
the library to which the script belongs.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2965673004 .
2017-07-10 17:20:26 -07:00
Aske Simon Christensen cec963f028 The current growth strategy for growable arrays allocates a backing array of size 2 at (empty) creation and doubles the size whenever the capacity is insufficient while adding elements.
I collected statistics for the sizes and capacities of growable arrays which are promoted to old-space or survive an old-space gc when running dart2js and Fasta. For these applications, the vast majority of arrays stay empty. More than half of the total object size of promoted backing arrays is backing for empty growable arrays.

Furthermore, since the overhead for an array is 3 words (header, type parameters and length), and object sizes are rounded up to an even number of words, we waste one word for all even-sized arrays.

This CL changes the growth strategy so that empty growable arrays are created with a shared, zero-sized array as backing, avoiding the allocation of a backing array if no elements are added. When the array needs to grow, it starts out at 3 and grows to double size plus one each time: 7, 15, 31, ...

A few places in the VM code need to handle these shared, zero-sized arrays specially. In particular, the Array::MakeArray function needs to allocate a new, empty array if its result is to be returned to Dart code.

Benchmarks suggest that the change improves memory usage by a few percent overall and does not significantly affect run time.

BUG=
R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2949803002 .
2017-06-22 10:51:54 +02:00
Ryan Macnak 2109cc53bf Remember deopt-id -> context-level mappings in var descriptors.
- Add deopt ids to DebugStepInstr and StrictCompareInstr since the debugger can stop there.
 - Add missing pc descriptor in DBC's StringInterpolateInstr.

Re-enable async_debugger, which had been crashing flakily from context mismatches.

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2903993002 .
2017-06-01 12:33:33 -07:00
Siva Chandra ffeaa4a46d Hit breakpoints in single line closures.
Before this change, breakpoints on lines like the following were not hit:

var singleLineClosure = (int a, int b) => return a + b;

The reason was that breakpoints were only resolved if their start token
was contained within a function. Since that is not true for closure vars
like in the above example, the breakpoints were never getting resolved.
This change avoids such a problem by resolving breakpoints if the token
range of the breakpoint overlaps the token range of a function.

Fixes #29736

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2912763005 .
2017-06-01 11:26:06 -07:00
Siva Chandra 3b9cf7351b Allow setting breakpoints in literal function initializers of fields.
Fixes #29581 when the VM parser is used.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2904793002 .
2017-05-26 13:43:34 -07:00
Siva Chandra 1eaa3dd84b Cleanup how a best fit function is found when setting a breakpoint.
1. Look for functions/closures only in the script where the breakpoint
is being set.
2. If an inner most closure is found, return that as the best fit.
3. When going over a class' functions, return immediately when a fit is
found as going over the other class functions will not yield a narrower
fit.

BUG=
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2898153006 .
2017-05-25 12:57:40 -07:00
Ryan Macnak 03a2c24edf vm-service: Add optional 'scope' parameter to 'evaluate' and 'evaluateInFrame'.
Closes #29535

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2872503004 .
2017-05-18 18:02:49 -07:00
Alexander Aprelev 5f9ec0abe8 Use latent breakpoints list when looking up or removing breakpoints.
BUG=https://github.com/dart-lang/sdk/issues/29566
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2869573002 .
2017-05-09 05:58:37 -07:00
Martin Kustermann ac8d2056a3 Fix asserts in StackFrameIterator which were effectively disabled
The assertions which tried to assert that we only use
StackFrameIterator to walk frames of the current thread was incorrect.
We already have cases where other threads will walk the stack of the
mutator thread, see below for an example where this can happen.

Thread::VisitObjectPointers was incorrectly passing Thread::Current() to
the StackFrameIterator instead of 'this'.  (Code in thread_registry.cc will
loop over a number of threads and calls VisitObjectPointers on them)

  Mutator thread:

    0  pthread_cond_wait@@GLIBC_2.3.2
    1  dart::Monitor::WaitMicros
    2  dart::Monitor::Wait
    3  dart::MonitorLocker::Wait
    4  dart::ThreadBarrier::Sync
    5  dart::GCMarker::MarkObjects
    6  dart::PageSpace::MarkSweep
    7  dart::Heap::CollectOldSpaceGarbage
    8  dart::Heap::CollectNewSpaceGarbage
    9  dart::Heap::CollectGarbage
    10 dart::DN_HelperObject_<native>
    11 dart::BootstrapNatives::<native>
    <dart frames>

  MarkTask thread:

    1  dart::EntryFrame::VisitObjectPointers
    2  dart::Thread::VisitObjectPointers          <---- Walks mutator thread stack
    3  dart::ThreadRegistry::VisitObjectPointers  <---- Iterates over a number of threads
    4  dart::Isolate::VisitStackPointers
    5  dart::Isolate::VisitObjectPointers
    6  dart::GCMarker::IterateRoots
    7  dart::MarkTask::Run
    8  dart::ThreadPool::Worker::Loop
    9  dart::ThreadPool::Worker::Main
    10 dart::ThreadStart

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2845053003 .
2017-05-03 10:27:01 +02:00
Erik Corry aa6353b6da Dart SDK Spelling b, c, and d.
R=kmillikin@google.com
BUG=

Review-Url: https://codereview.chromium.org/2850783002 .
2017-05-01 08:28:10 +02:00
Erik Corry 6617737ff5 Replace 'the the' with 'the'
R=kmillikin@google.com
BUG=

Review-Url: https://codereview.chromium.org/2830353002 .
2017-04-24 08:50:37 +02:00
Ryan Macnak 8b96a31c7f Move runtime functions to the more logical runtime_entry.cc.
Make --trace-runtime-calls respect the isolate filter.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2827873002 .
2017-04-19 10:22:04 -07:00
John McCutchan 6f039b508b Kill dead code
BUG=

Review-Url: https://codereview.chromium.org/2819573002 .
2017-04-13 09:55:13 -07:00
John McCutchan 7399d4bdec DBC follow up CL
- [x] Hoist handle out of loop.
- [x] Avoid allocating a handle.

BUG=

Review-Url: https://codereview.chromium.org/2819523003 .
2017-04-13 07:38:15 -07:00
John McCutchan f0734f99b3 Detect unhandled exceptions in async functions without an awaiter
- [x] Produce an awaiter stack trace even when there is no awaiter.
- [x] Fix fetching the saved context from Closure.call (fixes --trace_debugger_stacktrace)

Fixes #29200

Example code:

```
main(List<String> args) async {
  var f = new Foo();
  print(f.a.length);
  print('Should not get here');
}

class Foo {
  String a;
}
```

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2815863002 .
2017-04-12 13:15:41 -07:00
Regis Crelier d0a7bad121 Pass a second type argument vector to all type instantiation calls in the VM.
With generic methods, uninstantiated types will require 2 instantiators, one
reflecting the class type arguments (as of today) and one reflecting the
function type arguments (new).
This is work in progress and the second instantiator is always null for now.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2799373002 .
2017-04-10 21:25:33 -07:00
John McCutchan e33e09a23c Disable async debugger support until context mismatch issue is resolved.
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2795303002 .
2017-04-04 13:36:42 -07:00
John McCutchan fb84ff3fc4 Revert "Disable awaiter stepping by default until context level computation is fixed"
This reverts commit 61e11c6808.

BUG=

Review-Url: https://codereview.chromium.org/2791953002 .
2017-04-03 00:06:28 -07:00
John McCutchan 61e11c6808 Disable awaiter stepping by default until context level computation is fixed
BUG=
R=asiva@google.com, fschneider@google.com

Review-Url: https://codereview.chromium.org/2787023002 .
2017-04-02 21:03:11 -07:00
John McCutchan 193f26d1e1 Implement support for single stepping out of an async function.
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2785243003 .
2017-03-31 10:55:11 -07:00
Florian Schneider 5a3f9d9398 Fix a couple of bugs with async stack traces
Related to #29145.

Fixes #29199.

1. Missing source positions in async and async* functions (synthetic code)

2. Added unit tests for issues #28980 and added asyns stack trace testing flags to existing test.

3. Handle uninitialized Completer object when collecting async stack traces.

Still missing is the correct calculation of context levels in ActivationFrame::ContextLevel. This is planned for a separate CL.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2786503003 .
2017-03-30 11:02:33 -07:00
John McCutchan 2815f3f775 Implement debugger support for async step-out
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2777093006 .
2017-03-29 07:44:18 -07:00
John McCutchan 8cee5258ee Fix crash when determining whether an async exception is handled
BUG=

Review-Url: https://codereview.chromium.org/2780163002 .
2017-03-29 07:30:29 -07:00
John McCutchan d8555fb5a8 Include the awaiter stack trace in the service protocol
- [x] Include the (non-empty) awaiter stack trace in every `getStack` RPC.
- [x] Append the causal stack trace to the final frame of the awaiter stack trace.
- [x] Unit test for awaiter stack trace.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2782703002 .
2017-03-29 06:56:50 -07:00
John McCutchan 11cf515e5e Cleanups needed for async step-out
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2774233003 .
2017-03-27 15:18:41 -07:00
John McCutchan 07a257573d Debugger support for step-into async and async* functions.
- [x] Support stepping into an async function.
- [x] Support stepping into the async generator in an await for loop.
- [x] Unit test for async function.
- [x] Unit test for async* function.

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

Review-Url: https://codereview.chromium.org/2768103002 .
2017-03-24 07:56:50 -07:00
Regis Crelier bde22d2dee Cleanup change.
AssertAssignableInstr::Canonicalize was too restrictive: it can instantiate the
type even if the instantiator is null.
Do not allocate empty TypeArguments handles, but use the common one instead.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2759393005 .
2017-03-21 13:55:39 -07:00
Florian Schneider 537eacb525 Ensure unoptimized code when collecting awaiter return stack trace.
Fixes crashes when running reload stress tests with the async stack trace stress flag
(python tools/test.py --hot-reload -t240 --builder-tag no_ipv6 language/await_exceptions_test)

R=johnmccutchan@google.com

Also: Use iterators to get function of a stack frame (refactoring only).
Review-Url: https://codereview.chromium.org/2761143004 .
2017-03-21 13:03:03 -07:00
Florian Schneider ef7487a7a8 Fix two bugs with async stack traces.
1. A crash when collecting an async stack trace with inlined frames on the stack.

2. A missing source position in an async stack trace.

Fixes #29080.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2767483002 .
2017-03-21 09:31:11 -07:00
Matthias Hausner d8ddd7766b Fix debugger regression in issue 28980
When generating the implicit try-catch of an async function, use the
end token position of the function for the completeError() call. Before
this change, the position was one token past last function token.

CL https://codereview.chromium.org/2646093006/ introduced a regression.
This CL fixes #28980 and implements a different fix for #28443.

BUG=#28980
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2740783007 .
2017-03-09 16:20:48 -08:00
Matthias Hausner 408a64756e Fix setting breakpoint setting in await statements
CL https://codereview.chromium.org/2626753002 introduced a “real” token
position for the synthetic code that re-throws an exception returned
by an await’ed expression. This interferes with setting a breakpoint
in a line that contains an await, since the synthetic code happens to
be at the lowest compiled code address and will thus be picked as the
breakpoint location.

This CL makes the re-throw a synthetic token position again, but
includes synthetic token positions in stack traces. This is an alternative
fix for bug #28325.

BUG=#28770
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2727803002 .
2017-03-02 12:21:42 -08:00
John McCutchan 6cb83f037e Address comments from Matthias on previous CL
original CL: https://codereview.chromium.org/2692803006/

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2720723006 .
2017-02-28 14:02:32 -08:00
Kevin Millikin f31b6d5e2c Reland "Track the 'awaiter return' call stack..."
Original CL: https://codereview.chromium.org/2692803006/

Original commit message:
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2725623003 .
2017-02-28 16:13:41 +01:00
Kevin Millikin a0965a641f Revert "Track the 'awaiter return' call stack..."
Revert a pair of commits that cause failure of the Kernel continuation
transformer:

  cba7e3e79a
  4fe4f177de

R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2718353002 .
2017-02-28 12:46:31 +01:00
John McCutchan cba7e3e79a Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions
Tracking the awaiter return call stack:

- [x] Each async function closure now knows who is awaiting on their
return. This is effectively the asynchronous equivalent of the 'frame pointer'.
- [x] Each async* function closure now knows how is listening on their
stream. This is effectively the asynchronous equivalent of the 'frame pointer'.

Detecting uncaught exceptions in async functions:

- [x] Code object keeps a map from :await_jump_var to token position
- [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code
- [x] Debugger maps :await_jump_var to a specific try index

Fixes #27242

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2692803006 .
2017-02-27 14:16:15 -08:00
John McCutchan 6a312d429b Fix causal_async_star_stack_contents_test with optimization-counter-threshold=5
There was an off by one error when generating the causal async stack trace
in the debugger. We were always adding one more frame pass the sentinel frame.
This frame is always _Closure.call which is filtered out by the debugger
already. However when --optimization-counter-threshold=5, _Closure.call was
inlined and we ended up appending the inliner to the stack trace. The
inliner is not filtered out by the debugger so we got an extra frame in
the stack trace.

Fixes #28861

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2707413002 .
2017-02-24 06:58:39 -08:00
John McCutchan 19abef97f1 Reland improvements to causal async stack traces
Original CL: https://codereview.chromium.org/2690683002

Improvements to causal async stack traces

UX improvements:

- [x] Stop printing the suffix <%s_async_body> and <%s_async_gen_body> for the generated closures.

Fixes #28743

- [x] Don't include the duplicate frame below the asynchronous suspension marker.

Fixes #28742

Bug fixes:

- [x] Fix service protocol enum naming so that it is consistent with other enums.

Fixes #28726

Misc:

- [x] Stop using package:stack_trace now that the VM does it for us.

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

Review-Url: https://codereview.chromium.org/2691213003 .
2017-02-14 05:00:04 -08:00
John McCutchan e84d8a1f11 Revert "Improvements to causal async stack traces"
This reverts commit 8538d81473.

BUG=

Review-Url: https://codereview.chromium.org/2694213002 .
2017-02-14 02:29:40 -08:00