Commit Graph

19100 Commits

Author SHA1 Message Date
Brian Quinlan d1d2adb5dc Fix a bug where setAccessTime would also set the modified time on Windows.
TEST=issue_35112_test.dart
Bug: https://github.com/dart-lang/sdk/issues/35112
Change-Id: I4c7a1795250447888ec1cbde71bf2799c3467b55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218182
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-10-29 18:19:49 +00:00
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
Vyacheslav Egorov feadec2dc6 [vm] Unskip coverage_closure_call_test in JIT
This test should only be skipped in AOT mode just like other
similar tests.

Create observatory_2 version of the test.

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

TEST=ci

Fixed: 47568
Change-Id: I64285d2347fe4c6cd76062a7a8d401f088082db7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218641
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-10-29 10:53:29 +00:00
Ben Konyi a9752ad140 [ Gardening ] Skip coverage_closure_call_test
Causing various timeouts and infra failures.

Related issue: https://github.com/dart-lang/sdk/issues/47568

TEST=N/A

Change-Id: Ifbe6760faf3029a021aee557f676b08c1779c577
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218560
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-10-28 21:00:27 +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
Ben Konyi 4de9e805ed [ CLI ] Don't resolve paths as URIs for known SDK artifacts
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>
2021-10-27 16:34:00 +00:00
Ian McKellar c46baff9c9 Fix a use-after free in Fuchsia process launching
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>
2021-10-26 22:53:41 +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
Martin Kustermann fb59277b4a [vm/concurrency] Remove vm/dart/regress_40753_test in iso-stress tests
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>
2021-10-21 10:48:53 +00:00
Daco Harkes 41434e148a [vm] Fix non-const empty map and set messages
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>
2021-10-21 07:19:12 +00:00
Brian Quinlan f1af54b3b0 Fix a bug where an abort would occur if the sourceAddress did not match the host address type.
TEST=socket_source_address_test.dart

Bug: 47447
Change-Id: I7e70393c0edb4c5d51edcafe2568f95f8ceb85c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217448
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2021-10-20 22:18:25 +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
Brian Quinlan 8462f1da74 Fix a bug where Platform.operatingSystemVersion was incorrect in the iOS
simulator.

Also changes the MacOS implementation of that property.

TEST=platform_os_version_test.dart

Bug: 47138
Change-Id: I9134845a216423c8a383b804986af1ebb3c8d3d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214863
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-10-19 21:25:43 +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
David Benjamin 3d73ae1c22 Replace old M_ASN1_* macros with their functions
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>
2021-10-18 14:48:39 +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
Martin Kustermann 1be6f891de [gardening] Try to configure TSAN to produce coredumps on aborts
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>
2021-10-15 11:47:42 +00:00
Martin Kustermann d77a4af894 [gardening] Mark service/async_generator_breakpoint_test/ as slow in release mode
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>
2021-10-15 10:11:20 +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
Daco Harkes e512402b05 [test/ffi] Make the test generator async
The `dart format` step takes 8 seconds currently on the large files.
This cuts down the total time from 21 seconds to 9 on my machine.

TEST=This only changes the test generator, nothing should change.

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

Change-Id: Ie4940fdd3a43a923ca28cb39b0673cc19f81a10a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216664
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-10-14 13:05:33 +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
Ryan Macnak b4b7b8f116 [build] Add support for building for Fuchsia from Mac.
TEST=./tools/build.py --os=fuchsia --mode=all runtime create_sdk
Change-Id: I6b15d1cc174b84d900d526730e5f58d64d2596cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216540
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-10-13 21:14:56 +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 62a5289e7a [observatory] Include "uncollected garbage" and "free" when diffing heap snapshots.
TEST=examine "heap snapshot" in Observatory
Change-Id: I13436496a7dadcbd96c85a5bf7b7c0a0d647a4d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215987
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-10-12 21:34:05 +00:00
Nate Bosch f9c68a5679 Replace a bunch of references to .packages
Most of these arguments are flowing through to a `--packages` argument
which allows passing the `package_config.json` file. In the long term we
should remove the `.packages` file entirely.

TEST=None, the change should have no visible impact.

Change-Id: I60a8b175d5e217a85588bbcb91cc5095514066b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211503
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-10-12 20:16:15 +00:00