diff --git a/src/backend/core/JIT.cpp b/src/backend/core/JIT.cpp index 4689696c..49cb1eed 100644 --- a/src/backend/core/JIT.cpp +++ b/src/backend/core/JIT.cpp @@ -146,7 +146,7 @@ int JIT::Step() { code.push(code.rbp); code.mov(code.rbp, reinterpret_cast(this)); // Load context pointer - //cs_insn *insn; + cs_insn *insn; info("\tMIPS code (guest PC = 0x{:016X}):", blockPC); while (!instrEndsBlock) { // CheckCompareInterrupt(); @@ -224,20 +224,18 @@ int JIT::Step() { code.add(code.rsp, 8); code.ret(); code.setProtectModeRE(); - //static auto blockInfoSize = 0; - //blockInfoSize = code.getSize() - blockInfoSize; + static auto blockInfoSize = 0; + blockInfoSize = code.getSize() - blockInfoSize; - //trace("\tX86 code (block address = 0x{:016X}):", (uintptr_t)block); - //auto count = cs_disasm(disassemblerX86, blockInfo, blockInfoSize, (uintptr_t)block, 0, &insn); - //if (count > 0) { - // for (size_t j = 0; j < count; j++) { - // trace("\t\t0x{:016X}:\t{}\t\t{}\n", insn[j].address, insn[j].mnemonic, insn[j].op_str); - // } - // - // cs_free(insn, count); - //} - // const auto dump = code.getCode(); - // Util::WriteFileBinary(dump, code.getSize(), "jit.dump"); + info("\tX86 code (block address = 0x{:016X}):", (uintptr_t)block); + auto count = cs_disasm(disassemblerX86, blockInfo, blockInfoSize, (uintptr_t)block, 0, &insn); + if (count > 0) { + for (size_t j = 0; j < count; j++) { + info("\t\t0x{:016X}:\t{}\t\t{}", insn[j].address, insn[j].mnemonic, insn[j].op_str); + } + + cs_free(insn, count); + } // panic(""); return block(); } diff --git a/src/backend/core/JIT.hpp b/src/backend/core/JIT.hpp index 08e9e243..adc2c6da 100644 --- a/src/backend/core/JIT.hpp +++ b/src/backend/core/JIT.hpp @@ -16,7 +16,7 @@ static constexpr u32 kUpperSize = kAddressSpaceSize >> kUpperShift; // 0x800000 static constexpr u32 kLowerSize = 0x100; // 0x80 static constexpr u32 kCodeCacheSize = 32_mb; static constexpr u32 kCodeCacheAllocSize = kCodeCacheSize + 4_kb; -#define REG(acc, x) code.acc[code.rbp + (reinterpret_cast(®s.x) - (uintptr_t)this)] +#define REG(acc, x) code.acc[reinterpret_cast(®s.x)] #ifdef __aarch64__ struct JIT : BaseCPU {}; @@ -51,13 +51,13 @@ private: template Xbyak::Address GPR(const size_t index) const { if constexpr (sizeof(T) == 1) { - return code.byte[code.rbp + (reinterpret_cast(®s.gpr[index]) - reinterpret_cast(this))]; + return code.byte[reinterpret_cast(®s.gpr[index])]; } else if constexpr (sizeof(T) == 2) { - return code.word[code.rbp + (reinterpret_cast(®s.gpr[index]) - reinterpret_cast(this))]; + return code.word[reinterpret_cast(®s.gpr[index])]; } else if constexpr (sizeof(T) == 4) { - return code.dword[code.rbp + (reinterpret_cast(®s.gpr[index]) - reinterpret_cast(this))]; + return code.dword[reinterpret_cast(®s.gpr[index])]; } else if constexpr (sizeof(T) == 8) { - return code.qword[code.rbp + (reinterpret_cast(®s.gpr[index]) - reinterpret_cast(this))]; + return code.qword[reinterpret_cast(®s.gpr[index])]; } Util::Error::GetInstance().Throw(