Write barriers should not be eliminated for a StoreInstanceField
if there is a Dart call between store and object allocation.
This is implemented using Instruction::CanCallDart()
predicate, which is overridden for TemplateDartCall.
However, LoadField instructions for late fields with initializers can
also call initializer function directly without entering runtime.
This change introduces LoadFieldInstr::CanCallDart() to avoid
incorrect write barrier elimination across such LoadField instructions.
TEST=vm/cc/IRTest_WriteBarrierElimination_LoadLateField
Bug: b/204355807
Change-Id: Ibd9fe61e9723f1f4ecc9e4f5cedc3024d9d03c75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218583
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Instead of the background compiler task waiting forever for functions to show up in its queue, it performs a single compilation and schedules a new task if the queue is not empty.
This means an inactive isolate no longer consumes a thread. It also creates interrupt points and better fits with an embedder-provided task runner abstraction.
TEST=ci
Change-Id: I13960c776590b884fdee278d2f292bb0fa725fad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214242
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Handles cases where the SDK is installed on a path which includes
percent encoded characters. The OS doesn't decode these characters, so
decoding them before trying to load a snapshot with said characters in
their path will result in files not being found.
Fixes https://github.com/dart-lang/sdk/issues/46364
TEST=pkg/dartdev/test/regress_46364_test.dart
Change-Id: I5f78e8a2049cc0c83555528fcc8f41be946141f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218082
Reviewed-by: Ryan Macnak <rmacnak@google.com>
The fdio_flat_namespace_t returned by fdio_ns_export holds memory for
the paths of the prefixes. If this is freed then the fdio_spawn_action_t
entries point to freed memory.
Now we explicitly copy the prefix path strings and move the handles out.
TEST=internal testing
Change-Id: If8e1e0ded86003a618610a98dd571826a6ca40c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218087
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Auto-Submit: Ian McKellar <ianloic@google.com>
This region is mostly unused after loading, but it may be accessed again if
- Isolate.spawn is invoke with isolate groups disabled
- A secondary snapshot produced by splitting is loaded
- An external typed data in the snapshot is accessed (usually a kernel file)
- Likely other cases
Even if these cases did not exist, the region is often part of a shared library and so unable to be released independently.
madvise(DONT_NEED) on this region will cause the OS to release the memory in this region but keep the address space reservation and mapping. If it is touched again, it will be brought back in from the file. If it is not backed by a file, such as malloc memory, it will be brought back in as zeros and the program will likely fail.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/44019
Bug: https://github.com/flutter/flutter/issues/92120
Change-Id: I315a049b0f7d440e181d0a5e87fa6770a2fd4f79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216580
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Fixes a crash when SetObjectTypeAndName is called twice for the
same object id with different types.
Don't add Code objects to the profile for non-Code carrying snapshots,
as references to the Code object are replaced with references to null.
TEST=vm/dart{_2}/v8_snapshot_profile_writer_test
Bug: https://github.com/dart-lang/sdk/issues/47463
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Change-Id: Id9abf66509d422551ad5797744265eeb2c2ba2b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217643
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This particular test causes thousands of exceptions to be thrown. This
is not a problem in itself, but it is when running under TSAN because it
will cause a buffer-overflow in TSAN's fixed-size shadow stack.
The buffer overflow will override data structures that often causes the
iso-stress runs to crash.
See more information in the issue.
Issue https://github.com/dart-lang/sdk/issues/47472#issuecomment-948235479
TEST=Should eliminate certain causes of crashes on "iso-stress" builder.
Change-Id: I9c3357eb49a31daf1cb728d745eeb405f2ff4a81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217600
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Before https://dart-review.googlesource.com/c/sdk/+/176583, the index
of maps was always at least length 8. However, after the change the
length can be 1. Using this uninitialized index for creating a hash
mask makes the hashmask 31 1s instead of 29 1s on ia32, which is not a
Smi.
This CL changes _indexSizeToHashMask to return the uninitialized hash
mask (0) for when the index is uninitialized (length 1).
The behavior is exercised by sending a non-const map through a message
to another isolate, which calls `_regenerateIndex`.
https://dart-review.googlesource.com/c/sdk/+/210860 introduced the same
issue for sets.
TEST=runtime/tests/vm/dart/isolates/fast_object_copy_test.dart
TEST=runtime/tests/vm/dart/regress_47468_test.dart
If only assert `assert(indexSize >= _INITIAL_INDEX_SIZE);` is added to
`_indexSizeToHashMask`, it makes the test reliably fail.
Closes: https://github.com/dart-lang/sdk/issues/47468
Change-Id: I3bc40a289c16b58c3d740373bc9ed7bcad2f41c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217362
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Now that Types are no longer created for top level classes, the type
class id is guaranteed to fit in ClassIdTagType. That means we can
reduce the size of Type objects slightly as well as avoid the need to
tag and untag the type class id.
Also fixes an issue uncovered in GenerateSubtype1TestCacheLookup where
the retrieved super type was not first checked to be non-null.
TEST=Refactoring, so existing tests.
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-ia32-try,vm-kernel-linux-release-x64-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm64-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-linux-debug-x64c-try,vm-kernel-precomp-linux-debug-simarm64c-try
Change-Id: I851a827843e34eac6961e0f06f888b40bf16df55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217221
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
The only time we create a Type in the VM for a top level class is as the
"receiver" for a no such method error where the method was either not
found in the top level class or the found method had incompatible
arguments. Unlike other cases, the Dart implementation doesn't directly
use the InvocationMirror receiver for no such method errors at the top
level, but instead just passes it back to the VM.
Now, for the InvocationMirror receiver in the top level class case, we
either
* pass a null receiver if the method wasn't found, or
* pass the signature of the found method as a string, if the arguments
were incompatible, since the only use of the top level class was for
printing the signature.
TEST=vm/cc/DartAPI, service{_2}, vm/cc/Eval, lib{_2}/mirrors
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try
Change-Id: I1ac701b0be2aaebbc6163e644262c5f3ead656c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217220
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Otherwise a heap can accumulate just under 128MB (4 * max new-space capacity) worth of new-space external data without triggering a GC.
TEST=--verbose-gc
Change-Id: Ifaa5e4ea9277f1f4a09b722897b508a192c3297f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215142
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
M_ASN1_* is an old quirk from a very very old OpenSSL. They're just
wrappers over identically-named functions at this point.
Bug: none
TEST=ci
Change-Id: I1a204d6c1cca62861d7f11bf3c7adfa24bd47e59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217040
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
This CL adds the `Bool` `NativeType` with support for loading/storing
from `Pointer<Bool>`, `Array<Bool>`, and `Struct` and `Union` fields,
and support for passing booleans through FFI calls and callbacks.
The assumption is that `bool` is always treated as `uint8_t` in the
native ABIs. Including: (1) whether there can be garbage in the upper
bytes in CPU registers, (2) stack alignment, and (3) alignment in
compounds.
The conversion from `bool` to `uint8_t` is implemented as follows:
- bool to int: `value ? 1 : 0`
- int to bool: `value != 0`
The conversion is implemented in Dart in patch files for memory loads
and stores (pointer, array, and struct fields) and kernel_to_il for
FFI call and callback arguments and return value.
TEST=runtime/vm/compiler/ffi/native_type_vm_test.cc
TEST=tests/ffi/bool_test.dart
TEST=tests/ffi/function_callbacks_structs_by_value_generated_test.dart
TEST=tests/ffi/function_structs_by_value_generated_test.dart
Closes: https://github.com/dart-lang/sdk/issues/36855
Change-Id: I75d100340ba41771abfb41c598ca92066a89370b
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-ffi-android-debug-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-ffi-android-debug-arm64c-try,vm-kernel-mac-release-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216900
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
We seemingly don't get coredumps on the "iso-stress" builder when
running under TSAN. This is an attempt of setting TSAN settings via
an environment variable to explicitly force this behavior.
We also add a print to an existing test to help identify in which
section a crash happens.
TEST=Attempt to obtain cores on iso-stress when running under TSAN.
Change-Id: I698eb62e537923dc6733b4ed496a47f67338da34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217010
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This test uses --stacktrace-every= which will cause it to be slow. It
was marked only as slow in debug mode, which this CL extends to all
other modes as well.
This addresses timeout of service/async_generator_breakpoint_test.
TEST=service/async_generator_breakpoint_test
Change-Id: I7576d7c1a392ff75ee779278ceb79f9681b8157c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217005
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Avoid touching stubs in JIT mode when reading object pool
as stubs may not be initialized yet. This may happen if
using a core-jit snapshot.
TEST=ci
Change-Id: I598ef2ca4b6b22fb1bb560ad25b6ada9939799a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216924
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Currently there is a strong link between dyn:-forwarder and
its target (through Function::data_ field). This link causes us
to retain some Function objects even if they are otherwise
considered dropped.
In reality this link is only ever used during compilation
or when accessing script information for the dyn:-forwarder.
As such when generating snapshots in DWARF stack traces mode
we should be able to consider this connection weak
and allow dropped Function objects to be truly discarded from
the snapshot.
This change puts WSR in between dyn:-forwarder and its target
when we know that target is not going to be retained.
We also clean how forwarding target represented to avoid
unnecessary indirection through a one-element array.
TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I4f0ec822ff15f78c72ff55a87d9dc52abd466cb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216040
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
The added field holds the interface signature type for a Procedure when
this is different from the class signature type (implied by the function
parameters and return type). This is needed for forwarding semi stubs
when its declared type is different from the called super member.
Closes https://github.com/dart-lang/sdk/issues/47072
TEST=pkg/front_end/testcases/general/implement_semi_stub.dart and more
Change-Id: I4a7cdc9d564fb0a59e7b06e83646b5410d8d82f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216420
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
Enabling the CPU profiler on OSX/iOS with a lldb connection would cause
applications to slow to a crawl due to lldb performing checks on each
SIGPROF. This change replaces the SIGPROF based thread interrupter for
MacOS with one based on the Mach Thread APIs.
Fixes https://github.com/dart-lang/sdk/issues/47139
TEST=Manual testing, CQ
Change-Id: Iedfd73a83f92d51e01b98bfa281440c7d1ba9e08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216220
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>