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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 9969192: Implement condition type checks in new compiler, thereby removing last bailouts. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 6609)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -160,6 +160,15 @@
void TestGraphVisitor::ReturnValue(Value* value) {
+ if (FLAG_enable_type_checks) {
+ AssertBooleanComp* assert_boolean =
+ new AssertBooleanComp(node_id(),
+ token_index(),
+ owner()->try_index(),
+ value);
+ AddInstruction(new BindInstr(temp_index(), assert_boolean));
+ value = new TempVal(temp_index());
+ }
BranchInstr* branch = new BranchInstr(value);
AddInstruction(branch);
CloseFragment();
@@ -299,6 +308,10 @@
if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
// See ValueGraphVisitor::VisitBinaryOpNode.
TestGraphVisitor for_left(owner(), temp_index());
+ if (FLAG_enable_type_checks) {
+ for_left.set_node_id(node->left()->id());
+ for_left.set_token_index(node->left()->token_index());
+ }
node->left()->Visit(&for_left);
EffectGraphVisitor for_right(owner(), temp_index());
node->right()->Visit(&for_right);
@@ -344,18 +357,26 @@
const Bool& bool_false = Bool::ZoneHandle(Bool::False());
TestGraphVisitor for_test(owner(), temp_index());
- node->left()->Visit(&for_test);
if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in kAND/kOR");
+ for_test.set_node_id(node->left()->id());
+ for_test.set_token_index(node->left()->token_index());
}
+ node->left()->Visit(&for_test);
ValueGraphVisitor for_right(owner(), temp_index());
node->right()->Visit(&for_right);
+ Value* right_value = for_right.value();
if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in kAND/kOR");
+ AssertBooleanComp* assert_boolean =
+ new AssertBooleanComp(node->right()->id(),
+ node->right()->token_index(),
+ owner()->try_index(),
+ right_value);
+ for_right.AddInstruction(new BindInstr(temp_index(), assert_boolean));
+ right_value = new TempVal(temp_index());
}
StrictCompareComp* comp = new StrictCompareComp(Token::kEQ_STRICT,
- for_right.value(), new ConstantVal(bool_true));
+ right_value, new ConstantVal(bool_true));
for_right.AddInstruction(new BindInstr(temp_index(), comp));
if (node->kind() == Token::kAND) {
@@ -569,6 +590,15 @@
} else {
AddInstruction(new BindInstr(temp_index(), comp));
Value* eq_result = new TempVal(temp_index());
+ if (FLAG_enable_type_checks) {
+ AssertBooleanComp* assert_boolean =
+ new AssertBooleanComp(node->id(),
+ node->token_index(),
+ owner()->try_index(),
+ eq_result);
+ AddInstruction(new BindInstr(temp_index(), assert_boolean));
+ eq_result = new TempVal(temp_index());
+ }
BooleanNegateComp* negate = new BooleanNegateComp(eq_result);
ReturnComputation(negate);
}
@@ -598,10 +628,17 @@
ValueGraphVisitor for_value(owner(), temp_index());
node->operand()->Visit(&for_value);
Append(for_value);
+ Value* value = for_value.value();
if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in kNOT");
+ AssertBooleanComp* assert_boolean =
+ new AssertBooleanComp(node->operand()->id(),
+ node->operand()->token_index(),
+ owner()->try_index(),
+ value);
+ AddInstruction(new BindInstr(temp_index(), assert_boolean));
+ value = new TempVal(temp_index());
}
- BooleanNegateComp* negate = new BooleanNegateComp(for_value.value());
+ BooleanNegateComp* negate = new BooleanNegateComp(value);
ReturnComputation(negate);
return;
}
@@ -866,10 +903,11 @@
void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
TestGraphVisitor for_test(owner(), temp_index());
- node->condition()->Visit(&for_test);
if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in conditional expr");
+ for_test.set_node_id(node->condition()->id());
+ for_test.set_token_index(node->condition()->token_index());
}
+ node->condition()->Visit(&for_test);
// Translate the subexpressions for their effects.
EffectGraphVisitor for_true(owner(), temp_index());
@@ -883,10 +921,11 @@
void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
TestGraphVisitor for_test(owner(), temp_index());
- node->condition()->Visit(&for_test);
if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in conditional expr");
+ for_test.set_node_id(node->condition()->id());
+ for_test.set_token_index(node->condition()->token_index());
}
+ node->condition()->Visit(&for_test);
// Ensure that the value of the true/false subexpressions are named with
// the same temporary name.
@@ -918,10 +957,11 @@
// false_branch: <Sequence> }
void EffectGraphVisitor::VisitIfNode(IfNode* node) {
TestGraphVisitor for_test(owner(), temp_index());
- node->condition()->Visit(&for_test);
if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in if");
+ for_test.set_node_id(node->condition()->id());
+ for_test.set_token_index(node->condition()->token_index());
}
+ node->condition()->Visit(&for_test);
EffectGraphVisitor for_true(owner(), temp_index());
EffectGraphVisitor for_false(owner(), temp_index());
@@ -1089,13 +1129,13 @@
// g) break-join (optional)
void EffectGraphVisitor::VisitWhileNode(WhileNode* node) {
TestGraphVisitor for_test(owner(), temp_index());
+ if (FLAG_enable_type_checks) {
+ for_test.set_node_id(node->condition()->id());
+ for_test.set_token_index(node->condition()->token_index());
+ }
node->condition()->Visit(&for_test);
ASSERT(!for_test.is_empty()); // Language spec.
- if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in while");
- }
-
EffectGraphVisitor for_body(owner(), temp_index());
node->body()->Visit(&for_body);
@@ -1126,13 +1166,13 @@
node->body()->Visit(&for_body);
TestGraphVisitor for_test(owner(), temp_index());
+ if (FLAG_enable_type_checks) {
+ for_test.set_node_id(node->condition()->id());
+ for_test.set_token_index(node->condition()->token_index());
+ }
node->condition()->Visit(&for_test);
ASSERT(is_open());
- if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in do while");
- }
-
// Tie do-while loop (test is after the body).
JoinEntryInstr* body_entry_join = new JoinEntryInstr();
AddInstruction(body_entry_join);
@@ -1236,11 +1276,12 @@
} else {
TargetEntryInstr* loop_exit = new TargetEntryInstr();
TestGraphVisitor for_test(owner(), temp_index());
+ if (FLAG_enable_type_checks) {
+ for_test.set_node_id(node->condition()->id());
+ for_test.set_token_index(node->condition()->token_index());
+ }
node->condition()->Visit(&for_test);
Append(for_test);
- if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in for");
- }
*for_test.true_successor_address() = body_entry;
*for_test.false_successor_address() = loop_exit;
if (node->label()->join_for_break() == NULL) {
@@ -1771,7 +1812,7 @@
}
AssertAssignableComp* assert_assignable =
new AssertAssignableComp(node->id(),
- node->local().token_index(),
+ node->value()->token_index(),
owner()->try_index(),
value,
type_arguments,
@@ -1851,7 +1892,7 @@
}
AssertAssignableComp* assert_assignable =
new AssertAssignableComp(node->id(),
- node->field().token_index(),
+ node->value()->token_index(),
owner()->try_index(),
store_value,
type_arguments,
@@ -2268,7 +2309,7 @@
OS::Print("AssertAssignable(");
comp->value()->Accept(this);
OS::Print(", %s, '%s'",
- comp->dst_type().ToCString(),
+ String::Handle(comp->dst_type().Name()).ToCString(),
comp->dst_name().ToCString());
if (comp->type_arguments() != NULL) {
OS::Print(" (type-arg:");
Property changes on: runtime/vm/flow_graph_builder.cc
___________________________________________________________________
Deleted: svn:eol-style
- LF

Powered by Google App Engine
This is Rietveld 408576698