163 Commits
Author SHA1 Message Date
Michael Lippautz eb0d8fda0c cppgc: Annotate all write barrier slow paths with preserve most
The most critical barrier (CombinedWriteBarrierSlow) was already
annotated. Add more annotations to cover all the collection use cases
as well.

Speedometer3
👍 TodoMVC-Preact-Complex-DOM                  [ -1.1%,  -0.0%]

Bug: 537244297
Change-Id: Ie9f1823ba99f5e2ca8b15d446c10acf88b302d49
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8126059
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#108791}
2026-07-21 09:21:18 -07:00
Anton Bikineev dab56f9319 cppgc: Optimize allocation by placing GCInfo in separate section
Place GCInfo objects into a separate section (`gc_info_section` or
`__DATA,gc_info_section`) and compute the index directly as an offset
from the start of the section. This avoids the overhead of dynamic
registration and checking on allocation. This also eliminates the need
for `GCInfoTable` when active.

The optimization is enabled by default on desktop (Linux and macOS)
under the `cppgc_enable_object_section_gcinfo` GN flag for non-component
builds.

ELF and MachO platforms are supported.

TAG=agy

Change-Id: I83b5bf36dd8f0d0f469caf3dc8db4eb9464c2250
Bug: 522693606
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7918333
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#107939}
2026-06-12 03:53:46 -07:00
Dominik Inführ ec3ca53c8a [cppgc] Fix ASAN false positive in handle location
Enabling cppgc_enable_object_names causes ASAN false positives
when iterating cross-thread persistents. This is because of the
access to the location_ field. This CL fixes this by silencing
ASAN for this access similar to what we do for GetNodeFromGC() or
ClearFromGC().

Bug: 497855658
Change-Id: I6af31de5b6273a8cfde835388dbf64e826a65ef9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7865927
Auto-Submit: Dominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#107520}
2026-05-22 03:06:03 -07:00
Leszek Swirski d1db2e5992 Revert "[heap] Enable cppgc_enable_object_names by default on Desktop"
This reverts commit e1dbd978b6.

Reason for revert: https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux64%20-%20official/14106/overview

Original change's description:
> [heap] Enable cppgc_enable_object_names by default on Desktop
>
> This CL initially enables this "gn arg" on Desktop platforms. Android
> and Fuchsia can be enabled later as well.
>
> Bug: 497855658
> Change-Id: I09696c4df93f403a7eff349a74037e1ee167a557
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7807042
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#107492}

Bug: 497855658
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I04cade7ef4886dff232768779eefd90f9816fafa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7867736
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#107500}
2026-05-21 10:40:16 -07:00
Dominik Inführ e1dbd978b6 [heap] Enable cppgc_enable_object_names by default on Desktop
This CL initially enables this "gn arg" on Desktop platforms. Android
and Fuchsia can be enabled later as well.

Bug: 497855658
Change-Id: I09696c4df93f403a7eff349a74037e1ee167a557
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7807042
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#107492}
2026-05-21 05:53:02 -07:00
Matthias Liedtke 32d567d072 [cleanup] Apply readability-braces-around-statements
Change-Id: Icb5b0ab02689c969ec2a14be7abf1759f1954e45
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7827654
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Auto-Submit: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#107187}
2026-05-08 07:40:22 -07:00
Steinar H Gunderson 99205e3f1e Revert "Make Uncompress(Compress(ptr)) into a no-op."
This reverts commit b284c48c16.

Reason for revert: Performance regressions in event dispatch, presumably from LLVM [[assume]] weaknesses; since we don't see any clear wins anywhere else (besides a bit in size), it's easier to just revert.

Original change's description:
> Make Uncompress(Compress(ptr)) into a no-op.
>
> Add an [[assume]] annotation so that Clang understands this; it doesn't
> by itself (because it requires information about high bits in the
> uncompressed pointer that we've found it hard to teach it).
>
> Doesn't give a Speedometer win by itself, but it reduces the APK size
> of 64-bit Chrome by ~11 kB.
>
> Change-Id: I1480f0032e3733972553b1e34eb4a7def5f157ed
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7277326
> Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Steinar H Gunderson <sesse@chromium.org>
> Auto-Submit: Steinar H Gunderson <sesse@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#104529}

Fixed: 474389112
Change-Id: I924a6613291a7f422736b3b914e7cc8dd58b2676
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7487369
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Steinar H Gunderson <sesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#104742}
2026-01-16 05:02:43 -08:00
Steinar H. Gunderson b284c48c16 Make Uncompress(Compress(ptr)) into a no-op.
Add an [[assume]] annotation so that Clang understands this; it doesn't
by itself (because it requires information about high bits in the
uncompressed pointer that we've found it hard to teach it).

Doesn't give a Speedometer win by itself, but it reduces the APK size
of 64-bit Chrome by ~11 kB.

Change-Id: I1480f0032e3733972553b1e34eb4a7def5f157ed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7277326
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Steinar H Gunderson <sesse@chromium.org>
Auto-Submit: Steinar H Gunderson <sesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#104529}
2026-01-07 10:15:21 -08:00
Michael Lippautz 6d7526671e [heap] HoH: Use lower bits for GCInfoIndex
The GCInfoIndex is always written on allocation. This does not affect
writing/reading the construction bit which happens with a mask.

This safes one shift in the allocation fast path (for GCInfoIndex).

Drive-by: Use std::atomic_ref instead of casts to std::atomic.

Change-Id: I8932f46ef582558d30eded9bab9b8d210a0ee1cb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7213182
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#104077}
2025-12-03 03:53:20 -08:00
Leszek Swirski 44f769baca [debug] Only pass SourceLocation in debug in TurboShaft
SourceLocation is almost only used for debug messages in TurboShaft, so
pass it only in debug mode. Additionally, std::source_location (that it
wraps) is a single pointer, so we can efficiently pass it by value
rather than const ref.

This reduces release build d8 by ~170kb, of which ~4kb is the by-value
passing.

Change-Id: Ia6b592f094dad0987b8a886bf16a7d3fe8611eb1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6888815
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#102072}
2025-08-27 06:56:09 -07:00
Jakob Kummerow 6ef89d114b [cleanup] Modernize std::*::value and ::type
Mechanically replacing `std::foo<X>::value` with `std::foo_v<X>`,
and the same for `::type` -> `_t`.

Change-Id: I543dda07ba4c95534cdcd51f1f438f2626be8273
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6491388
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#99940}
2025-04-28 03:59:57 -07:00
Omer Katz 943b16366f Fix clang plugin violations in V8
Bug: 402564649
Change-Id: Ib81be42ab888210e5269ab1c5a0fae3d3c73aee1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6348644
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#99256}
2025-03-14 04:57:31 -07:00
Michael Lippautz 43479135b3 cppgc: Fix handling of intermediate values on the stack for 16G cages
This fixes the handling of intermediate values when conservatively
iterating memory (stack, but also heap).

To this end we will scan through memory word-by-word and consider:
1. Full pointers;
2. Compressed pointers in both half words;
3. A half-decompressed 35-bit value as intermediate state that doesn't
   assume sign extension happened;

We also bring back the optimization from https://crrev.com/c/6198226
which relied on the fact that the full pointer will be reached through
the intermediate state. This is now actually the case and handling 3.
implicitly also handles 1.

The CL also adds a bunch of tests that would have caught the original
problem.

Change-Id: Ibde3af33894b1f044cde49e97492b46c3e4b4e24
Bug: 391018461
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6198347
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#98372}
2025-01-28 08:51:32 -08:00
Michael Lippautz 94c4e3ab86 cppgc: Remove guard pages
Guard pages have effectively been disabled in
  https://crrev.com/c/6074477

This change merely removes the underlying GC infrastructure.

Bug: 378017037
Change-Id: I425ffa924cf2797e0abf88483054334528583d62
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6074521
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#97980}
2025-01-08 02:19:38 -08:00
Dominik Inführ a60ea98a83 [cppgc] Remove support for 2GB cage
The 2GB cage was already disabled for some time due to OOM errors. We
have also increased the cage from 4GB to 16GB already on non-Android
systems. So it seems unlikely that we could launch it again.

Bug: 343959927
Change-Id: I27c26256c84f4e592bb991d7b8a0582b54685e18
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6089581
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Auto-Submit: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#97791}
2024-12-16 03:44:48 -08:00
Michael Lippautz 239841592e Reland "cppgc: Remove guard pages and avoid discarding pages on Windows"
This is a reland of commit 48bdf7ae9f

Original change's description:
> cppgc: Remove guard pages and avoid discarding pages on Windows
>
> This is a reland of https://crrev.com/c/6049213 with improved handling
> for Windows.
>
> This CL changes the guard page size to 0 on all platforms. Individual
> Oilpan pages thus have no more guard regions. The infrastructure will
> be removed in a subsequent CL.
>
> On Windows discarding memory on 128K-aligned 128K in size chunks
> caused massive performance regressions on syscalls.
>
> The CL works around this by removing discarding in the following ways:
> 1. On destroying pages the memory is not discarded anymore. This is
>    okay because we only discard pages on memory reducing GCs which is
>    also when we drop pages from the pool which decommits the memory
>    anyways.
> 2. Discarding free list entries is disabled on Windows. This is in
>    line with the JS heap part which has a similar exemption.
>
> Change-Id: I8623467ef06eb3be63cd62718db09dde65e4a763
> Bug: 378017037
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6055482
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Omer Katz <omerkatz@chromium.org>
> Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#97600}

Cq-Include-Trybots: luci.v8.try:v8_win64_nodcheck_rel
Bug: 378017037
Change-Id: If02d76b37e39eb14949bc7a7769ce2771eaf1eab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6074477
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#97629}
2024-12-09 12:10:18 +00:00
Eva Herencsárová 306d0e55a8 Revert "cppgc: Remove guard pages and avoid discarding pages on Windows"
This reverts commit 48bdf7ae9f.

Reason for revert: Fails on https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Win64/61462/overview

Original change's description:
> cppgc: Remove guard pages and avoid discarding pages on Windows
>
> This is a reland of https://crrev.com/c/6049213 with improved handling
> for Windows.
>
> This CL changes the guard page size to 0 on all platforms. Individual
> Oilpan pages thus have no more guard regions. The infrastructure will
> be removed in a subsequent CL.
>
> On Windows discarding memory on 128K-aligned 128K in size chunks
> caused massive performance regressions on syscalls.
>
> The CL works around this by removing discarding in the following ways:
> 1. On destroying pages the memory is not discarded anymore. This is
>    okay because we only discard pages on memory reducing GCs which is
>    also when we drop pages from the pool which decommits the memory
>    anyways.
> 2. Discarding free list entries is disabled on Windows. This is in
>    line with the JS heap part which has a similar exemption.
>
> Change-Id: I8623467ef06eb3be63cd62718db09dde65e4a763
> Bug: 378017037
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6055482
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Omer Katz <omerkatz@chromium.org>
> Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#97600}

Bug: 378017037
Change-Id: I50949ea0085c60908984cf9489f9eac6fd466db0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6074950
Commit-Queue: Eva Herencsárová <evih@chromium.org>
Owners-Override: Eva Herencsárová <evih@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#97602}
2024-12-06 11:01:27 +00:00
Michael Lippautz 48bdf7ae9f cppgc: Remove guard pages and avoid discarding pages on Windows
This is a reland of https://crrev.com/c/6049213 with improved handling
for Windows.

This CL changes the guard page size to 0 on all platforms. Individual
Oilpan pages thus have no more guard regions. The infrastructure will
be removed in a subsequent CL.

On Windows discarding memory on 128K-aligned 128K in size chunks
caused massive performance regressions on syscalls.

The CL works around this by removing discarding in the following ways:
1. On destroying pages the memory is not discarded anymore. This is
   okay because we only discard pages on memory reducing GCs which is
   also when we drop pages from the pool which decommits the memory
   anyways.
2. Discarding free list entries is disabled on Windows. This is in
   line with the JS heap part which has a similar exemption.

Change-Id: I8623467ef06eb3be63cd62718db09dde65e4a763
Bug: 378017037
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6055482
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#97600}
2024-12-06 10:25:46 +00:00
Michael Lippautz 88ac58d006 Revert "cppgc: Remove guard pages"
This reverts commit e56d2eafd0.

Reason for revert: Heavily regresses Windows discarding time.

Original change's description:
> cppgc: Remove guard pages
>
> Guard pages (4K, 16K) were added on certain platforms within the 128K
> logical cppgc page. These regions have been implemented and dragged
> along from the initial version of Oilpan.
>
> For tooling these pages have no real use as we rely on ASAN for
> poisoning unused areas. OOB access for large objects is generally
> trapped on access in bounds checks.  Other OOB access has to hit
> exactly the guard pages to trap which is not generally the case.
>
> The mechanism had no relevance for actual security as the sizes were
> small and their positiion was deterministic.
>
> This CL removes the guard page support. This gets us back some virtual
> address space in the cage and slightly makes getting to page handles
> cheaper (over the public API).
>
> Bug: 378017037
> Change-Id: I8bb2c17e2daa4ee76c8a29aeaeb46827948160c3
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6049213
> Reviewed-by: Samuel Groß <saelo@chromium.org>
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#97389}

Bug: 378017037, 381201234, 381120830, 380922994
Change-Id: Ia2b55934891fb176acb3473d15151e184c75d44d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6055557
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#97458}
2024-11-28 11:39:59 +00:00
Michael Lippautz e56d2eafd0 cppgc: Remove guard pages
Guard pages (4K, 16K) were added on certain platforms within the 128K
logical cppgc page. These regions have been implemented and dragged
along from the initial version of Oilpan.

For tooling these pages have no real use as we rely on ASAN for
poisoning unused areas. OOB access for large objects is generally
trapped on access in bounds checks.  Other OOB access has to hit
exactly the guard pages to trap which is not generally the case.

The mechanism had no relevance for actual security as the sizes were
small and their positiion was deterministic.

This CL removes the guard page support. This gets us back some virtual
address space in the cage and slightly makes getting to page handles
cheaper (over the public API).

Bug: 378017037
Change-Id: I8bb2c17e2daa4ee76c8a29aeaeb46827948160c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6049213
Reviewed-by: Samuel Groß <saelo@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#97389}
2024-11-26 07:58:26 +00:00
Michael Lippautz 9be9b0197a cppgc: Fix slow checks on cppgc API
These checks are currently not run in Blink at all because the debug
macros are different. Move them behind v8_enable_slow_dchecks to allow
some testing and try to later enable them more broadly.

This also fixes the issue that for DEBUG builds the sizeof(Member) is
out of sync between V8 and Blink.

Change-Id: I332fb82ffe8f7bb2b1a9a8fee3630be0b06ce471
Bug: 373485798
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5952933
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#96769}
2024-10-23 10:40:14 +00:00
Michael Lippautz 58c6966683 cppgc: Fix atomic initialization
While the store of the actual pointer was atomic we also used
non-atomic initializers that would create a race.

Bug: 374122150
Change-Id: Id472529cee1d67f3a5f1449af7ccec6eb6fe2885
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5940377
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#96675}
2024-10-18 09:11:59 +00:00
Michael Lippautz 338e13d0ea cppgc: Properly enable API-level checks
cppgc's API-level checks have been gated behind `DEBUG` whereas Blink
always passes `_DEBUG` as symbol for debugging/dcheck builds.

Put the checks now behind a separate define that follows the common
practice of pairing a gn flag with a define for external usage.

This CL only enabled `CPPGC_DCHECK()` and leaves more expensive
verificaton for a follow up.

Bug: 373485798
Change-Id: Ic45738bb34569f3046118142350ecf7b6ac4439d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5934873
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#96665}
2024-10-17 18:31:46 +00:00
Michael Lippautz 3b42ac1ef3 cppgc: Avoid decompressions for pointer policies
Currently policies just use `Get()` which will trigger a
decompression, even if the result is then not used in some
configurations.

This is a possible small perf win on some configurations
where the decompression was not optimized away.

Bug: 373485798
Change-Id: I72a4c79652c64f5461790dd5d5d8e54874c7e5bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5938964
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#96663}
2024-10-17 17:03:20 +00:00
Nikolaos Papaspyrou 295b13cdb0 [cppgc] Make CppHeap accessible to multiple threads with v8::Locker
Documentation states that CppHeap can be used with V8::Locker. However,
in several cases, the implementation enforced checks that disallowed
the switching of threads. In particular:

1. Finalizers and pre-finalizers were expected to run on the same thread
   where the object was created.
2. Persistents were expected to be allocated and used by the thread that
   created the heap (this was enforced either explicitly or by some
   pointer policies).

This CL fixes this issue by loosening the checks, if the v8::Locker has
been used.

Bug: 373263965
Change-Id: I82b5ae5f2adc421ab33d283cf2c640edfa0915b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5934624
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#96646}
2024-10-17 11:25:02 +00:00
Nikolaos Papaspyrou cbbe873976 Revert "[cppgc] Make clearing of weak persistents concurrent"
This reverts commit 9144af8540.

Reason for revert: https://issues.chromium.org/issues/364340219

Original change's description:
> [cppgc] Make clearing of weak persistents concurrent
>
> Oilpan's weakness clearing phase often takes around 10% of the overall
> mark-compact pause. A small portion is taken by the clearing of
> same-thread WeakPersistent handles. This CL introduces a concurrent job
> for clearing such handles, in parallel to weak container callbacks.
>
> Bug: 349952799
> Change-Id: I497b199edd674379d552281125cdca65bc766bd3
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5822092
> Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#95872}

Bug: 349952799
Bug: 364340219
Change-Id: I81a5db34fa30cfddcb586b2265abe7239bd52140
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5877010
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#96207}
2024-09-20 15:29:16 +00:00
Nikolaos Papaspyrou 9144af8540 [cppgc] Make clearing of weak persistents concurrent
Oilpan's weakness clearing phase often takes around 10% of the overall
mark-compact pause. A small portion is taken by the clearing of
same-thread WeakPersistent handles. This CL introduces a concurrent job
for clearing such handles, in parallel to weak container callbacks.

Bug: 349952799
Change-Id: I497b199edd674379d552281125cdca65bc766bd3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5822092
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#95872}
2024-08-29 13:20:59 +00:00
Peter Kasting 9b2183b56a [jumbo] Make the NO_UNIQUE_ADDRESS macros actually work on Windows.
clang-cl matches cl.exe in making [[no_unique_address]] a no-op and
requiring [[msvc::no_unique_address]] instead. Handle accordingly in V8
so that on Windows the macro actually has an effect.

Bug: none
Change-Id: I1eca1a00504ccd7f3b321afbcd9f7eaab8b4a797
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5774208
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#95594}
2024-08-13 09:13:05 +00:00
Michael Lippautz 4e015f9955 [cppgc] Sweep based on live bytes on pages
Gardeners: This may cause a slight regression for a feature that
landed behind field trial (V8GCOptimizeSweepForMutator) as a
progression. The overall situation is still a net win once launched.

Not sweeping on allocation can cause memory regressions in case where
there is no progress via tasks as we are effectively getting new
pages. We also need sweeping to return empty pages due to having finalizers.

This CL brings back sweeping on allocation instead of bailing
out depending on the limit. At the same time we introduce per-page
live byte counts which are populated during marking. The sweeper can
then sort pages accordingly and start with pages that have the most
free bytes. This results in lower time spent in sweeping on allocation
as the chance is high to get a large block or almost empty page here.

In future, we can adjust concurrent sweeper to be page agnostic which
should improve this even further.

Change-Id: I8c6d4cd037c8fb1b521d1a43606d673fe0d370a1
Bug: 333981063
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5645442
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#94597}
2024-06-24 10:51:15 +00:00
Zhao Jiazhong 78e40de874 [loong64][mips64][heap/cppgc] Disable guard pages
Page size is normally 16k on loongarch64 and mips64 platforms, which
doesn't work well with cppgc's guard pages.
So disable guard pages on loongarch64 and mips64.

Change-Id: Iae4af9c21b261b27156fed52b771f04ea3547661
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5606546
Auto-Submit: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#94304}
2024-06-07 08:19:34 +00:00
Anton Bikineev 01501121f7 cppgc: Short-circuit callback checking in GCInfo
If gc-info for child is unfolded, we don't actually have to try to
call the parent's dtor, which can be e.g. protected.

Change-Id: I41e263d29fdeb1cbcb65bb066c505bee4b516ad1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5595019
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#94247}
2024-06-04 21:44:57 +00:00
Milad Fa 61d3749a85 Fix kGuardPageSize on powerpc
Size of a page on PPC is normally 64k.
Change is needed to fix a test failure, more details are
available under https://crrev.com/c/5541750

Change-Id: I7b58c4a6eba1ae6c8208012643d8dc3424fccc2f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5564403
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#94090}
2024-05-27 06:21:17 +00:00
Seth Brenith e58a397c24 Include InternalNodes in heap snapshots when exposing internals
Currently, heap snapshots represent many Blink objects as "InternalNode"
with size zero, and omit those objects entirely unless they point to
something with a more meaningful name. This improves the readability of
heap snapshots, but can hide a substantial amount of memory usage. This
CL changes the heap snapshot generator to include those InternalNodes
and their sizes if the user has enabled and checked the box titled
"Expose internals (includes additional implementation-specific
details)", because such users have explicitly opted in to see a more
detailed snapshot. The InternalNodes shown are not immediately
actionable, but there is a plausible pathway to success: InternalNodes
have a tooltip with a "learn more" link which explains how to see class
names in Chrome for Testing.

This change also includes a drive-by improvement to shrink EmbedderNode
by one pointer.

Bug: 340200025
Change-Id: Ic7b2fba8c3f45eedbc9a2fbeb33484c2c624cdaa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5542948
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#94083}
2024-05-24 17:00:58 +00:00
wenqin.yang d74c348464 [cppgc] Remove redundant CageBaseGlobal::Get() in Decompress()
It will call CageBaseGlobal::Get() in Decompress(), but the base
already in the argument of "GetNextUnfinalized", we could avoid to
call Decompress() by directing decompress the pointer with the base.

Change-Id: Iffd52cb4bacee500dd634cffc3f406dc2d8143b1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5384970
Commit-Queue: Wenqin Yang <wenqin.yang@intel.com>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#93000}
2024-03-25 11:50:28 +00:00
Michael Lippautz f3a14bcc41 [heap] Fix cppgc architecture macros
Most code was using V8_TARGET_* when really this macro is used for
determining the JIT target. All of Oilpan runs on the host though, so
we should use the V8_HOST_* macros.

A side effect of this is fixing a cross-compilation issue. Previously,
when setting target_cpu=x64 on arm64, we would get write barriers in
cppgc's public API wrong because the macro override is not propagated
to the API and the information about guard pages got out of sync.
Using the host macro fixes this because it is never overriden using GN
(but only via compilers directly).

Bug: chromium:1520621
Change-Id: Iba034f53b90b6f76f24d57f584e957cdde9d2177
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5257317
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#92134}
2024-02-01 09:21:51 +00:00
Kevin Babbitt 4d0bd67ac5 cppgc: Separate constants for default and max heap sizes
Prepare to introduce a runtime parameter that will allow varying the
heap size if the larger cage is enabled.

Bug: chromium:1434388
Change-Id: Ie68366c16983a83cf0d342248ee7cd1bf379de61
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4576492
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#88250}
2023-06-15 04:30:50 +00:00
Kevin Babbitt 46ce685fc2 cppgc: Parameterize AgeTable size
AgeTable is used to track objects in old versus young generations in
Oilpan. It's currently hardcoded for a caged heap of a fixed size.
This CL allows the size of the AgeTable to be set dynamically.

Also included is a fix to AgeTableTest for a compile-time error about
stack allocation of subtle::DisallowGarbageCollectionScope. The test
now compiles again when cppgc_enable_young_generation is set.

Bug: chromium:1434388
Change-Id: I9fd1928d9cf13f0dcaf98b18d99dee54075f392e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4575883
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#88178}
2023-06-12 17:05:17 +00:00
Michael Lippautz 6832ffec54 [api] Simplify USE() cast in GCInfo API
Use static_cast() to work with overloads and (void) cast instead of
USE() macro which is not available on the API.

Change-Id: I17cc5bdd8eb74c8058c3b035c93354594b29e4a0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4589669
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#88074}
2023-06-06 06:04:37 +00:00
Michael Lippautz 3cc08e81ef CfT: Ensure that cppgc_enable_object_names mode always compiles
Add checks for resolving the necessary trace method, finalizer, and
name method. The methods are not used and not part of the binary.
Resolving the names ensures that the mode always compiles.

Bug: chromium:1446931
Change-Id: Ibb89e11af4b42d9cf326bfaaab0c6e058d18d57a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4573670
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#87943}
2023-05-31 07:54:20 +00:00
Michael Lippautz 0a75e2f8c1 [cppgc] Avoid recording polymorphism in GCInfo
- Avoid recording a bit that was never used
- Rely on return value for the slow path of GCInfo creation

Change-Id: If0038bc0e8411865102f93808fb3ac594e0f7a50
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4573676
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#87936}
2023-05-30 16:53:04 +00:00
Kevin Babbitt 7622afda36 cppgc: Add a compile-time flag to enable larger cages
This CL introduces gn flag cppgc_enable_larger_cage and corresponding
When this flag is enabled, the caged heap can grow up to 16GB.

Testing: The test I would have written for this CL is to validate that
pointer compression and decompression work correctly under 3-bit shift,
which is already covered by MemberTest.CompressDecompress. I ran the
MemberTest unit tests locally with the flag enabled and confirmed that
they pass. I also ran a full CQ dry run with the flag enabled here:
https://chromium-review.googlesource.com/c/v8/v8/+/4491403

Bug: chromium:1434388
Change-Id: I7fb07c84f3a408add2a67b875acb513906b3e18c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4491284
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#87419}
2023-05-03 16:11:24 +00:00
Kevin Babbitt 0d2e4d22b9 cppgc: Factor pointer compression shift into a constant
Rewrite caged heap reservation and pointer compression/decompression in
terms of a named constant. On its own this has no functional change, but
it sets us up to vary the amount of pointer compression shift to allow
for larger heaps.

Bug: chromium:1434388
Change-Id: I1f5fcf3f168c8cde9be37fb2633e5fe8ddf9dfd0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4491283
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#87387}
2023-05-02 17:51:55 +00:00
Anton Bikineev b7b04bbacc cppgc: Allocate CageBaseGlobal in a separate cacheline
The linker puts CageBaseGlobal into the .data (i.e. modifiable) section
together with other potentially frequently modifiable global variables.
Make sure false sharing doesn't happen for CageBaseGlobal by storing it
in a dedicated cacheline.

Bug: chromium:1418300
Change-Id: I1ed9bce5ae61eb295a7c20b7a21b19271fa6e5bb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4280186
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#86087}
2023-02-25 23:36:46 +00:00
Dave Tapuska 86640aa589 Make JIT work in iOS simulator
Due to restrictions on device we are not able to execute code
using a JIT. However it is possible to enable it in the iOS simulator
so we can continue gathering performance data.

Bug: chromium:1413818, chromium:1411704
Change-Id: Ie370a280f439d53ba3f31ee40ff53fa87378be1f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4277141
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#86004}
2023-02-22 15:31:35 +00:00
Anton Bikineev d469a70049 cppgc: Fix CombinedWriteBarrierSlow()
The function relied on passed pointers always being compressed, which
is no longer the case with subtle::UncompressedMember<>.

Bug: chromium:1412021, chromium:1412221

Change-Id: I531e41d24fcab34e527db99f8047123f254e8a74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4217411
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85623}
2023-02-02 13:38:39 +00:00
Anton Bikineev 02afcd6b05 cppgc: Introduce subtle::UncompressedMember
Some very hot getters in Blink can spend many cycles on decompression.
We're planning to optimize such paths by selectively using uncompressed
pointers.

Change-Id: I78af751c423c56010a794448450032c66f8fa244
Bug: chromium:1410145
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4191778
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85508}
2023-01-26 23:51:28 +00:00
Michael Lippautz 48e79783ee cppgc: Optimize MakeGarbageCollected
Annotate slow path call for creating a new GCInfo accordingly. This
path will only hit for the first object allocation for a given type.
All subsequent allocations will use the fast path.

Bug: chromium:1408821
Change-Id: Ifc1d3491a94b30dfeee1a2c9679c64939025fefe
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4161752
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85408}
2023-01-19 18:46:28 +00:00
Michael Lippautz c020a31092 cppgc: Change calling convention for slow write barrier bailout
Change the calling convention for the slow write barrier call to allow
callers to avoid saving caller-saved registers.

Bug: chromium:1406464
Change-Id: I314bdacb235727e0e78a192ed7cbff09e9bc6b4b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4156476
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85254}
2023-01-12 14:23:01 +00:00
Michael Lippautz 24ca73004e cppgc: Implement slim write barrier
Introduces a slim write barrier for Oilpan behind
`cppgc_enable_slim_write_barrier` that is enabled by default. The slim
write barrier only performs a single approximate global check for
whether the write barrier is needed and delegates all other checks to
a slow path call. This is beneficial in configurations that do not need
many checks for the barrier overall, i.e., configurations without
young generation. Young generation is off by default which is why this
approach is beneficial.

On Speedometer the write barrier is hit 75M times with a fast bailout
of 99.3%. Progression on Speedometer2 is somewhere around 0.2-0.5%.

The resulting code embedded in another function is only 34 bytes
compared to 128 bytes before. See attached bug for detailed assembly
snippet.

Change-Id: I6869513186e7a26104c46f1f2ac2cfa855689f64
Bug: chromium:1406464
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4152488
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85232}
2023-01-11 18:54:57 +00:00
Anton Bikineev 6b1f085f99 cppgc: Apply [[clang::trivial_abi]] for Member<>
The attribute allows the Member to be passed around in registers. More
in the design dec: https://bit.ly/3e5tsok

Change-Id: I9c46fb2a5813f1f51f291fac6c0753f505009410
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3925708
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83550}
2022-10-06 06:52:13 +00:00