| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/double.h" | 7 #include "src/double.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/hydrogen-infer-representation.h" | 9 #include "src/hydrogen-infer-representation.h" |
| 10 #include "src/property-details-inl.h" | 10 #include "src/property-details-inl.h" |
| (...skipping 2936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2947 } | 2947 } |
| 2948 | 2948 |
| 2949 | 2949 |
| 2950 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { | 2950 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { |
| 2951 HConstant* res = NULL; | 2951 HConstant* res = NULL; |
| 2952 Handle<Object> handle = this->handle(zone->isolate()); | 2952 Handle<Object> handle = this->handle(zone->isolate()); |
| 2953 if (handle->IsBoolean()) { | 2953 if (handle->IsBoolean()) { |
| 2954 res = handle->BooleanValue() ? | 2954 res = handle->BooleanValue() ? |
| 2955 new(zone) HConstant(1) : new(zone) HConstant(0); | 2955 new(zone) HConstant(1) : new(zone) HConstant(0); |
| 2956 } else if (handle->IsUndefined()) { | 2956 } else if (handle->IsUndefined()) { |
| 2957 res = new(zone) HConstant(OS::nan_value()); | 2957 res = new(zone) HConstant(base::OS::nan_value()); |
| 2958 } else if (handle->IsNull()) { | 2958 } else if (handle->IsNull()) { |
| 2959 res = new(zone) HConstant(0); | 2959 res = new(zone) HConstant(0); |
| 2960 } | 2960 } |
| 2961 return Maybe<HConstant*>(res != NULL, res); | 2961 return Maybe<HConstant*>(res != NULL, res); |
| 2962 } | 2962 } |
| 2963 | 2963 |
| 2964 | 2964 |
| 2965 void HConstant::PrintDataTo(StringStream* stream) { | 2965 void HConstant::PrintDataTo(StringStream* stream) { |
| 2966 if (has_int32_value_) { | 2966 if (has_int32_value_) { |
| 2967 stream->Add("%d ", int32_value_); | 2967 stream->Add("%d ", int32_value_); |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4215 | 4215 |
| 4216 HInstruction* HUnaryMathOperation::New( | 4216 HInstruction* HUnaryMathOperation::New( |
| 4217 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { | 4217 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { |
| 4218 do { | 4218 do { |
| 4219 if (!FLAG_fold_constants) break; | 4219 if (!FLAG_fold_constants) break; |
| 4220 if (!value->IsConstant()) break; | 4220 if (!value->IsConstant()) break; |
| 4221 HConstant* constant = HConstant::cast(value); | 4221 HConstant* constant = HConstant::cast(value); |
| 4222 if (!constant->HasNumberValue()) break; | 4222 if (!constant->HasNumberValue()) break; |
| 4223 double d = constant->DoubleValue(); | 4223 double d = constant->DoubleValue(); |
| 4224 if (std::isnan(d)) { // NaN poisons everything. | 4224 if (std::isnan(d)) { // NaN poisons everything. |
| 4225 return H_CONSTANT_DOUBLE(OS::nan_value()); | 4225 return H_CONSTANT_DOUBLE(base::OS::nan_value()); |
| 4226 } | 4226 } |
| 4227 if (std::isinf(d)) { // +Infinity and -Infinity. | 4227 if (std::isinf(d)) { // +Infinity and -Infinity. |
| 4228 switch (op) { | 4228 switch (op) { |
| 4229 case kMathExp: | 4229 case kMathExp: |
| 4230 return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0); | 4230 return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0); |
| 4231 case kMathLog: | 4231 case kMathLog: |
| 4232 case kMathSqrt: | 4232 case kMathSqrt: |
| 4233 return H_CONSTANT_DOUBLE((d > 0.0) ? d : OS::nan_value()); | 4233 return H_CONSTANT_DOUBLE((d > 0.0) ? d : base::OS::nan_value()); |
| 4234 case kMathPowHalf: | 4234 case kMathPowHalf: |
| 4235 case kMathAbs: | 4235 case kMathAbs: |
| 4236 return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d); | 4236 return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d); |
| 4237 case kMathRound: | 4237 case kMathRound: |
| 4238 case kMathFloor: | 4238 case kMathFloor: |
| 4239 return H_CONSTANT_DOUBLE(d); | 4239 return H_CONSTANT_DOUBLE(d); |
| 4240 case kMathClz32: | 4240 case kMathClz32: |
| 4241 return H_CONSTANT_INT(32); | 4241 return H_CONSTANT_INT(32); |
| 4242 default: | 4242 default: |
| 4243 UNREACHABLE(); | 4243 UNREACHABLE(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4318 HInstruction* HPower::New(Zone* zone, | 4318 HInstruction* HPower::New(Zone* zone, |
| 4319 HValue* context, | 4319 HValue* context, |
| 4320 HValue* left, | 4320 HValue* left, |
| 4321 HValue* right) { | 4321 HValue* right) { |
| 4322 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4322 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 4323 HConstant* c_left = HConstant::cast(left); | 4323 HConstant* c_left = HConstant::cast(left); |
| 4324 HConstant* c_right = HConstant::cast(right); | 4324 HConstant* c_right = HConstant::cast(right); |
| 4325 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { | 4325 if (c_left->HasNumberValue() && c_right->HasNumberValue()) { |
| 4326 double result = power_helper(c_left->DoubleValue(), | 4326 double result = power_helper(c_left->DoubleValue(), |
| 4327 c_right->DoubleValue()); | 4327 c_right->DoubleValue()); |
| 4328 return H_CONSTANT_DOUBLE(std::isnan(result) ? OS::nan_value() : result); | 4328 return H_CONSTANT_DOUBLE(std::isnan(result) ? base::OS::nan_value() |
| 4329 : result); |
| 4329 } | 4330 } |
| 4330 } | 4331 } |
| 4331 return new(zone) HPower(left, right); | 4332 return new(zone) HPower(left, right); |
| 4332 } | 4333 } |
| 4333 | 4334 |
| 4334 | 4335 |
| 4335 HInstruction* HMathMinMax::New( | 4336 HInstruction* HMathMinMax::New( |
| 4336 Zone* zone, HValue* context, HValue* left, HValue* right, Operation op) { | 4337 Zone* zone, HValue* context, HValue* left, HValue* right, Operation op) { |
| 4337 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 4338 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| 4338 HConstant* c_left = HConstant::cast(left); | 4339 HConstant* c_left = HConstant::cast(left); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4351 } else { | 4352 } else { |
| 4352 if (d_left < d_right) return H_CONSTANT_DOUBLE(d_right); | 4353 if (d_left < d_right) return H_CONSTANT_DOUBLE(d_right); |
| 4353 if (d_left > d_right) return H_CONSTANT_DOUBLE(d_left); | 4354 if (d_left > d_right) return H_CONSTANT_DOUBLE(d_left); |
| 4354 if (d_left == d_right) { | 4355 if (d_left == d_right) { |
| 4355 // Handle +0 and -0. | 4356 // Handle +0 and -0. |
| 4356 return H_CONSTANT_DOUBLE((Double(d_left).Sign() == -1) ? d_right | 4357 return H_CONSTANT_DOUBLE((Double(d_left).Sign() == -1) ? d_right |
| 4357 : d_left); | 4358 : d_left); |
| 4358 } | 4359 } |
| 4359 } | 4360 } |
| 4360 // All comparisons failed, must be NaN. | 4361 // All comparisons failed, must be NaN. |
| 4361 return H_CONSTANT_DOUBLE(OS::nan_value()); | 4362 return H_CONSTANT_DOUBLE(base::OS::nan_value()); |
| 4362 } | 4363 } |
| 4363 } | 4364 } |
| 4364 return new(zone) HMathMinMax(context, left, right, op); | 4365 return new(zone) HMathMinMax(context, left, right, op); |
| 4365 } | 4366 } |
| 4366 | 4367 |
| 4367 | 4368 |
| 4368 HInstruction* HMod::New(Zone* zone, | 4369 HInstruction* HMod::New(Zone* zone, |
| 4369 HValue* context, | 4370 HValue* context, |
| 4370 HValue* left, | 4371 HValue* left, |
| 4371 HValue* right) { | 4372 HValue* right) { |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4870 break; | 4871 break; |
| 4871 case kExternalMemory: | 4872 case kExternalMemory: |
| 4872 stream->Add("[external-memory]"); | 4873 stream->Add("[external-memory]"); |
| 4873 break; | 4874 break; |
| 4874 } | 4875 } |
| 4875 | 4876 |
| 4876 stream->Add("@%d", offset()); | 4877 stream->Add("@%d", offset()); |
| 4877 } | 4878 } |
| 4878 | 4879 |
| 4879 } } // namespace v8::internal | 4880 } } // namespace v8::internal |
| OLD | NEW |