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

Unified Diff: runtime/vm/flow_graph_builder.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/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 35632)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -39,6 +39,25 @@
DECLARE_FLAG(bool, enable_type_checks);
+
+// TODO(srdjan): Allow compiler to add constants as they are encountered in
+// the compilation.
+const double kCommonDoubleConstants[15] =
+ {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0,
+ 10.0, 20.0, 30.0, 64.0, 255.0};
+
+uword FlowGraphBuilder::FindDoubleConstant(double value) {
+ intptr_t len = sizeof(kCommonDoubleConstants) / sizeof(double); // NOLINT
+ for (intptr_t i = 0; i < len; i++) {
+ // Bitwise compare.
+ if (*reinterpret_cast<int64_t*>(&value) ==
+ *reinterpret_cast<const int64_t*>(&kCommonDoubleConstants[i])) {
+ return reinterpret_cast<uword>(&kCommonDoubleConstants[i]);
+ }
+ }
+ return 0;
+}
+
// Base class for a stack of enclosing statements of interest (e.g.,
// blocks (breakable) and loops (continuable)).
class NestedStatement : public ValueObject {

Powered by Google App Engine
This is Rietveld 408576698