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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 9639010: Implement compilation of conditional expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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/flow_graph_builder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 4f387f971414ebb17531c0859d5693006b903521..20c01ef4e5e5c54f2cf5568e216b39d1150b94f5 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -538,7 +538,47 @@ void ValueGraphVisitor::VisitIncrOpIndexedNode(IncrOpIndexedNode* node) {
void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
- Bailout("EffectGraphVisitor::VisitConditionalExprNode");
+ TestGraphVisitor for_test(owner(), temp_index());
+ node->condition()->Visit(&for_test);
+ ASSERT(for_test.can_be_true() && for_test.can_be_false());
+
+ // Translate the subexpressions for their effects.
+ EffectGraphVisitor for_true(owner(), temp_index());
+ node->true_expr()->Visit(&for_true);
+ EffectGraphVisitor for_false(owner(), temp_index());
+ node->false_expr()->Visit(&for_false);
+
+ Join(for_test, for_true, for_false);
+}
+
+
+void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
+ TestGraphVisitor for_test(owner(), temp_index());
+ node->condition()->Visit(&for_test);
+ ASSERT(for_test.can_be_true() && for_test.can_be_false());
srdjan 2012/03/08 17:43:53 Again, what is the point of can_be_true and can_be
Kevin Millikin (Google) 2012/03/09 09:53:01 To support online constant folding of conditional
+
+ // Ensure that the value of the true/false subexpressions are named with
+ // the same temporary name.
+ ValueGraphVisitor for_true(owner(), temp_index());
+ node->true_expr()->Visit(&for_true);
+ ASSERT(for_true.is_open());
+ if (for_true.value()->IsTemp()) {
+ ASSERT(for_true.value()->AsTemp()->index() == temp_index());
+ } else {
+ for_true.AddInstruction(new BindInstr(temp_index(), for_true.value()));
+ }
+
+ ValueGraphVisitor for_false(owner(), temp_index());
+ node->false_expr()->Visit(&for_false);
+ ASSERT(for_false.is_open());
+ if (for_false.value()->IsTemp()) {
+ ASSERT(for_false.value()->AsTemp()->index() == temp_index());
+ } else {
+ for_false.AddInstruction(new BindInstr(temp_index(), for_false.value()));
+ }
+
+ Join(for_test, for_true, for_false);
+ ReturnValue(new TempVal(AllocateTempIndex()));
}
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698