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

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
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 35632)
+++ 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;
}
@@ -1602,8 +1609,19 @@
Definition* UnboxDoubleInstr::Canonicalize(FlowGraph* flow_graph) {
Florian Schneider 2014/05/01 18:34:16 Maybe add if (!HasUses()) return NULL; so that U
srdjan 2014/05/01 20:33:04 Done.
// 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, this->env(), Definition::kValue);
Florian Schneider 2014/05/01 18:34:16 UnboxedConstant should not need an environment, si
srdjan 2014/05/01 20:33:04 Done.
+ return uc;
Florian Schneider 2014/05/01 18:34:16 Make sure that the UnboxDoubleInstr get removed by
srdjan 2014/05/01 20:33:04 I checked it visually in disassembled output/flow
+ }
+
+ return this;
}

Powered by Google App Engine
This is Rietveld 408576698