Commit 19b523fd authored by Anton Bikineev's avatar Anton Bikineev Committed by V8 LUCI CQ

cppgc: Perform caged-heap fast check when conservatively scanning

This aims to speed up stack scanning with a fast on-heap check. The
blooom-filter (at least with caged-heap enabled) is probably not needed
anymore.

Change-Id: I05536025c73df0cacdbbf6c474339dc71ecf33e5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2825590
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76429}
parent 44fe02ce
...@@ -133,6 +133,7 @@ void Stack::IteratePointers(StackVisitor* visitor) const { ...@@ -133,6 +133,7 @@ void Stack::IteratePointers(StackVisitor* visitor) const {
PushAllRegistersAndIterateStack(this, visitor, &IteratePointersImpl); PushAllRegistersAndIterateStack(this, visitor, &IteratePointersImpl);
// No need to deal with callee-saved registers as they will be kept alive by // No need to deal with callee-saved registers as they will be kept alive by
// the regular conservative stack iteration. // the regular conservative stack iteration.
// TODO(chromium:1056170): Add support for SIMD and/or filtering.
IterateSafeStackIfNecessary(visitor); IterateSafeStackIfNecessary(visitor);
} }
......
...@@ -37,11 +37,21 @@ class CagedHeap final { ...@@ -37,11 +37,21 @@ class CagedHeap final {
return *static_cast<CagedHeapLocalData*>(reserved_area_.address()); return *static_cast<CagedHeapLocalData*>(reserved_area_.address());
} }
static uintptr_t OffsetFromAddress(void* address) { static uintptr_t OffsetFromAddress(const void* address) {
return reinterpret_cast<uintptr_t>(address) & return reinterpret_cast<uintptr_t>(address) &
(kCagedHeapReservationAlignment - 1); (kCagedHeapReservationAlignment - 1);
} }
static uintptr_t BaseFromAddress(const void* address) {
return reinterpret_cast<uintptr_t>(address) &
~(kCagedHeapReservationAlignment - 1);
}
bool IsOnHeap(const void* address) const {
return reinterpret_cast<void*>(BaseFromAddress(address)) ==
reserved_area_.address();
}
private: private:
VirtualMemory reserved_area_; VirtualMemory reserved_area_;
std::unique_ptr<AllocatorType> bounded_allocator_; std::unique_ptr<AllocatorType> bounded_allocator_;
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include "src/heap/cppgc/visitor.h" #include "src/heap/cppgc/visitor.h"
#include "src/base/sanitizer/msan.h" #include "src/base/sanitizer/msan.h"
#include "src/heap/cppgc/caged-heap.h"
#include "src/heap/cppgc/gc-info-table.h" #include "src/heap/cppgc/gc-info-table.h"
#include "src/heap/cppgc/heap-base.h"
#include "src/heap/cppgc/heap-object-header.h" #include "src/heap/cppgc/heap-object-header.h"
#include "src/heap/cppgc/heap-page.h" #include "src/heap/cppgc/heap-page.h"
#include "src/heap/cppgc/object-view.h" #include "src/heap/cppgc/object-view.h"
...@@ -50,6 +52,11 @@ void TraceConservatively(ConservativeTracingVisitor* conservative_visitor, ...@@ -50,6 +52,11 @@ void TraceConservatively(ConservativeTracingVisitor* conservative_visitor,
void ConservativeTracingVisitor::TraceConservativelyIfNeeded( void ConservativeTracingVisitor::TraceConservativelyIfNeeded(
const void* address) { const void* address) {
#if defined(CPPGC_CAGED_HEAP)
// TODO(chromium:1056170): Add support for SIMD in stack scanning.
if (V8_LIKELY(!heap_.caged_heap().IsOnHeap(address))) return;
#endif
const BasePage* page = reinterpret_cast<const BasePage*>( const BasePage* page = reinterpret_cast<const BasePage*>(
page_backend_.Lookup(static_cast<ConstAddress>(address))); page_backend_.Lookup(static_cast<ConstAddress>(address)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment