Commit Graph

652 Commits

Author SHA1 Message Date
Vyacheslav Egorov a9a756df8e VM: Allow configuring use_field_guards on the per-isolate basis and include it into snapshot features.
We have tests that disable it but we train app-jit snapshot for Kernel with field guards enabled so
we need to make sure that Kernel isolate runs with correct settings matching the settings at the time
when app-jit snapshot was created.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2715213008 .
2017-02-28 21:17:17 +01: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
Regis Crelier 3633c5bd5e Rename Closure instance field type_arguments_ to instantiator_.
Simplify handling of closures as deferred objects.
The name "type_arguments_" is confusing, because class Closure is not generic.
Class Closure was forcefully made (kinda) generic by setting its
type_arguments_field_offset_in_words_ field to a valid value, so that the
type_arguments_ field in closure instances could be accessed similarly as in
generic instances. With generic functions, closures will potentially have more
than one instantiator and the name type_arguments_ becomes nonsensical.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2719603002 .
2017-02-27 11:14:04 -08:00
Martin Kustermann 20130a2d43 VM: [Kernel] Ensure we record [FieldLoadInstr]s in the ParsedFunction when using field guards
R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2704623003 .
2017-02-17 13:10:20 +01: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
Florian Schneider 504e6bb1dc VM: Make debug printing of AST/scopes use --print-flow-graph-filter flag.
Helps reading debug output from these flags.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2684073005 .
2017-02-08 16:26:38 -08:00
Matthias Hausner cc8139350d Add debug step check before break and continue
This allows debuggers to set a breakpoint in a line that contains
a break or continue statement.

When running dart2js on a small program, this adds around 900 DebugStepCheck
runtime calls. I’m not sure the price is worth paying.

BUG=#28473
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2651263002 .
2017-01-26 13:49:37 -08:00
Matthias Hausner 197f141100 Allow debugger to stop when reading a static field
Add a DebugStepCheck when the right-hand side of an expression is an access
to a static field or top-level variable.

BUG=#28453
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2650823007 .
2017-01-25 14:39:24 -08:00
Vyacheslav Egorov 67576af5f2 VM: [Cleanup] Delete legacy code associated with BranchInstr.
1) BranchInstr::is_checked() was introduced back in the day when unoptimized
IR could contain comparisons like RelationalOp - these days unoptimized IR
can only contain StrictCompareInstr, other comparisons are represented as
calls and can't be merged into the branch, making BranchInstr::is_checked()
obsolete.

2) Constrained type support is no longer used: we deleted parts of the flow graph type propagator that propagated non-nullable types down from comparison with null (due to LICM issue).

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2640993003 .
2017-01-18 23:58:58 +01:00
Kevin Millikin d9f80a9ac1 Turn the VM's dart:typed_data into a patch
Before, the VM's dart:typed_data was a complete replacement of the SDK's
dart:typed_data implementation instead of a patch.  This is unlike all
the other SDK libraries.  This difference requires special-casing for
dart:typed_data in tools that handle the SDK libraries (e.g., the
Analyzer's patching support, the GN build).

This change makes dart:typed_data back into a patch to the SDK's
implementation.  It reintroduces a distinction between abstract
interface and concrete implementation classes, so there are more
classes.

BUG=
R=fschneider@google.com, vegorov@google.com

Committed: https://github.com/dart-lang/sdk/commit/a9b906d319c32525a0600c75c008c92753591d86
Review-Url: https://codereview.chromium.org/2571563005 .
2016-12-22 10:57:21 +01:00
Kevin Millikin f97440848f Revert "Turn the VM's dart:typed_data into a patch"
This reverts commit a9b906d319.

A lot of things were broken by the changes to implementation class
names.

BUG=

Review-Url: https://codereview.chromium.org/2598603002 .
2016-12-21 12:28:33 +01:00
Kevin Millikin a9b906d319 Turn the VM's dart:typed_data into a patch
Before, the VM's dart:typed_data was a complete replacement of the SDK's
dart:typed_data implementation instead of a patch.  This is unlike all
the other SDK libraries.  This difference requires special-casing for
dart:typed_data in tools that handle the SDK libraries (e.g., the
Analyzer's patching support, the GN build).

This change makes dart:typed_data back into a patch to the SDK's
implementation.  It reintroduces a distinction between abstract
interface and concrete implementation classes, so there are more
classes.

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2571563005 .
2016-12-21 08:34:52 +01: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
Ryan Macnak 26245de7a5 Support unaligned integer loads on ARM and MIPS.
Fixes SDK build with SIMARM/SIMARM64/SIMMIPS.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2452453002 .
2016-10-31 17:41:53 -07:00
Martin Kustermann e984271b94 Add support for OSR in kernel-based FlowGraphBuilder
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2464953002 .
2016-10-31 19:12:09 +01:00
John McCutchan 8061bd5a8a Add local variable declaration token position to service protocol
- [x] Add three public fields to the "BoundVariable" service type: declarationTokenPos, visibleStartTokenPos, and visibleEndTokenPos. (naming suggestions welcome!)
- [x] Extend LocalVarDescriptors to hold the declaration token position (it already had the scope visibility boundaries).
- [x] Extend ContextScope to hold the declaration token position.
- [x] Add a unit test which verifies this works for local variables, function parameters, and closure captured variables.

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

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2419013004 .
2016-10-17 11:18:24 -07:00
Zachary Anderson 08d70cdca5 DBC: Fix CheckCids instruction
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2408423004 .
2016-10-12 12:45:38 -07:00
Florian Schneider 7ca3da1a3a Fix lazy deoptimization in the presence of exceptions
Catch block entries need to be considered when doing lazy deoptimization.

In addition to the return, also patch all catch entry blocks in a function scheduled for lazy deoptimization.

Also, move restoring the pool pointer to the jump-to-handler stub to simplify patching the catch entry.

BUG=#27419
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2357343003 .
2016-09-26 16:24:23 -07:00
Siva Annamalai 12f86594ec Add --parse-all option in order to benchmark and measure the scanner/parser performance.
R=hausner@google.com

Review URL: https://codereview.chromium.org/2327693002 .
2016-09-23 15:20:39 -07:00
Matthias Hausner 7e82552124 Make local var assignments debuggable in checked mode
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2352993003 .
2016-09-20 17:31:22 -07:00
Matthias Hausner 631a48600b Fix debug break on assignment to global variable
Make sure a debug break is also inserted in checked mode.

BUG=#27287

Review URL: https://codereview.chromium.org/2351373002 .
2016-09-20 14:57:05 -07:00
Matthias Hausner 0dd760092d Add debugger safe point on assignment to global variables
Just like we do for local variables, add a debug step check (and
thus a breakpoint location) to global variable assignment if
the right side of the assignment has no possible breakpoint locations.

BUG=#27287
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2354773002 .
2016-09-20 14:05:45 -07:00
Florian Schneider 60e6faa7c3 VM: Zero-cost try-finally with an empty finally-block.
Consider code like

try {
    something();
} finally {
    assert(expr);
}

The compiler de-sugars this into

try {
  something();
} catch (_) {
  rethrow;
} finally {
  assert(expr);
}

In unchecked mode this leaves an empty finally-block, but we would still
have the overhead of the try-catch. This CL avoids this unnecessary overhead
by making try-finally with an empty finally zero-cost.

BUG=#27274
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2322853003 .
2016-09-09 14:00:47 -07:00
Florian Schneider 442fa8e7bc VM: Remove unecessary dead code from flow-graph builder.
We already recognize typed list factories and mark them
using is_known_list_constructor_.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2293103002 .
2016-08-30 11:14:40 -07:00
Florian Schneider 37dbf25f13 VM: Mark loads from final captured locals immutable.
This enables load elimination across calls for these locals.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2160613004 .
2016-07-18 13:32:51 -07:00
Lars Bak d59f3eaeca Added negative is check support ot simpleInstanceOf.
BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2153013002 .
2016-07-18 09:20:33 -07:00
Lars Bak 21a3a27aff Made simple instance-of checks fast for unoptimized code.
This change makes dart2js 15% faster when compiling 60KLOC. 15sec -> 13sec.

BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/2147123002 .
2016-07-14 11:11:17 -07:00
Florian Schneider 7f0273f83e Remove invalid assertion in the optimizer.
We can have stores inlined in the optimizer that are not initializing stores.

Mark initializing stores in the parser instead to distinguish
initializing- and non-initializing stores more precisely.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2112973002 .
2016-07-01 09:55:35 -07:00
Siva Annamalai 006bab2c47 Land Ivan's change of 'Remove support for verified memory handling'
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2112043002 .
2016-07-01 09:21:01 -07:00
Florian Schneider 9ee5dfb245 Fix speculative inlining in precompilation.
When optimistically inlining is-checks and as-casts, we have to guard
again repeated speculative attempts.

Also, add result cid information for recognized factories.

BUG=#26607
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2035073002 .
2016-06-06 16:37:39 -07:00
Ryan Macnak 2e9c5f9a91 Reapply "VM: Add result cid information for recognized methods."
- _HashVMBase._index is nullable
 - _HashVMBase._data is a regular Array
 - DBC fixes from Zach.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/2033553002 .
2016-06-02 09:59:48 -07:00
Ryan Macnak 907a6b1c3b Revert "VM: Add result cid information for recognized methods."
In Flutter, this caused

  RangeError (index): Index out of range: index should be less than null: 0
  Uint32List.[]= (dart:typed_data)
  _HashVMBase&MapMixin&&_LinkedHashMapMixin._insert (dart:collection-patch/compact_hash.dart)

This reverts commit 0ae4ae5033.

TBR=fschneider@google.com

Review URL: https://codereview.chromium.org/2023423002 .
2016-06-01 14:08:48 -07:00
Florian Schneider 0ae4ae5033 VM: Add result cid information for recognized methods.
We already had this for recognized factories. This CL adds a result cid
for the remaining recognized methods.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2018363004 .
2016-06-01 09:42:48 +02:00
Matthias Hausner 7daa2a8915 Fix capturing variables in optimized compilations
Fourth(!) attempt. This CL fixes another instance where parsing a nested function modifies the parser state of the function that is being compiled.

When a local function gets compiled the second time, constant
expressions may not be parsed again, since the constant value
is found in the cache. If the expression refers to an outer
variable, it does not get captured correctly.

Fix: instead of parsing a local function repeatedly to capture
outer variables, use the local function’s context scope to mark
outer variables as captured. This fixes the bug, and makes the
compiler more efficient as well.

BUG= 26453
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2010283004 .
2016-05-27 11:27:10 -07:00
Florian Schneider 80d6af1e0c Revert "Fix capturing variables in optimized compilations"
This reverts commit 4dca5d0e01.

It seems to cause at least one additional test failure:

Repro:
    python tools/test.py -mrelease -asimarm64 --write-debug-log --write-test-outcome-log --copy-coredumps -cprecompiler -rdart_precompiled --exclude-suite pkg -t480 language/async_star_regression_fisk_test

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2004373004 .
2016-05-25 13:30:24 +02:00
Matthias Hausner 4dca5d0e01 Fix capturing variables in optimized compilations
Third attempt. A latent bug in finally block inlining
caused the previous crashes in optimized functions.
Fix is in https://codereview.chromium.org/2004883004/.

When a local function gets compiled the second time, constant
expressions may not be parsed again, since the constant value
is found in the cache. If the expression refers to an outer
variable, it does not get captured correctly.

Fix: instead of parsing a local function repeatedly to capture
outer variables, use the local function’s context scope to mark
outer variables as captured. This fixes the bug, and makes the
compiler more efficient as well.

BUG=26453
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2008043002 .
2016-05-24 14:40:52 -07:00
Vyacheslav Egorov 655bc90489 Enable optimizer pipeline for DBC.
Most of the infrastructure is fixed to work with DBC stack layout:

- register allocator allocates DBC registers with the limitation that we allocate only 20 registers and bail out if anything needs spilling (there is no use implementing spilling on DBC because registers are memory locations themselves). We should be able to bump number of CPU registers on DBC up to 256 but this requires major surgery in some parts - so I postponed this;
- lazy deoptimization is implemented, eager deoptimization is not - because we don't emit any code that actually requires it. it's a minor change to support it once we have a target;
- stack scanning respects stack maps built by registers allocator;

We bailout from all unsupported instructions.

R=zra@google.com

Review URL: https://codereview.chromium.org/1992963002 .
2016-05-24 14:35:50 +02:00
Kevin Millikin f26e70ad3e Remove the LoadLocal used at the end of a temp local scope.
The previous pattern was:

1. FP-relative load of the top of the stack
2. Push #1
3. Pop
4. Pop
5. Push #3

Where #5 was omitted when the value was unused.

The new pattern is:

1. Pop
2. Push #1

Where #2 is omitted when the value is unused.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1963683003 .
2016-05-20 12:40:10 +02:00
Matthias Hausner b4e6c9d8f0 Revert "Fix capturing variables in optimized compilations"
This reverts commit 117693961f.

BUG=

Review URL: https://codereview.chromium.org/1991533002 .
2016-05-17 16:31:02 -07:00
Matthias Hausner 117693961f Fix capturing variables in optimized compilations
Second attempt, this time also capturing hidden variables
like 'this' in initializer lists. Original CL is
https://codereview.chromium.org/1980193002

When a local function gets compiled the second time, constant
expressions may not be parsed again, since the constant value
is found in the cache. If the expression refers to an outer
variable, it does not get captured correctly.

Fix: instead of parsing a local function repeatedly to capture
outer variables, use the local function’s context scope to mark
outer variables as captured. This fixes the bug, and makes the
compiler more efficient as well.

BUG=26453
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1986393002 .
2016-05-17 15:59:42 -07:00
Ryan Macnak 01e023263e Revert "Fix capturing variables in optimized compilations"
This reverts commit 3968005cc8.

Broke optimization counter and precompilation bots.

TBR=hausner@google.com

Review URL: https://codereview.chromium.org/1985103002 .
2016-05-17 10:05:07 -07:00
Matthias Hausner 3968005cc8 Fix capturing variables in optimized compilations
When a local function gets compiled the second time, constant
expressions may not be parsed again, since the constant value
is found in the cache. If the expression refers to an outer
variable, it does not get captured correctly.

Fix: instead of parsing a local function repeatedly to capture
outer variables, use the local function’s context scope to mark
outer variables as captured. This fixes the bug, and makes the
compiler more efficient as well.

No wall-time improvement found when running dart2js, though.

BUG=26453
R=regis@google.com

Review URL: https://codereview.chromium.org/1980193002 .
2016-05-16 15:53:00 -07:00
Florian Schneider f54c8d89fa VM: Remove PushTempInstr, simplify SSA renaming.
BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1950553002 .
2016-05-04 10:54:03 +02:00
Zachary Anderson 5d7ecb8500 Adds LoadClassIdInstr to DBC
R=iposva@google.com, vegorov@google.com

Review URL: https://codereview.chromium.org/1922173003 .
2016-05-02 09:02:22 -07:00
Florian Schneider 1217e539e9 VM: Remove _leftShiftWithMask32.
It was used for the Javascript integer overflow warnings which were already
removed from the VM.

BUG=
R=regis@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1900863004 .
2016-04-19 19:06:53 +02:00
Vyacheslav Egorov ee0f608ce4 Dart Byte Code interpreter.
This version is Clang/GCC only and does not support Windows because it uses computed goto's.

Only unoptimized mode is supported.

Architecture is described in constants_dbc.h and stack_frame_dbc.h.

R=fschneider@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1858283002 .
2016-04-18 23:02:01 +02:00
Ivan Posva 5be5d54529 - Refactor Symbol allocation to expect a thread parameter.
- Preallocate all tokens as symbols to avoid repeated lookups.
- Pass thread/zone where useful while doing this change.
- Avoid allocating symbols for error messages.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1870343002 .
2016-04-11 16:28:29 -07:00
Ryan Macnak 34e4107c0d Add flag to disable string externalization, allowing the compiler to rely on string class checks remaining valid across calls.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1859273002 .
2016-04-07 13:24:44 -07:00