diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2020-09-14 14:36:39 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:23 -0400 |
commit | 3739588811a621ccfd00aa7f8ad804cd1c60f92d (patch) | |
tree | c1228d4249a6f6222b95c003a14d3fe5612c95bb /ujit_compile.c | |
parent | ca47899ccf9547223f4c64fc4b0837796bee09af (diff) |
Remove PC argument from ujit instructions
Diffstat (limited to 'ujit_compile.c')
-rw-r--r-- | ujit_compile.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/ujit_compile.c b/ujit_compile.c index 3f3f8fd2c6..19b2b35c12 100644 --- a/ujit_compile.c +++ b/ujit_compile.c @@ -63,9 +63,13 @@ ujit_compile_insn(rb_iseq_t *iseq, size_t insn_idx) } int insn = (int)iseq->body->iseq_encoded[insn_idx]; + int len = insn_len(insn); //const char* name = insn_name(insn); //printf("%s\n", name); + // Compute the address of the next instruction + void* next_pc = &iseq->body->iseq_encoded[insn_idx + len]; + // Get a pointer to the current write position in the code block uint8_t* code_ptr = &cb->mem_block[cb->write_pos]; //printf("write pos: %ld\n", cb->write_pos); @@ -80,9 +84,12 @@ ujit_compile_insn(rb_iseq_t *iseq, size_t insn_idx) // Write the pre call bytes ujit_instr_entry(cb); - add(cb, RSI, imm_opnd(8)); // increment PC - mov(cb, mem_opnd(64, RDI, 0), RSI); // write new PC to EC object, not necessary for nop bytecode? - mov(cb, RAX, RSI); // return new PC + //add(cb, RSI, imm_opnd(8)); // increment PC + //mov(cb, mem_opnd(64, RDI, 0), RSI); // write new PC to EC object, not necessary for nop bytecode? + //mov(cb, RAX, RSI); // return new PC + + // Directly return the next PC, which is a constant + mov(cb, RAX, const_ptr_opnd(next_pc)); // Write the post call bytes ujit_instr_exit(cb); @@ -98,9 +105,9 @@ ujit_compile_insn(rb_iseq_t *iseq, size_t insn_idx) ujit_instr_entry(cb); sub(cb, mem_opnd(64, RDI, 8), imm_opnd(8)); // decrement SP - add(cb, RSI, imm_opnd(8)); // increment PC - mov(cb, mem_opnd(64, RDI, 0), RSI); // write new PC to EC object, not necessary for pop bytecode? - mov(cb, RAX, RSI); // return new PC + + // Directly return the next PC, which is a constant + mov(cb, RAX, const_ptr_opnd(next_pc)); // Write the post call bytes ujit_instr_exit(cb); |