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>
External final fields are equivalent to getters whose implementation
is provided outside of Dart code. As such they're not guaranteed to be
stable, so they shouldn't be promotable.
It turns out that the CFE was already correctly classifying them as
non-promotable (because it de-sugars them into getters prior to
computing promotability). This CL fixes the analyzer.
Fixes https://github.com/dart-lang/sdk/issues/53426.
Bug: https://github.com/dart-lang/sdk/issues/53426
Change-Id: Icdd897cdbdf0da0a69ea704a245c0b428070b95e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324340
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
When `getFunction` is called, the function will be added to the worklist if it has not been previously generated. However, if there is a later call to the code generator `call` helper method, this may decide to inline the function, meaning that the function will be generated twice. By calling `getFunctionType` instead, functions will be generated once by the `call` helper method.
Change-Id: I39a48dca37428b0723d897437fb4687748ad72f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324282
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jess Lally <jessicalally@google.com>
This dependency is optional and only pulled down if checkout_flute is
set to True in the .gclient file.
Bug: b/274424008
Change-Id: I786325548958458d147ab8fd9da57550f36320b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324441
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
_StringTable had 2 Uint32Lists for offsets and lengths in order to be
able to read strings lazily.
As offsets[x+1] = offsets[x]+length[x] we don't really need the lengths
one though.
Analyzing (82 contexts in) flutter/flutter (without a cache) this
reduces memory load by something like 22-27 MB (see below).
Note that it doesn't actually reduce the heap capacity or the process
RSS in this instance though.
Statistics on 5 runs of each:
```
_Uint32List (dart:typed_data) (bytes):
Difference at 95.0% confidence
-23842069.33 +/- 986160.19
-5.15% +/- 0.21%
heapUsage:
Difference at 95.0% confidence
-28619536.00 +/- 8755493.42
-0.79% +/- 0.24%
```
Change-Id: Ia71bac2233fcef2d9e930c8b78f1aee58e1af78f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320801
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This reverts commit cbdae14d2f.
In addition, Fix prefer_collection_literals for methods with expression bodies
Original description:
linter: Refactor prefer_collection_literals to use context type more
There is a basic premise in this rule which we cannot satisfy exactly:
we need to disallow `LinkedHashSet()` unless the context type requires
the developer to use `LinkedHashSet`. But the context type is long
gone when the lint rule is run.
This CL adds some logic to try to attempt figuring out the context
type in the cases where users have filed bugs, but it will never be
super accurate.
Fixes https://github.com/dart-lang/linter/issues/4736
Fixes https://github.com/dart-lang/linter/issues/3057
Fixes https://github.com/dart-lang/linter/issues/1649
Fixes https://github.com/dart-lang/linter/issues/2795
Change-Id: I958ba69a56866c18523ce6cbf62645ef8e028f6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324260
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
We were exporting all symbols to the dynamic table so that they could be looked up using `dladdr` for the profiler and backtracer. The symbols include our statically-linked libcxx, which can create trouble when another DSO has a different version of libcxx. Now we export only the VM embedding API functions (`Dart_*`) and use a specially produced table to do the symbolization.
TEST=runtime/tests/vm/dart/exported_symbols_test.dart
TEST=runtime/tests/vm/dart/symbolized_crash_test.dart
Bug: https://github.com/dart-lang/sdk/issues/53267
Change-Id: I2ee494fba86f67127ba0f6f402622f01a4662207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323702
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
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>
- Avoid Smi tagging for CID checks.
- Use one branch for CID range checks.
dart2js.aot.arm64 20744832 -> 20690216 (-54k)
TEST=ci
Change-Id: I0690bd98774ffc2f24758b1a303c605b57da65b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323231
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>