Commit Graph

13668 Commits

Author SHA1 Message Date
Alexander Markov 6c9a830fda [vm/compiler] Ensure that write barriers are not eliminated across LoadField which can call initializer directly
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>
2021-10-29 16:48:13 +00:00
Vyacheslav Egorov eaf7674f6d [vm] Fix TypedClosureCall test in PRODUCT
We don't emit RecordCoverage instruction in PRODUCT mode.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-product-x64-try
Change-Id: I794b4c08362fa7b84417923d80fbd246d5bb36be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218642
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-10-29 11:38:41 +00:00
Ryan Macnak 12bf51a466 [vm, gc] Include starting concurrent marking in --verbose_gc output.
Measure sizes in MB instead of kB.

TEST=--verbose_gc
Change-Id: I5d2b45a31d2eb91665c175d8abf016329ce0f07d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217740
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-28 18:20:18 +00:00
Ryan Macnak 5f288f4940 [vm] Background compile one function per task.
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>
2021-10-28 17:53:08 +00:00
Ben Konyi 7d3d835bc9 Reland "[ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs"
This reverts commit 711fdcc0de.

TEST=uri_mappings_lookup_test.dart

Change-Id: I0a548ef0b5f1f0f6bc23ec72e0fe7dafc244c5d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218520
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-10-28 17:16:49 +00:00
Vyacheslav Egorov 8896894315 [vm] Record coverage for closure calls
Previously coverage was computed from the state of ICData at various
call-sites in the function. This ties coverage collection with the
implementation of various operations. This CL is the first step towards
decoupling coverage collection from how individual operations are implemented.

We introduce a separate coverage array storing token_pos -> coverage hit
mapping. This array is updated by a separate RecordCoverage IL instruction.

Fixes https://github.com/dart-lang/sdk/issues/47174
Fixes https://github.com/dart-lang/sdk/issues/47530
Fixes https://github.com/dart-lang/sdk/issues/37944

TEST=runtime/observatory/tests/service/coverage_closure_call_test.dart

Change-Id: I986d3462412870372ca6a9d72c050f0563b9b725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218262
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-10-28 11:02:48 +00:00
Siva Annamalai 711fdcc0de Revert "Reland "[ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs""
This reverts commit 6c6dd13b14.

Reason for revert: Still seeing test failures in some configurations

Original change's description:
> Reland "[ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs"
>
> This reverts commit aa25975644.
>
> TEST=uri_mappings_lookup_test.dart
>
> Change-Id: I311e3130bc14a392cfc4b5d81afb137505c5c202
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218324
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=bkonyi@google.com,asiva@google.com

Change-Id: Ia69d9cfd7b395f692679fdfd185ef757550104bf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218360
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-10-27 23:48:49 +00:00
Ben Konyi 6c6dd13b14 Reland "[ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs"
This reverts commit aa25975644.

TEST=uri_mappings_lookup_test.dart

Change-Id: I311e3130bc14a392cfc4b5d81afb137505c5c202
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218324
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-10-27 23:15:51 +00:00
Ben Konyi aa25975644 Revert "[ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs"
This reverts commit 3d0f937569.

Reason for revert: Failing AOT bots

Original change's description:
> [ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs
>
> Adds RPCs that allow for service clients to convert URIs from absolute
> paths to unresolved package URIs and vice-versa.
>
> Fixes https://github.com/dart-lang/sdk/issues/46631
>
> TEST=uri_mappings_lookup_test.dart
>
> Change-Id: I06e56e37dc0d4fe505527f8fb246c07caef5e058
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217744
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Jacob Richman <jacobr@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=jacobr@google.com,bkonyi@google.com,rmacnak@google.com,asiva@google.com

Change-Id: If36248efe05cb6ee96b4b07b246dbbbd3d1b3368
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218322
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-10-27 20:21:52 +00:00
Ben Konyi 3d0f937569 [ VM / Service ] Add lookupResolvedPackageUri and lookupPackageUri RPCs
Adds RPCs that allow for service clients to convert URIs from absolute
paths to unresolved package URIs and vice-versa.

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

TEST=uri_mappings_lookup_test.dart

Change-Id: I06e56e37dc0d4fe505527f8fb246c07caef5e058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217744
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-10-27 18:59:17 +00:00
Ryan Macnak 985824de50 [vm] Ask the OS to release the memory for the clustered portion of the snapshot.
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>
2021-10-25 17:30:50 +00:00
Tess Strickland 8debbd0725 [vm] Fix writing v8 snapshot profiles for core snapshots.
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>
2021-10-21 19:39:15 +00:00
Ryan Macnak 22e501be61 [vm, gc] Guard PrintStatsToTimeline with SUPPORT_TIMELINE instead of PRODUCT.
We missed updating this code when SUPPORT_TIMELINE was introduced.

TEST=ci
Change-Id: I534ba9e41063f5381966b4bb0b4af7cb1f80e2b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217480
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-21 17:07:16 +00:00
Ben Konyi db45ae178a Reland "[ VM / Profiler ] Update MacOS thread interrupter to use Mach APIs instead of SIGPROF"
This reverts commit b6c659ae8f.

TEST=CQ

Change-Id: I49056d510a9365c7aed83388430949a630c0f4b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216740
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-10-20 16:54:32 +00:00
Tess Strickland f1f83c9bdd [vm] Store type class id for Types as ClassIdTagType, not Smi.
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>
2021-10-20 16:31:02 +00:00
Tess Strickland 1b8887080a [vm] Remove only use of Types of top level classes.
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>
2021-10-20 11:00:11 +00:00
Ahmed Ashour d041cf0478 Remove extra the, be and of
Fixes #https://github.com/dart-lang/sdk/issues/47504

TEST=No tests needed, only comments affected.

Change-Id: Ie096307b5ce314d328fea6780f396aaa226ad3b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216182
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-10-20 09:29:01 +00:00
Bruno Leroux f1ace5928b [VMService] - Add getClassList to service.md TOC
TEST=cq

Bug: https://github.com/dart-lang/sdk/issues/47497
Change-Id: Ie7544dfa2cc48cea99fd74333837f9c43895d11a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217183
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-10-19 20:55:54 +00:00
Ryan Macnak 1ef7e6a974 [vm, compiler] Use comparisons with the correct width for SpeculativeShiftUint32OpInstr.
Fixes failure to detect negative Smis with compressed pointers.

TEST=left_shift_bit_and_op_test on AppJIT
Change-Id: I2ca98f1af16eb62a309ddd8d6fe6d4a0e98e49c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217152
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-19 18:00:32 +00:00
Ryan Macnak 60d2df4a42 [vm, gc] Consider external memory when deciding whether an idle scavenge is worthwhile.
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>
2021-10-18 18:32:43 +00:00
Daco Harkes 757c2b82ce [vm/ffi] Add Bool
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>
2021-10-18 10:44:11 +00:00
Ryan Macnak 0e8d33825b [vm] Change Version::String() to not invoke malloc.
This may run during a segfault signal handler, and malloc is not signal safe.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/47472
Change-Id: I29702010384dc95396313791dddb3887ff6ca097
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217063
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-15 23:22:10 +00:00
Ryan Macnak f2174d4eb8 [vm, compiler] Fix BoxInt32Instr to not create denormalized Mints on arm64 with compressed pointers.
Removes the assumption that the incoming int32 is sign-extended.

TEST=ffi/function_test
Change-Id: I347dccec47b4784be40c834de62ccea157d9042d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216960
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-15 19:54:30 +00:00
Daco Harkes 4031e6a82c [cfe/ffi] Refactor transform lists into sets and maps
Addressing https://dart-review.googlesource.com/c/sdk/+/216900/3/pkg/vm/lib/transformations/ffi.dart#77

TEST=FFI test suite

Change-Id: I96a88534d452fd727b7cc693cc5d37fd49d06977
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217002
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-10-15 09:23:42 +00:00
Martin Kustermann edf9fa73ec [gardening] Fix memory leak of Dart::FeaturesString() buffer
The CL in [0] introduced a new usage of Dart::FeaturesString() but
missed to free the resulting buffer (it's not a compile-time constant
but rather built via TextBuffer).

Closes https://github.com/dart-lang/sdk/issues/47460

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

TEST=Fixes asan failures, e.g. vm/cc/DartAPI_InvokeVMServiceMethod

Change-Id: I954bd4a0af5959f1c38d4b70978bef6c6baed407
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216802
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-10-15 09:12:02 +00:00
Alexander Markov bb06e649f4 [vm] Handle entry point object pool entries only in AOT
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>
2021-10-14 21:39:05 +00:00
Ryan Macnak 63177bc4fc [vm, gc] Use idle time to deallocate cached new-space pages.
New-space pages are cached because deallocation, not allocation, is slow.

TEST=ci
Change-Id: I8439aa0477518a1fb7ac643a435de53bf6679ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216687
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-14 18:58:35 +00:00
Ryan Macnak fbcacd7c05 Reapply "[vm] Streamline Zones."
Fix imprecision in Zone::SizeInBytes that was finally noticed by vm/cc/AllocateZone because the size of the initial inline buffer changed.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47399
Change-Id: I152d24d03a59b21267a9a24e5d929b51af57af71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215980
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-14 00:10:12 +00:00
Ryan Macnak b5c911e2a3 [observatory] Report AppJIT/AOT feature string.
TEST=examine main page
Change-Id: I368b96e1a871a8d5da4cfab5c3fcf7c297a589be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215945
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-14 00:05:01 +00:00
Siva Annamalai b6c659ae8f Revert "[ VM / Profiler ] Update MacOS thread interrupter to use Mach APIs instead of SIGPROF"
This reverts commit 4daa257b32.

Reason for revert: Flutter Engine build breaks on iOS builds (32 bit)

Original change's description:
> [ VM / Profiler ] Update MacOS thread interrupter to use Mach APIs instead of SIGPROF
>
> 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>

TBR=bkonyi@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I4edf1b73d8f90934fff92971fac8ef7b0f165971
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216682
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-10-13 17:19:30 +00:00
Ryan Macnak 868b6a898c [vm, gc] Use relaxed loads when reading the header of an ephemeron's key.
The ephemeron and its key may be processed by different workers, so there is a race when accessing the key's header. This race is harmless: if the key becomes a survivor, it will trigger another round of ephemeron processing.

TEST=tsan, splay_ephemeron_test
Bug: https://github.com/dart-lang/sdk/issues/47412
Change-Id: I20339c2215f2d37ad8b9687aebe62492b36a8a61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216340
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-13 16:56:06 +00:00
Vyacheslav Egorov 36caf54631 [vm/aot] Allow dropping dyn:-forwarder targets
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>
2021-10-13 11:35:26 +00:00
Johnni Winther 56490f9776 [cfe] Add Procedure.signatureType
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>
2021-10-13 11:31:16 +00:00
Ben Konyi 4daa257b32 [ VM / Profiler ] Update MacOS thread interrupter to use Mach APIs instead of SIGPROF
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>
2021-10-12 21:43:45 +00:00
Ryan Macnak 1d70168786 [build] Fix arm and arm64 gcc builds.
TEST=./tools/build.py --no-goma --no-clang --arch=arm,arm64 runtime
Bug: https://github.com/dart-lang/sdk/issues/47330
Change-Id: I32cea56e3ad64200a7057cc6a381bc6d9656ec7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215984
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-10-12 18:49:52 +00:00
Alexander Markov 4b04219d94 [vm] Fix intrinsified Type.operator== for generic types with not finalized classes
UntaggedClass::host_type_arguments_field_offset_in_words_ is initialized
when class is finalized. When comparing generic types for the class
which was not finalized, we cannot rely on the value of that field.

Intrinsified Type.operator== has been using host_type_arguments_field_offset_in_words_
to check if the class is generic, and has been treating classes which
are not finalized as non-generic. This has been causing the wrong
result for generic types which are different only in type arguments.

This change fixes Type.operator== intrinsics to check if
type arguments match even if class was not finalized.

Also, EquivalentClassIds helper was revised to take 3 labels
explicitly for all possible outcomes (instead of 2 labels and
a fall-through).

TEST=runtime/tests/vm/dart/regress_47425_test.dart
Fixes https://github.com/dart-lang/sdk/issues/47425

Change-Id: I3f49114644d44808c668df7cbb8a702cd42b3673
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216270
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-10-12 17:03:00 +00:00
Daco Harkes e4ff34ceac [vm] Defer Field::RecordStore in Deserialization
Field::RecordStore inspects the object being pointed to. However,
it is not guaranteed that that objects has been initialized in
*DeserializationCluster::ReadEdges, that depends on the order of the
clusters.

In the reproduction, the TypedDataView cluster comes after the cluster
containing the instance. This leads to doing a field store while the
length field of the TypedDataView has not been read yet and is 0. This
causes a Field::RecordStore with value 0, which subsequently gets used
in compilation causing RangeErrors.

This CL delays the Field::RecordStore from ReadEdges to PostLoad so that
all objects are initialized before they are inspected by RecordStore.

TEST=tests/language/vm/regress_flutter_89584_test.dart

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

Change-Id: I1d5fe25c4084d62d5e492446123987aee10200bb
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-nnbd-win-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216181
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-10-11 16:27:20 +00:00
Martin Kustermann b7909e132a [vm/concurrency] Allow StackTrace objects to be shared
The existing lib/isolate/stacktrace_message_test was failing and also
incorrectly written due to "!" in front of the expected stringification
of the stacktrace.

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

TEST=vm/dart{,_2}/isolates/fast_object_copy2_test, lib{,_2}/isolate/stacktrace_message_test

Change-Id: I169d8fd7a7c3cb3b8c57e00287565e3a5c622acf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216041
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-10-11 09:01:44 +00:00
Alexander Aprelev 935ee25f3b [io/unix_domain_socket] Add support for sending/receiving open files, sockets, std streams via sockets.
This adds [sendMessage] and [receiveMessage] methods to [RawSocket] class. They are only supported on Linux at the moment as they require connection opened as unix domain socket connection.

This introduces [SocketControlMessage] class that represents a message sent via socket and also introduces [ResourceHandle] class that wraps [RandomAccessFile], [Socket]/[RawSocket]/[RawDatagramSocket], [Stdin]/[Stdout] for
marshalling/unmarshalling purposes.

Underlying OS implementation supports various kinds of control messages that can be passed via sockets, this CL only adds support for sending/receiving opened file description handles.
When receiving a message recipient can attempt to extract handles out of it via [tryExtractHandles]. It returns [null] if message has no handles to extract.

This is continuation of the work started on https://dart-review.googlesource.com/c/sdk/+/205067.

Bug: https://github.com/dart-lang/sdk/issues/46328
TEST=unix_socket_test

Change-Id: Ic9125b51dc80b677452e454366bae4118c298081
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212036
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2021-10-08 15:46:23 +00:00
Ryan Macnak 2532d954c8 [vm, gc] Aggregate marker statistics and delete visitors on the main thread.
This makes parallel marking more like parallel scavenge and is preparation for allowing marking/scavenging to complete even if some workers haven't started.

Also improve work stealing of weak processing by processing the worker-local weak properties first.

TEST=ci
Change-Id: I73bfb930129e2d9848a3bbcf378303a51bd65a5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215681
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-07 18:44:32 +00:00
Ryan Macnak 17a830d043 [vm] Fix warning in gcc-10.
TEST=build
Change-Id: I33f93ed93699899ed3a1bea727522d268190da58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215882
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-07 17:13:12 +00:00
Tess Strickland b9b1ea6b5d [vm] Refactor hash maps with T* keys where T <: Object.
Rename PointerKeyValueTrait<T>, which is used to create sets of pointers
to T instances where T <: Object and T has appropriate Hash and Equals
instance methods, to the more specific name PointerSetKeyValueTrait.

Create a PointerSet<T> alias for using this trait with
DirectChainedHashMap and use that alias in other code as a shorthand.

Remove PointerSetKeyValueTrait<const char> as a superclass of
CStringKeyValueTrait, as the only reuse from the former are the two
methods KeyOf and ValueOf which just return their argument, and having
this relationship is odd since const char is not a subtype of Object.

TEST=Renaming/refactoring, so existing tests.

Change-Id: I0274b16cb9fcb3939a28fb109fb8626c1ac8c0e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215761
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-10-07 06:43:53 +00:00
Alexander Markov ff0e760ac2 [vm/compiler] Replace debug prints with assertions
This change replaces debug prints introduced in
https://dart-review.googlesource.com/c/sdk/+/215152
with assertions. We no longer need the printed information because
root cause of the flaky crashes is found.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/47314
Change-Id: I2c37fa640bc64cf5295f8acd0fbfb2b63ec7cddf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215883
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-10-07 00:04:02 +00:00
Ryan Macnak 472e2bce17 Revert "[vm] Streamline Zones."
This reverts commit b5922e6db4.

Reason for revert: vm/cc/AllocateZone fails on Mac

Original change's description:
> [vm] Streamline Zones.
>
>  - Don't put a HANDLESCOPE right after a StackZone, as there's no state worth restoring
>  - Remove remaining zone bookkeeping dead since e3a9d70591.
>  - Remove unnecessary resetting of handle blocks before zone deletion.
>  - Shrink initial chunk size to make Zone's overall size fit in a faster malloc size class.
>
> TEST=ci
> Change-Id: I920e12f5af93aa71fb876435764c60df485215f9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212261
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

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

Change-Id: Id23dcebb781791616e48e54d2dcd7e58159178bc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215943
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-06 23:44:33 +00:00
Ryan Macnak b5922e6db4 [vm] Streamline Zones.
- Don't put a HANDLESCOPE right after a StackZone, as there's no state worth restoring
 - Remove remaining zone bookkeeping dead since e3a9d70591.
 - Remove unnecessary resetting of handle blocks before zone deletion.
 - Shrink initial chunk size to make Zone's overall size fit in a faster malloc size class.

TEST=ci
Change-Id: I920e12f5af93aa71fb876435764c60df485215f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212261
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-06 22:22:32 +00:00
Ryan Macnak 88d7f53359 [standalone] Truncate names passed to pthread_setname_np.
pthread_setname_np ignores names that are too long rather than truncating. This was causing most dart:io threads to remain unnamed.

Cf. eec49f34c4.

TEST="thread info" in gdb
Change-Id: I12f47b06b81f1204f742d829e14784d792a4fb96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215800
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-10-06 17:46:29 +00:00
Ryan Macnak 1a4d708580 [vm] Remove disused "mode" argument in timeline events.
TEST=ci
Change-Id: I746f592d30c5e4384a451c131d357d5843807567
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215642
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-06 16:30:19 +00:00
Ryan Macnak 38920c9585 [vm] Remove dead ObjectPool entry type NativeFunctionWrapper.
This became obsolete when we added separate exit stubs for each wrapper.

TEST=ci
Change-Id: Icf73452aebd20e00e16d0a75ffec877715c9e5c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215646
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-05 22:49:22 +00:00
Alexander Aprelev c0e5cec5da [vm/isolates] Fix Isolate.exit() message validation.
Isolate.exit() message validation diverged from SendPort.send one, so this CL aligns them back.

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

TEST=sendandexit_test

Change-Id: I4c85933acb87a29892df5eb3cd2843e3207418b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215502
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-10-05 20:44:31 +00:00
Alexander Markov 1d5b9ed046 [vm/aot] Remove PatchGlobalObjectPool step from AOT snapshot reading
This change removes the extra pass over global object pool after AOT
snapshot is loaded by adding extra kSwitchableCallMissEntryPoint and
kMegamorphicCallEntryPoint object pool entry kinds which are handled
during ReadFill phase.

On a low-end phone and large Flutter app compiled in release mode
with dwarf_stack_traces, FullSnapshotReader::ReadProgramSnapshot time
Before: 232.41 ms
After:  202.43 ms (-12.8%)

Also, this change adds PrintTimeScope utility class which can be used
to measure and print time in release mode without timeline and profiling
tools:

ApiErrorPtr FullSnapshotReader::ReadProgramSnapshot() {
  PrintTimeScope tm("FullSnapshotReader::ReadProgramSnapshot");
  ...
}

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/46116
Change-Id: I42bd46761eac8fc1e52ca695cacd2b86705034d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215500
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-10-05 16:32:40 +00:00