From dbcdc5b5436c222f1d937655edef8a031462ce15 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 8 Jun 2015 23:44:38 -0700 Subject: [PATCH] Function lookup is slow - replacing with a faster test. --- src/xenia/cpu/frontend/ppc_scanner.cc | 11 +++-------- src/xenia/cpu/processor.cc | 8 ++++++++ src/xenia/cpu/processor.h | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/xenia/cpu/frontend/ppc_scanner.cc b/src/xenia/cpu/frontend/ppc_scanner.cc index 397b41ba0..ad5d699b2 100644 --- a/src/xenia/cpu/frontend/ppc_scanner.cc +++ b/src/xenia/cpu/frontend/ppc_scanner.cc @@ -34,14 +34,9 @@ PPCScanner::PPCScanner(PPCFrontend* frontend) : frontend_(frontend) {} PPCScanner::~PPCScanner() {} bool PPCScanner::IsRestGprLr(uint32_t address) { - auto functions = frontend_->processor()->FindFunctionsWithAddress(address); - for (auto& function : functions) { - if (function->symbol_info()->behavior() == - FunctionBehavior::kEpilogReturn) { - return true; - } - } - return false; + auto function = frontend_->processor()->QueryFunction(address); + return function && + function->symbol_info()->behavior() == FunctionBehavior::kEpilogReturn; } bool PPCScanner::Scan(FunctionInfo* symbol_info, DebugInfo* debug_info) { diff --git a/src/xenia/cpu/processor.cc b/src/xenia/cpu/processor.cc index d0f6aa745..309b02cf9 100644 --- a/src/xenia/cpu/processor.cc +++ b/src/xenia/cpu/processor.cc @@ -181,6 +181,14 @@ FunctionInfo* Processor::DefineBuiltin(const std::string& name, return fn_info; } +Function* Processor::QueryFunction(uint32_t address) { + auto entry = entry_table_.Get(address); + if (!entry) { + return nullptr; + } + return entry->function; +} + std::vector Processor::FindFunctionsWithAddress(uint32_t address) { return entry_table_.FindWithAddress(address); } diff --git a/src/xenia/cpu/processor.h b/src/xenia/cpu/processor.h index c48dd144e..a8a6e825f 100644 --- a/src/xenia/cpu/processor.h +++ b/src/xenia/cpu/processor.h @@ -65,6 +65,7 @@ class Processor { FunctionInfo::BuiltinHandler handler, void* arg0, void* arg1); + Function* QueryFunction(uint32_t address); std::vector FindFunctionsWithAddress(uint32_t address); bool LookupFunctionInfo(uint32_t address, FunctionInfo** out_symbol_info);