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>
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>
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>
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>
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>
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>
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>
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>
`_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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>