Function lookup is slow - replacing with a faster test.

This commit is contained in:
Ben Vanik 2015-06-08 23:44:38 -07:00
parent 1a2b4a38e0
commit dbcdc5b543
3 changed files with 12 additions and 8 deletions

View File

@ -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) {

View File

@ -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<Function*> Processor::FindFunctionsWithAddress(uint32_t address) {
return entry_table_.FindWithAddress(address);
}

View File

@ -65,6 +65,7 @@ class Processor {
FunctionInfo::BuiltinHandler handler, void* arg0,
void* arg1);
Function* QueryFunction(uint32_t address);
std::vector<Function*> FindFunctionsWithAddress(uint32_t address);
bool LookupFunctionInfo(uint32_t address, FunctionInfo** out_symbol_info);