1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Ujit bug fixes

* uJIT: don't compile tailcalls

* Don't compile calls to protected methods

We need to generate extra code to check whether the call goes through if
we want to support these.

* Fix copy pasta

* Update blockids in branches

* Update dependencies
This commit is contained in:
Alan Wu 2021-02-18 11:54:37 -05:00
parent 15b088bd6e
commit faabe2b0ad
5 changed files with 24 additions and 1 deletions

View file

@ -6627,6 +6627,7 @@ io.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
io.$(OBJEXT): {$(VPATH)}builtin.h
io.$(OBJEXT): {$(VPATH)}config.h
io.$(OBJEXT): {$(VPATH)}constant.h
io.$(OBJEXT): {$(VPATH)}darray.h
io.$(OBJEXT): {$(VPATH)}defines.h
io.$(OBJEXT): {$(VPATH)}dln.h
io.$(OBJEXT): {$(VPATH)}encindex.h

View file

@ -1277,6 +1277,11 @@ gen_opt_swb_iseq(jitstate_t* jit, ctx_t* ctx, struct rb_call_data * cd, const rb
return false;
}
if (vm_ci_flag(cd->ci) & VM_CALL_TAILCALL) {
// We can't handle tailcalls
return false;
}
rb_gc_register_mark_object((VALUE)iseq); // FIXME: intentional LEAK!
// Create a size-exit to fall back to the interpreter
@ -1464,6 +1469,11 @@ gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx)
return false;
}
// We don't generate code to check protected method calls
if (METHOD_ENTRY_VISI(cme) == METHOD_VISI_PROTECTED) {
return false;
}
// If this is a C call
if (cme->def->type == VM_METHOD_TYPE_CFUNC)
{

View file

@ -256,6 +256,15 @@ block_t* find_block_version(blockid_t blockid, const ctx_t* ctx)
return best_version;
}
void
ujit_branches_update_references(void)
{
for (uint32_t i = 0; i < num_branches; i++) {
branch_entries[i].targets[0].iseq = (const void *)rb_gc_location((VALUE)branch_entries[i].targets[0].iseq);
branch_entries[i].targets[1].iseq = (const void *)rb_gc_location((VALUE)branch_entries[i].targets[1].iseq);
}
}
// Compile a new block version immediately
block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx)
{
@ -539,7 +548,7 @@ void gen_direct_jump(
generic_ctx.sp_offset = ctx->sp_offset;
if (count_block_versions(target0) >= MAX_VERSIONS - 1)
{
fprintf(stderr, "version limit hit in branch_stub_hit\n");
fprintf(stderr, "version limit hit in gen_direct_jump\n");
ctx = &generic_ctx;
}

View file

@ -145,6 +145,7 @@ block_t* find_block_version(blockid_t blockid, const ctx_t* ctx);
block_t* gen_block_version(blockid_t blockid, const ctx_t* ctx);
uint8_t* gen_entry_point(const rb_iseq_t *iseq, uint32_t insn_idx);
void ujit_free_block(block_t *block);
void ujit_branches_update_references(void);
void gen_branch(
const ctx_t* src_ctx,

View file

@ -206,6 +206,8 @@ ujit_root_update_references(void *ptr)
RUBY_ASSERT(false);
}
}
ujit_branches_update_references();
}
// GC callback during mark phase