diff --git a/src/backend_x64/block_of_code.cpp b/src/backend_x64/block_of_code.cpp index c0c6dd94..0153035b 100644 --- a/src/backend_x64/block_of_code.cpp +++ b/src/backend_x64/block_of_code.cpp @@ -189,8 +189,8 @@ void BlockOfCode::SwitchMxcsrOnExit() { ldmxcsr(dword[r15 + jsi.offsetof_save_host_MXCSR]); } -Xbyak::Address BlockOfCode::MConst(u64 constant) { - return constant_pool.GetConstant(constant); +Xbyak::Address BlockOfCode::MConst(u64 lower, u64 upper) { + return constant_pool.GetConstant(lower, upper); } void BlockOfCode::SwitchToFarCode() { diff --git a/src/backend_x64/block_of_code.h b/src/backend_x64/block_of_code.h index 7b61a1f1..e353fd1f 100644 --- a/src/backend_x64/block_of_code.h +++ b/src/backend_x64/block_of_code.h @@ -70,7 +70,7 @@ public: } } - Xbyak::Address MConst(u64 constant); + Xbyak::Address MConst(u64 lower, u64 upper = 0); /// Far code sits far away from the near code. Execution remains primarily in near code. /// "Cold" / Rarely executed instructions sit in far code, so the CPU doesn't fetch them unless necessary. diff --git a/src/backend_x64/constant_pool.cpp b/src/backend_x64/constant_pool.cpp index f2e57d0b..06b5f934 100644 --- a/src/backend_x64/constant_pool.cpp +++ b/src/backend_x64/constant_pool.cpp @@ -20,11 +20,13 @@ ConstantPool::ConstantPool(BlockOfCode& code, size_t size) : code(code), pool_si current_pool_ptr = pool_begin; } -Xbyak::Address ConstantPool::GetConstant(u64 constant) { +Xbyak::Address ConstantPool::GetConstant(u64 lower, u64 upper) { + const auto constant = std::make_tuple(lower, upper); auto iter = constant_info.find(constant); if (iter == constant_info.end()) { ASSERT(static_cast(current_pool_ptr - pool_begin) < pool_size); - std::memcpy(current_pool_ptr, &constant, sizeof(u64)); + std::memcpy(current_pool_ptr, &lower, sizeof(u64)); + std::memcpy(current_pool_ptr + sizeof(u64), &upper, sizeof(u64)); iter = constant_info.emplace(constant, current_pool_ptr).first; current_pool_ptr += align_size; } diff --git a/src/backend_x64/constant_pool.h b/src/backend_x64/constant_pool.h index aa749304..b4b6eb0f 100644 --- a/src/backend_x64/constant_pool.h +++ b/src/backend_x64/constant_pool.h @@ -24,12 +24,12 @@ class ConstantPool final { public: ConstantPool(BlockOfCode& code, size_t size); - Xbyak::Address GetConstant(u64 constant); + Xbyak::Address GetConstant(u64 lower, u64 upper = 0); private: static constexpr size_t align_size = 16; // bytes - std::map constant_info; + std::map, void*> constant_info; BlockOfCode& code; size_t pool_size;