Commit Graph

125 Commits

Author SHA1 Message Date
Alexander Markov 9503969664 [vm/bytecode] Add DebugCheck bytecode instruction
DebugCheck bytecode instruction is generated after parameter variables
are declared and copied into their locations in the prologue.
It helps debugger to stop in the beginning of a function at the point
where parameters can be inspected. It is generated only if
'--bytecode-options=debugger-stops' is specified.

Change-Id: I0f3b1ea8dc45d762a5dcee75b5d3a4ffc0b2a1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108371
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-07-09 19:14:53 +00:00
Régis Crelier 307ca3f3b6 [vm/bytecode] Improve single stepping and breakpoint setting in bytecode.
Modified list of bytecodes that check for debug breaks (wip).
Make sure source positions are not interpreted as return addresses.
Fix skipping of bytecode stub frames when stepping.
Fix DEBUG_CHECK macro to call debugger twice for breakpoint and following step.
Various minor bug fixes and printing improvements.

Change-Id: I36713de0548d060eddb7cbfd6fadb05c731e881a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108205
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-07-09 17:08:39 +00:00
Alexander Markov f91089faaf [vm/bytecode] Add yield point markers to source positions
Issue: https://github.com/dart-lang/sdk/issues/36427
Change-Id: I384161fd27b977e05796666c9a1a1e336d4d6440
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107572
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-06-28 17:13:51 +00:00
Alexander Markov 1eb113ba27 [vm/bytecode] Support native extensions
Change-Id: I224f740db674e20d643191605d0a7463bf85d39f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107451
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-06-27 20:24:25 +00:00
Ryan Macnak 5c1d5444d6 [vm, bytecode] Fix some source position discrepancies.
Fix most cases of accessing metadata; parameter annotations still missing.

Change-Id: Ie78c3d817a86a656548cdc5775f837250a710095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106967
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-06-25 00:57:26 +00:00
Alexander Markov bc8b6fb94d [vm/bytecode] Fix last source position in a function
Change-Id: Id3b9c6476cc3745a39a7010b7ae09d2422467e31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107182
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-06-24 19:25:07 +00:00
Alexander Markov 7c63999e74 [vm/bytecode] Correct scripts for members not from the script of enclosing class/library
This change ensures that fields and functions have correct script if their
script doesn't match script of enclosing class/library.

Change-Id: Icd598707fd8a3d8227b425ecbe3a9f6806c73d7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107060
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-06-24 18:06:38 +00:00
Alexander Markov 37a25d9100 [vm/bytecode] Add a compile-time error if there are too many arguments.
Issue: https://github.com/dart-lang/sdk/issues/37305
Change-Id: I9dac7c1b7b49fca8531ca2bf83b1c309d8217969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106984
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-06-24 16:02:05 +00:00
Alexander Markov f6af8ccba8 [vm/bytecode] Consolidate bytecode generation options
As number of bytecode generation options grows, it becomes cumbersome
to add them and propagate from the place where they are parsed to
the place where they are used. In order to make it easier to
change and add new bytecode generation options, this CL introduces
BytecodeOptions class which consolidates all options for bytecode
generation. Also, command line options --emit-bytecode-*** are gathered
into a single multi-option --bytecode-options=opt1,opt2,...

Also, unused --use-future-bytecode-format option is cleaned up. If needed,
it could be easily re-introduced in the new BytecodeOptions.

Change-Id: I637bf28ceb4233ead2562afe7ad51c69a99f2d60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106965
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-06-21 20:31:38 +00:00
Alexander Markov 0ae10fa68d [vm/bytecode] Support --causal_async_stacks in bytecode generator
Also, standalone_2/causal_async_stack_test is updated to actually
test --causal_async_stacks after Dart 2 sync-async.

Change-Id: I28a7a281963828707461652f19494ff54bdd21c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106760
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-06-20 20:23:37 +00:00
Alexander Markov 5042ff97c7 [vm/bytecode] Add async/async*/sync* attributes to closures
Change-Id: Ibb0f202ada840ee112f46d5db3d8f9459817c358
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106730
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-06-20 20:23:37 +00:00
Alexander Markov da8cb470cc [vm/bytecode] Represent classes, libraries, scripts and recursive types in bytecode
Size of a large application:
Before: 26628600
After: 21480120 (-19.3%)

Size of snapshots:

isolate_snapshot_framework.bin
Before: 9322496
After: 6782976 (-27.2%)

isolate_snapshot_product_framework.bin
Before: 9166848
After: 6602752 (-27.9%)

Regressions in tests:

1) Test language_2/type_alias_equality_test/04 fails similarly to default mode, as VM
does not implement comparison of function types according to the specification.
Previously this test was passing as function types were canonicalized in bytecode,
which was not always correct. This CL fixes the problem with canonicalization of
function types in bytecode and the test starts failing again.

2) Tests standalone_2/entrypoints_verification_test, standalone_2/io/test_extension_test,
standalone_2/io/test_extension_fail_test fail as native extensions are not supported
in bytecode yet. These tests start passing after df5e7aac17,
which switched bytecode tests to kernel service (on x64), because kernel service doesn't
drop ASTs. This CL switches from reading AST library declarations to bytecode even if
AST is not removed, so tests fail again.

Change-Id: I8b7ba44bfa49d0b1599b2509553ff7c831a4e244
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104700
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-06-20 18:27:21 +00:00
Alexander Markov 86ea9ad1e7 [vm/bytecode] Add source positions for more bytecode instructions
Also, correct source position for CheckStack instruction in the prologue of
a closure.

Change-Id: I175e5398296f17a1f67a223d45725206e65e0e8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105040
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-06-05 21:06:56 +00:00
Alexander Markov 372b02d97f [vm/bytecode] Add information about local variables to bytecode
Change-Id: I22bbd3b7ea0cccc0a8d721c3766a80ae1c72060d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/87701
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-05-30 21:21:44 +00:00
Alexander Markov ec4d48e241 [vm/bytecode] Add starting and ending source positions for closures
Issue: https://github.com/dart-lang/sdk/issues/36427
Change-Id: Ib2f55504f9238036a9700f1e2672b4641536ab7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103480
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-05-22 19:02:40 +00:00
Alexander Markov 477ad3c0ea [vm/bytecode] Eliminate asserts from bytecode unless --enable-asserts
Total size of a large app:
Before: 23681504
After: 23207344 (-463K/-2%)

Size of bytecode instructions:

Before: 6282376
After: 5981716 (-4.8%)
Change-Id: I57703616ecc91301c928672c83571482500dc365
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101883
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-05-09 20:41:21 +00:00
Alexander Markov e9bec21d13 [vm/bytecode] Cleanup after switching to compact bytecode instructions
Change-Id: Ie6ecdd88e8d1740c53cfb3fbc4b43f9e41c592b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101491
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-05-08 17:33:15 +00:00
Alexander Markov 68de477535 [vm/bytecode] Compact encoding of bytecode instructions (part 3/3)
Corresponding VM changes:
https://dart-review.googlesource.com/c/sdk/+/101062

On a large app, size of bytecode instructions:
Before: 12115384
After: 6282376 (-48.1%)

Total size of the app:
Before: 29790240
After: 23681504 (-20.5%)

Change-Id: Idd8f97e991236c25d663d1bcf18a51a53e73a2b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99400
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-05-08 17:33:15 +00:00
Alexander Markov 836ace6fcb [vm/bytecode] Avoid recalcualting class hierarchy for each dilp file
Compilation time in package-split mode with bytecode on a large app:
Before: 98 seconds
After: 37 seconds

Issue: b/131915611.
Change-Id: Ibc0ea460c9bb78d33441f91e977a914f97e8ce7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101325
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-05-03 23:34:28 +00:00
Alexander Markov 9cc008e49c [vm/bytecode] Add bytecode instructions for double operations
Change-Id: Ib1e8ca3b9bbf62f8282524fc5599eee5cae38389
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99089
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-04-12 20:17:01 +00:00
Alexander Markov ebd13e891f [vm/bytecode] Add UncheckedInterfaceCall instruction
dart --use-bytecode-compiler NavierStokes.dart
Before: NavierStokes(RunTime): 8909.053017777778 us.
After: NavierStokes(RunTime): 7221.510314079423 us.

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

Change-Id: Ib1be4dd20cdc25e3b979a91a098f67a7bc00df8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98945
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-04-10 21:49:23 +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
Alexander Markov 7c9d02b313 [vm/bytecode] Generate empty list literals more efficiently
Issue: https://github.com/dart-lang/sdk/issues/36429
Change-Id: I47e189bff4e9998123c06afa2e5b0d1c79d74566
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98608
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2019-04-03 23:43:21 +00:00
Alexander Markov 8fb77ec84d [vm/bytecode] Preliminary support for new language features in bytecode
Issue: https://github.com/dart-lang/sdk/issues/36214
Issue: https://github.com/dart-lang/sdk/issues/36218

Change-Id: I39149b82cb93c1cb87c64cf9c41c56b753bba13a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98400
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2019-04-02 19:11:09 +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
Aske Simon Christensen 1ea717f1c9 [CFE] Use Fasta diagnostics in constant evaluator.
The constant evaluator now generates all errors as Fasta diagnostic
messages. The ErrorReporter is simplified to just accept a diagnostic
message, or a notification that the constant evaluator encountered an
invalid expression (presumably put there due to an earlier error).

Also, the flow of control between the error reporter and the internal
abort exceptions is reversed, so the error reporter is now called as a
result of an abort exception being caught by the evaluate method.

Reland of https://dart-review.googlesource.com/c/sdk/+/96300

Change-Id: I7d32b6e98962b6ee781a6c96b593b00ee7fd8a89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97225
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-03-18 15:42:05 +00:00
Aske Simon Christensen c10ee9971f [CFE] Move constant evaluator to Fasta.
Reland of https://dart-review.googlesource.com/c/sdk/+/96081

Change-Id: Ie9e6a0d26703469396fa6ea4803f49ce387f495b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97224
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-03-18 15:42:05 +00:00
William Hesse 3b2e368376 Revert 5 changes with failures
TBR=askesc@google.com

Revert "[CFE] Move constant evaluator to Fasta."

This reverts commit 845b5b2df1.

Revert "[CFE] Always call the constant evaluator by the evaluate method."

This reverts commit 91bc4ec2b9.

Revert "[CFE] Use Fasta diagnostics in the constant evaluator."

This reverts commit c7b572aa29.

Revert "[CFE] Check for null in constant evaluation"

This reverts commit e6d2751e9c.

Revert "Rename import after moving file."

This reverts commit a6e2c5eb4c.

Change-Id: Iadfe087c0110f6f331b82d990213f95d3ef4541b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97223
Reviewed-by: William Hesse <whesse@google.com>
2019-03-18 12:25:32 +00:00
Aske Simon Christensen c7b572aa29 [CFE] Use Fasta diagnostics in the constant evaluator.
The constant evaluator now generates all errors as Fasta diagnostic
messages. The ErrorReporter is simplified to just accept a diagnostic
message, or a notification that the constant evaluator encountered an
invalid expression (presumably put there due to an earlier error).

Also, the flow of control between the error reporter and the internal
abort exceptions is reversed, so the error reporter is now called as a
result of an abort exception being caught by the evaluate method.

Change-Id: I66f148cc4e202e328f895ae0b770f9b68c9f3c8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96300
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-03-18 10:42:14 +00:00
Aske Simon Christensen 845b5b2df1 [CFE] Move constant evaluator to Fasta.
This is in preparation for recognizing Fasta-specific nodes in the
constant evaluator, and for using the Fasta diagnostics framework.

Change-Id: I8535fbb68e622f1814a1d577c348d87e573b6b34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96081
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-03-18 10:42:14 +00:00
Aske Simon Christensen b7afb22323 [CFE] Eliminate redundant coreTypes parameter.
Change-Id: Ie76a70454ef6dd7e60b916e2820c1d4e78b3e88d
Reviewed-on: https://dart-review.googlesource.com/c/92134
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-02-12 09:56:57 +00:00
Alexander Markov 336969538c [vm/bytecode] Revise representation of types, constants and calls in bytecode
* Type arguments are moved to global object table (and de-duplicated).
* Finalize non-recursive generic types at bytecode generation time.
* Constants are moved to global object table (and de-duplicated).
* ICData creation is avoided for direct calls.
* Interface calls reference target member instead of selector name.

Size of a dilp files: 17868K => 15896K (-11%).

Change-Id: I0c9bf338137a0fae6ed90ab6b125ed2b24a1a8ad
Reviewed-on: https://dart-review.googlesource.com/c/91108
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-02-05 20:13:45 +00:00
Aske Simon Christensen 8a45b5eb57 Move environment handling into the front-end constant evaluator.
Change-Id: Id01bad9d9dbb7d5f6104a0f633d8303fecfa29db
Reviewed-on: https://dart-review.googlesource.com/c/91227
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2019-02-04 13:31:30 +00:00
Aske Simon Christensen f066c05319 Rename klass getter on InstanceConstant to classNode
This achieves consistency with similar getters in the API.

This is technically a breaking change, since it changes a published
part of the Kernel API. Since the constants API is relatively new and
so far only used internally in the AOT compiler, the change is
expected to be unproblematic.

Closes https://github.com/dart-lang/sdk/issues/35696

Change-Id: I3ca30922580d226ccbdb6f77496983c21ef2102b
Reviewed-on: https://dart-review.googlesource.com/c/90220
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-01-28 13:31:05 +00:00
Kevin Millikin e36ad1dad0 [Kernel] Build an invalid constant for evaluation errors
An invalid constant is (currently) represented by an unevaluated
invalid expression.  Using this instead of null fixes 63 out of 125
CFE constant-evaluation crashes with constant-update-2018 and
correctly signals 26 more previously-missed compile-time errors.

Change-Id: I5b4de3995b3a59978dfa08fc542ef0f027572eb6
Reviewed-on: https://dart-review.googlesource.com/c/89506
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-01-17 07:26:04 +00:00
Alexander Markov 78abb98ee7 [vm/bytecode] Fix AST removal for package-split kernel files with bytecode
In package-split mode, bytecode generation is performed separately for
each package. Previously, dropping AST was done right after generating
bytecode. However, dropping AST for a package makes it impossible to do
constant evaluation in other packages which import the package with dropped
AST. This breaks bytecode generation for subsequent packages.

To work around this problem, in package-split mode AST is removed
temporary until dillp file is written. After that, removed AST is restored
back.

Change-Id: I3d8b6a8ad98f2fe88b57f7b6393bbbe87b046c21
Reviewed-on: https://dart-review.googlesource.com/c/89822
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-01-16 19:04:40 +00:00
Kevin Millikin d9944433af [Kernel] Clean up error reporting in constant evaluation
Make the constant evaluator take an explicit error reporter so we have
to opt in to using the "simple" one that reports errors in an ad hoc
way.  This is the start of a change to use Fasta-controlled error
messages throughout and eventually get rid of the simple error
handler, and to continue constant evaluation after the first constant
error.

Change-Id: If6b1801edab6063754b642cf4a603abf9d63103a
Reviewed-on: https://dart-review.googlesource.com/c/89501
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Auto-Submit: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2019-01-15 11:34:42 +00:00
Peter von der Ahé e45e334548 Rename strong mode to legacy mode in package:kernel
Change-Id: Ia4a8a9cac7817a8db5771ec82541b556c705f7c8
Reviewed-on: https://dart-review.googlesource.com/c/86353
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-12-20 18:06:34 +00:00
Régis Crelier 25851db73d [vm/bytecode] Replace InstanceCall instruction with InterfaceCall and DynamicCall.
Dispatch interface calls via hashtable rather than inline cache.
InterfaceCall doesn't need to take arguments descriptor into account
when doing method lookup.

Change-Id: I30eae6ea638d1d2ad2cf3ff073c653fee3377f31
Reviewed-on: https://dart-review.googlesource.com/c/86106
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-12-14 16:51:51 +00:00
Alexander Markov 170d5578c7 [vm/kernel] Move functionality of Fuchsia's compiler.dart into pkg/vm
This includes:
* Selecting front-end target.
* Support for multi-root virtual file system.
* Not linking platform into resulting kernel file.
* Specifying input as URI (instead of file path) on command line.
* Automatically converting input script URI to package URI.
* Writing ninja dependencies file.
* Writing package-split kernel binaries.

After this change Fuchsia's compiler.dart will become a small wrapper
over pkg/vm, sharing most logic and even most command line options
with pkg/vm gen_kernel tool.

Also, this CL attempts to share some pieces of code between frontend
server and gen_kernel.

In addition, seperate bytecode generation for package-split binaries
is implemented (needed for https://dart-review.googlesource.com/c/sdk/+/85469).

Corresponding Fuchsia CL: https://fuchsia-review.googlesource.com/c/topaz/+/229964

Change-Id: I12d7b2f6401357b3c9df2e31bc736af5a9dc5fd2
Reviewed-on: https://dart-review.googlesource.com/c/85721
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-12-04 01:08:03 +00:00
Alexander Markov 9f49b47823 [vm/bytecode] Revise representation of objects and strings in bytecode
This is a major revamp of bytecode metadata format. Now bytecode has
its own serialization mechanisms.

This CL adds 'bytecode component' metadata, which contains bytecode
object table and string table. All references from bytecode (constant
pools) to libraries, classes, members, types and strings now have a new
format. References to frequently used objects are represented as indices
in object table, while rarely used objects are written inline.
This allows VM to cache frequently used objects while reading bytecode.

Representation of strings is aligned with VM - string characters are
stored in separate pools of one-byte and two-byte strings. This allows
VM to avoid UTF-8 decoding and extra copying.

Closure declarations are now explicit. Type parameters no longer require
enslosing scopes when reading/writing them.

Benchmarks:
GenKernelKernelReadAllBytecode (Intel Core i5) +29.84%
GenKernelKernelReadAllBytecode (Intel Xeon) +28.74%
Change-Id: I4b80009733a8f8c038264af74f97c4e094b9e311
Reviewed-on: https://dart-review.googlesource.com/c/85469
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-12-03 19:08:42 +00:00
Alexander Markov 62c562ed7a [vm/bytecode] Encapsulate constant pool entry creation
This refactoring is needed to simplify upcoming changes in constant pool entries.

Change-Id: Ia0356b0a738d33b4e676cd5be67bd77a2f75279a
Reviewed-on: https://dart-review.googlesource.com/c/84684
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-19 17:23:40 +00:00
Alexander Markov a9abc64613 [vm/bytecode] Add context IDs to disambiguate accesses to distinct contexts
This CL adds context ID operand to AllocateContext, CloneContext,
LoadContextVar and StoreContextVar bytecode instructions.
The context ID will be used to create distinct Slots and disambiguate
accesses to context objects corresponding to different scopes.

Change-Id: I98850ab763017b71c1dcacfccaffc085bd850e00
Reviewed-on: https://dart-review.googlesource.com/c/84681
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-17 00:35:30 +00:00
Alexander Markov 7fafcec013 [vm/bytecode] Eliminate AssertBoolean instructions if condition is non-nullable
Number of AssertBoolean instructions in the 100Mb dynamic trace of
Richards benchmark in pure interpreted mode (platform with bytecode):

Before: 1812005
After:   251451
Change-Id: I9fe9d37499d73ffa7636c9ca5fb9c2c18dbc1397
Reviewed-on: https://dart-review.googlesource.com/c/84643
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-11-16 19:18:27 +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
Alexander Markov 8f7a0f400b [vm/bytecode] Emit source positions for bytecode instructions
Change-Id: I83963771db301089317823f6bf14eb4a2728dbfb
Reviewed-on: https://dart-review.googlesource.com/c/81740
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-14 00:27:45 +00:00
Alexander Markov 3c32b32d56 [vm/bytecode] Enable OSR for unoptimized code compiled from bytecode
In order to enable OSR, CheckStackOverflow IL instructions are attributed
with a non-zero loop depth. The original loop depth is passed as operand
of CheckStack bytecode instruction.

Change-Id: I771f59ba9f8d071680a3b7156be380e0f606b7b2
Reviewed-on: https://dart-review.googlesource.com/c/84081
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-12 19:04:54 +00:00
Régis Crelier 98a0309fbd [VM compiler] Reuse function type arguments to avoid instantiation at runtime, when possible.
Change-Id: Icfcbd165bb96cf83b7911c6c11a7daca17c6ba12
Reviewed-on: https://dart-review.googlesource.com/c/81701
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-10-30 18:38:37 +00:00
Alexander Markov 59e626e5c9 [vm/bytecode] Change encoding of MoveSpecial bytecode instruction
Previously MoveSpecial bytecode instruction used unsigned 8-bit A field
to encode target local variable index. This is too restrictive as we allow
signed 16-bit local variable indices.

After this change MoveSpecial has A_X encoding, with A field used for
special index (0 or 1), and signed 16-bit X field used for target local.

Change-Id: Ib87992e192b2923a39a9968913c39476947d3ea5
Reviewed-on: https://dart-review.googlesource.com/c/81440
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2018-10-25 19:07:19 +00:00
Alexander Markov c7c81af74e [vm/bytecode] Check for overflow of bytecode limits
Change-Id: I452596fb6f0fa72d76f26981adae2910ba1a179c
Reviewed-on: https://dart-review.googlesource.com/c/81336
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-10-25 00:10:24 +00:00