Commit Graph

13143 Commits

Author SHA1 Message Date
Martin Kustermann ea4b17533c [vm] Call OSThread::Cleanup() during VM shutdown (as with all other Init/Cleanup functions)
Change-Id: I3cfa51714247a62fe39951636ca1a75c34f6c95b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149293
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-05-29 08:02:59 +00:00
Tess Strickland f89d930e38 [vm/aot] Separate out stream methods from the Elf class.
Introduce an internal StreamingWriteStream wrapper and use that instead.

Also add more ELF-defined constants and use those appropriately.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-product-x64-try
Change-Id: I2bd34ebac60e789aea82c8f064c59351e2c55dd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149291
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-05-29 07:47:08 +00:00
Martin Kustermann a2b5373eaa [vm/concurrency] Avoid stopping mutators when updating subtype test cache
To avoid stopping all mutators when updating subtype test caches, we
ensure that any updates to the subtype test cache will be visible in a
consistent way to mutators by adding a store-release barrier when
updating the backing array of the STC.

Since STCs are always grown by allocating a new array with size+1, there
is no need to actually add barriers when accessing the individual
entries of the backing store.

To prevent multiple writers creating STCs and patching the pool or
updating a STC we add a mutex.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Ic705619fe16772565ac11438fd15d3977cbb49c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149164
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-05-29 04:47:22 +00:00
Martin Kustermann 764ebab404 [vm/gc] Ensure to tear down mutator pool of an isolate group before waiting for pending GC tasks
The mutator thread pool can, when it becomes idle, cause idle
notifaction, which can cause GC.

So we should turn down the mutator thread pool before waiting for
outstanding GC tasks.

See b/157612890

Fixes https://github.com/dart-lang/sdk/issues/42098

Change-Id: I1645252377ff07763eef1a00f9c1edff95e34f72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149296
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-29 04:43:08 +00:00
Alexander Markov 4f3293c70e [vm/compiler] Recognize List.filled factory
Recognized factories have known result type and its type arguments
and length are automatically forwarded (length is forwarded only for
fixed-size lists).

List.filled factory is recognized only if optional 'growable' parameter
is not passed.

Fixes https://github.com/dart-lang/sdk/issues/42019

Change-Id: I0d63428f1c4667f3981447a939dbef67170e542e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149385
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-29 03:12:48 +00:00
Ryan Macnak f049a410e5 [vm] Check prefix.loadLibrary is called and returns before prefix members are used.
Not loading is actually deferred.

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: I62688007bd36dbcb2e8ffb4a1fd2dceb1775b1c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149053
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-05-28 23:13:12 +00:00
Martin Kustermann 4c83df8741 [vm/tsan] Fix reported tsan race in message handler test
Closes https://github.com/dart-lang/sdk/issues/42097

Change-Id: I3fb89e18936b3ec95def268cd270ada889e0e9b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149322
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-05-28 17:25:58 +00:00
Martin Kustermann 87ffb0837f [vm] Print isolate group name in stack trace dumping (used e.g. for SEGVs)
Change-Id: I4f94f8e36d5c931c936d90d29ef541bba8f2209e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149282
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-28 16:39:18 +00:00
Vyacheslav Egorov 6ab62add0d [vm/compiler] Use unboxed constants when folding away unboxed ops.
Before this change we would replace unboxed definitions (those with
representation not equal to kTagged) which is too loose and causes issues
in subsequent passes, which assume that replacements have normalised
representation.

After this change we make sure that replacement has a matching
representation.

Closes https://github.com/dart-lang/sdk/issues/35371
Fixes https://github.com/dart-lang/sdk/issues/41971

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I48543893562acf4f8516651196eba7c0c0769a22
Fixed: 35371,41971
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103139
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-05-28 11:30:49 +00:00
Tess Strickland d881462eae [vm/aot] Clean up old assumptions in Serializer::WriteInstructions().
In the past, negative text offsets were used for instructions shared
by multiple code objects. This is no longer the case.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I85085a06b8c955abb21573caea5554e839154979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149281
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-05-28 10:14:18 +00:00
Martin Kustermann 4cf584d4fe [vm/concurrency] Move locks up from Isolate to IsolateGroup
In --enable-isolate group is

  * turned off, then we have 1<->1 mapping between isolate and isolate
    group, so moving the locks should have no impact

  * turned on, then we have N<->1 mapping between isolates and isolate
    group, mutators need to use the same locks to guarantee exclusive
    access (e.g. to symbol table, type canonicalization, type arguments
    canonicalization, ...)

This is a follow-up to share the program structure in AOT mode across
multiple isoltes.

In order to move the existing `Isolate::type_canonicalization_mutex_` to
`IsolateGroup` (and thereby make all mutators use the same lock), we need
to remove the `RunWithMutatorsStopped()` usage in the runtime entry.

  => Without this it can lead to deadlocks.

In order to remove usage of `RunWithMutatorsStopped()` we will change
access to the cached type arguments array to use load-acquire barriers
in generated code and store-release barriers in runtime code.

A nice side effect is that it reduces `sizeof(dart::Isolate)`.

Closes https://github.com/dart-lang/sdk/issues/41912
Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Ifd42691524fe41ffe8bb4e2623c5b8c1151de973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148539
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-27 17:04:30 +00:00
James Lin 10e8d5d1a6 Try to clarify the RangeError.range message
The old RangeError.range message was confusing:

  RangeError (index): Invalid value: Not in range 0..2, inclusive: 9

The comma makes the message hard to parse.  I've seen a number of
people misinterpret "inclusive" as describing the invalid value (9)
instead of acting as a modifier on the range.

https://github.com/dart-lang/sdk/issues/29586 has a lot of
bikeshedding about this, but in the interest of mitigating confusion
sooner, I propose changing it to:

  RangeError (index): Invalid value: Not in inclusive range 0..2: 9

I'm intentionally trying to improve the message with minimal
disruption to the structure of the error message.  Although I'd much
prefer that "Invalid value" and the actual value be adjacent instead
of being interrupted by the explanation, such restructuring is rather
non-trivial.  RangeError allows the "Invalid value" message to be
customized, and rearranging terms could produce even worse
constructions.

I also considered:

  RangeError (index): Invalid value: Not in range [0, 2]: 9

And while I like that that is brief and clear, I chose not to use it
for people who are unfamiliar with interval notation and who might
mistake it as a Dart List.

Bug: https://github.com/dart-lang/sdk/issues/29586
Change-Id: I0f23b195437e4053ae5f76b5d303123979a8c9fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146024
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2020-05-27 14:59:39 +00:00
Clement Skau 205ba04c5e [SDK][Gardening] Fixes profiler_test broken in c4b7097e.
Test Profiler_ArrayAllocation used the non-existing List.empty()
constuctor.
This fix replaces it with the semantic equivalent List.filled(..).

TBR:bkonyi

Change-Id: I70913803a4d3585cb19a39375b14c1184f047644
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149160
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2020-05-27 13:33:09 +00:00
Vyacheslav Egorov b95a1bd567 [vm/aot] Clean static fields handling in precompiler.cc
Instead of maintaining separate list of static fields which
needs to be flushed into list of retained fields in Iterate()
keep track of which precompilation phase we are in - and add static
fields into the retained set only if we are in the fixpoint
code generation (aka Iterate()) phase.

Apply the same treatment to selectors as well.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I2c7c7bdf268eaee9623ab1be5cf3eb022991a7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148403
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-05-27 10:22:19 +00:00
Vyacheslav Egorov 7175ab7329 [vm/compiler] Fix code determining if object can be a smi in LoadClassId.
Previous variant of the code did not handle FutureOr<T> and Comparable<U>
correctly - variables of these types can contain a smi value if T can be a
subclass of num or if U can be num.

Rename HasNonSmiAssignableInterface to CanReceiverBeSmiBasedOnInterfaceTarget
to better conway its meaning.

Fixes https://github.com/flutter/flutter/issues/57398

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I67b29908e057632e62c46fb327a5c805fcc78d74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149063
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-27 10:06:49 +00:00
Alexander Markov 2ec934d267 [vm] Fix crash on trampolines in --print_instructions_sizes_to
Trampolines which are generated in use_bare_instructions mode should be
taken into account when dumping sizes in --print_instructions_sizes_to.

This change fixes failing pkg/vm/test/snapshot/instruction_sizes_test on
Windows after https://dart-review.googlesource.com/c/sdk/+/148543.

Change-Id: I343f82699407ba54d9ccb9a9800875c61a6e8df3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149043
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-26 23:14:32 +00:00
Ben Konyi c4b7097e97 [ VM ] Migrate VM tests to support null safety and return errors from Dart_GetType and Dart_NewListOf when --null-safety is enabled
These methods return legacy types, which aren't valid with null safety
enabled.

Fixes https://github.com/dart-lang/sdk/issues/41154

Change-Id: I1181f0f3b9a8df156dea4dc4c82fef8afdf97ab9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148685
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-26 22:40:52 +00:00
Alexander Markov db063ea6d0 [vm/compiler] Remove redundant phis during canonicalization
It might be too late to remove redundant phis in EliminateDeadPhis
because EliminateDeadPhis runs after OptimizeBranches, and
OptimizeBranches may be able to eliminate more branches if redundant
phis are cleaned up.

This change moves elimination of redundant phis into canonicalization
pass which is repeated more frequently.

Fixes recent regressions on several micro-benchmarks after
https://dart-review.googlesource.com/c/sdk/+/139314

Change-Id: Ib0148564615dbd0adb88e93b938ca9f3f59cabfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148792
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-26 17:59:38 +00:00
Alexander Markov 572905d1e9 [vm] Fix crash in disassembler on trampolines
Fixes https://github.com/dart-lang/sdk/issues/42017

Change-Id: I7d9f2694907be2ba673f35c82ce65a4ee8bc77b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148942
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-26 17:31:58 +00:00
Vyacheslav Egorov ff6757f380 [vm/snapshot] Improve precision of --write-v8-snapshot-profile-to.
Attribute bytes written outside of any particular object to the
artificial root node.

https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I6d4be9b9a6a42cd0996330bb14552d12d6430ff9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148526
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-05-26 10:46:05 +00:00
Tess Strickland 826576dcfc [vm] Store relocated addresses for text sections in BSS.
The relocated addresses are populated during BSS::Initialize() for
natively loaded ELF snapshots, and during the non-native loader when it
is used. Putting this information in the BSS segment avoids having to
change the embedder interface, since we only need this information for
AOT snapshots. This also avoids depending on our ELF snapshot layout
to reverse-engineer the DSO base for ELF-compiled snapshots.

We now always print the DSO base for both the VM and isolate in
non-symbolic stack traces, not just for ELF-compiled snapshots. However,
we still only print the relocated addresses in individual stack frames
if we're guaranteed they match those in separately saved debugging
information.

Bug: https://github.com/dart-lang/sdk/issues/41880

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-mac-release-simarm64-try
Change-Id: I4837262f78e6e73a32eb7e24ef7a68ccb8ec2669
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148441
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-26 08:47:30 +00:00
Jens Johansen 857fca710f [kernel/VM] Fix 'infinite' loop with memory crash on specific invalid dill
The dill file has an index at the end. The last 4 bytes of that index is
a size that indicates how big the file is. This is done to support
concatenated dill files. If the dill is invalid and the size is read as 0
both the VM and the dart kernel reader will go into an infinite loop where
it allocates another list entry on every loop iteration (making the whole
loop not infinate because we will run out of ram soon enough).

This CL fixes the issue by checking the size to be possitive.

Change-Id: I42da0557c6d4a274fdbe1a729fdaf5b8f149b187
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148538
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-05-26 08:24:05 +00:00
Aske Simon Christensen 81ad24322c [vm/compiler] Check BoxInt64 overflow via the overflow flag on ARM64.
This saves one instruction for every BoxInt64 overflow check, reducing
the instructions size for Flutter benchmarks by between 0.26% and 1.03%
(0.26% for Flutter Gallery).

Also add OVERFLOW and NO_OVERFLOW condition aliases to arm and arm64.

Change-Id: I82990419b448f21a22ea2cc7a15a9497d3275943
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145860
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-20 14:05:40 +00:00
Vyacheslav Egorov a7e8fe2061 [vm] Write some nodes into profile even if they were dropped from the snapshot.
Snapshots don't necessarily retain original program structure because we
attempt to drop objects representing elements of the program structure
when it is not observable. However not having this information makes it
harder to understand how various parts of the snapshot graph relate to
the original program.

This CL introduces support for writing artificial nodes into snapshot profile
for the cases when we want to preserve some structure for later analysis.

To make mapping between actual heap objects and their artificial profile
counterparts simple we use currently unutilized part of the object-id space:
negative ids below kUnallocatedReference.

https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: Idb46491b0e2b21aebf946b0da55eaf67e73aadd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148530
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-20 12:35:22 +00:00
linzj d2ee73b251 [vm/compiler] Fix liveness analysis for unboxed parameters on 32-bit.
Fixes https://github.com/dart-lang/sdk/issues/41977

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-debug-simarm_x64-try
Change-Id: Ifcba1aac8e23aa382bdafe7506ce1725b8f2221d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148602
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-05-20 08:42:21 +00:00
Tess Strickland 71a8a3c11a [vm] Print DSO base of isolate when available.
Bug: https://github.com/dart-lang/sdk/issues/41880

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-win-release-x64-try
Change-Id: Ie68248a81167dfe05cbe65960fac8a8e029b9db3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147907
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-20 08:14:52 +00:00
Alexander Markov fef83c96fc [vm] Report compile-time errors when loading bootstrap libraries from kernel
Previously, we were crashing when trying to report a compile-time
error via H.ReportError when loading a bootstrap library from kernel.
That happened because we didn't have LongJumpScope set up.

This change sets up LongJumpScope and makes sure compile-time
errors during kernel loading can be reported and propagated up.

This also removes the need to use FATAL error when detecting
a dill file which is incompatible to the current runtime mode,
so we can use less severe compile-time error for that.

Fixes https://github.com/dart-lang/sdk/issues/41870

Change-Id: Ib3690f7812c20e5529f3066ed37fdb9052dd559b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148683
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-20 02:14:21 +00:00
P.Y. Laligand 65f132afe7 [fuchsia] Update more trace-engine/trace labels.
Change-Id: I19c165a42d199e1ea314aad00b212b2990745dba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148544
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-20 01:33:21 +00:00
Regis Crelier 19f49509b0 [VM/nnbd] The equivalent of dynamic as bound is Object? and not Object.
This is a partial fix for https://github.com/dart-lang/sdk/issues/41939

Let's take one step at a time, but later, we should be able to leave the bound as dynamic, since mutual subtyping of bounds is now implemented.

Change-Id: I57f725ba5b02237a64ae77593f340438f7159ab7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148515
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-05-19 18:10:54 +00:00
Ryan Macnak 2fa4d3e4d8 [vm, gc] Account for AllocateArray or CloneContext returning objects that have already been added to the remembered set.
Bug: b/156940113
Change-Id: Id212f9826b83981346ea4fbb1ef80a115e831a10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148506
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-19 17:47:11 +00:00
Ryan Macnak 41caebb39e [vm] Fix overly broad HeapIterationScope in getInstances.
Fix nested HeapIterationScopes.

Fix inadvertently disabled UI for getInstances.

Bug: https://github.com/dart-lang/sdk/issues/41943
Change-Id: I09fa385246dda7427a4f51a02144f945ec638557
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148502
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-19 17:37:10 +00:00
Martin Kustermann 7706afbcf5 [vm/concurrency] Optimize access to symbol table & remove isolate-specific symbol lock.
The most common case is to access the symbol table in read-only mode
outside a safepoint. This CL ensures that this use case is fast.

Furthermore it fixes a potential issue where one thread accesses the
symbol table using exclusive access via RW lock and is half-way-through
updating the symbol table while another thread requests a safepoint
operation, and updates the symbol table.

There is a remaining TODO item to not hold a safepoint while allocating
a symbol.

It increases performance by 10x for e.g. vm/dart/isolates/fibonacci_call_test
(26 seconds to 2.6 seconds).

Issue https://github.com/dart-lang/sdk/issues/36097
Issue https://github.com/dart-lang/sdk/issues/41943

Change-Id: I0b4e26aaffc613bed336a8845d12b7c7ee84b146
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148323
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-05-19 12:10:20 +00:00
Regis Crelier 5f9e3e0791 [vm] Hash of generic signature should include hash of its type parameters.
Change-Id: If77e8c55ae72e8fd18de167a736d7efe3c3193ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148185
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-05-19 01:11:52 +00:00
Ryan Macnak 6851c0eca3 Reland "[vm, gc] Allow for more parallelism in old-space GCs."
Fix visiting roots to wait for visiting new-space pages to finish, not merely start.

Change-Id: I0c6688701f4563bf5c3b8ae02f215e709d5cac6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148230
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-18 21:19:26 +00:00
Martin Kustermann 4477712ba0 [vm/compiler] Add regression test for many unboxed fields
The GC was sometimes incorrectly calculating the "is-unboxed" bit due to
shifter >= 64. The change in [0] fixed that issue and this CL is adding a
regresion test.

Our tests in `runtime/tests/vm/dart/*` have access to `dart:_internal`.
To make the newly added test reliable we add a `collectAllGarbage()` native
and use it in the test.

[0] https://dart-review.googlesource.com/c/sdk/+/143000

Change-Id: Ifb3f16469a9dc58623acdb029b78807ed7fcc857
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148402
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-18 11:30:57 +00:00
zhaoxuyang 313bf285df [vm/arm] Fix DecodeLoadWordFromPool with large offsets.
Previous version of the code did not correctly decode sequences like:

  movw r9, #0x6000
  movt r9, #0x10
  add r9, pp, r9
  ldr r9, [r9, #+3983]

Closes https://github.com/dart-lang/sdk/pull/41937
https://github.com/dart-lang/sdk/pull/41937

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-simarm-try
GitOrigin-RevId: 95cd97c57aa3025875ad89656e267821bc4e0ee1
Change-Id: I7f8b9cb8c9d703fe2ac0774749ab24fd8183b0d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148340
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-17 12:43:48 +00:00
Martin Kustermann ecd82166c3 [vm/concurrency] Avoid allocating objects if not needed (and possibly cache objects)
Two growable arrays needed for possibly re-hashing objects when sending
messages using the snappshotter are often unused. Only create them when
needed.

When looking up message handler and calling it avoid repeated
allocations of small arrays (they can be cached savely because right
the transition stubs will copy the arguments out of those arrays).

This improves performance of high-frequency messages but small message
handlers.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: I623aba5b29064f3a75ea294557ee153067a63d08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148263
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-05-16 06:45:02 +00:00
P.Y. Laligand db75896497 [fuchsia] Update label for trace-engine library.
Change-Id: I4b30ebb576e64d0b2448a815fb5f5cee2bc5655b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148235
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-16 00:04:22 +00:00
Ben Konyi 54fb6ce3c0 [ Service / DDS ] Prepare for package:dds publishing
Final cleanup work before first full version of package:dds is
published:

- Added `getSupportedProtocols` RPC to the VM service protocol, which returns a
  list of supported service protocols and extensions along with their version
  information.
- Added `getDartDevelopmentServiceVersion` RPC to the DDS protocol.
- Misc code and dependency cleanup recommended by pub

Change-Id: If1bdf46852778adf31242122665c36b63106ad44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148224
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-05-15 22:52:12 +00:00
Ryan Macnak 6b91f92154 [vm] Move megamorphic miss handling into the megamorphic call stub.
This removes the only stub code with a function owner.

Change-Id: I629eb3a1b231430afaf0a2777032bba8eaddd2aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148124
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-05-15 20:28:21 +00:00
Martin Kustermann e30646d9a3 [vm] Fix member-call-on-null ubsan issue
This is a follow up to: https://dart-review.googlesource.com/c/sdk/+/148120

Change-Id: Ibc5f59ae1d1ec13efb15f5d8cc4eae5e1848b083
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148134
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-05-15 12:58:32 +00:00
Martin Kustermann 143c1b9dac [vm/concurrency] Ensure VM behaves well if custom embedder uses custom message handler with unlimited number of threads
If a custom embedder does not use the VM's thread pool implementation
(1) but instead installs a custom message handler and invokes that
message handler on possibly unlimted number of threads, those mutator
threads will be constantly fighting to obtain TLABs.

To avoid this, the VM will ensure that only a limited number of mutators
can execute at the same time. The limit is the same as we use for
determining the VM's mutator thread pool.

In order to test this, we simulate such an embedder by disabling the
mutator pool limit, thereby allowing unlimited number of thread pool
workers.
=> The added test would timeout without without the new limit imposed
   by this CL.

(1) Which has a maximum size adjusted based on TLAB size and new space size.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: I6d459f85fbeb3e4b1d756b752853157e40097271
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148121
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-15 12:43:12 +00:00
Tess Strickland 7aae1f6032 [vm] Relax AssertSubtype to allow non-constant sub and super types.
Previously, AssertSubtype instructions could only be created with a
compile-time AbstractType value for sub_type and super_type. Relax this
so that AssertSubtype instructions can be created with possibly
non-constant Values instead.

Currently, all AssertSubtype uses still have constant sub- and
supertypes, so for now we check at code generation that we indeed
have constants for these values and only handle the constant case. Thus,
there should be no impact on size or speed of the generated code from
these changes. Follow-up work will add code generation for non-constant
sub- and supertypes and add uses the generalized form.

Bug: https://github.com/dart-lang/sdk/issues/40813

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: Ib1512b3e07a016d68a8e0c670ce857b8ac1b2777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147520
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-15 11:51:32 +00:00
Martin Kustermann 874588a859 [vm/concurrency] Allow thread pool with maximum size to grow in size if workers are blocked in native code
To avoid deadlock scenarios where an application runs N isolates on a
thread pool with T threads (T < N) where all scheduled T isolates will
do FFI call and block. That prevents any other isolates from executing.

To avoid such a scenario we add support for the isolate-group specific
thread pool to dynamically increase the maximum size if a worker is
running a isolate mutator thread, which calls to C which exits the
isolate.
=> While such an isolate is descheduled but still occupies a thread
   pool worker we temporarily incrase the maximum size of the thread pool.

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: Id61c39b06766da11f76d607ac7cbe8a8e623f250
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148120
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-15 10:57:09 +00:00
William Hesse a7b672c069 Revert "[vm, gc] Allow for more parallelism in old-space GCs."
This reverts commit ae0740032a.

Reason for revert: This is crashing on mac-release.

Crash logs: https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8880254409914739888/+/steps/test_results/0/logs/new_test_failures__logs_/0


Original change's description:
> [vm, gc] Allow for more parallelism in old-space GCs.
>
> Allow work stealing of new-space page when marking roots.
>
> Change-Id: I18fc22934bea26a37341216e88b13d1fb6f83b36
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125767
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=kustermann@google.com,aam@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I84c27cdd73a971f893ec968daaf5893c62c3a2e5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148129
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-15 09:11:06 +00:00
Alexander Aprelev 2472741ba0 [vm] Fix instance hash calculation to accommodate unboxed fields during cross compilation.
Instance hash calculation on host and on target should produce same
results(like when you use simarm_x64/gen_snapshot to produce arm snapshot).
It was not producing same results because of how unboxed fields could be
taking more than one word(on 32-bit arm they are taking two words).
Hash calculation was done in terms of words so simarm_x64/gen_snapshot
saw one word unboxed field, but same calculation saw two words.

The fix is to pay special attention when iterating over unboxed field
during hash calculation and accommodate host and target word size
difference.

Fixes https://github.com/dart-lang/sdk/issues/41824.

Change-Id: Ib280736fa458a3954ca1f9994734ad04ee8db80a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148040
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-15 01:28:55 +00:00
Ryan Macnak ae0740032a [vm, gc] Allow for more parallelism in old-space GCs.
Allow work stealing of new-space page when marking roots.

Change-Id: I18fc22934bea26a37341216e88b13d1fb6f83b36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125767
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-15 00:44:45 +00:00
Alexander Markov 85cb6eddf4 [vm/nnbd] Auto-detect null safety mode when bootstrapping from kernel
This change also enables auto-detection in gen_snapshot.

Issue: https://github.com/dart-lang/sdk/issues/41206
Change-Id: If047ab8457e8fa15dc24ec10c0dcfceaf836508a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148152
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-14 20:49:06 +00:00
Ryan Macnak a1ad5c7aa5 [vm] Further fix asymmetry in Load/StoreNonPointer.
Bug: https://github.com/dart-lang/sdk/issues/41581
Change-Id: Icee799d1e401eee84d9a337a9124826f91fa5b1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148022
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-14 18:26:03 +00:00
Clement Skau e29407cde2 [VM] Removes parameter type check for sync-yielding function.
Benchmarks:
- RunTime (bigger is better):
  - Iteration.tree.syncstar(ia32): +8%
  - Iteration.concat.syncstar(ia32): +10%
  - Iteration.tree.syncstar(x64): +4%
  - Iteration.concat.syncstar(x64): +5%

Bug: https://github.com/dart-lang/sdk/issues/37753
Change-Id: I9203560b9ceb0f2dcc1583d88ea95b7d88b628d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146780
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-14 17:18:56 +00:00