mirror of
https://github.com/ruby/ruby.git
synced 2025-09-22 03:53:58 +02:00
Fix sneaky ujit side-exit bug. Reduce ujit call threshold to 1.
This commit is contained in:
parent
542f2ba09e
commit
97cffcf79a
2 changed files with 20 additions and 7 deletions
2
ujit.h
2
ujit.h
|
@ -41,7 +41,7 @@ bool rb_ujit_enabled_p(void)
|
|||
return rb_ujit_enabled;
|
||||
}
|
||||
|
||||
#define UJIT_CALL_THRESHOLD (10u)
|
||||
#define UJIT_CALL_THRESHOLD (1u)
|
||||
|
||||
void rb_ujit_method_lookup_change(VALUE cme_or_cc);
|
||||
void rb_ujit_compile_iseq(const rb_iseq_t *iseq);
|
||||
|
|
|
@ -88,19 +88,19 @@ Generate an out-of-line exit to return to the interpreter
|
|||
static uint8_t *
|
||||
ujit_side_exit(jitstate_t* jit, ctx_t* ctx)
|
||||
{
|
||||
uint8_t* code_ptr = cb_get_ptr(ocb, cb->write_pos);
|
||||
uint8_t* code_ptr = cb_get_ptr(ocb, ocb->write_pos);
|
||||
|
||||
// Table mapping opcodes to interpreter handlers
|
||||
const void * const *table = rb_vm_get_insns_address_table();
|
||||
const void * const *handler_table = rb_vm_get_insns_address_table();
|
||||
|
||||
// Write back the old instruction at the exit PC
|
||||
// Otherwise the interpreter may jump right back to the
|
||||
// JITted code we're trying to exit
|
||||
VALUE* exit_pc = &jit->iseq->body->iseq_encoded[jit->insn_idx];
|
||||
int exit_opcode = opcode_at_pc(jit->iseq, exit_pc);
|
||||
void* exit_instr = (void*)table[exit_opcode];
|
||||
void* handler_addr = (void*)handler_table[exit_opcode];
|
||||
mov(ocb, RAX, const_ptr_opnd(exit_pc));
|
||||
mov(ocb, RCX, const_ptr_opnd(exit_instr));
|
||||
mov(ocb, RCX, const_ptr_opnd(handler_addr));
|
||||
mov(ocb, mem_opnd(64, RAX, 0), RCX);
|
||||
|
||||
// Generate the code to exit to the interpreters
|
||||
|
@ -932,8 +932,21 @@ gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx)
|
|||
void
|
||||
gen_branchunless_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t shape)
|
||||
{
|
||||
jz_ptr(cb, target0);
|
||||
jmp_ptr(cb, target1);
|
||||
switch (shape)
|
||||
{
|
||||
case SHAPE_NEXT0:
|
||||
jnz_ptr(cb, target1);
|
||||
break;
|
||||
|
||||
case SHAPE_NEXT1:
|
||||
jz_ptr(cb, target0);
|
||||
break;
|
||||
|
||||
case SHAPE_DEFAULT:
|
||||
jz_ptr(cb, target0);
|
||||
jmp_ptr(cb, target1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue