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/safe_math.h" | 8 #include "src/base/safe_math.h" |
9 #include "src/crankshaft/hydrogen-infer-representation.h" | 9 #include "src/crankshaft/hydrogen-infer-representation.h" |
10 #include "src/double.h" | 10 #include "src/double.h" |
(...skipping 4066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4077 break; | 4077 break; |
4078 } | 4078 } |
4079 } | 4079 } |
4080 switch (op) { | 4080 switch (op) { |
4081 case kMathExp: | 4081 case kMathExp: |
4082 lazily_initialize_fast_exp(isolate); | 4082 lazily_initialize_fast_exp(isolate); |
4083 return H_CONSTANT_DOUBLE(fast_exp(d, isolate)); | 4083 return H_CONSTANT_DOUBLE(fast_exp(d, isolate)); |
4084 case kMathLog: | 4084 case kMathLog: |
4085 return H_CONSTANT_DOUBLE(std::log(d)); | 4085 return H_CONSTANT_DOUBLE(std::log(d)); |
4086 case kMathSqrt: | 4086 case kMathSqrt: |
4087 return H_CONSTANT_DOUBLE(fast_sqrt(d)); | 4087 lazily_initialize_fast_sqrt(isolate); |
| 4088 return H_CONSTANT_DOUBLE(fast_sqrt(d, isolate)); |
4088 case kMathPowHalf: | 4089 case kMathPowHalf: |
4089 return H_CONSTANT_DOUBLE(power_double_double(d, 0.5)); | 4090 return H_CONSTANT_DOUBLE(power_double_double(d, 0.5)); |
4090 case kMathAbs: | 4091 case kMathAbs: |
4091 return H_CONSTANT_DOUBLE((d >= 0.0) ? d + 0.0 : -d); | 4092 return H_CONSTANT_DOUBLE((d >= 0.0) ? d + 0.0 : -d); |
4092 case kMathRound: | 4093 case kMathRound: |
4093 // -0.5 .. -0.0 round to -0.0. | 4094 // -0.5 .. -0.0 round to -0.0. |
4094 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0); | 4095 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0); |
4095 // Doubles are represented as Significant * 2 ^ Exponent. If the | 4096 // Doubles are represented as Significant * 2 ^ Exponent. If the |
4096 // Exponent is not negative, the double value is already an integer. | 4097 // Exponent is not negative, the double value is already an integer. |
4097 if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d); | 4098 if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4149 return use_double ? Representation::Double() : Representation::Integer32(); | 4150 return use_double ? Representation::Double() : Representation::Integer32(); |
4150 } | 4151 } |
4151 | 4152 |
4152 | 4153 |
4153 HInstruction* HPower::New(Isolate* isolate, Zone* zone, HValue* context, | 4154 HInstruction* HPower::New(Isolate* isolate, Zone* zone, HValue* context, |
4154 HValue* left, HValue* right) { | 4155 HValue* left, HValue* right) { |
4155 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4156 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
4156 HConstant* c_left = HConstant::cast(left); | 4157 HConstant* c_left = HConstant::cast(left); |
4157 HConstant* c_right = HConstant::cast(right); | 4158 HConstant* c_right = HConstant::cast(right); |
4158 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { | 4159 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { |
4159 double result = power_helper(c_left->DoubleValue(), | 4160 double result = |
4160 c_right->DoubleValue()); | 4161 power_helper(isolate, c_left->DoubleValue(), c_right->DoubleValue()); |
4161 return H_CONSTANT_DOUBLE(std::isnan(result) | 4162 return H_CONSTANT_DOUBLE(std::isnan(result) |
4162 ? std::numeric_limits<double>::quiet_NaN() | 4163 ? std::numeric_limits<double>::quiet_NaN() |
4163 : result); | 4164 : result); |
4164 } | 4165 } |
4165 } | 4166 } |
4166 return new(zone) HPower(left, right); | 4167 return new(zone) HPower(left, right); |
4167 } | 4168 } |
4168 | 4169 |
4169 | 4170 |
4170 HInstruction* HMathMinMax::New(Isolate* isolate, Zone* zone, HValue* context, | 4171 HInstruction* HMathMinMax::New(Isolate* isolate, Zone* zone, HValue* context, |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4694 case HObjectAccess::kExternalMemory: | 4695 case HObjectAccess::kExternalMemory: |
4695 os << "[external-memory]"; | 4696 os << "[external-memory]"; |
4696 break; | 4697 break; |
4697 } | 4698 } |
4698 | 4699 |
4699 return os << "@" << access.offset(); | 4700 return os << "@" << access.offset(); |
4700 } | 4701 } |
4701 | 4702 |
4702 } // namespace internal | 4703 } // namespace internal |
4703 } // namespace v8 | 4704 } // namespace v8 |
OLD | NEW |