Commit Graph

123 Commits

Author SHA1 Message Date
Mayank Patke 2bb32ec55a [dart2js] Update pubspec to 3.8 and reformat.
Change-Id: Ib1afd38a7d3694c2e5ed591132f41b147f76d75a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427560
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-05-09 10:34:12 -07:00
Mayank Patke 722929d268 [dart2js] Clean up wrapper powerset implementation.
This was a very useful experiment to validate that a powerset domain
could answer certain abstract value domain queries more efficiently. Now
that the core ideas have been incorporated directly into the typemasks,
we no longer need to preserve the wrappers.

Change-Id: Ife3df6eeb119783da97eeb721d9c045e5da649ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427020
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2025-05-07 19:18:38 -07:00
Mayank Patke 553ac951b3 [dart2js] Add indexable bits to powerset.
Change-Id: I5d4c0b4d15a05cfc30d87003785ca841c46b1a0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426583
Reviewed-by: Stephen Adams <sra@google.com>
2025-05-07 19:18:38 -07:00
Mayank Patke b941f6f0f4 [dart2js] Add modifiable/growable bits to powerset.
Change-Id: Ic8abbe3729a4c3b41fde0a37d8b6afe84bd9ba48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407920
Reviewed-by: Stephen Adams <sra@google.com>
2025-05-07 19:18:38 -07:00
Mayank Patke 7103d43876 [dart2js] Add powerset bits for interceptor domain.
Change-Id: Id9509c6b6eb8143263763e508512c0703d4aa493
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404500
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-04-16 18:14:21 -07:00
Mayank Patke 1bbbf26434 [dart2js] Refactor FlatTypeMask cache.
As the powerset grows, the cache needs to be keyed on both the base and
the full flags. While we're at it, we ensure that all FlatTypeMask
allocations go via the cache.

Change-Id: Ifdd400bf4ea23a936c4d37be91a5d527102aa3b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413700
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-03-07 04:20:04 -08:00
Mayank Patke d0e09ea091 [dart2js] Print powerset value in typemask toString methods.
We may find it useful later to add a more verbose stringification that
writes out the properties expressed by the powerset. For now, just
printing the int value is sufficient to debug e.g. test failures, and
it's relatively straightforward to manually convert an int to a set of
properties by looking at the definitions of the powerset domains.

Change-Id: I2397ffd83a6e86830f67c7f1ef811e33c0b7ff3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405567
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-07 04:20:04 -08:00
Mayank Patke 389ac928b9 [dart2js] Refactor typemasks to support additional powerset bits.
Change-Id: Ifffed9455272d6cedea55125e2af74b594fe310c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404381
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-07 04:20:04 -08:00
Mayank Patke f00dbb5856 [dart2js] Reformat pkg/compiler.
Change-Id: I9e379d1f0673b589139a2389c6d3602c36995cd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413720
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-07 04:20:04 -08:00
Mayank Patke 6acaf9b8f4 [dart2js] Account for late sentinels in trivial inference results.
Fixes: #49599
Fixes: #55058
Fixes: #60115
Change-Id: I66673b6e467b54428e8d5ba317eec8aa3248645f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258961
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-02-18 16:50:18 -08:00
Nate Biggs e038d8ac81 [dart2js] Add implicit null to type for optional non-nullable parameters.
This ensures any code downstream of this knows that it can receive a null and null checks are not removed during SSA.

Change-Id: I8c3d706875a9b70ed8407d00053fb381df168a49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406480
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-01-30 15:51:02 -08:00
Mayank Patke c878108cc8 [dart2js] Update pubspec to Dart 3.7 and reformat.
All non-pubspec changes generated by `dart format pkg/compiler`.

Change-Id: Iadaa70974816d96ccb47813fe72d5a2bb83d6bda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400181
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-12-13 11:24:50 -08:00
Mayank Patke a001a5e1f1 [dart2js] Enable recommended lints.
Change-Id: I71d30bdf8332ad5200faed8b084ef8888bb98ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400163
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-12-13 11:24:50 -08:00
Mayank Patke 017bda44cf [dart2js] Enable core lints.
Change-Id: Id5a14797e3e5eb8b68bd009d65b474748902fbe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400162
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-12-13 11:24:50 -08:00
Mayank Patke 49076fe6f4 [dart2js] Minor fixes before bumping to 3.7
Most of the fixes are to stop using `_` as an identifier now that it's a
wildcard.

Change-Id: I4287d12f4e664b974ad07063e21d04b2d0a61f29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400182
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-12-13 11:24:50 -08:00
Stephen Adams 0c527e1b9f [dart2js] Separate Iterables for Map.{keys,values,entries}
The default `MapBase.entries` and `MapBase.values` maps over the keys and does lookups. It is faster to scan the data like `get keys`.

This is essentially the dart2js version of https://github.com/dart-lang/sdk/commit/23a98d808c0

Change-Id: I03894efda459d9a4f7f07c4c79524ba5e4d925cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399027
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-12-10 04:36:59 +00:00
Mayank Patke 88eb64d222 [dart2js] Use enumset API for typemask bits.
Change-Id: I8f513d92d05290dceb53edc5f99a6d84a11a5571
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399121
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-12-10 00:39:52 +00:00
Lasse R.H. Nielsen f8086c81ae Collect all test-related files in package:expect.
Collects files from `package:async_helper` and `tests/language`
that are generally useful, so that all test-related helpers are
in `package:expect`.

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

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

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

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

Change-Id: I1b665135b5fef9b9a0c3b340ffe9daf874d0174c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373120
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-10-11 16:53:52 +00:00
Mayank Patke 37345b9f7e [dart2js] Enable strict-inference and strict-raw-types in pkg/compiler.
Change-Id: I4712d32dc37a8cbfa0e1e5bd61659df651c77471
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354140
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-02-26 22:41:58 +00:00
Mayank Patke 69df740ea9 [dart2js] Assorted TODO cleanup, bump pubspecs to 3.3.0
Change-Id: I621ac252c5d6f3b157a2f194b7f0b7ad85874e4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352990
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-02-21 00:02:13 +00:00
Nate Biggs a9fc1efe05 [dart2js] Clean up more code associated with Dart2JS static types.
The `ClassRelation` concept is no longer needed as we are only using the CFE static type. All creations of "exact" and "this" types were already removed in an earlier CL so we are already always following the 'subtype' path.

Change-Id: Iccc3d61737c5b64b3b4217f7f20b34b181cc7db2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348463
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-02-07 00:19:33 +00:00
Nate Biggs 63f766b64e [dart2js] Narrow type of map entries in global inference based on static type.
This helps avoid some regressions from doing less static inference and depending more on the CFE static types.

Change-Id: Id95596fab87ecc9ea0c2baf3a8c21f9c90b90f94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348221
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-02-07 00:19:33 +00:00
Mayank Patke f79ed9301b [dart2js] Remove remaining language version overrides
Now that dart2js only takes migrated files as input, all tests should
use the current language version.

Change-Id: I6c84850f5786aeac04154b67bd7a3c19083c8bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345344
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-01-23 01:26:09 +00:00
Lasse R.H. Nielsen 5543293a16 Reland "Expire 3.0.0 experiment flags."
This is a reland of commit 6f29e7fce4

Original change's description:
> Expire 3.0.0 experiment flags.
>
> TEST=Existing tests covers.
> Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

TEST=Existing tests covers.
Change-Id: I384e77744c74774a250be413358a7fa176117167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332684
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-11-17 13:10:01 +00:00
Nate Biggs 9eba05482b [dart2js] Fix list tracing treating first/last setters as type preserving.
I suspect that when the list of type preserving selectors was created the first/last setters either didn't exist or were just overlooked. Any dynamic List could have its inferred type changed by these operations.

Due to Dart2js's type representation this bug affects more than just dynamic lists. We track some simple values as part of the type system. So an operation that modifies a value can technically modify the type, as Dart2js represents it, even if the "real" type is preserved.

In the added test we would represent the list literal's type as "List(length: 2, elementType: Bool(true))". Notice the type states the elementType is specifically true, not just bool. Thus the first/last operations are modifying that type. But since we aren't registering this type change, SSA optimizes away the call/index and inlines the element itself.

Interestingly, this primarily manifested for bools due to a check in SSA:
https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/src/ssa/optimize.dart#L475

In that code we are inlining constant-like expressions for the arguments of static invocations (such as the argument to a Expect.isTrue call). However, a few lines earlier you will see we only inline bool constants:
https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/src/ssa/optimize.dart#L467

So when the list element type is anything other than a bool, this inlining does not trigger thus avoiding the bug.

Bug: https://github.com/dart-lang/sdk/issues/53944
Change-Id: I4e893903f335fc99b13cf526736c27bb066a4bad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334420
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-11-08 03:50:21 +00:00
Alexander Aprelev 6a464c9dee Revert "Expire 3.0.0 experiment flags."
This reverts commit 6f29e7fce4.

Reason for revert: broke g3 bot

Original change's description:
> Expire 3.0.0 experiment flags.
>
> TEST=Existing tests covers.
> Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

Change-Id: Ied6f612dc922824ffdadc4660898f3b859922ff5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332582
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Auto-Submit: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-10-27 16:50:09 +00:00
Lasse R.H. Nielsen 6f29e7fce4 Expire 3.0.0 experiment flags.
TEST=Existing tests covers.
Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-27 13:57:00 +00:00
Mayank Patke ac59672086 Reland "[dart2js] Improve computed type of AwaitTypeInformation."
This is a reland of commit b3e2090a77

Original change's description:
> [dart2js] Improve computed type of AwaitTypeInformation.
>
> Change-Id: I7d57bda09a620d1bd8b9ae89d4efd02575f1a4e7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322368
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Mayank Patke <fishythefish@google.com>

Change-Id: I1fdb22bc435a713f43cc7c891b7908f6ed6e8405
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323080
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2023-08-29 00:09:29 +00:00
Mayank Patke 7c7cb1cdcd Revert "[dart2js] Improve computed type of AwaitTypeInformation."
This reverts commit b3e2090a77.

Reason for revert: http://b/297494642

Original change's description:
> [dart2js] Improve computed type of AwaitTypeInformation.
>
> Change-Id: I7d57bda09a620d1bd8b9ae89d4efd02575f1a4e7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322368
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Mayank Patke <fishythefish@google.com>

Change-Id: I44940fb255e86154ce688379f6d2e3c7286df78a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322783
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2023-08-25 19:32:01 +00:00
Mayank Patke b3e2090a77 [dart2js] Improve computed type of AwaitTypeInformation.
Change-Id: I7d57bda09a620d1bd8b9ae89d4efd02575f1a4e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322368
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2023-08-24 00:43:38 +00:00
Mayank Patke ed0ac21194 [dart2js] Add inference unit tests for await e without a local.
Change-Id: I2465a0b8f29d2158f684099f8500153515421c8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322367
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-08-24 00:43:38 +00:00
Nate Biggs a8e7db5deb [dart2js] Consolidate type narrowing logic.
Currently _narrowType for TypeInformation nodes has logic to process DartTypes. This logic is a simplified version of the logic in createFromStaticType. We can consolidate the two and just use createFromStaticType directly.

And since the static type is only ever used for this type narrowing (and its immutable) we can create the AbstractValue up front and store that instead of the DartType.

There was no difference in the emitted JS when tested on 2 large programs.

Change-Id: I432279684580edf64ff52254653bd26501d461b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304160
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-05-22 18:38:23 +00:00
Nicholas Shahan f2aa312e17 [ddc] Implement new record types
Update the format of the shape keys to better match the format used in
the dart:_rti library. This change applies to the current runtime type 
system as well.

Change-Id: I87d2af2aaf2b9dbe012fae60a64718d264a3a18c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295721
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-05-12 17:23:07 +00:00
Nate Biggs b9c73fdf23 [dart2js] Update switch block local handling to correctly propagate types that fall through the block.
Fixes #52170

Change-Id: I7c473c3101d446eb17433d583bfe266bf6f193d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298760
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-04-27 19:35:45 +00:00
Nate Biggs a6f543e50a [dart2js] Repro for issue 52170.
Type inference is not tracking the type of 'local' correctly through the switch statement into the inner return. The same code without the for loop does work correctly though.

Change-Id: I0b1b4741e4ff17c22dec3383defb412f5fff0836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298980
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-04-27 18:15:48 +00:00
Stephen Adams 45efccb5e0 Remove left-over patch declarations for List constructor.
This CL replaces https://dart-review.googlesource.com/c/sdk/+/296900

The `List` constructor is removed in Dart 3.0.
Some of the `@patch` implementations were not removed.

This is *high priority*. It seems the left-over `@patch factory List` constructor did not cause any errors, instead it *added* a constructor  to `List` that can be used in web compiled code. Even if `List` doesn't have such a constructor in the SDK code proper.
The VM and analyzer will say the invocation is an error, but dart2js happily compiles it and runs.

(It used to be that patches couldn't add public members, that security seems to have been removed.)

Also removes code which tries to detect "the unnamed List constructor",
which is no longer a thing, and a number of invocations of the constructor, where it's not clear that the test is aware that the constructor no longer exists, and is not marked as `@dart=2.x` with x < 12.

TEST=ci

Change-Id: I4ffaf3ae2c4e75ca06e7ba0bf19187b6376f3888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297100
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-22 00:38:28 +00:00
Nate Biggs 7714e67efe [dart2js] Merge experimental inferrer into main inferrer branch.
Inference runtime metrics on a large program:
-----Before-----
Duration - Mean: 182.303 Median: 174.500 Max: 292.0
Memory - Mean: 5857.426 Median: 5752.639 Max: 6167.91

-----After-----
Duration - Mean: 144.525 Median: 133.500 Max: 242.0
Memory - Mean: 5867.756 Median: 5727.506 Max: 6262.414

This shows ~20% improvement in runtime and virtually no change in memory usage. Previously we saw a memory regression due to this change. But thanks to improvements in the representation of TypeInformation nodes that memory regression no longer exists.

Code size for this program is also very similar before and after this change.

Before: 43258484 bytes JS
After: 43258444 bytes JS
Change-Id: I6512637f16d83f3127fd1c060bb770ae56405b88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295460
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-04-18 22:15:49 +00:00
Nate Biggs 8b01742d60 [dart2js] Fix linearization issues.
- For parameters of closurized members make sure to mark the virtual parameter as closurized where appropriate. Closurized parameters are treated as dynamic and this needs to propagate to all the virtual target's overrides. Previously only the concrete target was getting marked as closurized.

- For mixins defining an abstract member, foo, implementations of foo (either directly on the mixin target or superclasses of it) should propagate their types to the abstract foo as they are effectively overriding it. Calls to foo within the body of the mixin can only target the abstract foo with a virtual call. So that virtual target needs to reflect the types of all its overrides.

Tests have been added that capture both of these cases. The values here reflect the non-linearized algorithm but prior to these fixes the linearized algorithms showed a diff for both tests. After these changes there is no diff.

This fixes all failures referenced in b/277876666.

Change-Id: Icaca99cb6902c54f481eebdbb65cbd7cf81aa2c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294960
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-04-15 02:05:49 +00:00
Emmanuel Pellereau 55ec45493f Revert "[dart2js] Patch experimental inferrer (with linearized algorithm) into main inferrer."
This reverts commit 9aa00f6c75.

Reason for revert: breaks google3 (b/277876666)

Original change's description:
> [dart2js] Patch experimental inferrer (with linearized algorithm) into main inferrer.
>
> After this change for a large program we see:
> - 20% reduction in runtime (254s -> 202s)
> - 2% decrease in memory usage (7671.029MB -> 7524.901MB)
> - Code size decrease of <1% (214,788,150 bytes -> 214,757,445 bytes).
> - The k-limit of 6 refines imposed on the global inference algorithm is no longer hit for converging types. All but 15 types converge, down from 777 types that were hitting the k-limit before. This means we are likely generating better types/code for all 762 of those types.
> - More resilience to dynamic calls with lots of potential targets.
>
> Change-Id: I53d4ade51559f3366f076b6f2b485c5bdc50c6e8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271480
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Nate Biggs <natebiggs@google.com>

Change-Id: Ia6e038e8e077813e589a54d2242bd2820bd22036
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294741
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-04-12 12:41:36 +00:00
Nate Biggs 9aa00f6c75 [dart2js] Patch experimental inferrer (with linearized algorithm) into main inferrer.
After this change for a large program we see:
- 20% reduction in runtime (254s -> 202s)
- 2% decrease in memory usage (7671.029MB -> 7524.901MB)
- Code size decrease of <1% (214,788,150 bytes -> 214,757,445 bytes).
- The k-limit of 6 refines imposed on the global inference algorithm is no longer hit for converging types. All but 15 types converge, down from 777 types that were hitting the k-limit before. This means we are likely generating better types/code for all 762 of those types.
- More resilience to dynamic calls with lots of potential targets.

Change-Id: I53d4ade51559f3366f076b6f2b485c5bdc50c6e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271480
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-04-11 16:37:26 +00:00
Nate Biggs 7ceea1ec11 [dart2js] Add tracing of types through records in global inference.
Change-Id: I4abdb76caecc91c89792396ff7d3fe4060cc7bc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289904
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-04-04 02:11:01 +00:00
Stephen Adams 482b4e485c [js_runtime] Use marker interface to signal trusted .runtimeType overrides
Use the `TrustedGetRuntimeType` interface to mark implementation
classes that have a `get runtimeType` that should be used for
reporting the types of instances in errors and `Record.runtimeType`.

Streamline the various more general `get runtimeType` implementations
by specializing them to the context. By explictly implementing
`Closure.runtimeType` we avoid the need to test for closures in the
'ordinary' object path. This should help the Flutter pattern of
testing `a.runtimeType == b.runtimeType`.

Change-Id: Ib49a6d89ff23e752beed8753aafceff40457433d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291741
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-03-31 04:05:08 +00:00
Lasse R.H. Nielsen 9e76983782 Reland "Add more interface and final modifiers to dart:core."
This is another reland of 4f8333e80e.
Third time is the charm.

CoreLibraryReviewExempt: Reland of accepted CL.
Change-Id: I4ea8326af91c168b044d252162571d3fe697e4b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289826
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-03-30 20:34:09 +00:00
Nate Biggs 3bc19d459b [dart2js] Fix unevaluated const evaluations for record literals.
Change-Id: I72430e012b5053e37894ac64e9e1d642c478abdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290981
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-03-23 22:56:15 +00:00
Nate Biggs 32c5b81f9c [dart2js] Add unit tests for records.
The expectations set here are updated as fixes/improvements are made in the next 2 CLs.

Change-Id: I0ac251ce09b980cde9e01afc1fa81b987a619747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290980
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-23 22:56:15 +00:00
Nate Biggs 71a6e8be8f [dart2js] Add unit tests for RecordTypeMask operations.
Change-Id: I03d988ffda39fa2416f429f464cb23aedbd1f44f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289083
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-17 22:50:44 +00:00
Nate Biggs a2719b5552 [dart2js] Make use of new RecordTypeMask for creation of record literals/constants as well as record field accesses.
All calls on records are no longer treated as essentially dynamic calls.  So a call to `record.foo` will not pull all `foo` members into the program (including unused ones). For example in the below test the getter `any` was causing `JSArray.any` to be included in the program. After this change it is no longer pulled in.
https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Records/members_A04_t02.dart#L39

Change-Id: If1f9eac1abadeeed80dca917a8912129d090643e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287681
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-17 22:50:44 +00:00
Ilya Yanok 936cdeeb2f Revert "Reland "Add more interface and final modifiers to dart:core.""
This reverts commit e293eb809d.

Reason for revert: Breaks G3.

Original change's description:
> Reland "Add more `interface` and `final` modifiers to `dart:core`."
>
> This is a reland of commit 4f8333e80e
>
> Blocked on Flutter patch: https://github.com/flutter/engine/pull/40175
>
> Original change's description:
> > Add more `interface` and `final` modifiers to `dart:core`.
> >
> > Make intent explicit for classes which are intended as interfaces,
> > or which are not intended to be subclassed.
> >
> > Mainly classes which are pure interfaces are marked as such,
> > and platform-specific classes not intended for subclassing
> > are made `final`.
> >
> > The `final` classes includes `BigInt`, which is written to assume
> > that arguments inherit its private members
> > (it runs `_ensureSystemBigInt` on arguments).
> >
> > It also includes the `Expando`, `WeakReference` and `Finalizer` classes,
> > which are just intended as stand-alone implementation classes for accessing
> > platform-specific functionality.
> >
> > Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Commit-Queue: Lasse Nielsen <lrn@google.com>
> > Reviewed-by: Aske Simon Christensen <askesc@google.com>
> > Reviewed-by: Nate Bosch <nbosch@google.com>
> > Reviewed-by: Martin Kustermann <kustermann@google.com>
>
> CoreLibraryReviewExempt: Accepted in original CL.
> Change-Id: Id713edede4228801bb097a64734be4f2187f51a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288206
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I05ff2fe44e5a13f20725eb122963d20243062c7a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288503
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-03-13 16:08:31 +00:00
Lasse R.H. Nielsen e293eb809d Reland "Add more interface and final modifiers to dart:core."
This is a reland of commit 4f8333e80e

Blocked on Flutter patch: https://github.com/flutter/engine/pull/40175

Original change's description:
> Add more `interface` and `final` modifiers to `dart:core`.
>
> Make intent explicit for classes which are intended as interfaces,
> or which are not intended to be subclassed.
>
> Mainly classes which are pure interfaces are marked as such,
> and platform-specific classes not intended for subclassing
> are made `final`.
>
> The `final` classes includes `BigInt`, which is written to assume
> that arguments inherit its private members
> (it runs `_ensureSystemBigInt` on arguments).
>
> It also includes the `Expando`, `WeakReference` and `Finalizer` classes,
> which are just intended as stand-alone implementation classes for accessing
> platform-specific functionality.
>
> Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180
> Reviewed-by: Stephen Adams <sra@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

CoreLibraryReviewExempt: Accepted in original CL.
Change-Id: Id713edede4228801bb097a64734be4f2187f51a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288206
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-13 15:21:30 +00:00
Nate Biggs 9ba4957a31 [dart2js] Add record getters as reachable targets from dynamic call infrastructure.
Change-Id: I78387dffa4a7a16f20e630300bd90b08591efe6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287480
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-03-09 21:26:52 +00:00