Commit Graph

2425 Commits

Author SHA1 Message Date
Srujan Gaddam c957483693 [ddc] Initialize and link the necessary library in debugger APIs
Closes https://github.com/dart-lang/sdk/issues/60109

Both getClassMetadata and getClassesInLibrary can be called before
main is called. In order to support this, libraries should be
initialized so that these debugger APIs can inspect them. Similarly,
SDK libraries that are needed before any code can run should be
initialized. In order to support this, they are initialized on the
first initializeAndLinkLibrary call and reinitialized during a
hotRestart (since the libraries are recreated).

Tests are added to evaluate these methods before main is called.
The debugger test helpers are amended to:
- Support breakpoints within the bootstrap script. This is done by
caching the script and querying to see if it has the breakpoint if
the input sources do not.
- Refactor shared test expectation logic.
- Remove an unused method.

Change-Id: I5534d7008436a51243cf51dba01bb8ad06adca69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410602
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2025-02-20 14:15:06 -08:00
Nate Biggs 773cf6b1d5 [ddc] Fix issues with duplicate library name aliases.
The attached bug shows an issue users have been encountering where a constructor seems to be undefined. It turns out this is because DDC is trying to read the constructor from the wrong library.

This is happening because both 'package:dio' and a sister package 'package:dio_web_adapter' both contain a library with the same path: 'src/adapter.dart'. 'BrowserHttpClientAdapter' the class they are trying to reference is defined in 'package:dio/src/adapter.dart'. However, due to a naming collision, their import is referencing 'package:dio_web_adapter/src/adapter.dart'.

This naming collision happens because of the logic in '_jsLibraryAlias'. By truncating the start of the import URI (i.e. 'dio/' and 'dio_web_adapter/') the two libraries map to the same alias. This alias is then used to as the key in the AMD module export object and since both libraries are in the same module, only the second one gets exported.

This code may have been written with the assumption that libraries from different packages would always be in different modules (in which case the shortened paths shouldn't collide) but this is not the case. The fix is to use the full import URI including the package name.

In writing the attached modular test I discovered another issue that only affects es6 imports. The ScopedId resolver was not considering NameSpecifier as a declaration point for variables. This lead to a similar name collision since the import alias's name was also being derived from a truncated import URI. In the test, both 'f1/foo.dart' and 'f2/foo.dart' were being imported 'as foo'. Now one is 'as foo' and the other is 'as foo$'.

The first issue affects both AMD and es6 while the second issue only affects es6. The modular tests run with es6 so the new test fails if either of these fixes is not in place.

The new DDC module system is not affected by either issue since it doesn't use NameSpecifiers and it uses the full import URI as a string to register libraries rather than a shortened alias.

Tested on TGP and with a local Flutter application.

Bug: https://github.com/dart-lang/sdk/issues/56498
Change-Id: I5bdb945cfbe615874b40e2fc4ebba31b661cf3b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410260
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-02-18 13:08:50 -08:00
Nicholas Shahan 1ee0894631 [modular_test] Delete support for macro execution
Mostly a revert of https://dart-review.googlesource.com/c/sdk/+/361261.
A straight revert contained merge conflicts that I resolved manually but
I left some of the cleanup or refactoring in place.

Change-Id: I2add9f4951d7c6c2399d8c95f36b1483279eea44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409401
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-02-13 08:30:33 -08:00
Nicholas Shahan b12fedced2 [ddc] Add hot reload rejection for type parameters
Changing the number of type parameters on a class is not supported
in a hot reload.

Issue: https://github.com/dart-lang/sdk/issues/60101
Change-Id: I3e397f26ca80e655dcb3d2807ddefd59c89adddb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409381
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2025-02-12 12:05:54 -08:00
Nicholas Shahan 39c60997ec [ddc] Add initial hot reload metadata
* Demonstrates the ability to generate metadata when inspecting the
  last accepted and delta components.
* Attach the metadata to the component right before compiling with DDC.
* Use the metadata to avoid deoptimizations in the initial compile
  when they are only required to support a hot reload.
  * Deletion of all type rules for classes that extend Object in the
    initial compile. In the future this should be reduced further to
    only the classes that had a hierarchy change in a hot reload.
  * Type checks on the return value of getters used to represent
    fields.

Change-Id: I2812b564bc3f4d72f005d4bd11fa55ec0eb394ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404940
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-02-11 12:04:50 -08:00
Nicholas Shahan c040cd66e5 [ddc] Pass an empty array when running main
Match the behavior of the ddc module system when running the
applications main method when using the new library bundle format.

This passes an empty JavaScript array to the main method which is
good enough to get the benchmarks that use main method args to run.

The API should be updated in a way that allows you to actually pass
a JavaScript array of Strings when starting the program.

Issue: https://github.com/dart-lang/sdk/issues/35113
Change-Id: I1a9aeb1df7afa5948d7f23517b3ac913aaabb62c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408640
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-02-07 14:53:14 -08:00
Nate Biggs 89af2425f2 [ddc] Append hot restart instruction to hot reload rejection reasons.
By adding this message here, any entrypoint that makes use of this for hot reload (e.g. DartPad, Flutter tools/FE server) will all surface this same message. This probably easier than having each one try to detect errors and append its own message.

Change-Id: I5980d530b66da818e29403cc13407095d8b203dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408380
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-02-07 10:20:53 -08:00
Johnni Winther 7c22f942aa [_fe_analyzer_shared] Remove macro tests and helpers
These are no longer used.

TEST=removed

Change-Id: Ibf5b2de9d1b550c21873b48111161366deb2ddc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407980
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
2025-02-05 03:59:31 -08:00
Johnni Winther c27cec63aa [cfe] Remove macro support
This removes the support running macros in the CFE.

The scanner and package:kernel still have support for the macro modifier. This will be removed in a follow-up.

The metadata expression parser is deliberately left in, since it might serve as the basis for a parser AST.

Change-Id: I06d91eb0fac2e7a71e6afde647b03be3814dbd5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406963
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
2025-02-03 07:13:51 -08:00
Nate Biggs 5855d91ba8 [ddc] Correctly extend type parameters for factory constructors.
RtiTypeEnvironment currently does not support being extended. However it's used for factory constructors which themselves can have generic functions defined in their bodies. This means we have to allow the ability to extend RtiTypeEnvironments as well.

Bug: https://github.com/flutter/flutter/issues/160338
Change-Id: I9b4e79b44f503a4a987e0c38da86fdce81361e4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406344
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-01-30 08:07:30 -08:00
Nate Biggs 44dfe081b2 [ddc] Add a covariant parameter check for optional nonnullable parameters with null initializer on lowered constructor tearoffs.
Change-Id: I77379ee43173ddbbdee25083bd641968eeeb787f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406500
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-01-29 23:07:26 -08:00
Nate Biggs cf4d27487f [ddc] Add options to emit, read and diff delta dills for hot reload.
This will allow DartPad (which invokes DDC directly) to maintain delta dills across each reload.

Change-Id: I801208c6b8f50a0aa20b6f509aa3e32a827a9cdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405661
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-01-29 14:45:16 -08:00
Nate Biggs 6c4028eab8 [ddc] Update ddc_module_loader.js to safely check for localStorage in page.
When running in an iframe without specific flags, DDC may not have access to `localStorage`. In this context, even trying to access `window.localStorage` can cause an exception in the iframe.

Wrapping the check in a try/catch allows us to safely check for access before using it.

Change-Id: I0c5d3d0ac34a550444c12b52f6519a9446ebfe9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405608
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2025-01-24 12:17:26 -08:00
MarkZ 6edbfd93ab [ddc] Updating representation of enums to support hot reload semantics.
Enums are now split between pre and post canonicalization members. A
separate operation during link-time is emitted for every const
enum field. These are required during link time since enhanced enums can have non-trivial type hierarchies.

Example for snippet:
```
enum E {
  e1(1), ...

  const E(this.i);
  final int i;
}

```

Used to emit enum fields as:
```
  dart.defineLazy(CT, {
    get C1() {
      return C[1] = dart.const(Object.setPrototypeOf({
        [_Enum__name]: "e1",
        [_Enum_index]: 0
        i: 1
      }, E.prototype));
    },
  }
```

Now emits them as:
```
// Declaration-time
  dart.defineLazy(CT, {
    get C1() {
      return C[1] = dart.const(Object.setPrototypeOf({
        [_Enum__name]: "e1",
      }, E.prototype));
    },
  }

// Link-time
    dart.extendEnum(dart.const(Object.setPrototypeOf({
      [_Enum__name]: "e1"
    }, E.prototype)), {
      i: 1,
      get index() {
        return E.values.indexOf(this);
      }
    });
```

Change-Id: Id5ce2ec117e59d8daa28df7fe6051e4a7e1a5bc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404723
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-01-23 14:10:59 -08:00
Srujan Gaddam 0037a5c554 [ddc] Add getSourceMap debugger API to dartDevEmbedder
This is used in bootstrappers to set a source map provider
within stack_trace_mapper.dart so that stack traces can be
mapped to their Dart equivalent.

Change-Id: If7dd7024cf8928f1b3a127599015107fcbafb2f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405245
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2025-01-22 12:53:39 -08:00
MarkZ b5232ac632 [ddc] Resolving link-time class members via the embedder.
Note: this may lead to memory leaks if all class declarations are persisted across hot reloads.

Fixes #59628

Change-Id: Iae82d6166602d6e4a005748e64e84b3bbbc81894
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403389
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-01-14 11:06:10 -08:00
Nicholas Shahan dc37a77cf7 [ddc] Add rejection for removed const fields
Reject hot reload requests that remove fields from const classes. This
is consistent with the VM implementation.

Change-Id: I73ff62795abbca62565ee6efd9cb245485d010ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403321
Reviewed-by: Morgan :) <davidmorgan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-01-10 14:46:39 -08:00
Nicholas Shahan f91050ca91 [ddc] Add visitor for hot reload deltas
Initially this visitor will reject reloads (by throwing an Exception).
Future changes will add the ability to record data about the delta to
guide the JavaScript compilation decisions.

- Rejects deltas that delete all const constructors from a class
  (making it non-const).
- Adds ability to test the visitor directly by compiling components
  from source via an in-memory compiler.
- Updates DDC frontend_server compiles to write errors to the output
  stream.

Change-Id: Ib318f42d28367416983266a214f97821a38a2913
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401600
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-01-10 10:20:42 -08:00
MarkZ c033dd24af [ddc] Updating tearoffs to be evaluated on access.
Tearoffs are now represented as a closure that resolves an underlying bound context and property on access. `_boundMethod` and RTI getters must also be evaluated late.

Additionally, we now both canonicalize static methods and tag them with their types at class-declaration time (though lazily) - so that late resolved closures have access to their types.

Some tests have been updated to expect simpler errors. DDC traditionally emits slightly different errors that might aid in debugging.

Change-Id: I1f762b8df45e0766d16dbc8688073768c8bfd233
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401321
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-01-08 13:40:33 -08:00
Nate Biggs 46bd9f351a [ddc] Handle optional/defaulted parameters when created scoped parameter renames for sync* transform.
This was missed in the original implementation of the sync* transformer because prior to my recent change, ScopedIds couldn't end up within a DestructuredVariable.

Change-Id: I2733ce1e01edb50659634347204bac1769269615
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401080
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-12-16 10:01:23 -08:00
Nate Biggs 2f46eaaf0c [ddc] Fix async rewrite ignoring new ScopedId variables.
The async rewriter was ignoring these variables since they were only used for non-user variables that didn't need to be captured. Now that we use these ScopedIds for user variables we need to capture some of them. "userDefined" specifies if the variable should be captured.

Change-Id: I2dbb86e1834982b59883a3d107612ee8f8e2284a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400662
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-12-13 11:10:26 -08:00
Nate Biggs 5c1510de6b [ddc] Rename TemporaryId to ScopedId.
Change-Id: I7bcf2484769dc187b3d3e14286fde2c9023a73c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400661
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-12-13 11:10:26 -08:00
Nate Biggs 8791205c4b [ddc] Remove print from expression compiler.
Change-Id: I14d1428310b3075ed43c492ead2bd20f734ff974
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400480
Auto-Submit: Nate Biggs <natebiggs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2024-12-12 16:41:03 -08:00
Nate Biggs 2616eb2aed [ddc] Use TemporaryId when emitting all kernel VariableDeclaration references.
Some CFE lowerings (e.g. pattern lowerings) result in nested scopes containing VariableDeclarations with the same 'name'. The current DDC transform translates these to the exact same name in JS leading to incorrect semantics.

The `TemporaryId` mechanism automatically renames any variables with the same name that would shadow each other. So we re-use that here to ensure the variables all have a unique name if the CFE hasn't already given them one. If the name is already okay (i.e. not shadowing something else), the name in JS will appear unchanged.

Side note: In a future change perhaps we should rename `TemporaryId`. The general mechanism it implements is more useful than its original intended use.

Fixes: #59613
Change-Id: I708c72528d5df19af48dde01163d375a5588baae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398504
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-12-12 08:56:11 -08:00
Jessy Yameogo ed8e22ff10 fixed bug, 'dartDeveloperLibrary()._extensions.keys' is not a function
Change-Id: I95a59575e3dfebf4e44008d171226994bb63ccba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399784
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Jessy Yameogo <yjessy@google.com>
2024-12-10 20:24:54 +00:00
MarkZ ebf9df9cb1 [ddc] Avoid overriding LegacyJavaScriptObject type rules across link phases.
This prevents libraries from accidentally clobbering LegacyJavaScriptObject rules when linking.

Change-Id: Ia7465013633a34907ca6ab9d1d5bfcdf99ffa13c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395161
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-11-27 00:35:50 +00:00
MarkZ bacbbf83c1 [ddc] Adding RTI subtype cache clearing.
This is required when a hot reload causes changes to the subtype hierarchy.

This change also adds RTI operations for clearing subtype caches and deleting type rules.

The DDC Embedder also now accesses the RTI library to clear subtype caches on hot reload.

See: #57049

Change-Id: I50a43ce342f23060bc28a3654c2da37c362492b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394040
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-11-26 19:33:37 +00:00
Nate Biggs d621ed9782 [ddc] Fix handling of continues in switch statements with labeled continues.
Tested with test case outlined in bug below. This should be tested via Lasse's tests when he lands them.

For slightly more context we compile code like this:
do {
  switch (y) {
    case 1:
      continue L1;
    L1:
    case 2:
      continue;
  }
} while (x);

into something like this:
do {
  while (true) {
    var labelState = y;
    switch (labelState) {
      case 1:
        labelState = 2;
      case 2:
        continue; // <-- This now only continues the while (true).
    }
  }
} while (x);

Bug: https://github.com/dart-lang/sdk/issues/59593
Change-Id: I9b343fd918e48cb44b65e90eab39d70fca4758d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397105
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-11-22 22:18:41 +00:00
Srujan Gaddam a7e4d59d2d [ddc] Fix passing module format to ExpressionCompiler
The DDC library bundle format is a combination of the DDC
format and canary, so therefore check that's the case, and if
so, pass the library bundle format.

Change-Id: I067d2b020e75b703a30fbe7d5f8dc2d31cd4878c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396420
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-11-20 20:29:57 +00:00
MarkZ 7d7d9ab943 [ddc] Extending static fields to perform type checks on first access.
Type changes across hot reloads need to be performed even if the underlying value has already been initialized.
To avoid extraneous type checks, getters replace themselves with a direct access on their value store on first access.

Also updates our builder to support get/set as property descriptor functions.

Adds some extra conditions that will be cleaned up when pragma support is added (#57049).

Change-Id: I44f4a9e1a6fd8a49aca5e629fb21348170a9d80f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393041
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-11-19 23:17:05 +00:00
Nate Biggs 9468f60aac [dart2js, ddc] Fix nested exception handling.
In the flattened control flow state machine generated for dart2js and ddc async functions, there is a single error state variable per function. However, functions can have nested error handling that may try to access stacked errors separately. When we enter a nested try/catch we should avoid clobbering the outer exception as the outer handler may need it later.

To fix this we maintain a stack of errors that we 'push' to when we enter a new try/catch and which we 'pop' from at the end of executing that try/catch.

Fixes: https://github.com/dart-lang/sdk/issues/57046
Change-Id: Ib96a44ab4152f6f9e444f2ee959ec9aa252800f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395580
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-11-15 23:20:00 +00:00
Jens Johansen a9469269d7 [kernel] BinaryReader takes Uint8List, not List<int>
In AOT this makes reading faster:

Output from `out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --iterations=10 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.1 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.2 --arguments="--warmups=10" --arguments="--iterations=5" --arguments="AstFromBinaryEager" --arguments="out/ReleaseX64/vm_platform_strong.dill"`:

```
msec task-clock:u: -8.6925% +/- 0.5737% (-167.09 +/- 11.03)
page-faults:u: 0.1410% +/- 0.0051% (243.00 +/- 8.71)
cycles:u: -10.2918% +/- 0.6161% (-732576747.50 +/- 43853449.16)
instructions:u: -14.4988% +/- 0.0004% (-1636799813.90 +/- 39902.18)
branch-misses:u: -3.4891% +/- 2.1142% (-1166085.00 +/- 706582.35)
seconds time elapsed: -8.7005% +/- 0.5634% (-0.17 +/- 0.01)
seconds user: -9.9752% +/- 1.5104% (-0.17 +/- 0.03)
```

Stats running manually (run as e.g. `out/ReleaseX64/dart-sdk/bin/dartaotruntime pkg/front_end/test/kernel_binary_bench.aot.1 --warmups=10 --iterations=5 AstFromBinaryEager out/ReleaseX64/vm_platform_strong.dill`):

```
AstFromBinaryEagerCold: -12.5174% +/- 3.10688%
AstFromBinaryEagerWarmup: -8.33675% +/- 2.62433%
AstFromBinaryEager: -10.3432% +/- 3.68375%
```

I don't expect there to be much of a change (if any) in JIT as the actual type was in practise always Uint8List anyway.

TEST=Existing tests.

Change-Id: I86b16ed207343848dee2e376f42598c223bbc48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393740
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-08 08:23:42 +00:00
Srujan Gaddam 22833d51da [ddc, test_runner] Add stackTrace debugger helper to dartDevEmbedder and clean up test_runner
Adds a stackTrace helper that returns a stringified StackTrace for
an arbitrary error. Removes importLibrary references in test_runner
now that we have that and removes some calls that didn't do anything
(addAsyncCallback, removeAsyncCallback, and startRootIsolate).

addAsyncCallback and removeAsyncCallback are also removed from the
runtime. Calling these were removed in https://github.com/dart-lang/sdk/commit/8bd3690ab06c3eda2f4996ca60b94fdcc9f76105
so this is just finishing up the clean-up.

Change-Id: I9dacc2b3fd3e27468061d6e59a3207eecdb7cac8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393800
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-11-07 03:40:54 +00:00
Srujan Gaddam e94de78d2b [ddc] Remove statements from the Fun returned by buildFunctionWithImports
This list of statements is intended to support additional
statements that need to be emitted to handle imports/exports.
For the incremental case, no non-import statements exist
and can be safely omitted from the body. We should be
intentional about including these if needed later to avoid
accidentally including unnecessary statements.

Change-Id: I726bb9e980d43c1edd1d0bda2d9be897586638ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393163
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-11-06 20:42:13 +00:00
Srujan Gaddam 65ce9ed581 Add debugger runtime APIs and add/modify tests
- Exposes a minimum set of APIs that are needed by DWDS
a single class Debugger.
- Renames some APIs and modifies the signature to better
align with what's happening and what DWDS actually uses.
Similarly, modifies the internal APIs to handle the new format.
- Modifies expression evaluation test suite to handle the
new module format correctly.
- Modifies LibraryBundleCompiler to emit the right export name.
- Adds/adapts existing tests for the runtime debugger APIs.

With this, all tests within pkg/dev_compiler/test/expression_compiler
pass with the new module format with the exception of two tests within
expression_compiler_e2e_ddc_null_safe_test, which will be fixed
in a future CL.

Change-Id: I296496441ea421ecb57bed3b2e90b92365fef510
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391308
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-11-01 22:09:30 +00:00
Nicholas Shahan 7d00c54b23 [ddc] Enforce unnecessary_breaks lint
Ignore violations in the js_ast sub-directory to avoid unnecessary diffs
with the original package.

Change-Id: Iac8c942e5e2446b8433e2073b546c28e42a8f5cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392700
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-10-30 21:10:38 +00:00
MarkZ d53711d88b [ddc] Reconciling d8 and Chrome timing differences in hot reload suite.
Appending a script to the DOM in Chrome causes microtasks to fire. This change makes the `hotRestart` pathway async and inserts an async callback at the hot restart boundary for d8.

Change-Id: Ib05e9e496b6313d861fb5cb691a5894beed62a6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389224
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-10-28 23:11:43 +00:00
MarkZ 933d630e42 [ddc] Cleaning up unused fields and functions
Removes:
* Unused SDK-specific field emission logic
* after-class-def items, which used to hold lazily emitted classes
* deferred supertypes/classes, which are no longer needed after the new class representation

Change-Id: Ibdaa8d32aecc42c25749cc6a2290ce0bfd4662f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391488
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-10-28 18:17:00 +00:00
MarkZ a5f734592c [ddc] Updating representation for virtual and lazy fields.
This restructures all fields as accessor/value-store pairs, providing a level of indirection required for hot reload.

Major updates include:
- All fields (top-level, lazy, virtual, etc.) now have a value store (represented as a private top-level symbol). The value store is initialized on first access for the initializer.
- Lazy value stores are prefixed with '_#v_' to indicate that they are not replaced on a hot reload.
- `declareClass` and `declareTopLevelProperties` are introduced to append classes/members to libraries. These functions extend the 'original' entity/class with fields introduced by a properties object, ignoring the special lazy value stores mentioned above.
- `defineLazy` is replaced with the above operations.
- Virtual/instance fields are still initialized by inside their constructor on first load (so their getter forwards to its value store). On hot reload, however, uninitialized fields are lazily initialized.
- Final fields now use a sentinel value to check for late initialization errors during the initialization loop.
- The JS AST is extended to support class properties.

Change-Id: I5cc3548477d83897273f3b993b304a804754ec0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386971
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-10-28 18:17:00 +00:00
Nicholas Shahan 368cb645e5 [ddc] Enable sound null safety by default
In the expression compiler worker. It appears all uses manually
pass the flag and this is just preparation to remove it in the
future.

Change-Id: Iad0edfbcab28194b4ffcb520db89943c6239753b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388745
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-10-09 15:50:31 +00:00
Nicholas Shahan ebd0b2ee16 [ddc] Merge the command libraries into one
Copy all of compiler/shared_command.dart into command/command.dart

Change-Id: Id8fb363b2800fe5fd60fae75f7dc557b33a806ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388051
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-10-08 16:51:12 +00:00
Nicholas Shahan b4d5272d99 [ddc] Move command.dart library
From: lib/src/kernel/command.dart
To: lib/src/command/command.dart

This is a step towards organizing the code from shared_command.dart and
eventually deleting it.

Change-Id: I1ca9fcfd3d7d74511957d516c01544f4a68e4e89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388050
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-10-08 00:47:01 +00:00
Nicholas Shahan 45b1612064 [ddc] Delete generic class table
The generic class table is no longer used since changing to the
new representation for generic classes.

Change-Id: I836e0ee9e4b291dab68397554adbbd1a67376b9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388740
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-10-08 00:08:18 +00:00
Nicholas Shahan 085deb8bc4 [ddc] Create new result.dart library
This is a step towards organizing the code from shared_command.dart and
eventually deleting it.

- Move `CompilerResult` from shared_command.dart.

Change-Id: Ibe4b8bbd5c6deb2558392255f3818773fa4ea80e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388049
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-10-07 22:54:09 +00:00
Nicholas Shahan 807660f323 [ddc] Create new options.dart library
This is a step towards organizing the code from shared_command.dart and
eventually deleting it.

- Move `SharedCompilerOptions` and rename to `Options` from
shared_command.dart along with helpers.

Change-Id: Ic9edfb47fc2425a28b1e948d94fad96a2f594108
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388048
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-10-07 21:21:30 +00:00
Nicholas Shahan 9b7f5a0af6 [ddc] Create new arguments.dart library
This is a step towards organizing the code from shared_command.dart and
eventually deleting it.

- Move `ParsedArguments` and helpers from shared_command.dart.

Change-Id: I10a05f9595e5421b6d5498e2fd1138d0acfd5e35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388047
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-10-07 19:27:19 +00:00
Nicholas Shahan 95d13a89fa [ddc] Compile SDK as a bundle of libraries
Cleanup temporary code paths in the stable version of compiler.dart.

Change-Id: I4b60d90345bf8653060772789f55e16fb5db60d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385185
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-10-04 20:08:57 +00:00
Nicholas Shahan d2de06a574 [ddc] Move hierarchy operations to link method
This also includes operations that require a linked hierarchy to
be in place before they are executed.

Change-Id: Idc83d81fe7b27d2137a2102bb155a9a1026b7049
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385184
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-10-04 20:08:57 +00:00
Nicholas Shahan 28806cb806 [ddc] Synthesize dartx as a library
Collect all extension symbols across all "dart:" libraries and
create the dartx library to contain them all.

Change-Id: I334d6e11a1767929bfb8ad5ebf31276b9785d09e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385183
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-10-04 20:08:57 +00:00
Devon Carew 1f8aea0c81 Bump lints to a97011b4b031b1df94765dbacd7d92b0b765c8b9
Changes:
```
> git log --format="%C(auto) %h %s" af68bf0..a97011b
 https://dart.googlesource.com/lints.git/+/a97011b add unintended_html_in_doc_comment; rev to 5.1.0 (211)

```

Diff: https://dart.googlesource.com/lints.git/+/af68bf0cbad88002a2ae19ee8db37b64eb120c32..a97011b4b031b1df94765dbacd7d92b0b765c8b9/
Change-Id: I998d73f5f72e94d5f2922b0751d31620a837555e
Tested: analysis only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387601
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2024-09-30 21:48:03 +00:00