Commit Graph

5924 Commits

Author SHA1 Message Date
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 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
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
Ö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
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
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 3a3dfcbb7d [dart2js] Remove references to new-rti/old-rti.
The "new" rti library has been standard for years now and no one should
be passing `--experiment-new-rti` or `--use-old-rti`. We can now clean
up any references to different versions of rtis.

Change-Id: I4421b8943fe5034ed4d259477e8112b25ba0c763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416326
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-03-19 11:54:57 -07:00
Mayank Patke 30f2914e74 [dart2js] Remove SNS checks flag.
Change-Id: Idb2163a47e7c6ad4f2482bc24aecfc3483c7023b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416342
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-19 11:54:57 -07:00
Johnni Winther 06d938046f [kernel] Remove NonNullableByDefaultCompiledMode
and TargetFlags.soundNullSafety

TEST=existing

Change-Id: I5e28d3d187b0f84fa23130c042fd3c55b89c687c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413460
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-19 01:37:07 -07:00
Mayank Patke 107660616e [dart2js] Remove all uses of useLegacySubtyping.
Bug: #60327
Fixes: #41960
Change-Id: Idc766a1cccd008aa7262c79effe25daa240850bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416180
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2025-03-18 19:09:54 -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 549639dc6c [dart2js, ddc] Remove LEGACY support from rti.
- Remove support for `JS_GET_FLAG('LEGACY')` from backends
- Remove `kindStar` Rtis
- Remove `Recipe.wrapStar`

Bug: #60327
Change-Id: I2ec9b0afc9f3cd99fc6167600e6d908c9771af1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416101
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-18 19:09:54 -07:00
Mayank Patke 6a2e567859 [dart2js, ddc] Remove PRINT_LEGACY_STARS.
Bug: #60327
Change-Id: I32a9f078e4c2ae5fc3b79b4f549a4357a08818d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416043
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-03-18 19:09:54 -07:00
Mayank Patke 13b5b8ab37 [dart2js, ddc] Remove support for SNS checks.
Bug: #60327
Change-Id: I38f04fea4e51dcd0fd43dc93ecc7007a0a816f29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416120
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@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
Mayank Patke 1f8ab5f53b [dart2js, ddc] Remove LEGACY_TYPE_REF.
Bug: #60327
Change-Id: I30017acd7087227e646b230078066208fb27e398
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416060
Reviewed-by: Nicholas Shahan <nshahan@google.com>
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
Nate Biggs 1841a8d9a4 [dart2js] Add support for tree shaking protobuf messages with mixins.
Typically these mixins introduce additional reflective features on the messages extending them. This made it unfavorable to tree shake fields on these messages.

However, some customers have tooling that makes it so the set of messages/fields accessed reflectively through mixins is statically known. Therefore, they can inject special code to retain those messages/fields and still benefit from treeshaking on the rest of the fields in those messages.

This is a separate flag because it introduces new opportunities for breakages that users may want to roll out separately.

Testing on an internal build showed an additional ~2.8% code size reduction from this additional tree shaking.

Change-Id: I6bbe6209acc26f8e8904c81f6960b71e4b516f25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414820
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-03-11 18:11:49 -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