core: Make the exclusive monitor a unique_ptr instead of a shared_ptr
Like the barrier, this is owned entirely by the System and will always outlive the encompassing state, so shared ownership semantics aren't necessary here.
This commit is contained in:
parent
c34efbbd60
commit
aeadbfa790
@ -144,7 +144,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const {
|
|||||||
|
|
||||||
// Multi-process state
|
// Multi-process state
|
||||||
config.processor_id = core_index;
|
config.processor_id = core_index;
|
||||||
config.global_monitor = &exclusive_monitor->monitor;
|
config.global_monitor = &exclusive_monitor.monitor;
|
||||||
|
|
||||||
// System registers
|
// System registers
|
||||||
config.tpidrro_el0 = &cb->tpidrro_el0;
|
config.tpidrro_el0 = &cb->tpidrro_el0;
|
||||||
@ -171,10 +171,9 @@ void ARM_Dynarmic::Step() {
|
|||||||
cb->InterpreterFallback(jit->GetPC(), 1);
|
cb->InterpreterFallback(jit->GetPC(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARM_Dynarmic::ARM_Dynarmic(std::shared_ptr<ExclusiveMonitor> exclusive_monitor,
|
ARM_Dynarmic::ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index)
|
||||||
std::size_t core_index)
|
|
||||||
: cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), core_index{core_index},
|
: cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), core_index{core_index},
|
||||||
exclusive_monitor{std::dynamic_pointer_cast<DynarmicExclusiveMonitor>(exclusive_monitor)} {
|
exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {
|
||||||
ThreadContext ctx{};
|
ThreadContext ctx{};
|
||||||
inner_unicorn.SaveContext(ctx);
|
inner_unicorn.SaveContext(ctx);
|
||||||
PageTableChanged();
|
PageTableChanged();
|
||||||
|
@ -23,7 +23,7 @@ class DynarmicExclusiveMonitor;
|
|||||||
|
|
||||||
class ARM_Dynarmic final : public ARM_Interface {
|
class ARM_Dynarmic final : public ARM_Interface {
|
||||||
public:
|
public:
|
||||||
ARM_Dynarmic(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, std::size_t core_index);
|
ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index);
|
||||||
~ARM_Dynarmic();
|
~ARM_Dynarmic();
|
||||||
|
|
||||||
void MapBackingMemory(VAddr address, std::size_t size, u8* memory,
|
void MapBackingMemory(VAddr address, std::size_t size, u8* memory,
|
||||||
@ -62,7 +62,7 @@ private:
|
|||||||
ARM_Unicorn inner_unicorn;
|
ARM_Unicorn inner_unicorn;
|
||||||
|
|
||||||
std::size_t core_index;
|
std::size_t core_index;
|
||||||
std::shared_ptr<DynarmicExclusiveMonitor> exclusive_monitor;
|
DynarmicExclusiveMonitor& exclusive_monitor;
|
||||||
|
|
||||||
Memory::PageTable* current_page_table = nullptr;
|
Memory::PageTable* current_page_table = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -142,7 +142,7 @@ struct System::Impl {
|
|||||||
cpu_barrier = std::make_unique<CpuBarrier>();
|
cpu_barrier = std::make_unique<CpuBarrier>();
|
||||||
cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size());
|
cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size());
|
||||||
for (std::size_t index = 0; index < cpu_cores.size(); ++index) {
|
for (std::size_t index = 0; index < cpu_cores.size(); ++index) {
|
||||||
cpu_cores[index] = std::make_shared<Cpu>(cpu_exclusive_monitor, *cpu_barrier, index);
|
cpu_cores[index] = std::make_shared<Cpu>(*cpu_exclusive_monitor, *cpu_barrier, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
telemetry_session = std::make_unique<Core::TelemetrySession>();
|
telemetry_session = std::make_unique<Core::TelemetrySession>();
|
||||||
@ -245,6 +245,7 @@ struct System::Impl {
|
|||||||
for (auto& cpu_core : cpu_cores) {
|
for (auto& cpu_core : cpu_cores) {
|
||||||
cpu_core.reset();
|
cpu_core.reset();
|
||||||
}
|
}
|
||||||
|
cpu_exclusive_monitor.reset();
|
||||||
cpu_barrier.reset();
|
cpu_barrier.reset();
|
||||||
|
|
||||||
// Shutdown kernel and core timing
|
// Shutdown kernel and core timing
|
||||||
@ -282,7 +283,7 @@ struct System::Impl {
|
|||||||
std::unique_ptr<VideoCore::RendererBase> renderer;
|
std::unique_ptr<VideoCore::RendererBase> renderer;
|
||||||
std::unique_ptr<Tegra::GPU> gpu_core;
|
std::unique_ptr<Tegra::GPU> gpu_core;
|
||||||
std::shared_ptr<Tegra::DebugContext> debug_context;
|
std::shared_ptr<Tegra::DebugContext> debug_context;
|
||||||
std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor;
|
std::unique_ptr<ExclusiveMonitor> cpu_exclusive_monitor;
|
||||||
std::unique_ptr<CpuBarrier> cpu_barrier;
|
std::unique_ptr<CpuBarrier> cpu_barrier;
|
||||||
std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores;
|
std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores;
|
||||||
std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads;
|
std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads;
|
||||||
|
@ -49,8 +49,7 @@ bool CpuBarrier::Rendezvous() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cpu::Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, CpuBarrier& cpu_barrier,
|
Cpu::Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index)
|
||||||
std::size_t core_index)
|
|
||||||
: cpu_barrier{cpu_barrier}, core_index{core_index} {
|
: cpu_barrier{cpu_barrier}, core_index{core_index} {
|
||||||
if (Settings::values.use_cpu_jit) {
|
if (Settings::values.use_cpu_jit) {
|
||||||
#ifdef ARCHITECTURE_x86_64
|
#ifdef ARCHITECTURE_x86_64
|
||||||
@ -68,10 +67,10 @@ Cpu::Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, CpuBarrier& cpu_ba
|
|||||||
|
|
||||||
Cpu::~Cpu() = default;
|
Cpu::~Cpu() = default;
|
||||||
|
|
||||||
std::shared_ptr<ExclusiveMonitor> Cpu::MakeExclusiveMonitor(std::size_t num_cores) {
|
std::unique_ptr<ExclusiveMonitor> Cpu::MakeExclusiveMonitor(std::size_t num_cores) {
|
||||||
if (Settings::values.use_cpu_jit) {
|
if (Settings::values.use_cpu_jit) {
|
||||||
#ifdef ARCHITECTURE_x86_64
|
#ifdef ARCHITECTURE_x86_64
|
||||||
return std::make_shared<DynarmicExclusiveMonitor>(num_cores);
|
return std::make_unique<DynarmicExclusiveMonitor>(num_cores);
|
||||||
#else
|
#else
|
||||||
return nullptr; // TODO(merry): Passthrough exclusive monitor
|
return nullptr; // TODO(merry): Passthrough exclusive monitor
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,8 +41,7 @@ private:
|
|||||||
|
|
||||||
class Cpu {
|
class Cpu {
|
||||||
public:
|
public:
|
||||||
Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, CpuBarrier& cpu_barrier,
|
Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index);
|
||||||
std::size_t core_index);
|
|
||||||
~Cpu();
|
~Cpu();
|
||||||
|
|
||||||
void RunLoop(bool tight_loop = true);
|
void RunLoop(bool tight_loop = true);
|
||||||
@ -71,7 +70,7 @@ public:
|
|||||||
return core_index;
|
return core_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::shared_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores);
|
static std::unique_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Reschedule();
|
void Reschedule();
|
||||||
|
Loading…
Reference in New Issue
Block a user