Commit Graph

329 Commits

Author SHA1 Message Date
Ryan Macnak 2be92b08c2 [vm] Remove more of the Dart 1 compiler.
Change-Id: Ib00e040f44275b9437e7fc622bf285607f4e4124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105681
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-06-12 01:00:29 +00:00
Alexander Markov 0e6b74543c Revert "[vm/kernel] Use GC-tracked ExternalTypedData/TypedDataView for kernel buffers"
This reverts commit ab6aeaa106.

Revert "[vm/compiler] Speed up the compiler part which deals with kernel reading up in DEBUG mode"

This reverts commit b316210d94.

Reason for revert: regression of snapshot sizes (DNO-599).

Original change's description:
> [vm/kernel] Use GC-tracked ExternalTypedData/TypedDataView for kernel buffers
>
> Until now we often leaked kernel buffers (e.g. hot reload buffers) because various
> objects were referencing ExternalTypedData objects pointing into the middle of
> c-allocated memory. This made it impossible for the GC to determine when the last
> reference is gone.
>
> This CL ensures that the actual buffers are *always* made available via
> ExternalTypedData and any inner pointers into it are created via TypedDataViews.
>
> The embedder guarantees to the free kernel buffers it has provided to:
>     - Dart_CreateIsolateFromKernel
>     - Dart_LoadScriptFromKernel
>     - Dart_LoadLibraryFromKernel
>     - Dart_SetDartLibrarySourcesKernel
> on isolate shutdown.
>
> All other kernel buffers will get a finalizer attached, which ensures the
> kernel buffers get freed by the GC once they are no longer referenced:
>     - Kernel blobs for expression evaluation
>     - Kernel blobs for Hot-Reload
>     - Kernel blobs for cc tests
>
> Fixes https://github.com/dart-lang/sdk/issues/33973
> Fixes https://github.com/dart-lang/sdk/issues/36857
> Issue https://github.com/dart-lang/sdk/issues/37030
>
> Change-Id: I1cc410c94c0f4b229413e793728a261afcb10aaf
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103130
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,rmacnak@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I49715d2400f4a5c8806b7d6a2912b7258f671a0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104343
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2019-05-31 22:15:51 +00:00
Martin Kustermann ab6aeaa106 [vm/kernel] Use GC-tracked ExternalTypedData/TypedDataView for kernel buffers
Until now we often leaked kernel buffers (e.g. hot reload buffers) because various
objects were referencing ExternalTypedData objects pointing into the middle of
c-allocated memory. This made it impossible for the GC to determine when the last
reference is gone.

This CL ensures that the actual buffers are *always* made available via
ExternalTypedData and any inner pointers into it are created via TypedDataViews.

The embedder guarantees to the free kernel buffers it has provided to:
    - Dart_CreateIsolateFromKernel
    - Dart_LoadScriptFromKernel
    - Dart_LoadLibraryFromKernel
    - Dart_SetDartLibrarySourcesKernel
on isolate shutdown.

All other kernel buffers will get a finalizer attached, which ensures the
kernel buffers get freed by the GC once they are no longer referenced:
    - Kernel blobs for expression evaluation
    - Kernel blobs for Hot-Reload
    - Kernel blobs for cc tests

Fixes https://github.com/dart-lang/sdk/issues/33973
Fixes https://github.com/dart-lang/sdk/issues/36857
Issue https://github.com/dart-lang/sdk/issues/37030

Change-Id: I1cc410c94c0f4b229413e793728a261afcb10aaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103130
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-05-22 01:23:46 +00:00
Zichang Guo f9402d635a [vm] Get script of closure from owner as parent function may contain wrong script
When a mixin class is created, there might be anonymous closures copied over to the other script.
Previously the script of closure function is the script of its parent function, which is not true in that case.
The solution is to create a patch class as the owner if parent function has a different script object. Return script of owner when query for script of closure function.

Bug: https://github.com/dart-lang/sdk/issues/34841
Change-Id: I53065cbf13f2d0dc8da320993fd3cd425e5c9714
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102226
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-05-20 15:50:54 +00:00
Liam Appelbe b2a3d1c31b Give Field::is_nullable the same consistency check as guarded_cid
Fixes: https://github.com/dart-lang/sdk/issues/36717
Bug: https://github.com/dart-lang/sdk/issues/36717
Change-Id: Ic58b9a004a0bbab91d330c24212ff2d8634c084f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100273
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2019-05-17 17:17:40 +00:00
Alexander Markov 802712795e [vm/bytecode] Cleanup obsolete bytecode format v2
Bytecode format v3 landed March 26 2019 in
https://github.com/dart-lang/sdk/commit/61f0f5bc43aa66252a7a5767316ba2fd29c612de

Change-Id: Id20742e1e04fa53ed4420ec0233302477db0e4be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101880
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-05-08 21:36:39 +00:00
Matthew Dempsky 4ce3aa7af1 [vm] Replace ^= assignments with = where possible
Change-Id: I04ac2e9c4b8bb654b7c660e728be3867aa4e1513
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100923
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
2019-05-01 00:04:44 +00:00
Liam Appelbe 317a075d93 [vm] Fix DEGUG typo and a few other bugs it was hiding.
Bug: https://github.com/dart-lang/sdk/issues/36672
Change-Id: I553623e5ec2d378006f5b3d4e7af8f80ef9b7d72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2019-04-25 16:14:41 +00:00
Ryan Macnak 225516466f [vm, interpreter] noSuchMethod dispatchers as a bytecode.
Change-Id: I0e105a56b733322737b6f22a7641f7c6b8afac79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100283
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-04-24 22:58:35 +00:00
Zichang Guo 2298712d62 [vm] fix position of DebugStepCheck when building break statement in flowgraph
Debugger will retrieve the saved context object when looking for IsAtAsyncJump(). The saved context object does not match the context level if setting breakpoint on "break" statement.
It is because when flowgraph builds break statement, DebugStepCheck was put after context object was restored to its parent. Then activation frame got the parent context when pausing at breakpoint.

Bug: https://github.com/dart-lang/sdk/issues/36622
Change-Id: I07508eb42ab102f9697797ef15f914de8bd1af65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100087
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2019-04-23 19:59:15 +00:00
Ryan Macnak 6d91643073 [vm, interpreter] Handle closure case of invoke-field-dispatchers as bytecode.
This will appear to regress the "interp-only" mode on Golem because it will no longer cheat by inlining into a machine code version of the closure call method.

Bug: https://github.com/dart-lang/sdk/issues/36410
Change-Id: I5daa2cffb6d18b6dd2da61ce08d5bc90092a250a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99561
Reviewed-by: Régis Crelier <regis@google.com>
2019-04-17 21:28:51 +00:00
Ryan Macnak 38049f3cb6 [vm, interpreter] Handle implicit static getters as bytecode.
Handle bytecode without a function in stack trace collection.

Bug: https://github.com/dart-lang/sdk/issues/36410
Change-Id: I828fbc11fb0c7ad617ff7a31f44adb021f9b6edf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99378
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-17 19:48:37 +00:00
Ryan Macnak d9c40462c2 [vm] Rename kImplicitStaticFinalGetter to kImplicitStaticGetter.
This function kind is used for any static field with an initializer. It has nothing to do with whether the field is final.

Change-Id: I3faa2d2d77fd4bbd801624bc0bba88476b8f3cb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99622
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-17 00:47:15 +00:00
Ryan Macnak 144bfdfce6 [vm] Use a separate kind tag for static field initializers.
This is preparation for handling implicit static getters as a bytecode.

Change-Id: Ic9fd186161d900c3b4c0bb773726b0cd0f35451e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99105
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-15 22:54:36 +00:00
Jens Johansen a190a2762b Allow debugger to stop on comparison to null
E.g. trying to set a breakpoint on the if in this code

```
  if (args == null) {
    print("was null");
  }
  // more code below
```

would actually set a breakpoint on the print, and the breakpoint - unless
the argument is null - would never be hit.

Change-Id: I072abb3bf2783e9f36c8d3ac6be4885ca454db94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98663
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2019-04-11 10:32:05 +00:00
Aart Bik 9876e92c7d [dart/vm] Support OSR on non-empty expression stack
Rationale:
This enables OSR even in the presence of block expressions,
which are introduced by the new CFE control-flow collections
and spread operations. Faster is better!

https://github.com/dart-lang/sdk/issues/36421
https://github.com/dart-lang/sdk/issues/36218
https://github.com/dart-lang/sdk/issues/36214

Change-Id: I363a0b0a5becbbd5743f8fb47ff24dcebc0e4d64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98744
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-10 19:40:49 +00:00
Ryan Macnak f819c866e7 [vm, interpreter] Handle method extractors as a bytecode.
Bug: https://github.com/dart-lang/sdk/issues/36410
Change-Id: Ifb803d88456227ce03f43b285b4d950c75ae379e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98947
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-10 18:24:36 +00:00
Daco Harkes 741b1f501f [vm/dbc] Implement CheckNull for DBC and enable optimizations
Closes: https://github.com/dart-lang/sdk/issues/36457

Change-Id: I20277a192456c91ff5d22929e4f4d9856ac6c176
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-simdbc64-try, vm-kernel-linux-release-simdbc64-try, vm-kernel-mac-debug-simdbc64-try, vm-kernel-mac-release-simdbc64-try, vm-kernel-reload-mac-debug-simdbc64-try, vm-kernel-reload-mac-release-simdbc64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98673
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2019-04-10 11:40:16 +00:00
Dmitry Stefantsov 4ab4545ff7 [cfe] Add type and file offset to constant expressions
Closes #36471.

Bug: http://dartbug.com/36471
Change-Id: I5ac294057f2f69f1a8edfdf1106f65908fc257ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98677
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-04-10 09:55:36 +00:00
Alexander Markov 38dbddc90d [vm/bytecode] Add AllocateClosure bytecode
AllocateClosure bytecode is used to convey information about closure
function into an instance allocation site. This allows VM inliner to see
closure function very early at the optimization pipeline and enables
inlining of closure calls.

DeltaBlueClosures in JIT/bytecode mode (--use-bytecode-compiler):
Before: DeltaBlueClosures(RunTime): 1746.5404424083767 us.
After: DeltaBlueClosures(RunTime): 1291.4649496449324 us.

Issue: https://github.com/dart-lang/sdk/issues/36342
Issue: https://github.com/dart-lang/sdk/issues/36429
Issue: https://github.com/dart-lang/sdk/issues/36428
Change-Id: I6e94cdc2eb30110b0651a86bd2bdc40dcdd63207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98439
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-04-05 00:00:13 +00:00
Aske Simon Christensen f63eaab3af [kernel] Add instance creation kernel node.
This is used in constant evaluation to represent const constructor
invocations with unevaluated field values or asserts.

Change-Id: I1d2d60a18f967a4dd195b3b5895db9a126c47803
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98561
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-04-04 12:22:50 +00:00
Aart Bik e64bd9a01a [vm/compiler] Fix incorrect labeling of stack slots
Rationale:
The "unoptimized code" representation is really a stack
machine that pushes and pops arguments. The intermediate
representation did not show the correct labeling for
"temporaries", in particular around push arguments.
This CL fixes that bug, making the human readable form
of the intermediate much easier to understand. Also,
it allows for proper stack depth computations.

First use:
Sharpen condition on OSR points a bit.
Simple control flow collections will now allow OSR.


https://github.com/dart-lang/sdk/issues/36421
https://github.com/dart-lang/sdk/issues/36409

Change-Id: I8be707af08462a22687b355b747ba85e42431ad5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98500
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-03 17:05:26 +00:00
Alexander Markov 61f0f5bc43 [vm/bytecode] Declare members in bytecode
This change replaces kernel AST declarations of fields and functions
with bytecode declarations.

Size of dilp files is reduced by 11-12%.

Startup latency:
Time to the first full frame: 1.945s -> 1.687s
FinalizeClass: 554ms -> 277ms
FinishClassLoading: 296ms -> 156ms

There are following regressions in bytecode mode, which will be fixed
in future:

* dart:mirrors are not supported yet (implementation of mirrors relies
  on reading kernel AST in certain cases).

  As the result, lib_2/mirrors/* tests fail.

* native extensions are not supported yet (annotations on libraries
  and classes in AST are cleaned up as they could reference members
  which are now removed from AST).

  As the result, standalone_2/entrypoints_verification_test test fails.

* language_2/spread_collections/const_error_test/* tests fail
  due to https://github.com/dart-lang/sdk/issues/36286.

Change-Id: I5130f401fd7b84038b136136e7ccc1a6e51b6cea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97561
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-26 21:40:10 +00:00
Ryan Macnak 298dacfef5 [vm] Avoid main thread compilation of implicit accessors.
Main thread compilations: 337 functions / 87.8 ms -> 111 functions / 45.5ms

Change-Id: I64ed6c2aca98c0b3849a9142d698a8a94ed418cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97405
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-03-21 20:18:32 +00:00
Alexander Markov 8f827aef4f [vm/bytecode] Recognize identical() in bytecode flow graph builder
This optimization is performed in AST-based flow graph builder and
it is needed for optimizer to constant fold certain things
(e.g. testing endianness in typed data getters).

Replicating it in bytecode flow graph builder to keep parity with
AST-based flow graph builder.

Bug: FL-203.
Change-Id: Id28bcccc75c5d5184801574dbe10b74b86711d50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97400
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-03-21 18:07:47 +00:00
Alexander Markov d53311866f [vm/bytecode] Support native methods in BytecodeFlowGraphBuilder
Change-Id: I7cd08a36a738c9c74a5c44854b60160484cb9f2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96989
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-03-15 19:17:48 +00:00
Samir Jindel 85f8d3c047 [vm] Build FFI trampolines with IL.
Bugs fixed: dartbug.com/36033, dartbug.com/36034, dartbug.com/36155.

Change-Id: Ic463dd2d299018e03f840ecedc8b7dfa350c6b95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/94860
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-03-15 12:38:54 +00:00
Alexander Markov b1a3629547 [vm] Move receiver variable to ParsedFunction, add ParameterVariable()
This refactoring moves receiver variable (previously known as this_variable)
from ScopeBuildingResult into ParsedFunction, like other special variables.
This is done as ScopeBuildingResult is AST-specific and not available
in bytecode, but certain flow graph builders use receiver variable
(for example to load instantiator type arguments for type arguments
checks).

This CL also introduces convenience ParsedFunction::ParameterVariable()
method to reduce repetitive incantations

  parsed_function->node_sequence()->scope()->VariableAt(..)

to a more readable

  parsed_function->ParameterVariable(..)

Change-Id: I427536abfa412de9916b79cf2e56e06f2f2f1d71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96842
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-03-14 00:25:56 +00:00
Alexander Markov b03db45379 [vm] Decouple flow graph building of dynamic invocation forwarders from kernel reading
Change-Id: I65f8fb5f3817630870e752ecb14ff3fb0506e7ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96711
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2019-03-13 16:14:12 +00:00
Alexander Markov 7c1544898d [vm] Decouple flow graph building of implicit getters and setters from kernel reading
Change-Id: I514fa59e88afaa63f989b9bd373a20ea42d1d0e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96204
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2019-03-11 20:56:21 +00:00
Aart Bik e6f56a8adf [vm/compiler] first vm implementation of block expression
Rationale:
Implementation of control-flow collections is
done through the notion of block expressions.
This is a first implementation to get this
working. It takes a few shortcuts (like disabling
OSR inside block expressions for now) that may be
refined later.

https://github.com/dart-lang/language/issues/78
https://github.com/dart-lang/language/issues/47

Change-Id: I966bf10942075052fcfd9bac00298a179efc551b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/94441
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-03-08 20:48:31 +00:00
Aske Simon Christensen ff55d429f6 [kernel] Collection concatenation nodes.
These arise when the constant evaluator partially evaluates collections
containing spreads or control-flow constructs with unevaluated
subexpressions. They are removed by the final constant evaluation.

Change-Id: Icdd155c4805cbcefe6aa4b45c2f85ec258e7bd36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95760
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-03-08 13:08:55 +00:00
Aart Bik 5c7b07f783 [dart/vm] Fix bug in kernel binary flow graph builder
Rationale:
Found by DartFuzz. One of the trickier bugs I had to debug.
While building the flow graph from kernel, the finalizer
builder expects the program context to be in the same state
as when the finalizer was seen first, not the context seen
by the breaking/continuing statement. This was done partially,
but only partially. Finding loop context or breakable
and switchable blocks was missing. Something only
a fuzzer can find :-)

https://github.com/dart-lang/sdk/issues/36076

Change-Id: Ie63912c5fad4d3c15f6559b60cc102b237949957
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95720
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-03-07 20:16:18 +00:00
Alexander Markov f2a8e71ff9 [vm] Decouple flow graph building of implicit closure functions from kernel reading
Change-Id: I6bf5ad6ed76c363904ae1765d8303eff4a799363
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95706
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-03-07 18:09:48 +00:00
Alexander Markov 51a334caa7 [vm] Remove kernel reading from BuildArgumentTypeChecks
This change is a preparation for decoupling flow graph building of
special functions from kernel reading.

Change-Id: Ied90bc6894cdfa48f49c71e980079967c8c4fbb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95061
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-03-05 18:48:51 +00:00
Aart Bik 571ea80e11 [vm/compiler] added assert to kernel flowgraph builder
Rationale:
Yields a more gentle crash in debug mode for
bug under investigation (found by DartFuzz)

https://github.com/dart-lang/sdk/issues/36076

Change-Id: I497fbef1ec2100b9701848c3454bef5ad7518d2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95280
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-03-04 19:30:53 +00:00
Kevin Millikin c9b8bae4e6 [Kernel] Add BlockExpression to the Kernel language
This is not yet used or tested.

Change-Id: Id050802926ad6452df3c39ace12ea5dd56d4faaa
Reviewed-on: https://dart-review.googlesource.com/c/87970
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2019-02-22 12:38:26 +00:00
Dan Field eb73f132c1 [vm] Add macro for fallthrough annotations
Internal builds in Google are catching this as an error.

I'm guarding it because I assume we might support building using other
compilers.

Change-Id: I665099cace9c6a40d737c471dd1b0fdb326fea39
Reviewed-on: https://dart-review.googlesource.com/c/91162
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-02-15 01:12:01 +00:00
Daco Harkes 7d46d4b5cb [vm / library] Foreign function interface prototype
Prototype for `dart:ffi` on Linux/MacOS x64 in JIT mode.
`dart:ffi` is experimental and its API is likely to change in the future.
Progress and design decisions are tracked in https://github.com/dart-lang/sdk/projects/13


issue: https://github.com/dart-lang/sdk/issues/34452
Change-Id: Ifa4566388e42c8757f154741d11e303465ef305d
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try, vm-kernel-mac-debug-x64-try, vm-kernel-asan-linux-release-x64
Reviewed-on: https://dart-review.googlesource.com/c/80124
Reviewed-by: Samir Jindel <sjindel@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2019-02-13 12:42:47 +00:00
Vyacheslav Egorov f496e538f4 [vm] Decouple assemblers from runtime.
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface. The goal of the refactoring to locate all places where compiler
accesses some runtime information and partion those accesses into two
categories:

- creating objects in the host runtime (e.g. allocating strings, numbers, etc)
during compilation;
- accessing properties of the target runtime (e.g. offsets of fields) to
embed those into the generated code;

This change introduces dart::compiler and dart::compiler::target namespaces.

All code in the compiler will gradually be moved into dart::compiler namespace.
One of the motivations for this change is to be able to prevent access to
globally defined host constants like kWordSize by shadowing them in the
dart::compiler namespace.

The nested namespace dart::compiler::target hosts all information about
target runtime that compiler could access, e.g. compiler::target::kWordSize
defines word size of the target which will eventually be made different
from the host kWordSize (defined by dart::kWordSize).

The API for compiler to runtime interaction is placed into compiler_api.h.

Note that we still permit runtime to access compiler internals directly -
this is not going to be decoupled as part of this work.

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

Change-Id: If4396d295879391becfa6c38d4802bbff81f5b20
Reviewed-on: https://dart-review.googlesource.com/c/90242
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-25 16:45:13 +00:00
Stevie Strickland 23f427b1a7 Reland [VM/Compiler] Removing definition status from Store{Indexed,InstanceField}.
Also do the same for the unsafe version of StoreIndexed.

Similar to the inliner, we may replace calls in the specializers with
these non-definition instructions, so we make variants that allow an
unrelated value to be used for the old users of the call site value. (In
all cases, this ends up being null, since the original calls wouldn't
have returned a useable value anyway.)

Change-Id: I0befd54920c4c0e63e086b804860ee4c9a7d3767
Reviewed-on: https://dart-review.googlesource.com/c/89585
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Stevie Strickland <sstrickl@google.com>
2019-01-15 17:23:21 +00:00
Vyacheslav Egorov 02b1658f59 Revert "[VM/Compiler] Revoke definition status of certain instructions."
This reverts commit a8777149a7.

Reason for revert: benchmarking infrastructure reports broken benchmarks on ARM.

Original change's description:
> [VM/Compiler] Revoke definition status of certain instructions.
> 
> Change StoreIndexed, StoreIndexedUnsafe, and StoreInstanceField
> to be non-definition instructions. Fix up the flow graph builders
> so they no longer treat StoreIndexed and StoreIndexedUnsafe as
> pushing values on the stack that need to be dropped.
> 
> We recently changed FlowGraphInliner::TryInlineRecognizedMethod
> to create a distinction between the last instruction to be inlined
> and the definition that should be used as the new result. Perform
> the same separation of replacement code and result in the call
> specializers.
> 
> Change-Id: I66c7ab60a662dcca05092e47156d1d4ba809d51f
> Reviewed-on: https://dart-review.googlesource.com/c/88326
> Commit-Queue: Stevie Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,sstrickl@google.com

Change-Id: I9c666d80a69ba6a5c37b421aae1ed83502694f19
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/89366
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2019-01-14 18:50:29 +00:00
Stevie Strickland a8777149a7 [VM/Compiler] Revoke definition status of certain instructions.
Change StoreIndexed, StoreIndexedUnsafe, and StoreInstanceField
to be non-definition instructions. Fix up the flow graph builders
so they no longer treat StoreIndexed and StoreIndexedUnsafe as
pushing values on the stack that need to be dropped.

We recently changed FlowGraphInliner::TryInlineRecognizedMethod
to create a distinction between the last instruction to be inlined
and the definition that should be used as the new result. Perform
the same separation of replacement code and result in the call
specializers.

Change-Id: I66c7ab60a662dcca05092e47156d1d4ba809d51f
Reviewed-on: https://dart-review.googlesource.com/c/88326
Commit-Queue: Stevie Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-14 15:45:03 +00:00
Alexander Markov 3b29f5ad81 [VM/AOT/TFA] Do not attribute calls via fields/getters with inference results
MethodInvocation nodes which have field or getter as interface target
actually correspond to 2 calls: 1) getter; 2) implicit call() on the result
of the getter.

While this was correctly modeled in summaries in TFA, it is not correct
to attribute such MethodInvocation nodes with results of the inference,
as results correspond to an each distinct call. To fix this, Call
statements in summaries are created without attaching them to a
corresponding kernel AST node.

Change-Id: I3ea28ed85550192f8b592a926cac0eae23810811
Reviewed-on: https://dart-review.googlesource.com/c/88424
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-07 10:22:40 +00:00
Alexander Markov 0e65e45e9e [vm/compiler] Do not use interface target for calls via getters
For calls via getters and fields front-end generates MethodInvocation
node with interface target pointing to a getter/field.
Such target doesn't fully represent what is being called - it should
be implicitly chained by call(), so it is incorrect to use such
interface target for type propagation.

Change-Id: I76198b443474fdcb383671fbc9946b4938a4e1df
Reviewed-on: https://dart-review.googlesource.com/c/88260
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-01-03 22:03:13 +00:00
Régis Crelier cb8c0ab8f5 [vm] Remove MixinAppType VM class and VM code supporting type resolution.
In Dart2, mixin application classes are generated by kernel and type resolution
is performed by kernel. In Dart1, using the VM parser, these tasks were done
during class and type finalization.

Change-Id: I927b1446d906ffd76ed9591c96e0d974df09f3bf
Reviewed-on: https://dart-review.googlesource.com/c/87025
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-12-13 20:18:36 +00:00
Samir Jindel ae3a33bd79 [vm/aot] Fix issues with multiple entry-points.
- We can now skip checks on tearoffs of functions called only via tearoffs.
- We don't always insert a check when intrinsifying the an unchecked call to set indexed.
- We only build the unchecked entry-point of regular methods when inlining to reduce code size.

Change-Id: I2e6a647409130385cda03906e734a3c161d56ab4
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-release-x64-try, vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/86562
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-13 16:13:50 +00:00
Régis Crelier 5f36c5f9d8 [vm] Delete BoundedType class in VM.
In Dart2, type bounds checking is either performed by the common front-end or
by explicitly generated code, but not by type finalization or runtime anymore,
as it was done in Dart1.
Consequently, the class BoundedType is not needed anymore, and malbounded or
malformed types are not seen by the runtime either.

Change-Id: I5d6e4c68d153d6730fa7ff7f6d9dcfa611299c16
Reviewed-on: https://dart-review.googlesource.com/c/86687
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-12-10 23:15:27 +00:00
Samir Jindel 921e62f1bf [vm] Introduce multiple entrypoints to AOT.
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-release-x64-try, vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-win-release-x64-try
Change-Id: I8643033febf9bdc57c8298dca5f43346fb8bf6d1
Reviewed-on: https://dart-review.googlesource.com/c/80304
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-12-07 13:19:24 +00:00
Alexander Aprelev 2bf29f6244 [kernel] Avoid reporting token position on InvalidExpression.
Source line information is part of the message from the frontend itself already. Including it here results in double-reporting of the source line quote.

Bug: https://github.com/dart-lang/sdk/issues/35239
Change-Id: I4b2c88900ac029982ed08102ce37e87f8f83d180
Reviewed-on: https://dart-review.googlesource.com/c/86243
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2018-12-06 16:55:26 +00:00