mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_insnhelper.h: RBASIC_CLASS
* vm_insnhelper.c (opt_eq_func): use RBASIC_CLASS() instead of HEAP_CLASS_OF(). * insns.def (opt_plus, opt_minus, opt_mult, opt_div, opt_mod, opt_lt), (opt_gt, opt_ltlt, opt_aref, opt_aset, opt_length, opt_size), (opt_empty_p, opt_succ): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
92d7cdc29a
commit
b3392daaad
4 changed files with 38 additions and 31 deletions
|
@ -1,3 +1,11 @@
|
|||
Tue Aug 27 16:11:05 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm_insnhelper.c (opt_eq_func): use RBASIC_CLASS() instead of HEAP_CLASS_OF().
|
||||
|
||||
* insns.def (opt_plus, opt_minus, opt_mult, opt_div, opt_mod, opt_lt),
|
||||
(opt_gt, opt_ltlt, opt_aref, opt_aset, opt_length, opt_size),
|
||||
(opt_empty_p, opt_succ): ditto.
|
||||
|
||||
Tue Aug 27 16:08:26 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* vm_eval.c (rb_check_funcall, rb_check_funcall_with_hook): constify
|
||||
|
|
52
insns.def
52
insns.def
|
@ -1335,15 +1335,15 @@ opt_plus
|
|||
val = DBL2NUM(RFLOAT_VALUE(recv) + RFLOAT_VALUE(obj));
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat && HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat && RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_PLUS, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = DBL2NUM(RFLOAT_VALUE(recv) + RFLOAT_VALUE(obj));
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cString && HEAP_CLASS_OF(obj) == rb_cString &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cString && RBASIC_CLASS(obj) == rb_cString &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_PLUS, STRING_REDEFINED_OP_FLAG)) {
|
||||
val = rb_str_plus(recv, obj);
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cArray &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_PLUS, ARRAY_REDEFINED_OP_FLAG)) {
|
||||
val = rb_ary_plus(recv, obj);
|
||||
}
|
||||
|
@ -1390,7 +1390,7 @@ opt_minus
|
|||
val = DBL2NUM(RFLOAT_VALUE(recv) - RFLOAT_VALUE(obj));
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat && HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat && RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_MINUS, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = DBL2NUM(RFLOAT_VALUE(recv) - RFLOAT_VALUE(obj));
|
||||
}
|
||||
|
@ -1441,7 +1441,7 @@ opt_mult
|
|||
val = DBL2NUM(RFLOAT_VALUE(recv) * RFLOAT_VALUE(obj));
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat && HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat && RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_MULT, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = DBL2NUM(RFLOAT_VALUE(recv) * RFLOAT_VALUE(obj));
|
||||
}
|
||||
|
@ -1504,7 +1504,7 @@ opt_div
|
|||
val = DBL2NUM(RFLOAT_VALUE(recv) / RFLOAT_VALUE(obj));
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat && HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat && RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_DIV, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = DBL2NUM(RFLOAT_VALUE(recv) / RFLOAT_VALUE(obj));
|
||||
}
|
||||
|
@ -1570,7 +1570,7 @@ opt_mod
|
|||
val = DBL2NUM(ruby_float_mod(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj)));
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat && HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat && RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_MOD, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = DBL2NUM(ruby_float_mod(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj)));
|
||||
}
|
||||
|
@ -1666,7 +1666,7 @@ opt_lt
|
|||
val = RFLOAT_VALUE(recv) < RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat && HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat && RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = double_cmp_lt(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
|
||||
}
|
||||
|
@ -1745,7 +1745,7 @@ opt_gt
|
|||
val = RFLOAT_VALUE(recv) > RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat && HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat && RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_GT, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = double_cmp_gt(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
|
||||
}
|
||||
|
@ -1807,11 +1807,11 @@ opt_ltlt
|
|||
(VALUE val)
|
||||
{
|
||||
if (!SPECIAL_CONST_P(recv)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
||||
if (RBASIC_CLASS(recv) == rb_cString &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LTLT, STRING_REDEFINED_OP_FLAG)) {
|
||||
val = rb_str_concat(recv, obj);
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cArray &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LTLT, ARRAY_REDEFINED_OP_FLAG)) {
|
||||
val = rb_ary_push(recv, obj);
|
||||
}
|
||||
|
@ -1839,10 +1839,10 @@ opt_aref
|
|||
(VALUE val)
|
||||
{
|
||||
if (!SPECIAL_CONST_P(recv)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cArray && BASIC_OP_UNREDEFINED_P(BOP_AREF, ARRAY_REDEFINED_OP_FLAG) && FIXNUM_P(obj)) {
|
||||
if (RBASIC_CLASS(recv) == rb_cArray && BASIC_OP_UNREDEFINED_P(BOP_AREF, ARRAY_REDEFINED_OP_FLAG) && FIXNUM_P(obj)) {
|
||||
val = rb_ary_entry(recv, FIX2LONG(obj));
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cHash && BASIC_OP_UNREDEFINED_P(BOP_AREF, HASH_REDEFINED_OP_FLAG)) {
|
||||
else if (RBASIC_CLASS(recv) == rb_cHash && BASIC_OP_UNREDEFINED_P(BOP_AREF, HASH_REDEFINED_OP_FLAG)) {
|
||||
val = rb_hash_aref(recv, obj);
|
||||
}
|
||||
else {
|
||||
|
@ -1869,11 +1869,11 @@ opt_aset
|
|||
(VALUE val)
|
||||
{
|
||||
if (!SPECIAL_CONST_P(recv)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cArray && BASIC_OP_UNREDEFINED_P(BOP_ASET, ARRAY_REDEFINED_OP_FLAG) && FIXNUM_P(obj)) {
|
||||
if (RBASIC_CLASS(recv) == rb_cArray && BASIC_OP_UNREDEFINED_P(BOP_ASET, ARRAY_REDEFINED_OP_FLAG) && FIXNUM_P(obj)) {
|
||||
rb_ary_store(recv, FIX2LONG(obj), set);
|
||||
val = set;
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cHash && BASIC_OP_UNREDEFINED_P(BOP_ASET, HASH_REDEFINED_OP_FLAG)) {
|
||||
else if (RBASIC_CLASS(recv) == rb_cHash && BASIC_OP_UNREDEFINED_P(BOP_ASET, HASH_REDEFINED_OP_FLAG)) {
|
||||
rb_hash_aset(recv, obj, set);
|
||||
val = set;
|
||||
}
|
||||
|
@ -1902,15 +1902,15 @@ opt_length
|
|||
(VALUE val)
|
||||
{
|
||||
if (!SPECIAL_CONST_P(recv)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
||||
if (RBASIC_CLASS(recv) == rb_cString &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LENGTH, STRING_REDEFINED_OP_FLAG)) {
|
||||
val = rb_str_length(recv);
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cArray &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LENGTH, ARRAY_REDEFINED_OP_FLAG)) {
|
||||
val = LONG2NUM(RARRAY_LEN(recv));
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cHash &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cHash &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LENGTH, HASH_REDEFINED_OP_FLAG)) {
|
||||
val = INT2FIX(RHASH_SIZE(recv));
|
||||
}
|
||||
|
@ -1937,15 +1937,15 @@ opt_size
|
|||
(VALUE val)
|
||||
{
|
||||
if (!SPECIAL_CONST_P(recv)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
||||
if (RBASIC_CLASS(recv) == rb_cString &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_SIZE, STRING_REDEFINED_OP_FLAG)) {
|
||||
val = rb_str_length(recv);
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cArray &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_SIZE, ARRAY_REDEFINED_OP_FLAG)) {
|
||||
val = LONG2NUM(RARRAY_LEN(recv));
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cHash &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cHash &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_SIZE, HASH_REDEFINED_OP_FLAG)) {
|
||||
val = INT2FIX(RHASH_SIZE(recv));
|
||||
}
|
||||
|
@ -1972,17 +1972,17 @@ opt_empty_p
|
|||
(VALUE val)
|
||||
{
|
||||
if (!SPECIAL_CONST_P(recv)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
||||
if (RBASIC_CLASS(recv) == rb_cString &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_EMPTY_P, STRING_REDEFINED_OP_FLAG)) {
|
||||
if (RSTRING_LEN(recv) == 0) val = Qtrue;
|
||||
else val = Qfalse;
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cArray &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cArray &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_EMPTY_P, ARRAY_REDEFINED_OP_FLAG)) {
|
||||
if (RARRAY_LEN(recv) == 0) val = Qtrue;
|
||||
else val = Qfalse;
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cHash &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cHash &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_EMPTY_P, HASH_REDEFINED_OP_FLAG)) {
|
||||
if (RHASH_EMPTY_P(recv)) val = Qtrue;
|
||||
else val = Qfalse;
|
||||
|
@ -2025,11 +2025,11 @@ opt_succ
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cString &&
|
||||
if (RBASIC_CLASS(recv) == rb_cString &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_SUCC, STRING_REDEFINED_OP_FLAG)) {
|
||||
val = rb_str_succ(recv);
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cTime &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cTime &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_SUCC, TIME_REDEFINED_OP_FLAG)) {
|
||||
val = rb_time_succ(recv);
|
||||
}
|
||||
|
|
|
@ -892,8 +892,8 @@ opt_eq_func(VALUE recv, VALUE obj, CALL_INFO ci)
|
|||
return (recv == obj) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
if (HEAP_CLASS_OF(recv) == rb_cFloat &&
|
||||
HEAP_CLASS_OF(obj) == rb_cFloat &&
|
||||
if (RBASIC_CLASS(recv) == rb_cFloat &&
|
||||
RBASIC_CLASS(obj) == rb_cFloat &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_EQ, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
double a = RFLOAT_VALUE(recv);
|
||||
double b = RFLOAT_VALUE(obj);
|
||||
|
@ -903,8 +903,8 @@ opt_eq_func(VALUE recv, VALUE obj, CALL_INFO ci)
|
|||
}
|
||||
return (a == b) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (HEAP_CLASS_OF(recv) == rb_cString &&
|
||||
HEAP_CLASS_OF(obj) == rb_cString &&
|
||||
else if (RBASIC_CLASS(recv) == rb_cString &&
|
||||
RBASIC_CLASS(obj) == rb_cString &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_EQ, STRING_REDEFINED_OP_FLAG)) {
|
||||
return rb_str_equal(recv, obj);
|
||||
}
|
||||
|
|
|
@ -246,7 +246,6 @@ enum vm_regan_acttype {
|
|||
#else
|
||||
#define FLONUM_2_P(a, b) 0
|
||||
#endif
|
||||
#define HEAP_CLASS_OF(obj) (RBASIC(obj)->klass)
|
||||
|
||||
#ifndef USE_IC_FOR_SPECIALIZED_METHOD
|
||||
#define USE_IC_FOR_SPECIALIZED_METHOD 1
|
||||
|
|
Loading…
Reference in a new issue