diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2021-12-07 15:37:32 -0500 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-12-07 17:20:34 -0500 |
commit | 286c07f0dcd7999bfb9cb4889125ebce59dca4cc (patch) | |
tree | 7226c03d1e822ee1824a291588681c46fe977e0a /yjit_codegen.c | |
parent | e51d0d2853126322e8463508aabadc661f45fbe5 (diff) |
YJIT: Remove guard_self_is_heap()
It's superseded by functionality added to jit_guard_known_klass().
In weird situations such as the ones in the included test,
guard_self_is_heap() triggered assertions.
Co-authored-by: Jemma Issroff <jemmaissroff@gmail.com>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5225
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index 9c603e240b..3378f1500d 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -1501,24 +1501,6 @@ gen_setlocal_wc1(jitstate_t *jit, ctx_t *ctx, codeblock_t *cb) return gen_setlocal_generic(jit, ctx, idx, 1); } -// Check that `self` is a pointer to an object on the GC heap -static void -guard_self_is_heap(codeblock_t *cb, x86opnd_t self_opnd, uint8_t *side_exit, ctx_t *ctx) -{ - - // `self` is constant throughout the entire region, so we only need to do this check once. - if (!ctx->self_type.is_heap) { - ADD_COMMENT(cb, "guard self is heap"); - RUBY_ASSERT(Qfalse < Qnil); - test(cb, self_opnd, imm_opnd(RUBY_IMMEDIATE_MASK)); - jnz_ptr(cb, side_exit); - cmp(cb, self_opnd, imm_opnd(Qnil)); - jbe_ptr(cb, side_exit); - - ctx->self_type.is_heap = 1; - } -} - static void gen_jnz_to_target0(codeblock_t *cb, uint8_t *target0, uint8_t *target1, uint8_t shape) { @@ -1808,7 +1790,6 @@ gen_getinstancevariable(jitstate_t *jit, ctx_t *ctx, codeblock_t *cb) // Guard that the receiver has the same class as the one from compile time. mov(cb, REG0, member_opnd(REG_CFP, rb_control_frame_t, self)); - guard_self_is_heap(cb, REG0, COUNTED_EXIT(jit, side_exit, getivar_se_self_not_heap), ctx); jit_guard_known_klass(jit, ctx, comptime_val_klass, OPND_SELF, comptime_val, GETIVAR_MAX_DEPTH, side_exit); @@ -2904,7 +2885,11 @@ gen_jump(jitstate_t *jit, ctx_t *ctx, codeblock_t *cb) } /* -Guard that a stack operand has the same class as known_klass. +Guard that self or a stack operand has the same class as `known_klass`, using +`sample_instance` to speculate about the shape of the runtime value. +FIXNUM and on-heap integers are treated as if they have distinct classes, and +the guard generated for one will fail for the other. + Recompile as contingency if possible, or take side exit a last resort. */ static bool |