Commit Graph

82 Commits

Author SHA1 Message Date
Ryan Macnak e48ad45fbd [vm, interpreter] Enable field guards.
Bug: https://github.com/dart-lang/sdk/issues/36131
Change-Id: I8aa538bc96d10d14322c875228dbd7a97ddf114b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95491
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-03-07 00:19:40 +00:00
Vyacheslav Egorov ddbe22190c [vm/compiler] Refactor representation of stores and loads in IL.
Make StoreIntanceField and LoadField instructions use a single uniform
abstraction: Slot (used to be called NativeFieldDesc), which represents
either a real Dart field (i.e. a field that has a corresponding Field object)
or a native VM field that does not have a corresponding Field object.

This refactoring eliminates raw stores/loads that were just using offsets
before - now we always know what kind of slots we are accessing and
this yields better aliasing information.

Change-Id: I2f48332d58258219565bd961764e8cc9dd4d75ce
Reviewed-on: https://dart-review.googlesource.com/c/74582
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-16 17:57:29 +00:00
Martin Kustermann 0a8b236159 [VM] Make the encoding of variable descriptors use variable indices
This decouples the scope building from knowing about frame layout.

Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I9058b242fb24f859f54d6e3660a5972df86d39e6
Reviewed-on: https://dart-review.googlesource.com/59093
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-11 09:55:54 +00:00
Martin Kustermann a603635b85 [VM] Decouple frontend from frame layout
So far the frontend (parser, flow graph builder, ssa construction) were
aware of the actual frame layout.

This CL makes the indices we assign to [LocalVariable]s logical
indices, assigning:

  * M parameters the indices      1 ... M
  * N local variables the indices 0 -1 ... -(N-1)

The scope building, flow graph builder and ssa construction operate on
those logical indices.

When emitting actual code, the backend will translate those indices into
actual FP relative indices. This allows us to be more flexible in the
backend which frame layout we choose.

Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I9a504bf97821c257aafd2b3430df9f4c9da4b442
Reviewed-on: https://dart-review.googlesource.com/57321
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-07 11:35:58 +00:00
Samir Jindel 23c8c4d101 [vm/kernel] Pass type variables through ActivationFrame for expression compilation.
Fixes https://github.com/dart-lang/sdk/issues/32376.

Change-Id: I37bbda2dbc6052925aa840865c62a170604c6cdd
Reviewed-on: https://dart-review.googlesource.com/44784
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-05-17 13:59:57 +00:00
Samir Jindel 7e64ddd00f [kernel/vm] Update closure conversion to work in Dart 2.
The change to vm.dart which turns it on by default will *not* be committed.

Change-Id: Ia3a80ff8e5335aa326f1ffaa9f5c9728ad511b60
Reviewed-on: https://dart-review.googlesource.com/51721
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-04-19 16:04:08 +00:00
Martin Kustermann cf1de7d46c [VM] Replace hand-written assembly prologues with IR
As part of the prologue changes we get rid of the empty context as well.

Issue https://github.com/dart-lang/sdk/issues/31495

Change-Id: I707e23c631bcfbbad6c91c4963d0c10f7a0be625
Reviewed-on: https://dart-review.googlesource.com/25320
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-13 16:04:34 +00: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
Régis Crelier a62107cfaf Check for a passed-in type argument vector in the prolog of generic functions.
Do this in unoptimized code only, when --reify-generic-functions is specified.
This is still work in progress, and support in optimizer, in inliner, in DBC,
in kernel to ir, and other areas, will follow.
Many small fixes and added todos.

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

Review-Url: https://codereview.chromium.org/2941643002 .
2017-06-21 09:02:16 -07: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
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
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
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
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
Vyacheslav Egorov f67ce21068 VM support for running Kernel binaries.
BUG=
R=asiva@google.com, fschneider@google.com

Review URL: https://codereview.chromium.org/2411823003 .
2016-10-15 22:48:46 +02:00
Matthias Hausner 1859ce46c3 Fix finally clause inlining for forward jumps
In switch statements, ‘continue L’ jumps can refer to a label
that the compiler hasn’t seen yet. The label is tentatively
to be in the innermost switch statement, but may later
be moved to an outer switch statement. The compiler must
make sure that the correct finally blocks are inlined in front
of these jumps.

BUG=26577, 25310
R=regis@google.com

Review URL: https://codereview.chromium.org/2030763002 .
2016-06-02 09:03:49 -07:00
John McCutchan d77d376124 Replace intptr_t with TokenDescriptor
- Use TokenDescriptor instead of intptr_t for all token positions.
- Use TokenDescriptor in raw_object instead of int32_t.
- TokenDescriptor is a POD with an int32_t (this shrinks the size of AST and IR nodes by 32-bits on 64-bit architectures).

There are some cleanups I plan on doing as a follow up CL:

- Replace TokenDescriptor::value() with TokenDescriptor::TokenPos()

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

Review URL: https://codereview.chromium.org/1644793002 .
2016-02-02 10:15:44 -08:00
John McCutchan 77101d63e3 Source positions for constructors and lots of async machinery
- Rework token position address space.
- Use ClassifyingTokenPositions::kMethodExtractor for the token position of a method extractor.
- Plumb token positions through all of Ast Transformer.
- Plumb token positions for temporary expressions, etc in Flow Graph Builder.
- Add token positions for parts of the await machinery.
- Move ClassifyingTokenPositions into token.h.
- Remove default token position of Scanner::kNoSourcePos for many IR instructions.
- A couple of unit tests.
- Use synthetic token positions for synthetic AstNodes.
- Fix SLEB128 encoding / decoding + test
- s/Scanner::kNoSourcePos/Token::kNoSourcePos.
- Remove >= 0 and < 0 checks against token positions and use helpers instead.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1589643002 .
2016-01-19 15:01:08 -08:00
John McCutchan cb8b641cc9 Make Scanner::kNoSourcePos be a true sentinel value
- It is possible to write a Dart program with a function token_pos of 0.
- Switch Scanner::kNoSourcePos from 0 to -1.

R=hausner@google.com

Review URL: https://codereview.chromium.org/1564493002 .
2016-01-06 09:06:28 -08:00
Florian Schneider 4a037f0ccb VM: Use read-only handle Object::dynamic_type() where possible.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1528873002 .
2015-12-16 11:31:53 +01:00
Ryan Macnak d7b46bf5c1 Don't use a special var descriptor for :async_op since it can now be either stack or context allocated.
BUG=http://dartbug.com/24439
R=regis@google.com

Review URL: https://codereview.chromium.org//1361423004 .
2015-09-25 13:47:41 -07:00
Regis Crelier 1abc4ce8e9 Reduce the number of captured variables in async code, by only capturing local
variables that are in scope at each await location.

R=hausner@google.com

Review URL: https://codereview.chromium.org//1308163006 .
2015-09-02 18:29:32 -07:00
Siva Annamalai 6b2ae767fd Changes to prepare for allowing script snapshots to be taken after running the main application
- Create singleton empty context scope object
 - Add an implicit field in the context scope so we can distinguish implict context scope objects
 - Allow serialization of extractor_parameter_types, extractor_parameter_names

BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org//1323813004 .
2015-08-31 15:41:41 -07:00
Regis Crelier e6225bee44 Improve async code in VM by not unnecessarily capturing parameters of async and
sync closures, thereby avoiding copy of parameters on entry.
Remove variable aliases in local scopes now that another mechanism detects
use-before-define cases. Keep aliases only for captured variables of outer
functions thereby speeding up scope lookups for all Dart code (not just async).
The next step will be to try to reduce the number of captured variables in
async code.

R=hausner@google.com

Review URL: https://codereview.chromium.org//1317213003 .
2015-08-27 16:49:07 -07:00
Regis Crelier a799659bcf Use correct scope to lookup saved async context variable.
Stop inserting aliases in all intermediary scopes for explicitly captured
variables.
Use proper lookup function in async code to access async completer variable.
Add asserts verifying async variables existence.

R=hausner@google.com

Review URL: https://codereview.chromium.org//1314993002 .
2015-08-25 15:46:17 -07:00
Regis Crelier 6d6a6a49b6 Clean up code capturing variables explicitly.
R=hausner@google.com

Review URL: https://codereview.chromium.org//1284103008 .
2015-08-17 16:09:42 -07:00
Ryan Macnak 0979a7b23e Async-step, first cut.
Also fix inclusion of internal variables from outer scopes in var descriptors.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1241673003 .
2015-07-16 13:05:37 -07:00
regis@google.com 92ceea613e Fix generation of context level descriptors (issue 22391).
R=hausner@google.com

Review URL: https://codereview.chromium.org//1026963002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44621 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-21 00:14:00 +00:00
regis@google.com ed1eb1d7bc Add a flag controlling context sharing.
R=iposva@google.com

Review URL: https://codereview.chromium.org//1028473002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44608 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-20 19:58:08 +00:00
regis@google.com 3783f349dc Be less aggressive in sharing contexts between scopes so that sibling contexts
cannot appear in nested node sequences (issue 22858), since this case cannot
be handled by the graph builder.
Add assert to graph builder to detect such occurences (uncovered async* bug).
Fix an async* issue where a scope was mistakenly reused.
Improve ast printing for node sequences.
Add regression test.

R=hausner@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org//1020893004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44592 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-19 22:39:46 +00:00
fschneider@google.com 7bec3edaef Remove saving/restoring of the context at function entry.
This is not needed anymore after I changed the current context
to always reside in a local variable.

Further simplifications and cleanup in the debugger.

This also fixes a bad memory retention problem with
non-capturing closures.

BUG=dartbug.com/18886
TEST=tests/language/vm/closure_memory_retention_test.dart
R=hausner@google.com

Review URL: https://codereview.chromium.org//695483003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41433 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-31 07:35:51 +00:00
fschneider@google.com 876193b31a Make CTX allocatable by the register allocator.
This change makes CTX available by not caching the current
context while in Dart code. Instead the current context
is held in a local variable (:saved_current_context_var) and
is passed as argument in CTX at calls.

This also simplifies a lot of code in the debugger: As a result,
Isolate::top_context is not needed anymore since the current context
can always be extracted from a Dart frame.

R=vegorov@google.com

Review URL: https://codereview.chromium.org//678763004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41422 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-30 15:42:38 +00:00
hausner@google.com d8a70f2932 Save more memory by compacting LocalVarDescriptors
(Re-landing this change after assertions fixed.)

Instead of allocating an array for the names of local variables,
store the names in the LocalVarDescriptors structure directly.

Using dart2js to compile a small dart program results in about 7200
LVDs on the heap.

Retained memory before: 568KB
Retained memory after: 432KB (75%)

R=asiva@google.com

Review URL: https://codereview.chromium.org//577443003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40276 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-15 21:34:58 +00:00
hausner@google.com 2f2cedfa42 Optimize LocalVarDescriptor objects for functions that have no local variables
Allocate a canonical “empty” variable descriptor object. Saves about 10% of
variable descriptor space when running dart2js.

R=asiva@google.com

Review URL: https://codereview.chromium.org//565513002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40158 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-11 16:08:59 +00:00
zra@google.com c686b2c624 Finishes removing intptr_t from raw object fields.
Also removes {Read,Write}IntptrValue from the snapshot reader and writer.

R=asiva@google.com

Review URL: https://codereview.chromium.org//343803002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40048 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-09 19:51:22 +00:00
mlippautz@google.com 7c7919f8ef Await it!
Add support for awaiting futures. This leaves us with a non-structural CFG.

TODOs:
* Forwarding exceptions through futures in async functions and rethrowing them using await.
* Known bug with nested contexts (will be fixed in following CL)
* await is not recognized at all expressions specified (yet)

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

Review URL: https://codereview.chromium.org//484933003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39559 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-26 17:35:56 +00:00
regis@google.com 38319b0f33 Fix issue 18435 (2nd attempt).
Add regression test.

R=hausner@google.com

Review URL: https://codereview.chromium.org//293013005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36402 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-21 00:32:32 +00:00
regis@google.com 8d7bc4bef5 Revert bad fix.
Review URL: https://codereview.chromium.org//288343005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36365 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-20 17:03:10 +00:00
regis@google.com 9ae1b1f5e0 Fix issue 18435.
Add regression test.

R=hausner@google.com

Review URL: https://codereview.chromium.org//295803003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36362 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-20 16:41:37 +00:00
turnidge@google.com f8fcc45e3d Save the entry context for a function that has captured loop variables.
BUG=18561
R=vegorov@google.com

Review URL: https://codereview.chromium.org//266783002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35692 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-02 16:14:05 +00:00
iposva@google.com 4c07af2487 - Ensure that all names in local scopes are symbols.
- Avoid calling Equals when comparing names in local scopes.

R=srdjan@google.com

Review URL: https://codereview.chromium.org//190753004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33443 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-07 19:37:04 +00:00
kmillikin@google.com 2a87b7eb94 Simplify the desugaring of catch clauses.
Rather than if/then/continue (where the continue does not match the
semantics of Dart's continue), use if/then/else.  This removes the
unnecessary goto and label as a step toward streamlining support for
jumping in the compiler backend.

R=hausner@google.com

Review URL: https://codereview.chromium.org//63983005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30227 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-13 14:08:11 +00:00
kmillikin@google.com a047e57abc Remove some unused fields from class SourceLabel.
We no longer need assembler labels in the AST.

R=fschneider@google.com

Review URL: https://codereview.chromium.org//55943002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29793 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-04 08:12:12 +00:00
hausner@google.com c96bc29ab5 Compile time error if name is used before variable is declared
Implement proper semantics if a name has been referenced in a
block and later a variable with that same name is declared.

Fix library code that was wrong.

Add new language test, delete a couple of tests that are
outdated, file co19 bug 649.

Dart2js and dart2dart are not yet implementing these compile-time
errors.

R=iposva@google.com

Review URL: https://codereview.chromium.org//51533003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29770 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-01 21:28:31 +00:00
hausner@google.com f3ed73c8da Make hidden initializing formal parameters invisible to the debugger
Fixes issue 13143.

R=regis@google.com

Review URL: https://codereview.chromium.org//23460040

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27505 260f80e4-7a28-3924-810f-c04153c831b5
2013-09-13 21:37:16 +00:00
hausner@google.com 32c1b1e412 Follow-up to capturing instantiator
Add boolean result to CaptureVariable, as suggested by Regis.

Review URL: https://codereview.chromium.org//22678002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25922 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-08 11:22:59 +00:00
hausner@google.com e390ba9871 Fix access to type variables in initializer expressions
Allow initializer expressions to capture type arguments.
This used to crash because the receiver is not accessible
in initializer expressions. We don't need the receiver, we
just need to mark it as captured.

Fixes issue 8847.

R=ahe@google.com

Review URL: https://codereview.chromium.org//22415002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25877 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-07 15:15:02 +00:00
hausner@google.com 3c34f42110 Add debugging info for 'this'
Token range for 'this' was wrong in the debug info, so its value was
not shown in most functions. Fixes issue 11435.

R=regis@google.com

Review URL: https://codereview.chromium.org//18272027

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24762 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-03 23:26:03 +00:00