Commit Graph

6306 Commits

Author SHA1 Message Date
Stephen Adams 23ba783c4c [dart2js] Use null-aware elements
Change-Id: I2dc74c57efd355ab4871eb2ad48a97fc817a2940
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433300
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-06-06 12:45:17 -07:00
Ivan Inozemtsev 3f2befef35 Revert "[dart2js] Do some load elimination in simplifier"
This reverts commit ff583f2e2e.

Reason for revert: b/422944368

Original change's description:
> [dart2js] Do some load elimination in simplifier
>
> Doing load elimination of final fields earlier generates more
> opportunities for GVN.  This helps when the same value is 'boxed' in a
> wrapper object and the 'unboxed' multiple times.
>
> Change-Id: Id3a2b392a7563bae7a4cd1f8b2763c5ac1b377b5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432502
> Commit-Queue: Stephen Adams <sra@google.com>
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Nate Biggs <natebiggs@google.com>

Change-Id: I97f06e46b193394df6393296d504965f959bcfa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433340
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-06-06 11:32:11 -07:00
Stephen Adams 73d9a8d08b [dart2js] Cleanup
Rename DummyInterceptorConstantValue to DummyConstantValue. It was
actually used as a dummy *receiver* argument and could be used against
any unused parameter.

Remove unused CompilerOptions argument in SSA as-checks and is-tests.
Pass the checked input explicitly to facilitate testing on other inputs (e.g. to do partial redundancy elimination by pushing the operation into the arms of a phi.)

Change-Id: I4b450bfcf5fc877de731bf83201e3c9248ffcb0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433104
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-06-05 13:53:16 -07:00
Stephen Adams ff583f2e2e [dart2js] Do some load elimination in simplifier
Doing load elimination of final fields earlier generates more
opportunities for GVN.  This helps when the same value is 'boxed' in a
wrapper object and the 'unboxed' multiple times.

Change-Id: Id3a2b392a7563bae7a4cd1f8b2763c5ac1b377b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432502
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-06-05 13:21:13 -07:00
Nate Biggs 26e9c8201a [dart2js] Don't emit deferred loading logs in part files when flag is disabled.
Change-Id: I70a3a3a3c7bd56d8fd994e766f0ab2ab8c1f9ec4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432820
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-06-05 09:17:11 -07:00
Stephen Adams 58f2d59dcc [dart2js] Allow malformed UTF-8
The kernel Source class allows malformed UTF-8.  Dart2js should too.
Hopefully this will allow more informative reports, e.g. #60801, where
the location of the crash is hidden by a subsequent crash in crash
reporting due to malformed UTF-8.

Wrap the source access with a try-catch so that other errors in finding the source lines do not prevent the file name from being displayed.

Change-Id: I0f70c2d7a9044732d038a918d120c05961f3d705
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432101
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-06-02 19:14:29 -07:00
Stephen Adams 3f2a6963fb [dart2js] Improve algorithm for condition targets
1. Use a work queue to avoid recursion on deep trees.

2. Use a visited set to avoid cycles and repeated work on conditions like `b && b`.

Bug: #60801
Change-Id: If20de27b1ddd157feee2391289ec781c03f741ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431704
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-05-30 18:05:54 -07:00
Stephen Adams 85ccbe6d8d [dart2js] late final initialized instance field getters are idempotent
I wanted to detect that the synthesized getter is a late final field
getter and set the 'allowCSE' property in the optimizer, but as there
is not obvious predicate, used the annotation instead.

Change-Id: Idd8797e3e7e8ececabe57e57e10c3fb9ade71477
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430921
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-05-30 16:37:21 -07:00
Stephen Adams d49cd3c552 [dart2js] Track, rather than compute, isCallOnInterceptor
By tracking `isCallOnInterceptor`, we avoid the need for class context
information in the `sourceElement` to compute the value. `sourceElement`
is now purely advisory to the choice of local names in codegen, and
can't be the wrong kind of element as in issue #60793.

Bug: #60793
Change-Id: I8bb68b6bf864a3a6f9f2beb40f68a6254431d49a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432003
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-05-30 11:38:22 -07:00
Stephen Adams e2fdf18b66 [dart2js] Refine types based on test with late sentinel
A small number of getters for `late final` instance fields with
initializers have better code.

When the initializing expression provably does not write to the backing
field*, the field value is re-used rather than re-loaded for the 'final'
check (that the field has not been assigned during the evaluation of the
initializer). We are testing both `value === $` and `value !== $`:

```
      value = _this.___LayoutWidgetState_firstChild_FI;
      if (value === $) {
        result = A._LayoutWidgetState__buildChild(B.ValueKey_1, _this._widget.node.firstChild);
        value !== $ && A.throwUnnamedLateFieldADI();
        _this.___LayoutWidgetState_firstChild_FI = result;
        value = result;
      }
```

In this change we refine the type of the tested value to late sentinel,
allowing the check to be removed:

```
      if (value === $)
        value = _this.___LayoutWidgetState_firstChild_FI = A._LayoutWidgetState__buildChild(B.ValueKey_1, _this._widget.node.firstChild);
```

*This effect analysis is pretty simple ('writes some field'), but if
improved, we might expect more `late final` getters to benefit.

Change-Id: I444ed157083663b848fb2f115d0575e544b47727
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430962
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-05-27 12:47:44 -07:00
Stephen Adams 29d5395c49 [dart2js] Fix side-effects bugs
Make the `HInstruction.sideEffects` field final.  The instruction owns
the mutable SideEffects objects so it would be dangerous to make the
field reference a shared SideEffects object.

Update the side effects of an interface call when the target becomes
known. We were essentially missing any benefit of inferred
side-effects for instance members.

Change-Id: I46da1d87e166864cd7fa4cee01f209bcc19986af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430546
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-05-22 19:49:10 -07:00
Stephen Adams f14ce9eec0 [dart2js] Remove unused Map/Set literal helper functions
These functions have not been used since we switched to the new Rti.

In modern Dart it is not worth special-casing `<dynamic,dynamic>{}` and
`<dynamic>{}`.

Bug: #37715
Change-Id: I535bc67055a7dc02016b14d1a0ae43ca1f850e79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430320
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-05-22 11:31:14 -07:00
Stephen Adams b00c777f79 [dart2js] allow-cse and allow-dce annotations
Add `@pragma('dart2js:allow-cse')` and `@pragma('dart2js:allow-dce')`.

These annotations allow the compiler to do common subexpression
elimination and dead code elimination on calls to getters and methods.

Change-Id: Ie4091466e4782a4d28a7f9bfbfdb60a5de45a384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426360
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-05-21 23:02:06 -07:00
Kevin Moore 387ed7dd7d pkg/compiler: remove unused parameter from DumpInfoProgramData
Change-Id: I0e928d2761d287d41f0aba2c3335faec17239b86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429225
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2025-05-19 09:41:58 -07:00
Stephen Adams 630a3aafb0 [dart2js] Slightly smaller constant lists
Move the setArrayType call into the makeConstantList helper.

Shaves ~8k of small Flutter apps.

Change-Id: I8ff17e93ad3ad9e09292e294e2c2ddcbe66c5d33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428560
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-05-15 14:48:49 -07:00
Johnni Winther 94c9dff1c5 [cfe] Add isInternalImplementation to Extension(Type)MemberDescriptor
This adds a flag to the member descriptors that allow us to skip these when building the name space for extensions and extension types from dill.

The late lowering of fields in dart2js is fixed to support lookup from dill.

Change-Id: Iacbd6451ac234767036dfe8f818c3ecbb693ced8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427720
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-12 00:26:25 -07:00
Parker Lougheed 97dab4fa19 [dart2js] Avoid N/A memory usage with dart compile js
dart compile js seems to run dart2js in product mode, so the developer service is unavailable.

Instead of always outputting "N/A", instead don't include memory usage in the output when it can't be determined.

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

Change-Id: I3eea98a20b717c75abb56a48b3fe2a923ed3ecf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424320
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-05-09 15:10:06 -07:00
Stephen Adams a42401ab3e [dart2js] Remove checks to support migration with mixed null safety
`_potentiallyAssertNotNull` would insert null checks to catch issues
from mixing libraries sound and unsound null safety. The null checks
are now always optimized away so we might as well never insert them.

Bug: #60327
Change-Id: I092a4fb336e46bf33b9b3cd9867dd7b6d8f9c65e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427569
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-05-09 14:41:52 -07:00
Stephen Adams 40ffa5af09 [dart2js] Move decision to do static type refinement to dataflow
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/426660

The "using" of the static type didn't work in loops since the variables used in the loop start out as phis with a top type, so the guard to avoid trusting the static type for legacy js-interop always applied.

There are very few code differences with this change, but if we can address the TODOs, especially to partition Dart closures from JavaScriptFunctions, there are some nice changes in loops that call function parameters.

Bug: #60327
Change-Id: I76252d99b8047f74547d34ddc10e23d1fa380b2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426820
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-05-09 11:42:52 -07:00
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 ec6a35c9ff [dart2js] Clean up multitest structure in async_await_js_transform_test.
These multitest comments interact poorly with `dart format` and make it
difficult to discern what's actually happening. This rewrite should be
clearer.

Change-Id: If5ad8c61be8d311fd9d1450897eeb88ec799e477
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427585
Reviewed-by: Nate Biggs <natebiggs@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
Nate Biggs 581d10cae7 [dart2js] Hide deferred loading event log behind a flag.
This feature was added to allow some internal apps to debug issues they were having with deferred loading. Those issues have since been resolved.

Since this could still be a useful debugging tool in the future I'm adding a flag to enable it rather than fully deleting it.

Change-Id: Ia75fe379893c08a32e7da551d712f45167fa73ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427061
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-05-07 15:06:35 -07:00
Stephen Adams f581341cd1 [dart2js] Use static type refinement for getters in SSA
This helps with generic fields of classes that have contexts with
concrete types, e.g Flutter's `IntTween extends Tween<int>` has `int?`
fields `begin` and `end`. This helps remove some `HPrimitiveCheck`
instructions.

Bug: #60327
Change-Id: Ic2022cc15e024f596ad30f3134ec6c325c892dcf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426660
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-05-05 17:52:20 -07:00
Stephen Adams 0f601c3a35 [dart2js] Simplify HTypeKnow.isRedundant
After 0bb3adb704 it seems we should not
need the HTypeKnown to stick around since the knownType can no longer
change.

Bug: #60327
Change-Id: I575816a11e41e75acebecde1c32d37d251b5947b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426343
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-05-05 14:07:54 -07:00
Stephen Adams 55bacbfe69 [js_runtime] Add JsObject.safeToString via registered hook
Change-Id: Ic3f67e61f5f77b343082bb42c52b0c2b6d14eddc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423962
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2025-04-25 17:32:58 -07:00
Parker Lougheed 509e1038cc [dart2js] Fix minor typos in dart compile js help
Also drop the outdated doc for the unused '--allow-mock-compilation'.

Change-Id: I25de278cd6c2a398f5f407fa98c7aa08ab5a137d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424321
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-04-24 11:19:15 -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
Konstantin Shcheglov 90a5e71787 Lint. unnecessary_this. Report for this.foo() of the same class.
Change-Id: I55fe9d08fd8d9985f992c7b2cda6376efb8386be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421421
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-16 12:57:12 -07:00
Nate Biggs 748a2a2b22 [dart2js] Fix handling of flags for proto mixin shaking.
Sets `enableProtoShaking` earlier based on the mixin flag. For sequential builds that emit a dill file during the closed world phase, the output file name was not being set correctly becasue this flag was not updated early enough.

Change-Id: I079559c98d7e25841971bdf2e840a80355460e54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422347
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-04-14 13:04:02 -07:00
Robert Nystrom 1345cdf399 Roll dart_style 3.1.0 into the SDK.
Change-Id: I6392327cadce5194dabaa719bff945868a690225
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419990
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2025-04-10 23:55:02 -07:00
Ömer Ağacan 094538f9e3 [dart2js] Remove unused code in async lowering
Change-Id: Ide57438aa0fa9438aab44325cd53f1763afc31f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421600
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2025-04-09 08:32:40 -07:00
Stephen Adams 0bb3adb704 [dart2js] Remove receiver-not-null strengthening
Adding the inference that, after `x.foo()`, `x` cannot be null used to
make sense, but with sound null safety means this is only applicable
when `x` is `dynamic`.

Removing the `knownType` update logic makes it easier to reason about
type propagation. There are very few regressions for removing this now
(huge app had half a dozen minor regressions, several other apps had
none).

If we decide to add something like this in the future, I think it
should be added as part of SsaTypeConversionInserter, and be extended
to add other post-conditions (e.g. the runtime helper `checkString(s)`
ensures `s` is a String).

Change-Id: I27a7fcbc13873867713c439c062ecf9bd71d644d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420504
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-04-07 12:49:04 -07:00
Tim Maffett 4a821b4046 simple typo fix
Closes https://github.com/dart-lang/sdk/pull/60485

GitOrigin-RevId: efef9e67c7e2bb2ab8146f852bed98eb3590f360
Change-Id: I062510b397e368da9de195b50e332b25f52196c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420620
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2025-04-06 20:27:31 -07:00
Stephen Adams 33ed2d83ab [dart2js] Add lints
Add `unneccessary_statements`.

Add `unneccesary_ignore` so we can better maintain the ignores.

Change-Id: I50303be70fd6dbc14bdf0c5f0af9e58a1c6ec042
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420464
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-04-04 15:06:36 -07:00
Mayank Patke 8cb4d3c981 [dart2js] Remove _CanonicalizedTypeMaskKey and use record
Since #60419 is fixed by https://github.com/dart-lang/sdk/issues/60419,
we should be able to use record keys again.

Change-Id: I1256d74e80e135b0ba2a38c64c42e0463964baaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419986
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-04-03 14:06:04 -07:00
Stephen Adams c5adfd2d3e [dart2js] Trust refined types from Dart type promotion
Using the promoted type reduces the need for primitive receiver and argument checks, and can result in better code.

The promoted type is 'used' by inserting pinned HTypeKnown instructions at the use site. The pinning can constrain code motion. Better inference in the optimizer (https://github.com/dart-lang/sdk/commit/9505e957e1770cc4f15a70f6ab1fc9b1cc73723d) relaxes most of these constraints.




Change-Id: Ic9c0ebe7fd95b60382e2f66c49f69440b8b881d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419484
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-04-02 11:09:52 -07:00
Mayank Patke 66666c39a1 [dart2js] Add extension type to distinguish flags and powersets
Change-Id: I516cd7f0e6a03b680a399c483ef93d1e1d6cbeee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417911
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-04-01 10:28:58 -07:00
Mayank Patke ee48eb7c84 [dart2js] Ensure all flat typemasks are normalized at construction.
Because certain union cases weaken the type constraint (the kind), it
was unsafe to pass the full set of flags rather than just the powerset.

Change-Id: Ia4a65d539669acbe696bc237230eb84a4b7d8c99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417951
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-04-01 10:28:58 -07:00
Mayank Patke 0c422d6d61 [dart2js] Don't use a record key for canonicalized type mask cache.
Bug: #60419
Change-Id: Id3368d69d9590b328dc26b5aa088cf1e7142c5b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418500
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-03-31 11:32:14 -07:00
Stephen Adams 2d21ca796a [dart2js] Cache globalThis
Feature-test for `self` and `globalThis`, and cache the result.

The cached access has smaller minified code size than either `self` or `globalThis`.

All older browsers that we have supported that don't have `globalThis`
do have `self`.

We prioritize `self` over `globalThis`. They are usually the same but it is possible that there are programs which run in an environment that has replaced `self`, for example, a test might do that. We don't want to break existing tests.

Bug: #59982
Change-Id: I11d19183d85a73e9552b66a2f49ac99be10c3c83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417912
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-03-27 15:33:43 -07:00
Mayank Patke 34d674ba19 [dart2js] Remove cyclic throw
Change-Id: I1ae53d055786cec70a0a3999e04016a085c85e4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417324
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-03-27 13:46:20 -07:00
Mayank Patke 76d660a3e1 [dart2js] Remove bool conversions
The CFE will now add an `as bool` when a `dynamic` value is used as a
condition, giving the condition the right static type. Without
`--omit-implicit-checks` we faithfully emit a cast, so no bool
conversion is needed. With `--omit-implicit-checks`, we trust that the
condition is a boolean and emit no check of any kind - but you get what
you asked for.

Change-Id: I5c9f6b6516386fab5b863f256f9676fc7abe19b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417323
Reviewed-by: Stephen Adams <sra@google.com>
2025-03-27 13:46:20 -07:00
Mayank Patke fc563fc991 [dart2js] Remove SsaInstructionSimplifier.visitBoundsCheck
Change-Id: Ie497a8596c2e1e2dd1407a2e63b424c373ecea13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416721
Reviewed-by: Stephen Adams <sra@google.com>
2025-03-27 13:46:20 -07:00
Mayank Patke 9d18a99087 [dart2js] Clean up APIs that were only used for unsound null safety.
Change-Id: Iff76a964317388c869373fbebe15ab4cbbe84468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416522
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-27 13:46:20 -07:00
Stephen Adams 9505e957e1 [dart2js] Add more refinements for null-test and type-tests.
Bug: #26835 #28330
Change-Id: I2ea5d3022901a67b10fdb7ca0a6233a22ca233bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417328
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-03-25 17:30:21 -07:00
Stephen Adams 57f177210a [dart2js] Test for complex condition strengthening
Bug: #26835 #28330
Change-Id: Ic3bc05f1b5525e58173c335c5f3f4f91dd09e2f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417329
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-03-24 15:29:23 -07:00
Sigurd Meldgaard 2fe05bd568 Reland "Migrate to use pub workspace"
This is a reland of commit b9b77058a9

Original change's description:
> Migrate to use pub workspace
>
> Use `pub get` to generate `.dart_tool/package_config.json` on gclient sync.
>
> All pkg/ (and a few third_party) packages that are developed inside the sdk repo are included in the workspace from the root `pubspec.yaml`.
>
> All dependencies that are pulled in via DEPS are added as path dependencies via `dependency_overrides` in the root `pubspec.yaml`.
>
> Bug: https://github.com/dart-lang/sdk/issues/56220
> Change-Id: I38c12b608c68da54c57821116cf9aa6696936746
> Tested: relies on CQ of existing tests. Should have no effect on functionality
> CoreLibraryReviewExempt: only core library change is adding a `// ignore:` comment. Should have no influence on functionality
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397164
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

Bug: https://github.com/dart-lang/sdk/issues/56220
Change-Id: I29afabade2d2447dea05121cb87ff50bb21a4b76
Cq-Include-Trybots: luci.dart.try:flutter-linux-try,flutter-web-try
Tested: relies on CQ of existing tests. Should have no effect on functionality
CoreLibraryReviewExempt: only core library change is adding a `//
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415561
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2025-03-20 06:19:16 -07:00