Commit graph

5503 commits

Author SHA1 Message Date
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
Stephen Adams d50e9e9355 [dart2js] Migrate ir/static_type_cache.dart
Change-Id: Ife640422d829cf7e74015876788df1c83e4df3ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242522
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-27 19:08:04 +00:00
Stephen Adams 4d9da00440 [dart2js] Migrate elements/types.dart to NNBD
- create a small 'facade' interface CommonElementsForDartTypes so that common/elements.dart can implement this interface to break the cycle between common/elements.dart and elements/types.dart

- Separate the tagging enums used into serialization into a separate 'tags.dart' library.

- Scattered hints to help the migration tool.

Change-Id: I8dbb993ebeb85f240392bafa53e4cc235825f63e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242506
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-27 19:05:44 +00:00
Stephen Adams b314f3f5ea [dart2js] Migrate selector.dart and call_structure.dart
Change-Id: Idd3e326fb974118d593b1737f898ac78567a054c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242301
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-04-26 03:49:13 +00:00
Joshua Litt c242053202 [dart2js] Fix bug in constant impact visitor.
Currently we do not collect constants from UnevaluatedContants.

Change-Id: Ie9ff2cd09cdd654f2294f4eee42edbfdc652695f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242220
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-25 18:51:37 +00:00
Sigmund Cherem 2b806379e2 [dart2js] update pubspec.
My local IDE was happy using the .packages file that used to be
pre-generated by default.  That file was removed from the repo, so I
need to call "dart pub get" to generate it on my local workflow.
This changes makes it possible to do so.

Change-Id: I7c9433cb71423c60810c6a5fc18e7da73c9bbe0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242261
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-04-25 18:29:02 +00:00
Mark Zhou dfd5109b64 [dart2js] Adding class and classtype dump info tests
Change-Id: Iba41106c2b75a8247123e36b505e0be42ad51fad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242181
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-24 20:05:20 +00:00
Mark Zhou ee5a62ff4e [dart2js] Adding dump info library tests
Change-Id: I1d9a30838dc08612032051f60344588f84b1d436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242163
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-24 19:57:51 +00:00
Stephen Adams db5d9ffc16 [dart2js] Migrate common.dart
`diagnostic_listener.dart` is the last unmigrated import of
`common.dart`, which is imported in ~100 files.

`compiler_api.dart` is split to move the `compile` method with
unmigrated dependencies to another file to allow `compiler_api.dart` to
become migrated. Luckily there is only one reference to `compile`.

We no longer allow null `SourceSpan`s and use `SourceSpan.unknown()`
instead.

Added `SpannableWithEntity` as a migrated interface that `HInstruction`
can implement to break the dependency on a large unmigrated ssa library.

Change-Id: I0a5ff6e6c36a34ff55d98f634c671bb8f1fb9e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242161
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-23 03:13:59 +00:00
Sigmund Cherem e5f4b85066 [dart2js] Fix deferred load URI when baseUrl has a single path segment
This fixes https://github.com/dart-lang/sdk/issues/48848

When the base URI is just a filename, then base was empty, and we accidentally
added a / in the first position.  This made the deferred URI absolute by
mistake.

Change-Id: I4d6a773f6ef8bfefbbf61417bfe7c005aa5e63ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241990
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-04-22 21:33:10 +00:00
Mark Zhou 3216e8ccb6 [dart2js] Adding external member test for dump info
Change-Id: I3f1541771a016d88e123252918bc648302887918
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241992
Auto-Submit: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-22 21:14:09 +00:00
Mayank Patke e085928061 [dart2js] Cleanup some unused paramters in the locals handler.
Change-Id: Ic4fd58ab0c9b3b64a0911b5ae058e05ce311e3b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241880
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-04-21 21:10:58 +00:00
Mayank Patke 091559359e Reland "[dart2js] Lower late field checks during SSA."
This reverts commit 45c1e51bb3.

Reason for revert: Reland

Original change's description:
> Revert "[dart2js] Lower late field checks during SSA."
>
> This reverts commit 7187b2efe9.
>
> Reason for revert: Broke flutter roll
>
> Original change's description:
> > [dart2js] Lower late field checks during SSA.
> >
> > Change-Id: I80e7a30c6f2a461e46b4f52ebf7eb7a13fbc6227
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240501
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Commit-Queue: Mayank Patke <fishythefish@google.com>
>
> TBR=sra@google.com,fishythefish@google.com
>
> Change-Id: Idf4eff95425db4d770137d589d4bb5484fc6e187
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241806
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Commit-Queue: Mayank Patke <fishythefish@google.com>


Change-Id: Iccba8947a5778f5310e194d814b398dc46465fbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241807
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-04-21 21:10:58 +00:00
Mayank Patke ec49b532c5 [dart2js] Improve narrowing of late fields.
Checks for late sentinels now behave like null checks and refine the
local on each branch.

Change-Id: I71fdcf50529c52ef82e2cff81425a34174e5c366
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225320
Reviewed-by: Stephen Adams <sra@google.com>
2022-04-21 21:10:58 +00:00
Mark Zhou 7f98a6dfe6 [dart2js] Adding holder info to dump info tests.
Change-Id: Ia45bc281cda289dcfa125aa40622a39e16f9422f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241500
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-21 17:55:58 +00:00
Stephen Adams 618db8a41d [dart2js] Rename lib/compiler.dart to lib/compiler_api.dart
Always import 'lib/compiler_api.dart' with prefix 'api'.
Remove import of 'lib/src/compiler.dart' with prefix 'api'.

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

Change-Id: I3f82d7d31f1c90a860c9811fce031a64cea04ddb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241867
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-21 03:42:39 +00:00
Joshua Litt 43cfa8cea3 [dart2js] Support trimming modular analysis data.
Change-Id: I0e0902813fd71c0bda5de6171487fa0e941f6bad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241246
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-20 21:58:29 +00:00
Stephen Adams 3634234ca0 [dart2js] Some simple NNBD migrations
- Migrate five trivial libraries.
- Add 'show' on some imports to help understand imports that use only a few definitions.

Change-Id: Ibc26b78d65cb808fa6146e47e8ae8c7d336303b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241693
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-20 20:18:38 +00:00
Mark Zhou d8baf0e377 [dart2js] Adding initial unit test for dump info members
Change-Id: I9209d8bae4106eb2a8666fc24b37be4845d2639f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241346
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-20 19:34:18 +00:00
Mayank Patke 45c1e51bb3 Revert "[dart2js] Lower late field checks during SSA."
This reverts commit 7187b2efe9.

Reason for revert: Broke flutter roll

Original change's description:
> [dart2js] Lower late field checks during SSA.
>
> Change-Id: I80e7a30c6f2a461e46b4f52ebf7eb7a13fbc6227
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240501
> Reviewed-by: Stephen Adams <sra@google.com>
> Commit-Queue: Mayank Patke <fishythefish@google.com>

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

Change-Id: Idf4eff95425db4d770137d589d4bb5484fc6e187
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241806
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-04-20 18:37:18 +00:00
Johnni Winther f26c0e2056 [cfe] Add explicit type argument to .map(...).toList()
Expressions like

  List<VariableDeclaration> variables = ...
  List<Expression> reads = variables.map((v) => VariableGet(v)).toList()

don't get the intended type argument `<Expression>` through inference,
but instead the type inferred from the return type of the closure, in
this case `<VariableGet>`.

This causes problems when used with the AST which assumes that
expressions are interchangeable wherever they are used, and is likely
the cause of https://github.com/flutter/flutter/issues/102077 .

This CL adds an explicit type argument in these cases.

TEST=general/infer_map

Change-Id: I0bcae21f06c54f290dc20686b0d84c065d8ea04c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241605
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-20 06:56:58 +00:00
Stephen Adams 35c78ac66b [dart2js] Migrate more of entities.dart
`entities.dart` is now a migrated library.
The definitions formerly moved to `entities_migrated.dart` have been
moved back.

There are a few methods of ParameterStructure that can't yet be
migrated.

The unmigrated methods of ParameterStructure have been moved to static
methods of ParameterStructureMethods and static extension methods in
`entities_parameter_structure_methods.dart`.

These methods will eventually be moved back into ParameterStructure.

The long file name is chosen to sort next to `entities.dart`.

Change-Id: Ie9e798315287b196db694fe66c323a92bc1a1f1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241701
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-20 04:46:57 +00:00
Stephen Adams 5620ce110f [dart2js] late field helper need global impacts
This ensures that the helpers are seen as being part of the main unit
for deferred-load compiles.

Prior to this change, debug dart2js would assert:

$ sdk/bin/dart2js_developer  --test-mode --packages=.packages benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart  --out=om1c/o.js
org-dartlang-sdk:///lib/_internal/js_runtime/lib/late_helper.dart@343+1:
Internal Error: The compiler crashed when compiling this element.
The compiler is broken.

When compiling the above element, the compiler crashed. It is not
possible to tell if this is caused by a problem in your program or
not. Regardless, the compiler should not crash.

The Dart team would greatly appreciate if you would take a moment to
report this problem at http://dartbug.com/new.

Please include the following information:

* the name and version of your operating system,

* the Dart SDK build number (build number could not be determined), and

* the entire message you see here (including the full stack trace
  below as well as the source location above).

The compiler crashed: 'package:compiler/src/deferred_load/output_unit.dart': Failed assertion: line 272 pos 12: 'unit != null': No output unit for member j:method(throwLateFieldNI)
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      OutputUnitData.outputUnitForMember (package:compiler/src/deferred_load/output_unit.dart:272:12)
#3      OutputUnitData.hasOnlyNonDeferredImportPaths (package:compiler/src/deferred_load/output_unit.dart:306:33)
#4      KernelSsaGraphBuilder._tryInlineMethod.heuristicSayGoodToGo (package:compiler/src/ssa/builder_kernel.dart:5922:12)


Change-Id: Ic31c4894105a9a22eb0821a489c8dd2a4e3d0110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241686
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-19 22:06:47 +00:00
Mayank Patke 7187b2efe9 [dart2js] Lower late field checks during SSA.
Change-Id: I80e7a30c6f2a461e46b4f52ebf7eb7a13fbc6227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240501
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-04-19 19:01:27 +00:00
Stephen Adams 47474fbcff [dart2js] Remove most of elements/operators.dart
The rich hierarchy of operators is no longer relevant since parsing
was moved to the common front-end.

All that remains is a Set of operator names that can be used to
declare instance methods.

This set is used for picking the 'operator' variety of Selector. I'm not
sure we even need operator selectors, but I am leaving that for future
consideration.

Change-Id: I7337c0cf82a3cb8f7ebf5fa17a737bac3a83f48b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241560
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-19 16:29:33 +00:00
Stephen Adams 65bbfca88d [dart2js] Split entities.dart to migrate some definitions
- migrate elements/jumps.dart, elements/names.dart, ir/util.dat

Change-Id: I57fc9c42dc0cca407bba38dfbf89fe7bfa6bd15d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241380
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-18 22:09:47 +00:00
Stephen Adams d572ef4b5e [dart2js] Migrate CodeOutputListener
Change-Id: I07c6a53f42a94f424bccea6d3bb05fbdc7ed801d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241440
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-18 18:36:57 +00:00
Mark Zhou 983b14f207 [dart2js] Containerizing dump info mutable state and output
Setup for dump info ID tests, which will rely on both AllInfo and the info maps

Change-Id: I92398c540d102fb2983ad77d4d20705009cc2f99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241345
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-18 17:44:06 +00:00
Mayank Patke ba8b4c8404 [dart2js] Ensure live/checked type visitors consider instantiations of
type variables.

Change-Id: I2fb404e5d544382fd4387268fd8c5765475abe65
Fixes: #48277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241148
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-04-16 00:07:25 +00:00
Stephen Adams b755c4939b [dart2js] Delete unused file script.dart
Change-Id: I3b4dafcb46d478394dcee5f5c5ef602306ecc215
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241343
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-15 23:08:45 +00:00
Stephen Adams bd79c3afbe [dart2js] Some trivial migrations
Change-Id: Ie8033e30f74142c10794909b449565f9024beb7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241342
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-04-15 22:30:34 +00:00
Stephen Adams 97d09743ee [dart2js] Pre-migration hints
Changes are mainly in elements/types.dart.

There are a few places where the code was rewritten to allow
non-nullable types, e.g. List.filled -> List.generate and changing an
assert into an if-test.

Change-Id: I0925c644c1152aa70d7a4cd3732307b898c2a68d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240919
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-15 20:23:06 +00:00
Stephen Adams b6bb10f69a [dart2js] Avoid some 'allowNull' options
This change is in preparation for migrating dart2js to NNBD.

In serialization some methods have an 'allowNull' or 'emptyAsNull'
optional arguments.

I'm trying to remove these named parameters and replace

    // @dart = 2.10
    Foo readFoo({bool allowNull: false});

with

    // TODO: @dart = 2.16
    Foo readFoo();
    Foo? readFooOrNull();

Having two functions with different return types helps keep the
nullability 'tight'. This helps the migration tool infer the correct
types.

For collections, we don't need two functions on the 'write' side, but
I think it is useful to keep the readers and writers consistent.

Change-Id: I40dc216b50c90e9bacf487436605f0bf2b1d94e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241206
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-14 19:26:13 +00:00
Mark Zhou 61a4d7ef68 [dart2js] Removing most non-kernel operations from kernel dump info
Note: Function parameter logic is incomplete, and some JElement tables need to be updated.
Change-Id: I429ff40160b0c4e96c6e6916ba371a01c7bb087c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240945
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-14 01:08:19 +00:00
Mark Zhou ce29691ba7 [dart2js] Adding annotator layer to kernel dump info
The Annotator appends closed-world info to the KernelDumpInfo data
(such as output unit, treeshaken status, and code size).
The annotator also processes closures (since these aren't visible to the kernel).

The general pattern is:
  * Generate lookup key from JElement node
  * Find the Kernel-generated info node with this lookup key
  * Visit JElement node
  * Annotate the Kernel info with new information

Note: Function parameter logic is incomplete


Change-Id: I9b2eaea7330aebb666042a61268128a4fc1074b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240944
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-14 01:07:53 +00:00
Joshua Litt 9a33643d76 [dart2js] Restore modular analysis test coverage.
Change-Id: Ieb58782c916a5e2c3a8b4797c8f8a49562fdcd5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240906
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-13 17:06:22 +00:00
Stephen Adams 2ed65e2a13 [dart2js] Pre-migration cleanups
- Annotations of /*?*/, /*!*/, /*late*/ and /*required*/ to help migration tool.
- Other cleanups (unused import, unnecessary 'implements').

Change-Id: Ibba552b4c5d1006c29ce9b40a8336c9438bf3ede
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241047
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-13 00:41:42 +00:00
Mark Zhou 294d034bd5 [dart2js] Adding treeshaking info to dumpInfo data structs
Change-Id: Ib9692ba12c85e5d1cbf5bb065a305cfc9425a00d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240943
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-12 22:27:17 +00:00
Mayank Patke ecf42a3815 [dart2js] Throw if undetermined nullability is encountered.
Change-Id: I6333275a0abafd91b847474726980e043d4d0cb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238163
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-04-12 18:41:52 +00:00
Stephen Adams 5eaca99b03 [dart2js] Migrate part of src/diagnostics
Change-Id: I691ee17bcebf607112b072b90b813f89ce389499
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240961
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-12 18:29:14 +00:00
Joshua Litt bd0391e66c [dart2js] Enable CFE constant evaluation.
Change-Id: Ib449906bbfd95b6510e701606c43ef4c4169313b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240601
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 16:57:16 +00:00
Stephen Adams 30413a1c5f [dart2js] Require SDK 2.16
Change-Id: I1594cb85c40feae1508ec31a5b4740eb6ca72816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240600
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-09 04:15:20 +00:00
Sigmund Cherem 441a762352 [modular_test] no longer generate .packages within modular test suites
Since the null-safety test migration we've been generating both a .packages file
and a package_config.json file. This deletes the use of the old .packages file
and updates all references to use the new file.

Change-Id: Iecef64ac8ed8579338795ad5327765118d643236
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240650
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-04-09 00:35:13 +00:00
Nate Biggs dbc91a01ad [dart2js] Skip lowering async functions with await...for loops.
These loops introduce control flow that is more complex and harder to represent with Futures.

Tests are back to their state prior to the start of the async/await lowering changes. (The one failing test was already timing out)

Change-Id: Ia65f1a11bd73f2a30e7a186d69c34774c9e361a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240381
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-04-08 21:47:29 +00:00
Stephen Adams 3384f458e4 [dart2js] Missed file clamped to 2.10
Change-Id: I7eb820d6326572c106633a2632d77e22bcff7ae7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240740
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-08 19:17:39 +00:00
Joshua Litt ca59d05807 [dart2js] Eliminate a use of a tree node in impact data(2).
This CL moves the handling of the runtime type use hint to when we build
impact data.

Change-Id: I2807f05f604103809f8b62da55f43dd89029e7ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239845
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-08 17:41:18 +00:00
Joshua Litt 54c4829fab [dart2js] Eliminate a use of a tree node in impact data(1).
This CL moves the error processing for the ConstConstructorInvocation
logic to when we build impact data, and in doing so allows us to
eliminate one use of a tree node. This should not change any logic.

Change-Id: I69ba69cabedb4d73ec718f552d451647c7f0c51b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239843
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-07 18:53:38 +00:00
Stephen Adams 5c2ca380a4 [dart2js] Tag all sources with @dart = 2.10
Change-Id: Ie9c7548dc81b58db0c1149124db79e4cf1430cc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239723
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-06 21:31:45 +00:00
Nate Biggs 8178fdea40 [dart2js] Add second level of lowering transformation for async -> future.
This handles the case where all 'await' expressions are (direct) children of return statements (i.e. of the form: return await e).

In this case we can drop all the awaits and return the operands directly. We make sure to wrap each operand in Future.value since it might not be already be a future.

We also make sure to wrap any extra returns with Future.value.

Tested on cm_shell with the following results:
Before: Compiled 243,799,156 characters Dart to 155,109,419 characters JavaScript
After: Compiled 243,799,156 characters Dart to 154,742,407 characters JavaScript

Reduced output size by ~0.2%.

Later iterations of this will reduce JS size by ~0.7%.

Change-Id: I43a29d2e843c316c7b61f6daceb8b0e855931eb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239120
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-04-06 20:11:54 +00:00
Joshua Litt f520683b6e [dart2js] Remove WorldImpactVisitor.
Change-Id: I287ac73c8baec05a45f50525bfcf9f77d07d08ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239587
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-06 18:08:24 +00:00
Sigmund Cherem 017e0f7224 [dart2js] Fix nested conditions in global inference
A bug in global inference made the analysis accidentally carry over
the state of a nested condition in a subexpression and conclude
that it was part of the state of the outer condition.

This was due to the fact that we didn't clear the state when
popping out of the context and reentering the conition state.

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

Change-Id: I4e8294bb1a05bb3b910b6aec374357d75acb67cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240321
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-04-06 16:42:34 +00:00
Sigmund Cherem bbf5dc1c59 [dart2js] add regression test for issue 48571
Global type inference incorrectly handles conditions nested within
subexpressions and accidentally carries information from those
in the context of outer conditions.

Change-Id: I99e0af3da65590acb9429771b318b7da8f3b7f14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240320
Reviewed-by: Stephen Adams <sra@google.com>
2022-04-06 16:42:34 +00:00
Mark Zhou 2fa070b3c3 [dart2js] Filling out kernel dump-info for libraries and classes.
Change-Id: Ic74e1d90c50587399b50cbbd6a01ab512a8e42d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239006
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-04-06 00:32:43 +00:00
Johnni Winther fed3bc0125 [_fe_analyzer_shared] Updated id testing to provide regeneration command
In most case, id testing annotations can be regenerated automatical.
This updates the error reporting to include the regeneration commands.

The test system now also runs all tests in case of failures instead of
stopping after the first found failure.

Change-Id: Ice865bddccd8d1da416a1072b3927ed6adfa48fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240048
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-05 20:34:53 +00:00
Nate Biggs 18d758cd5d [dart2js] Fix return value for async/await lowering.
Return Future.sync value from rewritten function.

Broken tests: https://dart-ci.firebaseapp.com/#1af37bd92a9b08ac2d88d26c55feb1dd43382416

Change-Id: I237fa5c52db76026bca1ca24b260c0b14acd94a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240260
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-04-05 16:49:03 +00:00
Joshua Litt 8a7d75b6ee [dart2js] Go directly to WorldImpact from Kernel.
Removes the ResolutionImpact, this should be significantly more
efficient in addition to making it much clearer how `ImpactData`
is actually used.

Change-Id: I8f12508469c784ec480ea351a34cf1477d33cf74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235481
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-05 16:46:43 +00:00
Nate Biggs 8fdd773096 [dart2js] Add async lowering transformation to kernel lowering transformer.
The JS expansion of an async/await function is a complex state machine.
In many cases 'async' functions either do not use 'await' or have very
simple 'await' logic which is easily captured by [Future]. By making this
transformation we avoid substantial over head from the state machine.

This implements the simplest case of a function with no awaits which translates to a Future.value() call.

Tested on cm_shell with the following results:
Before: Compiled 243,799,156 characters Dart to 155,116,598 characters
After: Compiled 243,799,156 characters Dart to 154,781,536 characters

Reduced output size by ~0.2%.

Later iterations of this will reduce JS size by ~0.7%.

Change-Id: I918f820ed2a8b27081dad0de9f922b595113d21f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238461
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-04-04 23:58:02 +00:00
Stephen Adams 11688294e9 [dart2js] Accept --output file command line option
Historically dart2js accepted

    -ofile
    -o file
    --out=file

The following are now also accepted:

    --output=file
    --output file
    --out file

Adding `--output` makes the handling `dart compile js` consistent with
`dart compile exe`, and corrects a discrepancy between the help text
and actual accepted options.

`--output` is the preferred form going forward.

Some messages were fixed to prevent diagnostics having a double
"Error: ".

Bug: 48709
Change-Id: Ie5c6972706a720ced8ee948d384ac63296484d5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239467
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-03-31 17:22:15 +00:00
Stephen Adams e057dddc73 [dart2js] Add missing Copyright lines
Years are the earliest year that can be reliably tracked using
'blame'.

TBR=sigmund@google.com

Change-Id: I1a7e650469a83d79e6eb65be899a5955dc74e1d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239620
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-03-31 16:23:25 +00:00
Joshua Litt 6bab50e1ae [dart2js] Add test to verify component trimming.
Change-Id: Ie9394bdfcda5f71b9126a9288ee108f09f7782fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239367
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-31 01:59:50 +00:00
Joshua Litt 7516ec28b9 [dart2js] Remove CodeLocation.
Per offline discussion, this, and the hints it suppresses, aren't really
useful, so it makes sense to remove them.

This suppression logic today appears to only affect hints and warnings
that come from Dart2js. Today the logic seems to assume that all
non-spannable elements are in user code(i.e. CFE messages). Meaning
today this is only suppressing a very limited set of hints from Dart2js
that should all probably be lints, if they aren't already(Dart2js
doesn't seem to use warn as far as I can tell).

Change-Id: Idc663e48d7dc67c92ed26b007a75f002853ac827
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238924
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-31 01:16:40 +00:00
Joshua Litt b1fbe0c01d [dart2js] Support running modular analysis alongside building a dill.
Change-Id: If10385445c5f6267e2de20b090b37e1741b7ace7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237925
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-30 23:59:00 +00:00
Joshua Litt cfde2d406a [dart2js] Fix bug with trimming component.
Also fully unifies all of our phases in `runSequentialPhases` for
simplicity.

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

Change-Id: I5f0970d9dbd5b1f215063ac161468b2774fb28a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239005
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-03-29 18:41:49 +00:00
Stephen Adams 985220bd5b [js_ast] Migrate template.dart and builder.dart
Change-Id: I049ca6282ca4a5db5a275a824f973ed135f924e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239002
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-29 00:20:20 +00:00
Joshua Litt 0776c6ab59 [dart2js] Inline ImpactBuilderBase into ImpactBuilder.
Change-Id: I1a355d95f41b1b7bd11908e9de76b80ce1b94737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235484
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-28 21:08:30 +00:00
Joshua Litt 838241b024 [dart2js] Move ResolutionEnqueuer to resolution/enqueuer.dart.
This CL is just a code move and contains no logic changes.

Change-Id: Id903f55558ba4f192bf3ae052d65e25f64668f28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233722
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-28 17:28:40 +00:00
Joshua Litt d3c1fee003 [dart2js] Cleanup runInternal.
Change-Id: Ieccd9d1fd06e553a74a0473532d880203af77d72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238880
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-28 17:04:30 +00:00
Stephen Adams 567925e089 [dart2js] Sort URIs for JSON output
Ordering makes it easier to see the differences when regenerating with
`-g`.

Change-Id: I855e29bbbee3c01d7cc2f5c5787c52d9208af707
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239003
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-25 23:59:50 +00:00
Mark Zhou 1e706215d1 [dart2js] Adding experimental flag for emitting treeshaking info
This will eventually be merged with --dump-info

Change-Id: I81884868521abc542bb0268912bfb37e6241cac5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238500
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-03-25 17:21:40 +00:00
Joshua Litt 9f33a4a052 [dart2js] Inline CompilerDiagnosticReporter into its super.
Change-Id: I3b675df3069f2ff7cb74374bcc2ee1caa31e8610
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238800
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-25 16:15:50 +00:00
Mark Zhou ca99bde913 [dart2js] Cleaning up codegen inputs and dart2js_info
Change-Id: I844b43580dbf8738b72e638b24be726e878f8635
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238780
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-03-25 15:22:20 +00:00
Nate Biggs 49c1a91587 [dart2js] Refactor serialization/deserialization implementations (6/6)
Rename DataSource -> DataSourceReader and SourceReader -> DataSource to more accurately reflect these classes' new roles. 'Writer' and 'Reader' are used for the higher level class that composes serialization operations. The 'Sink' and 'Source' handle the low-level conversions to/from the storage format.

Change-Id: I384b5f134beb040676f8e1ef4fba056e0c40358f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238243
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs f0b1143bc6 [dart2js] Refactor serialization/deserialization implementations (5/6)
Copy comments from original interfaces to new DataSink and DataSource and organize methods based on original interface.

Note: If the reorganization makes the diff on this too complicated I can just add the comments and leave in the order it was in.

Change-Id: I959ae19d80ad330ef67334effb8aad8661689937
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238242
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs c4c013b7f7 [dart2js] Refactor serialization/deserialization implementations (4/6)
Move DataSource/DataSink to implement serialization via composition rather than inheritance taking simple interfaces that do low-level writes/reads.

Note: Names and locations of classes will change throughout the next several CLs.

Change-Id: I04807d64a1238b42308ec93e5b5dda6ef2101c00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238241
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs 4f4b4d06b5 [dart2js] Refactor serialization/deserialization implementations (3/6)
Combine AbstractData(Source/Sink) and Data(Source/Sink) into a single class. This simplifies the inheritance hierarchy before switching to a composition structure.

Note: Names of classes will change throughout the next several CLs and comments from the interface get added back in here:
https://dart-review.googlesource.com/c/sdk/+/238242

Change-Id: I50597e04f5b18a1150da4822c4886d12896bed8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238240
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs 20ca69b8b7 [dart2js] Refactor serialization/deserialization implementations (2/6)
Copy mixin logic into AbstractSink/AbstractSource classes since these are the only usages of the mixins.

Note: Names and locations of classes will change throughout the next several CLs.

Change-Id: Ie154741a83c3488a098f3ebf5cf340f19a1a9c52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238220
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs 59c4fc3260 [dart2js] Refactor serialization/deserialization implementations (1/6)
Rename abstract class files in preparation for refactor.

Note: Names and locations of classes will change throughout the next several CLs.

Change-Id: Ibf1e56b9e1e550fd14f6b2b803b6bbbc2d7cae3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238162
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-03-24 18:34:49 +00:00
Joshua Litt b0da308fc5 [dart2js] Always compute impacts directly on kernel.
While this adds an intermediary form for impact computation, it did not
seem to noticeably change the time it takes to compute the closed world
on a large application.

In addition, it will be a necessary change if we want to start moving
some of the validation currently being performed while building
`ResolutionImpact`s modularly.

Change-Id: I76d63a34bbd099103051ead67ec54fd38142929a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235482
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-24 15:11:22 +00:00
Stephen Adams 727a35c588 Add szcmp script for comparing sizes of files
Change-Id: I2017b0f1e746e191f0a5de1f047dec8ba19dd395
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238384
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-23 23:59:21 +00:00
Joshua Litt 0ad7f27990 [dart2js] Apply mixin transform globally.
This cl applies the mixin transform only on the full dill. In addition,
this cl also adds a concatenate dills step to more closely match
modular builds in production.

Change-Id: Icb37c5e2180c9e8246334143a6f772a203f80bf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238320
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-23 18:38:51 +00:00
Mayank Patke 05a6506c92 [dart2js] Clean up unused topLevel member in DartTypeConverter.
Change-Id: I67e38effb7035e0af73cabc923d1e4e529fd9b72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238262
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-03-22 22:29:00 +00:00
Stephen Adams f82c8b4fe6 [dart2js] Use trusted types for URLs of deferred loading scripts
Using a trusted type policy for the script elements injected to load
deferred libraries allows a content security policy to be enabled to
prevent untrusted scripts elements from loading code.

TEST=https://dart-review.googlesource.com/c/sdk/+/237638

Change-Id: Ie3505a68d83cb19c7f8bdbefa01df7fc58d9924a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237542
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-19 20:01:32 +00:00
Joshua Litt c2a63d7cc8 [dart2js] Add a 'modular analysis' phase.
Change-Id: Idda666911a15e1726a15db65eb0cce2733851fdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237633
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-17 19:06:16 +00:00
Stephen Adams e2c9472485 IE11 cleanup - setting function names is unnecessary
Change-Id: Iaf327270bbee48736905b42e7b4290c2eb78e51a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237185
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-15 19:22:03 +00:00
Mayank Patke 1d239794ea [dart2js] Ensure finally sees the inference results of an abortive
`try` block.

Change-Id: Ib5793a9207a7f327780b97ed53530fa89fd9c8f2
Fixes: #48422
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235983
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-03-14 20:49:48 +00:00
Joshua Litt 6f5a99b211 [dart2js] Fix bug with leafless constraint graphs.
Change-Id: If0ddb1e0e3559f8ec05b0303da37adcd72acd336
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236444
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-11 02:35:05 +00:00
Joshua Litt f3092bebd8 [dart2js] Introduce 'load_kernel' phase.
Change-Id: Iefc15122dfd08b514a2f883d856a7b8a005911b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233765
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-09 20:11:44 +00:00
Joshua Litt ce73305411 [dart2js] Cleanup _RtiNode.testState.
Labeling nodes as direct / indirect seems to have been unstable and
unused, so this cl removes that logic. Also removed logic to process
_RtiNode._literalState which ssems to have been unused as well.

Change-Id: Ic463149ee353abcd55c22684f12ba11eb92cc91d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235722
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-08 00:30:23 +00:00
Mark Zhou 6f2291aaf7 [dart2js] Adding additional initialization logic for runtime allocations
Fixes an issue where the allocations object was not always initialized for certain apps

Change-Id: I717bd20c1bef3e4a64d9d4243c4fe3d48178ae2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235441
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-03-06 07:44:21 +00:00
Stephen Adams 6231245e80 [dart2js] Constant-fold indexers of constant Lists and Maps
Change-Id: Id2a15047759d3b1b8230379adff314e9052c922c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235283
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-05 02:14:31 +00:00
Johnni Winther 1f848492b7 [dart2js] Compute the correct selector for InstanceGetterInvocation
The Selector computed for InstanceGetterInvocation used the name of
the getter eventhough the invocation is actually a .call invocation.
This lead the computation of whether type arguments need to be parsed
to fail because it queried with the wrong selector.

Closes https://github.com/dart-lang/sdk/issues/48304

Change-Id: Ia08fb91fa24b5b04eba850f75f9b66cb89494dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234288
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-01 08:55:17 +00:00
Stephen Adams 96a4051dda [dart2js] Remove dynamic calls from ssa/variable_allocator.dart
Change-Id: Ibe7f47eb7a01c09ba29c5e7b311f195570def3bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234140
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-23 21:40:42 +00:00
Stephen Adams b55de5554b [dart2js] Avoid eager initialization optimization for some Maps and Sets
Unfortunately we have to give up on eager initialization of many maps
and sets due to unknown dependencies and effects in the hashCode
implemenation. Eager initialization of some cases could be recovered
as they are eligible to be `const` maps and sets.

Fixed: https://github.com/dart-lang/sdk/issues/48442
Change-Id: I6500123ff9d1fe42bacb53718a4b9e4e969ebc3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233942
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-23 19:17:32 +00:00
Joshua Litt 6e2b3da2e2 [dart2js] Remove StagedWorldImpactBuilder.
This thin wrapper appears to be no longer necessary.

Change-Id: Ice608986e3579dd7c23591a44d7955ac3e92d7df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233720
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-23 18:20:02 +00:00
Joshua Litt 7b4c8496b9 [dart2js] Cleanup some indirection in impacts.
1) Inlines ImpactBuilder into ImpactRegistryMixin + rename
   to ImpactBuilder.
2) Inlines ImpactData into ImpactDataImpl + drop the Impl.

Change-Id: I47322a309708fd6345e4cf4e9a5de505bdbc81c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233685
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-23 17:12:03 +00:00
Stephen Adams 8774f7fd31 [dart2js] Cleanup dynamic call in ValueSet
Change-Id: I0c440b1df288fa39ffb4cc892831520ff47402d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233965
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-23 16:42:14 +00:00
Joshua Litt f3ee8e19ac [dart2js] Eliminate uses of dynamic in behavior.dart.
Change-Id: I81b9e34770953afa0820eec70d817cdf2ab39fde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233963
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-23 03:39:16 +00:00
Joshua Litt 9f8feed92a [dart2js] Inline enqueue creation into compiler.
Also removes a few minor dead methods, and cleans up EnqueueTask which
can now just be a GenericTask.

Change-Id: Ib1614774df740739762f943df0a7bf901f7fdfc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233721
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-23 01:51:04 +00:00
Joshua Litt 49f23164f3 [dart2js] Cleanup comment in options.dart.
Change-Id: I8586aea2901a407cb33d2bd8730cce25f2515842
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233943
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-23 01:18:19 +00:00
Joshua Litt f788ab8c89 [dart2js] Inline Native*Impl into Native*.
This CL inlines NativeBasicDataImpl, NativeDataImpl, and their
respective builder impls into their respective interfaces.

Change-Id: I40c02e0d4cbe1bc66f166db1b998726082be0606
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233725
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-22 23:34:12 +00:00
Joshua Litt 2e14b26976 [dart2js] Remove BackendStrategy.
At this point we only have one backend. Maybe in the future we will have
a second backend, but that will be far enough in the future that it
makes sense to 'rediscover' the value of this pattern.

Change-Id: Ic4f5d3494c48325ea73ea2e64f923a9c532e9c52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233764
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-22 21:13:54 +00:00
Joshua Litt 21b93bcf9f [dart2js] Cleanup some indirection in element_map_impl and friends.
1) KernelElementMapImpl is inlined into KernelElementMap.
2) KernelBehaviorBuilder is inlined into BehaviorBuilder.
3) KernelClassQueries / ClassQueries are removed.
4) NativeMemberResolver is inlined into KernelNativeMemberResolver.
5) NativeClassFinder is inlined into BaseNativeClassFinder.

Change-Id: I04d14a64155de54aafc2abe8579304c018ad9490
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233658
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-22 20:35:32 +00:00
Stephen Adams 194ac46cfa [dart2js] Remove --legacy-javascript customizations
Change-Id: I8469f3d517ef42d897fa2310823e5ac8f3d8aeee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233860
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-22 19:23:22 +00:00
Joshua Litt 934ad4753d [dart2js] Elide a number of interfaces.
Inlined KClosedWorldImpl into KClosedWorld
Inlined ResolutionWorldBuilderImpl into ResolutionWorldBuilder

Change-Id: Id88abac06f7cd279413ae56ea8b021b349009649
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233655
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-19 02:49:52 +00:00
Stephen Adams 07d63eab7e [dart2js] GVN string concatenation
GVN pure stringifiers and string concatenation.

I removed the comment regarding #9293. I could not understand it.
Removing the 'setDependsOnSomething()' does occasionally produce
worse-looking code, but at the application level, the code is
marginally smaller.

https://github.com/dart-lang/sdk/issues/48243 is a more general
description of the 'looks better' problem that pure operations tend to
sink to their use, increasing live-ranges of the operands.  The
sinking is sometimes advantageous - e.g. when the new location is on
an error path.

I see common subexpression elimination often in the pattern of
constructing default strings for Intl.plural:


    Intl.plural(...,
        one: '$first (+$howManyMore language)',
        other: '$first (+$howManyMore languages)',
        ...);

--> old JavaScript

    var
      t1 = A.S(first) + " (+" + howManyMore + " language)",
      t2 = A.S(first) + " (+" + howManyMore + " languages)";
    return A.Intl__plural(..., t1, t2, ...);

--> new JavaScript

    var
      t1 = A.S(first) + " (+" + howManyMore;
    return A.Intl__plural(..., t1 + " language)", t1 + " languages)", ...);

Change-Id: I56aff26c9e5e31954fef224378f3723a05b318ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233641
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-18 23:20:52 +00:00
Stephen Adams b13257e01b [dart2js] Remove ability to choose --legacy-javascript
Change-Id: I48cc93c5778807e6c86168b096ae8ae97ff08b66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232483
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-18 02:24:11 +00:00
Mayank Patke d539c43372 [dart2js] Create child LocalState for inference of labeled statements.
This is analogous to what we do for other control flow constructs.
Without this, a `break` to the label causes the outer scope to also
appear aborted.

Fixes: #48317
Bug: https://github.com/flutter/flutter/issues/96394
Change-Id: I575a5bf96b25b49df6f15d429881e310b3b34d15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233446
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-02-18 00:58:20 +00:00
Joshua Litt fee5309e61 [dart2js] Remove ImpactTransformer.
Removing the indirection now that there is only one ImpactTransformer.

Change-Id: I20644113d4fce046138df4adc4b1f836d81c2523
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232964
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-17 23:11:16 +00:00
Joshua Litt f50a4b4612 [dart2js] Cleanup some TODOs in dart2js' frontend api.
These appear to be no longer necessary.

Change-Id: I8ec8a13394b6e56697de3ccee3a5326b149a137a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-15 17:41:39 +00:00
Joshua Litt 201557fb1d [dart2js] Remove FrontendStrategy.
This CL cleans up some indirection now that we only support
KernelFrontendStrategy.

Change-Id: Iaee8d41e061cc88957cae00d61111cbd8c076d65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232963
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-14 23:44:10 +00:00
Stephen Adams 1314d66d41 [dart2js] Better dead phi removal
Remove dead phis including back-edges and cycles.

Add a postcondition validation for optimization phases.

Add post-phase validation test for dead-phi removal and dead-code elimination.

Bug: https://github.com/dart-lang/sdk/issues/48397

Change-Id: I178cda52dd165e825b9e2d9ae642c22162cee2e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232782
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-14 23:30:30 +00:00
Sigmund Cherem 447e802aaa [web]: remove a couple dynamic calls in the sdk
Change-Id: I59d4697e981417a695a08b21f3b350fa6f84f484
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232962
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-02-14 21:44:20 +00:00
Joshua Litt 1e799e1580 [dart2js] Merge CompilerImpl into Compiler.
This indirection is no longer needed.

Change-Id: Ic917ec758dc8a8a648fea9f74ddf75f47b6b9d4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232485
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-14 20:42:50 +00:00
Stephen Adams 75d4047276 [dart2js] Dead code eliminator should remove dead phis
The bad codegen reported in #48383 was due to an unused phi confusing
the expression-tree construction algorithm. It was trying to generate

    data = cond ? callWithSideEffects() : null;

but `data` is unused, so somehow we generated only

    cond;

We should not have unused phis at this point so I put a safety check
in the above code to not try to build an unused conditional, and
changed the dead-code eliminator to eliminate dead phis.

Now we get

    if (cond)
      callWithSideEffects();

I compared the output for some large apps and there were about a dozen
changes. All looked like improvements, e.g. not assigning to an unused
variable. There was some code missing that is now present, but luckily
for the large apps, it was all code that did not have real-world side
effects.


Fixed: 48383
Change-Id: Id7b32cfa0cbfb47a4d9eff174ad9ae52da99f6a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232781
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-14 20:15:30 +00:00
Joshua Litt 971772bf6d [dart2js] Cleanup a few minor uses of dynamic.
Change-Id: Ic29689ce30f368bfa21bdd2bd13cca038973fba0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232321
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-14 18:33:33 +00:00
Alexander Thomas 30beab0f43 [infra] Add OWNERS to the Dart SDK
* Add team "groups" in tools/OWNERS_<group name>.
* Add top-level OWNERS as a fallback.
* Add OWNERS for all top-level directories.
* Add OWNERS to all packages.

For additional background information see go/dart-sdk-owners.

TEST=No op until code-owners is enabled.
Bug: b/200915407
Change-Id: I7fe6116cc599c749cd50ca16151d6d6a801d99d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229147
Reviewed-by: Jonas Termansen <sortie@google.com>
2022-02-14 14:06:34 +00:00
Joshua Litt da66e1f39a [dart2js] Make info_visitor_test cleanup created test data.
Change-Id: I8f70c5d751b670bde2d2b6f3fcc2c163722edac8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232661
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-11 19:41:26 +00:00
Joshua Litt 95a924d289 [dart2js] Delete ImpactStrategy.
This strategy is no longer necessary with the single frontend, and
inlining all the logic makes the code much easier to follow.

Change-Id: I73995aa6249b52a932dbfb2d459c2d6633a620d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232029
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-11 17:45:07 +00:00
Leaf Petersen 4dbd35f04d Reland "Simplify json parser and eliminate dynamic calls."
This is a reland of e77ea8a17b.  I've
undone the change to the name of the platformScript setter, restoring
the previous behavior of accepting anything and casting.

TEST=Existing tests.

Change-Id: I7e36935ef3784035769527dc5624191f38faaa40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232487
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2022-02-11 16:06:37 +00:00
Joshua Litt 4ce081c99b [dart2js] Remove old compiler interface.
Change-Id: If4f98f4d32a42ce8c2aabd98116997934b13b557
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232001
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-10 16:27:25 +00:00
Alexander Aprelev 4fb3d2afcf Revert "Simplify json parser and eliminate dynamic calls."
This reverts commit e77ea8a17b.

Reason for revert: broke g3 builder, blocking dart->engine rolls

Original change's description:
> Simplify json parser and eliminate dynamic calls.
>
> Tighten types to eliminate some dynamic calls from the core libraries.
> Also remove some unnecessary abstraction from the json parser.
>
> TEST=Existing tests for the library.
> Change-Id: Ieb4cdec5b8c26709b5f70774c392bd373a203113
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231800
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Leaf Petersen <leafp@google.com>

TBR=lrn@google.com,leafp@google.com,alexmarkov@google.com

Change-Id: Iec15058734d07c1966d43c1559a35313f59f8009
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232322
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-02-10 03:16:20 +00:00
Leaf Petersen e77ea8a17b Simplify json parser and eliminate dynamic calls.
Tighten types to eliminate some dynamic calls from the core libraries.
Also remove some unnecessary abstraction from the json parser.

TEST=Existing tests for the library.
Change-Id: Ieb4cdec5b8c26709b5f70774c392bd373a203113
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231800
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2022-02-10 00:07:49 +00:00
Joshua Litt 663d682ab3 [dart2js] Remove pkg/compiler/lib/src/helpers.
Most of these tools have been replaced by better tools.

We may re-add some of these in the future, but if so then maybe they should live in pkg/compiler/tool.

Change-Id: I673dd27dafad59cc01b0be0705c2032c11fca713
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231980
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-09 17:21:46 +00:00
Joshua Litt 21a5f73456 [dart2js] Cleanup ImpactCacheDeleter.
This cl mostly just removes indirection around clearing the Impact cache.
However, there is one minor logic change, today we clear the impact cache
before calling DeferredLoadTask._buildResult, but after this cl the
impact cache is cleared by its owner(Compiler) in the compiler pipeline
itself.

Change-Id: I5845b786887f861c61a0ac79a3c8f2de2a3a2a14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232026
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-09 02:28:41 +00:00
Joshua Litt ef02841083 [dart2js] Cleanup NativeEnqueuer.
This cl removes an unnecessary concrete interface, and makes the
existing base class abstract.

Change-Id: I41891a7b3c57008de05a7c4a20a70452983ab441
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232125
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-09 01:01:37 +00:00
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Parker Lougheed e31691b47f Update outdated old or removed dart.dev links
Removes reference to web portion of site-www as it is minimal and not standalone anymore.

Change-Id: I62e92d0dd90afffa5d90c3f3fd4e903251c5672b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229280
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2022-02-08 19:29:56 +00:00
Joshua Litt 6a7470f530 [dart2js] Remove unused compile_time_constants.dart.
Change-Id: I4a574ac615aabaf63d7bf3e241fc969766f03cf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232030
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-08 04:10:56 +00:00
Joshua Litt ef4411b2ed [dart2js] Remove some dead code.
Change-Id: Ib7dd4a08dae59ab0dc6b168c4252d7e815e5244b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231537
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-07 18:48:36 +00:00
Joshua Litt 85aed03894 [dart2js] Simplify NoSuchMethod* classes.
Change-Id: If41acd2a3835ef4d3db0999fb7b9340c64c98f13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231383
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-07 17:20:35 +00:00
Stephen Adams 3a8be9394d [dart2js] Share more CallStructures
Change-Id: I90a2fe027a61a7bb4235b54ab90c14a5f9049192
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177020
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-05 03:08:23 +00:00
Stephen Adams 5d02bc0a0a [dart2js] Handle x as E specially when x has type E?
This is implemented in dart2js rather than using a Kernel transform
because dart2js has additional context about the 'as dynamic' trick.

Change-Id: I4f7abe6bb95cff8209a683406cfaf2d82b3245ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231745
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-02-05 02:17:49 +00:00
Joshua Litt efe573401d [dart2js] Merge CommonElementsImpl into CommonElements.
Change-Id: I35fae9cd7e97f3782b8c091b7524a10388d57aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231531
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-04 02:36:06 +00:00
Joshua Litt 58e577da15 [dart2js] Move common_elements.dart to common/elements.dart.
Change-Id: Idaed02bb747670413f63e7f7b0797eb591e12f57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231523
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-03 21:21:39 +00:00
Joshua Litt 848e106346 [Dart2js] Remove unnecessary abstract interface on Enqueuer.
Change-Id: Ia9c2e329fb83eeb77f399c43ae5725ccb9b602c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231381
Auto-Submit: Joshua Litt <joshualitt@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-02-03 18:55:47 +00:00
Joshua Litt 6a4cb1a3a7 [dart2js] Move native_basic_data.dart into its own library.
Change-Id: I2aa257cb6b53d7e3cbf32efdfd0605df6fe4021e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231382
Auto-Submit: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-02-03 17:58:06 +00:00
Mayank Patke 99d49dca95 [dart2js] Remove dependency on package:expect in RTI-need emission
tests.

Change-Id: I8be03f22c3b7195a2d10050c622415379c8b7563
Bug: #48087
Fixes: #48087
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230883
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-02-01 23:42:25 +00:00
Mayank Patke 0163ef0d3b [dart2js] Remove dependency on package:expect in RTI-need unit tests.
Bug: #48087
Change-Id: I9729abea021945c66671f74805c4878aa04ade2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227903
Reviewed-by: Stephen Adams <sra@google.com>
2022-02-01 23:42:25 +00:00
Joshua Litt 69bc43a531 [dart2js] Statically type unnecessary dynamic type.
Change-Id: Ib188257cb2d218beaabc66851f12fa18850c0969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230824
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-02-01 01:52:24 +00:00
Stephen Adams 5a291a28e7 [dart2js] Avoid using 'at' as a minified instance method name.
This CL fixes one part of #48118 by no longer accidentally calling
String.prototype.at.

- Update the list of names that should not be used for minified instance
  method names.
- Expand comment.
- Add a script in tools for finding all the names from within a browser.



Bug: 48118
Change-Id: Iac41bd707d7b447a998d0d94a8b37576dc7d1493
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228300
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-29 01:03:52 +00:00
Joshua Litt 5bf2e76329 [dart2js] Cleanup dead code.
Change-Id: I640dc4da677ab3ba4644985aa790625aae36283a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230827
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-01-28 23:51:19 +00:00
Stephen Adams b4f0b58cb2 [dart2js] HStringify can generally throw but some uses are pure.
This is something I noticed when 'gardening': HStringify can throw but
the node was using the default 'canThrow' which returns 'false'. This
has the potential for bad codegen, though I am not aware of an instance
of it happening.

This CL makes the default for `HStringify.canThrow` be `true`.

Stringification for primitive types is pure, so this is added as an
optimization. There are a few improvements from this, including removing
an unused stringification.


Change-Id: I9285d91ec906fb544f8793944578b7e3feb8a634
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230221
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-28 23:31:32 +00:00
Joshua Litt f6ebe80d26 [dart2js] Refactor program split constraint's Fuse node.
This cl makes Fuse an unnamed ordering node, and allows ors / ands
within the fuse. For examples of the benefits of this new Fuse, please
see:
pkg/compiler/test/custom_split/data/fuse_with_and/main.dart
and
pkg/compiler/test/custom_split/data/fuse_with_or/main.dart

Change-Id: I5076abcd617d138b03dc8944737c61645e42e038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228685
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-01-26 18:03:58 +00:00
Sigmund Cherem 6bcba2529d [dart2js] minor tweaks to dart2js help message.
These changes make the help message more aligned with other
dart command line tools.

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

Change-Id: Id012400dc9b441b796c7437858e8ea4f29b57a90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229340
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-01-21 21:05:00 +00:00
Sigmund Cherem 8415b70e75 [dart2js] recommend using 'dart compile js'.
This is the first deprecation step, moving towards having dart2js
under the more general dart command line interface.

Going forward 'dart compile js' is the recommended way to invoke
dart2js.

This CL adds:
* an internal flag used to detect how was dart2js invoked and
  provide a warning when invoked in an unsupported way.
* ensures the flag is provided in the dart cli, as well as our
  (developer's only) scripts. These scripts will likely move to a
  different location in the future. Note that the `dart2js_sdk*`
  scripts are not providing this flag (these are the script that get
  eventually shipped with our built SDK), as such, invokations of the
  dart2js binary will show the new warning.

Change-Id: I96e40ecf01598eadab20dfc59114f5fff7438084
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229062
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-01-21 16:42:40 +00:00
Srujan Gaddam d17205184a [dart2js] Handle Object members of dart:html types
`dart:html` types have changed to inherit `JavaScriptObject`. Therefore,
the dart2js runtime needs to be changed so that interceptors are still
created for those types, and they're properly handled in `toString`
calculations. Includes tests on `Object` members that are currently
inconsistent between both compilers.

This test passes on dart2js with and without making the types in `dart:html`
extend `JavaScriptObject`. This test fails in DDC for the following reasons:

- `toString` of native types calls the native `toString`
- `hashCode` for interop objects are random and not 0
- `runtimeType` of interop objects is `LegacyJavaScriptObject` not `JSObject`

Change-Id: Ibf80109174615120df9e64995fa13016f7a1677b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228741
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-01-21 01:04:10 +00:00
Mark Zhou 74b57a69bd [dart2js] Extending experimental allocations collection to code fragments.
Required for upcoming runtime code usage tools.

Change-Id: Ie8417d03c9e60f3f97f536eb6e96ea56b7f0a817
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229260
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-01-20 21:37:27 +00:00
Johnni Winther 9b7be8d117 [cfe] Call MacroExecutor for phase 3 macros
This CL adds capability for calling MacroExecutor to apply phase 3
macros to function declarations.

Change-Id: I1ab5bf33c8d9c6ce0c6706fe2bcafe2298ff292b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227720
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-01-17 16:24:55 +00:00
Sigmund Cherem ba23762d2a dart2js: add missing check before reading argument list.
This causes a crash when invoking dart2js.dart with no arguments.

This is however minor, turns out that all environments invoking
dart2js always include an argument (and by default our snapshots
include the parameter to find the platform.dill file, for example).

Change-Id: I1c830768427f0c95e94100d092df445fee4224b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228262
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-01-14 20:56:13 +00:00
Johnni Winther 8510f27d37 [cfe] Change encoding of supported dart: libraries
This CL changes the way dart: libraries are considered supported when
used in conditional imports or bool.fromEnvironment constant using
the "dart.library.*" values.

Library nodes now has an isUnsupported flag which is set according to
the "supported" property in the libraries specification. Furthermore
the Target now supplies a DartLibrarySupport interface that allows
targets to override whether dart: libraries are unsupported.

This allows the JIT/AOT to use the same platform file but still
consider dart:mirrors unsupported in AOT mode, and dart2js to consider
the internal library `dart:_dart2js_runtime_metrics` supported.

Furthermore, the internal handling is changed so that condition imports
and bool.fromEnvironments constants are computed through the same logic
for "dart.library.*" values, avoiding the need for passing these values
through the environment.

TEST=pkg/front_end/testcases/general/supported_libraries/main

Closes https://github.com/dart-lang/sdk/issues/48057
Closes https://github.com/dart-lang/sdk/issues/47814
Closes https://github.com/dart-lang/sdk/issues/47243
Closes https://github.com/dart-lang/sdk/issues/32657
Closes https://github.com/dart-lang/sdk/issues/36460

Change-Id: Ie8f8dff99167de64ced51b71d89918bf0f3bbd13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227020
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-01-11 14:52:38 +00:00
Stephen Adams 44ba8ecdb2 [js_runtime] Remove unused ES6 Map _LinkedHashMap implementation
If we were to use ES6 Maps, we should try to use a single one for
all 'identity' keys (numbers, strings, enums etc).

Change-Id: Idc600b7cb48b58a074fd4c9bb6205d544f86dbc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226540
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-06 19:57:31 +00:00
Stephen Adams 8bdd732e08 [dart2js] Add --utf8 canary option
Change-Id: I98078be0fe07b1037d0bb70986be8769e170708a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225520
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-06 05:24:25 +00:00
Stephen Adams 91b69ef7b7 [js_ast] Split VariableInitialization from Assignment
Change-Id: Iefe989e824fcd504391f607135486025e170313e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225425
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-05 17:50:04 +00:00
Johnni Winther 4e283a7e08 [_fe_analyzer_shared] Support 'include' tag in libraries specification
This adds support for an 'include' tag in libraries specifications
that enable composite declarations. With this, we can avoid relying on
copied portions of (other) specifications.

Closes https://github.com/dart-lang/sdk/issues/47998

Change-Id: I694d5c006741e6625feb7cdd5898946cc6caee50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224952
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-01-05 08:13:23 +00:00
Stephen Adams b053f2c355 [dart2js] Use reporter.withCurrentElement in createClosureEntities
This should help investigation of #47916.

Change-Id: I1db9d97e963593ab7f8778c8470328419633155d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226220
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-05 00:41:04 +00:00
Stephen Adams 770969e25c [js_ast] Prepare visitors for null-safety
`BaseVisitor<R>` has two methods that return `null`, which will not
match the generic return type with NNBD.

The fix is to make the methods abstract, and provide a convenience
specialization `BaseVisitorVoid` with the default methods.

Change-Id: I62cd69c5ed1c912b2804da5044e2cda93d70b878
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224460
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-12-17 01:16:49 +00:00
Joshua Litt 59979dc973 [dart2js] Cleanup old holders code.
Change-Id: I5eafeb06cf2d6e32e9fdd1abee19ea18e1091ace
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221991
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2021-12-15 16:53:36 +00:00
Joshua Litt 47646ff6c7 [dart2js] Avoid trimming entryLibrary from components.
Change-Id: I28d1c36279ed7407bb6a82d100bf062d327bc7d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223220
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2021-12-14 17:50:34 +00:00