Commit Graph

153 Commits

Author SHA1 Message Date
Vyacheslav Egorov 2c97d724df [VM, JIT] Lower CloneContext into AllocateUninitializedContext.
CloneContext is implemented as a runtime call so it is considerably slower
than AllocateContext which leads to performance issues in loops that capture
iteration variables in for loops.

Lowering CloneContext into AllocateUninitializedContext and a sequence of
explicit load&store instructions both improves the performance by avoiding
the runtime call and also makes CloneContext semantics exposed to store-load
forwarding and allocation sinking.

PutIfAbsent benchmark from issue #31113 is improved by 5x, while 
ForInGeneratedLoop benchmark is improved by 8x.

Bug: https://github.com/dart-lang/sdk/issues/31113
Change-Id: I03fdede75f1a85fda92487aa8f9307ce06f23903
Reviewed-on: https://dart-review.googlesource.com/16280
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2017-10-25 11:09:29 +00:00
Alexander Aprelev ce427ac14f Revert "Revert "Introduce StaticCallNode::kNoRebind and use that in implicit closures.""
This reverts commit ade37f931e.

This re-lands RebindRule change with fixes for the "-mdebug--hot-reload" test failures.

Original commit is reverted in patch set 1.
Fixes are in following patch sets.

Bug:
Change-Id: I49375af9b891323fe05c670d77cbf880964aae54
Reviewed-on: https://dart-review.googlesource.com/9361
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2017-09-28 19:43:32 +00:00
Dmitry Stefantsov ade37f931e Revert "Introduce StaticCallNode::kNoRebind and use that in implicit closures."
This reverts commit 97393fd961.

TBR=aam@google.com

Change-Id: I8fc5f644e994faa20aa8b5c54f8d6227a054e39d
Reviewed-on: https://dart-review.googlesource.com/9220
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2017-09-28 08:44:48 +00:00
Alexander Aprelev 97393fd961 Introduce StaticCallNode::kNoRebind and use that in implicit closures.
Change-Id: I6219462fed278dbb90361c2084eed886c9245097

Revert "Revert "Introduce inline cache reload rule attribute to static call AST node and ICData.""

This reverts commit 162283c2f3.

This re-lands the change with original revert in Patch set 1, actual bug fix in next patch set.

Bug:
Change-Id: I6219462fed278dbb90361c2084eed886c9245097
Reviewed-on: https://dart-review.googlesource.com/8760
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2017-09-28 03:26:22 +00:00
Alexander Aprelev 162283c2f3 Revert "Introduce inline cache reload rule attribute to static call AST node and ICData."
This reverts commit 68a727fa5c.

Revert "Fix ICData::New() invocation. Follow-up to 68a727fa5cf5."

This reverts commit ac06b1c8ea.

Revert "Fix last ICData::New() invocation. Follow-up to 68a727fa5cf5."

This reverts commit da26ffc4de.

Bug:
Change-Id: Ia2d4e6a3c3a3a329982c90aded11e72bf25a9a34
Reviewed-on: https://dart-review.googlesource.com/8402
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2017-09-26 02:08:17 +00:00
Alexander Aprelev 68a727fa5c Introduce inline cache reload rule attribute to static call AST node and ICData.
Reload rule describes how inline cache has to be processed during hot reload, whether it should
be updated, reset or preserved.

Bug: dartbug.com/30639
Change-Id: I40b63ade786456ec48d4fa205a076654c2996bce
Reviewed-on: https://dart-review.googlesource.com/7586
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2017-09-25 20:18:58 +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
Régis Crelier 9aafded095 Pass type argument vector to generic functions (if --reify-generic-functions is
true, still false per default).
Work in progress, not functional yet (passed vector is still ignored in callee).

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

Review-Url: https://codereview.chromium.org/2859673002 .
2017-05-18 14:03:47 -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
Florian Schneider 67a93da99e Handle type literals correctly with deferred loading and await.
When referring to constants via a deferred prefix in an await expression
the transformation must make sure that the generated code before and after
the deferred load agree on the number of captured variables. (i.e. the number
of await-temp variables introduced by the await-transformer is the same)

This CL uses a temporary in the case of compile-time constants, because before
the deferred load, a reference lib.C is translated into a static getter which
also requires a temporary.

Fixes #28678

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2683973002 .
2017-02-08 15:37:39 -08:00
Florian Schneider 9c82d88d67 VM: Fix bug in deferred loading.
In some cases when loading a deferred library twice, the VM would crash/throw.

Make sure we generate the correct static NoSuchMethod error when referring to
a deferred library that is not loaded yet.

Fixes #28278.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2618823002 .
2017-01-05 18:20:51 -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
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
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 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
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
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
Regis Crelier 508b876ec8 Report wrong async function result type as type error in checked mode (Fixes #26133).
Add regression test.

R=hausner@google.com

Review URL: https://codereview.chromium.org/1847953002 .
2016-05-09 15:06:45 -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
Srdjan Mitrovic 5a69e3661b In background compilation make a copy of Field in order to freeze its state. Add flag --force_clone_compiler_objects for debugging purpose.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1722733002 .
2016-02-26 09:07:49 -08:00
Regis Crelier 3ffe9922b7 Simplify various name flavors in VM.
R=asiva@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1723733002 .
2016-02-25 11:21:27 -08: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
Lasse R.H. Nielsen 693628e99e Implement ?? as compile-time constant in VM.
Extracted from https://codereview.chromium.org/1493693002/

R=hausner@google.com

Review URL: https://codereview.chromium.org/1575383002 .
2016-01-22 12:39:16 +01: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 bda2b3d2ff Source position tests for switch and try catch finally
- Give AwaitMarkerNode a token position.
- Make it possible to provide a token position for SaveContext, RestoreContext, StoreContext, and CurrentContext.
- Pass in a token position to internally generated StoreLocal and LoadLocal instructions for try-catch-finally.
- Introduce a Context ClassifyingTokenPosition to be used when we can't attribute a context related instruction to a source position.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1575953005 .
2016-01-12 15:02:35 -08:00
Florian Schneider e9968ca5ff Fix VM bug with try-catch inside of try-finally.
There were two exception handlers with the same index added to the code so that only the one added
last was executed. In case of an exception that means that a re-throw may be omitted, causing invalid
control flow.

Also, add assertion to ensure unique try-index for exception handlers.

BUG=#25333
R=hausner@google.com

Review URL: https://codereview.chromium.org/1569523002 .
2016-01-06 18:50:53 +01: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 46f3e7bfe7 VM: Reduce size of AST-nodes vtables.
Make Is## methods of AST nodes non-virtual, like we do for IL instruction nodes.

This saves around 10k in vtables on ia32.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1482153006 .
2015-12-02 13:38:26 +01:00
Matthias Hausner 29e8118403 Handle potentially const interpolation
Fixes issue reported in 24970. As with all analysis for "potentially constant" expressions, this fix is too permissive. (See issue 392 for details.)

BUG=24970
R=iposva@google.com

Review URL: https://codereview.chromium.org/1455213002 .
2015-11-30 14:37:49 -08:00
Srdjan Mitrovic 181e8cc2a9 Move resolving of natives to a late stage (during code emission). That eliminates unnecessary native resolution (e.g., when native gets recognized or rejected in the inliner). Removed tests that are now impossible to implement with AST (fake native functions).
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org/1420173006 .
2015-11-03 16:18:24 -08:00
Regis Crelier 451eaab718 Remove --supermixin flag from VM.
Update tests and test status files.

Fixes #24479.

R=hausner@google.com

Review URL: https://codereview.chromium.org/1383923002 .
2015-10-01 18:04:31 -07:00
Siva Annamalai 79ef28317f Changes to prepare for allowing script snapshots to be taken after running the main application:
- Rename accessors of class Field to make it more apparent as to what is being accessed (static field values or instance field offsets
- Use precompiled initializer state (Used only during precompilation) to also store saved initial value of static fields (Used only during application snapshot   generation)

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

Review URL: https://codereview.chromium.org//1289643005 .
2015-09-04 11:03:46 -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
Florian Schneider c05f1f9448 VM: Link native calls lazily.
The first invocation of a native functions goes into LinkNativeCall which
determines the final entry point and patches the object pool entry.

When running precompiled code, this makes deserializing the object
pool entries for native functions easy, they all initially point to
a single entry (LinkNativeCall).

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1294113004 .
2015-08-21 11:37:50 +02:00
Matthias Hausner 0535e37619 Implement ?? ??= and ?. operators
BUG=23455
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1180903002.
2015-06-18 11:05:16 -07:00
Regis Crelier 4bf6db0c25 Adjust context level when required before executing inlined finally clauses.
Add regression test.

BUG=23537
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1154823003
2015-06-03 10:31:48 -07:00
hausner@google.com 21ca62f8bc Properly resolve top-level setters
Fixes issue 4386.

When converting a getter to a setter (converting a right-hand
side expression to a left-hand side, assignable entity),
we need to know where to look for the setter function.
Top-level setters need to be resolved in the library or prefix
scope in which the getter was found.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45316 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-21 17:36:34 +00:00
regis@google.com 9a2468736a Add support for debug break in Dart source.
The new flag --enable-debug-break turns the otherwise illegal Dart statement
  break "message";
into a break instruction preceded with a debug message, the equivalent of
emitting an Assembler::Stop("message").
Add a language test expecting a syntax error without the flag.
Change expected break instruction in arm64 simulator.
Remove constants related to now deleted simulator tracing on mips and arm64.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45218 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 19:32:48 +00:00
hausner@google.com c9400962f7 Cleanup obsolete setter code
Early on in Dart, it was ok to have a static getter and dynamic setter
with the same name. This is no longer the case. Remove code that handles
the obsolete case.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45122 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-13 21:23:10 +00:00
regis@google.com 8b73c2a3e5 Simplify restoring of saved try contexts in async code by passing around the
relevant variables instead of scopes and try indices.

R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45081 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-10 22:15:00 +00:00
hausner@google.com 8c49660a7e Make await for cancel the stream when breaking out of the loop
Wrap the await-for loop in a try-finally statement that ensures that
the stream is cancelled. Also adding the ability to the
AsyncStartStreamController class to return a cancellation future.

The cancel() call at the end of the await-for loop is not awaiting
the cancellation future yet. This is not part of the spec at this
point.

R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44689 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-25 17:41:39 +00:00
regis@google.com 8618df1864 One more fix to async machinery (rethrow in finally, issue 22595).
R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44189 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-03 18:34:01 +00:00