Commit graph

19582 commits

Author SHA1 Message Date
Martin Kustermann 2fd661d4fa [vm] Fix assertion in ICData::AssertInvariantsAreSatisfied()
The ICData::AssertInvariantsAreSatisfied() method will grab a snapshot
of the ICData's entrie()s backing store array and does verifications
on it.

Though the place when we check for the last entry (which is a back-ref)
we re-load the entries() array which could be updated at this point.

This causes us to possibly fail an assertion which checks that for empty
ic data arrays it should be a cached empty array.

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

TEST=Should fix flaky assertion hit.

Change-Id: I45cf57bd13a7c2e49c395eb25a2f6789c5140bf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242109
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-22 15:14:29 +00:00
Clement Skau 44a4cfc2d7 [vm][ffi] Add function name to FFI Trampolines.
This change will append the name of the associated function
to the name of FFI trampolines.
Previously the name of all FFI trampolines was "FfiTrampoline",
which made them difficult to keep track of when there was
more than one trampoline (i.e. more than one FFI function).

TEST=Existing
Change-Id: I7b5efa25dc9064d5615309331e2cfeaa01e4c9f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242100
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-04-22 09:48:39 +00:00
Clement Skau b514b74dee [format] Remove multiline comment that gcc errors on.
TEST=comment only change

Bug: https://github.com/dart-lang/sdk/issues/48855
Change-Id: I39ea0593d2e660803b2e6520f51c2a1c9aaaaec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241967
Auto-Submit: Clement Skau <cskau@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-21 22:30:59 +00:00
Ryan Macnak 0c762283a4 [vm, compiler] Remove dead kKeepCalleePP.
Dead since cf1de7d46c.

TEST=ci
Change-Id: I6dd42a62a8bfc8ff71bae8f1e33930c1bacfe103
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242040
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-21 20:30:58 +00:00
Ryan Macnak a8d9119f00 [vm] Add missing field metadata for finalizers.
TEST=misc heap tools in Observatory
Change-Id: Iefaa6f749e3c950f7b5ee3d542e2db103fd47222
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241841
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-21 17:59:28 +00:00
Ryan Macnak cb7a765f14 [test] Mark disassemble_aot_test as slow.
Bug: https://github.com/dart-lang/sdk/issues/48849
Change-Id: I8d277a1ed1dca0179865c38c670789308c43941b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241900
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-21 16:13:18 +00:00
Alexander Markov 2afc34112c [vm,kernel] New async/await implementation in the VM, part 1 - kernel
This change includes kernel-related changes:

* --compact-async option is added to kernel compilers (front-end
  server and gen_kernel). This option disables desugaring of async
  and await on kernel AST. Note that 'await for' is still desugared.

* File offset of the 'await' is now written for AwaitExpression nodes
  in the kernel binaries (will be used for async stack traces).

* Async/async*/sync* functions and AwaitExpression nodes are supported
  in TFA.

Design doc: go/compact-async-await.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I4233086b7434bc48347f4220645b0be5f9133456
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241842
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-04-21 15:11:08 +00:00
Vyacheslav Egorov 28654b90e8 [vm] Avoid local labels in assembly snapshots.
Labels starting with L are treated as local by the assembler
and cause problems down the line. When targeting ARM64 Mach-O
having local labels cause linker to break when trying to
generate compact unwinding information with a cryptic error

    ld: too many compact unwind infos in function <...>

This happens because local labels are not seen as function
boundaries and multiple .cfi_startproc/.cfi_endproc are
mashed into a single function.

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

TEST=runtime/tests/vm/dart{,_2}/no_local_labels_test.dart

Change-Id: I0171dc08f49c71ccb1ca02b398e01ac241efd9a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241962
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-21 11:06:39 +00:00
Ryan Macnak 5f1bda06ee Revert "[build] Fix Android build for ARM64 Mac."
This reverts commit b50396740f.

Reason for revert: vm-kernel-precomp-linux-debug-simarm_x64

Original change's description:
> [build] Fix Android build for ARM64 Mac.
>
> TEST=local
> Bug: https://github.com/dart-lang/sdk/issues/48792
> Change-Id: Ia43dd46f90ef5f592e324bb889c20c221f69998a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241102
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: William Hesse <whesse@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=whesse@google.com,rmacnak@google.com,dacoharkes@google.com

Change-Id: I0cfdb5653dff7675afdb005df0c37f7560b26ee3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/48792
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241860
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-20 23:13:29 +00:00
Ryan Macnak 6cea65bab7 [benchmarks] Add benchmark to record various startup durations.
TEST=ci
Change-Id: I65b298aa3f4a1ddf7752dc787e0a2ff1c2cacff8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241840
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-20 22:48:38 +00:00
Ryan Macnak 744864c4c5 [vm] Reduce TLS access during runtime allocation.
TEST=ci
Change-Id: Iec212406bc0af93699b08a3c28394551647646b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241202
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-20 21:10:08 +00:00
Ryan Macnak fbff8bd768 [vm, gc] Evacuate new-space when the store buffer overflows.
If the popular store buffer targets are copied instead of promoted, the store buffer won't shrink and a second scavenge will occur that does promote them.

TEST=ci
Change-Id: I09fd7f263a2a9e99179af7ee58bc93335c4f5d05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241203
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-20 20:30:18 +00:00
Ryan Macnak b50396740f [build] Fix Android build for ARM64 Mac.
TEST=local
Bug: https://github.com/dart-lang/sdk/issues/48792
Change-Id: Ia43dd46f90ef5f592e324bb889c20c221f69998a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241102
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-20 17:15:48 +00:00
Daco Harkes c440a0d2bc [vm] Only use IL print functions if available
https://dart-review.googlesource.com/c/sdk/+/241607 broke product
builds.

TEST=SDK build

Change-Id: I996e0554e77798e2c5cac3521b15011da4885a62
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-product-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241749
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-04-20 16:51:24 +00:00
Daco Harkes 1cce5e6090 [vm/ffi] Stop writing beyond allocated stack space
This CL adds an assert to check we're not writing beyond the allocated
stack space. This assert triggers at compile-time, rather than at
runtime, and it catches cases which would sometimes go correct at
runtime because the stack is also 16-byte aligned.

This only occurred on MacOS/iOS Arm64 because structs are word-aligned
on the stack in the other ABIs.

The fix in this CL is to always add 4 bytes extra in this ABI.

The alternative fix would be to stop copying word-size chunks and use
smaller moves. However, this would require a major re-engineering of
the marshaller because it breaks structs up in word-size definitions
currently.

TEST=tests/ffi/function_structs_by_value_generated_test.dart
     (would trigger the assert without the fix on MacOS arm64)

Fixed: https://github.com/dart-lang/sdk/issues/48806
Change-Id: Ia590be76919a192fed144520ee28b1abaf3aa485
Cq-Include-Trybots: luci.dart.try:vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,dart-sdk-mac-arm64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241607
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-04-20 15:42:58 +00:00
Vyacheslav Egorov d2126a3d5b [vm] Avoid deadlocks when launching subprocesses
Forked process should use _exit() rather than exit()
when exiting without exec-ing otherwise it risks
to hit an issue (e.g. deadlock) in an atexit handler.

Additionally `man fork` states:

> After a fork() in a multithreaded program, the child can
> safely call only async-signal-safe functions (see
> signal-safety(7)) until such time as it calls execve(2).

_exit is on the list of async-signal-safe functions, but
exit is not.

Fixes b/216834909

TEST=runtime/tests/vm/dart{,_2}/regress_b_216834909_test.dart

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-android-release-arm64c-try,vm-kernel-mac-release-x64-try
Change-Id: Ia67f23825fc0ee1c1918faf2d4ef3b81033263eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241608
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-20 13:55:59 +00:00
Ryan Macnak 4c7840d330 [dart:io] Publish implementations of the VM file callbacks.
TEST=ci
Change-Id: I481b6fe3e7eae02ff7f2c94fa2f60bef0a972b3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241685
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-19 23:27:17 +00:00
Ryan Macnak 907f7dd4ae [test] Forward flags such as --enable_asserts --no-sound-null-safety to test subprocess.
Bug: https://github.com/dart-lang/sdk/issues/48833
Change-Id: I56ecc67a21d32f881b6a0ceec05a35eab8e6e2fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241625
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-19 23:04:07 +00:00
Ryan Macnak 32715d1d5b [vm] Mark ELF libraries produced directly by the VM as not requiring an executable stack.
Even if the main program disables executable stacks, dlopen'ing a library that doesn't itself disable executable stack will switch the stack to executable. (Presumably in the name of compatability with GNU nested functions.)

Dart does not need executable stacks, and executable stacks are an additional attack surface.

TEST=readelf
Bug: b/229648756
Change-Id: Ia8c234ebc6178a26528d37b1359a10dd42039a9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241540
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-19 18:51:47 +00:00
Devon Carew 9f398fd728 move runtime/tools/wiki/xref_extractor to package:lints
Change-Id: Ifdf6419bf42baa4dc6df1b4e140e6239d379fe36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240916
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-04-19 15:39:57 +00:00
Ryan Macnak f76b6a8cc1 Reland "[vm] Add a timeline recorder that streams to a file."
Adjust TimelineEvent::PrintJSON to use JSONWriter for compatibility with PRODUCT mode.

TEST=ci
Change-Id: I694889c655719371364012b4324b7947d7b2d5e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240911
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-19 00:56:46 +00:00
Ryan Macnak fd10f5ab28 [vm, gc] Avoid unnecessary nested GcSafepointOperationScopes.
TEST=ci
Change-Id: Ic12d6d1766cf90808716d301abfa216eb597cb1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241201
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-18 23:14:37 +00:00
Ryan Macnak 2c72ea6e03 Reland "[vm] Tweak --verbose_gc."
Remove change to Scavenger::UsedInWords.

TEST=--verbose_gc
Change-Id: I2e4d7f369e7d7c34e488a5c0994a7599a2e78be9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241244
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-18 22:30:36 +00:00
Vyacheslav Egorov eff9944c4f [vm] Fix __unwind_info generation for ARM64 Mach-O
LLVM seems to prefer generating __unwind_info instead of __eh_frame
on certain targets. Unfortunately the way we use CFI directives
in assembly snapshots results in incomplete __unwind_info:
only the first function in the instruction snapshot gets unwinding
information recorded properly.

To fix this we change assembly writer to emit CFI directives
inside each individual function.

TEST=manually via `objdump -u`

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

Change-Id: I027bfe6483dcd7f7e39ab23154abfe12ebc478da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241282
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-18 22:17:54 +00:00
Devon Carew 8cc43aebcb Move runtime/tools/dartfuzz to package:lints.
Change-Id: I55cb7c3a832879202d9be225dcfdce3a12e25487
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241149
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-04-18 22:17:50 +00:00
Ryan Macnak da89828077 [vm] Remove hooks for the embedder to provide a task runner in lieu of the VM's thread pool.
This reverts commit dc3cf83bb6.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/44228
Change-Id: Ia8da6424fd4ebc67e0a2a50e37b1930b4aea5628
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231042
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-18 20:34:57 +00:00
Ryan Macnak e8df2987c7 Revert "[vm] Add a timeline recorder that streams to a file."
This reverts commit 398ef5d693.

Reason for revert: Failures on Android and Fuchsia product builds

Original change's description:
> [vm] Add a timeline recorder that streams to a file.
>
> TEST=ci
> Change-Id: If527a7c7f5dfa11fe6572452e382779b76b16638
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241100
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

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

Change-Id: Iccbcc9084a6a4a7e530f3f53c0b6c0fd424a8cdd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240910
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-14 20:11:15 +00:00
Ryan Macnak 398ef5d693 [vm] Add a timeline recorder that streams to a file.
TEST=ci
Change-Id: If527a7c7f5dfa11fe6572452e382779b76b16638
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241100
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-14 18:50:53 +00:00
Ryan Macnak 66e0d63b1a Revert "[vm] Tweak --verbose_gc."
This reverts commit de6ed2e9a3.

Reason for revert: More accurate Scavenge::UsedInWords has unexpected effects on growth policy

Original change's description:
> [vm] Tweak --verbose_gc.
>
>  - Make flag available in product mode.
>  - Stop including times for subphases. Better information is available in the timeline.
>  - Include the size of the store buffer.
>  - Include used delta.
>
> TEST=--verbose_gc
> Change-Id: I0aa71ffab5b08611e8cef118c1a77ecba61f3482
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241101
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I090224ed2c4ecdc2fb3b5bdfe90d5a2ad9f69f4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241212
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-14 18:20:33 +00:00
Ryan Macnak e7b5a63c6c [vm] Rename DRT_StackOverflow to DRT_InterruptOrStackOverflow.
This hopefully makes things less surprising to folks seeing this runtime entry when looking a profile because most programs don't have real stack overflows.

TEST=ci
Change-Id: I6ef610177ad745f5be7a44854e72ebda183f33da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235040
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-13 22:26:13 +00:00
Ryan Macnak de6ed2e9a3 [vm] Tweak --verbose_gc.
- Make flag available in product mode.
 - Stop including times for subphases. Better information is available in the timeline.
 - Include the size of the store buffer.
 - Include used delta.

TEST=--verbose_gc
Change-Id: I0aa71ffab5b08611e8cef118c1a77ecba61f3482
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241101
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-13 17:22:32 +00:00
Ryan Macnak cf2f4fc4cc [vm, ffi] Explicitly align ClobberAndCall.
Fixes `ld: warning: arm64 function not 4-byte aligned: _ClobberAndCall from obj/runtime/bin/ffi_test/libffi_test_functions.clobber_arm64.o`

TEST=ci
Change-Id: I84cc051655d48ac2eb27e0a12c1edcc8aa8e8a46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241080
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-13 16:03:14 +00:00
なつき c50940b56b Fallback to uname for detecting ARM CPU architecture
Currently running official dart `linux/arm/v7` container image on x86_64 with QEMU results in `Unrecognized ARM CPU architecture`.

This is due to QEMU reporting host `/proc/cpuinfo` instead of the emulated architecture.

Checking `uname` in addition to `/proc/cpuinfo` would make `linux/arm/v7` build work consistently regardless of whether `--use-qemu` is supplied during SDK build time.

TEST=running the qemu bot
TEST=ran the ffi/hardfp_test.dart locally both in AOT and JIT mode.

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

GitOrigin-RevId: d1414d747152d048f3ecaadfd0cd3356ce7a2205
Change-Id: If8b42a700d55e83fea0ee0035848308a3211ec43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238841
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-04-13 07:54:02 +00:00
Daco Harkes 5ca6eec782 [vm/ffi] Add Since annotations to dart:ffi
Closes: https://github.com/dart-lang/sdk/issues/48711

Change-Id: Iac0bcecdf81b02bcb2feb746aa94a1bef6caf600
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240045
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-04-12 11:06:21 +00:00
Alexander Markov 9a8b63d6fa [vm/tests] Fix reachability of Finalizer in vm/dart/finalizer/finalizer_zone_run_gc_test
Finalizer is not guaranteed to run if it becomes unreachable.
The test vm/dart/finalizer/finalizer_zone_run_gc_test incorrectly
assumed that Finalizer stored in a local variable is still reachable
after the last use of variable, but that is not guaranteed.

(Previously, async functions captured local variables into the
context and objects stored in local variables in async functions were
reachable even after variables become unused.
With the new async/await implementation, local variables in async
functions are handled in the same way as in ordinary functions and
not stored into the context, so this test started failing as
Finalizer was garbage collected and not executed.)

TEST=vm/dart/finalizer/finalizer_zone_run_gc_test

Change-Id: Id025556c68c5fc1cf08b06d44cb9d5bbd21dd916
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239860
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-04-11 18:01:22 +00:00
Oleh Prypin a3478da7fa Resolve clang-tidy warnings 'readability-redundant-smartptr-get'
4 instances of the following issue: redundant get() call on smart pointer

Tested: Only through CI. There are no changes in behavior, all possible problems would be found through a compilation failure.
Change-Id: Ib11432baef83d3daebd800b365183e1ea6621136
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240540
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2022-04-11 15:42:01 +00:00
Martin Kustermann 20bb5acf8b [gardening] Mark vm/dart{,_2}/regress47472_test as slow
The test throws 1 million exceptions which can, especially in debug mode
can take very long.

This addresses flaky timeouts of this test in debug mode.

TEST=ci

Change-Id: Ibfa9108d49303d62aa4267c07e03499d0a831292
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240700
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-08 12:23:18 +00:00
Alexander Thomas 8033f609ff [release] Bump version to 2.18
Tested: Default CQ run; Dart VM changes were generated.
Change-Id: If0ea7b9fd2bb0de8459c9d4b39b9cc91cec73e23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240542
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-04-08 08:25:33 +00:00
Ryan Macnak 44c1a24f90 [vm, compiler] Fix ARM64 TSAN.
TEST=local
Change-Id: If7501a69c89763d9e62a5d0eab865e47c38f88cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240322
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-08 00:51:18 +00:00
Ryan Macnak 53c04ff910 [vm] More pieces of Windows ARM support.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47824
Change-Id: Ie7388b12359b9ae11509a3f1b9e86c72507df38f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240483
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-07 23:15:48 +00:00
Siva Annamalai 94bc01240c Revert "[vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)"
This reverts commit 837ee17b43.

Reason for revert: Please see https://github.com/flutter/flutter/issues/101514

Original change's description:
> [vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)
>
> This fixes an issue where VM would run the async* generator after a
> `yield` / `yield*` even though the subscription may be paused or
> cancelled.
>
> Furthermore this fixes an issue where `StackTrace.current` used
> in async* generator crashes VM and/or produces truncated stack
> trace.
>
> This fixes the following existing tests that were failing before:
>
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
>   * language/async_star/async_star_cancel_test
>   * language/async_star/pause_test
>
> Issue https://github.com/flutter/flutter/issues/100441
> Issue https://github.com/dart-lang/sdk/issues/48695
> Issue https://github.com/dart-lang/sdk/issues/34775
>
> TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test
>
> Change-Id: I73f7d0b70937a3e3766b992740fa6fe6e6d57cec
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239421
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ic3d9c0508310a33a2aaee67860c0bb2ec83bab4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240506
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-07 21:46:38 +00:00
Ryan Macnak 2ebfc9fa6d [vm, ffi] Fix some confused register usage during callbacks.
EmitNativeMove is also used during NativeParamterInstr, not just FfiCallInstr, so the trick with WithIntermediateMarshalling doesn't work. Instead, move arguments to their final register in the prologue of FfiCallInstr and remove conflicting uses within FfiCallInstr.

TEST=ffi_2/function_callbacks_test
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I652ab714dbfcb092dc5a23e4596f77136d91ffde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240324
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-07 19:44:48 +00:00
Ben Konyi 240f1c90a1 [ Service ] Update protocol documentation
Clears up confusion around function/field owner locations not
necessarily representing where the function/field was actually declared
(e.g., for functions and fields brought into a class via a mixin
application).

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

TEST=Documentation change

Change-Id: Ideaf17ec99d005459c60a2dd88f72b3485b32664
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240481
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-04-07 16:52:54 +00:00
Johnni Winther 6980a1b4c3 [kernel] Add VariableDeclaration.hasDeclaredInitializer
The computation of default values on super parameters requires the
notion of a declared initializer. By adding this as a flag to
VariableDeclarations the implementation can now be normalized across
parameter from source and dill.

TEST=existing

Change-Id: Ic980e68b569e3bdab38d2c7c7e4374e0c931a87b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240403
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-07 14:54:08 +00:00
Daco Harkes 4b322a398a [vm] Finalizer / NativeFinalizer fixes
1. Run native finalizers before sending isolate exit message. This way
   users can rely on the isolate exit message for both (1) no Dart code
   executing anymore on that isolate _and_ (2) all native finalizers
   having run. Alternatively, we could opt to not provide this second
   guarantee and document this.

2. Fix UBSAN error by making SetArgumentTo42's argument a `void*`.

3. Fix bug in debug mode, stop reading tags from forwarding addresses.

4. Small optimization: Don't promote 0 bytes from new to old space.

5. Skip finalizer_isolate_groups_run_gc_test in optcounter mode.
   In hot reload mode, GC is guaranteed to run. On all other bots GC
   does not run (nothing happens in the other isolate group). However,
   in optcounter mode enough happens in the other isolate group to
   trigger GCs. Alternatively, we could loosen the test to allow either
   a GC to happen or not.

TEST=runtime/tests/vm/dart(_2)/finalizer/*
TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Closes: https://github.com/dart-lang/sdk/issues/48740
Closes: https://github.com/dart-lang/sdk/issues/48715
Closes: https://github.com/dart-lang/sdk/issues/48674

Change-Id: I5e260e087aef48524f2214f5b332caeda18f2e37
Cq-Include-Trybots: luci.dart.try:vm-kernel-ubsan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-canary-linux-debug-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-optcounter-threshold-linux-release-ia32-try,app-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240043
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-04-07 07:05:27 +00:00
Ryan Macnak ea0c27523a [build] Extend bin_to_coff.py to support ARM and ARM64.
TEST=local
Bug: https://github.com/dart-lang/sdk/issues/47824
Change-Id: I9e15bb538e63ee16a2646c78fb786e135d1184ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240441
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-06 22:21:07 +00:00
Martin Kustermann 837ee17b43 [vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)
This fixes an issue where VM would run the async* generator after a
`yield` / `yield*` even though the subscription may be paused or
cancelled.

Furthermore this fixes an issue where `StackTrace.current` used
in async* generator crashes VM and/or produces truncated stack
trace.

This fixes the following existing tests that were failing before:

  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
  * language/async_star/async_star_cancel_test
  * language/async_star/pause_test

Issue https://github.com/flutter/flutter/issues/100441
Issue https://github.com/dart-lang/sdk/issues/48695
Issue https://github.com/dart-lang/sdk/issues/34775

TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test

Change-Id: I73f7d0b70937a3e3766b992740fa6fe6e6d57cec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239421
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-06 10:44:34 +00:00
Martin Kustermann 70241fcbba [vm/concurrency] Avoid racy check in ICData
This CL refactors some ICData code to no longer do O(n) operations.
Instead we maintain strong invariant that ICData's backing store is
always Copy-on-Write modified and sentinenl is always at the end.

This fixes an issue for this code:

  intptr_t ICData::NumberOfChecks() const {
    const intptr_t length = Length();
    for (intptr_t i = 0; i < length; i++) {
      if (IsSentinelAt(i)) {
        return i;
      }
    }
    UNREACHABLE();
    return -1;
  }

Where the `Length()` was cached and another thread could update backing
store.

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

TEST=Should fix iso-stress issue.

Change-Id: I25f7d96258c108214032cf485246d3710f820b31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240044
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-06 07:55:34 +00:00
Ryan Macnak 3d8290d926 [vm] More efficiently access thread CPU time on Mac.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47850
Change-Id: I5719c42b4e2aa0d1a1b02c5e274cdb9b93177ca1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240148
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-05 19:23:43 +00:00
Ryan Macnak f59e196703 [vm, ffi] Callbacks on AOT RISC-V.
TEST=ffi_2/*callback*
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I22e27584247c014fef371dd0a68bc01e73c73b5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240141
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-05 18:23:03 +00:00
Martin Kustermann 87b9fd5695 [gardening] Make timing-dependent vm/cc/SafepointOperation_SafepointPointTest more robust
This test of safepoint operations has some probability of failing due to
dependence on timing of events.

This CL will lower probability of test failure by ensuring the helper
threads will try hard to join in normal way (and fail to do so if
expected) before unblocking main thread to continue.

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

TEST=ci

Change-Id: Ibd9b8573248bd2efc0c45525affa640adb7517a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239665
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-05 10:14:44 +00:00
Ryan Macnak 1af37bd92a [vm, compiler] Use AMOs in the RISC-V write barrier.
AMOs are more efficient than a LR/SC pair.

TEST=ci
Change-Id: I74915669bf4d13b92c04ed6ef21d61dd58df36ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240142
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-05 00:01:32 +00:00
Siva Annamalai ac6f72205a Revert "[VM/io] - Set correct file type for files backing unix domain sockets"
This reverts commit dbe6d1d574.

Reason for revert: One of the new tests spawns a process and runs the script from source and so this test will fail on all AOT configurations, In addition it is failing on mac builds and needs investigation.

Original change's description:
> [VM/io] - Set correct file type for files backing unix domain sockets
>
> The file type of file backing unix domain sockets was being incorrectly
> set as kDoesNotExist resulting in errors when operations like delete
> on the file was done. File::Exists on the other hand returned true.
> File rename and copyfile functionality have been fixed too.
>
> TEST=new tests added
>
> Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.
> Change-Id: Ie9c716c84b1d818c906ecdb622ba930125f9ee30
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237745
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

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

Change-Id: I517896fb90b013af1ce9a6754442a922e2b7cda5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240149
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 23:30:02 +00:00
asiva dbe6d1d574 [VM/io] - Set correct file type for files backing unix domain sockets
The file type of file backing unix domain sockets was being incorrectly
set as kDoesNotExist resulting in errors when operations like delete
on the file was done. File::Exists on the other hand returned true.
File rename and copyfile functionality have been fixed too.

TEST=new tests added

Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.
Change-Id: Ie9c716c84b1d818c906ecdb622ba930125f9ee30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237745
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 22:17:42 +00:00
asiva 89f5b68ca1 [VM / IO] Fix cases where TlsExceptions were being created with an
OSError code of 0

One such example was _SecurityContext.setTrustedCertificatesBytes

TEST=new tests added

Change-Id: Ibc5d06b83bb1bb93e12f79100acc60546554c268
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239863
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 21:57:22 +00:00
asiva 4f76b9535d [VM / IO] Assert When a socket exception is being thrown with an error code of 0.
TEST=ci

Change-Id: Ie0ea5329dfe0307f47fc04db693dae4e352d0f64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239846
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 21:34:21 +00:00
Alexander Aprelev 0b49bb6e37 [io/win] Ensure File_WriteFrom and File_Read report non-zero error code.
BUG=https://github.com/dart-lang/sdk/issues/48721
TEST=file_error2_test,file_fuzz_test on win ia32

Change-Id: I260c3fa46bc737db741b3b9ae9172c939648aa6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239861
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-04-02 04:11:59 +00:00
Slava Egorov 4c0387461c Revert "[VM / IO] - Reland : Assert when an OSError exception is reported with no error"
This reverts commit dc8002cc42.

Reason for revert: crashes internally (b/227727791) and externally (dartbug.com/48721)

Original change's description:
> [VM / IO] - Reland : Assert when an OSError exception is reported with no error
>
> 1. Add a Fatal assert when an OSError is reported with no error code (0).
> This is to ensure we get a coredum pwhen this happens so we can analyze
> it. (Please see https://github.com/flutter/flutter/issues/90921 for more
> details)
>
> TEST=ci
>
> Change-Id: I7146ac69ef8b1833f28bed8a23f0c27a2ece4bbf
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239726
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

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

Change-Id: Ic9302e7922b0ce2ea5ab81357804c3cd822a8052
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239664
Reviewed-by: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-01 10:14:37 +00:00
asiva dc8002cc42 [VM / IO] - Reland : Assert when an OSError exception is reported with no error
1. Add a Fatal assert when an OSError is reported with no error code (0).
This is to ensure we get a coredum pwhen this happens so we can analyze
it. (Please see https://github.com/flutter/flutter/issues/90921 for more
details)

TEST=ci

Change-Id: I7146ac69ef8b1833f28bed8a23f0c27a2ece4bbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239726
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-03-31 22:18:15 +00:00
Ryan Macnak 84d45cd032 [vm, ffi] Restore PP after leaf callouts on RISC-V.
PP is a volatile register on RISC-V to take advantage of compressed instructions, and a preserved register on the other architectures.

TEST=ffi_2/function_structs_test
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I947d6fd8171b8c0c7aa8eb524537038655177e27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238720
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-31 22:10:05 +00:00
Alexander Aprelev 67c6e2311a [io/win] Use filewin api which is coordinated with GetLastError, rather than errno.
Fixes https://github.com/dart-lang/sdk/issues/48718
TEST=file_test

Change-Id: Ie47fa7807b96832140e8b9d5df53b47ffa0ecc67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239725
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-31 20:51:25 +00:00
Ryan Macnak b262b845fb [vm] Generate nicer static symbols for Dart code.
TEST=ci
Change-Id: I58187fc89aa3be935e70dbdd2316b17aadf50574
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239465
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-31 20:24:56 +00:00
Ryan Macnak aeed1fd35a [vm, ffi] Port missing safepoint transition code to RISC-V.
Cf. cb64a64241.

 - Fix misaligned stack during some callouts.
 - Fix clobbered PP during some callouts.

TEST=vmspecific_handle_test
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I4650219e96f8592bf7e1790f9ff0b71c109c1ff6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239760
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-31 20:11:35 +00:00
Brian Quinlan c286b76c2d Allow sockets to enable TLS renegotiation.
TESTED=unit + manually tested user issue.
Bug: https://github.com/dart-lang/sdk/issues/47841
Change-Id: Iad13899135fd34f15abba3a499132d88e7f597dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234821
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-03-31 06:40:51 +00:00
Alexander Aprelev 3a4adb776e Revert "[VM / IO] - Assert when an OSError exception is reported with no error"
This reverts commit 9038f5e1f7.

Reason for revert: broke g3 bot blocking dart->engine roll

Original change's description:
> [VM / IO] - Assert when an OSError exception is reported with no error
>
> Add a Fatal assert when an OSError is reported with no error code (0).
> This is to ensure we get a coredum pwhen this happens so we can analyze
> it. (Please see https://github.com/flutter/flutter/issues/90921 for more
> details)
>
> TEST=ci
>
> Change-Id: I7f4609c2431e6ddc4eacc753356c807d7338b0a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239541
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

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

Change-Id: I87df53a7d81802ad1a88f54a90a49f88db44108b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239602
Reviewed-by: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-31 03:09:42 +00:00
asiva 9038f5e1f7 [VM / IO] - Assert when an OSError exception is reported with no error
Add a Fatal assert when an OSError is reported with no error code (0).
This is to ensure we get a coredum pwhen this happens so we can analyze
it. (Please see https://github.com/flutter/flutter/issues/90921 for more
details)

TEST=ci

Change-Id: I7f4609c2431e6ddc4eacc753356c807d7338b0a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239541
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-03-31 01:24:43 +00:00
Ryan Macnak f2d3051598 [vm] Some pieces for Windows ARM support.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47824
Change-Id: Iaf401f4d25fc5bf171170728d4a5d3ae6ef17527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239369
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-30 19:01:33 +00:00
Ryan Macnak 8a280c90f9 [build] -fno-strict-vtable-pointers is a Clang-only flag.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48703
Change-Id: I76dc6abe2ad709b5ae6c9df31db5174774b8ae9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239324
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-30 17:34:20 +00:00
Martin Kustermann 46e7d54050 [vm] Be more lenient when assumptions about _StreamIterator._stateData field is not a Future
Issue https://github.com/flutter/flutter/issues/100441
Issue https://github.com/dart-lang/sdk/issues/48695

TEST=vm/dart{,_2}/flutter_regress_100441_test

Change-Id: Ifdd331dc3b0a2b825a938132808b4021c0af5f71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239311
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-03-30 15:35:22 +00:00
Johnni Winther 88846ca4b4 [kernel] Remove unused Typedef fields
The fields typeParametersOfFunctionType, positionalParameters,
and namedParameters were never used.

TEST=existing

Change-Id: I0ca1c546fdf94df9c3248164a56ed88cd2468b18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239310
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-30 13:01:40 +00:00
Clement Skau ba341d740a [vm] Avoid spills for most FFI leaf calls.
Adds an additional `contains_call` mode specifying that the
register allocator should block all non-callee-save ABI registers.
As opposed to `kCall`, this frees the use of callee-save registers
across FfiCallInstr, meaning that live values do not always have
to be spilled.
For architectures with sufficient free callee-save registers
this should result in less overhead for each FfiCall.

This change also removes RequiresStackSlot as it was only being
used for FfiCall's TypedData, and wasn't implemented in the
Register Allocator.
Since FfiCall no longer blocks all registers TypedData can now
live in a register, so the previous assumptions about it always
being on stack have to be relaxed.

This change also works around an issue where the register allocator
might allocate an FPU register that does not have an associated S
register. This causes problems when FFI tries to pass 32 bit floats
in said register.
As a work around we block all FPU regs. above the 8 that have S regs.
for FFI calls in VFPv3-D32 mode.

This change also adds an additional temp registers which was previous
used but not being reserved in FfiCall IL on Arm64.

Some additional prereq. fixes were branched out into:
https://dart-review.googlesource.com/c/sdk/+/237690

TEST=Adds IRTest_FfiCallInstrLeafDoesntSpill.

Bug: https://github.com/dart-lang/sdk/issues/45468
Change-Id: Icdeccb0de77e46f5bc34dd5bd4e308d27bc1ef99
Cq-Do-Not-Cancel-Tryjobs: true
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-win-release-x64-try, vm-precomp-ffi-qemu-linux-release-arm-try, vm-kernel-mac-release-arm64-try, vm-kernel-nnbd-mac-debug-arm64-try, vm-kernel-nnbd-mac-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221624
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-03-30 10:57:26 +00:00
Ryan Macnak 9166b3eb9d [vm] Avoid vtable loads being hoisted above vtable stores.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48659
Bug: https://github.com/dart-lang/sdk/issues/48681
Change-Id: I23c4900862a534864790b0c587f61cdd7b9e4bfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239242
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-29 20:54:29 +00:00
Tess Strickland 95d1ae911d [vm] Reduce class id reloads in TTSes when possible.
Now GenerateCidRangesCheck in the flow graph compiler returns
whether the class id register was clobbered, so users that
make multiple calls to it for the same cid know whether the cid
needs reloading after the generated check.

Also unifies FlowGraphCompiler::EmitTestAndCheckCid across
architectures, since the non-Intel versions would have
always forced reloading.

TEST=vm/cc/TTS

Change-Id: I08835dc97ba457b7dc8dfa51206b4741a607db22
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-nnbd-mac-release-arm64-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-linux-debug-simriscv64-try,vm-kernel-precomp-linux-debug-simriscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238583
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-29 08:03:35 +00:00
Tess Strickland 6bec28da38 [vm] Only check for Smi once when reloading cid for TTS cid checks.
When generating a type testing stub (TTS) for implemented classes,
multiple cid range check blocks may be generated, each of which
requires reloading the cid. This CL makes it so that only a single
Smi check will be generated the first time the cid is loaded, so
later checks can just load the cid directly without the Smi case.

TEST=vm/cc/TTS

Change-Id: I4d76ee34a03cf4a0def268e9f74a096e3c0deb58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238702
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-29 07:48:45 +00:00
Ryan Macnak 91214d4457 [vm, ffi] Fix function types involving NativeFinalizer to satisfy UBSAN.
TEST=ubsan
Bug: https://github.com/dart-lang/sdk/issues/48680
Change-Id: Iebfc70a480f920b9a63758f16c2d4b0ea80b51c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239204
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-28 23:56:20 +00:00
Ryan Macnak b8091f54d2 [vm, compiler] Fix PopNativeCalleeSavedRegisters on Fuchsia ARM64.
Check the right register set when deciding if there is a leftover pop single. This worked by accident on non-Fuchsia ARM64 because there is an even number for both CPU and FPU registers, but Fuchsia has a different number of preserved CPU registers due to the shadow call stack.

TEST=no Fuchsia ARM64 bots; inspect disassembly of the entry stub
Bug: b/226647006
Change-Id: Ie0c7fa4a3b713d5b9fb21e9e778d620c7728bc39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239160
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-28 20:11:53 +00:00
Tess Strickland b231a373bf [vm/test] Make vm/cc/TTS_Regress_CidRangeChecks less brittle.
Since we're adding the classes in a known order, we can calculate
how many unrelated classes are needed to align the cids from
the next cid to be allocated.

TEST=TTS_Regress_CidRangeChecks

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

Change-Id: I04b750c64cf739bc6ba0bda2a93373a6443cedaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239025
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-28 11:20:52 +00:00
Daco Harkes 90f118484f [vm/ffi] Add Char C type
The diff from
https://dart-review.googlesource.com/c/sdk/+/229156/1..3

This was blocked by https://github.com/timsneath/win32/issues/349
earlier. Now that that has been resolved, we should be able to land
this.

We should land this to make package:ffigen be able to bind to `char` in
Dart 2.17.
https://github.com/dart-lang/ffigen/pull/287#discussion_r835734993

TEST=tests/ffi/c_types_test.dart

Change-Id: Ia3bc3785a3d5c0c9f7475106eb77f944f2d0a838
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239020
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-03-28 09:46:56 +00:00
Clement Skau 567e5008ef [vm/test] Adds regression test for movb on x64.
Fixed in: https://dart-review.googlesource.com/c/sdk/+/237690

Adds MoveByteRunTest, testing that we emit the correct assembly
for movb so that we are able to run it.

This includes a fix for the issue the cause this same change to
previously get reverted:
https://github.com/dart-lang/sdk/issues/48661
Namely, the test now saves RDI since it is non-volatile on Windows.

TEST=Adds cc/vm/MoveByteRunTest
Cq-Include-Trybots: luci.dart.try:dart-sdk-win-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-win-debug-x64-try
Change-Id: I97cad1367a5d33cfca36a880260e1771052af003
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238701
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-03-28 06:57:20 +00:00
Daco Harkes 532c116cd2 [vm] Implement NativeFinalizer
This CL implements `NativeFinalizer` in the GC.

`FinalizerEntry`s are extended to track `external_size` and in which
`Heap::Space` the finalizable value is.

On attaching a native finalizer, the external size is added to the
relevant heap. When the finalizable value is promoted from new to old
space, the external size is promoted as well. And when a native
finalizer is run or is detached, the external size is removed from the
relevant heap again.

In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate
shutdown.

When the `NativeFinalizer`s themselves are collected, the finalizers are
not run. Users should stick the native finalizer in a global variable to
ensure finalization. We will revisit this design when we add send and
exit support, because there is a design space to explore what to do in
that case. This current solution promises the least to users.

In this implementation native finalizers have a Dart entry to clean up
the entries from the `all_entries` field of the finalizer. We should
consider using another data structure that avoids the need for this Dart
entry. See the TODO left in the code.

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

TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
Tess Strickland 92a2a74cb7 [vm] Add tests for FutureOr normalization.
TEST=vm/cc/AbstractType_NormalizeFutureOrType
     vm/cc/AbstractType_InstantiatedFutureOrIsNormalized

Change-Id: I2d916bcb9c0ec433b5920c7179d87fec115b3e9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237302
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-25 13:47:00 +00:00
Tess Strickland 01e1d24eea [vm] Add regression test for e2fa5d8d.
Have manually tested that the test crashes if the fix in that commit
is reverted.

TEST=TTS_Regress_CidRangeChecks

Change-Id: Id53892e4bdefbf52fba630bf6cb73743128ad5f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238704
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-25 12:11:51 +00:00
Daco Harkes e151a81108 Reland "[vm] Implement Finalizer"
Original CL in patchset 1.
Split-off https://dart-review.googlesource.com/c/sdk/+/238341
And pulled in fix https://dart-review.googlesource.com/c/sdk/+/238582
(Should merge cleanly when this lands later.)

This CL implements the `Finalizer` in the GC.

The GC is specially aware of two types of objects for the purposes of
running finalizers.

1) `FinalizerEntry`
2) `Finalizer` (`FinalizerBase`, `_FinalizerImpl`)

A `FinalizerEntry` contains the `value`, the optional `detach` key, and
the `token`, and a reference to the `finalizer`.
An entry only holds on weakly to the value, detach key, and finalizer.
(Similar to how `WeakReference` only holds on weakly to target).

A `Finalizer` contains all entries, a list of entries of which the value
is collected, and a reference to the isolate.

When a the value of an entry is GCed, the enry is added over to the
collected list.
If any entry is moved to the collected list, a message is sent that
invokes the finalizer to call the callback on all entries in that list.

When a finalizer is detached by the user, the entry token is set to the
entry itself and is removed from the all entries set.
This ensures that if the entry was already moved to the collected list,
the finalizer is not executed.

To speed up detaching, we use a weak map from detach keys to list of
entries. This ensures entries can be GCed.

Both the scavenger and marker tasks process finalizer entries in
parallel.
Parallel tasks use an atomic exchange on the head of the collected
entries list, ensuring no entries get lost.
The mutator thread is guaranteed to be stopped when processing entries.
This ensures that we do not need barriers for moving entries into the
finalizers collected list.
Dart reads and replaces the collected entries list also with an atomic
exchange, ensuring the GC doesn't run in between a load/store.

When a finalizer gets posted a message to process finalized objects, it
is being kept alive by the message.
An alternative design would be to pre-allocate a `WeakReference` in the
finalizer pointing to the finalizer, and send that itself.
This would be at the cost of an extra object.

Send and exit is not supported in this CL, support will be added in a
follow up CL. Trying to send will throw.

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

TEST=runtime/tests/vm/dart/finalizer/*
TEST=runtime/tests/vm/dart_2/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc

Change-Id: Ibdfeadc16d5d69ade50aae5b9f794284c4c4dbab
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-analyze-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238086
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-25 10:29:30 +00:00
Tess Strickland e2fa5d8d09 [vm] Fix for BuildLoadInstanceTypeArguments in TTS generation.
We must load the class id from the instance prior to _each_
subtype range check, as GenerateCidRangesCheck can clobber that
register during the check.

TEST=Manually tested by @dcharkes using repro from CL 238480.
     Will add regression test on separate CL.

Change-Id: I1de6f4fdd9011f241d785082b4b4866d8b24fcfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238582
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-25 10:23:50 +00:00
Ryan Macnak e3c1042d74 [vm, compiler] Fix I-type overflows in some variants of LoadFromOffset.
TEST=ffi_2/function_callbacks_many_test
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: If4a215c53c98162f933532541145b6753e24a61f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238662
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-24 22:55:39 +00:00
Ben Konyi 4fa407abd5 Revert "[vm/test] Adds regression test for movb on x64."
This reverts commit d0c65801c0.

Reason for revert: https://github.com/dart-lang/sdk/issues/48661

TEST=N/A, revert

Original change's description:
> [vm/test] Adds regression test for movb on x64.
>
> Fixed in: https://dart-review.googlesource.com/c/sdk/+/237690
>
> Adds MoveByteRunTest, testing that we emit the correct assembly
> for movb so that we are able to run it.
>
> TEST=Adds cc/vm/MoveByteRunTest
> Change-Id: I97a854119c5abbca79f3fb55e208a3169b64b9d9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238040
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Clement Skau <cskau@google.com>

TBR=kustermann@google.com,cskau@google.com

Change-Id: Ifd5962b256b530bebf7684ec63d9f6201e1eb91c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238664
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-03-24 21:21:36 +00:00
Ryan Macnak 464bece529 [vm, compiler] Fix some stack alignment for RISC-V FFI.
- Fix bad frame walk from assuming kSavedCallerFpSlotFromFp is 0.
 - Fix sign of WChar.
 - Fix missing sign-extension in some cases of passing uint32.

TEST=qemu
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: Idc1699d473a115153b4b4e6fdc9f84519055de00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238386
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-24 20:45:09 +00:00
Ryan Macnak 6dfdbeefb6 [vm] Fix mismatch between ARM64 Simulator::JumpToFrame and StubCode::JumpToFrame.
In 67f93d3840, the simulator was extended to simulate signal handlers clobbering below CSP, but Simulator::JumpToFrame didn't kick CSP back near the stack limit.

TEST=fuzzer (anything with exceptions in debug simarm64)
Change-Id: I233388c9a73181521d6760e7a2f9c9dfe57e33ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238463
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-24 17:12:29 +00:00
Jason Simmons 0f225a8dea [vm] Remove underscore in copyright header
TEST=comment only change
Change-Id: I4e943046b67ed9708bc95bf72890c65ea49167c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238602
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2022-03-24 15:34:49 +00:00
Clement Skau d0c65801c0 [vm/test] Adds regression test for movb on x64.
Fixed in: https://dart-review.googlesource.com/c/sdk/+/237690

Adds MoveByteRunTest, testing that we emit the correct assembly
for movb so that we are able to run it.

TEST=Adds cc/vm/MoveByteRunTest
Change-Id: I97a854119c5abbca79f3fb55e208a3169b64b9d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238040
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-03-24 15:09:31 +00:00
Tess Strickland e0b06dd49b [vm] Add documentation for WeakSerializationReference macros.
TEST=Documentation changes only.

Change-Id: I67da02f186c61793e38a8f44b8a89c35ff32c9f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238580
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-24 13:58:01 +00:00
Tess Strickland cdb703859a [dart2native] Allow for signing of Windows standalone executables.
Instead of simply concatenating the dartaotruntime executable and the
ELF snapshot, we instead insert the ELF snapshot as a COFF section,
so the resulting PE file can be signed.

TEST=pkg/dartdev/test/commands/compile_test

Bug: https://github.com/dart-lang/sdk/issues/39106
Change-Id: Iaafb5833fcb9c69c0dd374b64769f22b8b9f53a2
Cq-Include-Trybots: luci.dart.try:pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236100
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-24 10:08:01 +00:00
Ryan Macnak 1f51957d2a [vm, compiler] Add missing volatile FPU registers to save on leaf runtime calls.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48645
Change-Id: I3454fa695e98c9bf2de9d32fc8b0f1187281c3d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238301
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-23 21:35:31 +00:00
Daco Harkes c7c7a17adf [vm] Refactor delayed lists in GC
This refactors the delayed lists in the marker and scavenger, but does
not have any behavior changes.

Split off https://dart-review.googlesource.com/c/sdk/+/238086

TEST=running test suites will trigger GC.

Change-Id: I82ca4c3dca3351b6543bafaee1318b8e0da75f1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238341
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-23 19:26:11 +00:00
Ben Konyi d7935c209d [ Profiler ] Avoid building empty CPU profiles when sample streaming is enabled
Building an empty CPU profile is still costly as function tables are
populated whether or not there's samples in the profile. This change
checks to see if any sample in the list of SampleBlocks was collected
under a UserTag with streaming enabled before building the profile.

TEST=CQ, manual testing

Change-Id: Ib526f9999a8b2bf48a7df1488c7dcf959031cf5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238183
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-03-23 18:30:21 +00:00
Vyacheslav Egorov 3e697cd1dd [vm/elf] Use correct kWordSize in cfa_offset.
We were generating unwinding information using host word size
instead of target word size.

TEST=manually

Bug: b/220804295
Change-Id: I5adacf2b7ecdf8af90ed6e7b25ae76e12b76124f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238085
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-03-22 23:16:10 +00:00
Ryan Macnak c4e913c839 [vm] Further make [os_]thread_absl.cc compatible with Mac.
TEST=ci, cbuild
Change-Id: I0fa9c11bbe826f71494cc9f7c89caed4f3597629
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238161
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-22 22:41:50 +00:00
Ryan Macnak 67f93d3840 [vm] Refactor compilation of runtime calls.
- Fixes SIMD registers clobbered by write barrier on ARM64.
 - Moves code generation out of non-compiler directory.
 - Removes unnecessary building of Dart frames on leaf runtime calls.
 - Removes unnecessary Threads slots for write barrier Code objects.
 - Removes duplicate saves of SP in leaf runtime calls on ARM64 and RISC-V.
 - Avoids some redundant SP updates on RISC-V.

TEST=ci
Change-Id: Idb92127658edc90b320923ef3d882a7219a450ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236842
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-22 19:45:03 +00:00
Alexander Aprelev 435ebeb5a7 Fix MSVC build
- refactor designated initializers as they are c++20
- unwrap #if/#endif in macro arguments
- remove taking pointer on purely intrinsic function (setjmp_)
- use DART_WARN_UNUSED_RESULT which is msvc/clang friendly
- provide StringRAII copying constructor

Bug: https://github.com/dart-lang/sdk/issues/48544
TEST=ci,msvc build
Change-Id: I1049589c96dc0cdf49e1d31d320b6804bf6e4558
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237929
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-22 18:28:19 +00:00
Daco Harkes 37526fc8d7 Revert "[vm] Implement Finalizer"
This reverts commit 7dca34c235.

Reason for revert: b/226085355 dart_vm_test crashing. Unclear what
the cause is. Reverting so we can triage the issue.

TEST=This is a revert.

Original change's description:
> [vm] Implement `Finalizer`
>
> This CL implements the `Finalizer` in the GC.
>
> (This CL does not yet implement `NativeFinalizer`.)
>
> The GC is specially aware of two types of objects for the purposes of
> running finalizers.
>
> 1) `FinalizerEntry`
> 2) `Finalizer` (`FinalizerBase`, `_FinalizerImpl`)
>
> A `FinalizerEntry` contains the `value`, the optional `detach` key, and
> the `token`, and a reference to the `finalizer`.
> An entry only holds on weakly to the value, detach key, and finalizer.
> (Similar to how `WeakReference` only holds on weakly to target).
>
> A `Finalizer` contains all entries, a list of entries of which the value
> is collected, and a reference to the isolate.
>
> When a the value of an entry is GCed, the enry is added over to the
> collected list.
> If any entry is moved to the collected list, a message is sent that
> invokes the finalizer to call the callback on all entries in that list.
>
> When a finalizer is detached by the user, the entry token is set to the
> entry itself and is removed from the all entries set.
> This ensures that if the entry was already moved to the collected list,
> the finalizer is not executed.
>
> To speed up detaching, we use a weak map from detach keys to list of
> entries. This ensures entries can be GCed.
>
> Both the scavenger and marker tasks process finalizer entries in
> parallel.
> Parallel tasks use an atomic exchange on the head of the collected
> entries list, ensuring no entries get lost.
> The mutator thread is guaranteed to be stopped when processing entries.
> This ensures that we do not need barriers for moving entries into the
> finalizers collected list.
> Dart reads and replaces the collected entries list also with an atomic
> exchange, ensuring the GC doesn't run in between a load/store.
>
> When a finalizer gets posted a message to process finalized objects, it
> is being kept alive by the message.
> An alternative design would be to pre-allocate a `WeakReference` in the
> finalizer pointing to the finalizer, and send that itself.
> This would be at the cost of an extra object.
>
> Send and exit is not supported in this CL, support will be added in a
> follow up CL. Trying to send will throw.
>
> Bug: https://github.com/dart-lang/sdk/issues/47777
>
> TEST=runtime/tests/vm/dart/finalizer/*
> TEST=runtime/tests/vm/dart_2/isolates/fast_object_copy_test.dart
> TEST=runtime/vm/object_test.cc
>
> Change-Id: I03e6b4a46212316254bf46ba3f2df333abaa686c
> Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-analyze-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229544
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TBR=lrn@google.com,vegorov@google.com,kustermann@google.com,rmacnak@google.com,dacoharkes@google.com

Change-Id: I991f6e49896d18a8d70210cf315d858b462d66c9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/47777
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-analyze-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238080
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-22 11:55:38 +00:00