Adds a conversion function on List<JSAny?> so that users can
modify the original list and have those changes carry forward
to the array. Creates a proxy object for dart2wasm when the
list is not a JSArrayImpl. This proxy uses handler methods and
the fact that Array methods are generic to provide an Array
interface. Also fixes a small issue in the exporting so that
toJS'd function types have a valid return type.
CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I00f453aa82dd19f2913820579eb2675b799288d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323446
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
When a callback is toJS'd with an int parameter, we should attempt
a conversion to int if possible, similar to return values on
external functions. Similarly, parameters where the expected type is
a JS type should check to make the value isn't nullish before boxing,
as JS null and undefined are converted to Dart null.
Tests are added for conversion semantics of JSFunctions.
Change-Id: I95566c2954d915b8cf31cdc55fed359c695404f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323445
Reviewed-by: Aske Simon Christensen <askesc@google.com>
This is a reland of commit 8193e6a385
The CL is changed to handle the inconsistent patching we have for
extension methods. This CL either checks if the member is non-external
or has the @patch annotation. This accounts for all the members in
dart:js_interop.
Original change's description:
> [dart:js_interop] Remove unnecessary custom static interop check
>
> This was added to prevent accidentally lowering patched members,
> but these members are patched before we see them, so they aren't
> marked external.
>
> Change-Id: Ib8f7c52c38a3f1e28905798a40319f7aa2994328
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322502
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
Change-Id: I129e5a030df1fd55e7292b4b4bd0276cab7bee15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322564
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Change-Id: Ia32b15ec9ac572332da7904e94ec9c9615bf3de1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324842
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This is cleanup work required to start enforcing this with static analysis, as
per https://github.com/dart-lang/sdk/issues/53253.
Real quick this issue is that this code is unsafe:
```dart
void f(Completer<int> c, int? i) {
Future<int>.value(i); // Ouch!
c.complete(i); // Ouch!
}
```
Change-Id: Ia4d83719c425601b24e8ae6e305c88c95cba8b20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324640
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
The generated constant evaluator is not being used and is removed by
this CL. All imports of the deleted evaluator will import the more
direct dependency and tests are moved to `evaluation_test.dart`.
Change-Id: Ie435d289bd85256419f67407b36af0375661f335
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324342
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
After this move, there are 10 remaining HintCodes: 3 are deprecated
(only reported in pre Dart 3.0 code), 5 are to be moved; 2 are to be
re-implemented as LintCodes.
Work towards https://github.com/dart-lang/sdk/issues/50796
Change-Id: I230c1c6a4defcdf1a00c0a755eac71baa1d4c9bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324420
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
No functional changes, just moving from the old `markers()` functions to `TestCode`, using the flat setXxxCapabilities() style and some other minor cleanup to be consistent with other tests.
Change-Id: I8ad04cd6b50df59004d07510f4fa2f57a8cd4463
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324721
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This is cleanup work required to start enforcing this with static
analysis, as per dart-lang/sdk#53253.
Real quick this issue is that this code is unsafe:
```dart
void f(Completer<int> c, int? i) {
Future<int>.value(i); // Ouch!
c.complete(i); // Ouch!
}
```
Change-Id: I12c4f0a92a2071fb47759d9626689e00cfa42f8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324763
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This CL also cleans up any required mixin declarations/uses.
Change-Id: Ib51847f01aa6c10ebf1284600455a07091a109b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324484
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
This lets the sanitizers intercept any symbol. It's not worth trying to track which symbols the sanitizers are interested in. The sanitizer builds are not distributed so concerns about incompatibility, access to internals or size do not apply.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/53440
Change-Id: I59d137f4c15863cd27af857bfca4c53d847f2b90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324566
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
When copying elements that are smaller than words on non-X86
architectures, only copy element by element until the remaining elements
can be copied in word-sized chunks, and then do so.
TEST=vm/cc/IRTest_Memory, co19{,_2}/LibTest/typed_data,
lib{,_2}/typed_data, corelib{,_2}/list_test
Issue: https://github.com/dart-lang/sdk/issues/42072
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv64-try,vm-linux-debug-simriscv64-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-mac-release-arm64-try,vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-linux-release-simarm-try,vm-linux-release-simarm64-try,vm-mac-release-arm64-try,vm-aot-android-release-arm64c-try,vm-ffi-android-debug-arm64c-try
Change-Id: I61eab310b92a6bc5ebd88fa63d562103d887cb74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324280
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
The `--watch` debug option to print the stack trace leading to a
particular byte in the output Wasm file didn't work for instructions
after the instruction encoder was changed to produce intermediate
instruction objects.
This is fixed by keeping a map from instruction objects to stack
traces in the instructions builder and registering those stack traces
when serializing the instructions.
Change-Id: I90d665753813452d07783c7f47e1e6bf63a3a18e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324681
Reviewed-by: Jess Lally <jessicalally@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
allocation.
When using the `struct.new_default` instruction for object allocation,
fields are always nullable and mutable. By using the `struct.new`
instruction instead, class fields can now have the same mutability and
nullability in Wasm as declared in Dart. In addition, the class ID and
type parameters (which are also stored in an object's struct), can now
be immutable and nonnullable as well.
To do this, object construction is now split into three functions:
(1) Initializer: evaluates initializers for instance fields and
constructor initializers (this constructor before super constructor).
(2) Constructor body: executes the constructor body (super constructor
before this constructor), with `this` pointed to the constructed object.
(3) Constructor allocator: which calls (1), allocates the object using
`struct.new`, then calls (2).
Because fields now have the correct mutability and nullability in Wasm,
this removes unnecessary null checks for nonnullable fields, and may
allow for better optimisations by Binaryen.
Fixes https://github.com/dart-lang/sdk/issues/51492
Change-Id: Ib26046686f772a70509a870301217e9b1c91b77e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315820
Commit-Queue: Jess Lally <jessicalally@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
When having multiple contexts we have duplicates of some things.
For instance line starts data.
This CL deduplicates some of it, and makes use of `Uint16List` and
`Uint32List` as appropriate (some where regular `List<int>`s before),
reducing the heap usage for analyzing `flutter/flutter` (80+ contexts)
when analyzing with an empty cache with about 165 MB.
Details:
```
_GrowableList (dart:core) (bytes):
Difference at 95.0% confidence
-451040.00 +/- 0.00
-0.79% +/- 0.00%
_Uint16List (dart:typed_data) (bytes):
Difference at 95.0% confidence
6558032.00 +/- 0.00
696.69% +/- 0.00%
_List (dart:core) (bytes):
Difference at 95.0% confidence
-70840960.00 +/- 231371.19
-9.58% +/- 0.03%
_Uint32List (dart:typed_data) (bytes):
Difference at 95.0% confidence
-103560448.00 +/- 2829564.24
-23.56% +/- 0.64%
heapUsage:
Difference at 95.0% confidence
-173020528.00 +/- 7787712.50
-4.78% +/- 0.21%
```
Change-Id: I49e23dde14a2faa7c8af94515b0ad1c669867c78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324501
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This avoids the overhead of Dart lists in subtype checks. It also
alleviates a potential source of infinite recursion by avoiding some
list operations with implicit type checks inside the type check code
(though there are still more of these).
With this change, we no longer have the const object cycle between
the empty list of `_Type` objects and the interface type object for
`_Type`. In combination with the the `struct.new` optimization, this
enables type argument fields to become non-nullable and immutable.
Change-Id: Ib46ea70a078a0c580713090163fecd63fe363bd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322900
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jess Lally <jessicalally@google.com>
This is a step towards making an [empty] `HInstruction.instructionType` more reliable as an indicator that following instructions are unreachable.
- Make accessing the `.instructionType` of a HControlFlow instruction
an error.
- Remove `AbstractValueDomain` as a constructor argument for
`HInstruction` nodes - either it is no longer necessary (for control
flow) or pass in the AbstractValue.
Change-Id: I642915069015fc1a42bbe46d4aaedd919a9dbdc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324344
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This is a reland of commit ebc96ecb83
Angular codegen emits members that are external so DDC's external
checks need to be more specific to only focus on JS interop. This
also modifies some code logic around whether a member is JS interop
to be less permissive. Before, it claimed that any member is JS
interop if it's external and the enclosing library has a @JS
annotation, but this is only true if there is no surrounding class.
Original change's description:
> [ddc] Don't emit type args on interop invocations
>
> DDC passes type args as the first args for a generic function
> invocation, but interop functions should be excluded from doing
> so, as this leads to passing type args to JS functions.
>
> Change-Id: Ia011beca8c7a0ebb3a7e6c81cd960096045c3a06
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323941
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
Change-Id: Id48337ac4980d9de5de03d895d93cad3ab3a1808
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324542
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Sorry about the size of the change.
This started as a CL to move the computation of keywords with a record
pattern from the contributor to the pass. In the process of doing so I
realized that the previous computation of the completion node (the node
that's visited) was too aggressive about moving upward in the AST. I
believe the issue happens when we reach a node in a list of similar
nodes (such as a statement in a block).
I changed the computation of the completion node, which necessitated a
lot of changes to existing code. It also resulted in changing several
tests, most for the better I think, but please look carefully for
places where you think the changes aren't reasonable. I'm also
interested in feedback about the change to the computation of the
completion node.
Change-Id: I2c6ac76fe88f672a206c3692d9ff51d2e487ec0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Due to a recent change to improve the dump info task, the `runSequentialPhases` method was reorganized. Part of this involved adding references to the closed world and global inference indices later on in the method (after the emitter task runs) to support serialization. Though this serialization only occurs if certain flags are passed to the compiler, the VM can no longer GC the results of those earlier phases as early since they might be used.
The fix is to reassign those locals earlier on based on the dump info flags. This way the VM will track the new locals separately and can free the original references while only adding a new reference if the relevant flags are passed.
Change-Id: I8f5dbc0f88c77ab43cb3f3bf12a42ecb37c9a803
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324660
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
```
ld64.lld: warning: cannot export hidden symbol Dart_ActivationFrameInfo
>>> defined in obj/runtime/vm/run_vm_tests.debugger_api_impl_test.o
```
Namespace the former API functions retained for testing so they don't match the export glob Dart_*.
TEST=build
Change-Id: I4b7ed4125ef25cc33b6d4073399b0824019a1e01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324568
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This is cleanup work required to start enforcing this with static analysis, as
per https://github.com/dart-lang/sdk/issues/53253.
Real quick this issue is that this code is unsafe:
```dart
void f(Completer<int> c, int? i) {
Future<int>.value(i); // Ouch!
c.complete(i); // Ouch!
}
```
Change-Id: I91d7be0a16e62e78b530a70f115117d379259b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324541
Reviewed-by: Liam Appelbe <liama@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
No functional chages.
* Move doc comment-specific data classes out of ast.dart into their own
library.
* Make many fields and methods in DocCommentBuilder private, and re-sort.
* Remove a text nit from doc comment warnings.
Change-Id: I2459115c2d688ef7ba4a0fa7d3ff986ace9d3f1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324565
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Applying patch from @aam for using try/catch in lookupAddresses instead
of Future error.
This will be cherry picked into the stable branch to ensure we
address the expedient issue in https://github.com/dart-lang/sdk/issues/53334
TEST=new test added.
Change-Id: Ia5375cbd118d8d6437cf6869383f173cab48aa3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323684
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
The library name cache is dead.
The library exported name cache is used indirectly through Dart_Invoke etc, and is practically only used for one-shot lookups like `main` or the embedder's startup hooks. The lookups that were worth caching now happen in the Dart frontend instead of the VM.
Cf. b9045af57b
TEST=ci
Change-Id: Ibd8bd30fbba3e9af32e3fbf3c5c4ced51a8d15d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324401
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This is a magical direct call, not a Dart language static call. Don't attempt to re-lookup.
TEST=reload
Bug: https://github.com/dart-lang/sdk/issues/53430
Change-Id: I4b0fd2491f7d41e5f6180970abbd43e871bd18b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324263
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This reverts commit ebc96ecb83.
Reason for revert: breaks G3, b/299279625
Original change's description:
> [ddc] Don't emit type args on interop invocations
>
> DDC passes type args as the first args for a generic function
> invocation, but interop functions should be excluded from doing
> so, as this leads to passing type args to JS functions.
>
> Change-Id: Ia011beca8c7a0ebb3a7e6c81cd960096045c3a06
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323941
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
Change-Id: Id1af7f71e80b22b48343c1d918b9431afaf6aaf4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324521
Commit-Queue: Ilya Yanok <yanok@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Since the `compile_benchmark` script is used for compiling benchmarks
which will eventually be used for binary size tracking, the generated
Wasm file should have its names stripped.
Change-Id: I5db06537e29c0316eb5c15420448c64529bc763d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324520
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jess Lally <jessicalally@google.com>
* Check against raw `EfficientLengthIterable` instead of specifying
its type parameter. Both checks are equivalent in this context as
`EfficientLengthIterable` is an internal marker interface and an
instance of `Iterable<T>` can never be an instance of
`EfficientLengthIterable` but not an instance of
`EfficientLengthIterable<T>`.
VM compiler is currently not good enough to eliminate the
`is` check if involves an uninstantiated type
(see https://dartbug.com/53445).
* Force inlining of `IndexedIterable` factory,
`IndexedIterable.get iterator` and `IterableExtensions.indexed`.
These changes significantly reduce overhead of for-in-indexed
when compared to baseline classical loop: before these changes
for-in-indexed is 13x slower than classical loop, after these
changes it is only 2.8x slower.
Performance comparison was using the following benchmark kernels:
```dart
final list = List<int>.generate(10000, (i) => i);
// For for-in-indexed
var result = 0;
for (var (i, e) in list.indexed) {
result ^= (i & e);
}
// For classical loop
var result = 0;
for (var i = 0; i < list.length; i++) {
result ^= (i & list[i]);
}
```
CoreLibraryReviewExempt: No API changes, VM specific optimisations.
Change-Id: Ic935a2aab2eda0837981184d872ee1eeef89ee7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324461
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>