Commit Graph

242 Commits

Author SHA1 Message Date
Nicholas Shahan 559b8552a8 [ddc,frontend_server] Fix expression compilation after recompile
Update the last known good component after a recompile reject back to
the expected state before the recompile.

Adds tests for expression compilation after recompile accept and
recompile reject cases with `--target=dartdevc`. Similar to existing
tests for the VM.

Removes calls to `_generator.accept()` and
`component.computeCanonicalNames()` from `compileExpressionToJs()`.
These were added very early in the prototype implementation and it is no
longer clear why they would be needed.

Added some additional test cases for expression compilation involving
import resolution because the change that originally added the
`component.computeCanonicalNames()` call implies it was needed for that
reason. See: https://dart-review.googlesource.com/c/sdk/+/138010

TEST=pkg/frontend_server/test/frontend_server_test.dart,pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart

Change-Id: I9c04bd46e56b33dc654d00fb330de29c3c643a5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434522
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-06-24 14:14:42 -07:00
Ryan Macnak ab4f9351b1 Rename vm_platform_strong.dill to vm_platform.dill.
The name has always been annoying because it did not add strong typing. And now there aren't variants of the VM platform to distinguish.

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

TEST=ci
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,flutter-frontend-try,flutter-linux-try
Change-Id: Ie76fa7f16940aa1ba8d582eb5197f0ae55dc8938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429828
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-16 18:33:38 -07:00
MarkZ 40bf581c79 [ddc] Adding extraDdcOptions forwarder to frontend server.
Change-Id: Ie2ee13b6089f4f24957e9865d6c2fd7296ed7c30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433261
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-06-12 14:43:52 -07:00
Alexander Markov d2252b1fd6 [dyn_modules] Add option to dump detailed dynamic interface
Front-end server and gen_kernel tools now take

--dump-detailed-dynamic-interface=foo.json

option which can be used along with --dynamic-interface when
AOT-compiling application with exposed dynamic interface.

This option dumps dynamic interface broken down to members
and classes as JSON.

TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart
Fixes b/420811696

Change-Id: Id1b15521f47a4869fefd40e835044584fbfb5274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431901
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-30 07:53:45 -07:00
Nicholas Shahan 6127d6cb8f [ddc] Add checks to static invocations in closures
Previously, code in a closure was compiled with the assumption that
invocations known to be statically sound didn't need any runtime checks
to guaranty soundness.

Now, if the code is retained from an earlier compile and executed after
a hot reload, any assumptions regarding soundness may be invalid.

This change transforms what was an invocation expression into a larger
expression that performs additional checks (similar to a dynamic call).

All checks are skipped if the compile generation matches the current hot
reload generation at runtime.

The soundness checks are handled by a new runtime helper method
`hotReloadCorrectnessChecks`. Any argument expressions are hoisted into
let variables to preserve their evaluation order and to ensure they are
only evaluated once. The helper checks for the existence of the
invocation target, the shape of the method signature, and runtime type
of the passed arguments. Mismatches result in an invocation of
`NoSuchMethod`. Any returned value is cast to the expected static type
of the original invocation.

Change-Id: If925f1a9b475d5ac581b2526403ab7c95753ffef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421640
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-05-02 12:52:05 -07:00
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 f75cb3dfb9 [macros] Remove pkg/_macros and pkg/macros
Change-Id: I14bde57b4de1a9dafe9aa291baf0fffca89c3b19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420680
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Jake Macdonald <jakemac@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
Srujan Gaddam fa4d761f07 [ddc] Align error message with VM when reload is rejected
https://github.com/flutter/flutter/blob/f3d0f5a2ca422b1d8cbfc1c4d67ae288ce22ee47/packages/flutter_tools/lib/src/run_hot.dart#L1669

The above is emitted when a reload is rejected at runtime in
the VM. Since we reject errors at compile-time, we should align
the error messages.

Change-Id: I6687d3efaf87d1dce1c7d21591039cbb5a447ff1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413543
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
2025-03-06 00:37:24 -08:00
Johnni Winther 0060b0f665 [cfe] Remove nnbd mode
TEST=existing

Change-Id: I30bbadb74e81c7f4aaa444d1e2f6f5ffc2005d4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412881
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-03-04 01:46:51 -08:00
Sigurd Meldgaard a9ab52bcbb Language version bumps for publish_to: none pkgs
Also a separate pubspec for the tools/ folder

Extracted from https://dart-review.googlesource.com/c/sdk/+/397164

Change-Id: If49a6ede07e4864d0c0fcb210c04c18c804849df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412041
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2025-02-27 00:48:40 -08:00
Nicholas Shahan 39c60997ec [ddc] Add initial hot reload metadata
* Demonstrates the ability to generate metadata when inspecting the
  last accepted and delta components.
* Attach the metadata to the component right before compiling with DDC.
* Use the metadata to avoid deoptimizations in the initial compile
  when they are only required to support a hot reload.
  * Deletion of all type rules for classes that extend Object in the
    initial compile. In the future this should be reduced further to
    only the classes that had a hierarchy change in a hot reload.
  * Type checks on the return value of getters used to represent
    fields.

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

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

TEST=removed

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

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

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

Change-Id: I06d91eb0fac2e7a71e6afde647b03be3814dbd5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406963
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
2025-02-03 07:13:51 -08:00
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
Nicholas Shahan f91050ca91 [ddc] Add visitor for hot reload deltas
Initially this visitor will reject reloads (by throwing an Exception).
Future changes will add the ability to record data about the delta to
guide the JavaScript compilation decisions.

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

Change-Id: Ib318f42d28367416983266a214f97821a38a2913
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401600
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-01-10 10:20:42 -08:00
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 60dd16be6d [ResidentFrontendServer] Remove explicit getters from the ResidentCompilerInfo class
CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes within
sdk/lib/vmservice/running_isolates.dart.
Change-Id: Icbd3a8fe6c10c2c1ef3d1f4737639f32227239c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401644
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-12-20 09:00:17 -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 79cf0d2f35 [ResidentFrontendServer] Factor out _handleCompileRequest helper function
TEST=purely a refactor, so CI

Change-Id: Ifa59ea49f315705bd479bee3ccb36875929aa10a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394762
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-12-03 19:17:51 +00:00
Derek Xu 246a15f887 [ResidentFrontendServer] Factor out _getResidentCompilerForEntrypoint helper function
TEST=purely a refactor, so CI

Change-Id: I91f433057144126e611fb3b687611825fa50c630
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394761
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-12-03 19:17:51 +00: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 a7e4d59d2d [ddc] Fix passing module format to ExpressionCompiler
The DDC library bundle format is a combination of the DDC
format and canary, so therefore check that's the case, and if
so, pass the library bundle format.

Change-Id: I067d2b020e75b703a30fbe7d5f8dc2d31cd4878c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396420
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-11-20 20:29:57 +00:00
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
Jens Johansen a9469269d7 [kernel] BinaryReader takes Uint8List, not List<int>
In AOT this makes reading faster:

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

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

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

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

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

TEST=Existing tests.

Change-Id: I86b16ed207343848dee2e376f42598c223bbc48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393740
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-08 08:23:42 +00:00
Ben Konyi 90b52f8aeb [ Frontend Server ] Clear error count before compiling expressions
Updated FrontendCompiler.compileExpression() to clear previous errors before
compiling the expression. This matches the behavior of
FrontendCompiler.compileExpressionToJs().

Related issue: https://github.com/flutter/flutter/issues/157922

Change-Id: I7bbc163c3f02758be4a495fd753a4ef6cf03c3ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394220
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-11-08 07:11:29 +00:00
Nicholas Shahan b4d5272d99 [ddc] Move command.dart library
From: lib/src/kernel/command.dart
To: lib/src/command/command.dart

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

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

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

Change-Id: Ic9edfb47fc2425a28b1e948d94fad96a2f594108
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388048
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-10-07 21:21:30 +00:00
Jens Johansen 3dce89fbe0 [scanner] Don't give the Utf8 scanner a 0-terminated byte sequence
Not having to do the read-allocate-copy dance for files to add a 0-byte
at the end results in these changes when using the CFE to compile
(a fixed version of) the CFE:

```
msec task-clock:u: -1.7356% +/- 0.2164% (-73.16 +/- 9.12)
page-faults:u: -2.6957% +/- 0.0111% (-2914.83 +/- 12.00)
cycles:u: -1.7128% +/- 0.2223% (-297927979.70 +/- 38660477.01)
instructions:u: -1.6814% +/- 0.0002% (-361315766.86 +/- 36853.71)
branch-misses:u: -3.3289% +/- 0.9669% (-2153126.00 +/- 625370.97)
seconds time elapsed: -1.7372% +/- 0.2154% (-0.07 +/- 0.01)
seconds user: -1.5998% +/- 0.2740% (-0.06 +/- 0.01)
seconds sys: -4.1451% +/- 2.9801% (-0.01 +/- 0.01)
Scavenge(   new space) goes from 62 to 61
```

TEST=Existing test coverage.

Change-Id: I8e182bcee39839f6ed1e658c30c85c40ecf0b259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 08:33:48 +00:00
MarkZ 43698dbed3 [frontend_server] Capturing DDC FES errors more gracefully.
Running DDC + FES in incremental mode was causing FES state machine responses to fail whenever DDC emits an error. These should be captured and reported (and potentially rejected manually).

Change-Id: Ic409dd8986c984b858fec21c6f67bd52147b367d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384824
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-09-12 17: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
Alexander Markov 4e0b69fbd9 [vm/aot] Improve dynamic interface annotator
Dynamic interface annotator now automatically annotates classes and
members which are used implicitly:

* Targets of redirecting factories.
* Classes and members used in constants.
* Instance fields of classes used in instance constants or
  having a callable const constructor.
* Everything used in the bodies of extendable mixin declarations and
  mixin classes.
* Possible dispatch targets of instance calls
  (overrides/implementations).

Front-end server now also exposes '--dynamic-interface' option,
similar to gen_kernel tool.

Also, this change includes a couple of minor fixes:
* Typo in ast.dart.
* In the front-end server, additional dill file specified with
  '--import-dill' option is not ignored when '--link-platform' is
  also used.

TEST=pkg/vm/testcases/transformations/dynamic_interface_annotator

Change-Id: I705b64efb1834dec6e0bdc5873025607f3472139
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377761
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-07-30 16:24:51 +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
Johnni Winther 543bc03de8 [cfe] Move /fasta/ content into /base/
These files should be further reorganized but that is for a
future CL.

Part of removing uses of 'fasta'.

Change-Id: I5010789b5901ba51c58d98fe26f13177b13c81b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373080
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-06-27 07:54:23 +00:00
Johnni Winther 8df57398c9 [cfe] Move src/fasta/ subfolders to src/
Part of removing uses of 'fasta'.

TEST=existing

Change-Id: Ice027678e11b7da8c1a7e756a1e1c8c8284722bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372623
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-06-25 10:05:21 +00:00
Alexander Markov 6ab01427bd [pkg/vm] Consolidate kernel compilation options to an object
TEST=ci

Change-Id: Ic9a8801bff140b1393decde61917e8c61ab1945d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370721
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-06-10 22:56:50 +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
David Morgan 7fc712791c [CFE] Skip macro library augmentation when considering input sources.
R=johnniwinther@google.com

Change-Id: Idcd4533542c8d3b92dad6df41378c798780f1227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364101
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-04-23 10:13:10 +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
Daco Harkes 2946586ef2 [frontend_server] Use kernel concatenation in AOT for @Native assets
Dill concatenation is supported in AOT now. So remove the workaround
in the frontend_server.

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

TEST=tests/ffi/native_assets/asset_relative_test.dart
VM unit test consuming AOT kernel files.

TEST=pkg/dartdev/test/native_assets/build_test
Integration test using `dart build`.

Bug: https://github.com/dart-lang/sdk/issues/50152
Change-Id: Id5c807e644cd2485fd2fb9061be0c619e95aa082
Cq-Include-Trybots: dart/try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-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/+/363564
Reviewed-by: Jens Johansen <jensj@google.com>
2024-04-19 14:37:26 +00:00
Kevin Moore 7df98cd150 FE server: drop dependency on pkg:usage
Inline trivial usage of UUID
Copied from https://github.com/dart-lang/usage/blob/2847cdb94e238a921c600e81b52c91baf4ea0b50/lib/uuid/uuid.dart

We could almost certainly DROP UUID here for some other random string
generator.

Change-Id: Ib50023b497dd02c469b4ead9139b0dc3d42cc379
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363405
Commit-Queue: Kevin Moore <kevmoo@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-04-18 16:25:28 +00:00
Alexander Markov 6d4817b147 Disable --no-sound-null-safety in 'dart compile', front-end server and gen_kernel
Change 'dart compile', front-end server and gen_kernel tools to reject
--no-sound-null-safety option as unsound mode is no longer supported.

TEST=ci

Change-Id: I4f6e87865bf206a27958caee4088272b4e397608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-04-18 13:34:17 +00:00