Commit graph

5388 commits

Author SHA1 Message Date
Nate Biggs c084ebb430 [dart2js] Prepare native_data.dart for nnbd migration
Change-Id: I9179dd5ac7feb6790c7d0fe3e3aab7213d489424
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249960
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-30 23:11:03 +00:00
Nate Biggs 837bb22581 [dart2js] Fix unordered index for codegen sharded mode
Index cache maps should be copied instead of used directly. And the set of indices (DataSourceIndices.caches) needs to be copied as well since we alter it when reading each shard.

Change-Id: If7a640ead07a54e3cb6003eee89c44db8f449812
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250202
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-30 17:16:26 +00:00
Mark Zhou bb75cf4519 [dart2js] Adding formal kernel dump info tests
Change-Id: I2e0f7c8cb5943b2de5d09f3a310c8485b108797d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250113
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-06-29 20:39:55 +00:00
Sigmund Cherem 8a0289eec9 [dart2js] migrate import_set.dart
Change-Id: Ie582bf62803e31b952e110f2c6160d2237bb9d10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249952
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-29 17:23:25 +00:00
Mark Zhou 515d8741e3 [dart2js] Moving entity map to kernel dump info annotator
Change-Id: I1aa5167759e1cdb1bdfbea76062df8fcafb8a67a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250022
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-06-28 21:37:06 +00:00
Mark Zhou ee21de85f1 [dart2js] Fixing info resolution paths in kernel dump info
Includes skipping duplicated installation code.
For more info, see #49348

Change-Id: I34833df32156d9fe090b579b665dd9cb93860f8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250020
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-28 21:37:03 +00:00
Srujan Gaddam b372fd4c52 [CFE/pkg:js] Find reference of stub if it already exists
Fixes #49301

From https://github.com/dart-lang/sdk/issues/49301#issuecomment-1165536192

Adds referenceFromIndex to outline transformations so that the eraser
can use it to find the reference for the stub if it was already created.
This is needed when the module where the stub exists is invalidated.
Since references in other modules should still be valid, we should
attempt to get that reference.

Change-Id: I5905a002480444aecd57de650cd439bdc34d4eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249729
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-28 18:36:02 +00:00
Stephen Adams f740b500e2 Revert "[dart2js] Migrate source_file_provider.dart"
This reverts commit c9ff7d95fd.

Reason for revert: Test failure in google3

Original change's description:
> [dart2js] Migrate source_file_provider.dart
>
> Change-Id: Iaded7ebfe4415f8108c9364521939b8394ab598a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249780
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Commit-Queue: Stephen Adams <sra@google.com>

TBR=sra@google.com,natebiggs@google.com

Change-Id: I23d7ae645b871ed7cca00e49288eb9e2c3f4fce7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250105
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-06-28 18:00:53 +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 1e7cb2f449 [dart2js] Migrate js_model/locals.dart to nnbd.
Change-Id: I76b137b68f10f2bb043df8e1d37455925a3bf536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249745
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-28 03:41:12 +00:00
Nate Biggs ca26ed23dc [dart2js] Prepare for locals.dart migration
`element_map_interfaces.dart` contains temporary interfaces that exist for the duration of the nnbd migration.

`element_map_migrated.dart` contains 'real' code from `element_map.dart` that has been migrated. This will get re-combined with the `element_map.dart` once it is all migrated.

Change-Id: I55cc414de471adbe2d63c0e226558d5b4773d409
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249744
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-27 21:43:52 +00:00
Nate Biggs 2edfa30d02 [dart2js] Migrate js_model/elements.dart and parts of js_model/closure.dart.
Change-Id: I50c950bbaeba720a16327eb6f82ceabe4c8d9e0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249743
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-27 21:19:43 +00:00
Stephen Adams a1535a893a [dart2js] Migrate ir/impact{,_data}.dart
Change-Id: I84b844d279eb7fd5daff7242cdf686ba27220af5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249732
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-27 20:44:32 +00:00
Stephen Adams c9ff7d95fd [dart2js] Migrate source_file_provider.dart
Change-Id: Iaded7ebfe4415f8108c9364521939b8394ab598a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249780
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-27 20:38:25 +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
Stephen Adams aa43ca02ec [dart2js] Annotations for late fields
Change-Id: I46ed386a1db6d79de9f9c9f15b9ac06f7f398956
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248708
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-27 06:34:01 +00:00
Stephen Adams 4c8a50109d [dart2js] Change return type of failedAt to Never
This allows `e!` to be replaced by `e ?? failedAt(...)` where a more descriptive internal error is desired.

`failedAt` used to return `bool` so that you could write

    assert(condition || failedAt(...));

We have had assertions with messages for a long time, so that was changed to

    assert(condition, failedAt(...));

This still works with the type `Never`.

Change-Id: I132665d898a6aefe1fcf73235e88c156bab1e21e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249730
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-24 22:58:59 +00:00
Stephen Adams 69ef56cffa [dart2js] Migrate universe/class_hierarchy.dart
Change-Id: I0bd5ab3c021e9c1e6087fb3b651696a9888d8078
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249700
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-24 21:35:00 +00:00
Nate Biggs 7628eefbd3 [dart2js] Move imports of 'serialization.dart' to use 'serialization_interfaces.dart' instead.
Change-Id: I556fe4962f0a414f7dcee2dd1650c9c626468fde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249741
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-24 20:45:40 +00:00
Johnni Winther e18977ed9c [cfe] Report error for missing concrete super target
In response to https://github.com/dart-lang/sdk/issues/47406

The error is currently not reported if the mixin declaration is from
an outline dill.

Change-Id: I94a61d6409d0c238614d9f377b5f324153360bc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249184
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-24 14:04:49 +00:00
Jens Johansen b4e2012f5b [CFE] Remove support for .packages file
This CL:
* Removed the redirect from .packages to .dart_tool/package_config.json
  (whenever such a file existed).
* Removes support for the old format entirely.
* Updates all tests etc that were found.

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

TEST=Existing tests updated.

Change-Id: Iccf711c455ac1885189aa773ca74dd8f55012964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248603
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-06-24 08:20:39 +00:00
Stephen Adams 9cc3b14dfa [dart2js] Prepare to migrate ir/impact_data.dart
Add the required methods to serialization_interfaces.dart

Change-Id: I201461f7a534d02cbfef4d095c670e0c60c40f22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249664
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-24 04:39:29 +00:00
Nate Biggs e40fd307ef [dart2js] Allow SpecialMemberDefinition to copy Deferrable from ClosureMemberDefiniton
Codegen deserialization was inadvertantly loading the nodes for many ClosureMemberDefinitions, specifically ones for generators. The node doesn't actually end up being used after this point though so the Deferrable is unnecessarily triggered.

To get around this we have the SpecialMemberDefinition constructor copy the Deferrable out of the ClosureMemberDefinition.

To avoid exposing the deferrable I've moved the ClosureMemberDefinition into the same library as SpecialMemberDefinition.

This brings the number of Kernel AST function bodies being deserialized down to 2 in cm_shell (down from many thousand).

Change-Id: I0781ab490dc1972118cf2ac2359f467916031633
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247283
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-24 03:35:38 +00:00
Stephen Adams 5da4b521ea [dart2js] Migrate backend_usage.dart
Also:
- KFieldAnalysis takes an elementMap instead of the whole strategy.
- Fix a missing `?` from a previous migration

Change-Id: I7f8fab61c644d14d1f037603a8539a2db5090d8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249547
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-24 01:51:48 +00:00
Johnni Winther 391540c889 [cfe] Make (Abstract)Super*.interfaceTarget non-nullable
This is a step towards improving the semantics of these nodes.

TEST=existing

Change-Id: I95bdb86790414b38af73e9e932cc228b3c0f1f6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249040
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-23 09:16:55 +00:00
Nate Biggs 9d3308528b [dart2js] Migrate visitors.dart and types.dart to nnbd.
Change-Id: Ic9f83d1f1fdae13f71ad04d703d5915148395f2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249520
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-22 23:48:27 +00:00
Mayank Patke 757e3b6537 [dart2js] Migrate static_type.dart to null safety.
Change-Id: I4ef2b7c6f971c085400e348af490515c8c3f47f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249461
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2022-06-22 23:36:15 +00:00
Mayank Patke d8da8c0ca0 [dart2js] Narrow scope of static type visitor.
The static type visitor only needs to be a TreeVisitor.

Change-Id: I5501a7e71719e711895c0ac18b49c9323665c9d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249460
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2022-06-22 23:36:15 +00:00
Stephen Adams 11e3c5c291 [dart2js] Migrate native/resolver.dart
Change-Id: I9dced570166c84e526bba1a9e587bda057f72085
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249443
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-22 20:32:07 +00:00
Stephen Adams 7d145a1074 [dart2js] Migrate common/work.dart, enqueue.dart
Change-Id: I0f37806657459807680fdf23c9912bc7f89a85ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249500
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-22 20:24:25 +00:00
Stephen Adams d2cec155f9 [dart2js] Migrate js_backend/backend_impact.dart
Change-Id: I2fc1a6ce25df29ebd4bcf1520299bdabfde26a7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249444
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2022-06-22 20:24:05 +00:00
Jens Johansen 3c8a679b46 [CFE] Handle unevaluated constants differently in constant evaluator
This for instance avoids an exponential blowup that would previously
have occurred in certain cases.

Change-Id: I258d8153e75f7059bca346826b5dec62cc1bac84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-06-22 08:51:04 +00:00
Stephen Adams 3c6720ac68 [dart2js] Migrate universe/world_impact.dart
Change-Id: Ice05b930f8a9124ad97752f0365c4f4ad71e1c23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249381
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2022-06-22 01:08:25 +00:00
Stephen Adams 3ede648397 [dart2js] Migrate native/behavior.dart
Change-Id: Ib8ce83940f2dc6475196b297f94b42533c7acdf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249140
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-22 00:46:44 +00:00
Nate Biggs 338fb1d62f [dart2js] Add deferred read/write to closed world and global analysis serialization.
Results after this CL:
Without the --deferred-serialization flag the linker phase finishes with ~10.2GB in ~120s.
With the --deferred-serialization flag the linker phase finishes with ~8.4GB in ~118s.
All other phases have negligible changes.

This is a ~17.6% reduction in memory usage and a small improvement in runtime.

Summary of this change:
With this change we target the new Deferrable concept to places that are triggering Kernel AST loads. By deferring the deserialization of these high-level data objects, we avoid the cascading deserialization of many other objects including much of the Kernel AST.

There are still a few locations that load the bodies of some functions. Some are slightly harder to defer for various reasons but represent a small number of function bodies.

This is a first pass and further improvements can probably be achieved with similar changes.

Change-Id: I7449f4222669a7ad8af0a6549d30117133aed03a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247281
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-21 22:44:44 +00:00
Stephen Adams 535efc0004 [dart2js] Migrate universe/member_usage.dart
Change-Id: I2d06c9aac1a74281fcfef6e002d849b9ff45a317
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249402
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-21 22:34:16 +00:00
Nate Biggs 3d35ae434c [dart2js] Add deferred read/write path to serialization.
Results after follow up CL:
Without the --deferred-serialization flag the linker phase finishes with ~10.2GB in ~120s.
With the --deferred-serialization flag the linker phase finishes with ~8.4GB in ~118s.
All other phases have negligible changes.

This is a ~17.6% reduction in memory usage and a small improvement in runtime.

Summary of this change:
We add the concept of a Deferrable which is a potentially lazy object to be read from serialized bytes.

We then specialize the DataSourceReader to either use an 'eager' or 'deferred' strategy when reading a deferrable entity. When writing the data we write the data with the ability for it to be read in either manner.

To start we will use an eager read strategy in all but the linker phase. This will mean an inconsequential memory in increase in all the other phases (a few extra _Eager objects which should only have 2 words each). The serialized bytes should get GCed immediately after the deserialization 'phase' just as they are today.

For the linker phase we will use the deferred read strategy. This will mean that we will hold on to the serialized bytes for each phase (_Deferred -> DataSourceReader -> DataSource -> bytes) but we avoid the creation of many many objects (lots of the Kernel AST and much of the closed world and global analysis data).

Change-Id: Ifa9fad3536dac96ec1fc071953dc0f9899544da8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247280
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-21 22:32:54 +00:00
Stephen Adams 053c25f7bc [dart2js] js_backend/ should not depend on ssa/
Break cycle by passing in the MemberEntity being compiled rather than
its HGraph.

Add some 'show' clauses to some imports.

Change-Id: I89557fa45320ccbd7c564ebe7d396b3628bfacd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249241
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-21 22:26:14 +00:00
Sigmund Cherem 4a6076926e [dart2js] Migrate use.dart
Change-Id: Ia5cafb6d2cbb7acbd9e28a89f0de71f94e34926f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249061
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-21 17:42:24 +00:00
Stephen Adams e2df05ed6b [dart2js] Take care not to split surrogate pairs when writing output
dart2js chunks the writing of the JavaScript file.  With `--utf8`, the
output can contain code points that are represented as two surrogate
pairs code units in the UTF-16 string. If the chunking splits the the
surrogate pair then the lower level UTF8 encoding does not see the
other element of the pair, so encodes the illegal unpaired surrogate
as U+FFFD � (REPLACEMENT CHARACTER).

The code point U+10000 ("𐀀") is encoded as the surrogate pair U+D800
followed by U+DC00, which normally is emitted as the UTF8 bytes

    ... F0 90 80 80 ...

If split, each surrogate is converted to U+FFFD, resulting in bytes

    ... EF BF BD EF BF BD ...

This change avoids splitting the surrogate pair by adjusting the index
at which the string is split.

Change-Id: I9629bf07d391005934c99d1dd649c55c4c58c3bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249066
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-18 05:12:39 +00:00
Stephen Adams 3644a596d2 [dart2js] Migrate JsToFrontendMap
Move JsToFrontendMap to its own file.
This will unblock migrating native/behavior.dart.

Change-Id: I13f44509e83e16a77f7128e20804338445390a64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248940
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-17 21:35:49 +00:00
Srujan Gaddam 459d57c8b8 [package:js] Add static interop stub for outlines
Fixes b/235393918

@staticInterop replaces factories with a new named node, a static
method. In order to persist this transformation in modular
compilation, this needs to be done to outlines that can then be
consumed by the source library. In order to allow erasure at the
time of 'performOutlineTransformations', coreTypes is added to that
API.

Change-Id: I90d17fff8bbe143982fcd12cfb06dc3e8d58781a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247928
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-17 19:58:49 +00:00
Johnni Winther 05bbe907d7 [cfe] Support extraneous references in serialization
This enables the serialization to handle references to libraries that
are not part of the serialized libraries. This is a step towards
removing the need to call computeCanonicalNames from outside the
serialization and to always use library filters for serialization
of a subset of the libraries in a component.

In response to b/235393918

TEST=existing

Change-Id: I48cd8b027795850ac2411a80e4b55efd517bb2cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248588
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-17 11:52:39 +00:00
Stephen Adams 538cf9ee2c [dart2js] Migrate NativeThrowBehavior
Split NativeThrowBehavior into its own file to allow native/js.dart
to be migrated.

Add methods to serialization_interfaces.dart to unblock
native/behavior.dart

Change-Id: Ia6798b41d1b698a24f16eddfeceb4978e32e75c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248920
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-16 23:20:28 +00:00
Mayank Patke edb0389996 [dart2js] Perform SSA dead code elimination in post-dominator order.
Suppose phi A is an input to phi B. Prior to this change, it was
possible for `cleanPhis` to visit A before B. If B got removed or had
its inputs zapped, this could leave A in an unused state. Now, B will
always be visited first, so A can be cleaned up after.

Change-Id: I9cb7c2e6d930e336612be98987cbde82e7447f1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248706
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-16 18:25:39 +00:00
Mayank Patke 4e22740930 [dart2js] Fix handling of type variable locals during inlining.
Even if a function doesn't have an RTI-need for type arguments, locals
for those type variables must still be updated with default values. Some
incorrect control flow caused _setupStateForInlining to skip all type
variable local setup when the function has no RTI-need for type
arguments.

Fixes: #48762
Change-Id: I5d770b6fcd563afa9454026e4b79eb021cf38a37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247609
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-06-15 22:32:39 +00:00
Stephen Adams 8119f9aa86 [dart2js] Migrate output_unit.dart
Change-Id: I16d11d163b0b44e3854eb20312079f641e5ec87a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248640
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-15 20:21:32 +00:00
Stephen Adams de5469376c [dart2js] Use && instead of if-then for late field checks
0.26% reduction in a medium-large sized Angular app.
0.12% on our huge app.

Change-Id: Ifc6b332e420168bc470e6994bf0d1a60e53fdd74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248446
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-15 18:47:49 +00:00
Stephen Adams 2d1e5d29c8 [dart2js] Migrate more serialization dependencies
Change-Id: If58b5b2c61a0bcc59ca4401285fd01254cc80497
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248523
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-15 14:18:48 +00:00
Ahmed Ashour 85700570f6 Fix typos
Fixes #49241

TEST=ci

Change-Id: I6117bf816fc8c4613cce66927f952fef75632725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248120
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-15 11:08:28 +00:00
Stephen Adams 3099911746 [dart2js] Add @pragma('dart2js:disable-inlining') annotation
This annotation prevents inlining at call sites within the method that
is annotated.

The main expected use is to control inlining in unit tests.

Change-Id: Ib6652f0b4cb7a34c6bf829b1be5c09e241ffbde2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248345
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-06-14 18:08:23 +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 58af27c5e6 [dart2js] Update serialization indices to allow for deferred read/write.
Results after this CL:
Without the --deferred-serialization flag the linker phase finishes with ~10.2GB in ~120s.
With the --deferred-serialization flag the linker phase finishes with ~8.4GB in ~118s.
All other phases have negligible changes.

This is a ~17.6% reduction in memory usage and a small improvement in runtime.

Summary of this change:
This introduces the idea of an UnorderedIndexed(Source/Sink) which removes the invariant that all data must be deserialized in the same order it is serialized.

The ordered (current) version of Indexed(Source/Sink) writes a list index in place of previously indexed values. On deserialization it assumes that if it sees a new index the data must be written at that location since the read/write order are the same.

The unordered (new) version of Indexed(Source/Sink) uses the data offset as the index for the data. This way whenever an index is read we know exactly where in the byte array to look it up. We move the "read head" to the specified index and perform the read operation.

There is an extra complication in that indices are shared across serialized files. So an offset written in one file can refer to a location in a different file. To deal with this we offset all of the file offsets by the size of the previous files. This effectively treats all the files as chunks of contiguous memory and the offsets are within that shared address space.

We must then allow for the DataSource being used by the DataSourceReader to be that of a different file for the duration of a read operation so that the data is read from the correct file. The "outside world" is unaware that the source of the data being read changed.

Change-Id: I3896e3c839d8e4c4512cb5bf209dc7d2b8f60191
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246220
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-13 22:34:27 +00:00
Mark Zhou 1219c6f33f [dart2js] resolving info objects with fully qualified names
* Replaces <unnamed> with a package name for certain library info objects

Change-Id: Ib98b661c1c5830283c1691b2a7a6efa80743cd57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247932
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-06-13 22:01:52 +00:00
Mark Zhou 214efd8e3c [dart2js] fixing top level method determination + cosmetic fixes
Change-Id: Ideae37125e66afdc0980b99c5e96f40b6cf6e353
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247930
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-13 21:45:47 +00:00
Mark Zhou ac183fa2fc [dart2js] Moving parameter info resolution to annotation phase for kernel dump info
Fixed:
Change-Id: Ib74af875204d554e35036e0f36ee3710fa73f284
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247929
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-06-13 21:45:47 +00:00
Nate Biggs d427700302 [dart2js] Migrate some easy files to nnbd.
Change-Id: Ib61264fa3febd9067909292d5a4468a9044118a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247286
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-13 17:50:57 +00:00
Stephen Adams 1c442cf9f0 [dart2js] Move ClassTypeVariableAccess to own file
Moving this enum to its own file breaks a dependency of the element
maps on SSA.

Change-Id: If66d1ddf0af6ccdc5380b4f65d5e447e3cebd8de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248081
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-13 16:53:57 +00:00
Johnni Winther 7900e9071a [cfe] Remove support for old super-mixins feature
This CL remove the support for mixing in classes that don't extend
Object. An error has been report by the analyzer for some time and
now also by the CFE.

This puts the breaking change https://github.com/dart-lang/sdk/issues/48167 into effect.

TEST=pkg/front_end/testcases/general/issue48167.dart

Change-Id: Ia7715a27dc1aa18a7c85b24ed86d19a91b6924d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247551
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-13 15:30:57 +00:00
Siva Annamalai 5cb3b37c74 Revert "Refactor _Future."
This reverts commit 69f32d6ad7.

Reason for revert: We seem to have a number of tests failing with timeouts in CBUILD after this change, please see logs at
69f32d6ad7

Original change's description:
> Refactor `_Future`.
>
> This is a major rewrite of the `_Future` class,
> which is the default implementation of the `Future` interface.
>
> The main goal was to reduce the number of expensive type checks
> in the internal passing around of data.
> Expensive type checks are things like
> * `is _Future<T>` (more expensive than just `is _Future`, the latter
>   can be a single class-ID check.
> * Covariant generic parameter checks (using `T` covariantly in a
>   parameter forces a run-time type check).
>
> Also removed some plain unnecessary casts and turned some
> implicit casts from `dynamic` into `unsafeCast`s.
>
> This seems to be an success, at least on very primitive benchmarks, according to Golem:
> FutureCatchErrorTest    41.22% (1.9 noise)
> FutureValueTest         46.51% (2.8 noise)
> EmptyFutureTest         59.15% (3.1 noise)
> FutureWhenCompleteTest  51.10% (3.2 noise)
>
> A secondary goal was to clean up a very old and messy class,
> and make it clearer for other `dart:async` how to interact
> with the future.
>
> The change has a memory cost: The `_FutureListener<S,T>` class,
> which represents a `then`, `catchError` or `whenComplete`
> call on a `_Future`, now contains a reference to its source future,
> the one which provides the inputs to the callbacks,
> as well as the result future returned by the call.
> That's one extra memory slot per listener.
>
> In return, the `_FutureListener` now does not need to
> get its source future as an argument, which needs a covariant
> generic type check, and the methods of `_Future` can be written
> in a way which ignores the type parameters of both `_Future`
> and `_FutureListener`, which reduces complex type checks
> significantly.
>
> In general, typed code is in `_FutureListener`, which knows both
> the source and target types of the listener callbacks, and which
> contains the futures already at that type, so no extra type checking
> is needed.
> The `_Future` class is mostly untyped, except for its "public"
> API, called by other classes, which checks inputs,
> and code interacting with non-native futures.
> Invariants ensure that only correctly typed values
> are stored in the untyped shared `_resultOrListeners` field
> on `_Future`, as determined by its `_state` integer.
> (This was already partially true, and has simply been made
> more consistent.)
>
> Further, we now throw an error in a situation that was previously
> unhandled: When a `_Future` is completed with *itself*.
> That would ensure that the future would never complete
> (it waits for itself to complete before it can complete),
> and may potentially have caused weird loops in the representation.
> In practice, it probably never happens. Now it makes the error
> fail with an error.
> Currently a private `_FutureCyclicDependencyError` which presents
> as an `UnsupportedError`.
> That avoids code like
> ```dart
> import "dart:async";
> void main() {
>   var c = Completer();
>   c.complete(c.future); // bad.
>   print("well!");
>   var d = Completer();
>   d.complete(c.future);
>   print("shucks!");
> }
> ```
> from hanging the runtime by busily searching for the end of a cycle.
>
> See https://github.com/dart-lang/sdk/issues/48225
> Fixes #48225
>
> TEST= refactoring covered by existing tests, few new tests.
>
> Change-Id: Id9fc5af5fe011deb0af3e1e8a4ea3a91799f9da4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244241
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

TBR=lrn@google.com,kustermann@google.com,sra@google.com,sigmund@google.com,nshahan@google.com

Change-Id: I455be5a04b4c346df26d4ded0fa7388baccb0f8c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247762
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-06-09 16:51:55 +00:00
Lasse R.H. Nielsen 69f32d6ad7 Refactor _Future.
This is a major rewrite of the `_Future` class,
which is the default implementation of the `Future` interface.

The main goal was to reduce the number of expensive type checks
in the internal passing around of data.
Expensive type checks are things like
* `is _Future<T>` (more expensive than just `is _Future`, the latter
  can be a single class-ID check.
* Covariant generic parameter checks (using `T` covariantly in a
  parameter forces a run-time type check).

Also removed some plain unnecessary casts and turned some
implicit casts from `dynamic` into `unsafeCast`s.

This seems to be an success, at least on very primitive benchmarks, according to Golem:
FutureCatchErrorTest    41.22% (1.9 noise)
FutureValueTest         46.51% (2.8 noise)
EmptyFutureTest         59.15% (3.1 noise)
FutureWhenCompleteTest  51.10% (3.2 noise)

A secondary goal was to clean up a very old and messy class,
and make it clearer for other `dart:async` how to interact
with the future.

The change has a memory cost: The `_FutureListener<S,T>` class,
which represents a `then`, `catchError` or `whenComplete`
call on a `_Future`, now contains a reference to its source future,
the one which provides the inputs to the callbacks,
as well as the result future returned by the call.
That's one extra memory slot per listener.

In return, the `_FutureListener` now does not need to
get its source future as an argument, which needs a covariant
generic type check, and the methods of `_Future` can be written
in a way which ignores the type parameters of both `_Future`
and `_FutureListener`, which reduces complex type checks
significantly.

In general, typed code is in `_FutureListener`, which knows both
the source and target types of the listener callbacks, and which
contains the futures already at that type, so no extra type checking
is needed.
The `_Future` class is mostly untyped, except for its "public"
API, called by other classes, which checks inputs,
and code interacting with non-native futures.
Invariants ensure that only correctly typed values
are stored in the untyped shared `_resultOrListeners` field
on `_Future`, as determined by its `_state` integer.
(This was already partially true, and has simply been made
more consistent.)

Further, we now throw an error in a situation that was previously
unhandled: When a `_Future` is completed with *itself*.
That would ensure that the future would never complete
(it waits for itself to complete before it can complete),
and may potentially have caused weird loops in the representation.
In practice, it probably never happens. Now it makes the error
fail with an error.
Currently a private `_FutureCyclicDependencyError` which presents
as an `UnsupportedError`.
That avoids code like
```dart
import "dart:async";
void main() {
  var c = Completer();
  c.complete(c.future); // bad.
  print("well!");
  var d = Completer();
  d.complete(c.future);
  print("shucks!");
}
```
from hanging the runtime by busily searching for the end of a cycle.

See https://github.com/dart-lang/sdk/issues/48225
Fixes #48225

TEST= refactoring covered by existing tests, few new tests.

Change-Id: Id9fc5af5fe011deb0af3e1e8a4ea3a91799f9da4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244241
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-06-09 15:32:33 +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 de8f84f62d [dart2js] Migrate ir/element_map.dart
Change-Id: I5b00914f7963658446099ca31a5a38aec09437e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247465
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-06-07 22:00:31 +00:00
Nate Biggs 43d68f91c6 [dart2js] Migrate load_kernel.dart to nnbd
Change-Id: If3e8925d5e6888f6c888ca6c81772a3e83f94bad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247285
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-07 16:37:16 +00:00
Stephen Adams 6384eceedc [dart2js] Late instance field optimizations
Late fields start out holding a sentinel value and after they are initialized or assigned, never hold a sentinel value again.
This CL implements some removal of checks and loads based on this monotonic behaviour.

On two large Dart Angular apps, this reduces the number of late-instance-field checks by ~25%.
One app is 0.44% smaller, the other is 0.98% smaller.

The optimization_test.dart no longer forces `--disable-inlining` because that prevents the inlining that exposes the optimization opportunities.
Most tests already use `@pragma('dart2js:noInline')` to prevent inlining where relevant.

Change-Id: I2327a96e69191313ed6c07eabe94aa2962fb2648
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246881
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-06-07 05:57:59 +00:00
Mark Zhou d76e36fbcb [dart2js] Adding kernel dump info regression tests
Ensures that kernel dump info doesn't break the original dump info's behavior.

Change-Id: I9bfe22cea0d1a5597db9c98fe736f20369b80c82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247122
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-06-06 22:35:29 +00:00
Nate Biggs cb2d5c972f [dart2js] Refactor Indexed(Sink/Source) to OrderedIndexed(Sink/Source)
- Rename to OrderedIndexed(Sink/Source)
- Add an interface to be shared with UnorderedIndexed(Sink/Source).
- Move 'reshape' logic into subclass.

Change-Id: I1f891aab961bde6685d77af342729ed6b5f31260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247400
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-06 19:11:21 +00:00
Mark Zhou 7769360d2b [dart2js] Moving dart2js info treeshaking filters to a separate visitor
Prelude to adding kernel dump info tests

Change-Id: I9b349700ec422da3833ee08514946fcd9b7d9b30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246860
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-03 22:17:26 +00:00
Sigmund Cherem 0517e97250 [dart2js] Fix stub generator.
When generating the tear-off stub of a JSInterop method, dart2js
associated the full JSName as the target name, as opposed to a
target path. This meant that code like:

  @JS('console.log')
  external consoleLog(arg1, [arg2]);

  main() => (consoleLog)(1);

Generated a tear-off with code like:

  self[console.log](arg);

Instead of:

  self.console.log(arg);

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

Change-Id: I7abb320ce790e2ce533031fefd3abc15f8958b5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246340
Reviewed-by: Stephen Adams <sra@google.com>
2022-06-03 17:02:26 +00:00
Nate Biggs 0c796a5964 [dart2js] Remove references to global growable list checks.
This is dead code, the field 'isFixedArrayCheckedForGrowable' is never read. Also drop code used to set this field.

The check suggested in the TODO in ssa/builder.dart doesn't reduce code size for cm_shell at all so it seems like all arrays that go through there end up getting "marked" anyway.

Change-Id: Ia4bf3eec3757fc7eadb503a7ccc58b8f60f86b6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244482
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-06-02 22:08:45 +00:00
Nate Biggs f6e4242a5d [dart2js] Fix tests for dart2js_info.
Fixes errors introduced in https://dart-review.googlesource.com/c/sdk/+/246140.

Change-Id: I7d09e58e27bcea138d4945fbda1d45b12bd6f53f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246800
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-06-01 19:56:14 +00:00
Nate Biggs aad436cc53 [dart2js] Migrate first round of dart2js_info to nnbd.
Change-Id: Ifc3f97eb6dad6e785263346f1d41ed5a78705bac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245924
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-05-27 15:31:40 +00:00
Devon Carew f7c46f145c [pkg] prefer 'any' deps for package dev dependencies
Tested: CI validation
Change-Id: If65cc156130a65ffe00c6f1660ac320e2921afae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246053
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-05-27 01:34:59 +00:00
Stephen Adams f7aa8d988d [dart2js] Fix migration mistake for DeferredGlobalConstanValue.unit
Change-Id: I9988f95d7143ba65091e9546d30515352e1b0a6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245906
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-26 20:48:29 +00:00
Nate Biggs a5042374a0 [dart2js] Migrate more files to nnbd.
Change-Id: I9a7e3fc95659fee3bfd459f49de736f83bc48654
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245922
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-05-26 15:17:49 +00:00
Nate Biggs 7b9d1d851c [dart2js] Migrate several files to nnbd.
Change-Id: I6e2e2b24e73ce15d02fd889e191ff0b6d71c9732
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245921
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-05-26 05:22:28 +00:00
Stephen Adams 28e36a8ff9 [dart2js] Migrate js/rewrite_async.dart
Change-Id: I3771393f27a41417ed0d43608ddae0ee6fb78748
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245912
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2022-05-26 02:57:58 +00:00
Stephen Adams 57c8184fe5 [dart2js] Fix random spelling errors.
Change-Id: I975462e071184c53817f133a9973883d7ea7a7b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246044
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-25 20:55:30 +00:00
Nate Biggs 362afe3656 [dart2js] Migrate tasks.dart to nnbd
Change-Id: I98e0cf54990ab5f4dc98b44660c4a195da3eab98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245920
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-25 02:33:48 +00:00
Sigmund Cherem 4f3714e595 [dart2js] be resilient if we can't compute RAM usage.
Under some configurations, we can't obtain an observatoryURI to compute
the RAM utilization of dart2js. It appears this happens when building
in product mode: "./tools/build.py -m product create_sdk".

This changes the logic to return "N/A" when that happens.

Change-Id: Ic8c9e89a09603558db3ac07ea696aed77f2eaca1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245781
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-05-24 16:30:55 +00:00
Ahmed Ashour a6fcb56901 Fix typos
Fixes #49094

TEST=ci

Change-Id: I23cdcb5ad2fc83e5e91d80e34b66af186c0cb923
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-05-24 09:10:51 +00:00
Mark Zhou 1c27154f41 [dart2js] Adding closure dump info tests + fixing sibling logic in kernel dump info
- Reconciles some logic for closure/LocalFunction name resolution between dump info and the element model
- Handles closure disambiguation (j world <-> k world) by assuming fixed visit order

Change-Id: Ic9a61208ed93372633e118541b71f20543e250a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245600
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-24 01:04:41 +00:00
Stephen Adams 8f81740066 [dart2js] Migrate js_backend/string_reference.dart
Change-Id: I817aff48464131e24284be6da8a7da96aab6e0b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245620
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-23 19:33:30 +00:00
Nicholas Shahan 444982f364 [web] Share more runtime code between ddc and dart2js
Creates a new 'dart:_js_shared_embedded_names' library for the names
accessed from the shared 'dart:_rti' library. Migrate all of the shared
symbols and uses to the new location.

Change-Id: Iaa72c4522888ad630782b921b0b70d7a2626d1b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241507
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-05-23 18:04:10 +00:00
Stephen Adams d10f740398 [dart2js] Migrate js_backend/annotations.dart
Change-Id: I98cb726cbbc82339ddeacf56d14a322236def864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245561
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-05-21 05:55:32 +00:00
Sigmund Cherem 077a7907e6 [dart2js] Include memory usage in dart2js's output.
This adds a small text on the output of dart2js to indicate how much memory
it consumed during compilation.

It's implemented via a service protocol API that collects the total heap
capacity at the time dart2js is practically done with compilation.
Once this is in place, we could change our benchmarks to start using this metric.

Change-Id: Iaf4425ef713ce0195474ef4e818149d46ab55e9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244802
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-19 18:42:00 +00:00
Mark Zhou 5270767eda [dart2js] Adding kernel closure information to dump info.
Change-Id: I7880d64b3c7ff62a1b1ad50ba5157f252e311aa2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245280
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-05-19 16:38:21 +00:00
Stephen Adams 3bc3e9f1ca [dart2js] Fix minor bug in rewrite_async.dart
We were always emitting an initialization of the $async$next stack for
unwinding finally blocks, even if there was no finally. The extra code
only appeared in generators that had try-catch-(no-finally), and seems
to be harmless, if slightly inefficient.

Change-Id: Ic1fa80e451fe00015a53b0319e3b56d2aaf04a30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245088
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-19 01:01:23 +00:00
Nicholas Shahan 58c84272bc [web] Move libraries to a shared location
These libraries will be shared between the dart2js and DDC runtimes.

Also renames the `shared` directory to `synced` to avoid confusion.
Synced directories are copied to be in sync with the compilers and
runtimes.

Change-Id: Ic36076938741d7102792f09413666de0033da3a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238300
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-05-18 19:59:33 +00:00
Stephen Adams e9ba00e518 [dart2js] Migrate js_emitter/constant_ordering.dart
Change-Id: I2270e470ca03b7abb750f56fe319b35412b68551
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245085
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-18 16:57:13 +00:00
Stephen Adams d10ee227fa [dart2js] Some trivial NNBD migrations
Change-Id: I0748d5295547237708b8321c7883aa771bd30a6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245140
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-18 05:08:37 +00:00
Johnni Winther 5222bfd90c [cfe] Refactor bounds checking
This CL moves the bounds checking into the TypeBuilder instead of
performing it from the outside on the computed DartType node.
This solves several problems:

  1) Errors are now reported on the type in the code instead of the
     declaration which holds the type.
  2) Checking of type aliases (both function and nonfunction type
     aliases) is now handled correctly in all cases. This achieved by
     computed the aliased type (containing TypedefType nodes)
     internally and performing the checking on this type, and only
     convert the type into the unaliased version (without TypedefType
     nodes) after checks have been performed. Previously this handled
     through the FunctionType.typedefType property for function type
     aliases and through and incomplete work-around for nonfunction
     type aliases.
  3) With 2) FunctionType.typedefType is no longer needed and is
     removed.

TEST=general/bounds_*

Change-Id: I7653bca5ccb0ebf4b3553828a298d1ad918ef235
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243722
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-17 14:36:19 +00:00
Nate Biggs 2037563b94 [dart2js] Migrate common/elements.dart to nnbd
Change-Id: I3be0442cd37674a208c55c87437df7159d763e9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244602
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-05-17 13:58:39 +00:00
Nate Biggs af589a8f6b [dart2js] Migrate abstract_value_domain to nnbd
Change-Id: Ic4258db7fcf29d23607d392e5ed2e6672221f6c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244700
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-05-17 03:04:25 +00:00
Nate Bosch 6ebd2633cd Use any deps for all unpublished packages
It should not be necessary to ever run `pub get` for a package which is
not published. All packages used in the SDK are controlled by a single
package config, so it's not necessary to declare versions or paths for
any packages.

Remove all dependency overrides.

R=devoncarew@google.com

Change-Id: Icb328813b471f35ee4c99995f4e90aac4d8ed438
Tested: Covered by existing static analysis.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244767
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2022-05-17 01:22:25 +00:00
Nate Biggs ebce8e8dd0 [dart2js] Migrate elements/indexed.dart to nnbd
Change-Id: Ice865c35a5bc0641622da22c47cb5d56e782bcf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244600
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-14 03:15:36 +00:00
Nate Biggs f6dd05939d [dart2js] Migrate ir/annotations.dart to nnbd
Change-Id: Iec104f841b1900fc8dd47e2a41ea201a7e900286
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244601
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-14 01:10:57 +00:00
Nate Bosch 1e04fe1fd0 Reland "Sync packages from shelf mono repo"
This is a reland of commit 072603d40a

Original change's description:
> Sync packages from shelf mono repo
>
> Drop the DEPS entries for the repositories which will be archived. Each
> of the packages has been merged into the `shelf` repository.
>
> Add the `shelf` repository to the specially handled directories with
> nested packages in `generate_package_config`.
>
> Update path dependencies in pubspecs to the new location.
>
> R=devoncarew@google.com
>
> Change-Id: Iefca4fdb2abb6bafa273b9b6b1b4f25d6c91b005
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243929
> Reviewed-by: Alexander Thomas <athom@google.com>
> Reviewed-by: Devon Carew <devoncarew@google.com>
> Commit-Queue: Nate Bosch <nbosch@google.com>
> Auto-Submit: Nate Bosch <nbosch@google.com>

Change-Id: I064d9bc87263e02357021c1def2b656afe45cf22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244725
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2022-05-12 21:35:55 +00:00
Nate Bosch 4c8654eb10 Revert "Sync packages from shelf mono repo"
This reverts commit 243ac04dbf.

Reason for revert: Breaks roll to flutter engine still.

Original change's description:
> Sync packages from shelf mono repo
>
> Keep the DEPS entries and directories for the old locations for these
> packages, but ignore them in `generate_package_config`. Removing the
> hashes and directories would invalidate the DEPS file in the flutter
> engine repository.
>
> Add the `shelf` repository to the specially handled directories with
> nested packages in `generate_package_config`.
>
> Update path dependencies in pubspecs to the new location.
>
> Reland of https://dart-review.googlesource.com/c/sdk/+/243929
> without the removal of the old directory locations.
>
> R=​devoncarew@google.com
>
> Change-Id: I3d3b3eb0722f3eba518a6a1034ed9c24f83c70f0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244300
> Reviewed-by: Devon Carew <devoncarew@google.com>
> Commit-Queue: Nate Bosch <nbosch@google.com>

TBR=devoncarew@google.com,nbosch@google.com

Change-Id: Ied6d9aa685208eddea6d82d04ca8876937651051
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244302
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2022-05-12 00:00:34 +00:00
Mayank Patke 4ea2b74256 [dart2js] Initialize all primitive constants in field allocators.
Change-Id: I6e1c3618758b1a569ee6d5d6c21520571d3234fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244361
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-05-11 23:37:44 +00:00