Commit Graph

45 Commits

Author SHA1 Message Date
Tess Strickland fe6ea5e39d [vm,dyn_modules] Rename DebugCheck to Nop and use after debugger() calls.
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>
2026-02-19 03:00:23 -08:00
Tess Strickland b6c060a6ab [vm,dyn_modules] Pass additional libraries to the BytecodeGenerator.
In addition to passing in the libraries that should be visited to the
bytecode generator, also pass the libraries which are needed by the
component and either are not in the component or should not be visited
(e.g., libraries from the platform when the platform is not included).

This way, the bytecode generator can create appropriate LibraryIndexes
to detect the use of `dart:` libraries which aren't already in
VmTarget.extraIndexedLibraries, and thus in coreTypes.index (e.g.,
'dart:ffi').

TEST=pkg/dart2bytecode

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Ic08f2022753950bf639c446c0b2594e1e269872a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476760
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-02-06 06:13:22 -08:00
Tess Strickland 134d45a41b [vm,dyn_modules] Remove the 'debugger-stops' bytecode option.
This CL does not yet remove the DebugCheck instruction from the
assembler/reader/interpreter and replace the DebugCheck opcode with
Unused##. Once the debugger fixups are complete without needing it,
then I'll remove that side of things.

Calls to _emitSourcePositions in the BytecodeGenerator have been
either replaced with asm.emitSourcePosition() or removed entirely
if the emit<Opcode> method in the assembler already calls
emitSourcePosition internally.

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Ibcb24da4a7b7a80c4d6ae56485cf33287a5aa68b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474180
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-01-20 02:27:30 -08:00
Tess Strickland a02596b28f [vm,dyn_modules] Source position cleanups and fewer temp uses.
Reduces the usage of temps in the following cases to remove unneeded
StoreLocal/Push instructions:

Refactors visitVariableSet so that a temporary is used only if the
variable is captured and the result is not ignored. (That is,
sets of uncaptured late final fields no longer need a temporary.)

Only allocate a temp for FunctionDeclarations and FunctionExpressions
if there are function type arguments to capture or if the function
is generic (in which case the delayed type arguments field must be
empty-initialized, not null initialized).

-----

Clean up how source positions are emitted to both be more consistent
and to also move some source position emissions closer to the actual
instruction that performs the operation:

Move emission of debugging information for FunctionDeclaration,
and VariableSet to when the variable is actually set. The emission
in VariableDeclaration stays before the initializer as that's when
debugger tests expect to pause at it.

Change the implementation of _genConditionAndJumpIf to use if/else
chaining instead of early returns so that the condition's source
position can be recorded once before the if/then chain and then the
previous source position restored afterward the chain. This means
that _emitDebuggerInformation can be used.

_generateNonLocalControlTransfer is only called during visit methods
where the parent call to _generateNode has already recorded the from
node's position, so there's no need to record it during that call.
Instead, move the emission of the source position to the jump within the
passed continuation.

Remove _emitLocalSourcePosition, since it is no longer used.

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Id7722146769c57713ae466d67401258c010cee37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473380
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-01-19 04:04:43 -08:00
Alexander Aprelev eb75c53d95 [vm/shared] Perform deeply-immutable initialization runtime check.
When an initial value is assigned into a class tagged as deeply-immutable, perform runtime check of that value. This is needed to support proper initialization of the closures as part of deeply-immutable classes.

BUG=https://github.com/dart-lang/sdk/issues/61962
TEST=run_isolate_group_run_test

Change-Id: I550746c0d22ca06ffb89959e8384cc9e6d28d590
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468200
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-14 08:42:22 -08:00
Alexander Aprelev 170df25b66 [vm/shared] Prohibit capturing of 'late final' variables by isolategroup-bound closures.
TEST=run_isolate_group_run_test
BUG=https://github.com/dart-lang/sdk/issues/62181

Change-Id: I50037ede337367020176262b98d2c2fd100b050a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466820
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-10 08:29:57 -08:00
Alexander Aprelev f04ff0410e [vm/shared/bytecode] Support use of vm:shared in bytecode/interpreter.
Fixes https://github.com/dart-lang/sdk/issues/62032
TEST=ci

Change-Id: I80600d81ee73b16338a337f7139bf4e898af6eca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466124
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-12-05 21:38:41 -08:00
Tess Strickland 7af4d14267 [vm,dyn_modules] Mark extension type members appropriately.
TEST=pkg/vm_service/test/step_through_extension_type_method_call_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I3bf331e175847280964fd42eb027e9f812598bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464705
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-12-02 06:31:15 -08:00
Tess Strickland 76c63313d2 [vm,dyn_modules] Fix source positions for variable declarations.
Also add synthetic source positions for synthesized variable nodes.

TEST=pkg/vm_service/test/issue_27238_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I0b4b13324eacc35fee00231b676f6b6bd5ac448a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464200
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-11-25 03:59:00 -08:00
Tess Strickland 1125460f2e [vm,dyn_modules] Allow desugared const constructors.
The front end may desugar some const constructors into procedures, so be
less strict with what is expected in the list of const constructors.

Also updates SourceReport to check all Functions with is_const() true
against the collected const constructor hits and not just Constructors.

TEST=ci

Fixes: https://github.com/dart-lang/sdk/issues/61947

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I092938eeeb0459de9b3d95400a538ec6528c43fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462442
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-11-17 06:56:33 -08:00
Tess Strickland 00922a0c11 [vm,dyn_modules] Fix adding breakpoints on variable assignment.
Instead of only adding source information if the initializer is null or
one of a few possibilities, instead add a source position if emitting a
store and the variable is not synthesized.  This matches an earlier
change which added source information when setting the value of a
non-synthesized variable.

Remove _variableSetNeedsDebugCheck and also remove the only other use of
it as a guard for emitting source positions (static field sets).

TEST=pkg/vm_service/test/breakpoint_on_record_assignment_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I02b3e118f36714f1e6e29bf9cced7dcd5da8e532
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456980
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-23 06:59:30 -07:00
Tess Strickland 3a85708697 [vm,dyn_modules] Fix adding breakpoints on conditions in bytecode.
TEST=pkg/vm_service/test/breakpoint_on_simple_conditions_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Id8872f3a1ad5d418392effacf56dfc46fb2b5976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456941
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-23 06:56:55 -07:00
Tess Strickland 3685c2add5 [vm,dyn_modules] Add source positions when setting non-synthesized vars.
In particular, this ensures that the bytecode that initializes pattern
variables has appropriate source information, as those variables have
hoisted definitions with the initialization later happening via a set.

TEST=pkg/vm_service/test/step_through_patterns_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I9622f88d7205c1efcfa3ca2e761d1b4eb5b5d2b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456660
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-10-23 04:14:49 -07:00
Tess Strickland bfb0815b07 [vm,dyn_modules] Fix source position for null-initialized variables.
Only use the file offset of the assignment operator if the variable has
an initializer, otherwise fall back onto the file offset of the
variable declaration.

TEST=pkg/vm_service/test/issue_25465_test
     pkg/vm_service/test/step_through_assign_call_test
     pkg/vm_service/test/step_through_assign_int_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I76284041d941254a10e050a4bebffdec619f2e05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456600
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-23 04:14:49 -07:00
Tess Strickland df693c20b0 [vm,dyn_modules] Add flags to bytecode source positions.
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>
2025-10-09 09:15:42 -07:00
Tess Strickland 99a370942b [vm,dyn_modules] Update some coverage information for bytecode.
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>
2025-10-01 09:51:59 -07:00
Tess Strickland 19d6b1d003 [vm,dyn_modules] Emit script file contents in bytecode when requested.
To enable this for pkg/dart2bytecode/bin/dart2bytecode:
dart2bytecode --bytecode-options=script-file-contents ...

This option is disabled by default, but enabled by the bytecode kernel
service and by the test runner when running in non-product
configurations.

TEST=pkg/vm_service/test/local_variable_declaration

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: Ibeeb7d212f6be27002b972d67867b2581d97a0aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449860
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-09-26 05:06:22 -07:00
Tess Strickland 74f753f32d [vm,dyn_modules] More work on bytecode debugger support.
Detects yield points in Debugger::IsAtAsyncJump for bytecode by seeing
if the currently executing instruction is a direct call to an await
or yield compiled stub.

Adds a ResumptionBreakpointHandler runtime entry that is called
during Interpreter::Resume() if the current isolate has resumption
breakpoints.

Similarly, all the places where a DebugCheck could be emitted if
debugging stops are requested now include an explicit source position
emission when source positions are requested but debugger stops are not,
to ensure the debugger has appropriate information.

Fixes CompareTopDartFrameTo returning kSelf for non-top frames when
the top frame was interpreted but the stepping frame was not or
vice versa.

TEST=pkg/vm_service/test

Change-Id: I88cdc37cf745f30e8dfb6b14c19fc9b2c4cbaf2d
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446300
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-09-12 04:19:40 -07:00
Alexander Markov 5f3466ea7c [vm,dyn_modules] Support deferred libraries
TEST=ci

Change-Id: I0c9ba10b3220729aa9114ae965a4d3d2a4037a88
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,vm-dyn-mac-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447761
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-09-08 07:56:13 -07:00
Alexander Markov 68382660c8 [vm,dyn_modules] Initial support for FFI calls in the interpreter
Limitations:
* Compounds (structs, unions, arrays) are not supported yet.
* Only x64 and arm64 are supported.

TEST=ci

Change-Id: I2929d514dc49015369d29dad31f479c661161655
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446282
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-08-26 09:22:30 -07:00
Alexander Markov ea746d21c2 [vm,dyn_modules] Remove unused library dependencies from bytecode
Fixes https://github.com/dart-lang/sdk/issues/61362
TEST=ci

Change-Id: I1e15b100a9d5f486addce11e85ea6d69389a6bb7
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/+/446101
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-08-25 08:39:00 -07:00
Alexander Markov a3038b85f8 [vm,dyn_modules] Support pragmas on local functions in bytecode
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>
2025-08-21 07:00:49 -07:00
Alexander Markov 8ef843ef4f [vm,dyn_modules] Support implicit dynamic calls in bytecode
TEST=ci (co19/Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A04_t01)

Change-Id: I49faf7c6f8d8f9353683dd94e9aa9a7ac7d30921
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/+/443882
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-08-07 06:44:40 -07:00
Alexander Markov e32c2ac796 [vm,dyn_modules] Remove enclosing function type parameters from instantiated types
VM treats instantiated function types with NumParentTypeArguments() != 0
as non-instantiated (as they potentially depend on the numbering of
enclosing type parameters) and would explicitly instantiate such types.

So bytecode generator needs to make sure that instantiated types,
instantiated type arguments and types used in constants always have
NumParentTypeArguments() == 0, so they would not need unnecessary
instantiation.

TEST=ci

Change-Id: I3ea54a0b535655611893d28edb54ffd50dcda1f0
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/+/443630
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-08-06 06:25:02 -07:00
Alexander Markov c7bf13176f [vm,dyn_modules] Support reachabilityFence and _nativeEffect from dart:_internal in bytecode
TEST=ci

Change-Id: I68c7b74b6ccc75139b5690f3216c47ab843cc544
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/+/442245
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-07-28 07:58:10 -07:00
Alexander Markov 644d0d4c49 [vm,dyn_modules] Include assertion text into bytecode
Extract the text of assert condition and put it into bytecode
instead of relying on runtime to find the source text
(which is most likely unavailable for a dynamic module).

TEST=ci (language/vm/regress_27671_test, vm/dart/asserts_test)

Change-Id: Id6643333164b37c5046fa1dfecdbe9338f53c93d
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/+/442244
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-07-28 07:40:42 -07:00
Alexander Markov 9f72f1034c [vm,dyn_modules] Support class modifiers in bytecode
TEST=ci

Change-Id: I521b27c793269dc6076b353f50e2cdaa629002e9
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/+/441987
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-07-24 06:02:35 -07:00
Alexander Markov 87beee922a [dart2bytecode] Generate instance field initializers for hot reload
Hot reload needs to run instance field initializers for all newly
added fields except fields initialized with null.

TEST=ci (vm/cc/IsolateReload_RunNewFieldInitializers)

Change-Id: I3ead726aa12b9d6c5aa515c7297deca0ddd9eb9f
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/+/441861
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-07-22 16:08:20 -07:00
Alexander Markov 3e462c1343 [vm,dyn_modules] Support external/native methods in bytecode
TEST=ci

Change-Id: I2827c95f7b4d4bfa40239369d3675ef6adba4ab2
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/+/439545
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-07-11 06:31:19 -07:00
Chloe Stefantsova 433c0998d0 [cfe] Remove Nullability.legacy
TEST=existing

Change-Id: Id924e4ef64ddabc1986cb885f558382ff139b481
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436620
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-07-02 23:50:12 -07:00
Chloe Stefantsova 39810ffbe4 [cfe] Cleanup interface of subtype queries
Under the hood, there is no difference between
`isSubtypeWhenUsingNullabilities` and
`isSubtypeWhenIgnoringNullabilities` by now. This CL makes the
corresponding renames and removals in the CFE and its clients.

TEST=existing

Change-Id: I22060c29834179c30ba62562aa254146b1d7530d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433480
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-06-13 02:02:54 -07:00
Alexander Markov f9860f9db9 [dyn_modules] Add source positions to bytecode
dart2bytecode can optionally add source position information
(including line starts) to the generated bytecode
(when '--bytecode-options=source-positions' flag is specified).

If bytecode has source positions, they are now shown in stack traces
involving interpreter frames.

TEST=ci

Change-Id: I1ae3326bac21201040be32c712514e71e96f51e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433760
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-10 12:15:25 -07:00
Alexander Markov ea27d17793 [dyn_modules,dart2bytecode] Fix isTop predicate for extension types in bytecode generator
Bytecode generator needs to know the runtime semantics of Dart types,
but TypeEnvironment.isTop predicate does not use erasure of extension
types and does not return true for extension types based on other top
types (e.g. dynamic).

TEST=language/dot_shorthands/member/static_method_cascade_test

Change-Id: If8323d11293498fb39d8d936c406bc9bb7e85ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426983
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-09 10:56:33 -07:00
Alexander Markov 18a44b3095 [vm, dynamic_modules] Support required named parameters in function types
TEST=language/nnbd/subtyping/function_type_required_params_test

Change-Id: I050f8fdd331985512f204b265d81c7deec0d67fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415640
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-03-18 14:50:45 -07:00
Devon Carew 3c973fb292 [lints] address diagnostics related to strict_top_level_inference
Change-Id: I228058202855900f0adba73c1ab04d35180a6e5d
Tested: this is an analyzer diagnostic only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414900
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-03-17 08:27:57 -07:00
Alexander Markov e200a3a722 [dart2bytecode] Avoid merging function types with different number of enclosing type parameters
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>
2024-12-09 15:19:43 +00:00
Johnni Winther 27048206ce [cfe] Rename TypeVariable to TypeParameter
This makes the CFE and kernel terminology consistent.

Change-Id: I6e35d9f4ea58d50eac0ab84763633bf5e445771d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390861
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-10-21 09:35:06 +00:00
Alexander Markov 80b092de04 [dart2bytecode] Throw exception instead of crashing when external member is called
TEST=ci

Change-Id: I60a598dd5f8ac05a4f5f3283d257c2c6a74490e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384820
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-12 14:52:58 +00:00
Alexander Markov fcdcdeddad [dart2bytecode, vm] Adjust bytecode file format
* Switch UInt32 from big-endian to little-endian encoding.
* Reorder object kinds, constant tags, type tags and constant pool tags.
* Reorder field and function flags.
* Cleanup yield point marker from source positions.

TEST=ci

Change-Id: I05ee940b6393a478831af11ac93fee9ec1441c4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-10 13:37:29 +00:00
Alexander Markov 1225b45bc7 [dart2bytecode, vm/interpreter] Async exceptions
TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: I9d5bb0f7f2544e41078ec9aeb75bce6224087976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383706
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-09-09 13:44:04 +00:00
Alexander Markov a17bc048b4 [dart2bytecode, vm/interpreter] Late final fields and variables
* Also, add implicitly overridden _Enum._enumToString to dynamic
  interface.

TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: I9d9d368715d0837d8b1039a46451152e03be7eec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383024
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-04 14:18:09 +00:00
Alexander Markov a3b7c9fb5a [dart2bytecode, vm/interpreter] Small fixes
* Use AllocateClosure instruction for closure instantiations in order
  to initialize closure entry point.

* Fix null handling in operator== to be before argument type checks.

* Add _InvocationMirror._withType to dynamic interface as it is
  implicitly used by noSuchMethod forwarders.

* Fix AssertAssignable for null objects.

TEST=language tests in vm-aot-dyn-linux-debug-x64 configuration

Change-Id: I7b1a037d4fde4d22ed32969e0f099b31ea4432ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382500
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-08-29 14:28:40 +00:00
Alexander Markov 2e63d3135a [dart2bytecode, vm/interpreter] Records
TEST=language tests in vm-aot-dyn-linux-debug-x64 configuration

Change-Id: I6dd7d5617f5c076c722304ab2a753159f22c0bf6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382421
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-08-28 13:12:48 +00:00
Alexander Markov 062b0738e3 [dart2bytecode, vm/interpreter] await/yield/yield*
TEST=language tests in vm-aot-dyn-linux-debug-x64 configuration

Change-Id: I205bec19c2072fe9ac11a3211123bba43cb99d5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381945
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-08-26 20:35:18 +00:00
Alexander Markov 3abf78212c Bytecode compiler
Add dart2bytecode tool which takes Dart sources and produces
Dart bytecode. The tool uses common front-end (CFE) to parse Dart
source code and contains bytecode generator which translates
kernel AST to bytecode.

Change-Id: I90bd6e72c619cf0edc556da0640760b30e81091d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378560
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-08-08 18:08:58 +00:00