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

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

Issue 68493005: Constant-folding through HForceRepresentation fix. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes fixed. Created 7 years, 1 month 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 !(block()->IsReachable() || 514 !(block()->IsReachable() ||
515 IsBlockEntry() || 515 IsBlockEntry() ||
516 IsControlInstruction() || 516 IsControlInstruction() ||
517 IsSimulate() || 517 IsSimulate() ||
518 IsEnterInlined() || 518 IsEnterInlined() ||
519 IsLeaveInlined()); 519 IsLeaveInlined());
520 } 520 }
521 521
522 522
523 bool HValue::IsInteger32Constant() { 523 bool HValue::IsInteger32Constant() {
524 HValue* value_to_check = IsForceRepresentation() 524 return IsConstant() && HConstant::cast(this)->HasInteger32Value();
525 ? HForceRepresentation::cast(this)->value()
526 : this;
527 return value_to_check->IsConstant() &&
528 HConstant::cast(value_to_check)->HasInteger32Value();
529 } 525 }
530 526
531 527
532 int32_t HValue::GetInteger32Constant() { 528 int32_t HValue::GetInteger32Constant() {
533 HValue* constant_value = IsForceRepresentation() 529 return HConstant::cast(this)->Integer32Value();
534 ? HForceRepresentation::cast(this)->value()
535 : this;
536 return HConstant::cast(constant_value)->Integer32Value();
537 } 530 }
538 531
539 532
540 bool HValue::EqualsInteger32Constant(int32_t value) { 533 bool HValue::EqualsInteger32Constant(int32_t value) {
541 return IsInteger32Constant() && GetInteger32Constant() == value; 534 return IsInteger32Constant() && GetInteger32Constant() == value;
542 } 535 }
543 536
544 537
545 void HValue::SetOperandAt(int index, HValue* value) { 538 void HValue::SetOperandAt(int index, HValue* value) {
546 RegisterUse(index, value); 539 RegisterUse(index, value);
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 } 1328 }
1336 return this; 1329 return this;
1337 } 1330 }
1338 1331
1339 1332
1340 void HTypeof::PrintDataTo(StringStream* stream) { 1333 void HTypeof::PrintDataTo(StringStream* stream) {
1341 value()->PrintNameTo(stream); 1334 value()->PrintNameTo(stream);
1342 } 1335 }
1343 1336
1344 1337
1338 HInstruction* HForceRepresentation::New(Zone* zone, HValue* context,
1339 HValue* value, Representation required_representation) {
1340 if (FLAG_fold_constants && value->IsConstant()) {
1341 HConstant* c = HConstant::cast(value);
1342 if (c->HasNumberValue()) {
1343 double double_res = c->DoubleValue();
1344 if (TypeInfo::IsInt32Double(double_res)) {
1345 return HConstant::New(zone, context,
1346 static_cast<int32_t>(double_res),
1347 required_representation);
1348 }
1349 }
1350 }
1351 return new(zone) HForceRepresentation(value, required_representation);
1352 }
1353
1354
1345 void HForceRepresentation::PrintDataTo(StringStream* stream) { 1355 void HForceRepresentation::PrintDataTo(StringStream* stream) {
1346 stream->Add("%s ", representation().Mnemonic()); 1356 stream->Add("%s ", representation().Mnemonic());
1347 value()->PrintNameTo(stream); 1357 value()->PrintNameTo(stream);
1348 } 1358 }
1349 1359
1350 1360
1351 void HChange::PrintDataTo(StringStream* stream) { 1361 void HChange::PrintDataTo(StringStream* stream) {
1352 HUnaryOperation::PrintDataTo(stream); 1362 HUnaryOperation::PrintDataTo(stream);
1353 stream->Add(" %s to %s", from().Mnemonic(), to().Mnemonic()); 1363 stream->Add(" %s to %s", from().Mnemonic(), to().Mnemonic());
1354 1364
(...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after
4365 break; 4375 break;
4366 case kExternalMemory: 4376 case kExternalMemory:
4367 stream->Add("[external-memory]"); 4377 stream->Add("[external-memory]");
4368 break; 4378 break;
4369 } 4379 }
4370 4380
4371 stream->Add("@%d", offset()); 4381 stream->Add("@%d", offset());
4372 } 4382 }
4373 4383
4374 } } // namespace v8::internal 4384 } } // 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