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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 10079018: Introduce an equality compare node. Equality will need to be handled specially soon (not just an in… (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
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 6532)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -507,6 +507,7 @@
// <Expression> :: Comparison { kind: Token::Kind
// left: <Expression>
// right: <Expression> }
+// TODO(srdjan): Implement new equality.
void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) {
if (Token::IsInstanceofOperator(node->kind())) {
BuildInstanceOf(node);
@@ -526,6 +527,27 @@
return;
}
+ if ((node->kind() == Token::kEQ) || (node->kind() == Token::kNE)) {
+ ValueGraphVisitor for_left_value(owner(), temp_index());
+ node->left()->Visit(&for_left_value);
+ Append(for_left_value);
+ ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index());
+ node->right()->Visit(&for_right_value);
+ Append(for_right_value);
+ EqualityCompareComp* comp = new EqualityCompareComp(
+ node->id(), node->token_index(), owner()->try_index(),
+ for_left_value.value(), for_right_value.value());
+ if (node->kind() == Token::kEQ) {
+ ReturnComputation(comp);
+ } else {
+ AddInstruction(new BindInstr(temp_index(), comp));
+ Value* eq_result = new TempVal(temp_index());
+ BooleanNegateComp* negate = new BooleanNegateComp(eq_result);
+ ReturnComputation(negate);
+ }
+ return;
+ }
+
ArgumentGraphVisitor for_left_value(owner(), temp_index());
node->left()->Visit(&for_left_value);
Append(for_left_value);
@@ -535,27 +557,11 @@
ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
arguments->Add(for_left_value.value());
arguments->Add(for_right_value.value());
- // 'kNE' is not overloadable, must implement as kEQ and negation.
- // Boolean negation '!' cannot be overloaded neither.
- if (node->kind() == Token::kNE) {
- const String& name = String::ZoneHandle(String::NewSymbol("=="));
- InstanceCallComp* call_equal = new InstanceCallComp(
- node->id(), node->token_index(), owner()->try_index(), name,
- arguments, Array::ZoneHandle(), 2);
- AddInstruction(new BindInstr(temp_index(), call_equal));
- Value* eq_result = new TempVal(temp_index());
- if (FLAG_enable_type_checks) {
- Bailout("GenerateConditionTypeCheck in kNE");
- }
- BooleanNegateComp* negate = new BooleanNegateComp(eq_result);
- ReturnComputation(negate);
- } else {
- const String& name = String::ZoneHandle(String::NewSymbol(node->Name()));
- InstanceCallComp* call = new InstanceCallComp(
- node->id(), node->token_index(), owner()->try_index(), name,
- arguments, Array::ZoneHandle(), 2);
- ReturnComputation(call);
- }
+ const String& name = String::ZoneHandle(String::NewSymbol(node->Name()));
+ InstanceCallComp* call = new InstanceCallComp(
+ node->id(), node->token_index(), owner()->try_index(), name,
+ arguments, Array::ZoneHandle(), 2);
+ ReturnComputation(call);
}
@@ -2195,7 +2201,14 @@
}
+void FlowGraphPrinter::VisitEqualityCompare(EqualityCompareComp* comp) {
+ comp->left()->Accept(this);
+ OS::Print(" == ");
+ comp->right()->Accept(this);
+}
+
+
void FlowGraphPrinter::VisitStaticCall(StaticCallComp* comp) {
OS::Print("StaticCall(%s",
String::Handle(comp->function().name()).ToCString());
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698