| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 Bailout("ValueGraphVisitor::VisitStringConcatNode"); | 286 Bailout("ValueGraphVisitor::VisitStringConcatNode"); |
| 287 } | 287 } |
| 288 void TestGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { | 288 void TestGraphVisitor::VisitStringConcatNode(StringConcatNode* node) { |
| 289 Bailout("TestGraphVisitor::VisitStringConcatNode"); | 289 Bailout("TestGraphVisitor::VisitStringConcatNode"); |
| 290 } | 290 } |
| 291 | 291 |
| 292 | 292 |
| 293 // <Expression> :: Comparison { kind: Token::Kind | 293 // <Expression> :: Comparison { kind: Token::Kind |
| 294 // left: <Expression> | 294 // left: <Expression> |
| 295 // right: <Expression> } | 295 // right: <Expression> } |
| 296 InstanceCallComp* EffectGraphVisitor::TranslateComparison( | 296 Computation* EffectGraphVisitor::TranslateComparison( |
| 297 const ComparisonNode& node) { | 297 const ComparisonNode& node) { |
| 298 if (Token::IsInstanceofOperator(node.kind()) || | 298 if (Token::IsInstanceofOperator(node.kind())) { |
| 299 Token::IsEqualityOperator(node.kind())) { | 299 Bailout("instanceof not yet implemented"); |
| 300 Bailout("Some kind of comparison we don't handle yet"); | 300 } else if ((node.kind() == Token::kEQ) || (node.kind() == Token::kNE)) { |
| 301 return NULL; | 301 Bailout("'==' or '!=' comparison not yet implemented"); |
| 302 } | 302 } |
| 303 ValueGraphVisitor for_left_value(owner(), temp_index()); | 303 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 304 node.left()->Visit(&for_left_value); | 304 node.left()->Visit(&for_left_value); |
| 305 Append(for_left_value); | 305 Append(for_left_value); |
| 306 CHECK_ALIVE(return NULL); | 306 CHECK_ALIVE(return NULL); |
| 307 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); | 307 ValueGraphVisitor for_right_value(owner(), for_left_value.temp_index()); |
| 308 node.right()->Visit(&for_right_value); | 308 node.right()->Visit(&for_right_value); |
| 309 Append(for_right_value); | 309 Append(for_right_value); |
| 310 CHECK_ALIVE(return NULL); | 310 CHECK_ALIVE(return NULL); |
| 311 if ((node.kind() == Token::kEQ_STRICT) || |
| 312 (node.kind() == Token::kNE_STRICT)) { |
| 313 return new StrictCompareComp( |
| 314 node.kind(), for_left_value.value(), for_right_value.value()); |
| 315 } |
| 311 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); | 316 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); |
| 312 arguments->Add(for_left_value.value()); | 317 arguments->Add(for_left_value.value()); |
| 313 arguments->Add(for_right_value.value()); | 318 arguments->Add(for_right_value.value()); |
| 314 return new InstanceCallComp(node.Name(), arguments); | 319 return new InstanceCallComp(node.Name(), arguments); |
| 315 } | 320 } |
| 316 | 321 |
| 317 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 322 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 318 InstanceCallComp* call = TranslateComparison(*node); | 323 Computation* call = TranslateComparison(*node); |
| 319 CHECK_ALIVE(return); | 324 CHECK_ALIVE(return); |
| 320 DoComputation(call); | 325 DoComputation(call); |
| 321 } | 326 } |
| 322 | 327 |
| 323 void ValueGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 328 void ValueGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 324 InstanceCallComp* call = TranslateComparison(*node); | 329 Computation* call = TranslateComparison(*node); |
| 325 CHECK_ALIVE(return); | 330 CHECK_ALIVE(return); |
| 326 ReturnValueOf(call); | 331 ReturnValueOf(call); |
| 327 } | 332 } |
| 328 | 333 |
| 329 void TestGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 334 void TestGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 330 InstanceCallComp* call = TranslateComparison(*node); | 335 Computation* call = TranslateComparison(*node); |
| 331 CHECK_ALIVE(return); | 336 CHECK_ALIVE(return); |
| 332 BranchOnValueOf(call); | 337 BranchOnValueOf(call); |
| 333 } | 338 } |
| 334 | 339 |
| 335 | 340 |
| 336 | 341 |
| 337 InstanceCallComp* EffectGraphVisitor::TranslateUnaryOp( | 342 InstanceCallComp* EffectGraphVisitor::TranslateUnaryOp( |
| 338 const UnaryOpNode& node) { | 343 const UnaryOpNode& node) { |
| 339 // "!" cannot be overloaded, therefore do not call operator. | 344 // "!" cannot be overloaded, therefore do not call operator. |
| 340 if (node.kind() == Token::kNOT) { | 345 if (node.kind() == Token::kNOT) { |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 Bailout("EffectGraphVisitor::VisitClosureNode"); | 548 Bailout("EffectGraphVisitor::VisitClosureNode"); |
| 544 } | 549 } |
| 545 void ValueGraphVisitor::VisitClosureNode(ClosureNode* node) { | 550 void ValueGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 546 Bailout("ValueGraphVisitor::VisitClosureNode"); | 551 Bailout("ValueGraphVisitor::VisitClosureNode"); |
| 547 } | 552 } |
| 548 void TestGraphVisitor::VisitClosureNode(ClosureNode* node) { | 553 void TestGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 549 Bailout("TestGraphVisitor::VisitClosureNode"); | 554 Bailout("TestGraphVisitor::VisitClosureNode"); |
| 550 } | 555 } |
| 551 | 556 |
| 552 | 557 |
| 558 InstanceCallComp* EffectGraphVisitor::TranslateInstanceCall( |
| 559 const InstanceCallNode& node) { |
| 560 ArgumentListNode* arguments = node.arguments(); |
| 561 int length = arguments->length(); |
| 562 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1); |
| 563 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 564 node.receiver()->Visit(&for_receiver); |
| 565 Append(for_receiver); |
| 566 CHECK_ALIVE(return NULL); |
| 567 values->Add(for_receiver.value()); |
| 568 int index = temp_index(); |
| 569 for (intptr_t i = 0; i < length; ++i) { |
| 570 ValueGraphVisitor for_value(owner(), index); |
| 571 arguments->NodeAt(i)->Visit(&for_value); |
| 572 Append(for_value); |
| 573 CHECK_ALIVE(return NULL); |
| 574 values->Add(for_value.value()); |
| 575 index = for_value.temp_index(); |
| 576 } |
| 577 return new InstanceCallComp(node.function_name().ToCString(), values); |
| 578 } |
| 579 |
| 580 |
| 553 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 581 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 554 Bailout("EffectGraphVisitor::VisitInstanceCallNode"); | 582 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 583 CHECK_ALIVE(return); |
| 584 DoComputation(call); |
| 555 } | 585 } |
| 556 void ValueGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 586 void ValueGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 557 Bailout("ValueGraphVisitor::VisitInstanceCallNode"); | 587 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 588 CHECK_ALIVE(return); |
| 589 ReturnValueOf(call); |
| 558 } | 590 } |
| 559 void TestGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 591 void TestGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 560 Bailout("TestGraphVisitor::VisitInstanceCallNode"); | 592 InstanceCallComp* call = TranslateInstanceCall(*node); |
| 593 CHECK_ALIVE(return); |
| 594 BranchOnValueOf(call); |
| 561 } | 595 } |
| 562 | 596 |
| 563 | 597 |
| 564 // <Expression> ::= StaticCall { function: Function | 598 // <Expression> ::= StaticCall { function: Function |
| 565 // arguments: <ArgumentList> } | 599 // arguments: <ArgumentList> } |
| 566 StaticCallComp* EffectGraphVisitor::TranslateStaticCall( | 600 StaticCallComp* EffectGraphVisitor::TranslateStaticCall( |
| 567 const StaticCallNode& node) { | 601 const StaticCallNode& node) { |
| 568 ArgumentListNode* arguments = node.arguments(); | 602 ArgumentListNode* arguments = node.arguments(); |
| 569 int length = arguments->length(); | 603 int length = arguments->length(); |
| 570 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length); | 604 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*>( | 1022 char* chars = reinterpret_cast<char*>( |
| 989 Isolate::Current()->current_zone()->Allocate(len)); | 1023 Isolate::Current()->current_zone()->Allocate(len)); |
| 990 OS::SNPrint(chars, len, kFormat, reason); | 1024 OS::SNPrint(chars, len, kFormat, reason); |
| 991 const Error& error = Error::Handle( | 1025 const Error& error = Error::Handle( |
| 992 LanguageError::New(String::Handle(String::New(chars)))); | 1026 LanguageError::New(String::Handle(String::New(chars)))); |
| 993 Isolate::Current()->long_jump_base()->Jump(1, error); | 1027 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 994 } | 1028 } |
| 995 | 1029 |
| 996 | 1030 |
| 997 } // namespace dart | 1031 } // namespace dart |
| OLD | NEW |