Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 16268009: Infer the range of Math.abs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Svens comment Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = lower < 0 && 0 < upper;
1318 upper = abs(upper);
1319 lower = abs(lower);
1320 if (upper < lower) {
1321 int temp = upper;
1322 upper = lower;
1323 lower = temp;
1324 }
1325 if (spans_zero) lower = 0;
1326 Range* result = new(zone) Range(lower, upper);
Sven Panne 2013/06/07 08:11:48 Shorter and more readable: new(zone) Range(spans_
Toon Verwaest 2013/06/07 08:18:02 Done.
1327 if (r.IsSmi()) result->ClampToSmi();
1328 if (r.IsInteger32()) result->ClampToInt32();
1329 return result;
1330 }
1331 }
1332 return HValue::InferRange(zone);
1333 }
1334
1335
1311 void HUnaryMathOperation::PrintDataTo(StringStream* stream) { 1336 void HUnaryMathOperation::PrintDataTo(StringStream* stream) {
1312 const char* name = OpName(); 1337 const char* name = OpName();
1313 stream->Add("%s ", name); 1338 stream->Add("%s ", name);
1314 value()->PrintNameTo(stream); 1339 value()->PrintNameTo(stream);
1315 } 1340 }
1316 1341
1317 1342
1318 void HUnaryOperation::PrintDataTo(StringStream* stream) { 1343 void HUnaryOperation::PrintDataTo(StringStream* stream) {
1319 value()->PrintNameTo(stream); 1344 value()->PrintNameTo(stream);
1320 } 1345 }
(...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after
3804 case kBackingStore: 3829 case kBackingStore:
3805 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3830 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3806 stream->Add("[backing-store]"); 3831 stream->Add("[backing-store]");
3807 break; 3832 break;
3808 } 3833 }
3809 3834
3810 stream->Add("@%d", offset()); 3835 stream->Add("@%d", offset());
3811 } 3836 }
3812 3837
3813 } } // namespace v8::internal 3838 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698