This change adds a bytecode generation option 'keep-unreachable-code' to
avoid eliminating unreachable code from constant conditions.
This option is enabled in kernel service.
If unreachable code is eliminated, then call instructions are not generated
and ICData objects are not created. Source code report is collected
using created ICData objects and will not flag the unreachable code as
not executed.
Change-Id: Ic73e19c653505e0dfab4648ab65ef6b90370e0b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113960
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
* Include source positions, source text (if provided by front-end, which is
controlled by a separate option) and assertions into platform with bytecode.
Also use environment defines if provided.
* Omit bytecode for synthetic static fields '_redirecting#' injected
by front-end, as they contain invalid AST nodes (taking tear-off of
a constructor). This is needed to avoid emitting bytecode which cannot be
loaded.
* Correctly merge source information such as source text and line numbers
in bytecode generator if the script was originally created for an
anonymous mixin application without such information.
* Always include import URIs into source information, even if other information is
excluded (for members in anonymous mixin applications / noSuchMethod forwarders /
forwarding stubs).
* Set native resolvers for vm/cc/PrintJSON test, as printing all objects to JSON
involves collecting token positions, which may read bytecode from platform and
need native resolvers to process native method entries.
Change-Id: I971e880c25439c0ec69db3a231a0085ccd5d15ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113780
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Code map((x) => ...).toList() is less efficient compared to an explicit loop.
Replacing these code patterns with loops slightly improves bytecode generation
speed (dart2js 1271 -> 1188 ms).
Also, map with closure consumes more stack space which results in flaky
stack overflow errors in kernel service on a test with deeply nested constants.
Change-Id: If209fc28d521abcbad46b5b2c7cffefcf8cd0ecb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113217
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
PushStatic instruction expects field object to be pushed onto the stack.
This is useless, as PushStatic also references field with its D operand.
This change replaces PushStatic instruction with LoadStatic which doesn't
take field object on the stack, so PushConstant/PushStatic pair is replaced
with a single LoadStatic instruction.
This change also enables constant propagation of values of injected CID
fields, which are not known at bytecode generation time.
Change-Id: Ifbdd3aea2aab338f6c9ec3e5728948c4d8541a4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112489
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Fixes crash in bytecode reader when trying to read body of
'abstract static external' function in test
co19_2/Language/Functions/External_Functions/not_connected_to_a_body_t01.
Change-Id: Ie60a6467a1b05aaf4c78baca50d67d29dfad3751
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111984
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Remove DebugCheck on Jump opcode.
Emit explicit DebugCheck bytecode instructions for VariableSet (see CL 111221).
Emit explicit DebugCheck bytecode instructions for VariableDeclaration.
Emit explicit DebugCheck bytecode instructions in _generateNonLocalControlTransfer before context is unwound.
Refactor prologue of async op functions, so that the same DebugCheck opcode is
encountered on every reentry.
Allow extra single steps when debugging bytecode in service tests.
Support context level calculation of compiled frames.
Adjust filter of synthetic variables in debugger.
Fix logic to skip single steps in bytecode prologue.
Change-Id: I1d6236c37af1aded0eebca1c3e3bb1978f7369dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111867
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
AST-based flow graph builder has a heuristic logic on when to generate
DebugStepCheck when assigning value to a variable. This logic depends on
right-hand side expression. In order to replicate the same behavior
with bytecode, bytecode generator would also implement this logic and
generate explicit DebugCheck instructions instead of stopping on every
StoreLocal/PopLocal/StoreContextVar.
Change-Id: Ic10180673a324db9216e34459d9c0afaca6a11e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111221
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
While stepping, do not stop more than once in the same token range.
Adjusted tests expecting multiple stops at same location.
Fixed emitted source position of DebugCheck opcode in async op.
Ignore all possible breakpoint positions until the first DebugCheck opcode of
the function, so as to not stop in the prologue where arguments are not yet
accessible.
Fixed look up of context level in debugger.
Use receiver to look up async op closure in frame instead of named captured
variable.
Made StoreContextVar a 'debug checked' opcode.
Implemented rewind of interpreted frames.
Marked get_source_report_test as (temporarily) failing in status file.
Removed fixed and passing regression test from status file.
Change-Id: I9396d3cf4b6accc85753bb6d227b7c068acc8df7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109558
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This change adds support for bytecode generation in incremental compiler in
kernel service. Bytecode generation is performed as a post-processing step,
after delta components are merged.
Bytecode generation requires CoreTypes and ClassHierarchy, which cannot be
constructed using delta component from incremental compilation (as it doesn't
contain platform or previously compiled libraries). The solution is to obtain
CoreTypes and ClassHierarchy directly from incremental compiler.
Now the following tests work:
vm/cc/IsolateReload_KernelIncrementalCompile
vm/cc/IsolateReload_KernelIncrementalCompileAppAndLib
Change-Id: I34c5870b01850c057ace71a63f8effa5b010cfcf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108682
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>