This fixes a huge performance regression (introduced in [0]) of a
synthetic microbenchmark - MicroClosureCreateTearoffClassSecondTime -
that happens to have a gigantic function with a large number of call
sites in them.
All of those call sites stay monomorphic but all of them will have to
go to runtime for miss handler because the target code was disabled (the
unoptimized code got disabled, since optimized target code was
installed). The particular target function in question is
`_GrowableArray.add()`.
The cause for the regression is that the miss handler will lookup the
ICData based on linearly walking PcDescriptors to find deopt-id which it
uses to get ICData from function's ic-data array.
Interestingly enough it only regresses ia32 but not x64 (the only two
architectures this benchmark is run on). The reason for that is that
x64 uses exactness tracking and therefore doesn't switch to
monomorphic calls.
This CL:
If a monomorphic call site had a miss because the cached old target
was disabled, we go to runtime to find the real target. Another thread
may have transitioned the call site already from monomorphic to
polymorphic.
When resolving the target function we take advantage of a back reference
from the `ICData::entries()` back to the `ICData` to avoid the O(N)
lookups.
[0] https://dart-review.googlesource.com/c/sdk/+/206373
TEST=Existing test suite.
Change-Id: Ia066a846f5f50e5a575f0734c9453d2368f80780
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207133
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This does not handle more specific function types (those represented
using FunctionType objects), but just Type::DartFunctionType().
TEST=vm/cc/TTS_Function
Change-Id: I42ddd8818da5331eed748784b051cd2c78547b5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209703
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Previously, the code in the TypeCheck runtime entry assumed that if a
lazily specialized type testing stub (TTS) returned a false negative in
JIT mode, that it should always be regenerated and that regeneration
would always result in different code. In AOT mode, false negatives
instead always cause the stub to go to runtime, even if that false
negative had been seen before, because the assumption is that false
negatives shouldn't happen when the whole class hierarchy is known at
compile time.
However, even in the current implementation of optimized TTSes, there
are cases where this assumption is false. For example, the code
generated by BuildOptimizedSubclassRangeCheckWithTypeArguments allows
for provided type arguments to be type parameters. When this happens,
the type parameter is instantiated at runtime using the instantiator or
function type arguments, and the instantiated type parameter must be
identical to the result retrieved from the type arguments of the
instance. That means that if the instantiated type parameter is not the
same type, but a supertype, of the result, then a false negative is
generated.
This CL changes TypeCheck's handling of false negatives from lazily
specialized TTSes as follows: in JIT, if the regenerated stub is the
same as the old stub, or in AOT, a false negative causes the same fall
back to SubtypeTestCaches as unoptimized stubs. This way, further
checks with the same false negative will be caught via the STC before
going to runtime, assuming the STC hasn't already filled up with false
negatives.
Currently, we only generate false negatives for reasons that will not
change when respecialization occurs due to additions to the hierarchy,
so we do not need to clear affected STCs during respecialization.
However, the previous approach to resetting STCs on reload (in
CallSiteResetter::ResetCaches) is insufficient, since there may be
caches containing reloaded types in non-reloaded code (like the TTS
invoker stub created by the TTS testing framework). Instead, clear
all caches on reload using the same ObjectVisitor as deoptimizing type
testing stubs.
Since we now have to check instruction equality to determine whether
to add to the STC, we now only replace the existing stub if the
instructions are different. This makes it easier to test whether a
TTS invocation on a false positive caused respecialization or not.
This CL also reworks the testing framework for type testing stubs,
1) creating a test case object that stores the particulars of a given
invocation, including expectations, and 2) moving most checks and
access to appropriate data structures into a state object that handles
setup and performing invocations given test cases.
TEST=vm/cc/TTS_Partial
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try
Change-Id: I139608c5a0f2442a85a1cf39d1c04104db7a5593
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208653
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
The transitive copy algorithm was missing support for [WeakProperty]s,
thereby ensuring that we only copy the values if the keys are reachable.
Furthermore we might need to re-hash [Expando]s - since the copied
objects start with no identity hash codes.
The CL also makes us avoid calling to Dart for each [Expando]
separately and instead use a list - just as we do in the re-hashing of
maps/sets.
We also move the C++ code to invoke rehashing logic into
DartLibraryCalls::*.
Issue https://github.com/dart-lang/sdk/issues/36097
TEST=vm/dart{,_2}/isolates/fast_object_copy{,2}_test
Change-Id: I836745feef8a6d7573faa94e29a19c1eca0c39f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209106
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
HashTable<..., GrowableArrayStorageTraits> passes the zone to placement-new of GrowableArrayStorageTraits::Array. Because this class did not extend ZoneAllocated, the default placement-new interpreted the zone as the allocated address and clobbered the beginning of the zone.
TEST=build
Change-Id: I95805e00b3012f5282f11cfb6da1567f00d56c46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208982
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
- Delete the port set during cleanup while holding the lock
- Check for port set being valid in every function that accesses
the port set to avoid racy access while the VM is shutting
down (e.g: Dart_InvokeVMServiceMethod)
TEST=ci
Change-Id: Ib5c3a6a36260820c040304d03fdc49558dae611b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208983
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This brings the native port deserializer into agreement with the native port serializer and the interpretation of TypedData::length_.
TEST=ci
Change-Id: I52eb28af7292fc15b0ad4779dc4d4e723f6e128b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208283
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This reverts commit 1796160606.
Reason for revert: Still seeing failures.
Original change's description:
> Reland "[ package:dds ] Add support for caching CPU samples based on UserTag"
>
> This reverts commit 4160747ef6.
>
> It seems like 9397b8ff05 should have fixed the original failures we were seeing and the failing bots in question seem to be passing when running try jobs.
>
> TBR=asiva@ (discussed offline)
>
> TEST=Existing service tests + get_cached_cpu_samples_test
> Change-Id: I1c50c0e79375df819a0bd68e68ac28c3064874c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208441
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>
TBR=bkonyi@google.com,asiva@google.com
Change-Id: Ic522ab61b430673533c94ecd0c91bee569a0add6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208960
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Combines one and two byte string serialization into a unified
string serialization cluster that's built on CanonicalSet
serialization. This approach is already used when serializing
to RO data, but we can't use RO data in compressed mode.
Change-Id: I28b2473efbc855c0d30fa9ec39fa9c6d42dc2b67
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208022
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This reverts commit 4160747ef6.
It seems like 9397b8ff05 should have fixed the original failures we were seeing and the failing bots in question seem to be passing when running try jobs.
TBR=asiva@ (discussed offline)
TEST=Existing service tests + get_cached_cpu_samples_test
Change-Id: I1c50c0e79375df819a0bd68e68ac28c3064874c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208441
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
All handles passed to IL instructions should be ZoneHandles.
Recently added code for generating constructor tear-offs has been
passing Handle instead of ZoneHandle by mistake.
This change fixes the bug and adds assertions to AllocateObjectInstr so
it would check handle type earlier and on all platforms.
TEST=co19/LanguageFeatures/Constructor-tear-offs in debug/ia32 mode
Issue https://github.com/dart-lang/sdk/issues/46231
Change-Id: I99e6889e59bf40f4788a7f3c6d37dad89aa91ab0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208686
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Both SampleBlock::ReserveAllocationSample and
SampleBlock::ReserveCPUSample can return nullptr, so that needs to be
appropriately handled in SampleBlock::ReserveSampleAndLink. The only
caller of the latter checks for nullptr, so pass though nullptr results
from the former methods.
TEST=Fixes current service tests failures on some trybots,
see test results on CL.
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-ia32-try,app-kernel-linux-debug-x64-try
Change-Id: Ib70cc6726862bc5fe3bfb0c06ee2aae84ec026c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208321
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Adds GetNativeField(o,i) to access NativeFieldWrapperClass{1-4}
native fields directly in Dart instead of through VM API.
This will allow us to pass `this` as a raw pointer instead of as
a Dart handle which needs to be unwrapped.
This will in turn allow ffi native calls for instance methods.
TEST=Adds vm/cc/DartAPI_NativeFieldAccess
Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I8006c735569fcbe5e49915a4c7e72c4ca85b356e
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205482
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
DDS can be configured to listen for CPU sample events and cache samples
that were collected while certain UserTags are active. These cached
samples are stored in a ring buffer and are stored until the isolate
shuts down.
TEST=pkg/dds/test/get_cached_cpu_samples_test.dart
Change-Id: Ib20770f59f1672c703413486f87795b3bb23f676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207206
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Kenzie Schmoll <kenzieschmoll@google.com>
Also make NBitMask generic, replace uses of SignedNBitMask
with generic NBitMask, and remove SignedNBitMask.
TEST=No changes to functionality for existing callers, so existing tests.
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: Ic33785e50be98123c75782c6e62ef32ec45f4191
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208181
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Split off https://dart-review.googlesource.com/c/sdk/+/203765 to make
that diff smaller.
Serializing the index incurs a large size penalty to snapshots. Rather
than serializing, we reconstruct the index based on the hashes that we
do serialize for all canonical objects. (Reconstructing the index is a
relatively cheap operation, recomputing the hashes is not.)
Note that to_snapshot is currently dead code, because we never serialize
non-const maps and sets in clustered snapshots.
Of course we do exercise the layout of the maps and sets itself.
Bug: https://github.com/dart-lang/sdk/issues/45908
TEST=The whole test suite including all map and set tests.
Change-Id: If54117497029e4da212c702a76c82de6d1531092
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208086
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
For members of program structure that we cache in the ObjectStore we try
to provide only read-only access in the public API. The lazy population
is encapculated in the ObjectStore class.
Use the same mechanism we use for core/isolate/... library members also
for the `dart:_internal` members.
Furthermore cache the Symbol._name field in the ObjectStore to avoid
expensive lookup as well as avoid an extra TLS lookup.
TEST=Existing test suite.
Change-Id: I299faceb39f20576e23244c71c58d698f80f80c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208180
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
We want to reuse CanonicalizeHash for const maps and sets. See design in
go/dart-vm-const-maps.
Before, we only used CanonicalizeHash on a per-class basis. However,
when we start using it for const maps and sets we don't want hash
collisions between const instances with identical layout but a different
class id. So we include the class id into the hash rather than the size.
Bug: https://github.com/dart-lang/sdk/issues/45908
TEST=vm/cc/CanonicalizeHash_Const_Instances
TEST=A ton of bots for existing tests.
Change-Id: Idc0eed49fbae8f76dcfdda21dd9fe2674dc4a240
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/+/208085
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>