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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 38eabdae06aa5d9968d1479e050e883ff7b707f2..33ab8797252b9880a50fb3a3f2deff5f8a9f9ca9 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -521,19 +521,12 @@ bool HValue::CanReplaceWithDummyUses() {
bool HValue::IsInteger32Constant() {
- HValue* value_to_check = IsForceRepresentation()
- ? HForceRepresentation::cast(this)->value()
- : this;
- return value_to_check->IsConstant() &&
- HConstant::cast(value_to_check)->HasInteger32Value();
+ return IsConstant() && HConstant::cast(this)->HasInteger32Value();
}
int32_t HValue::GetInteger32Constant() {
- HValue* constant_value = IsForceRepresentation()
- ? HForceRepresentation::cast(this)->value()
- : this;
- return HConstant::cast(constant_value)->Integer32Value();
+ return HConstant::cast(this)->Integer32Value();
}
@@ -1328,6 +1321,23 @@ void HTypeof::PrintDataTo(StringStream* stream) {
}
+HInstruction* HForceRepresentation::New(Zone* zone, HValue* context,
+ HValue* value, Representation required_representation) {
+ if (FLAG_fold_constants && value->IsConstant()) {
+ HConstant* c = HConstant::cast(value);
+ if ((c->HasNumberValue())) {
mvstanton 2013/11/19 10:22:28 nit: remove extra parens
Igor Sheludko 2013/11/19 11:43:35 Done.
+ double double_res = c->DoubleValue();
+ if (TypeInfo::IsInt32Double(double_res)) {
+ return HConstant::New(zone, context,
+ static_cast<int32_t>(double_res),
+ required_representation);
+ }
+ }
+ }
+ return new(zone) HForceRepresentation(value, required_representation);
+}
+
+
void HForceRepresentation::PrintDataTo(StringStream* stream) {
stream->Add("%s ", representation().Mnemonic());
value()->PrintNameTo(stream);
« 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