Commit 5e17b84d authored by Anton Bikineev's avatar Anton Bikineev Committed by V8 LUCI CQ

cpgpc: pointer-compression: Use global variable for base pointer

Now that the cage is shared, we can remove the thread-local base and
instead use a simple global.

Bug: chromium:1325007
Change-Id: I05019de83868f823c66003740e277578f2a1d439
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3688051
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81037}
parent 912a9023
...@@ -40,7 +40,7 @@ class CageBaseGlobal final { ...@@ -40,7 +40,7 @@ class CageBaseGlobal final {
static constexpr uintptr_t kLowerHalfWordMask = static constexpr uintptr_t kLowerHalfWordMask =
(api_constants::kCagedHeapReservationAlignment - 1); (api_constants::kCagedHeapReservationAlignment - 1);
static thread_local V8_EXPORT uintptr_t g_base_ static V8_EXPORT uintptr_t g_base_
#if !V8_CC_MSVC #if !V8_CC_MSVC
__attribute__((require_constant_initialization)) __attribute__((require_constant_initialization))
#endif // !V8_CC_MSVC #endif // !V8_CC_MSVC
......
...@@ -84,8 +84,7 @@ CagedHeap::CagedHeap(PageAllocator& platform_allocator) ...@@ -84,8 +84,7 @@ CagedHeap::CagedHeap(PageAllocator& platform_allocator)
#if defined(CPPGC_POINTER_COMPRESSION) #if defined(CPPGC_POINTER_COMPRESSION)
// With pointer compression only single heap per thread is allowed. // With pointer compression only single heap per thread is allowed.
CHECK(!CageBaseGlobal::IsSet()); CHECK(!CageBaseGlobal::IsSet());
CageBaseGlobalUpdater::UpdateCageBase( CageBaseGlobalUpdater::UpdateCageBase(CagedHeapBase::g_heap_base_);
reinterpret_cast<uintptr_t>(reserved_area_.address()));
#endif // defined(CPPGC_POINTER_COMPRESSION) #endif // defined(CPPGC_POINTER_COMPRESSION)
const bool is_not_oom = platform_allocator.SetPermissions( const bool is_not_oom = platform_allocator.SetPermissions(
......
...@@ -54,32 +54,6 @@ bool HasWorkForConcurrentMarking(MarkingWorklists& marking_worklists) { ...@@ -54,32 +54,6 @@ bool HasWorkForConcurrentMarking(MarkingWorklists& marking_worklists) {
->IsEmpty(); ->IsEmpty();
} }
#if defined(CPPGC_POINTER_COMPRESSION)
namespace {
// The concurrent marking task can run from a thread where no cage-base is set.
// Moreover, it can run from a thread which has another heap attached. Make sure
// to set/reset the base. This also works for the main thread joining the
// marking.
class PointerCompressionCageScope final {
public:
explicit PointerCompressionCageScope(HeapBase& heap)
: prev_cage_base_(CageBaseGlobalUpdater::GetCageBase()) {
CageBaseGlobalUpdater::UpdateCageBase(
reinterpret_cast<uintptr_t>(heap.caged_heap().base()));
}
~PointerCompressionCageScope() {
CageBaseGlobalUpdater::UpdateCageBase(prev_cage_base_);
}
private:
const uintptr_t prev_cage_base_;
};
} // namespace
#endif // defined(CPPGC_POINTER_COMPRESSION)
class ConcurrentMarkingTask final : public v8::JobTask { class ConcurrentMarkingTask final : public v8::JobTask {
public: public:
explicit ConcurrentMarkingTask(ConcurrentMarkerBase&); explicit ConcurrentMarkingTask(ConcurrentMarkerBase&);
...@@ -102,10 +76,6 @@ void ConcurrentMarkingTask::Run(JobDelegate* job_delegate) { ...@@ -102,10 +76,6 @@ void ConcurrentMarkingTask::Run(JobDelegate* job_delegate) {
StatsCollector::EnabledConcurrentScope stats_scope( StatsCollector::EnabledConcurrentScope stats_scope(
concurrent_marker_.heap().stats_collector(), concurrent_marker_.heap().stats_collector(),
StatsCollector::kConcurrentMark); StatsCollector::kConcurrentMark);
#if defined(CPPGC_POINTER_COMPRESSION)
PointerCompressionCageScope cage_base_resetter(concurrent_marker_.heap());
#endif // defined(CPPGC_POINTER_COMPRESSION)
if (!HasWorkForConcurrentMarking(concurrent_marker_.marking_worklists())) if (!HasWorkForConcurrentMarking(concurrent_marker_.marking_worklists()))
return; return;
ConcurrentMarkingState concurrent_marking_state( ConcurrentMarkingState concurrent_marking_state(
......
...@@ -8,8 +8,7 @@ namespace cppgc { ...@@ -8,8 +8,7 @@ namespace cppgc {
namespace internal { namespace internal {
#if defined(CPPGC_POINTER_COMPRESSION) #if defined(CPPGC_POINTER_COMPRESSION)
thread_local uintptr_t CageBaseGlobal::g_base_ = uintptr_t CageBaseGlobal::g_base_ = CageBaseGlobal::kLowerHalfWordMask;
CageBaseGlobal::kLowerHalfWordMask;
#endif // defined(CPPGC_POINTER_COMPRESSION) #endif // defined(CPPGC_POINTER_COMPRESSION)
} // namespace internal } // namespace internal
......
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