ruby-changes:56761
From: Yusuke <ko1@a...>
Date: Fri, 2 Aug 2019 15:06:06 +0900 (JST)
Subject: [ruby-changes:56761] Yusuke Endoh: a0980f2446 (master): Revert "Add a specialized instruction for `.nil?` calls"
https://git.ruby-lang.org/ruby.git/commit/?id=a0980f2446 From a0980f2446c0db735b8ffeb37e241370c458a626 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Fri, 2 Aug 2019 15:03:34 +0900 Subject: Revert "Add a specialized instruction for `.nil?` calls" This reverts commit 9faef3113fb4331524b81ba73005ba13fa0ef6c6. It seemed to cause a failure on macOS Mojave, though I'm unsure how. https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1014/ruby-master/log/20190802T034503Z.fail.html.gz This tentative revert is to check if the issue is actually caused by the change or not. diff --git a/benchmark/nil_p.yml b/benchmark/nil_p.yml deleted file mode 100644 index 79ba4f2..0000000 --- a/benchmark/nil_p.yml +++ /dev/null @@ -1,9 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0 -prelude: | - class Niller; def nil?; true; end; end - xnil, notnil = nil, Object.new - niller = Niller.new -benchmark: - - xnil.nil? - - notnil.nil? - - niller.nil? -loop_count: 10000000 diff --git a/compile.c b/compile.c index 0dbefd3..774dadf 100644 --- a/compile.c +++ b/compile.c @@ -3255,7 +3255,6 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj) https://github.com/ruby/ruby/blob/trunk/compile.c#L3255 case idLength: SP_INSN(length); return COMPILE_OK; case idSize: SP_INSN(size); return COMPILE_OK; case idEmptyP: SP_INSN(empty_p);return COMPILE_OK; - case idNilP: SP_INSN(nil_p); return COMPILE_OK; case idSucc: SP_INSN(succ); return COMPILE_OK; case idNot: SP_INSN(not); return COMPILE_OK; } diff --git a/defs/id.def b/defs/id.def index 25677ff..66dfdf9 100644 --- a/defs/id.def +++ b/defs/id.def @@ -3,7 +3,6 @@ firstline, predefined = __LINE__+1, %[\ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L3 max min freeze - nil? inspect intern object_id diff --git a/insns.def b/insns.def index 7c93af6..c971026 100644 --- a/insns.def +++ b/insns.def @@ -808,20 +808,6 @@ opt_str_freeze https://github.com/ruby/ruby/blob/trunk/insns.def#L808 } } -/* optimized nil? */ -DEFINE_INSN -opt_nil_p -(CALL_INFO ci, CALL_CACHE cc) -(VALUE recv) -(VALUE val) -{ - val = vm_opt_nil_p(ci, cc, recv); - - if (val == Qundef) { - CALL_SIMPLE_METHOD(); - } -} - DEFINE_INSN opt_str_uminus (VALUE str, CALL_INFO ci, CALL_CACHE cc) diff --git a/object.c b/object.c index 16dce71..3aa7cd2 100644 --- a/object.c +++ b/object.c @@ -1687,7 +1687,7 @@ rb_true(VALUE obj) https://github.com/ruby/ruby/blob/trunk/object.c#L1687 */ -MJIT_FUNC_EXPORTED VALUE +static VALUE rb_false(VALUE obj) { return Qfalse; diff --git a/vm.c b/vm.c index b4e2e3c..115bdca 100644 --- a/vm.c +++ b/vm.c @@ -1656,7 +1656,6 @@ vm_init_redefined_flag(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L1656 OP(Call, CALL), (C(Proc)); OP(And, AND), (C(Integer)); OP(Or, OR), (C(Integer)); - OP(NilP, NIL_P), (C(NilClass)); #undef C #undef OP } diff --git a/vm_core.h b/vm_core.h index d5e18ba..0120f21 100644 --- a/vm_core.h +++ b/vm_core.h @@ -550,7 +550,6 @@ enum ruby_basic_operators { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L550 BOP_LENGTH, BOP_SIZE, BOP_EMPTY_P, - BOP_NIL_P, BOP_SUCC, BOP_GT, BOP_GE, diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 1875d35..57f6d91 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -4228,26 +4228,6 @@ vm_opt_empty_p(VALUE recv) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L4228 } } -VALUE rb_false(VALUE obj); - -static VALUE -vm_opt_nil_p(CALL_INFO ci, CALL_CACHE cc, VALUE recv) -{ - if (recv == Qnil) { - if (BASIC_OP_UNREDEFINED_P(BOP_NIL_P, NIL_REDEFINED_OP_FLAG)) { - return Qtrue; - } else { - return Qundef; - } - } else { - if (vm_method_cfunc_is(ci, cc, recv, rb_false)) { - return Qfalse; - } else { - return Qundef; - } - } -} - static VALUE fix_succ(VALUE x) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/