changes vm_base util API

This commit is contained in:
Eyck-Alexander Jentzsch 2024-07-03 18:32:05 +02:00
parent 5b17599aa2
commit 55b0cea94f
2 changed files with 338 additions and 336 deletions

View File

@ -95,6 +95,7 @@ protected:
using super::gen_wait; using super::gen_wait;
using super::gen_leave; using super::gen_leave;
using super::gen_operation; using super::gen_operation;
using super::gen_sync;
using this_class = vm_impl<ARCH>; using this_class = vm_impl<ARCH>;
using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&); using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&);
@ -160,7 +161,7 @@ private:
} }
x86::Compiler& cc = jh.cc; x86::Compiler& cc = jh.cc;
cc.comment(fmt::format("${instr.name}_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("${instr.name}_{:#x}:",pc.val).c_str());
this->gen_sync(jh, PRE_SYNC, ${idx}); gen_sync(jh, PRE_SYNC, ${idx});
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
pc = pc+${instr.length/8}; pc = pc+${instr.length/8};
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -171,7 +172,7 @@ private:
<%instr.behavior.eachLine{%>${it} <%instr.behavior.eachLine{%>${it}
<%}%> <%}%>
gen_instr_epilogue(jh); gen_instr_epilogue(jh);
this->gen_sync(jh, POST_SYNC, ${idx}); gen_sync(jh, POST_SYNC, ${idx});
return returnValue; return returnValue;
} }
<%}%> <%}%>
@ -181,12 +182,12 @@ private:
continuation_e illegal_intruction(virt_addr_t &pc, code_word_t instr, jit_holder& jh ) { continuation_e illegal_intruction(virt_addr_t &pc, code_word_t instr, jit_holder& jh ) {
x86::Compiler& cc = jh.cc; x86::Compiler& cc = jh.cc;
cc.comment(fmt::format("illegal_intruction{:#x}:",pc.val).c_str()); cc.comment(fmt::format("illegal_intruction{:#x}:",pc.val).c_str());
this->gen_sync(jh, PRE_SYNC, instr_descr.size()); gen_sync(jh, PRE_SYNC, instr_descr.size());
pc = pc + ((instr & 3) == 3 ? 4 : 2); pc = pc + ((instr & 3) == 3 ? 4 : 2);
gen_instr_prologue(jh); gen_instr_prologue(jh);
cc.comment("//behavior:"); cc.comment("//behavior:");
gen_instr_epilogue(jh); gen_instr_epilogue(jh);
this->gen_sync(jh, POST_SYNC, instr_descr.size()); gen_sync(jh, POST_SYNC, instr_descr.size());
return BRANCH; return BRANCH;
} }
@ -282,7 +283,7 @@ void vm_impl<ARCH>::gen_instr_prologue(jit_holder& jh) {
cc.comment("//gen_instr_prologue"); cc.comment("//gen_instr_prologue");
cc.inc(get_ptr_for(jh, traits::ICOUNT)); cc.inc(get_ptr_for(jh, traits::ICOUNT));
x86_reg_t current_trap_state = get_reg_for(jh, traits::TRAP_STATE); x86_reg_t current_trap_state = get_reg_for(cc, traits::TRAP_STATE);
mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE));
mov(cc, get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state); mov(cc, get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state);
@ -292,7 +293,7 @@ void vm_impl<ARCH>::gen_instr_epilogue(jit_holder& jh) {
auto& cc = jh.cc; auto& cc = jh.cc;
cc.comment("//gen_instr_epilogue"); cc.comment("//gen_instr_epilogue");
x86_reg_t current_trap_state = get_reg_for(jh, traits::TRAP_STATE); x86_reg_t current_trap_state = get_reg_for(cc, traits::TRAP_STATE);
mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE));
cmp(cc, current_trap_state, 0); cmp(cc, current_trap_state, 0);
cc.jne(jh.trap_entry); cc.jne(jh.trap_entry);
@ -313,10 +314,10 @@ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
this->write_back(jh); this->write_back(jh);
this->gen_sync(jh, POST_SYNC, -1); this->gen_sync(jh, POST_SYNC, -1);
x86::Gp current_trap_state = get_reg_for_Gp(jh, traits::TRAP_STATE); x86::Gp current_trap_state = get_reg_for_Gp(cc, traits::TRAP_STATE);
mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE));
x86::Gp current_pc = get_reg_for_Gp(jh, traits::PC); x86::Gp current_pc = get_reg_for_Gp(cc, traits::PC);
mov(cc, current_pc, get_ptr_for(jh, traits::PC)); mov(cc, current_pc, get_ptr_for(jh, traits::PC));
x86::Gp instr = cc.newInt32("instr"); x86::Gp instr = cc.newInt32("instr");
@ -329,7 +330,7 @@ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
call_enter_trap->setArg(2, current_pc); call_enter_trap->setArg(2, current_pc);
call_enter_trap->setArg(3, instr); call_enter_trap->setArg(3, instr);
x86_reg_t current_next_pc = get_reg_for(jh, traits::NEXT_PC); x86_reg_t current_next_pc = get_reg_for(cc, traits::NEXT_PC);
mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC));
mov(cc, jh.next_pc, current_next_pc); mov(cc, jh.next_pc, current_next_pc);
@ -340,7 +341,7 @@ template <typename ARCH>
inline void vm_impl<ARCH>::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t cause) { inline void vm_impl<ARCH>::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t cause) {
auto& cc = jh.cc; auto& cc = jh.cc;
cc.comment("//gen_raise"); cc.comment("//gen_raise");
auto tmp1 = get_reg_for(jh, traits::TRAP_STATE); auto tmp1 = get_reg_for(cc, traits::TRAP_STATE);
mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id);
mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1); mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1);
mov(cc, jh.next_pc, std::numeric_limits<uint32_t>::max()); mov(cc, jh.next_pc, std::numeric_limits<uint32_t>::max());

File diff suppressed because it is too large Load Diff