Refactor lazily initialized singletons in simulators

Use the slimmer base::LeakyObject instead of base::LazyInstance.

R=tebbi@chromium.org

Bug: v8:8600
Change-Id: I71755db9fe3ea9c61be2cdf009a006947ef5560a
Reviewed-on: https://chromium-review.googlesource.com/c/1392203
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58544}
This commit is contained in:
Clemens Hammacher 2019-01-02 16:34:57 +01:00 committed by Commit Bot
parent aaec5fd51e
commit 3512fab37d
10 changed files with 167 additions and 178 deletions

View File

@ -13,6 +13,7 @@
#include "src/arm/constants-arm.h"
#include "src/assembler-inl.h"
#include "src/base/bits.h"
#include "src/base/lazy-instance.h"
#include "src/codegen.h"
#include "src/disasm.h"
#include "src/macro-assembler.h"
@ -23,9 +24,8 @@
namespace v8 {
namespace internal {
// static
base::LazyInstance<Simulator::GlobalMonitor>::type Simulator::global_monitor_ =
LAZY_INSTANCE_INITIALIZER;
DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor,
Simulator::GlobalMonitor::Get);
// This macro provides a platform independent use of sscanf. The reason for
// SScanF not being implemented in a platform independent way through
@ -690,7 +690,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
}
Simulator::~Simulator() {
global_monitor_.Pointer()->RemoveProcessor(&global_monitor_processor_);
GlobalMonitor::Get()->RemoveProcessor(&global_monitor_processor_);
free(stack_);
}
@ -928,17 +928,16 @@ void Simulator::TrashCallerSaveRegisters() {
int Simulator::ReadW(int32_t addr) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoad(addr);
intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
return *ptr;
}
int Simulator::ReadExW(int32_t addr) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoadExcl(addr, TransactionSize::Word);
global_monitor_.Pointer()->NotifyLoadExcl_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyLoadExcl_Locked(addr, &global_monitor_processor_);
intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
return *ptr;
}
@ -946,18 +945,17 @@ int Simulator::ReadExW(int32_t addr) {
void Simulator::WriteW(int32_t addr, int value) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyStore(addr);
global_monitor_.Pointer()->NotifyStore_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(addr, &global_monitor_processor_);
intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
*ptr = value;
}
int Simulator::WriteExW(int32_t addr, int value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (local_monitor_.NotifyStoreExcl(addr, TransactionSize::Word) &&
global_monitor_.Pointer()->NotifyStoreExcl_Locked(
GlobalMonitor::Get()->NotifyStoreExcl_Locked(
addr, &global_monitor_processor_)) {
intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
*ptr = value;
@ -970,7 +968,7 @@ int Simulator::WriteExW(int32_t addr, int value) {
uint16_t Simulator::ReadHU(int32_t addr) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoad(addr);
uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
return *ptr;
@ -979,17 +977,16 @@ uint16_t Simulator::ReadHU(int32_t addr) {
int16_t Simulator::ReadH(int32_t addr) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoad(addr);
int16_t* ptr = reinterpret_cast<int16_t*>(addr);
return *ptr;
}
uint16_t Simulator::ReadExHU(int32_t addr) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoadExcl(addr, TransactionSize::HalfWord);
global_monitor_.Pointer()->NotifyLoadExcl_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyLoadExcl_Locked(addr, &global_monitor_processor_);
uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
return *ptr;
}
@ -997,10 +994,9 @@ uint16_t Simulator::ReadExHU(int32_t addr) {
void Simulator::WriteH(int32_t addr, uint16_t value) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyStore(addr);
global_monitor_.Pointer()->NotifyStore_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(addr, &global_monitor_processor_);
uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
*ptr = value;
}
@ -1008,18 +1004,17 @@ void Simulator::WriteH(int32_t addr, uint16_t value) {
void Simulator::WriteH(int32_t addr, int16_t value) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyStore(addr);
global_monitor_.Pointer()->NotifyStore_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(addr, &global_monitor_processor_);
int16_t* ptr = reinterpret_cast<int16_t*>(addr);
*ptr = value;
}
int Simulator::WriteExH(int32_t addr, uint16_t value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (local_monitor_.NotifyStoreExcl(addr, TransactionSize::HalfWord) &&
global_monitor_.Pointer()->NotifyStoreExcl_Locked(
GlobalMonitor::Get()->NotifyStoreExcl_Locked(
addr, &global_monitor_processor_)) {
uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
*ptr = value;
@ -1030,50 +1025,47 @@ int Simulator::WriteExH(int32_t addr, uint16_t value) {
}
uint8_t Simulator::ReadBU(int32_t addr) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoad(addr);
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
return *ptr;
}
int8_t Simulator::ReadB(int32_t addr) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoad(addr);
int8_t* ptr = reinterpret_cast<int8_t*>(addr);
return *ptr;
}
uint8_t Simulator::ReadExBU(int32_t addr) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoadExcl(addr, TransactionSize::Byte);
global_monitor_.Pointer()->NotifyLoadExcl_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyLoadExcl_Locked(addr, &global_monitor_processor_);
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
return *ptr;
}
void Simulator::WriteB(int32_t addr, uint8_t value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyStore(addr);
global_monitor_.Pointer()->NotifyStore_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(addr, &global_monitor_processor_);
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
*ptr = value;
}
void Simulator::WriteB(int32_t addr, int8_t value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyStore(addr);
global_monitor_.Pointer()->NotifyStore_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(addr, &global_monitor_processor_);
int8_t* ptr = reinterpret_cast<int8_t*>(addr);
*ptr = value;
}
int Simulator::WriteExB(int32_t addr, uint8_t value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (local_monitor_.NotifyStoreExcl(addr, TransactionSize::Byte) &&
global_monitor_.Pointer()->NotifyStoreExcl_Locked(
GlobalMonitor::Get()->NotifyStoreExcl_Locked(
addr, &global_monitor_processor_)) {
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
*ptr = value;
@ -1086,17 +1078,16 @@ int Simulator::WriteExB(int32_t addr, uint8_t value) {
int32_t* Simulator::ReadDW(int32_t addr) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoad(addr);
int32_t* ptr = reinterpret_cast<int32_t*>(addr);
return ptr;
}
int32_t* Simulator::ReadExDW(int32_t addr) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoadExcl(addr, TransactionSize::DoubleWord);
global_monitor_.Pointer()->NotifyLoadExcl_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyLoadExcl_Locked(addr, &global_monitor_processor_);
int32_t* ptr = reinterpret_cast<int32_t*>(addr);
return ptr;
}
@ -1104,19 +1095,18 @@ int32_t* Simulator::ReadExDW(int32_t addr) {
void Simulator::WriteDW(int32_t addr, int32_t value1, int32_t value2) {
// All supported ARM targets allow unaligned accesses, so we don't need to
// check the alignment here.
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyStore(addr);
global_monitor_.Pointer()->NotifyStore_Locked(addr,
&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(addr, &global_monitor_processor_);
int32_t* ptr = reinterpret_cast<int32_t*>(addr);
*ptr++ = value1;
*ptr = value2;
}
int Simulator::WriteExDW(int32_t addr, int32_t value1, int32_t value2) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (local_monitor_.NotifyStoreExcl(addr, TransactionSize::DoubleWord) &&
global_monitor_.Pointer()->NotifyStoreExcl_Locked(
GlobalMonitor::Get()->NotifyStoreExcl_Locked(
addr, &global_monitor_processor_)) {
intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
*ptr++ = value1;
@ -6014,8 +6004,6 @@ bool Simulator::GlobalMonitor::Processor::NotifyStoreExcl_Locked(
return false;
}
Simulator::GlobalMonitor::GlobalMonitor() : head_(nullptr) {}
void Simulator::GlobalMonitor::NotifyLoadExcl_Locked(int32_t addr,
Processor* processor) {
processor->NotifyLoadExcl_Locked(addr);

View File

@ -447,8 +447,6 @@ class Simulator : public SimulatorBase {
class GlobalMonitor {
public:
GlobalMonitor();
class Processor {
public:
Processor();
@ -484,16 +482,21 @@ class Simulator : public SimulatorBase {
// Called when the simulator is destroyed.
void RemoveProcessor(Processor* processor);
static GlobalMonitor* Get();
private:
// Private constructor. Call {GlobalMonitor::Get()} to get the singleton.
GlobalMonitor() = default;
friend class base::LeakyObject<GlobalMonitor>;
bool IsProcessorInLinkedList_Locked(Processor* processor) const;
void PrependProcessor_Locked(Processor* processor);
Processor* head_;
Processor* head_ = nullptr;
};
LocalMonitor local_monitor_;
GlobalMonitor::Processor global_monitor_processor_;
static base::LazyInstance<GlobalMonitor>::type global_monitor_;
};
} // namespace internal

View File

@ -13,6 +13,7 @@
#include "src/arm64/decoder-arm64-inl.h"
#include "src/assembler-inl.h"
#include "src/base/lazy-instance.h"
#include "src/codegen.h"
#include "src/disasm.h"
#include "src/macro-assembler.h"
@ -57,9 +58,8 @@ TEXT_COLOUR clr_debug_number = FLAG_log_colour ? COLOUR_BOLD(YELLOW) : "";
TEXT_COLOUR clr_debug_message = FLAG_log_colour ? COLOUR(YELLOW) : "";
TEXT_COLOUR clr_printf = FLAG_log_colour ? COLOUR(GREEN) : "";
// static
base::LazyInstance<Simulator::GlobalMonitor>::type Simulator::global_monitor_ =
LAZY_INSTANCE_INITIALIZER;
DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor,
Simulator::GlobalMonitor::Get);
// This is basically the same as PrintF, with a guard for FLAG_trace_sim.
void Simulator::TraceSim(const char* format, ...) {
@ -367,7 +367,7 @@ void Simulator::ResetState() {
Simulator::~Simulator() {
global_monitor_.Pointer()->RemoveProcessor(&global_monitor_processor_);
GlobalMonitor::Get()->RemoveProcessor(&global_monitor_processor_);
delete[] reinterpret_cast<byte*>(stack_);
if (FLAG_log_instruction_stats) {
delete instrument_;
@ -1779,12 +1779,12 @@ void Simulator::LoadStoreHelper(Instruction* instr,
uintptr_t stack = 0;
{
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (instr->IsLoad()) {
local_monitor_.NotifyLoad();
} else {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_processor_);
}
}
@ -1913,12 +1913,12 @@ void Simulator::LoadStorePairHelper(Instruction* instr,
uintptr_t stack = 0;
{
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (instr->IsLoad()) {
local_monitor_.NotifyLoad();
} else {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_processor_);
}
}
@ -2064,7 +2064,7 @@ void Simulator::VisitLoadLiteral(Instruction* instr) {
unsigned rt = instr->Rt();
{
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
local_monitor_.NotifyLoad();
}
@ -2155,12 +2155,12 @@ void Simulator::VisitLoadStoreAcquireRelease(Instruction* instr) {
unsigned access_size = 1 << instr->LoadStoreXSizeLog2();
uintptr_t address = LoadStoreAddress(rn, 0, AddrMode::Offset);
DCHECK_EQ(address % access_size, 0);
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (is_load != 0) {
if (is_exclusive) {
local_monitor_.NotifyLoadExcl(address, get_transaction_size(access_size));
global_monitor_.Pointer()->NotifyLoadExcl_Locked(
address, &global_monitor_processor_);
GlobalMonitor::Get()->NotifyLoadExcl_Locked(address,
&global_monitor_processor_);
} else {
local_monitor_.NotifyLoad();
}
@ -2192,7 +2192,7 @@ void Simulator::VisitLoadStoreAcquireRelease(Instruction* instr) {
DCHECK_NE(rs, rn);
if (local_monitor_.NotifyStoreExcl(address,
get_transaction_size(access_size)) &&
global_monitor_.Pointer()->NotifyStoreExcl_Locked(
GlobalMonitor::Get()->NotifyStoreExcl_Locked(
address, &global_monitor_processor_)) {
switch (op) {
case STLXR_b:
@ -2217,7 +2217,7 @@ void Simulator::VisitLoadStoreAcquireRelease(Instruction* instr) {
}
} else {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_processor_);
switch (op) {
case STLR_b:
MemoryWrite<uint8_t>(address, wreg(rt));
@ -4531,12 +4531,12 @@ void Simulator::NEONLoadStoreMultiStructHelper(const Instruction* instr,
}
{
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (log_read) {
local_monitor_.NotifyLoad();
} else {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_processor_);
}
}
@ -4777,12 +4777,12 @@ void Simulator::NEONLoadStoreSingleStructHelper(const Instruction* instr,
}
{
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (do_load) {
local_monitor_.NotifyLoad();
} else {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_processor_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_processor_);
}
}
@ -5860,8 +5860,6 @@ bool Simulator::GlobalMonitor::Processor::NotifyStoreExcl_Locked(
return false;
}
Simulator::GlobalMonitor::GlobalMonitor() : head_(nullptr) {}
void Simulator::GlobalMonitor::NotifyLoadExcl_Locked(uintptr_t addr,
Processor* processor) {
processor->NotifyLoadExcl_Locked(addr);

View File

@ -2230,8 +2230,6 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
class GlobalMonitor {
public:
GlobalMonitor();
class Processor {
public:
Processor();
@ -2267,16 +2265,21 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
// Called when the simulator is destroyed.
void RemoveProcessor(Processor* processor);
static GlobalMonitor* Get();
private:
// Private constructor. Call {GlobalMonitor::Get()} to get the singleton.
GlobalMonitor() = default;
friend class base::LeakyObject<GlobalMonitor>;
bool IsProcessorInLinkedList_Locked(Processor* processor) const;
void PrependProcessor_Locked(Processor* processor);
Processor* head_;
Processor* head_ = nullptr;
};
LocalMonitor local_monitor_;
GlobalMonitor::Processor global_monitor_processor_;
static base::LazyInstance<GlobalMonitor>::type global_monitor_;
private:
void Init(FILE* stream);

View File

@ -14,6 +14,7 @@
#include "src/assembler-inl.h"
#include "src/base/bits.h"
#include "src/base/lazy-instance.h"
#include "src/codegen.h"
#include "src/disasm.h"
#include "src/macro-assembler.h"
@ -24,9 +25,8 @@
namespace v8 {
namespace internal {
// static
base::LazyInstance<Simulator::GlobalMonitor>::type Simulator::global_monitor_ =
LAZY_INSTANCE_INITIALIZER;
DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor,
Simulator::GlobalMonitor::Get);
// Utils functions.
bool HaveSameSign(int32_t a, int32_t b) {
@ -917,7 +917,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
}
Simulator::~Simulator() {
global_monitor_.Pointer()->RemoveLinkedAddress(&global_monitor_thread_);
GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_);
free(stack_);
}
@ -2000,8 +2000,8 @@ void Simulator::WriteW(int32_t addr, int value, Instruction* instr) {
}
if ((addr & kPointerAlignmentMask) == 0 || IsMipsArchVariant(kMips32r6)) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
TraceMemWr(addr, value, WORD);
*ptr = value;
@ -2024,12 +2024,12 @@ void Simulator::WriteConditionalW(int32_t addr, int32_t value,
dbg.Debug();
}
if ((addr & kPointerAlignmentMask) == 0 || IsMipsArchVariant(kMips32r6)) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (local_monitor_.NotifyStoreConditional(addr, TransactionSize::Word) &&
global_monitor_.Pointer()->NotifyStoreConditional_Locked(
GlobalMonitor::Get()->NotifyStoreConditional_Locked(
addr, &global_monitor_thread_)) {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, WORD);
int* ptr = reinterpret_cast<int*>(addr);
*ptr = value;
@ -2062,8 +2062,8 @@ double Simulator::ReadD(int32_t addr, Instruction* instr) {
void Simulator::WriteD(int32_t addr, double value, Instruction* instr) {
if ((addr & kDoubleAlignmentMask) == 0 || IsMipsArchVariant(kMips32r6)) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
double* ptr = reinterpret_cast<double*>(addr);
*ptr = value;
return;
@ -2108,8 +2108,8 @@ int16_t Simulator::ReadH(int32_t addr, Instruction* instr) {
void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) {
if ((addr & 1) == 0 || IsMipsArchVariant(kMips32r6)) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
TraceMemWr(addr, value, HALF);
*ptr = value;
@ -2125,8 +2125,8 @@ void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) {
void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) {
if ((addr & 1) == 0 || IsMipsArchVariant(kMips32r6)) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
int16_t* ptr = reinterpret_cast<int16_t*>(addr);
TraceMemWr(addr, value, HALF);
*ptr = value;
@ -2157,8 +2157,8 @@ int32_t Simulator::ReadB(int32_t addr) {
void Simulator::WriteB(int32_t addr, uint8_t value) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
TraceMemWr(addr, value, BYTE);
*ptr = value;
@ -2167,8 +2167,8 @@ void Simulator::WriteB(int32_t addr, uint8_t value) {
void Simulator::WriteB(int32_t addr, int8_t value) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
int8_t* ptr = reinterpret_cast<int8_t*>(addr);
TraceMemWr(addr, value, BYTE);
*ptr = value;
@ -2192,8 +2192,8 @@ T Simulator::ReadMem(int32_t addr, Instruction* instr) {
template <typename T>
void Simulator::WriteMem(int32_t addr, T value, Instruction* instr) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
int alignment_mask = (1 << sizeof(T)) - 1;
if ((addr & alignment_mask) == 0 || IsMipsArchVariant(kMips32r6)) {
T* ptr = reinterpret_cast<T*>(addr);
@ -6788,12 +6788,12 @@ void Simulator::DecodeTypeImmediate() {
}
case LL: {
DCHECK(!IsMipsArchVariant(kMips32r6));
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
addr = rs + se_imm16;
set_register(rt_reg, ReadW(addr, instr_.instr()));
local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word);
global_monitor_.Pointer()->NotifyLoadLinked_Locked(
addr, &global_monitor_thread_);
GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr,
&global_monitor_thread_);
break;
}
case SC: {
@ -6870,14 +6870,14 @@ void Simulator::DecodeTypeImmediate() {
switch (instr_.FunctionFieldRaw()) {
case LL_R6: {
DCHECK(IsMipsArchVariant(kMips32r6));
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
int32_t base = get_register(instr_.BaseValue());
int32_t offset9 = instr_.Imm9Value();
addr = base + offset9;
DCHECK_EQ(addr & kPointerAlignmentMask, 0);
set_register(rt_reg, ReadW(base + offset9, instr_.instr()));
local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word);
global_monitor_.Pointer()->NotifyLoadLinked_Locked(
GlobalMonitor::Get()->NotifyLoadLinked_Locked(
addr, &global_monitor_thread_);
break;
}
@ -7280,8 +7280,6 @@ bool Simulator::GlobalMonitor::LinkedAddress::NotifyStoreConditional_Locked(
return false;
}
Simulator::GlobalMonitor::GlobalMonitor() : head_(nullptr) {}
void Simulator::GlobalMonitor::NotifyLoadLinked_Locked(
uintptr_t addr, LinkedAddress* linked_address) {
linked_address->NotifyLoadLinked_Locked(addr);

View File

@ -597,8 +597,6 @@ class Simulator : public SimulatorBase {
class GlobalMonitor {
public:
GlobalMonitor();
class LinkedAddress {
public:
LinkedAddress();
@ -636,16 +634,21 @@ class Simulator : public SimulatorBase {
// Called when the simulator is destroyed.
void RemoveLinkedAddress(LinkedAddress* linked_address);
static GlobalMonitor* Get();
private:
// Private constructor. Call {GlobalMonitor::Get()} to get the singleton.
GlobalMonitor() = default;
friend class base::LeakyObject<GlobalMonitor>;
bool IsProcessorInLinkedList_Locked(LinkedAddress* linked_address) const;
void PrependProcessor_Locked(LinkedAddress* linked_address);
LinkedAddress* head_;
LinkedAddress* head_ = nullptr;
};
LocalMonitor local_monitor_;
GlobalMonitor::LinkedAddress global_monitor_thread_;
static base::LazyInstance<GlobalMonitor>::type global_monitor_;
};
} // namespace internal

View File

@ -24,9 +24,8 @@
namespace v8 {
namespace internal {
// static
base::LazyInstance<Simulator::GlobalMonitor>::type Simulator::global_monitor_ =
LAZY_INSTANCE_INITIALIZER;
DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor,
Simulator::GlobalMonitor::Get);
// Util functions.
inline bool HaveSameSign(int64_t a, int64_t b) { return ((a ^ b) >= 0); }
@ -849,7 +848,7 @@ Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
}
Simulator::~Simulator() {
global_monitor_.Pointer()->RemoveLinkedAddress(&global_monitor_thread_);
GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_);
free(stack_);
}
@ -1915,8 +1914,8 @@ void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) {
}
if ((addr & 0x3) == 0 || kArchVariant == kMips64r6) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, WORD);
int* ptr = reinterpret_cast<int*>(addr);
*ptr = value;
@ -1937,12 +1936,12 @@ void Simulator::WriteConditionalW(int64_t addr, int32_t value,
DieOrDebug();
}
if ((addr & 0x3) == 0 || kArchVariant == kMips64r6) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (local_monitor_.NotifyStoreConditional(addr, TransactionSize::Word) &&
global_monitor_.Pointer()->NotifyStoreConditional_Locked(
GlobalMonitor::Get()->NotifyStoreConditional_Locked(
addr, &global_monitor_thread_)) {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, WORD);
int* ptr = reinterpret_cast<int*>(addr);
*ptr = value;
@ -1988,8 +1987,8 @@ void Simulator::Write2W(int64_t addr, int64_t value, Instruction* instr) {
}
if ((addr & kPointerAlignmentMask) == 0 || kArchVariant == kMips64r6) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, DWORD);
int64_t* ptr = reinterpret_cast<int64_t*>(addr);
*ptr = value;
@ -2010,13 +2009,13 @@ void Simulator::WriteConditional2W(int64_t addr, int64_t value,
DieOrDebug();
}
if ((addr & kPointerAlignmentMask) == 0 || kArchVariant == kMips64r6) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (local_monitor_.NotifyStoreConditional(addr,
TransactionSize::DoubleWord) &&
global_monitor_.Pointer()->NotifyStoreConditional_Locked(
GlobalMonitor::Get()->NotifyStoreConditional_Locked(
addr, &global_monitor_thread_)) {
local_monitor_.NotifyStore();
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, DWORD);
int64_t* ptr = reinterpret_cast<int64_t*>(addr);
*ptr = value;
@ -2047,8 +2046,8 @@ double Simulator::ReadD(int64_t addr, Instruction* instr) {
void Simulator::WriteD(int64_t addr, double value, Instruction* instr) {
if ((addr & kDoubleAlignmentMask) == 0 || kArchVariant == kMips64r6) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
double* ptr = reinterpret_cast<double*>(addr);
*ptr = value;
return;
@ -2093,8 +2092,8 @@ int16_t Simulator::ReadH(int64_t addr, Instruction* instr) {
void Simulator::WriteH(int64_t addr, uint16_t value, Instruction* instr) {
if ((addr & 1) == 0 || kArchVariant == kMips64r6) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, HALF);
uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
*ptr = value;
@ -2110,8 +2109,8 @@ void Simulator::WriteH(int64_t addr, uint16_t value, Instruction* instr) {
void Simulator::WriteH(int64_t addr, int16_t value, Instruction* instr) {
if ((addr & 1) == 0 || kArchVariant == kMips64r6) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, HALF);
int16_t* ptr = reinterpret_cast<int16_t*>(addr);
*ptr = value;
@ -2142,8 +2141,8 @@ int32_t Simulator::ReadB(int64_t addr) {
void Simulator::WriteB(int64_t addr, uint8_t value) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, BYTE);
uint8_t* ptr = reinterpret_cast<uint8_t*>(addr);
*ptr = value;
@ -2152,8 +2151,8 @@ void Simulator::WriteB(int64_t addr, uint8_t value) {
void Simulator::WriteB(int64_t addr, int8_t value) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
TraceMemWr(addr, value, BYTE);
int8_t* ptr = reinterpret_cast<int8_t*>(addr);
*ptr = value;
@ -2180,8 +2179,8 @@ void Simulator::WriteMem(int64_t addr, T value, Instruction* instr) {
int alignment_mask = (1 << sizeof(T)) - 1;
if ((addr & alignment_mask) == 0 || kArchVariant == kMips64r6) {
local_monitor_.NotifyStore();
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore_Locked(&global_monitor_thread_);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_);
T* ptr = reinterpret_cast<T*>(addr);
*ptr = value;
TraceMemWr(addr, value);
@ -7120,12 +7119,12 @@ void Simulator::DecodeTypeImmediate() {
}
case LL: {
DCHECK(kArchVariant != kMips64r6);
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
addr = rs + se_imm16;
set_register(rt_reg, ReadW(addr, instr_.instr()));
local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word);
global_monitor_.Pointer()->NotifyLoadLinked_Locked(
addr, &global_monitor_thread_);
GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr,
&global_monitor_thread_);
break;
}
case SC: {
@ -7136,12 +7135,12 @@ void Simulator::DecodeTypeImmediate() {
}
case LLD: {
DCHECK(kArchVariant != kMips64r6);
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
addr = rs + se_imm16;
set_register(rt_reg, Read2W(addr, instr_.instr()));
local_monitor_.NotifyLoadLinked(addr, TransactionSize::DoubleWord);
global_monitor_.Pointer()->NotifyLoadLinked_Locked(
addr, &global_monitor_thread_);
GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr,
&global_monitor_thread_);
break;
}
case SCD: {
@ -7235,27 +7234,27 @@ void Simulator::DecodeTypeImmediate() {
switch (instr_.FunctionFieldRaw()) {
case LL_R6: {
DCHECK_EQ(kArchVariant, kMips64r6);
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
int64_t base = get_register(instr_.BaseValue());
int32_t offset9 = instr_.Imm9Value();
addr = base + offset9;
DCHECK_EQ(addr & 0x3, 0);
set_register(rt_reg, ReadW(addr, instr_.instr()));
local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word);
global_monitor_.Pointer()->NotifyLoadLinked_Locked(
GlobalMonitor::Get()->NotifyLoadLinked_Locked(
addr, &global_monitor_thread_);
break;
}
case LLD_R6: {
DCHECK_EQ(kArchVariant, kMips64r6);
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
int64_t base = get_register(instr_.BaseValue());
int32_t offset9 = instr_.Imm9Value();
addr = base + offset9;
DCHECK_EQ(addr & kPointerAlignmentMask, 0);
set_register(rt_reg, Read2W(addr, instr_.instr()));
local_monitor_.NotifyLoadLinked(addr, TransactionSize::DoubleWord);
global_monitor_.Pointer()->NotifyLoadLinked_Locked(
GlobalMonitor::Get()->NotifyLoadLinked_Locked(
addr, &global_monitor_thread_);
break;
}
@ -7686,8 +7685,6 @@ bool Simulator::GlobalMonitor::LinkedAddress::NotifyStoreConditional_Locked(
return false;
}
Simulator::GlobalMonitor::GlobalMonitor() : head_(nullptr) {}
void Simulator::GlobalMonitor::NotifyLoadLinked_Locked(
uintptr_t addr, LinkedAddress* linked_address) {
linked_address->NotifyLoadLinked_Locked(addr);

View File

@ -621,8 +621,6 @@ class Simulator : public SimulatorBase {
class GlobalMonitor {
public:
GlobalMonitor();
class LinkedAddress {
public:
LinkedAddress();
@ -660,16 +658,21 @@ class Simulator : public SimulatorBase {
// Called when the simulator is destroyed.
void RemoveLinkedAddress(LinkedAddress* linked_address);
static GlobalMonitor* Get();
private:
// Private constructor. Call {GlobalMonitor::Get()} to get the singleton.
GlobalMonitor() = default;
friend class base::LeakyObject<GlobalMonitor>;
bool IsProcessorInLinkedList_Locked(LinkedAddress* linked_address) const;
void PrependProcessor_Locked(LinkedAddress* linked_address);
LinkedAddress* head_;
LinkedAddress* head_ = nullptr;
};
LocalMonitor local_monitor_;
GlobalMonitor::LinkedAddress global_monitor_thread_;
static base::LazyInstance<GlobalMonitor>::type global_monitor_;
};
} // namespace internal

View File

@ -12,6 +12,7 @@
#include "src/assembler.h"
#include "src/base/bits.h"
#include "src/base/lazy-instance.h"
#include "src/codegen.h"
#include "src/disasm.h"
#include "src/macro-assembler.h"
@ -26,9 +27,8 @@
namespace v8 {
namespace internal {
// static
base::LazyInstance<Simulator::GlobalMonitor>::type Simulator::global_monitor_ =
LAZY_INSTANCE_INITIALIZER;
DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor,
Simulator::GlobalMonitor::Get);
// This macro provides a platform independent use of sscanf. The reason for
// SScanF not being implemented in a platform independent way through
@ -3952,12 +3952,6 @@ uintptr_t Simulator::PopAddress() {
return address;
}
Simulator::GlobalMonitor::GlobalMonitor()
: access_state_(MonitorAccess::Open),
tagged_addr_(0),
size_(TransactionSize::None),
thread_id_(ThreadId::Invalid()) {}
void Simulator::GlobalMonitor::Clear() {
access_state_ = MonitorAccess::Open;
tagged_addr_ = 0;

View File

@ -248,14 +248,14 @@ class Simulator : public SimulatorBase {
// Read and write memory.
template <typename T>
inline void Read(uintptr_t address, T* value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
memcpy(value, reinterpret_cast<const char*>(address), sizeof(T));
}
template <typename T>
inline void ReadEx(uintptr_t address, T* value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyLoadExcl(
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyLoadExcl(
address, static_cast<TransactionSize>(sizeof(T)),
isolate_->thread_id());
memcpy(value, reinterpret_cast<const char*>(address), sizeof(T));
@ -263,17 +263,17 @@ class Simulator : public SimulatorBase {
template <typename T>
inline void Write(uintptr_t address, T value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
global_monitor_.Pointer()->NotifyStore(
address, static_cast<TransactionSize>(sizeof(T)),
isolate_->thread_id());
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
GlobalMonitor::Get()->NotifyStore(address,
static_cast<TransactionSize>(sizeof(T)),
isolate_->thread_id());
memcpy(reinterpret_cast<char*>(address), &value, sizeof(T));
}
template <typename T>
inline int32_t WriteEx(uintptr_t address, T value) {
base::MutexGuard lock_guard(&global_monitor_.Pointer()->mutex);
if (global_monitor_.Pointer()->NotifyStoreExcl(
base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex);
if (GlobalMonitor::Get()->NotifyStoreExcl(
address, static_cast<TransactionSize>(sizeof(T)),
isolate_->thread_id())) {
memcpy(reinterpret_cast<char*>(address), &value, sizeof(T));
@ -386,8 +386,6 @@ class Simulator : public SimulatorBase {
class GlobalMonitor {
public:
GlobalMonitor();
// Exposed so it can be accessed by Simulator::{Read,Write}Ex*.
base::Mutex mutex;
@ -397,16 +395,20 @@ class Simulator : public SimulatorBase {
bool NotifyStoreExcl(uintptr_t addr, TransactionSize size,
ThreadId thread_id);
static GlobalMonitor* Get();
private:
// Private constructor. Call {GlobalMonitor::Get()} to get the singleton.
GlobalMonitor() = default;
friend class base::LeakyObject<GlobalMonitor>;
void Clear();
MonitorAccess access_state_;
uintptr_t tagged_addr_;
TransactionSize size_;
ThreadId thread_id_;
MonitorAccess access_state_ = MonitorAccess::Open;
uintptr_t tagged_addr_ = 0;
TransactionSize size_ = TransactionSize::None;
ThreadId thread_id_ = ThreadId::Invalid();
};
static base::LazyInstance<GlobalMonitor>::type global_monitor_;
};
} // namespace internal