330 Commits

Author SHA1 Message Date
Nicholas Shahan de18b40933 [ddc] Split hot restart into two phases
Exposes two new methods `hotRestartBegin()` and `hotRestartEnd()` in
the `DartDevEmbedder`. This provides a more customizable loading
of sources across the variety of environments we are supporting.

Change-Id: Id7a35695234f0625fe4de1d67c9d5a8055bad461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500240
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-05-08 11:43:35 -07:00
Nicholas Shahan bc3a70cdc8 [ddc] Format and cleanup comments in the embedder
* Preparation for merging this file with the internal version.
* Fixes lint violations and consistency issues in the docs and formatting.

Change-Id: Ib563a3bb834509de819895ea99483fab7d0e4bb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465485
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-12-02 10:53:30 -08:00
MarkZ bbc99947c9 [ddc] Rolling internal dart_library.js into the external module loader.
Change-Id: If25fd9ac78d795d16b7edca507df0b806a0ebf39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433262
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-06-06 07:20:10 -07:00
Nate Biggs f7068a415e [ddc] Relax conditions on allowed defineLibrary calls during hot reload.
The current conditions make it so that every library transitively reachable from a reload target (and therefore included in the DDC output) must be known in the client when `dartDevEmbedder.hotReload` is called.

While this is the case for pages running with DWDS, it's an unnecessary constraint. Some users may only care about reloading a specific subset of known libraries. As is the case in dart-pad when we only need to reload the main library as we know this is the only code that can have changed.

Any new libraries must also registered and initialized as this is new code not yet in the page. This would happen if a new import was added to the code.

Change-Id: I164f59a6931fd809867716c164cb467880806f8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432440
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-06-03 12:02:03 -07:00
Srujan Gaddam 55c5febc6a [DDC] Renamed captureHotReloadEndHandler to capturedHotReloadEndHandler
Keeping it consistent with capturedMainHandler.

Change-Id: I9fd05321fd6a49811739a8d07fa0e27558f03f27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429541
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
2025-05-19 15:01:43 -07:00
Srujan Gaddam 8f8ad12af6 [DDC] Allow deferring of hotReloadEnd via callback
This allows the application to set breakpoints in the
new scripts before pushing them into the Dart runtime.

Change-Id: Ica4613e061bf7db05b3e17366d3f3a4e0e46685d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429422
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-05-19 12:46:50 -07:00
MarkZ 028914a3ef [ddc] Emitting embedder link functions via symbol property.
Fixes errors when top level 'link' members exist.

Change-Id: I0a339298ff9f51f6cd1f6af7c983eeda4a013956
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426002
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-05-02 15:00:17 -07:00
MarkZ 2284e20fcf [ddc] Adding IndexedDB to auto-loaded libraries with global side effects.
Change-Id: If5e0fdd6c269c1933018b741813d180c8d62c660
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425660
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-04-30 11:37:22 -07:00
Srujan Gaddam c497d099db [ddc] Add hot restart initializers to a pending map instead
It is possible with the way the library manager is written
today that during a hot restart, a previously defined library
may be initialized. Because the manager uses the same map
to store the initializers for the non-hot restart case and
the hot restart case, we may end up using a newer version of
code in an older generation. Instead, this CL adds a pending
map that stores the hot restart initializers so that we can
later add them to the general map of initializers right before
we call main during a hot restart and during synchronous code.
This should avoid that race condition.

Change-Id: Ib40cbe5bec400035276ebd6fca12efed7077a2b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425190
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-04-29 17:11:45 -07:00
Srujan Gaddam 8ac1fbdd07 [ddc] Emit call to register source maps in DDC library bundle format
- Sets the name field in the emitted LibraryBundle node to
to the provided module name. We tried to avoid providing a
module name as the notion doesn't map cleanly to library
bundles, but we need to respect the provided module name.
- Emits a call to set the source map for a given library
bundle url. We don't need the full trackLibraries call so we
don't use it.
- Adds a check to avoid redefining libraries outside of a hot
reload or a hot restart. This was handled in the same code
where we emitted trackLibraries calls in the old compiler
for dynamic modules, but we want this for all code, regardless
of whether dynamic modules is enabled. So, add this check in
the library manager instead.

Change-Id: Ic4e86dbfca2b3eefa99cce44fae0973164ab77a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423620
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-04-29 17:11:45 -07:00
Nicholas Shahan be6d2e3a00 [ddc] Cancel futures after a hot restart
Outstanding async code now checks and cancels itself if it was created
in a previous version of the application from before a hot restart
operation. This includes outstanding `Future`s created by calling the
`dart:js_util` helper `promiseToFuture`.

Issue: https://github.com/flutter/flutter/issues/166004
Change-Id: I342bbd2f8eda6b58d2f0fdaf3c00f55f03561b1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423961
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-04-28 23:25:56 -07:00
MarkZ cd20b29917 [reload_test] Resolving d8 timer problems in the reload suite.
d8 tests weren't executing code after a hot restart due to several factors:
1) subsequent calls to `main` after a hot restart weren't being added to an event loop.
2) periodic timers, which use `setInterval` weren't updated to check for the hot restart generation.
3) d8's simulated timers run synchronously, which interacts poorly with our async implementation. Periodic timers never cede to the async task that handles changing hot restart generation, so they would run forever whenever an error was thrown.

Changes:
* Added a helper to d8.js that cancels all timers.
* d8 now cancels all timers if an async main registers an error (via a handler on main).
* `setInterval` is now implemented.
* The embedder now accepts a publicly modifiable config object. `capturedMainHandler` and `mainErrorCallback` can be set via this object.

Change-Id: I523752ea69e8fd1f1ec0f6f585a484b670534cfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421680
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-04-18 15:08:48 -07:00
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
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 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
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
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 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
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 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
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
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
Sigmund Cherem 00b11411d6 [ddc] support library cycles in the new module format.
We'd like to properly support cases like:

```
a.dart:
  import 'b.dart';
  class A extends B {}
  class C {}

b.dart:
  import 'a.dart'
  class B extends C {}
```

Here both A and B will request a reference to the other during
linking.

We break the cycle by storing libraries in the map after they are
initialized, but before we recursively link them. Now an access to a
library proxy has different guarantees:
* during linking, it guarantees to return an intialized library.
* during program execution, it guarantees to return a linked
  library.

Aside from this change, this CL does a minor change to the logic on
`hotReloadEnd` to not change the state of the `libraries` array on a
hot-reload. This change is technically not necessary, but may help us
more clearly track the invariants of the library map: the new logic
keeps updates to the map monotonic over time.

Change-Id: Id2aafa3d94c6bff32b7ddb326f883f978bff6bf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385324
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-09-27 18:07:48 +00:00
Sigmund Cherem 9c91f31c10 DDC implementation of experimental dynamic modules.
In particular,

* Provides a DDC implementation for dynamic modules, where the download
  and instantiation of the module is delegated to the embedder of the
  program.

* Exposes an embedding API to allow embedders to define the loading logic.

* Adds a flag to compile code as a dynamic module. This includes
  generating an entrypoint trampoline and checks to validate that a
  dynamic module doesn't stump over previously defined libraries.

* Adds test coverage for DDC under `pkg/dynamic_modules/test/`.

Test suite can be run by executing:
```
DART_CONFIGURATION=ReleaseX64 out/ReleaseX64/dart-sdk/bin/dart \
    pkg/dynamic_modules/test/runner/main.dart -t ddc
```

Once we provide integration of test configuration results to that test
runner, we will add it as part of the test matrix.


Change-Id: I626b5fefe9a27546cc6d1630d17e812544a711c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379748
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-09-10 00:55:02 +00:00
MarkZ 6db84ef903 [ddc] Adding hot reload test with DDC's new module system.
Change-Id: I55c0b4d3c74654c192b6e664120778b057aa7161
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383820
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-09-09 23:16:48 +00:00
Nicholas Shahan ec0445ae79 [ddc] Add hot restart to new ddc module format
Add a simple implementation that throws out all libraries and runs the
main method again which triggers all libraries to be initialized with
fresh values.

Move the hot reload tests to the ddc canary test configuration
since that is where the support works at this time.

Update frontend server to use the use the new version of the DDC
LibraryCompiler when the emit library bundle option is true.

Change-Id: I6eba613106672536ef8bfcb0ff0a55749e2fb63c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381902
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-09-09 17:58:56 +00:00
Nicholas Shahan 3cc6105316 [ddc] Add empty link methods to new ddc module format
The link methods will contain all operations required to link class
hierarchies across library boundaries.

Change-Id: Iaa2bc566e17d215fd8bd9a20e6fc668679a2b58c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380208
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-08-30 22:53:32 +00:00
Nicholas Shahan c958bcc4cc [ddc] Use import URI to name a library
Import URIs are normalized by the CFE and should be globally unique in
the program. They serve as a good identifier to name a library in the
new "ddc" module format.

Change-Id: I9e255221bcffba52ad80138a4672d0490b7cbacd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381781
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-08-30 22:53:32 +00:00
Nicholas Shahan 49f630c53b [ddc] Introduce a hot reload variant of "ddc" modules
These new modules are only used when compiling with the `--canary`,
`--modules=ddc` and no other module formats.

This new flavor of the module system treats the output .js files as
a bundle of one or more Dart libraries.

In this change the Dart SDK module is still compiled with it's
libraries mixed together but exports them individually. Ideally this
is temporary and eventually they can be compiled in isolation as
well.

All other modules are compiled in isolation so class hierarchies many
may be broken until proper cross library linking is implemented in a
followup change.

Change-Id: I27e58a445476198bd8613bb63c57cb96c0d5bc55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379261
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-08-20 20:14:36 +00:00
Elliott Brooks 51e8a74f07 [DDC] During hot-restart, wait to run main if the promise readyToRunMain is provided
Bug: https://github.com/flutter/devtools/issues/7231
Change-Id: Iebd1caa62cff4f41a226d7214c7a8ae330ed02c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355880
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
2024-04-18 21:22:15 +00:00
MarkZ d30283f0a1 [ddc] Adding tests for pkg:reload_test and enabling reload tests in test bots.
* Adds tests for the memory filesystem
* Enables hot restart/reload tests
* Adds flags to the hot reload suite
* Makes path resolution logic windows-friendly
* Adds test-reporting logic for trybots to hot reload tests

Change-Id: Ic51a0b8a3c6f8b6de20b58b2ac185dacf444cf47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353788
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-03-25 23:58:26 +00:00
MarkZ 210e120fbd [ddc] Creating a hot reload and hot restart test suite.
The hot reload runner currently only supports d8, but I plan to add support for Chrome and VM execution.

Notable changes:
* Creates `package:reload_test` with helpers for running this suite.
* Updates the module loader with D8-specific branches and hooks for hot reload/restart.
* Exposes DDC runtime variables via a `HotReloadTestRuntime` API.
* Ports constant equality hot restart tests from webdev/dwds (validated to fail if either cache-clearing mechanism fails).
* Partially rolls DDC's d8 preamble forward (towards dart2js's).
* Wraps D8's timer implementation with custom timeout logic to better match Chrome's timing semantics when executing with native JS async.

Tests for the framework and matrix updates will be added in an upcoming change.

Change-Id: I2773b29f464cfd0330e4c653c05e117ae150b4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350021
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-03-05 00:12:18 +00:00
MarkZ 91d22a7e40 [ddc] Renaming dart_library.js to ddc_module_loader.js
This also removes deprecated references to the DDC module system as the "legacy" module system.

This is part of an ongoing effort to deprecate the AMD module system: https://github.com/dart-lang/sdk/issues/52361

Change-Id: Ic32c6c6a0b7bf2c3bf0326be42cc9a88db8e303e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348183
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2024-01-30 19:43:49 +00:00
MarkZ 5d4e742a67 Updating dart_library.js to be consistent with its internal version.
Change-Id: Ia90393022cf43a713bf9f6efb36f3f29b13aa456
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338422
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-12-06 21:50:54 +00:00
Nicholas Shahan 1e1266f8e6 [ddc] Sync dart_library.js from internal
Fixes: https://github.com/dart-lang/sdk/issues/52372
Change-Id: I9cc76c685b9234118a66fa38d2d4e03c2d3fc434
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306916
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-06-05 17:59:24 +00:00
Mark Zhou 887505e3ab [ddc] Creating dart_library API for deferred loading
This is part of a series of CLs to enable real deferred loading in DDC.

- Creates a new top-level object in dart_library.js for holding the state/API
  for deferred loading.
- Only supported in the DDC module system

This also contains a bunch of cleanup/comments for our internal JS Linter. Notably, 'var' is not allowed, so we're attaching our top level namespace objects to `self`.

Change-Id: I230d63f044e85e7d16644525ff79fa9522398c87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289400
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-04-10 23:00:41 +00:00
Mark Zhou a92274cae8 [ddc] Rolling internal dart_library.js into SDK
Change-Id: Ifb1cf1aed53b04eaa0a258668eab6b4b8f19df80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286609
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-03-07 19:44:26 +00:00
Nicholas Shahan 2b4a3b082b [ddc] Merge remaining diffs in dart_library.js
- Copy the internal version of dart_library.js without any changes.
- Unblocks syncing this file again.
- Update ddb script to use the dart2js preamble for d8 which includes
  assignment of a global `self` and the fake event loop for better
  error handling.

Change-Id: I01c2ad82fe7c36bb393f9eab897f558daabf6b8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181522
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-02-01 19:55:49 +00:00
Nicholas Shahan 0551fdc7f1 [ddc] Format dart_library.js
Just some preliminary formatting to make it easier to see the diffs
when I merge the changes from the version in google3. The diff
algorithm gerrit uses doesn't handle the change in indentation very
well.

Change-Id: I2a4daa50d0051140569d51bea5845a0366ba1dad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180700
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-01-25 18:47:53 +00:00
Mark Zhou 05d46af646 [dartdevc] Synchronizing dart_library.js with internal hot restart change.
See: cl/352082170
Change-Id: I6bb9cc27997d1ce2117c58d5e3b3ee3a299e7c2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180260
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2021-01-21 00:39:13 +00:00
Sigmund Cherem 1a98374702 [dartdevc] Make dart_library.js compatible with d8.
This change makes dart_library.js more resilient so it can run in a
browser or in d8.

This is a necessary step to later enable test.py dartdevk tests in d8.

Change-Id: Ic8e5bbc9f1bbc6707a876208605f4fcaad41cee7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177000
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2021-01-06 01:53:30 +00:00
Nicholas Shahan 1869a54132 [ddc] Update ddb to run with ddc/legacy modules in d8
- Fixes broken benchmarks in ddc because the benchmarks run in
  d8 with the ddc module system can handle conflicting library
  names more gracefully than es6.

- In the future we need to update the source of truth for
  dart_library.js so we can keep the file in sync.

- Removes the ability for ddb to run with any precompiled sdk.js
  from a dart installation. Now you must run a build first and
  the sdk.js files from that build will be used. This means the
  `--debug` flag no longer changes which sdk.js files are used.

Change-Id: Icaf78956f93ff643d23e68001354ec08c9c28b12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166926
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-10-24 00:14:42 +00:00
David Morgan 056bd5e72f Reland "Revert "[dartdevc] record metrics""
This reverts commit a0e4f0575a.

Reason for revert: Issues with hot restart in google3, see b/152181536.

Original change's description:
> Revert "Revert "[dartdevc] record metrics""
> 
> Reland with fixes for internal build (patch set 2+)
> 
> Change-Id: I5b130d020c9437a2c52dd074ad007e1fef7a8fa5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139241
> Commit-Queue: Vijay Menon <vsm@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Gary Roumanis <grouma@google.com>

TBR=vsm@google.com,sigmund@google.com,grouma@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I012e1adaa405e85fd1a3d7d280b889b7df44e5b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140580
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
2020-03-23 12:16:13 +00:00
Vijay Menon a0e4f0575a Revert "Revert "[dartdevc] record metrics""
Reland with fixes for internal build (patch set 2+)

Change-Id: I5b130d020c9437a2c52dd074ad007e1fef7a8fa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139241
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2020-03-19 13:09:59 +00:00
Vijay Menon 4093d08271 Revert "[dartdevc] record metrics"
This reverts commit 73347e0cad.

This is breaking the internal build.

TBR=grouma,sigmund

Change-Id: Iad093ddb8c996cd65571d00b3d711453358a4f26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139001
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
2020-03-11 01:38:38 +00:00
Vijay Menon 73347e0cad [dartdevc] record metrics
Embeds metrics in generated JS code to measure code size / load times.

Change-Id: I13b2b3cb458af571702c4f559af8b9c9b35a7562
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138891
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-03-10 18:19:50 +00:00
Vijay Menon 8a947deffa [dartdevc] clear console on hot restart
Internal request b/147818704

Change-Id: I08c655c74ea10b6f14ffde8283cbfc286dfae41b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132180
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2020-01-16 22:07:18 +00:00
Jenny Messerly c0c3fc4c5f [dartdevc] fix #34596, hot restart can now clear field & cache state
This adds a method to the internal SDK runtime library that can be
called to clear state when a hot restart is desired.

This also refactors some of the logic around ignoring type errors,
as we need to ensure we can clear those caches. Also I noticed a bug
where the result of isSubtypeOf was assumed to be non-null, but this
was not the case. The new structure should make this more clear.

(Note: I think we may be able to remove a lot of the code for ignoring
type errors soon.)

Change-Id: Icf5072ffe21aefd85e9816ffc2fc29f679839bc4
Reviewed-on: https://dart-review.googlesource.com/c/78324
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
2018-10-18 19:52:32 +00:00
Bob Nystrom 68dc77f456 Build DDC's SDK as part of the regular build.
This involves a few main pieces:

- Add code to the GN scripts to generate DDC's patched SDK and then
  compile it to summaries and JS in the build output directory.

- Add support to the underlying DDC build scripts to support controlling
  which files are built where.

- Update test.dart to use the DDC SDK from the build directory.

- Update create_sdk to use the built SDK instead of the checked in one.

- Fix various internal DDC tools to build their own copy of the SDK
  (since they can't easily find the one in the build directory because
  it's path if config-specific) and use those.

- Delete the checked DDC SDK JS and summaries.

I think I got everything working. The built Dart SDK looks fine -- it's
identical to one built using the old build scripts.

The various tools and DDC's little test runner I *think* work, but there
may be a bug or two in there. I tried the various things I could and it
seems like they work but it's hard to tell since they may be kind of
broken right now anyway.

Bug:
Change-Id: Iea77915a5c1cc8450f60ebfbdf8c725c7ea2f32c
Reviewed-on: https://dart-review.googlesource.com/18144
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2017-11-20 23:24:07 +00:00
Vijay Menon f70f544e57 Fix source map entries for field accesses
This improves:
- stepping through assignment expressions in devtools
- hover on fields when on lhs

Change-Id: Ifee0d7b0fe2de65494182f6818b9dbcd0a79087d
Reviewed-on: https://dart-review.googlesource.com/21820
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Alan Knight <alanknight@google.com>
2017-11-17 23:38:45 +00:00