Commit Graph

152 Commits

Author SHA1 Message Date
Johnni Winther 678c4ac77f [frontend_server] Remove binary protocol
This was added to support macros

Change-Id: I1115e5d507a0f0bb6764fe49a11e496571d7cb5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420701
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-04-08 00:18:40 -07:00
Johnni Winther 06d938046f [kernel] Remove NonNullableByDefaultCompiledMode
and TargetFlags.soundNullSafety

TEST=existing

Change-Id: I5e28d3d187b0f84fa23130c042fd3c55b89c687c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413460
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-19 01:37:07 -07:00
Mayank Patke 0c55c7e573 Remove unsound web configurations from test matrix.
This CL also removes references to unsound .dill files from the test
matrix and other build scripts and disables some of the option handling
that would lead to requiring unsound .dill files.

Change-Id: I89f701f8f5e1168bf974b5b44bfbafd5a39954fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412401
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-02-26 15:57:55 -08:00
Jens Johansen 2fff7d83e8 [CFE/VM] Make IncrementalCompilerResult classHierarchy, coreTypes non-nullable; always use latest
This also fixes a potential leak on missing .accept call where using the
non-latest coreTypes in the VM causes us to hold on to old libraries.

Tested: CI
Change-Id: I3a4a25dab83de0d5113b9f08ec745ac181c24b9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411580
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-02-26 00:43:19 -08:00
Alexander Markov 7fd0d073a9 [vm] Cleanup experimental createUriForKernelBlob API
This API was added in https://dart-review.googlesource.com/c/sdk/+/232682
in order to support one of the strategies for running macros,
but it is no longer needed.

TEST=ci

Change-Id: I8da233932351f27fd5dfd01b66f481195d7ca0e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407540
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-02-03 12:55:53 -08:00
Johnni Winther 7b9c5d938b [ddc,frontend_server] Remove macro tests
Change-Id: I1227eaed501e0175859e3c7759d88a8b19e8f4d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406964
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-02-03 00:37:19 -08:00
Srujan Gaddam 63261a7b6d [frontend_server/ddc] Add recompile-restart instruction
- Adds a new instruction intended for recompiles during a hot
restart. This is desired so that DDC can differentiate between
the two recompiles and emit errors for hot reload. The VM only
ever recompiles during a hot reload, so they won't need this.
- Adds some tests to make sure recompile-restart doesn't trigger
errors that recompile will. Also tests that they're virtually
similar otherwise.
- Fixes a small issue in the delta inspector to use importUris
instead of fileUris when computing the LibraryIndex.

Change-Id: Ic375167ec72934cd380c4f538b45566bd87de433
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406200
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-01-29 17:06:58 -08:00
Nicholas Shahan 8968e0e2d6 [ddc] Remove unsound null safety option from tests
Change-Id: I1da8a572fc3556b03141a312375fa91bb3a8f358
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386084
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-01-28 09:24:00 -08:00
Sigurd Meldgaard 862ca5b12e Opt front_end_server test fixtures out of package_deps validation
Change-Id: Ia0e557f4546b32390675d0addd1a2004113a1a46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404564
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2025-01-24 01:02:48 -08:00
Derek Xu fc95268a36 [ResidentFrontendServer] Cache the compiler options that were last used
to compile every entrypoint

This is necessary to ensure that the options used when performing
compilation during expression evaluation or hot reload match the options
that were used to compile the running program before it was started.

TEST=test case added to pkg/dartdev/test/commands/run_test.dart, CI

CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes in
sdk/lib/vmservice/running_isolates.dart.
Change-Id: If11207e090d9b02d5a6a8396e09dc90d0c874f58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403240
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-01-08 14:51:12 -08:00
Derek Xu 9a6f6c5a94 [ResidentFrontendServer] Add 'compileExpression' endpoint
TEST=test cases added to
`pkg/frontend_server/test/src/resident_frontend_server_test.dart`

Change-Id: I6ffb810d38fc4b13326cb828785aaf6eb6de90f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394764
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-12-20 09:00:17 -08:00
Derek Xu 0ce6724f40 [ResidentFrontendServer] Add 'replaceCachedDill' endpoint
TEST=test case added to
`pkg/frontend_server/test/src/resident_frontend_server_test.dart`

Change-Id: I45a4b28c8c89714dcb93fa7f64874e158a0d69df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394763
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-12-11 13:26:55 -08:00
Derek Xu e1faaad954 [ResidentFrontendServer] Fix Windows test failures
Fixes: https://github.com/dart-lang/sdk/issues/59659
Change-Id: I3ea0b01c1e12ada5e33b2a43106cd5e8f318eb28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399700
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-12-11 13:26:55 -08:00
Derek Xu 6eae080b55 [ResidentFrontendServer] Make ResidentFrontendCompiler handle dill caching instead of dartdev
TEST=modified the "kernel cache respects directory structure" test case
in `pkg/dartdev/test/commands/run_test.dart`, CI

Change-Id: I93ebfd8860904988f36f4232b5461e5c6e64884d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394640
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-12-03 19:17:51 +00:00
Derek Xu 0ac63b6d79 [package:frontend_server] Move ResidentCompilerInfo and sendAndReceiveResponse from package:dartdev to package:frontend_server's resident_frontend_server_utils.dart
Change-Id: Ie3c8ac69413d55e510d86c5b20f059d5d5301ec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-11-28 16:18:52 +00:00
Srujan Gaddam 879046e133 [frontend_server] Refactor usage of module to library bundle
With the new (and eventually, only) module format, we refer
to collections of libraries as bundles rather than modules.
This convention is a better fit as the frontend server
already treats modules as a collection of libraries.

Furthermore, places where we use the word "module" may be
better communicated by using "library bundle import" (the
component URI) or "library bundle name" (the synthesized
name we give library bundles).

This CL leaves usages of modules that are tied to user-facing
flags for clarity, e.g. "module format" and "useDebuggerModuleNames".
It also ignores usages where the intention is very much tied
to a module e.g. when using require.js.

Change-Id: I363b1eac955f710accece9fa3a8ea2624c751430
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-11-27 21:13:00 +00:00
Srujan Gaddam 32565d1bcd Reland "[frontend_server] Soft-deprecate moduleName for compileExpressionToJS"
This reverts commit 817306a735.

Reason for revert: Later patchset includes fix for `frontend_server_circular_evaluate_test`.

The fix is to cache the bundle/program compiler for all the
libraries in the strongly connected component, and not just
for the initial one that determines the component uri.

Original change's description:
> Revert "[frontend_server] Soft-deprecate moduleName for compileExpressionToJS"
>
> This reverts commit 294a50fc6f.
>
> Reason for revert: This breaks `frontend_server_circular_evaluate_test` in DWDS.
>
> Original change's description:
> > [frontend_server] Soft-deprecate moduleName for compileExpressionToJS
> >
> > https://github.com/dart-lang/sdk/issues/58265
> >
> > The DDC library bundle format does not give names to modules.
> > Therefore the frontend server should try and find the compiler
> > associated with the library and not the module to be consistent.
> > This then means that moduleName becomes entirely unused, and
> > therefore we can soft-deprecate it.
> >
> > Change-Id: I241c63a346d046405599384409a373ab12be2654
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396102
> > Commit-Queue: Srujan Gaddam <srujzs@google.com>
> > Reviewed-by: Johnni Winther <johnniwinther@google.com>
>
> Change-Id: I74b096f7ebc322c9d4428d236ab226ef1adcb6b9
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396567
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: I45852c29a0b5735976f6a5f649f3ee84b26ef76c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396572
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-11-25 18:42:46 +00:00
Srujan Gaddam 817306a735 Revert "[frontend_server] Soft-deprecate moduleName for compileExpressionToJS"
This reverts commit 294a50fc6f.

Reason for revert: This breaks `frontend_server_circular_evaluate_test` in DWDS.

Original change's description:
> [frontend_server] Soft-deprecate moduleName for compileExpressionToJS
>
> https://github.com/dart-lang/sdk/issues/58265
>
> The DDC library bundle format does not give names to modules.
> Therefore the frontend server should try and find the compiler
> associated with the library and not the module to be consistent.
> This then means that moduleName becomes entirely unused, and
> therefore we can soft-deprecate it.
>
> Change-Id: I241c63a346d046405599384409a373ab12be2654
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396102
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I74b096f7ebc322c9d4428d236ab226ef1adcb6b9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396567
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-11-21 19:58:56 +00:00
Srujan Gaddam 294a50fc6f [frontend_server] Soft-deprecate moduleName for compileExpressionToJS
https://github.com/dart-lang/sdk/issues/58265

The DDC library bundle format does not give names to modules.
Therefore the frontend server should try and find the compiler
associated with the library and not the module to be consistent.
This then means that moduleName becomes entirely unused, and
therefore we can soft-deprecate it.

Change-Id: I241c63a346d046405599384409a373ab12be2654
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396102
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-11-20 20:29:47 +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
Jens Johansen 0329ebfd99 [CFE et al] Lint for fields with StackTrace.current
This CL primarily adds a lint for fields with `StackTrace.current`
which is often useful for debugging, but shouldn't be left in.

* Add an ast visitor after the "explicit creation test",
  finding - for now - `StackTrace.current` calls in fields.
  This should have caught the left-in debug such in
  https://dart-review.googlesource.com/c/sdk/+/379281.
* Renamed explicit_creation to compile_and_lint
* Remove (for some time) unused "smoke_test_quick" files.
* Add kernel to the compile_and_lint suite, but ignore it for explicit
  creation (i.e. kernel will also be checked for fields
  with `StackTrace.current`).

Change-Id: Ib886d23a8945e7063dc673a7f99cbb3a6adc1139
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382361
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-08-28 09:46:08 +00:00
Srujan Gaddam f3aa176765 Test both AMD module format and DDC module format + canary in frontend_server_test
DDC hot reload requires a new module format. This is
represented by the intersection of the DDC module format
and canary. Currently, this test file only tests the AMD
module format by default. This change duplicates all the
existing tests with the AMD format and tests them with the
DDC module format + canary.

Also cleans up a TODO to use named parameters for
compileExpressionToJs.

Change-Id: Ic93a748f6efef9463cb343cb19f243d895dac3b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377765
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-07-30 23:33:05 +00:00
Nate Biggs 8bd3690ab0 Reland "[ddc] Update DDC compiler to start using the new async transform."
This is a reland of commit d84f908641

Includes fixes:
--- Catch scope fix ---
Each catch block should define its own scope, but the compiler was not treating the body of these catch blocks as a scope. This was leading to incorrect variable renaming.


--- Duplicate label fix ---
Labels weren't being removed from the _labelNames Map after being used so multiple nodes were getting tagged with the same label. Note: This didn't actually cause any bugs because the label closer to the break statements using those labels was the correct one.

--- addAsyncCallback cleanup ---
The new async semantics actually don't require managing addAsyncCallback and removeAsyncCallback calls (proxies for async_helper.asyncStart and async_helper.asyncEnd). None of the other backends manage these themselves. It's up to tests to ensure they call async_helper.asyncStart and async_helper.asyncEnd.


Original change's description:
> [ddc] Update DDC compiler to start using the new async transform.
>
> Updates compiler.dart to use the new async transformation.
>
> Some key things to note:
> - Dart Let and BlockExpression expressions are represented as IIFEs in DDC compiled code. For non-async code this works fine but this doesn't work when they contain "await" expressions. When these expressions contain awaits we use the same lowering as we would for an async function, but instead apply it to the IIFE function. Then we simply await the IIFE Call expression as the IIFE will return a future after the transform.
> - For async/sync*/async* functions we want to make sure parameter initialization happens synchronously before any of the async logic is hit. To do this we first apply the async transform the user-code function body. We then prepend the paramter initialization logic to the body of the transformed function.
> - We add support for JS_RAW_EXCEPTION which allows the machinery in async_patch to access the wrapped JS exception in a catch block rather than the unwrapped Dart exception.
> - Stacktraces and sourcemaps have some differences. There is still room for improvement in these but they should at least allow users to reasonably step through parts of the async code.
>
>
> There are also several test fixes/updates associated with this change. The test_runner wrapper no longer has to inject in asyncStart/asyncEnd calls, these are handled by the new async logic.
>
> Change-Id: I0f9f547cd9eb52ff7d850d277876d4d57568a14e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374444
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>

Change-Id: Idfe05c0628b2b91f474d08d99427961381debeb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/376000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-07-30 03:13:58 +00:00
Nate Biggs 1812619b20 Revert "[ddc] Update DDC compiler to start using the new async transform."
This reverts commit d84f908641.

Reason for revert: Causing internal failures.

Original change's description:
> [ddc] Update DDC compiler to start using the new async transform.
>
> Updates compiler.dart to use the new async transformation.
>
> Some key things to note:
> - Dart Let and BlockExpression expressions are represented as IIFEs in DDC compiled code. For non-async code this works fine but this doesn't work when they contain "await" expressions. When these expressions contain awaits we use the same lowering as we would for an async function, but instead apply it to the IIFE function. Then we simply await the IIFE Call expression as the IIFE will return a future after the transform.
> - For async/sync*/async* functions we want to make sure parameter initialization happens synchronously before any of the async logic is hit. To do this we first apply the async transform the user-code function body. We then prepend the paramter initialization logic to the body of the transformed function.
> - We add support for JS_RAW_EXCEPTION which allows the machinery in async_patch to access the wrapped JS exception in a catch block rather than the unwrapped Dart exception.
> - Stacktraces and sourcemaps have some differences. There is still room for improvement in these but they should at least allow users to reasonably step through parts of the async code.
>
>
> There are also several test fixes/updates associated with this change. The test_runner wrapper no longer has to inject in asyncStart/asyncEnd calls, these are handled by the new async logic.
>
> Change-Id: I0f9f547cd9eb52ff7d850d277876d4d57568a14e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374444
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>

Change-Id: Ia939fe5a9dfd3a5031b06a7ea26c52e58b89f011
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375701
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-07-16 17:00:52 +00:00
Nate Biggs d84f908641 [ddc] Update DDC compiler to start using the new async transform.
Updates compiler.dart to use the new async transformation.

Some key things to note:
- Dart Let and BlockExpression expressions are represented as IIFEs in DDC compiled code. For non-async code this works fine but this doesn't work when they contain "await" expressions. When these expressions contain awaits we use the same lowering as we would for an async function, but instead apply it to the IIFE function. Then we simply await the IIFE Call expression as the IIFE will return a future after the transform.
- For async/sync*/async* functions we want to make sure parameter initialization happens synchronously before any of the async logic is hit. To do this we first apply the async transform the user-code function body. We then prepend the paramter initialization logic to the body of the transformed function.
- We add support for JS_RAW_EXCEPTION which allows the machinery in async_patch to access the wrapped JS exception in a catch block rather than the unwrapped Dart exception.
- Stacktraces and sourcemaps have some differences. There is still room for improvement in these but they should at least allow users to reasonably step through parts of the async code.


There are also several test fixes/updates associated with this change. The test_runner wrapper no longer has to inject in asyncStart/asyncEnd calls, these are handled by the new async logic.

Change-Id: I0f9f547cd9eb52ff7d850d277876d4d57568a14e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374444
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-07-12 16:05:19 +00:00
Johnni Winther c17e9c116e [cfe] Clean up backend imports
This updates backend imports to use reexports from api_prototype
or api_unstable.

TEST=existing

Change-Id: I8d9d1c76ef72c709c578acac5497064710ee5579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373462
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-07-08 11:32:30 +00:00
MarkZ 72ee2943fd [dartdevc] Moving DDC Set implementations into DDC's private runtime.
This allows internal Set classes to be referenced by our runtime.

Context: incoming changes to our generic types (required for hot reload) requires that RTIs be passed to generic classes on instantiation. Moving our Set implementation into our private runtime and making their classes public allows us to directly reference them without clobbering names externally.
Change-Id: Ie47b3263ebbf2650d314b5285a2d50f3abd1a664
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373327
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-07-02 07:27:12 +00:00
Johnni Winther ae03b57cbb [cfe] Remove .isNonNullableByDefault from package:kernel
This removes the .isNonNullableByDefault properties and similar from
the AST nodes in package:kernel. NNBD is now always enabled so these
properties are trivial.

TEST=existing

Change-Id: I75ca0551ac4b5910ea63530dd0c9c2e68bd01aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366320
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-05-15 08:31:38 +00:00
Alexander Markov 9ee25d3ce1 Cleanup unsound mode from pkg/vm, frontend_server and dart2native
TEST=ci

Change-Id: Ica8b8b68f69e8f4a8cd5af3375da4a9ff0947c35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364602
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-04-29 14:18:01 +00:00
Jens Johansen a9f684e624 [CFE/kernel/VM] Fix for crash when compiling after a reject in face of unnamed extension
In https://dartbug.com/55357 a crash is reported happening after a hot
restart (not reload!) with a compilation error. This causes a "reject"
call, which means we create a new incremental compiler, initializing it
from the component of the previous good world.

World 1: Initial state.
World 2: The library is new, but (most) references are reused because
         of advanced invaidation. References of unnamed extensions are
         not reused. Instead the canonical names are unbound (so they
         can successfully be bound to the new reference).
         We now have:
           * ref1 (from world1) pointing to no canonical name.
           * ref2 (from world2) pointing to the canonical name.
           * The canonical name pointing to ref2.
         This world is rejected.
World 3: We start from the world 1 state, but because world 2 *did*
         happen and that only most references (i.e. not references for
         unnamed extensions) were reused, when about to unbind the
         unnamed extenesion we are looking at ref1 and have nothing
         to unbind.
         Compiling creates ref3 (from world 3).
         Upon attempt to serialize we try to bind the canonical name to
         "ref3", but it is already bound to "ref2" and we crash.

The main problem here is that not only `Reference`s are reused,
but because `Reference`s point to `CanonicalName`s these are reused too.

This CL clears the canonical name in the references in the libraries that are reused, meaning that a whole new canonical name tree for those
libraries will be created. This is more in line with what the
non-advanced-invalidation does (by it not reusing references and
naturally getting a whole new canonical name tree).
In my opinion it even makes more sense --- and the fact that the
canonical names were reused was probably more me not thinking about it,
than it was a deliberate design decision.

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

Change-Id: I90bd579984f4aefad78243e8366ac0ab91a905bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363563
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-04-22 14:08:20 +00:00
Daco Harkes 81af7ebbf4 [frontend_server] native-assets-only compilation
This CL adds a `--native-assets-only` CLI option to the
frontend_server startup for single shot compilation.

This CL adds a `native-assets-only` instruction to the
frontend_server protocol.

TEST=pkg/frontend_server/test/native_assets_test.dart
Unit test producing kernel file.

Closes: https://github.com/dart-lang/sdk/issues/55503
Change-Id: Ice6281162460032e669d2dda2a128b357e81bc50
Cq-Include-Trybots: dart/try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-win-release-try,pkg-win-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363567
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-04-19 14:37:26 +00:00
David Morgan 97be47cf17 [CFE] Fix test broken by introduction of package:macros.
Increase timeout to address flakiness.

R=johnniwinther@google.com

Change-Id: Ia25b6429b057cb4606646b09621293354d8f5d80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360821
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-04-03 09:10:38 +00:00
Konstantin Shcheglov 36c0788137 add package:_macros (SDK vendored) and package:macros (pub published)
add sdk_packages.yaml file (describes SDK vendored package locations)

delete old macro code in _fe_analyzer_shared, move tests/benchmarks

adds a top level `pkg` directory to the Dart SDK, which is where vendored packages live

BUG: https://github.com/dart-lang/sdk/issues/54976
Change-Id: Ib3503a27fb5644fa8a39ab5a3e5b568df330cfd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359040
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2024-03-26 18:40:00 +00:00
Johnni Winther 4b21f58d39 [cfe] Don't emit warnings on null-aware access on non-nullable
Change-Id: I94f3011f69330f5b2d8998f29eb9511517e1fffa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357301
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-03-20 14:04:29 +00:00
David Morgan 859e359266 [macros] Cleanup after exception changes.
Add `RequestChannelException`, remove unused `RemoteExcepion`, update
some doc comments.

R=jakemac@google.com

Change-Id: Id51d2a9d16e7d4599703470b5c974c2bd438c55e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352911
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-02-20 09:07:29 +00:00
David Morgan 3c77c86929 [macros] Improvements to exceptions.
Introduce `MacroException` base type that is serializable as a `RemoteInstance`. This means that if a macro implementation does not catch the exception then the exact same instance will be recovered on deserialization.

Add `UnexpectedMacroException`, `MacroImplementationException` and `MacroIntrospectionCycleInspection`.

Update API docs, analyzer and CFE to throw MacroImplementationException instead of ArgumentError.

To do after this PR: update spec, analyzer and tests `StateError`->`MacroIntrospectionCycleInspection`.

R=jakemac@google.com

Change-Id: I76be4ef7687a5f5611c963be40fb0918ac3fb7ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347680
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-01-29 15:53:27 +00:00
Jens Johansen cdad90dfb8 [frontend_server] frontend_server_flutter_suite
Generally the test loads a big dill thats 90+% the same content as the
previous load, then verifies it.
This CL loads smarter and verifies less.

Before this CL, locally, running
pkg/frontend_server/test/frontend_server_flutter.dart took
real    24m56.080s
user    48m42.422s
sys     1m2.360s

and the suite edition (using 4 shards in isolates) took
real    15m9.196s
user    53m41.118s
sys     1m30.045s

With this CL, locally running
pkg/frontend_server/test/frontend_server_flutter.dart takes
real    5m0.206s
user    9m23.933s
sys     0m20.984s

and the suite edition takes
real    3m24.243s
user    12m0.069s
sys     0m28.131s

On the try-bot the runtime seems to have gone from ~40 minutes
to ~20 minutes, the "compile flutter tests" step from ~30 minutes to
~10 minutes and the portion of time actually running the
dart-code that compiles, loads and verifies, from ~26 minutes
to ~7 minutes.

Change-Id: I6db225c33e1c0ee817f3880327e720446150ad7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347282
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-01-26 14:28:40 +00:00
Jens Johansen 39d68052a9 [frontend_server/DDC] Expression compilation for JavaScript can pass scriptUri
This allows using the new scope finder and facilitates expression
compilation with and in extension types.

For now the script uri is optional (and only passable in the new json
input via package:frontend_server), and only if the script uri is passed
we'll use the new scope finder.

Flutter etc should be updated to pass the new data.

Change-Id: I36eed1ea76a825e63e4c5b9ea60daf18aee39f3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342400
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
2024-01-10 10:12:22 +00:00
Jens Johansen c152cce35c [frontend server] Add test for expression compilation on/in extension types
This is done via the new json communication channel, which initially
also added support for sending "scriptUri" and "offset".

The js version of expression compilation still needs updating.
Flutter etc will also still have to be updated.

Change-Id: I428bda68aaa13aa947b57e87f7a5bfb28802cf95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341921
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-12-20 11:14:57 +00:00
Jens Johansen 69a8834d15 [frontend_server] Take json when wanting to compile expressions
This adds an option to compile expressions (vm ones and javascript ones)
by communicating via json. This allows for future expansion without
destroying the communication channel.

For now the old versions will continue to exist, again to not destroy
alreadyy used communication channels.

Flutter etc. should be updated to use this new json communication,
but it can wait until plumbing in passing offset and scriptUri anyway.

Change-Id: Ifbff752527fea35e09a73e0bb210072d8ab81cdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-12-20 10:39:01 +00:00
David Morgan 0c4db1ea87 [macros] Deduplicate RemoteException.
It's not clear that we need two; I kept the one with the better
`toString`.

R=jakemac@google.com

Change-Id: I80934c0f1b05b0c486105654b03b628e7acf439b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341920
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
2023-12-20 09:49:38 +00:00
Jens Johansen bf96a722bc [frontend_server] CFE team takes ownership of package:frontend_server
First of we apply the wanted lints etc we prefer.
This includes but isn't limited to using types (i.e. no "var") and
being explicit about creation (i.e. no missing "new").

Change-Id: I516bccdac9760221ea5311af4567466bb4a65c77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341960
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-12-19 10:38:28 +00:00
Nicholas Shahan 3838338bc4 [frontend_server] Add dart:_rti to test libraries
Compiling with the new type system in DDC requires a few more classes
from the dart:_rti library.

Change-Id: I984e0cdbe3937e4ef70c40a9a6eabc714738e88a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341780
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-12-15 22:20:18 +00:00
David Morgan 296a7f642e [macros] Remove Introspectable* types.
Per https://github.com/dart-lang/language/issues/3442 inrospection will
be allowed to succeed if possible, failing if there are cycles.

Change-Id: I341cc4ae87d1399df82cebb1d5c9df7e5070e777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339620
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2023-12-07 09:44:59 +00:00
David Morgan c7df717d3e [CFE] Simplify path handling in macros_test.dart.
R=jensj@google.com

Change-Id: Ib94ef362d18016502f34e5dac15f0ec4ae996397
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340081
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2023-12-06 17:28:39 +00:00
David Morgan 590b5434f5 [cfe] Remove unused precompiled-macro-format option.
The format is deduced from the file extension: dill for kernel, anything
else is treated as an executable.

R=jakemac@google.com

Change-Id: Ic1202dea232806ede15929383caa0b1cb484e0f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339580
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-12-04 15:52:35 +00:00
David Morgan 74b851667f [CFE] Really fix macros_test.dart for Windows.
R=jensj@google.com

Change-Id: Ied86939d8f6f312b156639305eaab65053d8e90d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338661
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
2023-11-30 13:28:28 +00:00
Ian Hickson 86231e2d70 Remove the widget cache experiment.
Bug: https://github.com/flutter/flutter/issues/132157
Change-Id: Ie87ba74b8ed99477cc5032824286adb07f1157d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319871
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-29 08:47:59 +00:00
David Morgan 7f80ebc6b9 [CFE] Extend macros_test to cover incremental mode too.
R=jensj@google.com

Change-Id: Ic122983a6fcab8fac6584083f16de1d954596c2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338123
Reviewed-by: Jens Johansen <jensj@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2023-11-28 08:52:25 +00:00
David Morgan cd4c378f82 [CFE] Fix macros_test.dart for Windows.
R=jensj@google.com

Change-Id: I8fce79c0726878caab1d8db37588f97af1bc1670
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338340
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2023-11-27 15:50:07 +00:00