When we just search, it is enough to know that there is just any
reference kind, however wheb I attempted to implemented rename
refactoring, I realized that we need to know if the reference is
from a ConstructorReference, so `.new` is required.
I think this change will let us do this, however I still have not
tried to actually wire it, so might still be wrong.
Change-Id: Ie97e23d391ea89d7f3695663368835e747cbeee5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212546
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
The check for number of isolates was racy because isolates might be exiting, number of isolates in the group going down as we enter ic cache miss runtime handler.
This caused flaky failures on debug buildbots.
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/47132
Change-Id: Ie78a80fecb30d2cc40635acd465078cb0f22a234
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212487
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
The new space allocated objects created by transitive object copy are
themselves always GC safe. If an invalid object is encountered and the
copy is aborted, there will be unreachable, allocated new space objects
left, that the next scavenge will reclaim.
If an object in the heap is unreachable it shouldn't really be touched
(not even by GC). Only heap iterations can possibly look at them.
Turns out that hot reload performs heap iterations without collecting
all garbage first. That means it can encounter such an unreachable
object.
Hot reload assumes that it can (for instances of generic classes) always
get a valid TypeArguments vector (or null) - though it encountered 0
instead.
So there's several solutions:
* Make Hot-Reload only work on actually alive objects.
* Make the unreachable objects have null instead of 0 in them
We'll choose the latter and use the existing Object::InitializeObject()
helper method (although it will be slower than the existing
implementation).
Fixes https://github.com/dart-lang/sdk/issues/47131
TEST=Fixes vm/dart_2/isolates/closures_without_captured_variables_test in hot-reload test mode.
Change-Id: I15d48473f0ce4a856316fe24166e81ebc87ccdbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212585
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This CL re-enables (except on platforms that don't support them):
Language/Libraries_and_Scripts/Scripts/top_level_main_t01
Language/Expressions/Numbers/syntax_t34
Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I10a1b1c9abc125c000cc9e9ba7d749b8766e193d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212563
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Change-Id: I73bfdd310af6df6cc1d62311e155fc432b84165d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212567
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
This CL changes the frontend to emit map and set constants which are
then processed by the constant reader in the VM.
This CL also introduces support for sending the const maps and sets
in messages between isolates and saving it in snapshots.
TEST=tests/language/const/map_test.dart (et al, for lookups)
TEST=tests/lib/isolate/message3_test.dart (et al, for isolate messages)
TEST=tools/test.py -c dartkp (for consts from clustered snapshot)
TEST=tools/test.py -n app_jitk-linux-debug-x64 (for consts from app
jit snapshots)
TEST=Building the SDK which uses const Maps in clustered snapshots.
Closes: https://github.com/dart-lang/sdk/issues/45908
Change-Id: I1f8150a8aba8298c4e64d2571dd147743526135a
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203765
Reviewed-by: Martin Kustermann <kustermann@google.com>
This CL introduces immutable maps and sets in the VM backend but does
not yet target them from the frontend. The changes are tested by unit
tests constructing these immutable maps and sets.
This CL introduces immutable variants of the hash map and set in
compact_hash.dart and recognizes them in the VM. The immutable ones
use a different mixin with a different recognized method for accessing
members.
* Data list is an immutable list with a different cid. (Otherwise the
optimizer notices that immutable and mutable lists cannot be equal.)
* Index is a nullable mutable typed data. (Otherwise optimizer removes
necessary null checks.)
* Index should use a store-release barrier when written to.
Multiple isolates might lazily compute the index for const sets and
maps. This is fine because all identityHashCodes and hashCodes are
guaranteed to be race-free. The later isolates will override the index
pointer with an identical index.
This CL does not introduce support for using these immutable maps and
sets in AOT (clustered_snapshot) and in messages to other isolates
(message_snapshot) because that is harder to test with unit tests. That
will be added in the follow-up CL.
Design doc: go/dart-vm-const-maps
TEST=runtime/vm/object_test.cc
Bug: https://github.com/dart-lang/sdk/issues/45908
Change-Id: I4042179c15e8b37692d3255655351c01c7124991
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210860
Reviewed-by: Martin Kustermann <kustermann@google.com>
In dependent CL, const maps and sets can be shared between isolates in
the same isolate group before the index is lazily populated. To prevent
one isolate from seeing a non-null index pointer, while not all writes
to the index itself are visible to the isolate (the mutator thread of
that isolate), we use a store release barrier on arm architectures.
This CL adds a store release barrier option to the StoreInstanceField
instruction to be used in the dependent CL.
Even though there is no barrier on x64 and ia32, we still also use the
option on these architectures because on x64 we signal the barrier to
TSAN.
The stlr instruction on arm64 does not feature an address operand.
Therefore we need to branch in the assembler on whether we're using
a store-release before we construct an Address.
Design doc: go/dart-vm-const-maps
TEST=Dependent CL, split off for ease of reviewing.
Bug: https://github.com/dart-lang/sdk/issues/45908
Change-Id: I6563aa3c813319a23e815b862ca5caabb805dc9e
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210726
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Before: `NoSuchMethodError: The method 'FfiTrampoline' was called on
null.`
After: `Invalid argument(s): argument value for ':ffi_param2' is null`.
Makes the ArgumentNullError RTE lookup the name of the argument in the
code source map when reporting a null argument.
Makes the FFI call arguments and FFI callbacks use kArgumentError
instead of the default kNoSuchMethod so that we target this RTE instead.
This changes the Error type from `NoSuchMethodError` to `ArgumentError`.
Because `Error`s should not be caught [1], this is fine.
Since FFI trampolines are created from type arguments, the arguments do
not have names. The arguments are assigned names programmatically. See
the related bug.
Also, this CL cleans up the SourcePosition of the `CheckNullOptimized`,
it was never passed.
[1] https://dart.dev/guides/language/effective-dart/usage#dont-explicitly-catch-error-or-types-that-implement-it
TEST=tests/ffi/function_test.dart
Closes: https://github.com/dart-lang/sdk/issues/47094
Bug: https://github.com/dart-lang/sdk/issues/36780
Change-Id: I15e7de4d026e034bde0eda3ba7fe3785f0da5057
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,app-kernel-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212462
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
We already allow sending closures (if immutable via sharing
otherwise via copying). This CL makes use of this to allow the argument
to `Isolate.spawn()` to be any closure.
Similar to normal message sending, the spawn will fail if the closure
cannot be sent (or causes an error on the new isolate, e.g. rehashing
error).
Issue https://github.com/dart-lang/sdk/issues/46623
TEST=vm/dart{_2,}/isolates/closure_entrypoint_test
Change-Id: Iab342267d87bd87bc8c0c82d16aec58a69a3df44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212295
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
When several isolates share same isolate group, they share the same heap.
This change iterates over isolate groups and aggregates their heap size instead of iterating over isolates.
Change-Id: I83b04110277b3a2d22ab758b50ee8c4ce480ea7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212382
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
* Update tearoff runtime equality algorithm with newly specified
requirements.
* Update kernel golden files for the dartdevc target to include
the static method lowering for constructor tearoffs.
* Avoid adding source maps and debug symbols to the static methods
created by the CFE lowering.
* Add additional expected non-nullable values detected in the
nullable inference tests. These correspond to the values that
appear in the static method return statements.
Measurements taken from large applications show the lowering causes
a code size increase of 2.5%-3.5%. That increase did not appear to
create any measurable difference in initial page load time but if
there turns out to be a regression we can revisit each of the various
lowerings to implement support in DDC at the site where the constructor
is torn off.
Fixes: https://github.com/dart-lang/sdk/issues/46486
Fixes: https://github.com/dart-lang/sdk/issues/46837
Change-Id: I01fa39d4f1d0e937919dd1466bb6a34c91a10e75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206960
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
loaded_blobs need to be visited as part of IsolateGroup::Visit method rather than Isolate::Visit one.
Before this change loaded_blobs could become corrupted because GC requires objects being visited only once during collection cycles.
Fixes https://github.com/flutter/flutter/issues/89406
TEST=ci, flutter
Change-Id: Ic61498c205c5cc072e5f45928264a507a7752e0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212440
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Also update some TODOs.
Change-Id: I02c883e717a3315892a99879ef45aba804183c86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
The destructor of [IsolateSpawnState] might call destructors on
[Message] which may want to delete persistent handles. Doing so requires
an active isolate group.
This CL ensure that in shutdown races (main isolate exists which
triggers VM shutdown, helper islate is about to start but fails to start
due to VM shutdown request), we still ensure to properly delete the
persistent handles.
TEST=Fixes vm/dart_2/spawn_shutdown_test/0 on app-jit configurations.
Change-Id: I0c3e0ceca7faab36f298953dabb1ccae3a0ecc8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212464
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
The allocation routine for allocating context objects (used for copying
closures) has to use uncompressed mode - since [Context] objects aren't
compressed yet.
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/209110
TEST=Fixes closure tests in vm/dart_2/isolates/fast_object_copy2_test/<num> in compressed mode.
Change-Id: I3a16701fe662ff7ea501a238653c7efb376cda55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212465
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
As a side-effect of making closures without captured variables have an
empty context, we not only avoid a memory leak, but also allow such
closures to be sent across [SendPort]s.
Issue https://github.com/dart-lang/sdk/issues/36983
Issue https://github.com/dart-lang/sdk/issues/45603
TEST=vm/dart{_2,}/isolates/closures_without_captured_variables_test
Change-Id: I5e8845203059ff625f7cff3f072d845b5e48ba36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212297
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-03 sgrekhov@unipro.ru Fixes 1187. Roll failures fixed
Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I168b3dff190ea889eba23aad0159a5d130251718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212463
Auto-Submit: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Now that support for native extensions (aka dart-ext:*) has been
removed, the kernel loader is guaranteed not to call out to embedder
anymore (it did so before for loading shared libraries).
This allos us to clean up some code as well as extend the scope of our
NoActiveIsolateScope.
TEST=ci
Change-Id: I5c8c9ee47298fdd316583ba3aed74772c1c7783f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212296
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>