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

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

Issue 22732006: Reduce some code duplication (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 | « no previous file | 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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 // A change from an integer32 can be replaced by the integer32 value. 1278 // A change from an integer32 can be replaced by the integer32 value.
1279 if (dividend->IsChange() && 1279 if (dividend->IsChange() &&
1280 HChange::cast(dividend)->from().IsInteger32()) { 1280 HChange::cast(dividend)->from().IsInteger32()) {
1281 return HChange::cast(dividend)->value(); 1281 return HChange::cast(dividend)->value();
1282 } 1282 }
1283 return NULL; 1283 return NULL;
1284 } 1284 }
1285 1285
1286 1286
1287 HValue* HUnaryMathOperation::Canonicalize() { 1287 HValue* HUnaryMathOperation::Canonicalize() {
1288 if (op() == kMathRound) { 1288 if (op() == kMathRound || op() == kMathFloor) {
1289 HValue* val = value(); 1289 HValue* val = value();
1290 if (val->IsChange()) val = HChange::cast(val)->value(); 1290 if (val->IsChange()) val = HChange::cast(val)->value();
1291 1291
1292 // If the input is integer32 then we replace the round instruction 1292 // If the input is smi or integer32 then we replace the instruction with its
1293 // with its input. 1293 // input.
1294 if (val->representation().IsSmiOrInteger32()) { 1294 if (val->representation().IsSmiOrInteger32()) {
1295 if (!val->representation().Equals(representation())) { 1295 if (!val->representation().Equals(representation())) {
1296 HChange* result = new(block()->zone()) HChange( 1296 HChange* result = new(block()->zone()) HChange(
1297 val, representation(), false, false, false); 1297 val, representation(), false, false, false);
1298 result->InsertBefore(this); 1298 result->InsertBefore(this);
1299 return result; 1299 return result;
1300 } 1300 }
1301 return val; 1301 return val;
1302 } 1302 }
1303 } 1303 }
1304 1304
1305 if (op() == kMathFloor) { 1305 if (op() == kMathFloor) {
1306 HValue* val = value(); 1306 HValue* val = value();
1307 if (val->IsChange()) val = HChange::cast(val)->value(); 1307 if (val->IsChange()) val = HChange::cast(val)->value();
1308
1309 // If the input is integer32 then we replace the floor instruction
1310 // with its input.
1311 if (val->representation().IsSmiOrInteger32()) {
1312 if (!val->representation().Equals(representation())) {
1313 HChange* result = new(block()->zone()) HChange(
1314 val, representation(), false, false, false);
1315 result->InsertBefore(this);
1316 return result;
1317 }
1318 return val;
1319 }
1320
1321 if (val->IsDiv() && (val->UseCount() == 1)) { 1308 if (val->IsDiv() && (val->UseCount() == 1)) {
1322 HDiv* hdiv = HDiv::cast(val); 1309 HDiv* hdiv = HDiv::cast(val);
1323 HValue* left = hdiv->left(); 1310 HValue* left = hdiv->left();
1324 HValue* right = hdiv->right(); 1311 HValue* right = hdiv->right();
1325 // Try to simplify left and right values of the division. 1312 // Try to simplify left and right values of the division.
1326 HValue* new_left = SimplifiedDividendForMathFloorOfDiv(left); 1313 HValue* new_left = SimplifiedDividendForMathFloorOfDiv(left);
1327 if (new_left == NULL && 1314 if (new_left == NULL &&
1328 hdiv->observed_input_representation(1).IsSmiOrInteger32()) { 1315 hdiv->observed_input_representation(1).IsSmiOrInteger32()) {
1329 new_left = new(block()->zone()) HChange( 1316 new_left = new(block()->zone()) HChange(
1330 left, Representation::Integer32(), false, false, false); 1317 left, Representation::Integer32(), false, false, false);
(...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after
4164 break; 4151 break;
4165 case kExternalMemory: 4152 case kExternalMemory:
4166 stream->Add("[external-memory]"); 4153 stream->Add("[external-memory]");
4167 break; 4154 break;
4168 } 4155 }
4169 4156
4170 stream->Add("@%d", offset()); 4157 stream->Add("@%d", offset());
4171 } 4158 }
4172 4159
4173 } } // namespace v8::internal 4160 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698