Commit Graph

55 Commits

Author SHA1 Message Date
Kevin Moore 387ed7dd7d pkg/compiler: remove unused parameter from DumpInfoProgramData
Change-Id: I0e928d2761d287d41f0aba2c3335faec17239b86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429225
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2025-05-19 09:41:58 -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
Mayank Patke c878108cc8 [dart2js] Update pubspec to Dart 3.7 and reformat.
All non-pubspec changes generated by `dart format pkg/compiler`.

Change-Id: Iadaa70974816d96ccb47813fe72d5a2bb83d6bda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400181
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-12-13 11:24:50 -08: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
Lasse R.H. Nielsen f8086c81ae Collect all test-related files in package:expect.
Collects files from `package:async_helper` and `tests/language`
that are generally useful, so that all test-related helpers are
in `package:expect`.

Moves the two libraries from `package:async_helper` into `package:expect`,
and the `tests/language/static_type_helper.dart` file too.

Deprecates `async_minitest.dart`, to follow `minitest.dart`,
expecting the Flutter use of it to have been fixed to not break
on deprecation (I believe Flutter no longer breaks builds on deprecations at all).

Patch 1 is the actual change.
Patch 2+4+8 is changing all existing references to the files.
Patch 6 ignores deprecation in files still using `async_minitest.dart`.

3+5+7+9 are updating this text to make the numbers match.
Then it's just test-expectations and small tweaks from there.

Change-Id: I1b665135b5fef9b9a0c3b340ffe9daf874d0174c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373120
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-10-11 16:53:52 +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
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
Nate Biggs b9b4d616a4 [dart2js] Fix record field get receiver type serialization.
Internal users reported a compiler crash when using sequential compilation. Their change involved adding a class hierarchy in which the constructor of a superclass included a RecordIndexGet. When analyzing the constructor of the subclass we also analyze the body of the super constructors.

In this rare case the member being analyzed does not match the member containing the receiver node. Usually calls act as a layer of indirection that we do not analyze across.

When we then save the type of the receiver, we do so in the context of the wrong member (the subclass constructor rather than the superclass constructor). We just have to be more careful to use the correct context member.

The added test fails prior to this change.

Change-Id: I8b9a3b8a7692b8604d5c37c59b94bb8d46afff75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371580
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-06-14 19:17:14 +00:00
Nate Biggs f54eb08177 [dart2js] Update Dart2jsStage definitions and CLI surface area.
Today to invoke Dart2js with sequential actions there are 2 ways to specify the stage from the command line. By specifying a `write-<stage-data>=<some-uri>` or by using `stage=<some-stage>`. Internally we use the former via a similar (but separate) concept to Dart2jsStage. The goal here is to consolidate all these different entry points.

The new CLI works as follows:
- To run the compiler in full you can:
  - Pass no additional flags as before
  - Specify 'stage=all'
  - 'dump-info-all' runs the full compilation from scratch but includes
    dump info.
- To run the compiler in sequential mode you specify a stage:
  - Each stage has its own name passed to the '--stage' flag.
  - All the intermediate data URIs can be passed to every stage and only
    the relevant ones are used for any given stage. If no URI is passed
    then a default URI is used.
  - 'dump-info' is now its own stage. Partial dump info data is
    always included in the emit-js and codegen-emit-js steps.
  - 'cfe-only' flag is maintained for compatibility with Flutter CLI.


Change-Id: I67965d7708688a85c866d8abef3716bee23a083f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358740
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-04-02 19:46:11 +00:00
Nate Biggs 52f996b5bc [dart2js] Use impacts from codegen results for dump info.
Currently, serialized dump info metadata (output of emitter phase) contains all the impacts created during codegen in a Map<MemberEntity, WorldImpact>. These impacts are already serialized in the output of the codegen phase. This is bad for two reasons: 1) The serialized bytes are duplicated. 2) The impacts cannot be GCed right after the emitter uses them, the dump info registry maintains a reference to them.

To mitigate this I've updated the registry to only store impacts for entities where the impacts are generated during the emitter phase (today only parameter stubs). Rather than try to re-generate those impacts during the dump info phase, we serialize them with the dump info metadata. However, most impacts are generated during the codegen phase and for these we deserialize them from the codegen results at the beginning of the dump info phase.

Change-Id: I1302b4ab759bca3d492bc6b40194d7a7720ed6f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354580
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-03-07 19:25:15 +00:00
Mayank Patke 37345b9f7e [dart2js] Enable strict-inference and strict-raw-types in pkg/compiler.
Change-Id: I4712d32dc37a8cbfa0e1e5bd61659df651c77471
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354140
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-02-26 22:41:58 +00:00
Mayank Patke 69df740ea9 [dart2js] Assorted TODO cleanup, bump pubspecs to 3.3.0
Change-Id: I621ac252c5d6f3b157a2f194b7f0b7ad85874e4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352990
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-02-21 00:02:13 +00:00
Mayank Patke f79ed9301b [dart2js] Remove remaining language version overrides
Now that dart2js only takes migrated files as input, all tests should
use the current language version.

Change-Id: I6c84850f5786aeac04154b67bd7a3c19083c8bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345344
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-01-23 01:26:09 +00:00
Nate Biggs 412bb9f359 Reland "[dart2js] Stop emitting a dill with closed world."
This is a reland of commit b9e25afcb4

Original change's description:
> [dart2js] Stop emitting a dill with closed world.
>
> All transformations to the dill are now performed with the CFE linker phase (phase0b). This means we no longer need to emit a dill as part of the closed world computation. This saves both time and memory resources associated with the cost of serialization during that phase.
>
> Change-Id: I28dde8a1eecd71e823880027505f62fc804fcca6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332821
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Commit-Queue: Nate Biggs <natebiggs@google.com>

Change-Id: Ia693213dcdc949a8ef4b4204cc033130274d2381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336982
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-11-18 00:32:49 +00:00
Nate Biggs d7fa5f3d89 Reland "[dart2js] Evaluate CFE consts as part of phase 0b (CFE linker)."
This is a reland of commit bebd08746b

Original change's description:
> [dart2js] Evaluate CFE consts as part of phase 0b (CFE linker).
>
> Constants are current evaluated in a few places during closed world generation, primarily as part of the ScopeModelBuilder. The scope visitor was modifying the AST which meant we had to emit a new dill with these evaluated constants along with the closed world results.
>
> This change instead evaluates the constants directly after linking the Kernel as part of the global transformations. This means we can update the ScopeModelBuilder to not mutate the AST at all as all constants are already simplified.
>
> A potential follow up here is to simplify the ScopeModelBuilder since all nodes should already be simplified if they can be, we should be able to avoid visiting some children.
>
> After this change we only directly create a single ConstantEvaluator, the one in `load_kernel`. The const simplifier also creates one and a follow up CL moves this to to run right after this new transformation.
>
> Note: Alternate versions of this CL tried to make the global transformation simpler by either:
> 1) Running the const evaluator indiscriminately on all expressions. This didn't work because it lead to exponential computation on constants set up as a DAG (see tests/language/const/constant_dag_test).
> 2) Only evaluating ConstantExpression nodes to update UnevaluatedConstants. This does not cover all the cases where the ScopeModelBuilder is modifying the tree and lead to a different compiler output.
>
> Change-Id: I746d889b37feddc9ab6c386c6252016dec745e6e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332601
> Reviewed-by: Mayank Patke <fishythefish@google.com>

Change-Id: I53871a57144a3a1bd363af141d8f31c8ffa5ca6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336221
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-11-15 19:15:29 +00:00
Nate Biggs 3fe10c470e Revert "[dart2js] Evaluate CFE consts as part of phase 0b (CFE l..."
Revert submission 332821

Reason for revert: Breaking internal build targets.

Reverted changes: /q/submissionid:332821

Change-Id: Ic81f371c83956027f7e710c663a7eeb432c71d7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336087
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-11-14 19:44:24 +00:00
Sigmund Cherem 802279dc0e Revert "[dart2js] Stop emitting a dill with closed world."
Revert submission 332821

Reason for revert:
Caused breakage in flutter engine, see https://github.com/flutter/flutter/issues/138326 for details.

Reverted changes: /q/submissionid:332821

Change-Id: I179b3596e938c8b2202b200037ba5dcdd01b3384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335900
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-11-13 18:39:39 +00:00
Nate Biggs b9e25afcb4 [dart2js] Stop emitting a dill with closed world.
All transformations to the dill are now performed with the CFE linker phase (phase0b). This means we no longer need to emit a dill as part of the closed world computation. This saves both time and memory resources associated with the cost of serialization during that phase.

Change-Id: I28dde8a1eecd71e823880027505f62fc804fcca6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332821
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-11-10 20:38:34 +00:00
Nate Biggs bebd08746b [dart2js] Evaluate CFE consts as part of phase 0b (CFE linker).
Constants are current evaluated in a few places during closed world generation, primarily as part of the ScopeModelBuilder. The scope visitor was modifying the AST which meant we had to emit a new dill with these evaluated constants along with the closed world results.

This change instead evaluates the constants directly after linking the Kernel as part of the global transformations. This means we can update the ScopeModelBuilder to not mutate the AST at all as all constants are already simplified.

A potential follow up here is to simplify the ScopeModelBuilder since all nodes should already be simplified if they can be, we should be able to avoid visiting some children.

After this change we only directly create a single ConstantEvaluator, the one in `load_kernel`. The const simplifier also creates one and a follow up CL moves this to to run right after this new transformation.

Note: Alternate versions of this CL tried to make the global transformation simpler by either:
1) Running the const evaluator indiscriminately on all expressions. This didn't work because it lead to exponential computation on constants set up as a DAG (see tests/language/const/constant_dag_test).
2) Only evaluating ConstantExpression nodes to update UnevaluatedConstants. This does not cover all the cases where the ScopeModelBuilder is modifying the tree and lead to a different compiler output.

Change-Id: I746d889b37feddc9ab6c386c6252016dec745e6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332601
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-11-10 20:38:34 +00:00
Nate Biggs 671e58c268 [dart2js] Decouple closed world and serialization.
Change-Id: Idf9420eb1d461b9a2cff90354cfbfee601b75ae8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330861
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-10-21 02:18:48 +00:00
Nate Biggs 232d716474 [dart2js] Use Dart2JS serialization indexing instead of element map indexing for element model entities.
The element map indexing system adds complexity to our element model with little benefit. Serialization already has its own indexing logic that we now reuse for entities.

Some things to note:
1) Libraries are still assigned an index. We only use that index in one place in the namer to disambiguate members. I now assign these indices as a late final field when adding the libraries to the element map.
2) The sizes of serialized files get slightly bigger since serialization indexing uses "addresses" rather than incrementing numbers for the indices. This effect is very minimal (<4MB+ for the largest programs).
3) "Late" members (constructor and generator bodies) which are created during codegen must be tracked and registered separately. Before the index was used to determine which entities were "late".

I see a very small memory improvement across all phases because of this change. There is also a small regression in runtime because the entity map queries are hash map lookups instead of list index lookups now. I think this very small regression is worth the reduced complexity in the compiler.

If we care about getting that time regression back we can add an "IndexedEntityMixin" with a late final index member that the registry would set/manage internally and would allow it to go back to tracking entities in a List. The field should be private so it would only be used for this purpose. This would only be necessary if we find the added time overhead of the map lookups to be too much.

Change-Id: Idd6d22bfc6ab61943a07feb58b35287d50e7d72e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326461
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-10-21 00:31:34 +00:00
Nate Biggs 0b1bad9ffc [dart2js] Refactor serialization indices.
Simplifies indices management for serialization by reusing the same indexing readers/writers for each phase. This way the caches are shared across all the phases and we can decouple the indices with any specific data read.

This fixes an issue that prevented the indices from being used in certain read/write patterns. None of our current usages of these indices exhibited this pattern but later changes I have planned do run into this issue.

This new pattern is also more resilient to sharding/parallel data files. Previously there could be collisions if two files were written in "parallel" (such as the codegen shards) and later their address spaces had to be merged. Now we do the address space merging at read time when we have full knowledge of the parallel files and can therefore avoid collisions.

Change-Id: Iff4c1461e734fc00f251d81f9fff1b9db83484d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326460
Reviewed-by: Stephen Adams <sra@google.com>
2023-10-21 00:31:34 +00:00
Nate Biggs d95c6f4de6 [dart2js] Add source map test that ensures no regressions with serialization.
Confirmed that reverting https://dart-review.googlesource.com/c/sdk/+/325600 causes these new tests to fail.

Fixes: https://github.com/dart-lang/sdk/issues/53466
Change-Id: I9ffb2e75664d965a410581d71b7e5c6e681b60d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325942
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-09-28 02:36:27 +00:00
Nate Biggs 839f890f13 [dart2js] Improve dump info scalability.
Isolates data needed from emitter phase for dump info task. The new DumpInfoProgramData captures only the necessary data and allows it to be serialized so that dump info can be run independently of the emitter task.

This change also ends up improving the combined emitter and dump info task. By processing the JS AST and extracting out the relevant info up front, the AST is able to be GCed before the dump info task runs. In local runs on a big app this resulted in ~1.4GB less ram being.

Runtime stat comparison:
Without --dump-info: 117s 5.4GB

Before with --dump-info: 205s 18.3GB
Before with --dump-info=binary: 148s 9.9GB

After with --dump-info: 205s 16.9GB
After with --dump-info=binary: 150s 7.5GB

After with --dump-info-write: 132s 6.2GB
After with --dump-info-read: 118s 14.8GB
After with --dump-info-read --dump-info=binary: 67.9s 5.5GB

By providing the new "--dump-info-write-uri=URI" a binary file will be written with the necessary dump info data. Then if Dart2JS is invoked with the same parameters and "--dump-info-read-uri=URI" then the compiler will skip generating/emitting JS and use the output file to generate the info dump. The existing invocation of just adding "--dump-info" works as before.

I also had the goal of removing DumpInfoTask dependencies on other parts of the compiler and vice versa.

Change-Id: I3f40b0136eb77a709c49737607a2ad6127127e49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322843
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-08-29 02:35:37 +00:00
Nate Biggs 776b614018 [dart2js] Add stage flag to Dart2JS.
Maintains functionality of existing '--write-X-uri' and '--read-X-uri' but also introduces new '--stage' flag that indicates which phases of the compiler should run.

Also expands the behavior of the `--output` flag to support taking a file prefix and/or an output directory that files are written out to.

Valid invocations can look like:
`dart2js main.dart --stage=cfe`
`dart2js main.dart --stage=cfe --output=prefix1-`
`dart2js main.dart --stage=cfe --output=/some/path/`


Change-Id: If90fb16f549d35f16f77d660c51f8d28673e454f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300520
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-05-10 22:43:37 +00:00
Nate Biggs 9a25f65eb6 [dart2js] Introduce formalized phases to Dart2JS.
This change locks down the Dart2JS command line API to the few invocation flows we use today:
1) Full compile from Dart sources.
2) Full compile from pre-compiled dill sources (modular CFE).
3) Phased compilation from Dart sources.
4) Phased compilation from pre-compiled dill sources (modular CFE).

It also ensures that each phase is run individually (accounting for sharding in codegen/emitter).

There are already places in the code where we assume that Dart2JS will be invoked in one of these ways so this should codify those assumptions.

Change-Id: I4e2a85d123e0c2ad924e2dd1b230548a995af0da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299760
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-05-10 22:43:37 +00:00
Nate Biggs 464bbdde7e [dart2js] Compactify location data on SourceLocations.
We encode line/column in a single 64-bit integer and derive offset from this using the lineStarts stored on the kernel Source object.

Saves 90-100MB of memory within the emitter phase on a large program. Most of that is from the smaller deserialized SourceLocation objects but some memory is also saved due to the smaller output size from the compact serial representation. The input to the emitter phase is ~14MB smaller (with the savings split across multiple codegen shards).

Change-Id: Ic71231fb43fc746293b6f6f77e0ee2c3b17742cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291900
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-31 03:27:32 +00:00
Nicholas Shahan 7c0e4d67c7 [dart2js] Prevent unsound compiles
- Remove unsound platform .dill files from the packaged SDK.
- Throw and error referencing the sound null safety requirements of
  Dart 3 when compiling with `--no-sound-null-safety` and an unsound
  platform .dill file is not found.

Change-Id: I703a446e3e92c76a6b48168577fc0161eea83854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289280
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-03-28 21:31:27 +00:00
Nate Biggs 545ee13cd4 [dart2js] Clean up usages of 'new' keyword.
Change-Id: I193e19581d29a9c4b343ae0a681d1ff530cfce1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281309
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-02-14 02:36:38 +00:00
Nate Biggs a4e4761339 [dart2js] Migrate test/serialization for null safety migration.
Change-Id: If2338b67b207c9fffc8f09be399e99bbd5119fd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279584
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-01-27 00:24:47 +00:00
Sigmund Cherem e8906e65e7 [3.0 alpha][dart2js] No longer infer the null-safety mode from sources.
This prepares dart2js to default to sound null safety in Dart 3.0.

The compiler no longer infers the default mode based on the input
program, instead uses sound null safety unless
'--no-sound-null-safety' is specified.

On a separate change, we expect to remove the option of disabling
null safety.

Note: this change should also be reflected in the CHANGELOG, but
we've currently not included it to redeuce merge conflicts, as we plan
to land multiple 3.0-alpha changes in a short window of time

Change-Id: Id87498cc5976548ec89d1f36c60674b72406950a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270860
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2022-12-07 04:02:13 +00:00
Nate Biggs 975cb8a9cb [dart2js] Move memory compiler out of test folder.
Change-Id: I4fd3b1fa91582ce19fb16a61a81013d694e0cd59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270540
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-11-18 02:59:15 +00:00
Nate Biggs 3ed70b013b [dart2js] Remove JClosedWorld interface and use only implementer, JsClosedWorld, everywhere.
Change-Id: I9641033aa3a93a28ee428ddc63aa7fc337e5468a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267802
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-11-04 15:11:27 +00:00
Michael Thomsen 17972ddce5 Move swarm to a test folder to avoid confusion that this might
be a customer facing app sample.

Bug: None
Change-Id: I94944d4d5677b08eaf6c27ecf26e8503d8eae38f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255255
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2022-09-07 14:08:18 +00:00
Lasse R.H. Nielsen 8a883fa54d Change : to = for default values in pkg.
Leaves some in parser test:
 pkg/front_end/parser_testcases/error_recovery/keyword_named_formal_parameter_prime.dart

TEST=Refactoring, covered by existing tests.

Change-Id: I7a83ef95df3cbd283878b3685b5c747bd89a1b16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256125
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-08-24 15:57:16 +00:00
Nate Biggs e2d926c1b2 [dart2js] Always do codegen in serialization tests.
Change-Id: I3837c7c31c5073212426a1526dab9d2ca7d8cde3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252440
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-07-21 18:51:55 +00:00
Nate Biggs 8b3e9a84e7 Add test for unordered indexing in serialization.
This test catches an issue previously uncaught by tests where offsets for indices were written incorrectly and could therefore lead to errors when deserializingelements in deferred mode.

Change-Id: I14bf80bbe4fa47c12e543679803c7be38582a0e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252300
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-07-21 03:59:25 +00:00
Mark Zhou 635a3bf00f [dart2js] Adding total program RAM usage to dump info's output
See: #49160

This doesn't offer a phase-specific view of the ram usage nor aggregate ram usage across split phase compilation.

Change-Id: Ia1f781f9bd35b40048ac23fe103b8fee3b4da584
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250947
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-07-12 00:53:41 +00:00
Nate Biggs e87c84ff69 [dart2js] Migrate serialization.dart to nnbd and remove temp migration files.
Change-Id: I109c219fa0cc989ac1f3eea6b5d6de0b0cbb7d22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249746
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-28 03:41:12 +00:00
Nate Biggs 97ad0fbf30 [dart2js] Move more serialization logic into nnbd.
At this point the only imports of the pre-nnbd DataSourceReader and DataSinkWriter are files that need to instantiate the class. Other references have been migrated.

Change-Id: I79672fc5f8c681d05a183990e184535f1becc0e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249742
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-27 17:01:32 +00:00
Nate Biggs d5c79bbc7f [dart2js] Don't serialize allocation node in allocating type masks.
These allocation nodes are not used beyond the global type inference phase so we can avoid serializing them. The values will just be null in later phases.

Change-Id: I0a1dd02658e0e6621d635c89ff97d4b2c07ac86a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247740
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-14 14:58:57 +00:00
Nate Biggs 743573cb26 [dart2js] Add some more setup logic for unordered indices and deferred serialization.
- Pass options to all DataSourceReader and DataSinkWriter constructor calls.
- Add DataAndIndices to replace ClosedWorldAndIndices. Maintains the same indices as before for now.

Change-Id: I2e25d4a4c25ef12276fa808146ff8aae27da792c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247401
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-08 18:57:02 +00:00
Stephen Adams 618db8a41d [dart2js] Rename lib/compiler.dart to lib/compiler_api.dart
Always import 'lib/compiler_api.dart' with prefix 'api'.
Remove import of 'lib/src/compiler.dart' with prefix 'api'.

Some of the test helper files under 'compiler/test' are a little tedious
with lots of 'api.' prefixes and I could be convinced to change them
back but I think we should stick with always using a prefix under
'compiler/lib/'.

Change-Id: I3f82d7d31f1c90a860c9811fce031a64cea04ddb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241867
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-21 03:42:39 +00:00
Mark Zhou 10c5c79aa5 [dart2js] Plumbing the kernel component to and restructuring dumpInfo
- Pulls dumpInfo out from the Linking phase.
- Forks dumpInfo into ElementInfoCollector and KernelInfoCollector.
- Introduces a temporary compiler variable that will be more cleanly integrated later.

Change-Id: I5f0970d9dbd5b1f215063ac161468b2774fb28a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239005
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-03-29 18:41:49 +00:00
Joshua Litt d3c1fee003 [dart2js] Cleanup runInternal.
Change-Id: Ieccd9d1fd06e553a74a0473532d880203af77d72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238880
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-28 17:04:30 +00:00
Joshua Litt f3092bebd8 [dart2js] Introduce 'load_kernel' phase.
Change-Id: Iefc15122dfd08b514a2f883d856a7b8a005911b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233765
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-09 20:11:44 +00:00
Joshua Litt 4ce081c99b [dart2js] Remove old compiler interface.
Change-Id: If4f98f4d32a42ce8c2aabd98116997934b13b557
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232001
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-10 16:27:25 +00:00
Joshua Litt 7e76dd6b28 [dart2js] Select main method manually when compiling from dill.
Change-Id: I45ddca41b9bff49606e49dfd9b6110b7fc7f2283
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215683
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-10-15 16:40:29 +00:00
Joshua Litt a2d1fa1a33 [dart2js] Support serialization with supplied indices.
Change-Id: I830d084f59281b9dff81f33b72002d709f35c16c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212344
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-16 19:33:55 +00:00
Joshua Litt 81092839c7 Reland "[dart2js] Avoid reserializing the closed world alongside type inference."
This is a reland of 7b022a7f2f

Original change's description:
> [dart2js] Avoid reserializing the closed world alongside type inference.
>
> This cl adds a temporary flag '--no-closed-world-in-data' in order to
> support serializing global inference results with and without the closed
> world.
>
> This flag only exists to allow us to roll this into google3. Afterwards,
> it will be removed.
>
> Change-Id: I6e9712739edd148edcf43007b6ece35efa688538
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192124
> Commit-Queue: Joshua Litt <joshualitt@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I47c08edb868f272c7501ae139a9533fa07d4176f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193585
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2021-03-31 16:11:39 +00:00