зеркало из https://github.com/github/ruby.git
insns.def: float comparison
* insns.def (opt_lt, opt_le, opt_gt, opt_ge): optimize flonum and on-heap float comparison. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c2c0157040
Коммит
5dc87d5ba3
32
insns.def
32
insns.def
|
@ -1645,17 +1645,11 @@ opt_lt
|
|||
/* flonum is not NaN */
|
||||
val = RFLOAT_VALUE(recv) < RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
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));
|
||||
}
|
||||
else {
|
||||
goto INSN_LABEL(normal_dispatch);
|
||||
}
|
||||
else if (FLOAT_INSTANCE_P(recv) && FLOAT_INSTANCE_P(obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = double_cmp_lt(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
|
||||
}
|
||||
else {
|
||||
INSN_LABEL(normal_dispatch):
|
||||
PUSH(recv);
|
||||
PUSH(obj);
|
||||
CALL_SIMPLE_METHOD(recv);
|
||||
|
@ -1689,6 +1683,10 @@ opt_le
|
|||
/* flonum is not NaN */
|
||||
val = RFLOAT_VALUE(recv) <= RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (FLOAT_INSTANCE_P(recv) && FLOAT_INSTANCE_P(obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = double_cmp_le(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
|
||||
}
|
||||
else {
|
||||
/* other */
|
||||
PUSH(recv);
|
||||
|
@ -1724,17 +1722,11 @@ opt_gt
|
|||
/* flonum is not NaN */
|
||||
val = RFLOAT_VALUE(recv) > RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)) {
|
||||
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));
|
||||
}
|
||||
else {
|
||||
goto INSN_LABEL(normal_dispatch);
|
||||
}
|
||||
else if (FLOAT_INSTANCE_P(recv) && FLOAT_INSTANCE_P(obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = double_cmp_gt(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
|
||||
}
|
||||
else {
|
||||
INSN_LABEL(normal_dispatch):
|
||||
PUSH(recv);
|
||||
PUSH(obj);
|
||||
CALL_SIMPLE_METHOD(recv);
|
||||
|
@ -1768,6 +1760,10 @@ opt_ge
|
|||
/* flonum is not NaN */
|
||||
val = RFLOAT_VALUE(recv) >= RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
|
||||
}
|
||||
else if (FLOAT_INSTANCE_P(recv) && FLOAT_INSTANCE_P(obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
val = double_cmp_ge(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
|
||||
}
|
||||
else {
|
||||
PUSH(recv);
|
||||
PUSH(obj);
|
||||
|
|
|
@ -166,6 +166,8 @@ enum vm_regan_acttype {
|
|||
#else
|
||||
#define FLONUM_2_P(a, b) 0
|
||||
#endif
|
||||
#define FLOAT_HEAP_P(x) (!SPECIAL_CONST_P(x) && RBASIC_CLASS(x) == rb_cFloat)
|
||||
#define FLOAT_INSTANCE_P(x) (FLONUM_P(x) || FLOAT_HEAP_P(x))
|
||||
|
||||
#ifndef USE_IC_FOR_SPECIALIZED_METHOD
|
||||
#define USE_IC_FOR_SPECIALIZED_METHOD 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче