From f29fbf35a91b8808aea1c21071e189b47d6c831b Mon Sep 17 00:00:00 2001 From: Hannes Payer Date: Tue, 21 Aug 2018 11:54:28 +0200 Subject: [PATCH] [heap] Provide memory order relaxed accessor of page flags. Bug: chromium:874437,chromium:852420 Change-Id: I4f484a6bb7072804dbcaacab77d25ba7a3fe338f Reviewed-on: https://chromium-review.googlesource.com/1183188 Reviewed-by: Ulan Degenbaev Commit-Queue: Hannes Payer Cr-Commit-Position: refs/heads/master@{#55287} --- src/heap/spaces.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/heap/spaces.h b/src/heap/spaces.h index c170beb1ff..5624ae0bb1 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -568,7 +568,10 @@ class MemoryChunk { void SetFlag(Flag flag) { SetFlags(flag, flag); } - bool IsFlagSet(Flag flag) { return (flags() & flag) != 0; } + template + bool IsFlagSet(Flag flag) { + return (flags() & flag) != 0; + } void ClearFlag(Flag flag) { flags_ &= ~flag; } // Set or clear multiple flags at a time. The flags in the mask are set to @@ -583,7 +586,14 @@ class MemoryChunk { } // Return all current flags. - uintptr_t flags() { return flags_; } + template + uintptr_t flags() { + if (access_mode == AccessMode::NON_ATOMIC) { + return flags_; + } else { + return flags_.load(std::memory_order_relaxed); + } + } bool NeverEvacuate() { return IsFlagSet(NEVER_EVACUATE); }