diff options
author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2021-01-15 17:10:52 -0500 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:27 -0400 |
commit | 02a97004751eae471e00b2b6c3ce86c9dd6ae259 (patch) | |
tree | 16795b4ba93362e393f94d27439fec514e2efc99 /ujit_iface.c | |
parent | 79331368b94b297a0653152cb568a9b998af7fee (diff) |
End current block after opt_send_without_block
Diffstat (limited to 'ujit_iface.c')
-rw-r--r-- | ujit_iface.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ujit_iface.c b/ujit_iface.c index 583326ce42..d759560cb6 100644 --- a/ujit_iface.c +++ b/ujit_iface.c @@ -63,6 +63,42 @@ opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc) } } +// Verify that calling with cd on receiver goes to callee +void +check_cfunc_dispatch(VALUE receiver, struct rb_call_data *cd, void *callee, rb_callable_method_entry_t *compile_time_cme) +{ + if (METHOD_ENTRY_INVALIDATED(compile_time_cme)) { + rb_bug("ujit: output code uses invalidated cme %p", (void *)compile_time_cme); + } + + bool callee_correct = false; + const rb_callable_method_entry_t *cme = rb_callable_method_entry(CLASS_OF(receiver), vm_ci_mid(cd->ci)); + if (cme->def->type == VM_METHOD_TYPE_CFUNC) { + const rb_method_cfunc_t *cfunc = UNALIGNED_MEMBER_PTR(cme->def, body.cfunc); + if ((void *)cfunc->func == callee) { + callee_correct = true; + } + } + if (!callee_correct) { + rb_bug("ujit: output code calls wrong method cd->cc->klass: %p", (void *)cd->cc->klass); + } +} + +MJIT_FUNC_EXPORTED VALUE rb_hash_has_key(VALUE hash, VALUE key); + +bool +cfunc_needs_frame(const rb_method_cfunc_t *cfunc) +{ + void* fptr = (void*)cfunc->func; + + // Leaf C functions do not need a stack frame + // or a stack overflow check + return !( + // Hash#key? + fptr == (void*)rb_hash_has_key + ); +} + // GC root for interacting with the GC struct ujit_root_struct {}; |