mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
revert r64847, r64846 and r64839
because r64849 seems to fix issues which we were confused about. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fa3d1ca0f4
commit
6e62e59eec
9 changed files with 87 additions and 7 deletions
16
compile.c
16
compile.c
|
@ -3245,6 +3245,8 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
|
||||||
case idGE: SP_INSN(ge); return COMPILE_OK;
|
case idGE: SP_INSN(ge); return COMPILE_OK;
|
||||||
case idLTLT: SP_INSN(ltlt); return COMPILE_OK;
|
case idLTLT: SP_INSN(ltlt); return COMPILE_OK;
|
||||||
case idAREF: SP_INSN(aref); return COMPILE_OK;
|
case idAREF: SP_INSN(aref); return COMPILE_OK;
|
||||||
|
case idAnd: SP_INSN(and); return COMPILE_OK;
|
||||||
|
case idOr: SP_INSN(or); return COMPILE_OK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -6441,17 +6443,17 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, in
|
||||||
INIT_ANCHOR(args);
|
INIT_ANCHOR(args);
|
||||||
#if SUPPORT_JOKE
|
#if SUPPORT_JOKE
|
||||||
if (nd_type(node) == NODE_VCALL) {
|
if (nd_type(node) == NODE_VCALL) {
|
||||||
ID id_bitblt;
|
ID id_bitblt;
|
||||||
ID id_answer;
|
ID id_answer;
|
||||||
|
|
||||||
CONST_ID(id_bitblt, "bitblt");
|
CONST_ID(id_bitblt, "bitblt");
|
||||||
CONST_ID(id_answer, "the_answer_to_life_the_universe_and_everything");
|
CONST_ID(id_answer, "the_answer_to_life_the_universe_and_everything");
|
||||||
|
|
||||||
if (mid == id_bitblt) {
|
if (mid == id_bitblt) {
|
||||||
ADD_INSN(ret, line, bitblt);
|
ADD_INSN(ret, line, bitblt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (mid == id_answer) {
|
else if (mid == id_answer) {
|
||||||
ADD_INSN(ret, line, answer);
|
ADD_INSN(ret, line, answer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,8 @@ token_ops = %[\
|
||||||
Eqq === EQQ
|
Eqq === EQQ
|
||||||
Neq != NEQ
|
Neq != NEQ
|
||||||
Not !
|
Not !
|
||||||
|
And &
|
||||||
|
Or |
|
||||||
Backquote `
|
Backquote `
|
||||||
EqTilde =~ MATCH
|
EqTilde =~ MATCH
|
||||||
NeqTilde !~ NMATCH
|
NeqTilde !~ NMATCH
|
||||||
|
|
28
insns.def
28
insns.def
|
@ -1216,6 +1216,34 @@ opt_ltlt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* optimized X&Y. */
|
||||||
|
DEFINE_INSN
|
||||||
|
opt_and
|
||||||
|
(CALL_INFO ci, CALL_CACHE cc)
|
||||||
|
(VALUE recv, VALUE obj)
|
||||||
|
(VALUE val)
|
||||||
|
{
|
||||||
|
val = vm_opt_and(recv, obj);
|
||||||
|
|
||||||
|
if (val == Qundef) {
|
||||||
|
CALL_SIMPLE_METHOD();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* optimized X|Y. */
|
||||||
|
DEFINE_INSN
|
||||||
|
opt_or
|
||||||
|
(CALL_INFO ci, CALL_CACHE cc)
|
||||||
|
(VALUE recv, VALUE obj)
|
||||||
|
(VALUE val)
|
||||||
|
{
|
||||||
|
val = vm_opt_or(recv, obj);
|
||||||
|
|
||||||
|
if (val == Qundef) {
|
||||||
|
CALL_SIMPLE_METHOD();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* [] */
|
/* [] */
|
||||||
DEFINE_INSN
|
DEFINE_INSN
|
||||||
opt_aref
|
opt_aref
|
||||||
|
|
|
@ -478,6 +478,14 @@ class TestJIT < Test::Unit::TestCase
|
||||||
assert_compile_once('[1] << 2', result_inspect: '[1, 2]', insns: %i[opt_ltlt])
|
assert_compile_once('[1] << 2', result_inspect: '[1, 2]', insns: %i[opt_ltlt])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_compile_insn_opt_and
|
||||||
|
assert_compile_once('1 & 3', result_inspect: '1', insns: %i[opt_and])
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_compile_insn_opt_or
|
||||||
|
assert_compile_once('1 | 3', result_inspect: '3', insns: %i[opt_or])
|
||||||
|
end
|
||||||
|
|
||||||
def test_compile_insn_opt_aref
|
def test_compile_insn_opt_aref
|
||||||
skip_on_mswin
|
skip_on_mswin
|
||||||
# optimized call (optimized JIT) -> send call
|
# optimized call (optimized JIT) -> send call
|
||||||
|
|
|
@ -187,6 +187,16 @@ class TestRubyOptimization < Test::Unit::TestCase
|
||||||
assert_redefine_method('String', '<<', 'assert_equal "b", "a" << "b"')
|
assert_redefine_method('String', '<<', 'assert_equal "b", "a" << "b"')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fixnum_and
|
||||||
|
assert_equal 1, 1&3
|
||||||
|
assert_redefine_method('Integer', '&', 'assert_equal 3, 1&3')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_fixnum_or
|
||||||
|
assert_equal 3, 1|3
|
||||||
|
assert_redefine_method('Integer', '|', 'assert_equal 1, 3|1')
|
||||||
|
end
|
||||||
|
|
||||||
def test_array_plus
|
def test_array_plus
|
||||||
assert_equal [1,2], [1]+[2]
|
assert_equal [1,2], [1]+[2]
|
||||||
assert_redefine_method('Array', '+', 'assert_equal [2], [1]+[2]')
|
assert_redefine_method('Array', '+', 'assert_equal [2], [1]+[2]')
|
||||||
|
|
|
@ -52,6 +52,8 @@ module MJITHeader
|
||||||
'vm_opt_gt',
|
'vm_opt_gt',
|
||||||
'vm_opt_ge',
|
'vm_opt_ge',
|
||||||
'vm_opt_ltlt',
|
'vm_opt_ltlt',
|
||||||
|
'vm_opt_and',
|
||||||
|
'vm_opt_or',
|
||||||
'vm_opt_aref',
|
'vm_opt_aref',
|
||||||
'vm_opt_aset',
|
'vm_opt_aset',
|
||||||
'vm_opt_aref_with',
|
'vm_opt_aref_with',
|
||||||
|
|
2
vm.c
2
vm.c
|
@ -1610,6 +1610,8 @@ vm_init_redefined_flag(void)
|
||||||
OP(Max, MAX), (C(Array));
|
OP(Max, MAX), (C(Array));
|
||||||
OP(Min, MIN), (C(Array));
|
OP(Min, MIN), (C(Array));
|
||||||
OP(Call, CALL), (C(Proc));
|
OP(Call, CALL), (C(Proc));
|
||||||
|
OP(And, AND), (C(Integer));
|
||||||
|
OP(Or, OR), (C(Integer));
|
||||||
#undef C
|
#undef C
|
||||||
#undef OP
|
#undef OP
|
||||||
}
|
}
|
||||||
|
|
|
@ -531,6 +531,8 @@ enum ruby_basic_operators {
|
||||||
BOP_MAX,
|
BOP_MAX,
|
||||||
BOP_MIN,
|
BOP_MIN,
|
||||||
BOP_CALL,
|
BOP_CALL,
|
||||||
|
BOP_AND,
|
||||||
|
BOP_OR,
|
||||||
|
|
||||||
BOP_LAST_
|
BOP_LAST_
|
||||||
};
|
};
|
||||||
|
|
|
@ -3652,6 +3652,30 @@ vm_opt_ltlt(VALUE recv, VALUE obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
vm_opt_and(VALUE recv, VALUE obj)
|
||||||
|
{
|
||||||
|
if (FIXNUM_2_P(recv, obj) &&
|
||||||
|
BASIC_OP_UNREDEFINED_P(BOP_AND, INTEGER_REDEFINED_OP_FLAG)) {
|
||||||
|
return LONG2NUM(FIX2LONG(recv) & FIX2LONG(obj));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Qundef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
vm_opt_or(VALUE recv, VALUE obj)
|
||||||
|
{
|
||||||
|
if (FIXNUM_2_P(recv, obj) &&
|
||||||
|
BASIC_OP_UNREDEFINED_P(BOP_OR, INTEGER_REDEFINED_OP_FLAG)) {
|
||||||
|
return LONG2NUM(FIX2LONG(recv) | FIX2LONG(obj));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Qundef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
vm_opt_aref(VALUE recv, VALUE obj)
|
vm_opt_aref(VALUE recv, VALUE obj)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue