| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/crankshaft/hydrogen-instructions.h" | 5 #include "src/crankshaft/hydrogen-instructions.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/ieee754.h" | 8 #include "src/base/ieee754.h" |
| 9 #include "src/base/safe_math.h" | 9 #include "src/base/safe_math.h" |
| 10 #include "src/crankshaft/hydrogen-infer-representation.h" | 10 #include "src/crankshaft/hydrogen-infer-representation.h" |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 const char* HUnaryMathOperation::OpName() const { | 1108 const char* HUnaryMathOperation::OpName() const { |
| 1109 switch (op()) { | 1109 switch (op()) { |
| 1110 case kMathFloor: | 1110 case kMathFloor: |
| 1111 return "floor"; | 1111 return "floor"; |
| 1112 case kMathFround: | 1112 case kMathFround: |
| 1113 return "fround"; | 1113 return "fround"; |
| 1114 case kMathRound: | 1114 case kMathRound: |
| 1115 return "round"; | 1115 return "round"; |
| 1116 case kMathAbs: | 1116 case kMathAbs: |
| 1117 return "abs"; | 1117 return "abs"; |
| 1118 case kMathCos: |
| 1119 return "cos"; |
| 1118 case kMathLog: | 1120 case kMathLog: |
| 1119 return "log"; | 1121 return "log"; |
| 1120 case kMathExp: | 1122 case kMathExp: |
| 1121 return "exp"; | 1123 return "exp"; |
| 1124 case kMathSin: |
| 1125 return "sin"; |
| 1122 case kMathSqrt: | 1126 case kMathSqrt: |
| 1123 return "sqrt"; | 1127 return "sqrt"; |
| 1124 case kMathPowHalf: | 1128 case kMathPowHalf: |
| 1125 return "pow-half"; | 1129 return "pow-half"; |
| 1126 case kMathClz32: | 1130 case kMathClz32: |
| 1127 return "clz32"; | 1131 return "clz32"; |
| 1128 default: | 1132 default: |
| 1129 UNREACHABLE(); | 1133 UNREACHABLE(); |
| 1130 return NULL; | 1134 return NULL; |
| 1131 } | 1135 } |
| (...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3394 if (!FLAG_fold_constants) break; | 3398 if (!FLAG_fold_constants) break; |
| 3395 if (!value->IsConstant()) break; | 3399 if (!value->IsConstant()) break; |
| 3396 HConstant* constant = HConstant::cast(value); | 3400 HConstant* constant = HConstant::cast(value); |
| 3397 if (!constant->HasNumberValue()) break; | 3401 if (!constant->HasNumberValue()) break; |
| 3398 double d = constant->DoubleValue(); | 3402 double d = constant->DoubleValue(); |
| 3399 if (std::isnan(d)) { // NaN poisons everything. | 3403 if (std::isnan(d)) { // NaN poisons everything. |
| 3400 return H_CONSTANT_DOUBLE(std::numeric_limits<double>::quiet_NaN()); | 3404 return H_CONSTANT_DOUBLE(std::numeric_limits<double>::quiet_NaN()); |
| 3401 } | 3405 } |
| 3402 if (std::isinf(d)) { // +Infinity and -Infinity. | 3406 if (std::isinf(d)) { // +Infinity and -Infinity. |
| 3403 switch (op) { | 3407 switch (op) { |
| 3408 case kMathCos: |
| 3409 case kMathSin: |
| 3410 return H_CONSTANT_DOUBLE(std::numeric_limits<double>::quiet_NaN()); |
| 3404 case kMathExp: | 3411 case kMathExp: |
| 3405 return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0); | 3412 return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0); |
| 3406 case kMathLog: | 3413 case kMathLog: |
| 3407 case kMathSqrt: | 3414 case kMathSqrt: |
| 3408 return H_CONSTANT_DOUBLE( | 3415 return H_CONSTANT_DOUBLE( |
| 3409 (d > 0.0) ? d : std::numeric_limits<double>::quiet_NaN()); | 3416 (d > 0.0) ? d : std::numeric_limits<double>::quiet_NaN()); |
| 3410 case kMathPowHalf: | 3417 case kMathPowHalf: |
| 3411 case kMathAbs: | 3418 case kMathAbs: |
| 3412 return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d); | 3419 return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d); |
| 3413 case kMathRound: | 3420 case kMathRound: |
| 3414 case kMathFround: | 3421 case kMathFround: |
| 3415 case kMathFloor: | 3422 case kMathFloor: |
| 3416 return H_CONSTANT_DOUBLE(d); | 3423 return H_CONSTANT_DOUBLE(d); |
| 3417 case kMathClz32: | 3424 case kMathClz32: |
| 3418 return H_CONSTANT_INT(32); | 3425 return H_CONSTANT_INT(32); |
| 3419 default: | 3426 default: |
| 3420 UNREACHABLE(); | 3427 UNREACHABLE(); |
| 3421 break; | 3428 break; |
| 3422 } | 3429 } |
| 3423 } | 3430 } |
| 3424 switch (op) { | 3431 switch (op) { |
| 3432 case kMathCos: |
| 3433 return H_CONSTANT_DOUBLE(base::ieee754::cos(d)); |
| 3425 case kMathExp: | 3434 case kMathExp: |
| 3426 return H_CONSTANT_DOUBLE(base::ieee754::exp(d)); | 3435 return H_CONSTANT_DOUBLE(base::ieee754::exp(d)); |
| 3427 case kMathLog: | 3436 case kMathLog: |
| 3428 return H_CONSTANT_DOUBLE(base::ieee754::log(d)); | 3437 return H_CONSTANT_DOUBLE(base::ieee754::log(d)); |
| 3438 case kMathSin: |
| 3439 return H_CONSTANT_DOUBLE(base::ieee754::sin(d)); |
| 3429 case kMathSqrt: | 3440 case kMathSqrt: |
| 3430 lazily_initialize_fast_sqrt(isolate); | 3441 lazily_initialize_fast_sqrt(isolate); |
| 3431 return H_CONSTANT_DOUBLE(fast_sqrt(d, isolate)); | 3442 return H_CONSTANT_DOUBLE(fast_sqrt(d, isolate)); |
| 3432 case kMathPowHalf: | 3443 case kMathPowHalf: |
| 3433 return H_CONSTANT_DOUBLE(power_double_double(d, 0.5)); | 3444 return H_CONSTANT_DOUBLE(power_double_double(d, 0.5)); |
| 3434 case kMathAbs: | 3445 case kMathAbs: |
| 3435 return H_CONSTANT_DOUBLE((d >= 0.0) ? d + 0.0 : -d); | 3446 return H_CONSTANT_DOUBLE((d >= 0.0) ? d + 0.0 : -d); |
| 3436 case kMathRound: | 3447 case kMathRound: |
| 3437 // -0.5 .. -0.0 round to -0.0. | 3448 // -0.5 .. -0.0 round to -0.0. |
| 3438 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0); | 3449 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0); |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4031 case HObjectAccess::kExternalMemory: | 4042 case HObjectAccess::kExternalMemory: |
| 4032 os << "[external-memory]"; | 4043 os << "[external-memory]"; |
| 4033 break; | 4044 break; |
| 4034 } | 4045 } |
| 4035 | 4046 |
| 4036 return os << "@" << access.offset(); | 4047 return os << "@" << access.offset(); |
| 4037 } | 4048 } |
| 4038 | 4049 |
| 4039 } // namespace internal | 4050 } // namespace internal |
| 4040 } // namespace v8 | 4051 } // namespace v8 |
| OLD | NEW |