Commit Graph

50 Commits

Author SHA1 Message Date
Nicholas Shahan c2c5357a25 [front_end] Add option for expanded invalidation
In this mode when an edit only touches the body of a mixin
(not the public API) libraries that apply the mixin will also
be invalidated.

Add mixin invalidation test.

Issue: https://github.com/dart-lang/sdk/issues/61864
Change-Id: Id4dde67364dcef958ae1e0e0bbf124cec389f5f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459343
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-14 08:53:51 -08:00
Nicholas Shahan cff9ab2c8e [ddc] Add hot reload checks in aysnc bodies
Treats async code like function expressions when adding extra
checks for correctness after a hot reload. This is intended to handle
the cases where code that was statically sound and enqueued before the
reload actually runs after a reload when the soundness may no longer
be valid.

Change-Id: I42cd010175126748937d7df830875bc5b850a565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444368
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-09-30 15:06:34 -07:00
Nicholas Shahan eb4619d139 [ddc] Add hot reload checks for instance methods
Handles errors and type changes on a hot reload when call sites
that were statically valid are retained and run after the reload.

Change-Id: I8bebbd7bc7acc97f55ff930e8f456f99146fbf21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440082
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-07-28 16:16:06 -07:00
Nicholas Shahan 113df82c9f [ddc] Add validation to instance setter calls
Ensures soundness for instance setter calls after a hot reload.

Issue: https://github.com/dart-lang/sdk/issues/60100
Issue: https://github.com/dart-lang/sdk/issues/60112
Change-Id: Ie6736d002752076e5526bd37ae9f103040ed8cdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437124
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-06-30 17:46:09 -07:00
Nate Biggs 31dc969da2 [ddc] Test DartPad-like hot reload workflow.
Refactors the hot reload test suite to support non-FE server based hot reload. Similar to DartPad it uses a DDC process running in '--persistent_worker' mode and sends bazel requests for each reload.

I call this "stateless" mode because the compilation process itself is not maintaining any state. The necessary metadata is passed from one compilation to the other via a delta dill. This differs from the "stateful" mode where the FE server persists a kernel AST in memory from one compilation to the next.

Disregarding the browsers there are effectively 3 run modes now:
- web stateful
- web stateless (new)
- vm stateful

One key difference between the "stateless" and "stateful" modes is the output format of the JS files. In stateful mode DDC emits a file per library being re-compiled. In stateless mode DDC is emitting a single file with all the libraries.

DartPad's workflow is slightly simpler than what's seen in the stateless mode here. It only supports editing a single library so we skip processing any metadata. To simulate this I've added the special 'main_only' which passes a single library for each reload generation. I've verified that this would fail if not for the change recently made to ddc_module_loader.js.

Change-Id: If05da6dbeded4dd20e9e6d9dfaed52151541a19b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434340
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-06-12 17:18:30 -07:00
Nicholas Shahan f4c87f2ae8 [ddc] Add hot reload checks to instance getter accesses
Checks the compile and current hot reload generations. If they are not
equal the value is checked to have a getter of the expected name and
if so it gets called. If not, `.noSuchMethod` is invoked instead.

Issue: https://github.com/dart-lang/sdk/issues/60100

Change-Id: Ib80582b45f87f2ab41b943e0f263167b38601e0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429066
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-05-22 13:27:31 -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
MarkZ 23cefd8aa9 [ddc] Adding support for hot reloaded super getters.
This removes the 'bind' and 'bindCall' methods in our runtime in favor of extending 'tearoff' to support their behavior. Also introduces 'superTearoff' for invoking torn off super members late.

Change-Id: I52ab797558a225c57cc2c6197c7b1bfa7f05a3c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416763
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2025-04-04 11:17:56 -07:00
MarkZ ba90daf304 Reland "[ddc] Overhauling tearoff equality and identity."
This new update adds fixes + tests for cross-module super mixins. Super getters can refer to mixins compiled in other modules, so we need to expose all mixin names to make them accessible from their enclosing library.

This is a reland of commit e4c4d0f839

Original change's description:
> [ddc] Overhauling tearoff equality and identity.
>
> Hot reload requires DDC to update how its tearoffs are represented. Tearoffs obey the following conventions:
> * Instance tearoffs are never identical
> * Tearoffs with the same object target and name have the same hash code (even if they resolve to different functions across hot reloads)
> * Two separate tearoffs of the same member are equal
>
> To support this, tearoff equality must not depend on the bound object and method but a composite of the bound object, torn off member name, and the exact class/object from which the member was torn off.
>
> Notable changes:
> * Methods' immediately bound targets are emitted with member signatures. This is required to determine the bound targets for instance and dynamic tearoffs. Bound targets are identified by `libraryUri:class` strings.
> * `applyMixin` passes in a 'true' bound target. This is because mixin applications' members are considered children of their 'on' class (not the mixed in class) wrt equality/hashCode.
> * `bind` is modified to pass in its 'true' bound object to support mixins' super getters.
> * `tearoff` and `staticTearoff` are modified to accept a bound target string (only required for static tearoffs, as they are bound at tearoff-creation-time).
> * Static tearoffs avoid using their bound object for hashcode and equality, as these libraries may be wrapped in proxy objects.
> * Tearoff equality and hashCode are updated to consider bound object, bound name, and its bound method's immediate target.
> * 'noSuchMethod' and 'toString' methods are always accessed through their extension property during signature lookups.
>
>
> Change-Id: Ica5501b6860c605db50aa945bafb6802a7317511
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406723
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Commit-Queue: Mark Zhou <markzipan@google.com>

Change-Id: I645992030f9106c158426412387ddecafc78e3f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415102
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-03-17 10:34:48 -07:00
Nicholas Shahan 58ba6006a6 Revert "[ddc] Overhauling tearoff equality and identity."
This reverts commit e4c4d0f839.

Reason for revert: Breaks are blocking roll into flutter
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8720592021329723649/+/u/run_test.dart_for_web_canvaskit_tests_shard_and_subshard_0/stdout

Original change's description:
> [ddc] Overhauling tearoff equality and identity.
>
> Hot reload requires DDC to update how its tearoffs are represented. Tearoffs obey the following conventions:
> * Instance tearoffs are never identical
> * Tearoffs with the same object target and name have the same hash code (even if they resolve to different functions across hot reloads)
> * Two separate tearoffs of the same member are equal
>
> To support this, tearoff equality must not depend on the bound object and method but a composite of the bound object, torn off member name, and the exact class/object from which the member was torn off.
>
> Notable changes:
> * Methods' immediately bound targets are emitted with member signatures. This is required to determine the bound targets for instance and dynamic tearoffs. Bound targets are identified by `libraryUri:class` strings.
> * `applyMixin` passes in a 'true' bound target. This is because mixin applications' members are considered children of their 'on' class (not the mixed in class) wrt equality/hashCode.
> * `bind` is modified to pass in its 'true' bound object to support mixins' super getters.
> * `tearoff` and `staticTearoff` are modified to accept a bound target string (only required for static tearoffs, as they are bound at tearoff-creation-time).
> * Static tearoffs avoid using their bound object for hashcode and equality, as these libraries may be wrapped in proxy objects.
> * Tearoff equality and hashCode are updated to consider bound object, bound name, and its bound method's immediate target.
> * 'noSuchMethod' and 'toString' methods are always accessed through their extension property during signature lookups.
>
>
> Change-Id: Ica5501b6860c605db50aa945bafb6802a7317511
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406723
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Commit-Queue: Mark Zhou <markzipan@google.com>

Change-Id: Ic5694976260189f7215dfa3c2318e9a0656f0de6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415100
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-03-12 12:46:38 -07:00
MarkZ 5d624dc584 [tests] Minor hot reload test suite cleanup.
Removing extraneous configs + reporting less for error summaries.

Change-Id: I874e1217f6ba80e230a031c005cc5039464c513d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414828
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-03-12 10:52:17 -07:00
MarkZ e4c4d0f839 [ddc] Overhauling tearoff equality and identity.
Hot reload requires DDC to update how its tearoffs are represented. Tearoffs obey the following conventions:
* Instance tearoffs are never identical
* Tearoffs with the same object target and name have the same hash code (even if they resolve to different functions across hot reloads)
* Two separate tearoffs of the same member are equal

To support this, tearoff equality must not depend on the bound object and method but a composite of the bound object, torn off member name, and the exact class/object from which the member was torn off.

Notable changes:
* Methods' immediately bound targets are emitted with member signatures. This is required to determine the bound targets for instance and dynamic tearoffs. Bound targets are identified by `libraryUri:class` strings.
* `applyMixin` passes in a 'true' bound target. This is because mixin applications' members are considered children of their 'on' class (not the mixed in class) wrt equality/hashCode.
* `bind` is modified to pass in its 'true' bound object to support mixins' super getters.
* `tearoff` and `staticTearoff` are modified to accept a bound target string (only required for static tearoffs, as they are bound at tearoff-creation-time).
* Static tearoffs avoid using their bound object for hashcode and equality, as these libraries may be wrapped in proxy objects.
* Tearoff equality and hashCode are updated to consider bound object, bound name, and its bound method's immediate target.
* 'noSuchMethod' and 'toString' methods are always accessed through their extension property during signature lookups.


Change-Id: Ica5501b6860c605db50aa945bafb6802a7317511
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406723
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-03-11 10:31:19 -07:00
MarkZ 5ec6de2ec9 [tests] Porting deleted super member tests to the hot reload framework.
Change-Id: Ibdbe23fe2da83c9583e0aa4b2b3a2794a8762b67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414663
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-03-11 10:30:02 -07:00
MarkZ 73257e4397 [tests] Porting VM tests for calling deleted class members to the hot reload framework
Change-Id: I0104f25f5522b38bfe09a9546d602a2b0884c008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410942
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-02-24 10:36:25 -08:00
MarkZ a647f0eed0 [tests] Porting top level deleted member tests to the hot reload framework
Change-Id: Ic3561614b75b63556ea91b5a4dd75421cc5d3d5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411084
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-02-20 16:29:25 -08:00
MarkZ c0819ff165 [tests] Porting misc hot reload tests.
Change-Id: Ib77f447954049315a6a4812cf1d6066529fd9057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406683
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-02-19 15:10:17 -08:00
Nicholas Shahan 16960a8638 [tests] Fix tests for changing type parameters
* Handle inconsistencies in the type of a notice in reload reports.
* Update expected error messages when the type parameters of a class
  change.
* Fail reload tests if rejection error was expected but the actual
  error is null.
* Cleanup unused imports in tests.
* Delete change_instance_format7 test because it was split into DDC
  and VM specific versions.

Change-Id: I3b4d6cb3126d7c1fad688c393677e053a005687f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408883
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-02-10 16:26:00 -08:00
Srujan Gaddam 8aa6b413eb [ddc] Update hot reload test suite to use recompile-restart
A new optional suffix to the file names is added: '.restart'.
This allows us to differentiate between hot reload generations
and hot restart generations. All files with the same generation
should either have the suffix or don't. If present, uses the
recompile-request instruction in the frontend server. If not,
uses the recompile instruction. Tests are renamed and a WIP
README is added to document this change.

Change-Id: I2691c5ec0b7336115a76dc0e0369213e74b6ea21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406183
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-02-05 14:51:21 -08:00
MarkZ 3396a7b92a [tests] Adding ddc and vm specific hot reload differences.
Change-Id: If2a398bc8020438b7c46e58cba03180bfa61b660
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407180
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-01-31 21:31:49 -08:00
MarkZ ebbdbe4ef8 [tests] Porting instance and hierarchy change tests to the hot reload framework.
Change-Id: I7a11a43d34772f2020dda235327da71fa388f3ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406062
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-01-31 15:13:18 -08:00
MarkZ 0083128537 [tests] Using git diff over diff for stability in hot reload tests.
Change-Id: Icdbdf4c569fd8ab5de96560722ac62616185a751
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406224
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-01-29 16:17:13 -08:00
MarkZ b6778c956b [test] Porting mixin hot reload tests.
Change-Id: Ie9aedb99878cf4adb40949e8127c6e254dba1162
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406061
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-01-28 17:37:09 -08:00
Nicholas Shahan 4fce27b1f7 [tests] Fix formatting when writing diffs
* Normalize white space around source code strings before producing
  diffs by trimming and appending a single newline character.
* Write an empty line between the source code and diff text in
  generation files.
* Run dart format on all test files.

With these changes you should be able to run the hot reload suite with
`--diff write` and dart format the code multiple times without
introducing changes in the file.

Change-Id: Ifc0b1dd7032bd448f5f6568c5aa3c18dde076c71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405247
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-01-24 09:07:01 -08:00
Nicholas Shahan 5ec1002eff [ddc] Port library show/hide hot reload tests
Change-Id: Iaa7ef742f1204c73e96738cdba774f1263b32797
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405061
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2025-01-21 16:36:01 -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
MarkZ 29fe663917 [test] Porting VM enum tests to the hot reload test framework
Change-Id: I8fc17823e5236ab80d89d96c6e3f7d4b82b5b369
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402762
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-01-03 11:56:07 -08:00
MarkZ 8aa86087a6 [test] Porting VM tearoff tests to the hot reload test framework.
One test crashes due to #59671

Change-Id: I685bab8a87171c619da5bd685bf75fffe9fa7f39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399322
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-12-07 00:10:41 +00:00
MarkZ 9f00613eeb [test] Porting more VM hot reload tests.
Change-Id: I196cbd9bee6996c313285cce89f928e22b4804cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398929
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-12-05 18:35:30 +00:00
MarkZ 861fd1eae5 [test] Adding a level of indirection for more clarity in constant identity tests.
Change-Id: I9aa6c6bf278e8c8357d416d1a25be1eda4a4bf21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398761
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-12-04 00:50:41 +00:00
Nicholas Shahan 0224206aaa [tests] Port const tests from vm hot reload suite
Change-Id: I8fedb4afe8f117e54aa17ff85e0415e818b2c62f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389583
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-11-28 01:23:24 +00:00
Nicholas Shahan 0055f0ab17 [ddc] Add test for super calls after hot reload
Regression test for broken super calls after a hot reload.

Issue: https://github.com/dart-lang/sdk/issues/59628
Change-Id: I799cac6babb45f0a8f7d2dd63fdfbaea72dba9b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398041
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-11-28 00:48:34 +00:00
Nicholas Shahan 47e3ad7f1f [ddc] Add rejection to hot reload test suite
Allows tests to define generation files that are expected to be
rejected as invalid for hot reload.

Tests generation files now support the extension `.reject.dart` to
signal a rejection is expected. A corresponding rejection error
message should be added to the map in the config.json file.

- Add new rejection logic to the file discovery and config file
  parsing.
- Add new reload receipts that are output by the runtime utils when
  running hot reload tests. These receipts are used to verify that
  each file generation was visited (not necessarily accepted) at
  runtime.

Change-Id: Ifee698f0d6502ecfceba2d5c733a2c88fb5daf7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394564
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-11-28 00:34:31 +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
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
MarkZ 5b0128565c [ddc] Porting VM hot reload tests to the hot reload framework related to type updates.
Change-Id: I3c42781acd253ac82658593c96ab92ef6c2cdb50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392466
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-11-07 23:13:37 +00:00
MarkZ 679271edd2 [ddc] Porting hot restart tests to the hot reload framework.
The old hot restart tests only tested DDC-internal state changes, not 'true' hot restart. The 'dart.hotRestart' runtime call is due to be deprecated.

Change-Id: I34e32342bca6fabc886d8283e32ae510f8d49874
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389400
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-10-28 23:11:43 +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 bbdf1952b4 [reload_test] Enabling all DDC hot reload tests.
Change-Id: I8a6a102f87ff162b1624da0917f3ee8db8f2144c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385120
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-09-24 22:03:24 +00:00
MarkZ 6281f58c58 [ddc] Removing --minimal from reload suite diff logic
This was causing diff discrepancies on Mac vs Linux

Change-Id: I2b67b51d1aab959fa99de916d40d282fc5d19f8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384310
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-09-10 20:47:38 +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
MarkZ 87f7758b88 [reload_test] Porting more field modification VM tests hot reload suite
Change-Id: I79d8c405295779ad09f55af514a74f7884ea52a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381940
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-08-23 00:09:08 +00:00
MarkZ 80586c8596 [reload_test] Porting VM hot reload tests related to member/field initialization to the hot reload suite.
These aren't fully inclusive, but they're good enough litmus tests.

Change-Id: I4954ac6cb43ea3bdf704c67c5bd70bf305756f55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380286
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-08-20 17:50:56 +00:00
MarkZ 842c0981b2 [reload_test] Adding several new reload tests.
Change-Id: Ia654e827d7758d44ece6e52f4d8a15aae4f90e97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365122
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-05-01 20:01:19 +00:00
MarkZ 6357371c0a [reload_test] Adding diffs to existing tests.
Change-Id: Icf7135ae46159ca834a54849c72405eec83f9b4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364384
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-04-26 23:05:10 +00:00
MarkZ 9d08a13721 [reload_test] Adding support for negative tests in reload suite.
* Extends the frontend server controller to validate/reject compile errors in compiles/recompiles.
* Extends the config to permit an 'expectedError' entry.
* Adds a handful of tests to the suite (adapted from the VM's hot reload tests).

Change-Id: I47d814e375c4c72d0406ebf5bdfee3f1975c64f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363800
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-04-24 12:45:44 +00:00
MarkZ df75a619c8 [reload_test] Adding support for VM hot reload tests.
VM hot reload are run via:
1) We first emit a dill for every generation ahead of time (full dill on gen 0, incremental deltas subsequently).
2) We start a VM process at generation 0.
3) The VM process runs until it hits a `hotReload` command. It then uses the VM service protocol to connect to itself and reload the next generation.
4) The VM exits when the next generation isn't found.

* Adds config files to reload tests that allow runtime filtering.
* Implements VM-side hot reloading
* Adds several VM-specific hot reload tests

Change-Id: I1c6ad5c4eed426a0189c1b4af31297c9c1dba717
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359200
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-04-07 16:39:49 +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