Merge A32 and A64 exclusive monitors

This commit is contained in:
MerryMage 2020-06-17 10:28:24 +01:00
parent 4b371c0445
commit 9f3277540a
10 changed files with 15 additions and 159 deletions

View file

@ -12,7 +12,7 @@
#include <mp/traits/integer_of_size.h>
#include <dynarmic/A32/coprocessor.h>
#include <dynarmic/A32/exclusive_monitor.h>
#include <dynarmic/exclusive_monitor.h>
#include "backend/x64/a32_emit_x64.h"
#include "backend/x64/a32_jitstate.h"

View file

@ -1,62 +0,0 @@
/* This file is part of the dynarmic project.
* Copyright (c) 2018 MerryMage
* SPDX-License-Identifier: 0BSD
*/
#include <algorithm>
#include <dynarmic/A32/exclusive_monitor.h>
#include "common/assert.h"
namespace Dynarmic {
namespace A32 {
ExclusiveMonitor::ExclusiveMonitor(size_t processor_count) :
exclusive_addresses(processor_count, INVALID_EXCLUSIVE_ADDRESS), exclusive_values(processor_count) {
Unlock();
}
size_t ExclusiveMonitor::GetProcessorCount() const {
return exclusive_addresses.size();
}
void ExclusiveMonitor::Lock() {
while (is_locked.test_and_set(std::memory_order_acquire)) {}
}
void ExclusiveMonitor::Unlock() {
is_locked.clear(std::memory_order_release);
}
bool ExclusiveMonitor::CheckAndClear(size_t processor_id, VAddr address) {
const VAddr masked_address = address;
Lock();
if (exclusive_addresses[processor_id] != masked_address) {
Unlock();
return false;
}
for (VAddr& other_address : exclusive_addresses) {
if (other_address == masked_address) {
other_address = INVALID_EXCLUSIVE_ADDRESS;
}
}
return true;
}
void ExclusiveMonitor::Clear() {
Lock();
std::fill(exclusive_addresses.begin(), exclusive_addresses.end(), INVALID_EXCLUSIVE_ADDRESS);
Unlock();
}
void ExclusiveMonitor::ClearProcessor(size_t processor_id) {
Lock();
exclusive_addresses[processor_id] = INVALID_EXCLUSIVE_ADDRESS;
Unlock();
}
} // namespace A32
} // namespace Dynarmic

View file

@ -9,7 +9,7 @@
#include <fmt/ostream.h>
#include <mp/traits/integer_of_size.h>
#include <dynarmic/A64/exclusive_monitor.h>
#include <dynarmic/exclusive_monitor.h>
#include "backend/x64/a64_emit_x64.h"
#include "backend/x64/a64_jitstate.h"

View file

@ -5,11 +5,10 @@
#include <algorithm>
#include <dynarmic/A64/exclusive_monitor.h>
#include <dynarmic/exclusive_monitor.h>
#include "common/assert.h"
namespace Dynarmic {
namespace A64 {
ExclusiveMonitor::ExclusiveMonitor(size_t processor_count) :
exclusive_addresses(processor_count, INVALID_EXCLUSIVE_ADDRESS), exclusive_values(processor_count) {
@ -57,6 +56,4 @@ void ExclusiveMonitor::ClearProcessor(size_t processor_id) {
Unlock();
}
} // namespace A64
} // namespace Dynarmic