OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 case kMathExp: return "exp"; | 1301 case kMathExp: return "exp"; |
1302 case kMathSqrt: return "sqrt"; | 1302 case kMathSqrt: return "sqrt"; |
1303 case kMathPowHalf: return "pow-half"; | 1303 case kMathPowHalf: return "pow-half"; |
1304 default: | 1304 default: |
1305 UNREACHABLE(); | 1305 UNREACHABLE(); |
1306 return NULL; | 1306 return NULL; |
1307 } | 1307 } |
1308 } | 1308 } |
1309 | 1309 |
1310 | 1310 |
| 1311 Range* HUnaryMathOperation::InferRange(Zone* zone) { |
| 1312 Representation r = representation(); |
| 1313 if (r.IsSmiOrInteger32() && value()->HasRange()) { |
| 1314 if (op() == kMathAbs) { |
| 1315 int upper = value()->range()->upper(); |
| 1316 int lower = value()->range()->lower(); |
| 1317 bool spans_zero = value()->range()->CanBeZero(); |
| 1318 // Math.abs(kMinInt) overflows its representation, on which the |
| 1319 // instruction deopts. Hence clamp it to kMaxInt. |
| 1320 int abs_upper = upper == kMinInt ? kMaxInt : abs(upper); |
| 1321 int abs_lower = lower == kMinInt ? kMaxInt : abs(lower); |
| 1322 Range* result = |
| 1323 new(zone) Range(spans_zero ? 0 : Min(abs_lower, abs_upper), |
| 1324 Max(abs_lower, abs_upper)); |
| 1325 // In case of Smi representation, clamp Math.abs(Smi::kMinValue) to |
| 1326 // Smi::kMaxValue. |
| 1327 if (r.IsSmi()) result->ClampToSmi(); |
| 1328 return result; |
| 1329 } |
| 1330 } |
| 1331 return HValue::InferRange(zone); |
| 1332 } |
| 1333 |
| 1334 |
1311 void HUnaryMathOperation::PrintDataTo(StringStream* stream) { | 1335 void HUnaryMathOperation::PrintDataTo(StringStream* stream) { |
1312 const char* name = OpName(); | 1336 const char* name = OpName(); |
1313 stream->Add("%s ", name); | 1337 stream->Add("%s ", name); |
1314 value()->PrintNameTo(stream); | 1338 value()->PrintNameTo(stream); |
1315 } | 1339 } |
1316 | 1340 |
1317 | 1341 |
1318 void HUnaryOperation::PrintDataTo(StringStream* stream) { | 1342 void HUnaryOperation::PrintDataTo(StringStream* stream) { |
1319 value()->PrintNameTo(stream); | 1343 value()->PrintNameTo(stream); |
1320 } | 1344 } |
(...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3804 case kBackingStore: | 3828 case kBackingStore: |
3805 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3829 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
3806 stream->Add("[backing-store]"); | 3830 stream->Add("[backing-store]"); |
3807 break; | 3831 break; |
3808 } | 3832 } |
3809 | 3833 |
3810 stream->Add("@%d", offset()); | 3834 stream->Add("@%d", offset()); |
3811 } | 3835 } |
3812 | 3836 |
3813 } } // namespace v8::internal | 3837 } } // namespace v8::internal |
OLD | NEW |