Since both throw and rethrow statements share the same 'Throw' bytecode opcode
(differentiated by an operand), we make the opcode not implicitly 'debug
checked' anymore.
Instead, we emit a 'DebugCheck' opcode for the throw statement only.
This fixes the following test:
service/async_single_step_exception_test
Change-Id: I4e540ea0a640fda5365d51933ce4e5125548e2f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114754
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This emulates behavior of AST-based flow graph builder which would
insert DebugStepCheck if RHS is LoadLocal.
As-expression generated by AST-based flow graph builder results
in LoadLocal (unless it's casting to a top type).
Fixes service/next_through_is_and_as_test with bytecode.
Change-Id: Icb809d42daf2a4ebbad22bfa92bc737406144489
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114740
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Removing source information for this call prevents the debugger to set a
breakpoint in compiled bytecode on this call which occurs prior to the first
DebugStepCheck in the function.
However, this change uncovered a bug in debugging interpreted bytecode:
The first source range of an async_op function gets split into 3 ranges, with
the middle range specifying a NoSource token position. The debugger does not
set a breakpoint in the first range, because DebugCheck is not yet encountered,
which is correct, but it failed to look for another range (the 3rd one) with the
same token position.
Change-Id: I11dcc75d115cb57b37f62afd83c783cf563b63e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114700
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
The extra DebugCheck is skipped depending on the initializer expression,
similarly to VariableSet.
This matches how AST-based flow graph builder inserts DebugStepCheck for
VariableDeclaration.
Test: runtime/observatory/tests/service/async_star_step_out_test.dart
Change-Id: Id1b11813b533996e219891f416e7008a994dbc51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114593
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This fixes the following tests in bytecode mode:
service/step_through_switch_test broke
service/step_through_switch_with_continue_test
Change-Id: I3f6f835185b9dae86e5ebebfdd4484b4d1cb6af0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114549
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
* Set parent for TypeParameters created in createExpressionEvaluationComponent.
* Resolve references from bytecode to an expression evaluation class
using real class. Expression evaluation class could be referenced
from type parameters.
* Avoid registering expression evaluation classes in hierarchy. They
shouldn't be discovered through direct subclasses or implementors,
as expression evaluation classes don't have cids.
* Add :function_type_arguments_var local variable to bytecode local
variables info, so expression evaluation can find function type
arguments which are in scope.
Change-Id: I515431a989b4d02af4ecf90579931dd59d3acadd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114182
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
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>