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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 266633007: Merge ConstantInstr -> UnboxDouble to UnboxedConstant. Reduces register usage and allows for variou… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 35656)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -325,6 +325,14 @@
}
+UnboxedConstantInstr::UnboxedConstantInstr(const Object& value)
+ : ConstantInstr(value), constant_address_(NULL) {
+ // Only doubles supported for now.
+ ASSERT(value.IsDouble());
+ constant_address_ =
+ FlowGraphBuilder::FindDoubleConstant(Double::Cast(value).value());
+}
+
// Returns true if the value represents a constant.
bool Value::BindsToConstant() const {
return definition()->IsConstant();
@@ -1224,7 +1232,6 @@
return ToIntegerConstant(value->definition()->AsUnboxDouble()->value(),
result);
}
-
return false;
}
@@ -1601,9 +1608,21 @@
Definition* UnboxDoubleInstr::Canonicalize(FlowGraph* flow_graph) {
+ if (!HasUses()) return NULL;
// Fold away UnboxDouble(BoxDouble(v)).
- BoxDoubleInstr* defn = value()->definition()->AsBoxDouble();
- return (defn != NULL) ? defn->value()->definition() : this;
+ BoxDoubleInstr* box_defn = value()->definition()->AsBoxDouble();
+ if (box_defn != NULL) {
+ return box_defn->value()->definition();
+ }
+
+ ConstantInstr* c = value()->definition()->AsConstant();
+ if ((c != NULL) && c->value().IsDouble()) {
+ UnboxedConstantInstr* uc = new UnboxedConstantInstr(c->value());
+ flow_graph->InsertBefore(this, uc, NULL, Definition::kValue);
+ return uc;
+ }
+
+ return this;
}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698