Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/longjump.h" | 9 #include "vm/longjump.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 void ValueGraphVisitor::VisitReturnNode(ReturnNode* node) { UNREACHABLE(); } | 181 void ValueGraphVisitor::VisitReturnNode(ReturnNode* node) { UNREACHABLE(); } |
| 182 void TestGraphVisitor::VisitReturnNode(ReturnNode* node) { UNREACHABLE(); } | 182 void TestGraphVisitor::VisitReturnNode(ReturnNode* node) { UNREACHABLE(); } |
| 183 | 183 |
| 184 | 184 |
| 185 // <Expression> ::= Literal { literal: Instance } | 185 // <Expression> ::= Literal { literal: Instance } |
| 186 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { | 186 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) { | 190 void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) { |
| 191 ReturnValue(new ConstantValue(node->literal())); | 191 LoadLiteralComp* load = |
| 192 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.
| |
| 193 ReturnValueOf(load); | |
| 192 } | 194 } |
| 193 | 195 |
| 194 void TestGraphVisitor::VisitLiteralNode(LiteralNode* node) { | 196 void TestGraphVisitor::VisitLiteralNode(LiteralNode* node) { |
| 195 BranchOnValue(new ConstantValue(node->literal())); | 197 LoadLiteralComp* load = |
| 198 new LoadLiteralComp(new ConstantValue(node->literal())); | |
| 199 BranchOnValueOf(load); | |
| 196 } | 200 } |
| 197 | 201 |
| 198 | 202 |
| 199 // Type nodes only occur as the right-hand side of instanceof comparisons, | 203 // Type nodes only occur as the right-hand side of instanceof comparisons, |
| 200 // and they are handled specially in that context. | 204 // and they are handled specially in that context. |
| 201 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } | 205 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } |
| 202 void ValueGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } | 206 void ValueGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } |
| 203 void TestGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } | 207 void TestGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } |
| 204 | 208 |
| 205 | 209 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 Bailout("ValueGraphVisitor::VisitStringConcatNode"); | 290 Bailout("ValueGraphVisitor::VisitStringConcatNode"); |
| 287 } | 291 } |
| 288 void TestGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { | 292 void TestGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { |
| 289 Bailout("TestGraphVisitor::VisitStringConcatNode"); | 293 Bailout("TestGraphVisitor::VisitStringConcatNode"); |
| 290 } | 294 } |
| 291 | 295 |
| 292 | 296 |
| 293 // <Expression> :: Comparison { kind: Token::Kind | 297 // <Expression> :: Comparison { kind: Token::Kind |
| 294 // left: <Expression> | 298 // left: <Expression> |
| 295 // right: <Expression> } | 299 // right: <Expression> } |
| 296 InstanceCallComp* EffectGraphVisitor::TranslateComparison( | 300 Computation* EffectGraphVisitor::TranslateComparison( |
| 297 const ComparisonNode& node) { | 301 const ComparisonNode& node) { |
| 298 if (Token::IsInstanceofOperator(node.kind()) || | 302 if (Token::IsInstanceofOperator(node.kind())) { |
| 299 Token::IsEqualityOperator(node.kind())) { | 303 Bailout("instanceof not yet implemented"); |
| 300 Bailout("Some kind of comparison we don't handle yet"); | 304 } else if ((node.kind() == Token::kEQ) || (node.kind() == Token::kNE)) { |
| 301 return NULL; | 305 Bailout("'==' or '!=' comparison not yet implemented"); |
| 302 } | 306 } |
| 303 ValueGraphVisitor for_left_value(owner(), temp_index()); | 307 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 304 node.left()->Visit(&for_left_value); | 308 node.left()->Visit(&for_left_value); |
| 305 Append(for_left_value); | 309 Append(for_left_value); |
| 306 CHECK_ALIVE(return NULL); | 310 CHECK_ALIVE(return NULL); |
| 307 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); | 311 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); |
| 308 node.right()->Visit(&for_right_value); | 312 node.right()->Visit(&for_right_value); |
| 309 Append(for_right_value); | 313 Append(for_right_value); |
| 310 CHECK_ALIVE(return NULL); | 314 CHECK_ALIVE(return NULL); |
| 315 if ((node.kind() == Token::kEQ_STRICT) || | |
| 316 (node.kind() == Token::kNE_STRICT)) { | |
| 317 return new StrictCompareComp( | |
| 318 node.kind(), for_left_value.value(), for_right_value.value()); | |
| 319 } | |
| 311 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); | 320 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); |
| 312 arguments->Add(for_left_value.value()); | 321 arguments->Add(for_left_value.value()); |
| 313 arguments->Add(for_right_value.value()); | 322 arguments->Add(for_right_value.value()); |
| 314 return new InstanceCallComp(node.Name(), arguments); | 323 return new InstanceCallComp(node.Name(), arguments); |
| 315 } | 324 } |
| 316 | 325 |
| 317 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 326 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 318 InstanceCallComp* call = TranslateComparison(*node); | 327 Computation* call = TranslateComparison(*node); |
| 319 CHECK_ALIVE(return); | 328 CHECK_ALIVE(return); |
| 320 DoComputation(call); | 329 DoComputation(call); |
| 321 } | 330 } |
| 322 | 331 |
| 323 void ValueGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 332 void ValueGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 324 InstanceCallComp* call = TranslateComparison(*node); | 333 Computation* call = TranslateComparison(*node); |
| 325 CHECK_ALIVE(return); | 334 CHECK_ALIVE(return); |
| 326 ReturnValueOf(call); | 335 ReturnValueOf(call); |
| 327 } | 336 } |
| 328 | 337 |
| 329 void TestGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 338 void TestGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 330 InstanceCallComp* call = TranslateComparison(*node); | 339 Computation* call = TranslateComparison(*node); |
| 331 CHECK_ALIVE(return); | 340 CHECK_ALIVE(return); |
| 332 BranchOnValueOf(call); | 341 BranchOnValueOf(call); |
| 333 } | 342 } |
| 334 | 343 |
| 335 | 344 |
| 336 | 345 |
| 337 InstanceCallComp* EffectGraphVisitor::TranslateUnaryOp( | 346 InstanceCallComp* EffectGraphVisitor::TranslateUnaryOp( |
| 338 const UnaryOpNode& node) { | 347 const UnaryOpNode& node) { |
| 339 // "!" cannot be overloaded, therefore do not call operator. | 348 // "!" cannot be overloaded, therefore do not call operator. |
| 340 if (node.kind() == Token::kNOT) { | 349 if (node.kind() == Token::kNOT) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 Bailout("EffectGraphVisitor::VisitClosureNode"); | 552 Bailout("EffectGraphVisitor::VisitClosureNode"); |
| 544 } | 553 } |
| 545 void ValueGraphVisitor::VisitClosureNode(ClosureNode* node) { | 554 void ValueGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 546 Bailout("ValueGraphVisitor::VisitClosureNode"); | 555 Bailout("ValueGraphVisitor::VisitClosureNode"); |
| 547 } | 556 } |
| 548 void TestGraphVisitor::VisitClosureNode(ClosureNode* node) { | 557 void TestGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 549 Bailout("TestGraphVisitor::VisitClosureNode"); | 558 Bailout("TestGraphVisitor::VisitClosureNode"); |
| 550 } | 559 } |
| 551 | 560 |
| 552 | 561 |
| 562 InstanceCallComp* EffectGraphVisitor::TranslateInstanceCall( | |
| 563 const InstanceCallNode& node) { | |
| 564 ArgumentListNode* arguments = node.arguments(); | |
| 565 int length = arguments->length(); | |
| 566 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1); | |
| 567 ValueGraphVisitor for_receiver(owner(), temp_index()); | |
| 568 node.receiver()->Visit(&for_receiver); | |
| 569 Append(for_receiver); | |
| 570 CHECK_ALIVE(return NULL); | |
| 571 values->Add(for_receiver.value()); | |
| 572 int index = temp_index(); | |
| 573 for (intptr_t i = 0; i < length; ++i) { | |
| 574 ValueGraphVisitor for_value(owner(), index); | |
| 575 arguments->NodeAt(i)->Visit(&for_value); | |
| 576 Append(for_value); | |
| 577 CHECK_ALIVE(return NULL); | |
| 578 values->Add(for_value.value()); | |
| 579 index = for_value.temp_index(); | |
| 580 } | |
| 581 return new InstanceCallComp(node.function_name().ToCString(), values); | |
| 582 } | |
| 583 | |
| 584 | |
| 553 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 585 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 554 Bailout("EffectGraphVisitor::VisitInstanceCallNode"); | 586 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 587 CHECK_ALIVE(return); | |
| 588 DoComputation(call); | |
| 555 } | 589 } |
| 556 void ValueGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 590 void ValueGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 557 Bailout("ValueGraphVisitor::VisitInstanceCallNode"); | 591 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 592 CHECK_ALIVE(return); | |
| 593 ReturnValueOf(call); | |
| 558 } | 594 } |
| 559 void TestGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 595 void TestGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 560 Bailout("TestGraphVisitor::VisitInstanceCallNode"); | 596 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 597 CHECK_ALIVE(return); | |
| 598 BranchOnValueOf(call); | |
| 561 } | 599 } |
| 562 | 600 |
| 563 | 601 |
| 564 // <Expression> ::= StaticCall { function: Function | 602 // <Expression> ::= StaticCall { function: Function |
| 565 // arguments: <ArgumentList> } | 603 // arguments: <ArgumentList> } |
| 566 StaticCallComp* EffectGraphVisitor::TranslateStaticCall( | 604 StaticCallComp* EffectGraphVisitor::TranslateStaticCall( |
| 567 const StaticCallNode& node) { | 605 const StaticCallNode& node) { |
| 568 ArgumentListNode* arguments = node.arguments(); | 606 ArgumentListNode* arguments = node.arguments(); |
| 569 int length = arguments->length(); | 607 int length = arguments->length(); |
| 570 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length); | 608 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 988 char* chars = reinterpret_cast<char*>( | 1026 char* chars = reinterpret_cast<char*>( |
| 989 Isolate::Current()->current_zone()->Allocate(len)); | 1027 Isolate::Current()->current_zone()->Allocate(len)); |
| 990 OS::SNPrint(chars, len, kFormat, reason); | 1028 OS::SNPrint(chars, len, kFormat, reason); |
| 991 const Error& error = Error::Handle( | 1029 const Error& error = Error::Handle( |
| 992 LanguageError::New(String::Handle(String::New(chars)))); | 1030 LanguageError::New(String::Handle(String::New(chars)))); |
| 993 Isolate::Current()->long_jump_base()->Jump(1, error); | 1031 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 994 } | 1032 } |
| 995 | 1033 |
| 996 | 1034 |
| 997 } // namespace dart | 1035 } // namespace dart |
| OLD | NEW |