1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Revert "Add a specialized instruction for .nil? calls"

This reverts commit 9faef3113f.

It seemed to cause a failure on macOS Mojave, though I'm unsure how.
20190802T034503Z.fail.html.gz

This tentative revert is to check if the issue is actually caused by the
change or not.
This commit is contained in:
Yusuke Endoh 2019-08-02 15:03:34 +09:00
parent 19006b711d
commit a0980f2446
8 changed files with 1 additions and 48 deletions

View file

@ -1,9 +0,0 @@
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

View file

@ -3255,7 +3255,6 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
case idLength: SP_INSN(length); return COMPILE_OK; case idLength: SP_INSN(length); return COMPILE_OK;
case idSize: SP_INSN(size); return COMPILE_OK; case idSize: SP_INSN(size); return COMPILE_OK;
case idEmptyP: SP_INSN(empty_p);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 idSucc: SP_INSN(succ); return COMPILE_OK;
case idNot: SP_INSN(not); return COMPILE_OK; case idNot: SP_INSN(not); return COMPILE_OK;
} }

View file

@ -3,7 +3,6 @@ firstline, predefined = __LINE__+1, %[\
max max
min min
freeze freeze
nil?
inspect inspect
intern intern
object_id object_id

View file

@ -808,20 +808,6 @@ opt_str_freeze
} }
} }
/* 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 DEFINE_INSN
opt_str_uminus opt_str_uminus
(VALUE str, CALL_INFO ci, CALL_CACHE cc) (VALUE str, CALL_INFO ci, CALL_CACHE cc)

View file

@ -1687,7 +1687,7 @@ rb_true(VALUE obj)
*/ */
MJIT_FUNC_EXPORTED VALUE static VALUE
rb_false(VALUE obj) rb_false(VALUE obj)
{ {
return Qfalse; return Qfalse;

1
vm.c
View file

@ -1656,7 +1656,6 @@ vm_init_redefined_flag(void)
OP(Call, CALL), (C(Proc)); OP(Call, CALL), (C(Proc));
OP(And, AND), (C(Integer)); OP(And, AND), (C(Integer));
OP(Or, OR), (C(Integer)); OP(Or, OR), (C(Integer));
OP(NilP, NIL_P), (C(NilClass));
#undef C #undef C
#undef OP #undef OP
} }

View file

@ -550,7 +550,6 @@ enum ruby_basic_operators {
BOP_LENGTH, BOP_LENGTH,
BOP_SIZE, BOP_SIZE,
BOP_EMPTY_P, BOP_EMPTY_P,
BOP_NIL_P,
BOP_SUCC, BOP_SUCC,
BOP_GT, BOP_GT,
BOP_GE, BOP_GE,

View file

@ -4228,26 +4228,6 @@ vm_opt_empty_p(VALUE recv)
} }
} }
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 static VALUE
fix_succ(VALUE x) fix_succ(VALUE x)
{ {