constant_pool: Allow for 128-bit constants
This commit is contained in:
parent
69de50a878
commit
1423584f9f
4 changed files with 9 additions and 7 deletions
|
@ -189,8 +189,8 @@ void BlockOfCode::SwitchMxcsrOnExit() {
|
||||||
ldmxcsr(dword[r15 + jsi.offsetof_save_host_MXCSR]);
|
ldmxcsr(dword[r15 + jsi.offsetof_save_host_MXCSR]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Xbyak::Address BlockOfCode::MConst(u64 constant) {
|
Xbyak::Address BlockOfCode::MConst(u64 lower, u64 upper) {
|
||||||
return constant_pool.GetConstant(constant);
|
return constant_pool.GetConstant(lower, upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockOfCode::SwitchToFarCode() {
|
void BlockOfCode::SwitchToFarCode() {
|
||||||
|
|
|
@ -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.
|
/// 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.
|
/// "Cold" / Rarely executed instructions sit in far code, so the CPU doesn't fetch them unless necessary.
|
||||||
|
|
|
@ -20,11 +20,13 @@ ConstantPool::ConstantPool(BlockOfCode& code, size_t size) : code(code), pool_si
|
||||||
current_pool_ptr = pool_begin;
|
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);
|
auto iter = constant_info.find(constant);
|
||||||
if (iter == constant_info.end()) {
|
if (iter == constant_info.end()) {
|
||||||
ASSERT(static_cast<size_t>(current_pool_ptr - pool_begin) < pool_size);
|
ASSERT(static_cast<size_t>(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;
|
iter = constant_info.emplace(constant, current_pool_ptr).first;
|
||||||
current_pool_ptr += align_size;
|
current_pool_ptr += align_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ class ConstantPool final {
|
||||||
public:
|
public:
|
||||||
ConstantPool(BlockOfCode& code, size_t size);
|
ConstantPool(BlockOfCode& code, size_t size);
|
||||||
|
|
||||||
Xbyak::Address GetConstant(u64 constant);
|
Xbyak::Address GetConstant(u64 lower, u64 upper = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr size_t align_size = 16; // bytes
|
static constexpr size_t align_size = 16; // bytes
|
||||||
|
|
||||||
std::map<u64, void*> constant_info;
|
std::map<std::tuple<u64, u64>, void*> constant_info;
|
||||||
|
|
||||||
BlockOfCode& code;
|
BlockOfCode& code;
|
||||||
size_t pool_size;
|
size_t pool_size;
|
||||||
|
|
Loading…
Reference in a new issue