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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 9456033: Added LoadLiteralComp, StrictCompareComp; implement InstanceCallNode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 4552)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -188,11 +188,15 @@
}
void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) {
- ReturnValue(new ConstantValue(node->literal()));
+ LoadLiteralComp* load =
+ new LoadLiteralComp(new ConstantValue(node->literal()));
Kevin Millikin (Google) 2012/02/24 10:53:04 As mentioned: let's not materialize literals in al
srdjan 2012/02/24 22:16:24 OK, let's see how it works out.
+ ReturnValueOf(load);
}
void TestGraphVisitor::VisitLiteralNode(LiteralNode* node) {
- BranchOnValue(new ConstantValue(node->literal()));
+ LoadLiteralComp* load =
+ new LoadLiteralComp(new ConstantValue(node->literal()));
+ BranchOnValueOf(load);
}
@@ -293,12 +297,12 @@
// <Expression> :: Comparison { kind: Token::Kind
// left: <Expression>
// right: <Expression> }
-InstanceCallComp* EffectGraphVisitor::TranslateComparison(
+Computation* EffectGraphVisitor::TranslateComparison(
const ComparisonNode& node) {
- if (Token::IsInstanceofOperator(node.kind()) ||
- Token::IsEqualityOperator(node.kind())) {
- Bailout("Some kind of comparison we don't handle yet");
- return NULL;
+ if (Token::IsInstanceofOperator(node.kind())) {
+ Bailout("instanceof not yet implemented");
+ } else if ((node.kind() == Token::kEQ) || (node.kind() == Token::kNE)) {
+ Bailout("'==' or '!=' comparison not yet implemented");
}
ValueGraphVisitor for_left_value(owner(), temp_index());
node.left()->Visit(&for_left_value);
@@ -308,6 +312,11 @@
node.right()->Visit(&for_right_value);
Append(for_right_value);
CHECK_ALIVE(return NULL);
+ if ((node.kind() == Token::kEQ_STRICT) ||
+ (node.kind() == Token::kNE_STRICT)) {
+ return new StrictCompareComp(
+ node.kind(), for_left_value.value(), for_right_value.value());
+ }
ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
arguments->Add(for_left_value.value());
arguments->Add(for_right_value.value());
@@ -315,19 +324,19 @@
}
void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) {
- InstanceCallComp* call = TranslateComparison(*node);
+ Computation* call = TranslateComparison(*node);
CHECK_ALIVE(return);
DoComputation(call);
}
void ValueGraphVisitor::VisitComparisonNode(ComparisonNode* node) {
- InstanceCallComp* call = TranslateComparison(*node);
+ Computation* call = TranslateComparison(*node);
CHECK_ALIVE(return);
ReturnValueOf(call);
}
void TestGraphVisitor::VisitComparisonNode(ComparisonNode* node) {
- InstanceCallComp* call = TranslateComparison(*node);
+ Computation* call = TranslateComparison(*node);
CHECK_ALIVE(return);
BranchOnValueOf(call);
}
@@ -550,14 +559,43 @@
}
+InstanceCallComp* EffectGraphVisitor::TranslateInstanceCall(
+ const InstanceCallNode& node) {
+ ArgumentListNode* arguments = node.arguments();
+ int length = arguments->length();
+ ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1);
+ ValueGraphVisitor for_receiver(owner(), temp_index());
+ node.receiver()->Visit(&for_receiver);
+ Append(for_receiver);
+ CHECK_ALIVE(return NULL);
+ values->Add(for_receiver.value());
+ int index = temp_index();
+ for (intptr_t i = 0; i < length; ++i) {
+ ValueGraphVisitor for_value(owner(), index);
+ arguments->NodeAt(i)->Visit(&for_value);
+ Append(for_value);
+ CHECK_ALIVE(return NULL);
+ values->Add(for_value.value());
+ index = for_value.temp_index();
+ }
+ return new InstanceCallComp(node.function_name().ToCString(), values);
+}
+
+
void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) {
- Bailout("EffectGraphVisitor::VisitInstanceCallNode");
+ InstanceCallComp* call = TranslateInstanceCall(*node);
+ CHECK_ALIVE(return);
+ DoComputation(call);
}
void ValueGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) {
- Bailout("ValueGraphVisitor::VisitInstanceCallNode");
+ InstanceCallComp* call = TranslateInstanceCall(*node);
+ CHECK_ALIVE(return);
+ ReturnValueOf(call);
}
void TestGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) {
- Bailout("TestGraphVisitor::VisitInstanceCallNode");
+ InstanceCallComp* call = TranslateInstanceCall(*node);
+ CHECK_ALIVE(return);
+ BranchOnValueOf(call);
}

Powered by Google App Engine
This is Rietveld 408576698