Commit graph

556 commits

Author SHA1 Message Date
Ryan Macnak 6694cae4d7 [vm, gc] Incremental compaction, take 3.
- Use atomics to mark remembered cards in the write barrier stub.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/52513
Bug: https://github.com/dart-lang/sdk/issues/55754
Change-Id: I1f78c6b680a6ae9170613ba328a244335a6343e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368480
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-05-30 21:01:39 +00:00
Martin Kustermann 698bf0846b [vm] Hoist CStringUniquePtr out of Utils, add CAllocUniquePtr` to simplify code
Hoist `CStringUniquePtr` out of the `Utils` class as there
is no reason it has to be nested inside a class - it just makes
code more verbose.

This simplifies code of the form
   std::unique_ptr<T, decltype(std::free)> a = { nullptr, std::free };
to
   CAllocUniquePtr<T> a;

TEST=ci

Change-Id: Ice42c1b16dfa5b20b321c13fbe5b28b3918581cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368425
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-05-29 10:16:28 +00:00
Daco Harkes b732c96e8a Revert "[vm, gc] Incremental compaction, take 2."
This reverts commit 9077bf991f.

Reason for revert: CBuild and TGP crashes in random Dart code which
look a lot like arbitrary memory corruption.

Original change's description:
> [vm, gc] Incremental compaction, take 2.
>
> - Fix missing store buffer flush when --marker_tasks=0.
> - Fix passing untagged pointer to store barrier check on ARM/ARM64 (6bc417dd17).
> - Fix passing uninitialized header to store barrier check on ARM64/RISCV (1447193053).
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/52513
> Bug: https://github.com/dart-lang/sdk/issues/55754
> Change-Id: Id2aa95b6d776b82d83464cde0d00e6f3b29b7b77
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367202
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>

Bug: https://github.com/dart-lang/sdk/issues/52513
Bug: https://github.com/dart-lang/sdk/issues/55754
Change-Id: I1d70d33c65fe6bf7089b8c1422d59f9146ae7ebf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367962
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-05-23 19:00:50 +00:00
Ryan Macnak 9077bf991f [vm, gc] Incremental compaction, take 2.
- Fix missing store buffer flush when --marker_tasks=0.
- Fix passing untagged pointer to store barrier check on ARM/ARM64 (6bc417dd17).
- Fix passing uninitialized header to store barrier check on ARM64/RISCV (1447193053).

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/52513
Bug: https://github.com/dart-lang/sdk/issues/55754
Change-Id: Id2aa95b6d776b82d83464cde0d00e6f3b29b7b77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367202
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-05-21 16:33:00 +00:00
Ryan Macnak 42ec219908 Revert "[vm, gc] Incremental compaction."
This reverts commit bc0f02e4c8.

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

Original change's description:
> [vm, gc] Incremental compaction.
>
> At the beginning of a major GC cycle, select some mostly-empty pages to be evacuated. Mark the pages and the objects on these pages. Apply a write barrier for stores creating old -> evacuation candidate pointers, and discover any such pointers that already exist during marking.
>
> At the end of a major GC cycle, evacuate objects from these pages. Forward pointers of objects in the remembered set and new-space. Free the evacuated pages.
>
> This compaction is incremental in the sense that creating the remembered set is interleaved with mutator execution. The evacuation step, however, is stop-the-world.
>
> Write-barrier elimination for x.slot = x is removed. Write-barrier elimination for x.slot = constant is removed in the JIT, kept for AOT but snapshot pages are marked as never-evacuate.
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/52513
> Change-Id: Icbc29ef7cb662ef8759b8c1d7a63b7af60766281
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357760
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Bug: https://github.com/dart-lang/sdk/issues/52513
Change-Id: I565ad6c0fca283d33f605c10f181bc0a59e7d2b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366965
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-05-17 18:03:42 +00:00
Ryan Macnak bc0f02e4c8 [vm, gc] Incremental compaction.
At the beginning of a major GC cycle, select some mostly-empty pages to be evacuated. Mark the pages and the objects on these pages. Apply a write barrier for stores creating old -> evacuation candidate pointers, and discover any such pointers that already exist during marking.

At the end of a major GC cycle, evacuate objects from these pages. Forward pointers of objects in the remembered set and new-space. Free the evacuated pages.

This compaction is incremental in the sense that creating the remembered set is interleaved with mutator execution. The evacuation step, however, is stop-the-world.

Write-barrier elimination for x.slot = x is removed. Write-barrier elimination for x.slot = constant is removed in the JIT, kept for AOT but snapshot pages are marked as never-evacuate.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/52513
Change-Id: Icbc29ef7cb662ef8759b8c1d7a63b7af60766281
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357760
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-05-16 23:26:08 +00:00
Ryan Macnak b3287af10e [vm] Remove MSAN_UNPOISONs around print and sort functions.
This was probably fixed by ddc11f8084.

TEST=msan
Change-Id: I05f58b382ad186929bd4dbf56e905568cb268d96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366683
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-05-16 16:33:52 +00:00
Ryan Macnak 8c1de038e0 [vm, compiler] Allow targeting TSAN or MSAN by passing a flag to gen_snapshot.
Add check that the snapshot and runtime agree on whether to use MSAN. We already have this check for TSAN.

TEST=vm/dart/sanitizer_compatibility_test
Bug: https://github.com/dart-lang/sdk/issues/55637
Bug: https://github.com/dart-lang/sdk/issues/55638
Change-Id: I320e6f55cd59209ce6e58a82ac205a87c8a60a84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365487
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-05-08 17:03:59 +00:00
Daco Harkes f98a2138b7 [vm] Run clang-format on code base
When uploading CLs, the presubmit checks verify that the lines in the
diff are formatted correctly according to `git cl format runtime`.

However, when `buildtools/<os>-<arch>/clang/bin/clang-format` is
updated, it does not force reformatting of files that would be
reformatted.

This leads to two issues:
* Inconsistent style within the code base and within a single file.
* Spurious reformatting in CLs when (1) clang-format is used on the
  whole file, or (2) the diff lines overlap.

`clang-format` doesn't change that frequently, so in general this is
not a large issue, but I've seen a bit too many "spurious formatting,
please revert" comments on CLs recently.

This CL formats the runtime to be in line with the current pinned
`clang-format`:

```
$ find runtime/ -iname *.h -o -iname *.cc | xargs buildtools/mac-arm64/clang/bin/clang-format -i
```

`git cl format` (which only formats changed lines, and does so with
`clang-format`) seems to not agree with itself, or clang-format, or
cpplint in a handful of places. This CL adds `// clang-format off`
for these. (See previous patchsets for the specific instances.)

TEST=A variety of bots including GCC, MacOS and Windows.

Change-Id: I470892e898971899fda14bb3b8f2c8efefd67686
Cq-Include-Trybots: luci.dart.try:vm-gcc-linux-try,vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-win-debug-x64-try,vm-win-debug-x64c-try,vm-mac-debug-x64-try,vm-mac-debug-arm64-try,vm-aot-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362780
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-04-17 19:14:41 +00:00
Tess Strickland 0d3ade255b [vm/compiler] Limit exposure of untagged pointers to managed memory.
After https://dart-review.googlesource.com/c/sdk/+/330600, there were
more chances for the optimizing compiler to introduce or move
GC-triggering instructions like allocations or boxings between the
retrieval of an untagged pointer to GC-moveable memory and its use.

To limit the chance of this happening, this CL removes the explicit
loading of the untagged payload address when building the initial
flow graph in most cases when the array is not known to be an external
array (an external string, an external typed data object, or an FFI
Pointer).

The remaining case is during view allocation, which extracts the
payload address of the base typed data object underlying the view
(which may be GC-movable) to calculate the payload address that should
be stored in the data field of the view object. See
https://github.com/dart-lang/sdk/issues/54884.

During canonicalization of LoadIndexed, StoreIndexed, and MemoryCopy
instructions, if the cid of an array input is an external array
(external string, external typed data object, or Pointer), then a
LoadField instruction that extracts the untagged payload address
is inserted before the instruction and the corresponding input is
rebound to that LoadField instruction.

Once all compiler passes that involve code motion have been performed,
a new pass looks for LoadIndexed, StoreIndexed, or MemoryCopy where
the cid stored in the instruction for the array is a typed data cid.
In these cases, if the array is not an internal typed data object,
then the payload address is extracted. Waiting until this point ensures
that no GC-triggering instructions are inserted between the extraction
of the payload address and the use. (Internal typed data objects are
left as-is because the payload address is inside the object itself
and doesn't require indirection through the data field of the object).

This CL also replaces code conditional on the array cid with code
that is instead conditional on the array element representation in
cases where it makes sense to do so, since this is a less brittle
check than checking the array cid (e.g., checking for kUnboxedInt8
to load, store, or copy an signed byte from an array instead of
listing all possible array cids that store signed bytes).

This CL also fixes an issue with the ARM64 assembler where calling
LoadFromOffset with an Address that has a non-Offset type would
silently generate bad code instead of triggering the ASSERT in
PrepareLargeOffset.

TEST=vm/dart/typed_list_index_checkbound_il_test

Issue: https://github.com/dart-lang/sdk/issues/54710
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-release-ia32-try
Change-Id: I25b5f314943e9254d3d28986d720a5d47f12feeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352363
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-03-22 10:12:39 +00:00
Zijie He 476ed37a25 Reland "[Fuchsia] Remove the legacy gn build rules for fuchsia"
This change may require a codereview from flutter side before moving
forward. See https://github.com/flutter/engine/pull/51072.

This reverts commit 283051acba.

Reason for revert: Redo the change with the similar one in flutter.

After this change, the next dart -> flutter roll needs extra cares
in https://github.com/flutter/engine/pull/51072. It also contains
more details about the reason why it could not be two-way
compatible.

Original change's description:
> Revert "[Fuchsia] Remove the legacy gn build rules for fuchsia"
>
> This reverts commit 094202bb91.
>
> Reason for revert: Break flutter, this change should happen after
> flutter being migrated to the same gn-sdk.
>
> Original change's description:
> > [Fuchsia] Remove the legacy gn build rules for fuchsia
> >
> > The updated test-scripts contains https://crrev.com/c/5341620 which
> > allows to generate fidl apis with an env var controlled location
> > rather than a hard-coded one. So the existing fuchsia gn build rules
> > in dart/sdk become obsolete and can be fully removed in favor of the
> > one in //third_party/fuchsia/gn-sdk/.
> >
> > Meanwhile the gn-sdk has been updated with
> > https://crrev.com/c/5325282 to use api-level version'ed idk but not
> > the ones in arch/.
> >
> > Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
> > Tested: ^^^^^
> > Bug: 40935282
> > Change-Id: I2ce958e6db1ff8221beef7b7ff953c32bb4525ba
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355283
> > Reviewed-by: Ryan Macnak <rmacnak@google.com>
> > Reviewed-by: Alexander Thomas <athom@google.com>
> > Commit-Queue: Zijie He <zijiehe@google.com>
>
> Bug: 40935282
> Change-Id: I7c455d1d362210523671c97d99ef018ede1743f4
> Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356307
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Auto-Submit: Zijie He <zijiehe@google.com>
> Reviewed-by: Derek Xu <derekx@google.com>
> Commit-Queue: Zijie He <zijiehe@google.com>

Bug: 40935282
Change-Id: Id5a9a98013350359037b19f8506f24158c9a3120
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356924
Commit-Queue: Zijie He <zijiehe@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2024-03-14 20:22:12 +00:00
Slava Egorov c2e9ceeb6b [vm/io] Cleanup long path handling on Windows
* Switch to `std::unique_ptr<wchar_t[]>` to represent a
dynamically strings instead of wrappers like
`StringRAII` and `Utf8ToWideScope`;
* Avoid back and forth conversion between UTF8 and UTF16:
convert to UTF16 first then work on that. This also simplifies
code - previously it tried to work with strings allocated in
different ways uniformly, which is actually unnecessary if
resulting string needs to be converted to UTF16 (and allocated
with `malloc`) anyway;
* Fix a bug in `File::CreateLink`: it was handling relative
links with long paths incorrectly. Change file_long_path_test
to cover this case and make it run on non-Windows systems as
well to ensure that all behavior that can match actually
matches.

TEST=ci

Change-Id: I1279aff1d2cdace5e2ce8633c2f7ea69a34fe41a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356680
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-03-12 08:29:36 +00:00
Zijie He 283051acba Revert "[Fuchsia] Remove the legacy gn build rules for fuchsia"
This reverts commit 094202bb91.

Reason for revert: Break flutter, this change should happen after
flutter being migrated to the same gn-sdk.

Original change's description:
> [Fuchsia] Remove the legacy gn build rules for fuchsia
>
> The updated test-scripts contains https://crrev.com/c/5341620 which
> allows to generate fidl apis with an env var controlled location
> rather than a hard-coded one. So the existing fuchsia gn build rules
> in dart/sdk become obsolete and can be fully removed in favor of the
> one in //third_party/fuchsia/gn-sdk/.
>
> Meanwhile the gn-sdk has been updated with
> https://crrev.com/c/5325282 to use api-level version'ed idk but not
> the ones in arch/.
>
> Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
> Tested: ^^^^^
> Bug: 40935282
> Change-Id: I2ce958e6db1ff8221beef7b7ff953c32bb4525ba
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355283
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>
> Commit-Queue: Zijie He <zijiehe@google.com>

Bug: 40935282
Change-Id: I7c455d1d362210523671c97d99ef018ede1743f4
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356307
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Zijie He <zijiehe@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Zijie He <zijiehe@google.com>
2024-03-08 20:50:31 +00:00
Zijie He 094202bb91 [Fuchsia] Remove the legacy gn build rules for fuchsia
The updated test-scripts contains https://crrev.com/c/5341620 which
allows to generate fidl apis with an env var controlled location
rather than a hard-coded one. So the existing fuchsia gn build rules
in dart/sdk become obsolete and can be fully removed in favor of the
one in //third_party/fuchsia/gn-sdk/.

Meanwhile the gn-sdk has been updated with
https://crrev.com/c/5325282 to use api-level version'ed idk but not
the ones in arch/.

Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Tested: ^^^^^
Bug: 40935282
Change-Id: I2ce958e6db1ff8221beef7b7ff953c32bb4525ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355283
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Zijie He <zijiehe@google.com>
2024-03-07 18:26:59 +00:00
Alexander Aprelev 34213ba605 [win/unwinding] Remove Windows7 handling of unwinding records API.
Bug: https://github.com/dart-lang/sdk/issues/54509
Change-Id: Ic88c864a1d9c0ef571576b4d39119ba3d0384135
TEST=ci
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353783
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2024-02-23 04:13:39 +00:00
Ryan Macnak d67f159332 [vm] Fix using GCC with the sanitizers.
TEST=local
Change-Id: Icb47e2c68e55ae14f806cb421b8d860cda4d1f1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350647
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-02-21 20:15:15 +00:00
Miguel Flores Ruiz de Eguino d1ba46c05e [inspect] Update Inspect library usage
The new Inspect library uses InspectSink as described in RFC-168 [1].
Additionally it's using the new CPP bindings instead of the deprecated
HLCPP bindings.

[1]: https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0168_exposing_inspect_through_inspectsink?hl=en

TEST=build locally together with the flutter engine and internal code.
Bug: https://g-issues.fuchsia.dev/issues/320785253
Change-Id: Ide167f67217dd964167133c9aafd9e33ec81afc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Miguel Flores <miguelfrde@google.com>
Auto-Submit: Miguel Flores <miguelfrde@google.com>
2024-02-12 18:18:01 +00:00
Ryan Macnak fd2c27ff4e [vm, gc] Avoid TSAN warning for accessing Page::top_.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/54766
Change-Id: Ic297b426977b835d11c2a98357839f1df8cfbc39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349711
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-02-06 22:53:59 +00:00
Ryan Macnak 4e6cd29eef [vm, gc] Mark through new-space.
- Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
 - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
 - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
 - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
 - reachabilityBarrier is now just a count of major GCs.

TEST=ci
Change-Id: I1e653c9b5d3e02e45b280302c832157a75788db6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345350
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-01-26 18:58:54 +00:00
Alexander Markov 71ffaf392f [vm] Fix cross-build Windows -> android
TEST=ci
Fixes https://github.com/flutter/flutter/issues/141786

Change-Id: I9c6620b8ee25e36631da2b1213002e8bf30b6473
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347065
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-01-18 21:22:59 +00:00
Daco Harkes fb8f06baef [vm] Fix g3
Follow-up to https://dart-review.googlesource.com/c/sdk/+/346940.
Follow up to https://dart-review.googlesource.com/c/sdk/+/346907.

TEST=ci
Fixes b/320789794

Change-Id: I82e52a651174d9a84cd05995383255a01257f556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346961
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-01-18 08:44:22 +00:00
Alexander Markov 6ce0341f60 [vm] Fix build on vm-ffi-qemu-linux-release-arm bot
Follow-up to https://dart-review.googlesource.com/c/sdk/+/346940.

TEST=ci
Fixes b/320789794

Change-Id: I4440f06b82f92594749540c715801f71fe90759d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346907
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2024-01-18 07:33:38 +00:00
Alexander Markov 5230995e3a [vm] Fix unwinding records on Windows
This change fixes the following 2 bugs related to unwinding records
on Windows:

1) When cross-compiling from another OS to Windows, unwinding records
   were not added to the end of the code section. Later, when loading
   AOT snapshot, arbitrary bytes at the end of the code section were
   used as the unwinding data, which could result in the errors
   returned from Windows API calls.

2) When code section is mapped, its size was rounded up to the page
   size; when looking for unwinding record, size of the unwinding
   record was subtracted from the rounded size. This is not correct
   as unwinding record is placed right at the end of code section,
   so code section size should be used before rounding.

Also, magic value is added to the unwinding record in order to
verify that it is preserved and correctly found.

TEST=Manually tested repro from b/320642692
TEST=ffi/ffi_induce_a_crash_test

Fixes b/320642692
Fixes https://github.com/dart-lang/sdk/issues/54206

Change-Id: Id0c6413cd1b759da9e9f25f7617eef55f33b04a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346940
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-01-18 01:09:49 +00:00
Vyacheslav Egorov aaca6ce34a [vm] Fix running under WSL 1
On WSL 1 trying to allocate memory close to the binary
by supplying a hint fails with ENOMEM for unclear reason.
Some reports suggest that this might be related to the
alignment of the hint but aligning it by 64Kb does not
make the issue go away in our experiments. Instead
just retry without any hint.

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

TEST=manually under WSL 1

Change-Id: I0adf997fbf76e470a57da00f5ce7a26bb50706f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345802
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-01-11 22:24:44 +00:00
Vyacheslav Egorov 3e0ae6da5f [vm] Remove dual mapping of code
We are no longer using Dart VM in a setting where this
matters as a security measure and it just complicates
portability for no benefit.

There is an indication that it is causing problems when
running Linux build of Dart VM under Docker on Mac OS X.

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

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Change-Id: I11bdaa8faebaca1df6fd59097049bdaea9cb8e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344581
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-01-09 12:36:55 +00:00
Siva Annamalai 94c8d341d7 Revert "[vm, gc] Mark through new-space."
This reverts commit a3b7c323b0.

Reason for revert: We are seeing crashes in some internal testing
si_signo=Segmentation fault(11), si_code=SEGV_ACCERR(2), si_addr=0x7f1cadb85bc6
version=3.3.0-edge+google3-v2 (google3) (google3) on "linux_x64"
pid=8967, thread=8969, isolate_group=main(0x5583571aaaf0), isolate=(nil)((nil))
os=linux, arch=x64, comp=no, sim=no
isolate_instructions=7f1cad8b7e40, vm_instructions=7f1cad8b1000
fp=7f1cacc7ebc0, sp=7f1cacc7eb90, pc=5583568155bc
  pc 0x00005583568155bc fp 0x00007f1cacc7ebc0 dart::MarkingVisitorBase<true>::VisitPointers(dart::ObjectPtr*, dart::ObjectPtr*)+0x15c
  pc 0x0000558356975a1d fp 0x00007f1cacc7ec60 dart::StackFrame::VisitObjectPointers(dart::ObjectPointerVisitor*)+0x1bd
  pc 0x0000558356935c29 fp 0x00007f1cacc7ecc0 dart::UntaggedSuspendState::VisitSuspendStatePointers(dart::SuspendStatePtr, dart::ObjectPointerVisitor*)+0x89
  pc 0x0000558356815948 fp 0x00007f1cacc7ed10 dart::MarkingVisitorBase<true>::DrainMarkingStackWithPauseChecks()+0x128
  pc 0x0000558356815749 fp 0x00007f1cacc7ed80 dart::ConcurrentMarkTask::Run()+0x69

Original change's description:
> [vm, gc] Mark through new-space.
>
>  - Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
>  - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
>  - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
>  - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
>  - reachabilityBarrier is now just a count of major GCs.
>
> TEST=ci
> Change-Id: Ic7754e8d972763654eae2b7faa8670735d9cda3f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340644
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Change-Id: Ice07b4eb5bef3b41c9618ef0ca7759de006ffe00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343060
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-12-21 21:02:38 +00:00
Simon Binder ada6b81761 [vm/ffi] Improve error messages on Windows
Use `FormatMessageA` to allocate an English description of an error code.
Previously, only the error code itself was shown.

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

TEST=tests/ffi/dylib_open_test.dart
Cq-Include-Trybots: luci.dart.try:vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-aot-win-debug-x64c-try,vm-aot-asan-linux-release-x64-try,vm-asan-linux-release-x64-try
Change-Id: Iccae6c763fb16d4bb999b9c260fcfea9c5de276b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328420
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-12-20 13:24:16 +00:00
Ryan Macnak a3b7c323b0 [vm, gc] Mark through new-space.
- Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
 - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
 - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
 - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
 - reachabilityBarrier is now just a count of major GCs.

TEST=ci
Change-Id: Ic7754e8d972763654eae2b7faa8670735d9cda3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340644
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-12-12 01:56:15 +00:00
Vyacheslav Egorov dcac60b672 [vm/aot] Fix BoxInt64 in deferred units
When generating code for deferred units compiler
can't emit PC relative call to the shared Mint allocation
stub. This causes compiler to emit an indirect call
through a Code object. Such calls clobber CODE_REG
which is actually an allocatable register.

Fix this by using non-allocatable register instead of
CODE_REG when generating indirect calls through
Code object in AOT mode. Callees don't expect
anything useful in CODE_REG anyway because AOT
calling convetion does not use it.

TEST=vm/cc/{BranchLinkPreservesRegisters,JumpAndLinkPreservesRegisters,CallCodePreservesRegisters}

Bug: b/242559057
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-product-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-linux-debug-simriscv64-try,vm-ffi-qemu-linux-release-riscv64-try
Change-Id: Ib1fdc1c104d0269d41bb1ab9cbe292ad28c7cd49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338127
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-11-28 13:15:56 +00:00
Ryan Macnak fc85488000 [vm] Unwind records for Windows ARM64.
TEST=ffi_induce_a_crash_test
Bug: https://github.com/dart-lang/sdk/issues/51726
Change-Id: I7df3b56a150434d4c7b0cfbadda4fd9d57606eef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336203
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-11-21 20:39:29 +00:00
Daco Harkes 84404136e9 [vm] Fix some cross compilation issues from Linux to Windows
Upstreamed changes from cl/579854752.

The cross-compiler checks some things that are check on Windows.
* Correct capitalization of filenames in includes.
* Field initialization order in constructors.

In the cross compilation process, some binaries are run on the host.
This unveiled missing `UnwindingRecords::GenerateRecordsInto`.

Finally, when emitting blob data with a symbol in assembly, the
`.type` directive is not supported but the format should still be
unix style assemble. So this CL introduces "win_gnu". This tool is
directly invoked from the build-rules in cl/579854752, and will not be
used until we address https://github.com/dart-lang/sdk/issues/28617.

TEST=windows bots

Change-Id: I94256589e8c231b45b8e14a63727c782416c2e98
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,pkg-win-release-try,pkg-win-release-arm64-try,vm-win-debug-arm64-try,vm-win-debug-x64c-try,vm-win-debug-x64-try,vm-msvc-windows-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335520
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-13 14:25:28 +00:00
Tess Strickland b44987450e [platform] Fix Utils::IsInt on unsigned values.
Also add unsigned value tests for IsUint and MagnitudeIsUint to
verify they don't have similar issues.

TEST=vm/cc/IsInt, vm/cc/IsUint, vm/cc/MagnitudeIsUint

Change-Id: I3c8dcb93b9d019117948bb5c3dac0d1d619931b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333083
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-10-31 19:39:51 +00:00
Jorge Gorbe Moya 93c1d54de1 Add missing #include <cstdlib>
Closes https://github.com/dart-lang/sdk/pull/53908

GitOrigin-RevId: f25ea09a900c15a8289858c9824c30c17afdb225
Change-Id: I1f1565a3bcb7a785e910d917579725ca15e24056
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332452
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-10-31 16:13:19 +00:00
Ryan Macnak 95e1de4f38 [vm] Fix Windows ARM64 MSVC build.
TEST=--no-clang
Change-Id: I7e7da1afd13337f73230f3ded1f800c6ed7c969e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331420
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-10-20 19:45:49 +00:00
Slava Egorov 425a42e3be Revert "[vm, gc] Mark through new-space."
This reverts commit 5daaa7d9eb.

Reason for revert: internal crashes

Original change's description:
> [vm, gc] Mark through new-space.
>
>   - Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
>   - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
>   - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
>   - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
>   - reachabilityBarrier is now just a count of major GCs.
>
> TEST=ci
> Change-Id: I4a6a23273d8ecb78c640f054731d4ceb737bfc4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325840
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Change-Id: I8a50074db343c63c14f0487ae8b4f5fee2c4ae76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330720
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-10-18 07:47:39 +00:00
Ryan Macnak 5daaa7d9eb [vm, gc] Mark through new-space.
- Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
  - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
  - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
  - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
  - reachabilityBarrier is now just a count of major GCs.

TEST=ci
Change-Id: I4a6a23273d8ecb78c640f054731d4ceb737bfc4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325840
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-10-10 19:15:12 +00:00
Ryan Macnak 8e6191c7f9 [build] Include FPESAN in UBSAN.
TEST=ubsan
Bug: b/301044910
Change-Id: I608dd742a243bc1ab620c92da46e48270d6b060f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327041
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-09-21 15:16:39 +00:00
Emmanuel Pellereau a675a79f39 Revert "Reland "[vm, gc] Mark through new-space.""
This reverts commit 095171e937.

Reason for revert: breaks google3 (b/296014654)

Original change's description:
> Reland "[vm, gc] Mark through new-space."
>
>  - Adjust allocation stub write barrier elimination compensation to check if result is no longer in an active TLAB.
>
> TEST=ci
> Change-Id: I5d24602ae76ee861f2d009d67272251b04da3592
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322448
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

Change-Id: I73b60f799dda755028b65653ac21f27c13e009e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322682
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2023-08-28 14:34:21 +00:00
Ryan Macnak 095171e937 Reland "[vm, gc] Mark through new-space."
- Adjust allocation stub write barrier elimination compensation to check if result is no longer in an active TLAB.

TEST=ci
Change-Id: I5d24602ae76ee861f2d009d67272251b04da3592
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322448
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-08-25 21:13:02 +00:00
Ivan Inozemtsev 3176cfcd21 Revert "[vm, gc] Mark through new-space."
This reverts commit 3fb88e4c66.

Reason for revert: b/297175670

Original change's description:
> [vm, gc] Mark through new-space.
>
>  - Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
>  - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
>  - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
>  - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
>  - reachabilityBarrier is now just a count of major GCs.
>
> TEST=ci
> Change-Id: I6362802cd93ba5ba9c39f116ddff82e4feb4c312
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321304
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

Change-Id: I33075156160dc35861355d738a5776b74dce88b9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322344
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-23 13:13:28 +00:00
Ryan Macnak 3fb88e4c66 [vm, gc] Mark through new-space.
- Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
 - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
 - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
 - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
 - reachabilityBarrier is now just a count of major GCs.

TEST=ci
Change-Id: I6362802cd93ba5ba9c39f116ddff82e4feb4c312
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321304
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-08-22 16:19:06 +00:00
Ilya Yanok 92ca7985a5 Revert "[vm, gc] Mark through new-space."
This reverts commit e95e7b8e96.

Reason for revert: suspected cause to non-deterministic AOT binaries crashes, b/296014654

Original change's description:
> [vm, gc] Mark through new-space.
>
>  - Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
>  - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
>  - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
>  - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
>  - reachabilityBarrier is now just a count of major GCs.
>
> TEST=ci
> Change-Id: I8c2c64b120766571b62d3bd8dab37ae81c2dca98
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319583
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

Change-Id: Idda542c7c657d4f14c836423b173c9b067132212
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320820
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-08-15 11:09:20 +00:00
Ryan Macnak e95e7b8e96 [vm, gc] Mark through new-space.
- Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
 - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
 - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
 - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
 - reachabilityBarrier is now just a count of major GCs.

TEST=ci
Change-Id: I8c2c64b120766571b62d3bd8dab37ae81c2dca98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319583
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-08-14 18:16:05 +00:00
Ryan Macnak a7e20dd2b0 Revert "[vm, gc] Mark through new-space."
This reverts commit 6194209b28.

Reason for revert: issues on arm32

Original change's description:
> [vm, gc] Mark through new-space.
>
>  - Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
>  - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
>  - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
>  - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
>  - reachabilityBarrier is now just a count of major GCs.
>
> TEST=ci
> Change-Id: I3668a2e56821f9eadf96e38c228dab27be656016
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309826
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Change-Id: I434eb595c9e7858efc8c9b07cbca954e5649f506
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319321
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-08-09 18:13:17 +00:00
Ryan Macnak 6194209b28 [vm, gc] Mark through new-space.
- Initial and final marking no longer visit all of new-space, reducing the STW pause for major GC.
 - A scavenge during concurrent marking must forward / filter objects in the marking worklist that are moved / collected, increasing the STW pause for minor GC.
 - Unreachable intergenerational cycles and weak references are collected in the next mark-sweep instead of first requiring enough scavenges to promote the whole cycle or weak target into old-space.
 - Artificial minor GCs are no longer needed to avoid memory leaks from back-to-back major GCs.
 - reachabilityBarrier is now just a count of major GCs.

TEST=ci
Change-Id: I3668a2e56821f9eadf96e38c228dab27be656016
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309826
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-09 15:57:17 +00:00
Martin Kustermann 389aab624d [vm] Allow non-TSAN gen_snapshot target TSAN AOT runtime
This is a revert of b6bbfff8c0c6c44cdab0d7d78 which temporarily disabled
this.

Turns out that a non-TSAN gen_snapshot would - when emitting code via
`Assembler::TsanLoadAcquire` - use an incorrect `Thread`-offset:

It calculated the offset via `Thread::OffsetFromThread`. That function
took a `dart::RuntimeEntry*` and tried to find its offset.

We happen to have the following leaf runtime entries:

  #define LEAF_RUNTIME_ENTRY_LIST(V)
      ...
      V(void, MsanUnpoison, void*, size_t)
      V(void, MsanUnpoisonParam, size_t)
      V(void, TsanLoadAcquire, void*)
      V(void, TsanStoreRelease, void*)
      ...

It loops over all runtime entries and finds the first one that has the
identical `dart::RuntimeEntry::function_` pointer.

Though all 4 of them are `nullptr` at `gen_snapshot` time, so when
searching for offset for

  `Thread::OffsetFromThread(kTsanLoadAcquireRuntimeEntry)`

it looked for the first runtime entry with `nullptr` function pointer -
which turned out to be `MsanUnpoison` (instead of `TsanLoadAcquire`).

=> The obvious fix is to use the `dart::RuntimeEntry*` pointer for
comparison instead of it's `function_` member.

TEST=ci
Issue b/287638965

Change-Id: I85c06674927978ef8561e9e7bdfab4823c0a8e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312902
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-10 11:53:58 +00:00
Martin Kustermann 2cb0882a2d [vm] Unblock dart->g3 roll
The adjustments to g3 build rules that allow running non-TSAN
gen_snapshot targeting TSAN AOT runtime aren't quite fleshed out yet.

So we temporarily let `gen_snapshot` detect whether to target TSAN by
whether it is itself compiled in TSAN (instead of via
`-DTARGET_USES_THREAD_SANITIZER`)

TEST=ci
Issue b/287638965

Change-Id: I2cd744f959d8302ba81cb1feceedee2756e02656
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312901
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-07-07 19:28:58 +00:00
Martin Kustermann 9d876d12b2 [vm] Rename kUsingThreadSanitizer->kTargetUsesThreadSanitizer, include tsan in snapshot flags
TEST=ci
Issue b/287638965

Change-Id: I649b28ac0181761d0927e80b8eff7c8af5fe305a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312840
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-07 14:42:22 +00:00
Martin Kustermann 82577191ec [vm] Allow build rules to pass TARGET_USES_THREAD_SANITIZER in any configuration
This may simplify some g3 build rules as it allows passing this define
whenever we compile under TSAN - instead currently it can only be passed
if DART_PRECOPMILER is also passed.

TEST=ci

Change-Id: I73e51243716373cdeca7559b344408bb206e22ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312801
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-07-07 09:02:32 +00:00
Martin Kustermann 2287c76724 [vm] Make AOT compiler use TARGET_USES_THREAD_SANITIZER
The VM has two parts related to TSAN: compiler & runtime.

So far both parts used self-detection whether running with TSAN. This
implies that if AOT runtime runs under TSAN that the AOT compiler then
also has to run under TSAN (which is slow).

We separate the two by making the compiler use
`TARGET_USES_THREAD_SANITIZER`. It will be auto-detected by-default
except when `DART_PRECOPMILER` is set. In the precompiler case we
require the build rules to pass in whether the target runs under
TSAN or not.

Issue b/287638965

TEST=ci

Change-Id: Ib333a8a69ed2d7bdca7596014a0d25b103af25b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312480
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-07-06 08:44:33 +00:00