summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2021-06-09 17:01:57 -0700
committerAlan Wu <[email protected]>2021-10-20 18:19:36 -0400
commit986b9b47d11829f1071f7d3bab78f847ea4543bf (patch)
tree2fd7a23c139b62fcf8e62e97fba4006587bfd0a7 /yjit_codegen.c
parent0a3ee8b2e314ee0950dbdb39e9dd0da58f63f16f (diff)
Better comments
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r--yjit_codegen.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c
index afb1d00918..dc148c1951 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -2924,6 +2924,10 @@ gen_invokesuper(jitstate_t *jit, ctx_t *ctx)
if (!me) {
return YJIT_CANT_COMPILE;
} else if (me->def->type == VM_METHOD_TYPE_BMETHOD) {
+ // In the interpreter the method id can change which is tested for and
+ // invalidates the cache.
+ // By skipping super calls inside a BMETHOD definition, I believe we
+ // avoid this case
return YJIT_CANT_COMPILE;
}
@@ -2949,6 +2953,11 @@ gen_invokesuper(jitstate_t *jit, ctx_t *ctx)
VALUE comptime_recv = jit_peek_at_stack(jit, ctx, argc);
VALUE comptime_recv_klass = CLASS_OF(comptime_recv);
+ // Ensure we haven't rebound this method onto an incompatible class.
+ // In the interpreter we try to avoid making this check by performing some
+ // cheaper calculations first, but since we specialize on the receiver
+ // class and so only have to do this once at compile time this is fine to
+ // always check and side exit.
if (!rb_obj_is_kind_of(comptime_recv, current_defined_class)) {
return YJIT_CANT_COMPILE;
}
@@ -2967,6 +2976,7 @@ gen_invokesuper(jitstate_t *jit, ctx_t *ctx)
return YJIT_CANT_COMPILE;
}
+ // Check that we'll be able to write this method dispatch before generating checks
switch (cme->def->type) {
case VM_METHOD_TYPE_ISEQ:
case VM_METHOD_TYPE_CFUNC:
@@ -2997,6 +3007,7 @@ gen_invokesuper(jitstate_t *jit, ctx_t *ctx)
x86opnd_t recv = ctx_stack_opnd(ctx, argc);
insn_opnd_t recv_opnd = OPND_STACK(argc);
mov(cb, REG0, recv);
+
if (!jit_guard_known_klass(jit, ctx, comptime_recv_klass, recv_opnd, SEND_MAX_DEPTH, side_exit)) {
return YJIT_CANT_COMPILE;
}