From 9205a6b062bf2a7bfad73f51dcc66c3ec6d93452 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 8 Sep 2019 21:32:34 +0200 Subject: [PATCH] [Kernel] Fixup GetProcAddressByOrdinal Now properly takes a global lock when populating guest_trampoline_map_ as opposed to taking and immediately releasing it Also removes a redundant find() from guest_trampoline_map_ so map is not searched twice if the function has already been generated. --- src/xenia/kernel/kernel_module.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/xenia/kernel/kernel_module.cc b/src/xenia/kernel/kernel_module.cc index 44d7c8ee3..1b79b73fb 100644 --- a/src/xenia/kernel/kernel_module.cc +++ b/src/xenia/kernel/kernel_module.cc @@ -107,12 +107,12 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) { } else { if (export_entry->function_data.trampoline || export_entry->function_data.shim) { - global_critical_region_.Acquire(); + auto global_lock = global_critical_region_.Acquire(); // See if the function has been generated already. - if (guest_trampoline_map_.find(ordinal) != guest_trampoline_map_.end()) { - auto entry = guest_trampoline_map_.find(ordinal); - return entry->second; + auto item = guest_trampoline_map_.find(ordinal); + if (item != guest_trampoline_map_.end()) { + return item->second; } cpu::GuestFunction::ExternHandler handler = nullptr; @@ -131,7 +131,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) { export_entry->name, guest_addr); // Register the function in our map. - guest_trampoline_map_[ordinal] = guest_addr; + guest_trampoline_map_.emplace(ordinal, guest_addr); return guest_addr; } else { // Not implemented.