ruby-changes:72120
From: Noah <ko1@a...>
Date: Sat, 11 Jun 2022 01:29:42 +0900 (JST)
Subject: [ruby-changes:72120] e777ac9161 (master): Don't return a value from jit_guard_known_klass. We never return anything but true at this point and we don't usually check the returned value. (#6000)
https://git.ruby-lang.org/ruby.git/commit/?id=e777ac9161 From e777ac9161f6d772ab2930a037ecb07789be4fe5 Mon Sep 17 00:00:00 2001 From: Noah Gibbs <noah.gibbs@s...> Date: Fri, 10 Jun 2022 17:29:26 +0100 Subject: Don't return a value from jit_guard_known_klass. We never return anything but true at this point and we don't usually check the returned value. (#6000) --- yjit/src/codegen.rs | 65 ++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 4d7e7344ad..ca2c237e2d 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -2448,20 +2448,17 @@ fn gen_equality_specialized( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L2448 // Guard that a is a String mov(cb, REG0, C_ARG_REGS[0]); - unsafe { - // Use of rb_cString here requires an unsafe block - jit_guard_known_klass( - jit, - ctx, - cb, - ocb, - rb_cString, - StackOpnd(1), - comptime_a, - SEND_MAX_DEPTH, - side_exit, - ); - } + jit_guard_known_klass( + jit, + ctx, + cb, + ocb, + unsafe { rb_cString }, + StackOpnd(1), + comptime_a, + SEND_MAX_DEPTH, + side_exit, + ); let ret = cb.new_label("ret".to_string()); @@ -2475,19 +2472,17 @@ fn gen_equality_specialized( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L2472 mov(cb, REG0, C_ARG_REGS[1]); // Note: any T_STRING is valid here, but we check for a ::String for simplicity // To pass a mutable static variable (rb_cString) requires an unsafe block - unsafe { - jit_guard_known_klass( - jit, - ctx, - cb, - ocb, - rb_cString, - StackOpnd(0), - comptime_b, - SEND_MAX_DEPTH, - side_exit, - ); - } + jit_guard_known_klass( + jit, + ctx, + cb, + ocb, + unsafe { rb_cString }, + StackOpnd(0), + comptime_b, + SEND_MAX_DEPTH, + side_exit, + ); } // Call rb_str_eql_internal(a, b) @@ -3353,7 +3348,7 @@ fn jit_guard_known_klass( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3348 sample_instance: VALUE, max_chain_depth: i32, side_exit: CodePtr, -) -> bool { +) { let val_type = ctx.get_opnd_type(insn_opnd); if unsafe { known_klass == rb_cNilClass } { @@ -3472,8 +3467,6 @@ fn jit_guard_known_klass( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3467 cmp(cb, klass_opnd, REG1); jit_chain_guard(JCC_JNE, jit, ctx, cb, ocb, max_chain_depth, side_exit); } - - true } // Generate ancestry guard for protected callee. @@ -3720,7 +3713,7 @@ fn jit_rb_str_concat( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3713 // Guard that the argument is of class String at runtime. let arg_opnd = ctx.stack_opnd(0); mov(cb, REG0, arg_opnd); - if !jit_guard_known_klass( + jit_guard_known_klass( jit, ctx, cb, @@ -3730,9 +3723,7 @@ fn jit_rb_str_concat( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L3723 comptime_arg, SEND_MAX_DEPTH, side_exit, - ) { - return false; - } + ); let concat_arg = ctx.stack_pop(1); let recv = ctx.stack_pop(1); @@ -4800,7 +4791,7 @@ fn gen_send_general( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L4791 let recv = ctx.stack_opnd(argc); let recv_opnd = StackOpnd(argc.try_into().unwrap()); mov(cb, REG0, recv); - if !jit_guard_known_klass( + jit_guard_known_klass( jit, ctx, cb, @@ -4810,9 +4801,7 @@ fn gen_send_general( https://github.com/ruby/ruby/blob/trunk/yjit/src/codegen.rs#L4801 comptime_recv, SEND_MAX_DEPTH, side_exit, - ) { - return CantCompile; - } + ); // Do method lookup let mut cme = unsafe { rb_callable_method_entry(comptime_recv_klass, mid) }; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/