17 Commits

Author SHA1 Message Date
Jens Johansen ec5e71ead4 [CFE] Rename additionalDills to additionalDillModules; don't use it to load platform
* Rename additionalDills to additionalDillModules to indicate that it
   is used to load a "module", not any old dill file.
 * Where additionalDills was used to provide the platform use sdkSummary
   instead.
 * Remove unused constructor in KernelCompilationResults.

Tested: Existing tests.
Change-Id: I5f73f61db73b2bc932c211fb0b2e66ec2f5c50c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495981
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-01 00:57:31 -07:00
Chloe Stefantsova b02a83e114 [cfe] Enable super initializers with new variables in constant evaluator
This CL adjusts the predicate `_isFormalParameter` in the constant
evaluator, so that it includes variables from the new
model. Additionally, `IntenralPositionalParameters` and
`InternalNamedParameters` that were emitted as parts of function
declarations are replaced with their corresponding `astVariable`s in
the output.

The CL allows to unskip the last test in the bytecode generator when
the new variable model is enabled.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ibb8df47bf53f7f31aab58f8d5d104192edc83718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489380
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-03-23 06:47:10 -07:00
Chloe Stefantsova e07e723707 [cfe,dart2bytecode] Apply model-agnostic isThisExpression predicate
In the new model `ThisExpression` is replaced with a `VariableGet`
referring to `ThisVariable`. This CL introduces the model-agnostic
predicate `isThisExpression`, which is applied to replace is-checks on
`ThisExpression`.

The changes in this CL allow to unskip the test `type_ops.dart` in
`bytecode_generator_test.dart`.

This CL is also a follow-up to
https://dart-review.googlesource.com/c/sdk/+/488780/1/pkg/front_end/lib/src/type_inference/inference_visitor_base.dart#3481

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I9d56ea6a648dc8d299d9a9692b4ffa4459221147
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-23 06:47:10 -07:00
Alexander Markov 8a2deccc9a [vm,dart2bytecode] Reformat pkg/dart2bytecode and pkg/vm
Reformat these packages after the language version was bumped in
https://dart-review.googlesource.com/c/sdk/+/487942

TEST=ci

Change-Id: I6475e4b3d096b3c1f9aded34a5736989222e1689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489400
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-03-20 06:35:41 -07:00
Chloe Stefantsova aa3665ed78 [dart2bytecode] Use CatchVariables in dart2bytecode
The changes in this CL allow to unskip the tests 'async.dart' and
'try_blocks.dart' when the experiment is enabled.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: If2b7756f8ef30f7140742c066729842b080589b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488820
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-03-19 04:42:42 -07:00
Chloe Stefantsova 4336423831 [cfe,dart2bytecode] Use ThisVariable in dart2bytecode
The change allows unskip the bytecode generator tests 'closures.dart'
and 'super_calls.dart'.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ia631642eff475c364f409c6b096f7cc81878382f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488780
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-19 04:42:42 -07:00
Chloe Stefantsova 5190320af8 [cfe] Produce synthetic assignments in for-in loops in output form
In the new variable encoding, variables exist either in the internal
form (InternalLocalVariable, InternalSyntheticVariable, etc) or in the
output form, which is passed to the backends. Normally, type inference
is the mechanism that consumes the variables in the internal forma and
produces the variables in the output form. However, some expressions are
produced before type inference (in the BodyBuilder) and will never be
processed by type inference. Synthetic assignments in for-in loops is an
example of such expressions.

This CL modifies the expression generators used by the BodyBuilder, so
that the synthetic assignments are produced directly in the output form,
since they will not be touched by type inference.

This change makes the `loop.dart`, `switch.dart`,
`instance_creation.dart`, `asserts.dart`, `field_initializers.dart`,
`optional_params.dart`, `bootstrapping.dart`, `ffi.dart`, and
`invisible.dart` tests of the bytecode generator to pass, so it can be
removed from the excluded tests when the closure-context-lowering
experiment is enabled.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I8d828b7da8e33c6e9fa6bfdda1f201bcdfad9ac4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487840
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-03-16 03:50:37 -07:00
Tess Strickland db8563d4d6 [vm,dyn_modules] Recognize the vm:invisible pragma.
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>
2026-03-09 10:16:02 -07:00
Nate Biggs 44a049c082 [dynamic_modules] Add support for deduplicating library prefixes to dart2wasm
Change-Id: I325e4e1e3aff25c4e894bc2f3f23fcf02f15da16
Fixes: https://github.com/dart-lang/sdk/issues/62828
Tested: Dynamic module tests.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485980
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Nate Biggs <natebiggs@google.com>
2026-03-06 05:39:21 -08:00
Ivan Inozemtsev a5b890f90d [dart2bytecode] Allow adding prefixes to bytecode-compiled libraries.
This enables sharing (by duplicating) the common code not included into the host app between dynamic modules.

Bug: b/475757441
Change-Id: I4831fc8b996303691ea2311019d1957f52c7d40c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478370
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2026-02-10 12:26:20 -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
Chloe Stefantsova 1fb8ef4ec2 [cfe] Add function parameters to closure contexts
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ic70f9da9fbe22c7e3d59d603563655941e5f5260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-01-22 02:14:56 -08:00
Chloe Stefantsova a4d6787112 [cfe] Start emititng new variable nodes when the experiment is on
As a part of this CL, the following was changed:

* Instead of `VariableInitialization` implementing `VariableDeclaration`, `VariableDeclaration` now implements `VariableInitialization`.
* `InternalLocalVariable` now implements `LocalVariable`. It delegates most of its members to the variable it wraps around, and the implementations of the `TreeNode` members are throwing.
* Some tests in the bytecode generator under the experimental type started to fail and are skipped.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I06b391cc762d5935f528d208ff5e27eccf311a47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462981
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-20 01:33:37 -08:00
Chloe Stefantsova ec92547b99 [model][vm] Add Target flag for Closure Contexts in AST experiment
The flag is enabled in some of the bytecode generator tests.

Part of https://github.com/dart-lang/sdk/issues/61572

TEST=existing

Change-Id: I65f491d90aad3a8d923f1a740012bad0ae8f318a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451280
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-09-25 08:02:49 -07:00
Paul Berry 111e84b958 Rename CFE DiagnosticMessage class.
The analyzer already has a class with the same name, but a slightly
different purpose. (The analyzer's class represents a single message
associated with a source location, whereas the CFE's class represents
a message along with related context messages).

I'm currently embarking on an arc of work that I hope will eventually
culminate in unifying the analyzer and CFE diagnostic message
representations into a single set of classes. Until that unification
is complete, both representations will have to co-exist in the
`_fe_analyzer_shared` package. To reduce confusion during that time
period, I would like the classes to have distinct names.

Since the analyzer's `DiagnosticMessage` class is exposed through the
analyzer public API, analyzer clients may depend on the name. So it
makes sense to rename the CFE's `DiagnosticMessage` class.

Tested: standard trybots
Change-Id: I6b6948fe9da18c7b6688333fa12ffeea8e81436f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441831
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-08-04 11:20:23 -07:00
Ryan Macnak ab4f9351b1 Rename vm_platform_strong.dill to vm_platform.dill.
The name has always been annoying because it did not add strong typing. And now there aren't variants of the VM platform to distinguish.

Leave a copy at the old name to not immediately break illegal uses.

TEST=ci
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,flutter-frontend-try,flutter-linux-try
Change-Id: Ie76fa7f16940aa1ba8d582eb5197f0ae55dc8938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429828
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-16 18:33:38 -07: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