The RecordCoverage instruction has an A/E encoding. The A argument
is the type of coverage being recorded, whereas the E argument is
the logical index into the coverage array for updating whether that
source position has been hit.
Also adds new metadata to the bytecode component for the coverage
arrays associated with bytecode containing RecordCoverage instructions
and a new runtime entry for lazily allocate the coverage array for
an interpreted function when needed.
The type of coverage is encoded in the RecordCoverage instruction,
despite being redundant with the information in the coverage array, so that checking whether that type of coverage is currently enabled at
runtime doesn't require either accessing the coverage array (which may
be lazily allocated), forcing allocation of the coverage array just to
discover that type of coverage is currently disabled, or reading the
serialized bytecode component to avoid that forced allocation.
------
Other changes:
Source reporting now treats unexecuted interpreted functions when
not forcing compilation as if they were uncompiled native functions,
so that the source report from running the same code gives the same
result whether using the interpreter or the native compiler.
Bytecode closures are no longer skipped in source reports. Previously
any closure without a context scope was skipped, but bytecode closures
don't have those.
TEST=vm/cc/SourceReport_Coverage
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: I7557e5dd4c98331c7ca2f5c867dd5f6d03e9d756
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501520
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This is a reland of commit 88496ba1c3
Fixes on top of the original change:
* Closure layout is changed to avoid gap between fixed fields and
variable-length elements on compressed pointers architecture.
This gap was causing crashes in the GC when scanning closure
objects.
* pkg/vm_snapshot_analysis/test/instruction_sizes_test is fixed
on arm64 by decreasing threshold for detecting size changes.
Original change's description:
> [vm,dart2bytecode,modular_aot] Variable-length closure objects
>
> Extend closure objects with variable number of elements to capture.
> This is needed to support capturing multiple independent contexts
> after capturing is computed in the front-end.
>
> The following fixed Closure fields are moved into variable-length
> elements:
> - delayed type arguments;
> - instantiator type arguments;
> - function type arguments;
> - context.
>
> Number of elements and presence/indices of various type arguments
> are encoded into the new length_and_flags field in the Closure.
>
> Most closure objects don't need any of the type arguments so this
> change will reduce average Closure object size.
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I8685e632e2d0832766ecdc470f3cf9a6b880de48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494243
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Extend closure objects with variable number of elements to capture.
This is needed to support capturing multiple independent contexts
after capturing is computed in the front-end.
The following fixed Closure fields are moved into variable-length
elements:
- delayed type arguments;
- instantiator type arguments;
- function type arguments;
- context.
Number of elements and presence/indices of various type arguments
are encoded into the new length_and_flags field in the Closure.
Most closure objects don't need any of the type arguments so this
change will reduce average Closure object size.
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61572
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I7ca5cec0fd8725c432a01d51781fb14e803997dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489482
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Adds a new isInvisible flag for both FunctionDeclarations and
ClosureDeclarations and sets it if the function or closure declaration
is annotated with @pragma('vm:invisible'). This way, function visibility
is appropriately recorded even if options.emitAnnotations is false.
The bytecode reader checks for the isInvisible flag when reading
FunctionDeclarations and ClosureDeclarations and appropriately
sets the is_visible flag for the Function object accordingly.
TEST=pkg/dart2bytecode/test/bytecode_generator_test
vm/dart/invisible_function_pragma_test
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: If435afbe5e74adc022ce064784b6b3e5e8a88164
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486381
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Normally, bytecodes no longer in use would be renamed to Unused<X>.
However, in the case of DebugCheck, its only use was to call the
debugger when single stepping, and since its original creation, the
interpreter has been changed to call the debugger when single stepping
on every instruction. Thus, DebugCheck instructions are effectively
no-ops, only used as a distinct PC offset for source positions, and this
CL changes their name to reflect this.
This CL also changes the bytecode generator to detect uses of debugger()
from dart:developer and to add a Nop after it, mimicking how
StreamingFlowGraphBuilder recognizes uses of debugger() and adds a
DebugStepCheck instruction afterwards. Doing this instead of just
using asm.emitSourcePosition() at the end of visitStaticInvocation
ensures that the source position isn't overwritten by the next emitted
instruction.
TEST=pkg/vm_service/test/set_sdk_library_debuggable_test
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Ie24bcea0b5aeb9e41d7765f25b1cd123bb2565b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480203
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
There are two possible flags for each source position currently:
a flag that marks the source position as synthetic and a flag that
marks the source position as within a yield point.
Synthetic source positions in bytecode are treated the same as synthetic
source positions in compiled code. That is, they encode the source
position in the text that caused them to be synthesized, but denote that
the covered instructions are internal and not to be used for debugger
pause points or for call site/branch coverage information.
Adding these flags allow us to mark appropriate parts of the async
machinery as synthetic, and also allow us to mark all the bytecode
involved in yield points as having the same token position.
The latter fixes tests where the code would step over a previous
expression, thus being paused at the start of the await bytecode,
and would record the fp and token position there as the ones to
ignore. However, since a new source position wasn't emitted until the
direct call to the await method, the recorded token position would
be the token position prior to the await call, and so the change
in token position at the await call would trigger an early pause.
TEST=pkg/vm_service/test/async_single_step_exception_test
pkg/vm_service/test/async_single_step_into_test
pkg/vm_service/test/async_single_step_out_test
pkg/vm_service/test/async_star_single_step_into_test
pkg/vm_service/test/async_step_out_test
pkg/vm_service/test/positive_token_pos_test
pkg/vm_service/test/step_into_async_no_await_test
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-product-x64-try
Change-Id: Ic7642a74fb76227a473f461f360e84dd3d5a45a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453322
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Add a flag to SourceFile which is true if the associated script
contains a list of covered const constructors, and serialize said
list if true.
Delay reading and resolving the list of covered const constructors in
the bytecode reader until code is read.
Update usage counters for interpreted functions in Entry instructions.
Fix up cases where SourceReport assumed compiled code as appropriate.
Remaining:
* Record call and assert coverage information if the current isolate
group has coverage enabled.
* Record branch coverage information if the current isolate group
has branch coverage enabled.
TEST=pkg/vm_service pkg/dart2bytecode
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I14b6ffba1e175993e992c0fe939473557303bfeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449900
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Pragmas on local functions are used internally by FFI.
TEST=ci
Change-Id: I3ffb9984d8fcd943b22a98746faa915b2ce7c9fa
Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446121
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
When creating function types, VM takes number of parent function type
arguments into account. So function types with distinct number of
parent function type arguments should not be merged in the bytecode
object table and should be represented as distinct types.
TEST=language/mixin/type_parameter_inference_test
Fixes https://github.com/dart-lang/sdk/issues/59633
Change-Id: I9c8b0923c52b1b95628ff8daa3bbfa135c559912
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398500
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>