Once the vm-service isolate starts up it will iterate over all isolates
to discover already started isolates. It does so via iterating over all
isolate groups and all isolates within them. Doing so requires a read
lock.
Until now it has called into Dart while holding the read lock. This can
lead to a deadlock, since calling Dart code can trigger JIT compilation
which can trigger various things that require the same lock.
Instead, this CL accumulates a list of (isolate-main-port, isolate-name)
pairs while iterating over isolate groups and the isolates therein.
Afterwards it registers those isolates in a bulk - without holding any
locks.
Issue https://github.com/dart-lang/sdk/issues/36097
TEST=Refactoring of existing test suite. Fixes flaky timeouts.
Change-Id: Iea7013ce57cef2500700fb464972104c66357777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182321
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Option --write_code_comments_as_synthetic_source_to=file tells AOT
compiler to create a file which contains code comments for all code
objects written into an ELF snapshot and then emit a DWARF line number
program into .debug_line section which attributes code to code comments
in a way similar to how our own disassembler does it.
This enables tools like objdump to display our code comments as part of
the disassembly.
This CL also tweaks ifdefs in such a way that IL printer and code comments
facilities is now included into PRODUCT gen_snapshot binary.
TEST=manually run product build with --print-flow-graph and --write_code_comments_as_synthetic_source_to
Change-Id: Id6741013d43e1733b4ddeb34891a4d2fc06b9313
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181380
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
For microbenchmarking it is good to be able to force VM to drop
all stack overflow checks in a given function to reduce overhead of the
measuring loop to the minimum.
This pragma might have other applications, e.g. to allow writing tight
loops in core libraries.
TEST=CheckStackOverflowElimination_NoInterruptsPragma
Change-Id: I07c7fec5c49a893bbb0e4f557d89f022b90be141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181400
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
When --dwarf-stack-trace option is used, we don't use nor write inlined
functions information to the snapshot. However, we were retaining
Function objects corresponding to inlined functions.
On a large app, AOT-compiled in PRODUCT mode with
--dwarf-stack-traces on arm64:
Function objects in AOT snapshot -19.4%
Heap size used by objects in snapshot -4.45%
Total AOT snapshot size -2.35%
Flutter gallery AOT snapshot size
(release mode with --dwarf-stack-traces):
arm64 -1.1% (gzip -1.3%, brotli -1.4%)
arm -0.95% (gzip -1.2%, brotli -1.4%)
TEST=ci
Change-Id: Id2d7a2d6b6bff1a5929be97477b0e17a9afae475
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181700
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
This statistics is printed with --print_snapshot_sizes_verbose.
It is useful in order to figure out how much memory is consumed by
program structure objects without running an application.
TEST=manual testing with --print_snapshot_sizes_verbose
Change-Id: I6eeae7b303ecaf44806deb0f532058492c1d5808
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181444
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Add safepoint around patching the code.
TEST=existing test suite that runs with --enable-isolate-groups=true
Issue dartbug.com/36097.
Change-Id: I55c2763d71bbe90801b980969055d266d44a673c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181062
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
* Correctly handle _Smi type when producing TTS for it.
Previously it would not correctly establish that an instance
of _Smi is assignable to _Smi causing it to always fall through
into runtime system;
* Correctly handle Null type as a type argument when checking C<Null>
is C<X>, if Null is assignable to X we need to explicitly check if
type argument is Null because cid ranges don't really handle this
check.
* Strengthen the assert checking that TTS specialization succeeded:
check that specialization is (bitwise) different from the previous
version of the stub. If they are equal that means specialization
failed.
TEST=vm/cc/TTS_SubtypeRangeCheck,vm/cc/TTS_Smi
Change-Id: I151a89b52ae07d7e5acce14f59bcb3226bfa1f36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180842
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Previously, deferred imports were really deferred, and the VM would have needed to trigger more loading as part of checking the validity of a reload and handle the re-entrancy of the tag handler and restart the checking a reload: all messy control flow that was side-stepped by just erroring-out. Currently, the language and kernel are incapable of truly deferred imports, so we need only propagate the state bit that checks loadLibrary was called and completed before members are accessed through the deferred prefix.
TEST=deferred_import_reload_test
Bug: https://github.com/dart-lang/sdk/issues/26878
Bug: https://github.com/flutter/flutter/issues/73602
Change-Id: I48bf3e8331630b732d96393e02b12f86de8cc5b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179620
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Inlining will evaluate metadata, which can involve creating constants if the metadata wasn't previously evaluated. We currently can't handle creating new constants in the compiler because we lack a mechanism to trigger the field guard deopts from threads other than the main thread. Compare the general inlining case, which aborts if the inlining candidate wasn't previously compiled (on the main thread).
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/44714
Change-Id: Ib06d5697be6151f373f3242345be49d5c6ec61be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180084
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This CL removes asserts that prevented background compiler from doing class finalization.
It adds program_lock synchronization for when object properties are updated during class finalization.
It also encloses code instructions installation into safepoint scopes to ensure that no code is executed during installation.
Issue https://github.com/dart-lang/sdk/issues/36097
TEST=existing test suite
Change-Id: If297e44f51b187242eca2cdcfff066c8f6386d97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178163
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Field.staticValue has always been able to take a Sentinel as a value but
was not correctly specified in the service spec. Updates the spec and
package:vm_service to allow for this case.
Also fixed an issue where FreeListElement and ForwardingCorpse were
being returned from getClassList.
Fixes https://github.com/dart-lang/sdk/issues/44588
TEST=pkg/vm_service/test/regress_44588_test.dart
Change-Id: I059717657533ff623a70d159a918d63e9e4b6cc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179020
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This fixes an internal test crash where snapshots are compiled
with an x64 toolchain and run on ia32:
`runtime/vm/compiler/backend/il_ia32.cc: 1859: error: unimplemented code`
TEST=tools/test.py -n dartk-linux-debug-ia32 vm/dart_2/causal_stacks/
Change-Id: I9ac652e428e5463926052e0c94c430c86eadd4bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179762
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
As part of making the compiler and other subsystems independent
of `Isolate` we have to move various state from `Isolate` to
`IsolateGroup` (or to another place).
Part of that is `Isolate::reload_context()`. In order to avoid name
conflict of what a `reload_context()` is, we separate it into
`reload_context()` and `program_reload_context()` where the former
contains GC information and the latter contains information about
changes in program structure.
Issue https://github.com/dart-lang/sdk/issues/36097
TEST=Pure refactoring - relying on existing test coverage.
Change-Id: I7e1b732ce8b34c8842718699d618be542bd59ff6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177863
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Currently we have things called XPtr which are not what you get from ptr().
Old world:
handle->raw() returns RawObject* (tagged)
raw_obj->ptr() returns RawObject* (untagged)
After 6fe15f6df9:
handle->raw() returns ObjectPtr
obj_ptr->ptr() returns ObjectLayout*
New world:
handle->ptr() returns ObjectPtr
obj_ptr->untag() returns UntaggedObject*
TEST=ci
Change-Id: I6c7f34014cf20737607caaf84979838300d12df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149367
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
When a function type does not describe the signature of a function (e.g. when it just describes a function type literal), the names of the type parameters are not relevant and can be replaced by canonical names allowing proper canonicalization of type literals.
TEST=fixes upcoming language/nnbd/const/type_literals_test
Change-Id: I62924ef619ae3f5a2fe5964f45c8d60990f3aa69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179060
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>