[A64] Add thread-safe atomics to A64Function

Also adds some bounds check to LookupFunction.

Co-Authored-By: Reality <reality@xenios.jp>
This commit is contained in:
Herman S.
2026-03-25 14:15:59 +09:00
parent 0e05b92f85
commit b6ad99ee21
3 changed files with 24 additions and 9 deletions

View File

@@ -234,7 +234,15 @@ class CodeCacheBase : public CodeCache {
}
GuestFunction* LookupFunction(uint64_t host_pc) override {
uint32_t key = uint32_t(host_pc - kGeneratedCodeExecuteBase);
if (generated_code_map_.empty()) {
return nullptr;
}
const uint64_t code_base = execute_base_address();
const uint64_t code_end = code_base + total_size();
if (host_pc < code_base || host_pc >= code_end) {
return nullptr;
}
uint32_t key = uint32_t(host_pc - code_base);
void* fn_entry = std::bsearch(
&key, generated_code_map_.data(), generated_code_map_.size(),
sizeof(std::pair<uint32_t, Function*>),