Browse Source

fix?

lizzie/multicore-macos-fix1
lizzie 4 days ago
parent
commit
967af80be6
  1. 8
      src/core/cpu_manager.cpp
  2. 28
      src/core/hle/kernel/kernel.cpp
  3. 2
      src/core/hle/kernel/physical_core.cpp
  4. 6
      src/dynarmic/src/dynarmic/backend/x64/a32_interface.cpp
  5. 2
      src/dynarmic/src/dynarmic/backend/x64/a64_interface.cpp

8
src/core/cpu_manager.cpp

@ -104,12 +104,10 @@ void CpuManager::MultiCoreRunGuestThread() {
kernel.CurrentScheduler()->OnThreadStart();
while (true) {
auto* physical_core = &kernel.CurrentPhysicalCore();
while (!physical_core->IsInterrupted()) {
physical_core->RunThread(thread);
physical_core = &kernel.CurrentPhysicalCore();
auto& physical_core = kernel.CurrentPhysicalCore();
while (!physical_core.IsInterrupted()) {
physical_core.RunThread(thread);
}
HandleInterrupt();
}
}

28
src/core/hle/kernel/kernel.cpp

@ -355,19 +355,8 @@ struct KernelCore::Impl {
application_process->Open();
}
/// Sets the host thread ID for the caller.
u32 SetHostThreadId(std::size_t core_id) {
// This should only be called during core init.
ASSERT(tls_data.host_thread_id == UINT8_MAX);
// The first four slots are reserved for CPU core threads
ASSERT(core_id < Core::Hardware::NUM_CPU_CORES);
tls_data.host_thread_id = u8(core_id);
return tls_data.host_thread_id;
}
/// Gets the host thread ID for the caller
u32 GetHostThreadId() const {
[[nodiscard]] inline u32 GetHostThreadId() const noexcept {
return tls_data.host_thread_id;
}
@ -386,9 +375,12 @@ struct KernelCore::Impl {
}
/// Registers a CPU core thread by allocating a host thread ID for it
void RegisterCoreThread(std::size_t core_id) {
void RegisterCoreThread(std::size_t core_id) noexcept {
// This should only be called during core init.
ASSERT(tls_data.host_thread_id == UINT8_MAX);
// The first four slots are reserved for CPU core threads
ASSERT(core_id < Core::Hardware::NUM_CPU_CORES);
const auto this_id = SetHostThreadId(core_id);
const auto this_id = tls_data.host_thread_id = u8(core_id);
if (!is_multicore)
single_core_thread_id = this_id;
}
@ -398,7 +390,7 @@ struct KernelCore::Impl {
(void)GetHostDummyThread(existing_thread);
}
[[nodiscard]] u32 GetCurrentHostThreadID() {
[[nodiscard]] inline u32 GetCurrentHostThreadID() noexcept {
auto const this_id = GetHostThreadId();
if (!is_multicore && single_core_thread_id == this_id)
return u32(system.GetCpuManager().CurrentCore());
@ -930,11 +922,7 @@ const Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) const {
}
size_t KernelCore::CurrentPhysicalCoreIndex() const {
const u32 core_id = impl->GetCurrentHostThreadID();
if (core_id >= Core::Hardware::NUM_CPU_CORES) {
return Core::Hardware::NUM_CPU_CORES - 1;
}
return core_id;
return impl->GetCurrentHostThreadID();
}
Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() {

2
src/core/hle/kernel/physical_core.cpp

@ -207,7 +207,7 @@ void PhysicalCore::Idle() {
m_on_interrupt.wait(lk, [this] { return m_is_interrupted; });
}
bool PhysicalCore::IsInterrupted() const {
[[noinline]] bool PhysicalCore::IsInterrupted() const {
return m_is_interrupted;
}

6
src/dynarmic/src/dynarmic/backend/x64/a32_interface.cpp

@ -120,11 +120,13 @@ struct Jit::Impl {
}
void HaltExecution(HaltReason hr) {
Atomic::Or(&jit_state.halt_reason, static_cast<u32>(hr));
Atomic::Or(&jit_state.halt_reason, u32(hr));
Atomic::Barrier();
}
void ClearHalt(HaltReason hr) {
Atomic::And(&jit_state.halt_reason, ~static_cast<u32>(hr));
Atomic::And(&jit_state.halt_reason, ~u32(hr));
Atomic::Barrier();
}
void ClearExclusiveState() {

2
src/dynarmic/src/dynarmic/backend/x64/a64_interface.cpp

@ -122,10 +122,12 @@ public:
void HaltExecution(HaltReason hr) {
Atomic::Or(&jit_state.halt_reason, u32(hr));
Atomic::Barrier();
}
void ClearHalt(HaltReason hr) {
Atomic::And(&jit_state.halt_reason, ~u32(hr));
Atomic::Barrier();
}
u64 GetSP() const {

Loading…
Cancel
Save