Commit Graph

696 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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 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
Nate Biggs c3f6e4f591 [dart2js] Allow for consistent CLI flags for staged compilations.
Issue: https://github.com/dart-lang/sdk/issues/60353
Change-Id: I58f9f17b6916fec0d6279e1659618950aa695f81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416327
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-03-19 12:02:39 -07:00
Mayank Patke 77cd774d08 [dart2js] Remove legacy type test specializations.
Bug: #60327
Change-Id: Ie9b1b86c0f7695e0b9d377004a082f56f44bd57f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416160
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-18 19:09:54 -07:00
Mayank Patke 38ef3748c3 [dart2js] Remove LegacyType.
Bug: #60327
Change-Id: Ia236d1674ba8030da3b91e88ac869e99fe5b8399
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416024
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-18 19:09:54 -07:00
Ömer Ağacan f4b41f0902 [dart2wasm] Fix handling of --define/-D
When parsing `--define` or `-D` arguments don't split the the value by
commas.

This is consistent with how dart2js handles `-D`, but inconsistent with
how VM handles it.

Example:

    void main() {
      print(const String.fromEnvironment("FOO"));
    }

When compiled with `dart compile js -DFOO="a, b"` and run, dart2js
prints

    a, b

VM prints (when compiled to exe)

    a

Between these two, I think dart2js' behavior is more common, so we
follow dart2js.

Also update compile_benchmark to avoid splitting a single argument "a b"
into "a" and "b" when parsing the arguments and then splicing them back
before calling `dart2wasm`.

Also update the test runner and ddc batch mode argument parser to handle
splitting quoted arguments in `// dart2jsOption = ...` and the same
options for ddc and dart2wasm, by moving dart2js's `splitLine` to a new
library and reusing it in the test runner and ddc.

Fixes https://github.com/flutter/flutter/issues/164873.

See also https://github.com/dart-lang/sdk/issues/60341 for relevant
future work.

Change-Id: Idbdf69072fa212c8e4a390990577eb5a57b49e8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415280
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2025-03-18 04:11:41 -07:00
Sigmund Cherem 6f70ffa4ff [dart:html] Disallow extending html elements.
This change removes the `.created` constructor in the html
class hierarchy. These classes now only offer public factory
constructors. As a result, developers will no longer be able
to extend these classes in their libraries.

This is a breaking change, however we don't expect there to
be as much use of this feature (extending html element
classes). In particular, the ability to extend html elements
was intended for web components.  Dart only ever supported
the 0.5 spec of web components, which is old and long
deprecated.  Previously, in Dart 3.0, we removed APIs used
to register custom elements from `dart:html`, so the ability
to extend html elements has not been useful since then.

For more details see https://github.com/dart-lang/sdk/issues/53264

CoreLibraryReviewExempt: ddc/dart2js-specific library.
Change-Id: I43d8c9ae99dc83545e70e1f3b9dfc9f1b274a5c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321741
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2025-03-11 13:25:58 -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 b1849f5fcc [dart2js] Delete regression test for unused dump-info mode
Change-Id: I491fd7c47f33ef900ab3189dee224291c7b2d73f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414165
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-06 16:47:29 -08:00
Johnni Winther 0060b0f665 [cfe] Remove nnbd mode
TEST=existing

Change-Id: I30bbadb74e81c7f4aaa444d1e2f6f5ffc2005d4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412881
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-03-04 01:46:51 -08:00
Nate Biggs 237742feab [dart2js] Remove '--no-sound-null-safety' flag and make '--sound-null-safety' flag a no-op with warning.
Change-Id: I0225f9306aa2a84494f3fc17c9f7191214404249
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406081
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-03-03 15:46:16 -08:00
Mayank Patke 0c55c7e573 Remove unsound web configurations from test matrix.
This CL also removes references to unsound .dill files from the test
matrix and other build scripts and disables some of the option handling
that would lead to requiring unsound .dill files.

Change-Id: I89f701f8f5e1168bf974b5b44bfbafd5a39954fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412401
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-02-26 15:57:55 -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
Mayank Patke 66fa0e2a49 [dart2js] Clean up nullability adjustments in interface sufficiency test
Now that https://github.com/dart-lang/sdk/issues/60076 has been
addressed, we no longer need to widen the nullability ourselves.

Change-Id: I4bc5a1767d9e2d98bcf0ca4c24171482e0f600ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409162
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2025-02-13 01:49:09 -08:00
Stephen Adams e962350dd6 [dart2js] Simply is-test when type parameters not needed
Sometimes the type expression of a is-test can be widened to one that
does not use type variables:

```dart
void addAll(Iterable<E> items) {
  if (items is List<E>) {
    ... items[i] ...  // code specialized to lists
  }
  ...
}
```

Changing `is List<E>` to `is List` is more efficient, but not possible
at the source level since the explicit type parameter is needed for
type promotion.

This change uses a predicate provided by the Kernel package to widen
an interface type when generating the CFG instructions for the
is-test. This can lead to knock-on optimizations like compiling `is X`
to `instanceof`.



Bug: #54998
Change-Id: I956b9d9b8a31ae40aee86e31def475baa9ab5cfe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408124
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-02-06 16:54:50 -08:00
Stephen Adams a11aeeb500 [dart2js] Annotation for exception stacks with shorter prefix
Dart's `throw` expression does not correspond exactly to JavaScript's `throw` statement. To implement Dart semantics, and to reduce code size, dart2js uses the functions `wrapException` and `throwExpression` from the dart2js runtime. As a result, these functions appear in the stack trace (one or both).

A consequence of this is that a fixed prefix of an error stack is less useful, as potentially interesting frames are forced out of the prefix by these 'noise' frames.

This change ensures only one of the helpers on the stack trace.

It is also possible to get rid of the helper frame by an annotation.

The annotation `@pragma('dart2js:stack-starts-at-throw')` causes the stack to be captured in the current JavaScript function rather than in a helper. The cost is more code at the call site, about 12 bytes per `throw` expression in minified code. The annotation can be placed on a method, class or library, and applies to all `throw` expression in the scope of the annotated element.

This change uses the annotation to remove noise frames from type errors and some other errors in the runtime.

Change-Id: If15184a5963fb054199177bb4526b32f25e53fe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406684
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-01-30 20:45:49 -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
Chloe Stefantsova c32edddf80 [cfe] Report "!" in constant expressions as error
Closes https://github.com/dart-lang/sdk/issues/59800

Change-Id: I06d68eb1d0608a0a865002c88f7665415159f468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405901
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-01-30 02:02:41 -08:00
Stephen Adams 32082be3eb [dart2js] invariance optimization for field setters under -O2
Calls to the implicit setters for fields are replaced with field assignments (HFieldSet). This is inhibited when the setter needs to check its argument, which happens when the field type is covariant and the checks not 'trusted', i.e. at optimizations level `-O2` and lower (aka 'spec' mode).

This optimization detects when the check is unnecessary due to invariance. If the receiver of a setter instance call to the the implicit setter has `this` as a receiver and the setter does not have an explicit `covariant` declaration, then the check will always pass, so the setter call can be replaced with HFieldSet.

This optimization works well for Iterators for generic collections at the assignment to the `_current` field, with some iteration-heavy benchmarks improved by 20-50% at `-O2`.

Change-Id: I4f3ffd08b45ba28de721535afc3c7a6d1e486a3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405448
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-01-27 16:24:09 -08:00
Stephen Adams a1c54855a6 [dart2js] Detect larger no-op regions
Change-Id: Id4ced6f3a54d40a3775b77fde8453e45a6383ee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404800
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-01-24 14:35:55 -08:00
Stephen Adams b3502f17cb [dart2js] Reduce redundant phis with refinements
Redundant phi elimination removes phis that join the same value.
However, this does not work when one or more of the inputs has a refinement (HTypeKnown). This change adds redundant phi elimination when the phi inputs have refinements.

The need for this optimization shows up when static js_interop needs a dispatch on type for conversion:

```
final JSAny? jsValue;
if (value is String) {
  jsValue = value.toJS;
} else if (value is bool) {
  jsValue = value.toJS;
...
```

(The `.toJS` calls become no-ops since, for dart2js, we are already in JavaScript, and so leave an otherwise pointless if-then-else chain).

Change-Id: If1a94856592163a81ac36c686cee04232c16d197
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403950
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-01-16 11:16:31 -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
Mayank Patke 723cbc1f73 [dart2js] Change Enumset.operator +/- to Enumset.add/remove.
Change-Id: I92a97911531b699c5fc17cc37d5540c3fc44e63d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396566
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-11-21 19:13:50 +00:00
Mayank Patke 0bfa0b05a2 [dart2js] Add Bitset and EnumSetDomain abstractions.
Change-Id: I85b401d7eb13e0d9ba0bfcb37aebdb28e65bc77f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395062
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-11-21 19:13:50 +00:00
Nate Biggs 9468f60aac [dart2js, ddc] Fix nested exception handling.
In the flattened control flow state machine generated for dart2js and ddc async functions, there is a single error state variable per function. However, functions can have nested error handling that may try to access stacked errors separately. When we enter a nested try/catch we should avoid clobbering the outer exception as the outer handler may need it later.

To fix this we maintain a stack of errors that we 'push' to when we enter a new try/catch and which we 'pop' from at the end of executing that try/catch.

Fixes: https://github.com/dart-lang/sdk/issues/57046
Change-Id: Ib96a44ab4152f6f9e444f2ee959ec9aa252800f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395580
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-11-15 23:20:00 +00:00
Jens Johansen a9469269d7 [kernel] BinaryReader takes Uint8List, not List<int>
In AOT this makes reading faster:

Output from `out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --iterations=10 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.1 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.2 --arguments="--warmups=10" --arguments="--iterations=5" --arguments="AstFromBinaryEager" --arguments="out/ReleaseX64/vm_platform_strong.dill"`:

```
msec task-clock:u: -8.6925% +/- 0.5737% (-167.09 +/- 11.03)
page-faults:u: 0.1410% +/- 0.0051% (243.00 +/- 8.71)
cycles:u: -10.2918% +/- 0.6161% (-732576747.50 +/- 43853449.16)
instructions:u: -14.4988% +/- 0.0004% (-1636799813.90 +/- 39902.18)
branch-misses:u: -3.4891% +/- 2.1142% (-1166085.00 +/- 706582.35)
seconds time elapsed: -8.7005% +/- 0.5634% (-0.17 +/- 0.01)
seconds user: -9.9752% +/- 1.5104% (-0.17 +/- 0.03)
```

Stats running manually (run as e.g. `out/ReleaseX64/dart-sdk/bin/dartaotruntime pkg/front_end/test/kernel_binary_bench.aot.1 --warmups=10 --iterations=5 AstFromBinaryEager out/ReleaseX64/vm_platform_strong.dill`):

```
AstFromBinaryEagerCold: -12.5174% +/- 3.10688%
AstFromBinaryEagerWarmup: -8.33675% +/- 2.62433%
AstFromBinaryEager: -10.3432% +/- 3.68375%
```

I don't expect there to be much of a change (if any) in JIT as the actual type was in practise always Uint8List anyway.

TEST=Existing tests.

Change-Id: I86b16ed207343848dee2e376f42598c223bbc48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393740
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-08 08:23:42 +00:00
Robert Nystrom 732b07a42b Roll dart_style into the SDK.
I'm still chasing down a couple of google3 failures, but this is ready for review so that I can get it approved and land it once the last couple of failures are fixed. Here is who I think should review what:

athom@ for:

- DEPS

johnniwinther@ for:

- pkg/_fe_analyzer_shared
- pkg/front_end
- pkg/kernel

brianwilkerson@ for:

- pkg/analysis_server
- pkg/analyzer_plugin
- pkg/analyzer_utilities

kenzieschmoll@ for:

- pkg/dartdev

pquitslund@ for:

- pkg/linter/lib/src/lint_codes.g.dart

If you're not the right person, feel free to summon someone else.

Most of the changes here are re-running code generators that auto-format the code they generate. The changes are:

Roll in the latest dart_style commit:

- DEPS

Manually updated these test expectations to expect the new style:

- pkg/analysis_server/test/lsp/format_test.dart
- pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart
- pkg/analysis_server/test/src/domains/flutter/set_property_value_test.dart
- pkg/analysis_server/test/src/services/flutter/container_properties_test.dart
- pkg/analysis_server/test/src/services/flutter/widget_descriptions_test.dart
- pkg/analysis_server/test/src/services/refactoring/convert_selected_formal_parameters_to_named_test.dart
- pkg/analysis_server/test/src/services/refactoring/move_selected_formal_parameters_left_test.dart

This was auto-generated by something, but I'm not sure why it thinks there is a diff:

- pkg/analyzer_plugin/doc/api.html

Updated to require a version of dart_style that accepts a language version in DartFormatter():

- pkg/analyzer_plugin/pubspec.yaml

Updated to always use the latest language version (and thus new style) when invoking the formatter:

- pkg/analyzer_utilities/lib/tools.dart

Manually updated the formatting in the code templates so that they matched the formatting expected by the tests, which implicitly format using the latest language version:

- pkg/dartdev/lib/src/templates/...

The rest are all generated files that are formatted so re-generated using the new style:

- pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart
- pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
- pkg/analysis_server_client/lib/handler/notification_handler.dart
- pkg/analysis_server_client/lib/src/protocol/...
- pkg/analysis_server/lib/protocol/protocol_generated.dart
- pkg/analysis_server/test/integration/support/integration_test_methods.dart
- pkg/analysis_server/test/integration/support/protocol_matchers.dart
- pkg/analyzer_plugin/lib/protocol/...
- pkg/analyzer_plugin/test/integration/support/integration_test_methods.dart
- pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
- pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
- pkg/analyzer/lib/src/dart/error/...
- pkg/analyzer/lib/src/error/codes.g.dart
- pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart
- pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart
- pkg/analyzer/lib/src/summary/format.dart
- pkg/analyzer/lib/src/wolf/ir/ir.g.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_000_1.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_001_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_010_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_100_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/simple/...
- pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart
- pkg/front_end/lib/src/codes/cfe_codes_generated.dart
- pkg/front_end/lib/src/util/parser_ast_helper.dart
- pkg/front_end/test/parser_test_listener.dart
- pkg/front_end/test/parser_test_parser.dart
- pkg/front_end/testcases/...
- pkg/kernel/lib/src/coverage.dart generated
- pkg/kernel/lib/src/equivalence.dart generated
- pkg/linter/lib/src/lint_codes.g.dart

Change-Id: Ice0141b763e63b84f54692cd19a442a0719673c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391263
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-11-06 18:42:25 +00:00