From 0d6bf924ed7fed0b3b33cbde97b09805dae6ed0c Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Tue, 23 Jul 2024 15:45:51 +0200 Subject: [PATCH] changes jh.globals from map to vector --- gen_input/templates/asmjit/CORENAME.cpp.gtl | 10 ++++++---- src/vm/asmjit/vm_tgc5c.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gen_input/templates/asmjit/CORENAME.cpp.gtl b/gen_input/templates/asmjit/CORENAME.cpp.gtl index 9ad7de4..97ed953 100644 --- a/gen_input/templates/asmjit/CORENAME.cpp.gtl +++ b/gen_input/templates/asmjit/CORENAME.cpp.gtl @@ -96,6 +96,7 @@ protected: using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&); continuation_e gen_single_inst_behavior(virt_addr_t&, unsigned int &, jit_holder&) override; + enum globals_e {TVAL = 0, GLOBALS_SIZE}; void gen_block_prologue(jit_holder& jh) override; void gen_block_epilogue(jit_holder& jh) override; inline const char *name(size_t index){return traits::reg_aliases.at(index);} @@ -261,7 +262,8 @@ template void vm_impl::gen_block_prologue(jit_holder& jh){ jh.pc = load_reg_from_mem_Gp(jh, traits::PC); jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC); - jh.globals["tval"] = get_reg_Gp(jh.cc, 64, false); + jh.globals.resize(GLOBALS_SIZE); + jh.globals[TVAL] = get_reg_Gp(jh.cc, 64, false); } template void vm_impl::gen_block_epilogue(jit_holder& jh){ @@ -284,7 +286,7 @@ void vm_impl::gen_block_epilogue(jit_holder& jh){ call_enter_trap->setArg(0, jh.arch_if_ptr); call_enter_trap->setArg(1, current_trap_state); call_enter_trap->setArg(2, current_pc); - call_enter_trap->setArg(3, jh.globals["tval"]); + call_enter_trap->setArg(3, jh.globals[TVAL]); 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)); @@ -304,7 +306,7 @@ inline void vm_impl::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t template template void vm_impl::gen_set_tval(jit_holder& jh, T new_tval) { - mov(jh.cc, jh.globals["tval"], new_tval); + mov(jh.cc, jh.globals[TVAL], new_tval); } template void vm_impl::gen_set_tval(jit_holder& jh, x86_reg_t _new_tval) { @@ -312,7 +314,7 @@ void vm_impl::gen_set_tval(jit_holder& jh, x86_reg_t _new_tval) { x86::Gp new_tval = std::get(_new_tval); if(new_tval.size() < 8) new_tval = gen_ext_Gp(jh.cc, new_tval, 64, false); - mov(jh.cc, jh.globals["tval"], new_tval); + mov(jh.cc, jh.globals[TVAL], new_tval); } else { throw std::runtime_error("Variant not supported in gen_set_tval"); } diff --git a/src/vm/asmjit/vm_tgc5c.cpp b/src/vm/asmjit/vm_tgc5c.cpp index f9d774d..fe0215c 100644 --- a/src/vm/asmjit/vm_tgc5c.cpp +++ b/src/vm/asmjit/vm_tgc5c.cpp @@ -96,6 +96,7 @@ protected: using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&); continuation_e gen_single_inst_behavior(virt_addr_t&, unsigned int &, jit_holder&) override; + enum globals_e {TVAL = 0, GLOBALS_SIZE}; void gen_block_prologue(jit_holder& jh) override; void gen_block_epilogue(jit_holder& jh) override; inline const char *name(size_t index){return traits::reg_aliases.at(index);} @@ -4801,7 +4802,8 @@ template void vm_impl::gen_block_prologue(jit_holder& jh){ jh.pc = load_reg_from_mem_Gp(jh, traits::PC); jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC); - jh.globals["tval"] = get_reg_Gp(jh.cc, 64, false); + jh.globals.resize(GLOBALS_SIZE); + jh.globals[TVAL] = get_reg_Gp(jh.cc, 64, false); } template void vm_impl::gen_block_epilogue(jit_holder& jh){ @@ -4824,7 +4826,7 @@ void vm_impl::gen_block_epilogue(jit_holder& jh){ call_enter_trap->setArg(0, jh.arch_if_ptr); call_enter_trap->setArg(1, current_trap_state); call_enter_trap->setArg(2, current_pc); - call_enter_trap->setArg(3, jh.globals["tval"]); + call_enter_trap->setArg(3, jh.globals[TVAL]); 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)); @@ -4844,7 +4846,7 @@ inline void vm_impl::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t template template void vm_impl::gen_set_tval(jit_holder& jh, T new_tval) { - mov(jh.cc, jh.globals["tval"], new_tval); + mov(jh.cc, jh.globals[TVAL], new_tval); } template void vm_impl::gen_set_tval(jit_holder& jh, x86_reg_t _new_tval) { @@ -4852,7 +4854,7 @@ void vm_impl::gen_set_tval(jit_holder& jh, x86_reg_t _new_tval) { x86::Gp new_tval = std::get(_new_tval); if(new_tval.size() < 8) new_tval = gen_ext_Gp(jh.cc, new_tval, 64, false); - mov(jh.cc, jh.globals["tval"], new_tval); + mov(jh.cc, jh.globals[TVAL], new_tval); } else { throw std::runtime_error("Variant not supported in gen_set_tval"); }