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 {
static constexpr uintptr_t kLowerHalfWordMask =
(api_constants::kCagedHeapReservationAlignment - 1);
static thread_local V8_EXPORT uintptr_t g_base_
static V8_EXPORT uintptr_t g_base_
#if !V8_CC_MSVC
__attribute__((require_constant_initialization))
#endif // !V8_CC_MSVC
......
......@@ -84,8 +84,7 @@ CagedHeap::CagedHeap(PageAllocator& platform_allocator)
#if defined(CPPGC_POINTER_COMPRESSION)
// With pointer compression only single heap per thread is allowed.
CHECK(!CageBaseGlobal::IsSet());
CageBaseGlobalUpdater::UpdateCageBase(
reinterpret_cast<uintptr_t>(reserved_area_.address()));
CageBaseGlobalUpdater::UpdateCageBase(CagedHeapBase::g_heap_base_);
#endif // defined(CPPGC_POINTER_COMPRESSION)
const bool is_not_oom = platform_allocator.SetPermissions(
......
......@@ -54,32 +54,6 @@ bool HasWorkForConcurrentMarking(MarkingWorklists& marking_worklists) {
->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 {
public:
explicit ConcurrentMarkingTask(ConcurrentMarkerBase&);
......@@ -102,10 +76,6 @@ void ConcurrentMarkingTask::Run(JobDelegate* job_delegate) {
StatsCollector::EnabledConcurrentScope stats_scope(
concurrent_marker_.heap().stats_collector(),
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()))
return;
ConcurrentMarkingState concurrent_marking_state(
......
......@@ -8,8 +8,7 @@ namespace cppgc {
namespace internal {
#if defined(CPPGC_POINTER_COMPRESSION)
thread_local uintptr_t CageBaseGlobal::g_base_ =
CageBaseGlobal::kLowerHalfWordMask;
uintptr_t CageBaseGlobal::g_base_ = CageBaseGlobal::kLowerHalfWordMask;
#endif // defined(CPPGC_POINTER_COMPRESSION)
} // 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