Commit graph

5361 commits

Author SHA1 Message Date
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
Mayank Patke 41ba014616 [dart2js] Clean up .isXXX members on ConstantValue.
Bug: #48974
Change-Id: If70fac64e69f60fb5228492eac5591d620f25f77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244360
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-05-11 20:25:44 +00:00
Nate Bosch 3c231e4f57 Read package_config.json in more tests
Towards #48275

R=mit@google.com

Change-Id: I38cc986937543c5e4d1f2a2cd4c7804d180a2741
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244304
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2022-05-11 18:58:44 +00:00
Nate Bosch 243ac04dbf 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>
2022-05-11 15:10:14 +00:00
Mayank Patke 34ebfc6594 [dart2js] Add regression test for https://dart-review.googlesource.com/c/sdk/+/225320
Change-Id: Iff348b9ce13ea249b8c63f8c0952cd446ad5cb7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243528
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-05-10 22:56:23 +00:00
Mayank Patke e5498bcd40 [dart2js] Clean up some file paths.
* The wrapped abstract value domain is moved out of the powersets folder
  since they're unrelated.
* {inferrer,ssa}/builder_kernel.dart renamed to just builder.dart since
  we only operate on kernel.
* inferrer/inferrer_engine.dart renamed to engine.dart since it was
  redundant.

Change-Id: I355e626431d8a49e9a944341360b2d6401895929
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243645
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-05-10 21:36:13 +00:00
Joshua Litt 2783cca57d [dart2js] Fix bug in impact data serialization.
Change-Id: I1e4915624b609aafa9392fc651f5935bf658a71b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244184
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-05-10 03:34:13 +00:00
Nate Bosch fac9bbb5d6 Revert "Sync packages from shelf mono repo"
This reverts commit 072603d40a.

Reason for revert: Causing issues with rolling into flutter engine.

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>

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

Change-Id: Ic610d47a3294a7dac9503e8a7b160173e0009056
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244140
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-05-09 22:58:22 +00:00
Nate Bosch 072603d40a 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>
2022-05-09 19:14:52 +00:00
Stephen Adams daba3529cb [dart2js] Migrate constants/constant_system.dart
Most of the change is changing `foo.isInt` to `foo is IntConstantValue` to get promotion and avoid downcasts.

Change-Id: Ie38bc5500dcb22ed9e194e6b810702dd94f2f79e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243926
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-07 01:05:50 +00:00
Stephen Adams e3e9aed1f5 [dart2js] Migrate constants/values.dart
Change-Id: Ia042b4ba17407bd8a4da404ce832ae83d046cb1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243880
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2022-05-06 15:58:15 +00:00
Stephen Adams b488bd1a75 [dart2js] Migrating cycle in io/ and js/
This migrates js/js.dart which will unblock the {ConstantValue,OutputUnit} cycle.


Change-Id: I6d49c2c588ac3a58e7698228e1b276d4cfb931d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243531
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2022-05-06 03:54:16 +00:00
Sigmund Cherem bf2cff83d5 [dart2js]: Update README
One pass to update the general description of the compiler pipeline.

Change-Id: I0597958139e9ea11b27dcb6072b8d70a90c9c937
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242505
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-05-06 01:16:25 +00:00
Nate Biggs c6173d3686 [dart2js] Correctness updates for async lowering.
- Wrap returns in Future.value to ensure the returned Future has the async function's return type.
- Skip any function that has try/catch/finally as these introduce more complex control flow. (Might be able to convert these using an onError callback in the future).
- Don't assume futureValueType since CFE might not populate it in Kernel when syntax is incorrect.

Change-Id: Ice3954da52a10a74f93b0adc6409a2d98e13cb3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241260
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-05-05 21:25:45 +00:00
Stephen Adams 56765625e0 [dart2js] Migrate more of serialization/ to NNBD
This CL reduces the number of part files in serialization/ by moving
classes into smaller libraries.

This allows the {Data,Binary,Object}{Sink,Source} to be migrated to
NNBD while sink.dart and source.dart still have dependencies.

Change-Id: I0ea44f95841f18978e78c2e1697fbc97a3bf73c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243711
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-05 20:04:45 +00:00
Mark Zhou bf5690dd0c [dart2js] Removing size checks from main output unit dump info tests
These were far too sensitive to code size changes and causing unhelpful failures.

Change-Id: I5293c7d281a5db2d36af35f67966f4d47413a78a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243561
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-05-03 23:14:04 +00:00
Mark Zhou 9c572f08ca [dart2js] Adding closure tests for dump info members
Change-Id: I73d6e262941fa1b8278f32c3e17689e45dea4ebd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243383
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-03 20:53:34 +00:00
Stephen Adams 7836057041 [dart2js] Share late-check name strings
0.925% reduction in specific Dart Angular app.

Change-Id: Ic4828a3175775060397a8f9cb513b18f175f5c6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242424
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-03 06:03:58 +00:00
Mark Zhou 9925c72e55 [dart2js] Adding program-level info to dump info tests
Change-Id: I3df11ad508259ac12080bab6595377550124c8a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243023
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-02 22:00:52 +00:00
Stephen Adams 0d5d34a2ed [dart2js] Migrate more serialization methods
Change-Id: I1fb46ff661197c321afad040d284d0da33ff2ed3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243024
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-05-02 20:14:12 +00:00
Sigmund Cherem 6eb527be4d [dart2js] migrate program split constraints to null safety
Change-Id: Ice2bcf15d55e0b9bff0a11376c0b9ff42e012b50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243025
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-05-02 19:30:54 +00:00
Nate Biggs 017393ecdc [dart2js] Migrate member_data.dart and node_indexer.dart to nnbd
Change-Id: I0e80d9aacb6e2f15afa2388543ad3dcbd68065ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242700
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-05-02 18:02:28 +00:00
Mark Zhou a0b35de326 [dart2js] Moving runtime allocations to pkg:dart2js_runtime_metrics
* Stores runtime information on `$runtimeMetrics` instead of `$__dart_deferred_initializers__`
* Keys each app's runtime allocations onto self.runtimeMetrics.$currentScript

Change-Id: I6612fd2a5ac792bfcb7580ffe91d5391b80d5965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242507
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-29 21:48:41 +00:00
Stephen Adams f092184371 [dart2js] Migrate io/source_file.dart
Change-Id: Ic5c29160ed048ebce5ee48d05734096d9e451edb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243041
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-04-29 21:27:13 +00:00
Stephen Adams c50157e099 Support invoking JS operators through dart:js_util.
Some JS functionality is only exposed through operators, such as
implicit type conversions and BigInt arithmetic. Other than requiring
some minor additions for the exponentiation (`**`) operator, supporting
these through `dart:js_util` is trivial.

Change-Id: I010674303e4f99b42d43b73095de69b8ddcdeb47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242680
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-28 21:18:40 +00:00
Stephen Adams c8ad81e0c3 [dart2js] Move ParameterStructureMethods back to ParameterStructure
This cleans up the temporary splitting of ParameterStructure into two
libraries.

Change-Id: I475ed3dfc67da81c1f4bcc85c5660095d5457374
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242781
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-28 19:57:43 +00:00
Stephen Adams 779f1341fd [dart2js] Migrate ir/{closure,constants,scope,scope_visitor}.dart
These libraries are a cycle.

Change-Id: I0d1145876dd4dc341c426de9dafd4a2ff817fd81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242780
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-28 19:49:41 +00:00
Nate Biggs 8033bb0fa0 [dart2js] Add interner for DartTypes.
This interner handles both Kernel DartType and the dart2js model.

Some samples of memory usage before and after this change (from linking/output phase):

Before: https://screenshot.googleplex.com/ctYKkApkrqaoHDg
After: https://screenshot.googleplex.com/4fyCXXNNUbyWSyu

Before: https://screenshot.googleplex.com/4nLYCQ6CkqdzgaQ
After: https://screenshot.googleplex.com/5N9btNjGbsdHpW3


Change-Id: I1b86bc1a134703259830a6ea31b4ccb10abaea8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241621
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-04-27 20:33:34 +00:00