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

Unified Diff: runtime/vm/flow_graph_compiler.cc

Issue 10918097: Allow smi comparisons to have constant operands. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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_compiler.cc
diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc
index 4bb850f22fcc6c8d3a04cebcb158a48f3ccbb080..6370b52d40a96f27b069a9a6f2c8a72cde11347e 100644
--- a/runtime/vm/flow_graph_compiler.cc
+++ b/runtime/vm/flow_graph_compiler.cc
@@ -807,4 +807,46 @@ void ParallelMoveResolver::PerformMove(int index) {
}
+Condition FlowGraphCompiler::FlipCondition(Condition condition) {
+ switch (condition) {
+ case EQUAL: return EQUAL;
+ case NOT_EQUAL: return NOT_EQUAL;
+ case LESS: return GREATER;
+ case LESS_EQUAL: return GREATER_EQUAL;
+ case GREATER: return LESS;
+ case GREATER_EQUAL: return LESS_EQUAL;
+ case BELOW: return ABOVE;
+ case BELOW_EQUAL: return ABOVE_EQUAL;
+ case ABOVE: return BELOW;
+ case ABOVE_EQUAL: return BELOW_EQUAL;
+ default:
+ UNIMPLEMENTED();
+ return EQUAL;
+ }
+}
+
+
+bool FlowGraphCompiler::EvaluateCondition(Condition condition,
+ intptr_t left,
+ intptr_t right) {
+ const uintptr_t unsigned_left = static_cast<uintptr_t>(left);
+ const uintptr_t unsigned_right = static_cast<uintptr_t>(right);
+ switch (condition) {
+ case EQUAL: return left == right;
+ case NOT_EQUAL: return left != right;
+ case LESS: return left < right;
+ case LESS_EQUAL: return left <= right;
+ case GREATER: return left > right;
+ case GREATER_EQUAL: return left >= right;
+ case BELOW: return unsigned_left < unsigned_right;
+ case BELOW_EQUAL: return unsigned_left <= unsigned_right;
+ case ABOVE: return unsigned_left > unsigned_right;
+ case ABOVE_EQUAL: return unsigned_left >= unsigned_right;
+ default:
+ UNIMPLEMENTED();
+ return false;
+ }
+}
+
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698