| 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/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 : parsed_function_(parsed_function), | 33 : parsed_function_(parsed_function), |
| 34 copied_parameter_count_(parsed_function.copied_parameter_count()), | 34 copied_parameter_count_(parsed_function.copied_parameter_count()), |
| 35 // All parameters are copied if any parameter is. | 35 // All parameters are copied if any parameter is. |
| 36 non_copied_parameter_count_((copied_parameter_count_ == 0) | 36 non_copied_parameter_count_((copied_parameter_count_ == 0) |
| 37 ? parsed_function.function().num_fixed_parameters() | 37 ? parsed_function.function().num_fixed_parameters() |
| 38 : 0), | 38 : 0), |
| 39 stack_local_count_(parsed_function.stack_local_count()), | 39 stack_local_count_(parsed_function.stack_local_count()), |
| 40 context_level_(0), | 40 context_level_(0), |
| 41 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), | 41 last_used_try_index_(CatchClauseNode::kInvalidTryIndex), |
| 42 try_index_(CatchClauseNode::kInvalidTryIndex), | 42 try_index_(CatchClauseNode::kInvalidTryIndex), |
| 43 graph_entry_(NULL) { } | 43 graph_entry_(NULL), |
| 44 inlining_context_(kNotInlining), |
| 45 exits_(NULL) { } |
| 44 | 46 |
| 45 | 47 |
| 46 void FlowGraphBuilder::AddCatchEntry(TargetEntryInstr* entry) { | 48 void FlowGraphBuilder::AddCatchEntry(TargetEntryInstr* entry) { |
| 47 graph_entry_->AddCatchEntry(entry); | 49 graph_entry_->AddCatchEntry(entry); |
| 48 } | 50 } |
| 49 | 51 |
| 50 | 52 |
| 51 void EffectGraphVisitor::Append(const EffectGraphVisitor& other_fragment) { | 53 void EffectGraphVisitor::Append(const EffectGraphVisitor& other_fragment) { |
| 52 ASSERT(is_open()); | 54 ASSERT(is_open()); |
| 53 if (other_fragment.is_empty()) return; | 55 if (other_fragment.is_empty()) return; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 334 } |
| 333 ReturnValue(Bind(computation)); | 335 ReturnValue(Bind(computation)); |
| 334 } | 336 } |
| 335 | 337 |
| 336 | 338 |
| 337 void EffectGraphVisitor::Bailout(const char* reason) { | 339 void EffectGraphVisitor::Bailout(const char* reason) { |
| 338 owner()->Bailout(reason); | 340 owner()->Bailout(reason); |
| 339 } | 341 } |
| 340 | 342 |
| 341 | 343 |
| 344 void EffectGraphVisitor::InlineBailout(const char* reason) { |
| 345 if (owner()->InInliningContext()) owner()->Bailout(reason); |
| 346 } |
| 347 |
| 348 |
| 342 // <Statement> ::= Return { value: <Expression> | 349 // <Statement> ::= Return { value: <Expression> |
| 343 // inlined_finally_list: <InlinedFinally>* } | 350 // inlined_finally_list: <InlinedFinally>* } |
| 344 void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) { | 351 void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) { |
| 345 ValueGraphVisitor for_value(owner(), temp_index()); | 352 ValueGraphVisitor for_value(owner(), temp_index()); |
| 346 node->value()->Visit(&for_value); | 353 node->value()->Visit(&for_value); |
| 347 Append(for_value); | 354 Append(for_value); |
| 348 | 355 |
| 349 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { | 356 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { |
| 357 InlineBailout("EffectGraphVisitor::VisitReturnNode (finally)"); |
| 350 EffectGraphVisitor for_effect(owner(), temp_index()); | 358 EffectGraphVisitor for_effect(owner(), temp_index()); |
| 351 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); | 359 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); |
| 352 Append(for_effect); | 360 Append(for_effect); |
| 353 if (!is_open()) return; | 361 if (!is_open()) return; |
| 354 } | 362 } |
| 355 | 363 |
| 356 Value* return_value = for_value.value(); | 364 Value* return_value = for_value.value(); |
| 357 if (FLAG_enable_type_checks) { | 365 if (FLAG_enable_type_checks) { |
| 366 InlineBailout("EffectGraphVisitor::VisitReturnNode (type check)"); |
| 358 const Function& function = owner()->parsed_function().function(); | 367 const Function& function = owner()->parsed_function().function(); |
| 359 const bool is_implicit_dynamic_getter = | 368 const bool is_implicit_dynamic_getter = |
| 360 (!function.is_static() && | 369 (!function.is_static() && |
| 361 ((function.kind() == RawFunction::kImplicitGetter) || | 370 ((function.kind() == RawFunction::kImplicitGetter) || |
| 362 (function.kind() == RawFunction::kConstImplicitGetter))); | 371 (function.kind() == RawFunction::kConstImplicitGetter))); |
| 363 // Implicit getters do not need a type check at return, unless they compute | 372 // Implicit getters do not need a type check at return, unless they compute |
| 364 // the initial value of a static field. | 373 // the initial value of a static field. |
| 365 // The body of a constructor cannot modify the type of the | 374 // The body of a constructor cannot modify the type of the |
| 366 // constructed instance, which is passed in as an implicit parameter. | 375 // constructed instance, which is passed in as an implicit parameter. |
| 367 // However, factories may create an instance of the wrong type. | 376 // However, factories may create an instance of the wrong type. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 382 ASSERT(current_context_level >= 0); | 391 ASSERT(current_context_level >= 0); |
| 383 if (owner()->parsed_function().saved_context_var() != NULL) { | 392 if (owner()->parsed_function().saved_context_var() != NULL) { |
| 384 // CTX on entry was saved, but not linked as context parent. | 393 // CTX on entry was saved, but not linked as context parent. |
| 385 BuildLoadContext(*owner()->parsed_function().saved_context_var()); | 394 BuildLoadContext(*owner()->parsed_function().saved_context_var()); |
| 386 } else { | 395 } else { |
| 387 while (current_context_level-- > 0) { | 396 while (current_context_level-- > 0) { |
| 388 UnchainContext(); | 397 UnchainContext(); |
| 389 } | 398 } |
| 390 } | 399 } |
| 391 | 400 |
| 392 AddInstruction(new ReturnInstr(node->token_pos(), return_value)); | 401 ReturnInstr* return_instr = new ReturnInstr(node->token_pos(), return_value); |
| 402 AddReturnExit(return_instr); |
| 403 AddInstruction(return_instr); |
| 393 CloseFragment(); | 404 CloseFragment(); |
| 394 } | 405 } |
| 395 | 406 |
| 396 | 407 |
| 397 // <Expression> ::= Literal { literal: Instance } | 408 // <Expression> ::= Literal { literal: Instance } |
| 398 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { | 409 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { |
| 399 return; | 410 return; |
| 400 } | 411 } |
| 401 | 412 |
| 402 | 413 |
| 403 void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) { | 414 void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) { |
| 404 ReturnComputation(new ConstantComp(node->literal())); | 415 ReturnComputation(new ConstantComp(node->literal())); |
| 405 } | 416 } |
| 406 | 417 |
| 407 | 418 |
| 408 // Type nodes only occur as the right-hand side of instanceof comparisons, | 419 // Type nodes only occur as the right-hand side of instanceof comparisons, |
| 409 // and they are handled specially in that context. | 420 // and they are handled specially in that context. |
| 410 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } | 421 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } |
| 411 | 422 |
| 412 | 423 |
| 413 // Returns true if the type check can be skipped, for example, if the | 424 // Returns true if the type check can be skipped, for example, if the |
| 414 // destination type is Dynamic or if the compile type of the value is a subtype | 425 // destination type is Dynamic or if the compile type of the value is a subtype |
| 415 // of the destination type. | 426 // of the destination type. |
| 416 bool EffectGraphVisitor::CanSkipTypeCheck(intptr_t token_pos, | 427 bool EffectGraphVisitor::CanSkipTypeCheck(intptr_t token_pos, |
| 417 Value* value, | 428 Value* value, |
| 418 const AbstractType& dst_type, | 429 const AbstractType& dst_type, |
| 419 const String& dst_name) { | 430 const String& dst_name) { |
| 431 InlineBailout("EffectGraphVisitor::CanSkipTypeCheck"); |
| 420 ASSERT(!dst_type.IsNull()); | 432 ASSERT(!dst_type.IsNull()); |
| 421 ASSERT(dst_type.IsFinalized()); | 433 ASSERT(dst_type.IsFinalized()); |
| 422 | 434 |
| 423 // If the destination type is malformed, a dynamic type error must be thrown | 435 // If the destination type is malformed, a dynamic type error must be thrown |
| 424 // at run time. | 436 // at run time. |
| 425 if (dst_type.IsMalformed()) { | 437 if (dst_type.IsMalformed()) { |
| 426 return false; | 438 return false; |
| 427 } | 439 } |
| 428 | 440 |
| 429 // Any type is more specific than the Dynamic type and than the Object type. | 441 // Any type is more specific than the Dynamic type and than the Object type. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 457 eliminated); | 469 eliminated); |
| 458 } | 470 } |
| 459 return eliminated; | 471 return eliminated; |
| 460 } | 472 } |
| 461 | 473 |
| 462 | 474 |
| 463 // <Expression> :: Assignable { expr: <Expression> | 475 // <Expression> :: Assignable { expr: <Expression> |
| 464 // type: AbstractType | 476 // type: AbstractType |
| 465 // dst_name: String } | 477 // dst_name: String } |
| 466 void EffectGraphVisitor::VisitAssignableNode(AssignableNode* node) { | 478 void EffectGraphVisitor::VisitAssignableNode(AssignableNode* node) { |
| 479 InlineBailout("EffectGraphVisitor::VisitAssignableNode"); |
| 467 UNREACHABLE(); | 480 UNREACHABLE(); |
| 468 } | 481 } |
| 469 | 482 |
| 470 | 483 |
| 471 void ValueGraphVisitor::VisitAssignableNode(AssignableNode* node) { | 484 void ValueGraphVisitor::VisitAssignableNode(AssignableNode* node) { |
| 485 InlineBailout("ValueGraphVisitor::VisitAssignableNode"); |
| 472 ValueGraphVisitor for_value(owner(), temp_index()); | 486 ValueGraphVisitor for_value(owner(), temp_index()); |
| 473 node->expr()->Visit(&for_value); | 487 node->expr()->Visit(&for_value); |
| 474 Append(for_value); | 488 Append(for_value); |
| 475 ReturnValue(BuildAssignableValue(node->expr()->token_pos(), | 489 ReturnValue(BuildAssignableValue(node->expr()->token_pos(), |
| 476 for_value.value(), | 490 for_value.value(), |
| 477 node->type(), | 491 node->type(), |
| 478 node->dst_name())); | 492 node->dst_name())); |
| 479 } | 493 } |
| 480 | 494 |
| 481 | 495 |
| 482 // <Expression> :: BinaryOp { kind: Token::Kind | 496 // <Expression> :: BinaryOp { kind: Token::Kind |
| 483 // left: <Expression> | 497 // left: <Expression> |
| 484 // right: <Expression> } | 498 // right: <Expression> } |
| 485 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { | 499 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { |
| 500 InlineBailout("EffectGraphVisitor::VisitBinaryOpNode"); |
| 486 // Operators "&&" and "||" cannot be overloaded therefore do not call | 501 // Operators "&&" and "||" cannot be overloaded therefore do not call |
| 487 // operator. | 502 // operator. |
| 488 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { | 503 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { |
| 489 // See ValueGraphVisitor::VisitBinaryOpNode. | 504 // See ValueGraphVisitor::VisitBinaryOpNode. |
| 490 TestGraphVisitor for_left(owner(), | 505 TestGraphVisitor for_left(owner(), |
| 491 temp_index(), | 506 temp_index(), |
| 492 node->left()->token_pos()); | 507 node->left()->token_pos()); |
| 493 node->left()->Visit(&for_left); | 508 node->left()->Visit(&for_left); |
| 494 EffectGraphVisitor for_right(owner(), temp_index()); | 509 EffectGraphVisitor for_right(owner(), temp_index()); |
| 495 node->right()->Visit(&for_right); | 510 node->right()->Visit(&for_right); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 521 node->kind(), | 536 node->kind(), |
| 522 arguments, | 537 arguments, |
| 523 Array::ZoneHandle(), | 538 Array::ZoneHandle(), |
| 524 2); | 539 2); |
| 525 ReturnComputation(call); | 540 ReturnComputation(call); |
| 526 } | 541 } |
| 527 | 542 |
| 528 | 543 |
| 529 // Special handling for AND/OR. | 544 // Special handling for AND/OR. |
| 530 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { | 545 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { |
| 546 InlineBailout("ValueGraphVisitor::VisitBinaryOpNode"); |
| 531 // Operators "&&" and "||" cannot be overloaded therefore do not call | 547 // Operators "&&" and "||" cannot be overloaded therefore do not call |
| 532 // operator. | 548 // operator. |
| 533 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { | 549 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { |
| 534 // Implement short-circuit logic: do not evaluate right if evaluation | 550 // Implement short-circuit logic: do not evaluate right if evaluation |
| 535 // of left is sufficient. | 551 // of left is sufficient. |
| 536 // AND: left ? right === true : false; | 552 // AND: left ? right === true : false; |
| 537 // OR: left ? true : right === true; | 553 // OR: left ? true : right === true; |
| 538 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 554 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 539 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); | 555 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); |
| 540 | 556 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 return; | 597 return; |
| 582 } | 598 } |
| 583 EffectGraphVisitor::VisitBinaryOpNode(node); | 599 EffectGraphVisitor::VisitBinaryOpNode(node); |
| 584 } | 600 } |
| 585 | 601 |
| 586 | 602 |
| 587 void EffectGraphVisitor::BuildTypecheckArguments( | 603 void EffectGraphVisitor::BuildTypecheckArguments( |
| 588 intptr_t token_pos, | 604 intptr_t token_pos, |
| 589 Value** instantiator_result, | 605 Value** instantiator_result, |
| 590 Value** instantiator_type_arguments_result) { | 606 Value** instantiator_type_arguments_result) { |
| 607 InlineBailout("EffectGraphVisitor::VisitBinaryOpNode"); |
| 591 Value* instantiator = NULL; | 608 Value* instantiator = NULL; |
| 592 Value* instantiator_type_arguments = NULL; | 609 Value* instantiator_type_arguments = NULL; |
| 593 const Class& instantiator_class = Class::Handle( | 610 const Class& instantiator_class = Class::Handle( |
| 594 owner()->parsed_function().function().Owner()); | 611 owner()->parsed_function().function().Owner()); |
| 595 // Since called only when type tested against is not instantiated. | 612 // Since called only when type tested against is not instantiated. |
| 596 ASSERT(instantiator_class.NumTypeParameters() > 0); | 613 ASSERT(instantiator_class.NumTypeParameters() > 0); |
| 597 instantiator = BuildInstantiator(); | 614 instantiator = BuildInstantiator(); |
| 598 if (instantiator == NULL) { | 615 if (instantiator == NULL) { |
| 599 // No instantiator when inside factory. | 616 // No instantiator when inside factory. |
| 600 instantiator = BuildNullValue(); | 617 instantiator = BuildNullValue(); |
| 601 instantiator_type_arguments = | 618 instantiator_type_arguments = |
| 602 BuildInstantiatorTypeArguments(token_pos, NULL); | 619 BuildInstantiatorTypeArguments(token_pos, NULL); |
| 603 } else { | 620 } else { |
| 604 // Preserve instantiator. | 621 // Preserve instantiator. |
| 605 const LocalVariable& expr_temp = | 622 const LocalVariable& expr_temp = |
| 606 *owner()->parsed_function().expression_temp_var(); | 623 *owner()->parsed_function().expression_temp_var(); |
| 607 instantiator = Bind(BuildStoreLocal(expr_temp, instantiator)); | 624 instantiator = Bind(BuildStoreLocal(expr_temp, instantiator)); |
| 608 Value* loaded = Bind(BuildLoadLocal(expr_temp)); | 625 Value* loaded = Bind(BuildLoadLocal(expr_temp)); |
| 609 instantiator_type_arguments = | 626 instantiator_type_arguments = |
| 610 BuildInstantiatorTypeArguments(token_pos, loaded); | 627 BuildInstantiatorTypeArguments(token_pos, loaded); |
| 611 } | 628 } |
| 612 *instantiator_result = instantiator; | 629 *instantiator_result = instantiator; |
| 613 *instantiator_type_arguments_result = instantiator_type_arguments; | 630 *instantiator_type_arguments_result = instantiator_type_arguments; |
| 614 } | 631 } |
| 615 | 632 |
| 616 | 633 |
| 617 Value* EffectGraphVisitor::BuildNullValue() { | 634 Value* EffectGraphVisitor::BuildNullValue() { |
| 635 InlineBailout("EffectGraphVisitor::BuildNullValue"); |
| 618 return Bind(new ConstantComp(Object::ZoneHandle())); | 636 return Bind(new ConstantComp(Object::ZoneHandle())); |
| 619 } | 637 } |
| 620 | 638 |
| 621 | 639 |
| 622 // Used for testing incoming arguments. | 640 // Used for testing incoming arguments. |
| 623 AssertAssignableComp* EffectGraphVisitor::BuildAssertAssignable( | 641 AssertAssignableComp* EffectGraphVisitor::BuildAssertAssignable( |
| 624 intptr_t token_pos, | 642 intptr_t token_pos, |
| 625 Value* value, | 643 Value* value, |
| 626 const AbstractType& dst_type, | 644 const AbstractType& dst_type, |
| 627 const String& dst_name) { | 645 const String& dst_name) { |
| 646 InlineBailout("EffectGraphVisitor::BuildAssertAssignable"); |
| 628 // Build the type check computation. | 647 // Build the type check computation. |
| 629 Value* instantiator = NULL; | 648 Value* instantiator = NULL; |
| 630 Value* instantiator_type_arguments = NULL; | 649 Value* instantiator_type_arguments = NULL; |
| 631 if (dst_type.IsInstantiated()) { | 650 if (dst_type.IsInstantiated()) { |
| 632 instantiator = BuildNullValue(); | 651 instantiator = BuildNullValue(); |
| 633 instantiator_type_arguments = BuildNullValue(); | 652 instantiator_type_arguments = BuildNullValue(); |
| 634 } else { | 653 } else { |
| 635 BuildTypecheckArguments(token_pos, | 654 BuildTypecheckArguments(token_pos, |
| 636 &instantiator, | 655 &instantiator, |
| 637 &instantiator_type_arguments); | 656 &instantiator_type_arguments); |
| 638 } | 657 } |
| 639 return new AssertAssignableComp(token_pos, | 658 return new AssertAssignableComp(token_pos, |
| 640 value, | 659 value, |
| 641 instantiator, | 660 instantiator, |
| 642 instantiator_type_arguments, | 661 instantiator_type_arguments, |
| 643 dst_type, | 662 dst_type, |
| 644 dst_name); | 663 dst_name); |
| 645 } | 664 } |
| 646 | 665 |
| 647 | 666 |
| 648 // Used for type casts and to test assignments. | 667 // Used for type casts and to test assignments. |
| 649 Value* EffectGraphVisitor::BuildAssignableValue(intptr_t token_pos, | 668 Value* EffectGraphVisitor::BuildAssignableValue(intptr_t token_pos, |
| 650 Value* value, | 669 Value* value, |
| 651 const AbstractType& dst_type, | 670 const AbstractType& dst_type, |
| 652 const String& dst_name) { | 671 const String& dst_name) { |
| 672 InlineBailout("EffectGraphVisitor::BuildAssignableValue"); |
| 653 if (CanSkipTypeCheck(token_pos, value, dst_type, dst_name)) { | 673 if (CanSkipTypeCheck(token_pos, value, dst_type, dst_name)) { |
| 654 return value; | 674 return value; |
| 655 } | 675 } |
| 656 return Bind(BuildAssertAssignable(token_pos, value, dst_type, dst_name)); | 676 return Bind(BuildAssertAssignable(token_pos, value, dst_type, dst_name)); |
| 657 } | 677 } |
| 658 | 678 |
| 659 | 679 |
| 660 void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) { | 680 void EffectGraphVisitor::BuildTypeTest(ComparisonNode* node) { |
| 681 InlineBailout("EffectGraphVisitor::BuildTypeTest"); |
| 661 ASSERT(Token::IsTypeTestOperator(node->kind())); | 682 ASSERT(Token::IsTypeTestOperator(node->kind())); |
| 662 EffectGraphVisitor for_left_value(owner(), temp_index()); | 683 EffectGraphVisitor for_left_value(owner(), temp_index()); |
| 663 node->left()->Visit(&for_left_value); | 684 node->left()->Visit(&for_left_value); |
| 664 Append(for_left_value); | 685 Append(for_left_value); |
| 665 } | 686 } |
| 666 | 687 |
| 667 | 688 |
| 668 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { | 689 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { |
| 690 InlineBailout("EffectGraphVisitor::BuildTypeCast"); |
| 669 ASSERT(Token::IsTypeCastOperator(node->kind())); | 691 ASSERT(Token::IsTypeCastOperator(node->kind())); |
| 670 const AbstractType& type = node->right()->AsTypeNode()->type(); | 692 const AbstractType& type = node->right()->AsTypeNode()->type(); |
| 671 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed. | 693 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed. |
| 672 ValueGraphVisitor for_value(owner(), temp_index()); | 694 ValueGraphVisitor for_value(owner(), temp_index()); |
| 673 node->left()->Visit(&for_value); | 695 node->left()->Visit(&for_value); |
| 674 Append(for_value); | 696 Append(for_value); |
| 675 const String& dst_name = String::ZoneHandle( | 697 const String& dst_name = String::ZoneHandle( |
| 676 Symbols::New(Exceptions::kCastExceptionDstName)); | 698 Symbols::New(Exceptions::kCastExceptionDstName)); |
| 677 if (!CanSkipTypeCheck(node->token_pos(), for_value.value(), type, dst_name)) { | 699 if (!CanSkipTypeCheck(node->token_pos(), for_value.value(), type, dst_name)) { |
| 678 Do(BuildAssertAssignable( | 700 Do(BuildAssertAssignable( |
| 679 node->token_pos(), for_value.value(), type, dst_name)); | 701 node->token_pos(), for_value.value(), type, dst_name)); |
| 680 } | 702 } |
| 681 } | 703 } |
| 682 | 704 |
| 683 | 705 |
| 684 void ValueGraphVisitor::BuildTypeTest(ComparisonNode* node) { | 706 void ValueGraphVisitor::BuildTypeTest(ComparisonNode* node) { |
| 707 InlineBailout("ValueGraphVisitor::BuildTypeTest"); |
| 685 ASSERT(Token::IsTypeTestOperator(node->kind())); | 708 ASSERT(Token::IsTypeTestOperator(node->kind())); |
| 686 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 709 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 687 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); | 710 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); |
| 688 const AbstractType& type = node->right()->AsTypeNode()->type(); | 711 const AbstractType& type = node->right()->AsTypeNode()->type(); |
| 689 ASSERT(type.IsFinalized() && !type.IsMalformed()); | 712 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
| 690 const bool negate_result = (node->kind() == Token::kISNOT); | 713 const bool negate_result = (node->kind() == Token::kISNOT); |
| 691 // All objects are instances of type T if Object type is a subtype of type T. | 714 // All objects are instances of type T if Object type is a subtype of type T. |
| 692 const Type& object_type = Type::Handle(Type::ObjectType()); | 715 const Type& object_type = Type::Handle(Type::ObjectType()); |
| 693 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { | 716 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { |
| 694 // Must evaluate left side. | 717 // Must evaluate left side. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 for_left_value.value(), | 764 for_left_value.value(), |
| 742 instantiator, | 765 instantiator, |
| 743 instantiator_type_arguments, | 766 instantiator_type_arguments, |
| 744 node->right()->AsTypeNode()->type(), | 767 node->right()->AsTypeNode()->type(), |
| 745 (node->kind() == Token::kISNOT)); | 768 (node->kind() == Token::kISNOT)); |
| 746 ReturnComputation(instance_of); | 769 ReturnComputation(instance_of); |
| 747 } | 770 } |
| 748 | 771 |
| 749 | 772 |
| 750 void ValueGraphVisitor::BuildTypeCast(ComparisonNode* node) { | 773 void ValueGraphVisitor::BuildTypeCast(ComparisonNode* node) { |
| 774 InlineBailout("ValueGraphVisitor::BuildTypeCast"); |
| 751 ASSERT(Token::IsTypeCastOperator(node->kind())); | 775 ASSERT(Token::IsTypeCastOperator(node->kind())); |
| 752 const AbstractType& type = node->right()->AsTypeNode()->type(); | 776 const AbstractType& type = node->right()->AsTypeNode()->type(); |
| 753 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed. | 777 ASSERT(type.IsFinalized()); // The type in a type cast may be malformed. |
| 754 ValueGraphVisitor for_value(owner(), temp_index()); | 778 ValueGraphVisitor for_value(owner(), temp_index()); |
| 755 node->left()->Visit(&for_value); | 779 node->left()->Visit(&for_value); |
| 756 Append(for_value); | 780 Append(for_value); |
| 757 const String& dst_name = String::ZoneHandle( | 781 const String& dst_name = String::ZoneHandle( |
| 758 Symbols::New(Exceptions::kCastExceptionDstName)); | 782 Symbols::New(Exceptions::kCastExceptionDstName)); |
| 759 ReturnValue(BuildAssignableValue(node->token_pos(), | 783 ReturnValue(BuildAssignableValue(node->token_pos(), |
| 760 for_value.value(), | 784 for_value.value(), |
| 761 type, | 785 type, |
| 762 dst_name)); | 786 dst_name)); |
| 763 } | 787 } |
| 764 | 788 |
| 765 | 789 |
| 766 // <Expression> :: Comparison { kind: Token::Kind | 790 // <Expression> :: Comparison { kind: Token::Kind |
| 767 // left: <Expression> | 791 // left: <Expression> |
| 768 // right: <Expression> } | 792 // right: <Expression> } |
| 769 // TODO(srdjan): Implement new equality. | 793 // TODO(srdjan): Implement new equality. |
| 770 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { | 794 void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) { |
| 795 InlineBailout("EffectGraphVisitor::VisitComparisonNode"); |
| 771 if (Token::IsTypeTestOperator(node->kind())) { | 796 if (Token::IsTypeTestOperator(node->kind())) { |
| 772 BuildTypeTest(node); | 797 BuildTypeTest(node); |
| 773 return; | 798 return; |
| 774 } | 799 } |
| 775 if (Token::IsTypeCastOperator(node->kind())) { | 800 if (Token::IsTypeCastOperator(node->kind())) { |
| 776 BuildTypeCast(node); | 801 BuildTypeCast(node); |
| 777 return; | 802 return; |
| 778 } | 803 } |
| 779 if ((node->kind() == Token::kEQ_STRICT) || | 804 if ((node->kind() == Token::kEQ_STRICT) || |
| 780 (node->kind() == Token::kNE_STRICT)) { | 805 (node->kind() == Token::kNE_STRICT)) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 Append(for_right_value); | 854 Append(for_right_value); |
| 830 RelationalOpComp* comp = new RelationalOpComp(node->token_pos(), | 855 RelationalOpComp* comp = new RelationalOpComp(node->token_pos(), |
| 831 node->kind(), | 856 node->kind(), |
| 832 for_left_value.value(), | 857 for_left_value.value(), |
| 833 for_right_value.value()); | 858 for_right_value.value()); |
| 834 ReturnComputation(comp); | 859 ReturnComputation(comp); |
| 835 } | 860 } |
| 836 | 861 |
| 837 | 862 |
| 838 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { | 863 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { |
| 864 InlineBailout("EffectGraphVisitor::VisitUnaryOpNode"); |
| 839 // "!" cannot be overloaded, therefore do not call operator. | 865 // "!" cannot be overloaded, therefore do not call operator. |
| 840 if (node->kind() == Token::kNOT) { | 866 if (node->kind() == Token::kNOT) { |
| 841 ValueGraphVisitor for_value(owner(), temp_index()); | 867 ValueGraphVisitor for_value(owner(), temp_index()); |
| 842 node->operand()->Visit(&for_value); | 868 node->operand()->Visit(&for_value); |
| 843 Append(for_value); | 869 Append(for_value); |
| 844 Value* value = for_value.value(); | 870 Value* value = for_value.value(); |
| 845 if (FLAG_enable_type_checks) { | 871 if (FLAG_enable_type_checks) { |
| 846 value = | 872 value = |
| 847 Bind(new AssertBooleanComp(node->operand()->token_pos(), value)); | 873 Bind(new AssertBooleanComp(node->operand()->token_pos(), value)); |
| 848 } | 874 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 864 name = Symbols::New(Token::Str(node->kind())); | 890 name = Symbols::New(Token::Str(node->kind())); |
| 865 } | 891 } |
| 866 InstanceCallComp* call = new InstanceCallComp( | 892 InstanceCallComp* call = new InstanceCallComp( |
| 867 node->token_pos(), name, node->kind(), | 893 node->token_pos(), name, node->kind(), |
| 868 arguments, Array::ZoneHandle(), 1); | 894 arguments, Array::ZoneHandle(), 1); |
| 869 ReturnComputation(call); | 895 ReturnComputation(call); |
| 870 } | 896 } |
| 871 | 897 |
| 872 | 898 |
| 873 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { | 899 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { |
| 900 InlineBailout("EffectGraphVisitor::VisitConditionalExprNode"); |
| 874 TestGraphVisitor for_test(owner(), | 901 TestGraphVisitor for_test(owner(), |
| 875 temp_index(), | 902 temp_index(), |
| 876 node->condition()->token_pos()); | 903 node->condition()->token_pos()); |
| 877 node->condition()->Visit(&for_test); | 904 node->condition()->Visit(&for_test); |
| 878 | 905 |
| 879 // Translate the subexpressions for their effects. | 906 // Translate the subexpressions for their effects. |
| 880 EffectGraphVisitor for_true(owner(), temp_index()); | 907 EffectGraphVisitor for_true(owner(), temp_index()); |
| 881 node->true_expr()->Visit(&for_true); | 908 node->true_expr()->Visit(&for_true); |
| 882 EffectGraphVisitor for_false(owner(), temp_index()); | 909 EffectGraphVisitor for_false(owner(), temp_index()); |
| 883 node->false_expr()->Visit(&for_false); | 910 node->false_expr()->Visit(&for_false); |
| 884 | 911 |
| 885 Join(for_test, for_true, for_false); | 912 Join(for_test, for_true, for_false); |
| 886 } | 913 } |
| 887 | 914 |
| 888 | 915 |
| 889 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { | 916 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { |
| 917 InlineBailout("ValueGraphVisitor::VisitConditionalExprNode"); |
| 890 TestGraphVisitor for_test(owner(), | 918 TestGraphVisitor for_test(owner(), |
| 891 temp_index(), | 919 temp_index(), |
| 892 node->condition()->token_pos()); | 920 node->condition()->token_pos()); |
| 893 node->condition()->Visit(&for_test); | 921 node->condition()->Visit(&for_test); |
| 894 | 922 |
| 895 ValueGraphVisitor for_true(owner(), temp_index()); | 923 ValueGraphVisitor for_true(owner(), temp_index()); |
| 896 node->true_expr()->Visit(&for_true); | 924 node->true_expr()->Visit(&for_true); |
| 897 ASSERT(for_true.is_open()); | 925 ASSERT(for_true.is_open()); |
| 898 for_true.Do(BuildStoreLocal( | 926 for_true.Do(BuildStoreLocal( |
| 899 *owner()->parsed_function().expression_temp_var(), for_true.value())); | 927 *owner()->parsed_function().expression_temp_var(), for_true.value())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 924 | 952 |
| 925 node->true_branch()->Visit(&for_true); | 953 node->true_branch()->Visit(&for_true); |
| 926 // The for_false graph fragment will be empty (default graph fragment) if | 954 // The for_false graph fragment will be empty (default graph fragment) if |
| 927 // we do not call Visit. | 955 // we do not call Visit. |
| 928 if (node->false_branch() != NULL) node->false_branch()->Visit(&for_false); | 956 if (node->false_branch() != NULL) node->false_branch()->Visit(&for_false); |
| 929 Join(for_test, for_true, for_false); | 957 Join(for_test, for_true, for_false); |
| 930 } | 958 } |
| 931 | 959 |
| 932 | 960 |
| 933 void EffectGraphVisitor::VisitSwitchNode(SwitchNode* node) { | 961 void EffectGraphVisitor::VisitSwitchNode(SwitchNode* node) { |
| 962 InlineBailout("EffectGraphVisitor::VisitSwitchNode"); |
| 934 EffectGraphVisitor switch_body(owner(), temp_index()); | 963 EffectGraphVisitor switch_body(owner(), temp_index()); |
| 935 node->body()->Visit(&switch_body); | 964 node->body()->Visit(&switch_body); |
| 936 Append(switch_body); | 965 Append(switch_body); |
| 937 if ((node->label() != NULL) && (node->label()->join_for_break() != NULL)) { | 966 if ((node->label() != NULL) && (node->label()->join_for_break() != NULL)) { |
| 938 if (is_open()) Goto(node->label()->join_for_break()); | 967 if (is_open()) Goto(node->label()->join_for_break()); |
| 939 exit_ = node->label()->join_for_break(); | 968 exit_ = node->label()->join_for_break(); |
| 940 } | 969 } |
| 941 // No continue label allowed. | 970 // No continue label allowed. |
| 942 ASSERT((node->label() == NULL) || | 971 ASSERT((node->label() == NULL) || |
| 943 (node->label()->join_for_continue() == NULL)); | 972 (node->label()->join_for_continue() == NULL)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 959 // e) true-target-0 -> case-statements-join | 988 // e) true-target-0 -> case-statements-join |
| 960 // f) true-target-1 -> case-statements-join | 989 // f) true-target-1 -> case-statements-join |
| 961 // g) case-statements-join | 990 // g) case-statements-join |
| 962 // h) [ case-statements ] -> exit-join | 991 // h) [ case-statements ] -> exit-join |
| 963 // i) exit-target -> exit-join | 992 // i) exit-target -> exit-join |
| 964 // j) exit-join | 993 // j) exit-join |
| 965 // | 994 // |
| 966 // Note: The specification of switch/case is under discussion and may change | 995 // Note: The specification of switch/case is under discussion and may change |
| 967 // drastically. | 996 // drastically. |
| 968 void EffectGraphVisitor::VisitCaseNode(CaseNode* node) { | 997 void EffectGraphVisitor::VisitCaseNode(CaseNode* node) { |
| 998 InlineBailout("EffectGraphVisitor::VisitCaseNode"); |
| 969 const intptr_t len = node->case_expressions()->length(); | 999 const intptr_t len = node->case_expressions()->length(); |
| 970 // Create case statements instructions. | 1000 // Create case statements instructions. |
| 971 EffectGraphVisitor for_case_statements(owner(), temp_index()); | 1001 EffectGraphVisitor for_case_statements(owner(), temp_index()); |
| 972 // Compute start of statements fragment. | 1002 // Compute start of statements fragment. |
| 973 JoinEntryInstr* statement_start = NULL; | 1003 JoinEntryInstr* statement_start = NULL; |
| 974 if ((node->label() != NULL) && node->label()->is_continue_target()) { | 1004 if ((node->label() != NULL) && node->label()->is_continue_target()) { |
| 975 // Since a labeled jump continue statement occur in a different case node, | 1005 // Since a labeled jump continue statement occur in a different case node, |
| 976 // allocate JoinNode here and use it as statement start. | 1006 // allocate JoinNode here and use it as statement start. |
| 977 statement_start = node->label()->join_for_continue(); | 1007 statement_start = node->label()->join_for_continue(); |
| 978 if (statement_start == NULL) { | 1008 if (statement_start == NULL) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 // body: <Sequence> } | 1088 // body: <Sequence> } |
| 1059 // The fragment is composed as follows: | 1089 // The fragment is composed as follows: |
| 1060 // a) loop-join | 1090 // a) loop-join |
| 1061 // b) [ test ] -> (body-entry-target, loop-exit-target) | 1091 // b) [ test ] -> (body-entry-target, loop-exit-target) |
| 1062 // c) body-entry-target | 1092 // c) body-entry-target |
| 1063 // d) [ body ] -> (continue-join) | 1093 // d) [ body ] -> (continue-join) |
| 1064 // e) continue-join -> (loop-join) | 1094 // e) continue-join -> (loop-join) |
| 1065 // f) loop-exit-target | 1095 // f) loop-exit-target |
| 1066 // g) break-join (optional) | 1096 // g) break-join (optional) |
| 1067 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { | 1097 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { |
| 1098 InlineBailout("EffectGraphVisitor::VisitWhileNode"); |
| 1068 TestGraphVisitor for_test(owner(), | 1099 TestGraphVisitor for_test(owner(), |
| 1069 temp_index(), | 1100 temp_index(), |
| 1070 node->condition()->token_pos()); | 1101 node->condition()->token_pos()); |
| 1071 node->condition()->Visit(&for_test); | 1102 node->condition()->Visit(&for_test); |
| 1072 ASSERT(!for_test.is_empty()); // Language spec. | 1103 ASSERT(!for_test.is_empty()); // Language spec. |
| 1073 | 1104 |
| 1074 EffectGraphVisitor for_body(owner(), temp_index()); | 1105 EffectGraphVisitor for_body(owner(), temp_index()); |
| 1075 for_body.Do( | 1106 for_body.Do( |
| 1076 new CheckStackOverflowComp(node->token_pos())); | 1107 new CheckStackOverflowComp(node->token_pos())); |
| 1077 node->body()->Visit(&for_body); | 1108 node->body()->Visit(&for_body); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1095 | 1126 |
| 1096 // The fragment is composed as follows: | 1127 // The fragment is composed as follows: |
| 1097 // a) body-entry-join | 1128 // a) body-entry-join |
| 1098 // b) [ body ] | 1129 // b) [ body ] |
| 1099 // c) test-entry (continue-join or body-exit-target) | 1130 // c) test-entry (continue-join or body-exit-target) |
| 1100 // d) [ test-entry ] -> (back-target, loop-exit-target) | 1131 // d) [ test-entry ] -> (back-target, loop-exit-target) |
| 1101 // e) back-target -> (body-entry-join) | 1132 // e) back-target -> (body-entry-join) |
| 1102 // f) loop-exit-target | 1133 // f) loop-exit-target |
| 1103 // g) break-join | 1134 // g) break-join |
| 1104 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { | 1135 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { |
| 1136 InlineBailout("EffectGraphVisitor::VisitDoWhileNode"); |
| 1105 // Traverse body first in order to generate continue and break labels. | 1137 // Traverse body first in order to generate continue and break labels. |
| 1106 EffectGraphVisitor for_body(owner(), temp_index()); | 1138 EffectGraphVisitor for_body(owner(), temp_index()); |
| 1107 for_body.Do( | 1139 for_body.Do( |
| 1108 new CheckStackOverflowComp(node->token_pos())); | 1140 new CheckStackOverflowComp(node->token_pos())); |
| 1109 node->body()->Visit(&for_body); | 1141 node->body()->Visit(&for_body); |
| 1110 | 1142 |
| 1111 TestGraphVisitor for_test(owner(), | 1143 TestGraphVisitor for_test(owner(), |
| 1112 temp_index(), | 1144 temp_index(), |
| 1113 node->condition()->token_pos()); | 1145 node->condition()->token_pos()); |
| 1114 node->condition()->Visit(&for_test); | 1146 node->condition()->Visit(&for_test); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 // a) [ initializer ] | 1182 // a) [ initializer ] |
| 1151 // b) loop-join | 1183 // b) loop-join |
| 1152 // c) [ test ] -> (body-entry-target, loop-exit-target) | 1184 // c) [ test ] -> (body-entry-target, loop-exit-target) |
| 1153 // d) body-entry-target | 1185 // d) body-entry-target |
| 1154 // e) [ body ] | 1186 // e) [ body ] |
| 1155 // f) continue-join (optional) | 1187 // f) continue-join (optional) |
| 1156 // g) [ increment ] -> (loop-join) | 1188 // g) [ increment ] -> (loop-join) |
| 1157 // h) loop-exit-target | 1189 // h) loop-exit-target |
| 1158 // i) break-join | 1190 // i) break-join |
| 1159 void EffectGraphVisitor::VisitForNode(ForNode* node) { | 1191 void EffectGraphVisitor::VisitForNode(ForNode* node) { |
| 1192 InlineBailout("EffectGraphVisitor::VisitForNode"); |
| 1160 EffectGraphVisitor for_initializer(owner(), temp_index()); | 1193 EffectGraphVisitor for_initializer(owner(), temp_index()); |
| 1161 node->initializer()->Visit(&for_initializer); | 1194 node->initializer()->Visit(&for_initializer); |
| 1162 Append(for_initializer); | 1195 Append(for_initializer); |
| 1163 ASSERT(is_open()); | 1196 ASSERT(is_open()); |
| 1164 | 1197 |
| 1165 // Compose body to set any jump labels. | 1198 // Compose body to set any jump labels. |
| 1166 EffectGraphVisitor for_body(owner(), temp_index()); | 1199 EffectGraphVisitor for_body(owner(), temp_index()); |
| 1167 for_body.Do( | 1200 for_body.Do( |
| 1168 new CheckStackOverflowComp(node->token_pos())); | 1201 new CheckStackOverflowComp(node->token_pos())); |
| 1169 node->body()->Visit(&for_body); | 1202 node->body()->Visit(&for_body); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 exit_ = loop_exit; | 1255 exit_ = loop_exit; |
| 1223 } else { | 1256 } else { |
| 1224 loop_exit->Goto(node->label()->join_for_break()); | 1257 loop_exit->Goto(node->label()->join_for_break()); |
| 1225 exit_ = node->label()->join_for_break(); | 1258 exit_ = node->label()->join_for_break(); |
| 1226 } | 1259 } |
| 1227 } | 1260 } |
| 1228 } | 1261 } |
| 1229 | 1262 |
| 1230 | 1263 |
| 1231 void EffectGraphVisitor::VisitJumpNode(JumpNode* node) { | 1264 void EffectGraphVisitor::VisitJumpNode(JumpNode* node) { |
| 1265 InlineBailout("EffectGraphVisitor::VisitJumpNode"); |
| 1232 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { | 1266 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { |
| 1233 EffectGraphVisitor for_effect(owner(), temp_index()); | 1267 EffectGraphVisitor for_effect(owner(), temp_index()); |
| 1234 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); | 1268 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); |
| 1235 Append(for_effect); | 1269 Append(for_effect); |
| 1236 if (!is_open()) return; | 1270 if (!is_open()) return; |
| 1237 } | 1271 } |
| 1238 | 1272 |
| 1239 // Unchain the context(s) up to the outer context level of the scope which | 1273 // Unchain the context(s) up to the outer context level of the scope which |
| 1240 // contains the destination label. | 1274 // contains the destination label. |
| 1241 SourceLabel* label = node->label(); | 1275 SourceLabel* label = node->label(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 node->label()->set_join_for_continue( | 1310 node->label()->set_join_for_continue( |
| 1277 new JoinEntryInstr(owner()->try_index())); | 1311 new JoinEntryInstr(owner()->try_index())); |
| 1278 } | 1312 } |
| 1279 jump_target = node->label()->join_for_continue(); | 1313 jump_target = node->label()->join_for_continue(); |
| 1280 } | 1314 } |
| 1281 Goto(jump_target); | 1315 Goto(jump_target); |
| 1282 } | 1316 } |
| 1283 | 1317 |
| 1284 | 1318 |
| 1285 void EffectGraphVisitor::VisitArgumentListNode(ArgumentListNode* node) { | 1319 void EffectGraphVisitor::VisitArgumentListNode(ArgumentListNode* node) { |
| 1320 InlineBailout("EffectGraphVisitor::VisitArgumentListNode"); |
| 1286 UNREACHABLE(); | 1321 UNREACHABLE(); |
| 1287 } | 1322 } |
| 1288 | 1323 |
| 1289 | 1324 |
| 1290 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) { | 1325 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) { |
| 1326 InlineBailout("EffectGraphVisitor::VisitArrayNode"); |
| 1291 // Translate the array elements and collect their values. | 1327 // Translate the array elements and collect their values. |
| 1292 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1328 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1293 new ZoneGrowableArray<PushArgumentInstr*>(node->length()); | 1329 new ZoneGrowableArray<PushArgumentInstr*>(node->length()); |
| 1294 for (int i = 0; i < node->length(); ++i) { | 1330 for (int i = 0; i < node->length(); ++i) { |
| 1295 ValueGraphVisitor for_value(owner(), temp_index()); | 1331 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1296 node->ElementAt(i)->Visit(&for_value); | 1332 node->ElementAt(i)->Visit(&for_value); |
| 1297 Append(for_value); | 1333 Append(for_value); |
| 1298 arguments->Add(PushArgument(for_value.value())); | 1334 arguments->Add(PushArgument(for_value.value())); |
| 1299 } | 1335 } |
| 1300 const AbstractTypeArguments& type_args = | 1336 const AbstractTypeArguments& type_args = |
| 1301 AbstractTypeArguments::ZoneHandle(node->type().arguments()); | 1337 AbstractTypeArguments::ZoneHandle(node->type().arguments()); |
| 1302 Value* element_type = BuildInstantiatedTypeArguments(node->token_pos(), | 1338 Value* element_type = BuildInstantiatedTypeArguments(node->token_pos(), |
| 1303 type_args); | 1339 type_args); |
| 1304 CreateArrayComp* create = new CreateArrayComp(node->token_pos(), | 1340 CreateArrayComp* create = new CreateArrayComp(node->token_pos(), |
| 1305 arguments, | 1341 arguments, |
| 1306 node->type(), | 1342 node->type(), |
| 1307 element_type); | 1343 element_type); |
| 1308 ReturnComputation(create); | 1344 ReturnComputation(create); |
| 1309 } | 1345 } |
| 1310 | 1346 |
| 1311 | 1347 |
| 1312 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { | 1348 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 1349 InlineBailout("EffectGraphVisitor::VisitClosureNode"); |
| 1313 const Function& function = node->function(); | 1350 const Function& function = node->function(); |
| 1314 | 1351 |
| 1315 Value* receiver = NULL; | 1352 Value* receiver = NULL; |
| 1316 if (function.IsNonImplicitClosureFunction()) { | 1353 if (function.IsNonImplicitClosureFunction()) { |
| 1317 // The context scope may have already been set by the non-optimizing | 1354 // The context scope may have already been set by the non-optimizing |
| 1318 // compiler. If it was not, set it here. | 1355 // compiler. If it was not, set it here. |
| 1319 if (function.context_scope() == ContextScope::null()) { | 1356 if (function.context_scope() == ContextScope::null()) { |
| 1320 const ContextScope& context_scope = ContextScope::ZoneHandle( | 1357 const ContextScope& context_scope = ContextScope::ZoneHandle( |
| 1321 node->scope()->PreserveOuterScope(owner()->context_level())); | 1358 node->scope()->PreserveOuterScope(owner()->context_level())); |
| 1322 ASSERT(!function.HasCode()); | 1359 ASSERT(!function.HasCode()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1352 } | 1389 } |
| 1353 PushArgumentInstr* push_type_arguments = PushArgument(type_arguments); | 1390 PushArgumentInstr* push_type_arguments = PushArgument(type_arguments); |
| 1354 arguments->Add(push_type_arguments); | 1391 arguments->Add(push_type_arguments); |
| 1355 ReturnComputation(new CreateClosureComp(node, arguments)); | 1392 ReturnComputation(new CreateClosureComp(node, arguments)); |
| 1356 } | 1393 } |
| 1357 | 1394 |
| 1358 | 1395 |
| 1359 void EffectGraphVisitor::TranslateArgumentList( | 1396 void EffectGraphVisitor::TranslateArgumentList( |
| 1360 const ArgumentListNode& node, | 1397 const ArgumentListNode& node, |
| 1361 ZoneGrowableArray<Value*>* values) { | 1398 ZoneGrowableArray<Value*>* values) { |
| 1399 InlineBailout("EffectGraphVisitor::TranslateArgumentList"); |
| 1362 for (intptr_t i = 0; i < node.length(); ++i) { | 1400 for (intptr_t i = 0; i < node.length(); ++i) { |
| 1363 ValueGraphVisitor for_argument(owner(), temp_index()); | 1401 ValueGraphVisitor for_argument(owner(), temp_index()); |
| 1364 node.NodeAt(i)->Visit(&for_argument); | 1402 node.NodeAt(i)->Visit(&for_argument); |
| 1365 Append(for_argument); | 1403 Append(for_argument); |
| 1366 values->Add(for_argument.value()); | 1404 values->Add(for_argument.value()); |
| 1367 } | 1405 } |
| 1368 } | 1406 } |
| 1369 | 1407 |
| 1370 | 1408 |
| 1371 void EffectGraphVisitor::BuildPushArguments( | 1409 void EffectGraphVisitor::BuildPushArguments( |
| 1372 const ArgumentListNode& node, | 1410 const ArgumentListNode& node, |
| 1373 ZoneGrowableArray<PushArgumentInstr*>* values) { | 1411 ZoneGrowableArray<PushArgumentInstr*>* values) { |
| 1412 InlineBailout("EffectGraphVisitor::BuildPushArguments"); |
| 1374 for (intptr_t i = 0; i < node.length(); ++i) { | 1413 for (intptr_t i = 0; i < node.length(); ++i) { |
| 1375 ValueGraphVisitor for_argument(owner(), temp_index()); | 1414 ValueGraphVisitor for_argument(owner(), temp_index()); |
| 1376 node.NodeAt(i)->Visit(&for_argument); | 1415 node.NodeAt(i)->Visit(&for_argument); |
| 1377 Append(for_argument); | 1416 Append(for_argument); |
| 1378 PushArgumentInstr* push_arg = PushArgument(for_argument.value()); | 1417 PushArgumentInstr* push_arg = PushArgument(for_argument.value()); |
| 1379 values->Add(push_arg); | 1418 values->Add(push_arg); |
| 1380 } | 1419 } |
| 1381 } | 1420 } |
| 1382 | 1421 |
| 1383 | 1422 |
| 1384 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 1423 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
| 1424 InlineBailout("EffectGraphVisitor::VisitInstanceCallNode"); |
| 1385 ValueGraphVisitor for_receiver(owner(), temp_index()); | 1425 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 1386 node->receiver()->Visit(&for_receiver); | 1426 node->receiver()->Visit(&for_receiver); |
| 1387 Append(for_receiver); | 1427 Append(for_receiver); |
| 1388 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); | 1428 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); |
| 1389 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1429 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1390 new ZoneGrowableArray<PushArgumentInstr*>( | 1430 new ZoneGrowableArray<PushArgumentInstr*>( |
| 1391 node->arguments()->length() + 1); | 1431 node->arguments()->length() + 1); |
| 1392 arguments->Add(push_receiver); | 1432 arguments->Add(push_receiver); |
| 1393 | 1433 |
| 1394 BuildPushArguments(*node->arguments(), arguments); | 1434 BuildPushArguments(*node->arguments(), arguments); |
| 1395 InstanceCallComp* call = new InstanceCallComp( | 1435 InstanceCallComp* call = new InstanceCallComp( |
| 1396 node->token_pos(), | 1436 node->token_pos(), |
| 1397 node->function_name(), Token::kILLEGAL, arguments, | 1437 node->function_name(), Token::kILLEGAL, arguments, |
| 1398 node->arguments()->names(), 1); | 1438 node->arguments()->names(), 1); |
| 1399 ReturnComputation(call); | 1439 ReturnComputation(call); |
| 1400 } | 1440 } |
| 1401 | 1441 |
| 1402 | 1442 |
| 1403 // <Expression> ::= StaticCall { function: Function | 1443 // <Expression> ::= StaticCall { function: Function |
| 1404 // arguments: <ArgumentList> } | 1444 // arguments: <ArgumentList> } |
| 1405 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { | 1445 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { |
| 1446 InlineBailout("EffectGraphVisitor::VisitStaticCallNode"); |
| 1406 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1447 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1407 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); | 1448 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); |
| 1408 BuildPushArguments(*node->arguments(), arguments); | 1449 BuildPushArguments(*node->arguments(), arguments); |
| 1409 StaticCallComp* call = | 1450 StaticCallComp* call = |
| 1410 new StaticCallComp(node->token_pos(), | 1451 new StaticCallComp(node->token_pos(), |
| 1411 node->function(), | 1452 node->function(), |
| 1412 node->arguments()->names(), | 1453 node->arguments()->names(), |
| 1413 arguments); | 1454 arguments); |
| 1414 ReturnComputation(call); | 1455 ReturnComputation(call); |
| 1415 } | 1456 } |
| 1416 | 1457 |
| 1417 | 1458 |
| 1418 ClosureCallComp* EffectGraphVisitor::BuildClosureCall( | 1459 ClosureCallComp* EffectGraphVisitor::BuildClosureCall( |
| 1419 ClosureCallNode* node) { | 1460 ClosureCallNode* node) { |
| 1461 InlineBailout("EffectGraphVisitor::BuildClosureCall"); |
| 1420 ValueGraphVisitor for_closure(owner(), temp_index()); | 1462 ValueGraphVisitor for_closure(owner(), temp_index()); |
| 1421 node->closure()->Visit(&for_closure); | 1463 node->closure()->Visit(&for_closure); |
| 1422 Append(for_closure); | 1464 Append(for_closure); |
| 1423 PushArgumentInstr* push_closure = PushArgument(for_closure.value()); | 1465 PushArgumentInstr* push_closure = PushArgument(for_closure.value()); |
| 1424 | 1466 |
| 1425 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1467 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1426 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); | 1468 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); |
| 1427 arguments->Add(push_closure); | 1469 arguments->Add(push_closure); |
| 1428 BuildPushArguments(*node->arguments(), arguments); | 1470 BuildPushArguments(*node->arguments(), arguments); |
| 1429 | 1471 |
| 1430 // Save context around the call. | 1472 // Save context around the call. |
| 1431 BuildStoreContext(*owner()->parsed_function().expression_temp_var()); | 1473 BuildStoreContext(*owner()->parsed_function().expression_temp_var()); |
| 1432 return new ClosureCallComp(node, arguments); | 1474 return new ClosureCallComp(node, arguments); |
| 1433 } | 1475 } |
| 1434 | 1476 |
| 1435 | 1477 |
| 1436 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { | 1478 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { |
| 1479 InlineBailout("EffectGraphVisitor::VisitClosureCallNode"); |
| 1437 Do(BuildClosureCall(node)); | 1480 Do(BuildClosureCall(node)); |
| 1438 // Restore context from saved location. | 1481 // Restore context from saved location. |
| 1439 BuildLoadContext(*owner()->parsed_function().expression_temp_var()); | 1482 BuildLoadContext(*owner()->parsed_function().expression_temp_var()); |
| 1440 } | 1483 } |
| 1441 | 1484 |
| 1442 | 1485 |
| 1443 void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { | 1486 void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { |
| 1487 InlineBailout("ValueGraphVisitor::VisitClosureCallNode"); |
| 1444 Value* result = Bind(BuildClosureCall(node)); | 1488 Value* result = Bind(BuildClosureCall(node)); |
| 1445 // Restore context from temp. | 1489 // Restore context from temp. |
| 1446 BuildLoadContext(*owner()->parsed_function().expression_temp_var()); | 1490 BuildLoadContext(*owner()->parsed_function().expression_temp_var()); |
| 1447 ReturnValue(result); | 1491 ReturnValue(result); |
| 1448 } | 1492 } |
| 1449 | 1493 |
| 1450 | 1494 |
| 1451 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { | 1495 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { |
| 1496 InlineBailout("EffectGraphVisitor::VisitCloneContextNode"); |
| 1452 Value* context = Bind(new CurrentContextComp()); | 1497 Value* context = Bind(new CurrentContextComp()); |
| 1453 Value* clone = Bind(new CloneContextComp(node->token_pos(), context)); | 1498 Value* clone = Bind(new CloneContextComp(node->token_pos(), context)); |
| 1454 ReturnComputation(new StoreContextComp(clone)); | 1499 ReturnComputation(new StoreContextComp(clone)); |
| 1455 } | 1500 } |
| 1456 | 1501 |
| 1457 | 1502 |
| 1458 Value* EffectGraphVisitor::BuildObjectAllocation( | 1503 Value* EffectGraphVisitor::BuildObjectAllocation( |
| 1459 ConstructorCallNode* node) { | 1504 ConstructorCallNode* node) { |
| 1505 InlineBailout("EffectGraphVisitor::BuildObjectAllocation"); |
| 1460 const Class& cls = Class::ZoneHandle(node->constructor().Owner()); | 1506 const Class& cls = Class::ZoneHandle(node->constructor().Owner()); |
| 1461 const bool requires_type_arguments = cls.HasTypeArguments(); | 1507 const bool requires_type_arguments = cls.HasTypeArguments(); |
| 1462 | 1508 |
| 1463 // In checked mode, if the type arguments are uninstantiated, they may need to | 1509 // In checked mode, if the type arguments are uninstantiated, they may need to |
| 1464 // be checked against declared bounds at run time. | 1510 // be checked against declared bounds at run time. |
| 1465 Computation* allocate_comp = NULL; | 1511 Computation* allocate_comp = NULL; |
| 1466 if (FLAG_enable_type_checks && | 1512 if (FLAG_enable_type_checks && |
| 1467 requires_type_arguments && | 1513 requires_type_arguments && |
| 1468 !node->type_arguments().IsNull() && | 1514 !node->type_arguments().IsNull() && |
| 1469 !node->type_arguments().IsInstantiated() && | 1515 !node->type_arguments().IsInstantiated() && |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1492 | 1538 |
| 1493 allocate_comp = new AllocateObjectComp(node, allocate_arguments); | 1539 allocate_comp = new AllocateObjectComp(node, allocate_arguments); |
| 1494 } | 1540 } |
| 1495 return Bind(allocate_comp); | 1541 return Bind(allocate_comp); |
| 1496 } | 1542 } |
| 1497 | 1543 |
| 1498 | 1544 |
| 1499 void EffectGraphVisitor::BuildConstructorCall( | 1545 void EffectGraphVisitor::BuildConstructorCall( |
| 1500 ConstructorCallNode* node, | 1546 ConstructorCallNode* node, |
| 1501 PushArgumentInstr* push_alloc_value) { | 1547 PushArgumentInstr* push_alloc_value) { |
| 1548 InlineBailout("EffectGraphVisitor::BuildConstructorCall"); |
| 1502 Value* ctor_arg = Bind( | 1549 Value* ctor_arg = Bind( |
| 1503 new ConstantComp(Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll)))); | 1550 new ConstantComp(Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll)))); |
| 1504 PushArgumentInstr* push_ctor_arg = PushArgument(ctor_arg); | 1551 PushArgumentInstr* push_ctor_arg = PushArgument(ctor_arg); |
| 1505 | 1552 |
| 1506 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1553 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1507 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1554 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1508 arguments->Add(push_alloc_value); | 1555 arguments->Add(push_alloc_value); |
| 1509 arguments->Add(push_ctor_arg); | 1556 arguments->Add(push_ctor_arg); |
| 1510 | 1557 |
| 1511 BuildPushArguments(*node->arguments(), arguments); | 1558 BuildPushArguments(*node->arguments(), arguments); |
| 1512 Do(new StaticCallComp(node->token_pos(), | 1559 Do(new StaticCallComp(node->token_pos(), |
| 1513 node->constructor(), | 1560 node->constructor(), |
| 1514 node->arguments()->names(), | 1561 node->arguments()->names(), |
| 1515 arguments)); | 1562 arguments)); |
| 1516 } | 1563 } |
| 1517 | 1564 |
| 1518 | 1565 |
| 1519 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { | 1566 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { |
| 1567 InlineBailout("EffectGraphVisitor::VisitConstructorCallNode"); |
| 1520 if (node->constructor().IsFactory()) { | 1568 if (node->constructor().IsFactory()) { |
| 1521 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1569 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1522 new ZoneGrowableArray<PushArgumentInstr*>(); | 1570 new ZoneGrowableArray<PushArgumentInstr*>(); |
| 1523 PushArgumentInstr* push_type_arguments = PushArgument( | 1571 PushArgumentInstr* push_type_arguments = PushArgument( |
| 1524 BuildInstantiatedTypeArguments(node->token_pos(), | 1572 BuildInstantiatedTypeArguments(node->token_pos(), |
| 1525 node->type_arguments())); | 1573 node->type_arguments())); |
| 1526 arguments->Add(push_type_arguments); | 1574 arguments->Add(push_type_arguments); |
| 1527 ASSERT(arguments->length() == 1); | 1575 ASSERT(arguments->length() == 1); |
| 1528 BuildPushArguments(*node->arguments(), arguments); | 1576 BuildPushArguments(*node->arguments(), arguments); |
| 1529 StaticCallComp* call = | 1577 StaticCallComp* call = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1540 // t_n+2... <- constructor arguments start here | 1588 // t_n+2... <- constructor arguments start here |
| 1541 // StaticCall(constructor, t_n+1, t_n+2, ...) | 1589 // StaticCall(constructor, t_n+1, t_n+2, ...) |
| 1542 // No need to preserve allocated value (simpler than in ValueGraphVisitor). | 1590 // No need to preserve allocated value (simpler than in ValueGraphVisitor). |
| 1543 Value* allocated_value = BuildObjectAllocation(node); | 1591 Value* allocated_value = BuildObjectAllocation(node); |
| 1544 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); | 1592 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); |
| 1545 BuildConstructorCall(node, push_allocated_value); | 1593 BuildConstructorCall(node, push_allocated_value); |
| 1546 } | 1594 } |
| 1547 | 1595 |
| 1548 | 1596 |
| 1549 Value* EffectGraphVisitor::BuildInstantiator() { | 1597 Value* EffectGraphVisitor::BuildInstantiator() { |
| 1598 InlineBailout("EffectGraphVisitor::BuildInstantiator"); |
| 1550 const Class& instantiator_class = Class::Handle( | 1599 const Class& instantiator_class = Class::Handle( |
| 1551 owner()->parsed_function().function().Owner()); | 1600 owner()->parsed_function().function().Owner()); |
| 1552 if (instantiator_class.NumTypeParameters() == 0) { | 1601 if (instantiator_class.NumTypeParameters() == 0) { |
| 1553 return NULL; | 1602 return NULL; |
| 1554 } | 1603 } |
| 1555 Function& outer_function = | 1604 Function& outer_function = |
| 1556 Function::Handle(owner()->parsed_function().function().raw()); | 1605 Function::Handle(owner()->parsed_function().function().raw()); |
| 1557 while (outer_function.IsLocalFunction()) { | 1606 while (outer_function.IsLocalFunction()) { |
| 1558 outer_function = outer_function.parent_function(); | 1607 outer_function = outer_function.parent_function(); |
| 1559 } | 1608 } |
| 1560 if (outer_function.IsFactory()) { | 1609 if (outer_function.IsFactory()) { |
| 1561 return NULL; | 1610 return NULL; |
| 1562 } | 1611 } |
| 1563 | 1612 |
| 1564 ASSERT(owner()->parsed_function().instantiator() != NULL); | 1613 ASSERT(owner()->parsed_function().instantiator() != NULL); |
| 1565 ValueGraphVisitor for_instantiator(owner(), temp_index()); | 1614 ValueGraphVisitor for_instantiator(owner(), temp_index()); |
| 1566 owner()->parsed_function().instantiator()->Visit(&for_instantiator); | 1615 owner()->parsed_function().instantiator()->Visit(&for_instantiator); |
| 1567 Append(for_instantiator); | 1616 Append(for_instantiator); |
| 1568 return for_instantiator.value(); | 1617 return for_instantiator.value(); |
| 1569 } | 1618 } |
| 1570 | 1619 |
| 1571 | 1620 |
| 1572 // 'expression_temp_var' may not be used inside this method if 'instantiator' | 1621 // 'expression_temp_var' may not be used inside this method if 'instantiator' |
| 1573 // is not NULL. | 1622 // is not NULL. |
| 1574 Value* EffectGraphVisitor::BuildInstantiatorTypeArguments( | 1623 Value* EffectGraphVisitor::BuildInstantiatorTypeArguments( |
| 1575 intptr_t token_pos, Value* instantiator) { | 1624 intptr_t token_pos, Value* instantiator) { |
| 1625 InlineBailout("EffectGraphVisitor::BuildInstantiatorTypeArguments"); |
| 1576 const Class& instantiator_class = Class::Handle( | 1626 const Class& instantiator_class = Class::Handle( |
| 1577 owner()->parsed_function().function().Owner()); | 1627 owner()->parsed_function().function().Owner()); |
| 1578 if (instantiator_class.NumTypeParameters() == 0) { | 1628 if (instantiator_class.NumTypeParameters() == 0) { |
| 1579 // The type arguments are compile time constants. | 1629 // The type arguments are compile time constants. |
| 1580 AbstractTypeArguments& type_arguments = AbstractTypeArguments::ZoneHandle(); | 1630 AbstractTypeArguments& type_arguments = AbstractTypeArguments::ZoneHandle(); |
| 1581 // Type is temporary. Only its type arguments are preserved. | 1631 // Type is temporary. Only its type arguments are preserved. |
| 1582 Type& type = Type::Handle( | 1632 Type& type = Type::Handle( |
| 1583 Type::New(instantiator_class, type_arguments, token_pos, Heap::kNew)); | 1633 Type::New(instantiator_class, type_arguments, token_pos, Heap::kNew)); |
| 1584 type ^= ClassFinalizer::FinalizeType( | 1634 type ^= ClassFinalizer::FinalizeType( |
| 1585 instantiator_class, type, ClassFinalizer::kFinalize); | 1635 instantiator_class, type, ClassFinalizer::kFinalize); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1616 return Bind(new LoadVMFieldComp( | 1666 return Bind(new LoadVMFieldComp( |
| 1617 instantiator, | 1667 instantiator, |
| 1618 type_arguments_instance_field_offset, | 1668 type_arguments_instance_field_offset, |
| 1619 Type::ZoneHandle())); // Not an instance, no type. | 1669 Type::ZoneHandle())); // Not an instance, no type. |
| 1620 } | 1670 } |
| 1621 | 1671 |
| 1622 | 1672 |
| 1623 Value* EffectGraphVisitor::BuildInstantiatedTypeArguments( | 1673 Value* EffectGraphVisitor::BuildInstantiatedTypeArguments( |
| 1624 intptr_t token_pos, | 1674 intptr_t token_pos, |
| 1625 const AbstractTypeArguments& type_arguments) { | 1675 const AbstractTypeArguments& type_arguments) { |
| 1676 InlineBailout("EffectGraphVisitor::BuildInstantiatedTypeArguments"); |
| 1626 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { | 1677 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { |
| 1627 return Bind(new ConstantComp(type_arguments)); | 1678 return Bind(new ConstantComp(type_arguments)); |
| 1628 } | 1679 } |
| 1629 // The type arguments are uninstantiated. | 1680 // The type arguments are uninstantiated. |
| 1630 Value* instantiator_value = | 1681 Value* instantiator_value = |
| 1631 BuildInstantiatorTypeArguments(token_pos, NULL); | 1682 BuildInstantiatorTypeArguments(token_pos, NULL); |
| 1632 return Bind(new InstantiateTypeArgumentsComp(token_pos, | 1683 return Bind(new InstantiateTypeArgumentsComp(token_pos, |
| 1633 type_arguments, | 1684 type_arguments, |
| 1634 instantiator_value)); | 1685 instantiator_value)); |
| 1635 } | 1686 } |
| 1636 | 1687 |
| 1637 | 1688 |
| 1638 void EffectGraphVisitor::BuildConstructorTypeArguments( | 1689 void EffectGraphVisitor::BuildConstructorTypeArguments( |
| 1639 ConstructorCallNode* node, | 1690 ConstructorCallNode* node, |
| 1640 Value** type_arguments, | 1691 Value** type_arguments, |
| 1641 Value** instantiator, | 1692 Value** instantiator, |
| 1642 ZoneGrowableArray<PushArgumentInstr*>* call_arguments) { | 1693 ZoneGrowableArray<PushArgumentInstr*>* call_arguments) { |
| 1694 InlineBailout("EffectGraphVisitor::BuildConstructorTypeArguments"); |
| 1643 const Class& cls = Class::ZoneHandle(node->constructor().Owner()); | 1695 const Class& cls = Class::ZoneHandle(node->constructor().Owner()); |
| 1644 ASSERT(cls.HasTypeArguments() && !node->constructor().IsFactory()); | 1696 ASSERT(cls.HasTypeArguments() && !node->constructor().IsFactory()); |
| 1645 if (node->type_arguments().IsNull() || | 1697 if (node->type_arguments().IsNull() || |
| 1646 node->type_arguments().IsInstantiated()) { | 1698 node->type_arguments().IsInstantiated()) { |
| 1647 Value* type_arguments_val = Bind(new ConstantComp(node->type_arguments())); | 1699 Value* type_arguments_val = Bind(new ConstantComp(node->type_arguments())); |
| 1648 if (call_arguments != NULL) { | 1700 if (call_arguments != NULL) { |
| 1649 ASSERT(type_arguments == NULL); | 1701 ASSERT(type_arguments == NULL); |
| 1650 call_arguments->Add(PushArgument(type_arguments_val)); | 1702 call_arguments->Add(PushArgument(type_arguments_val)); |
| 1651 } else { | 1703 } else { |
| 1652 ASSERT(type_arguments != NULL); | 1704 ASSERT(type_arguments != NULL); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 ASSERT(instantiator == NULL); | 1764 ASSERT(instantiator == NULL); |
| 1713 call_arguments->Add(PushArgument(instantiator_val)); | 1765 call_arguments->Add(PushArgument(instantiator_val)); |
| 1714 } else { | 1766 } else { |
| 1715 ASSERT(instantiator != NULL); | 1767 ASSERT(instantiator != NULL); |
| 1716 *instantiator = instantiator_val; | 1768 *instantiator = instantiator_val; |
| 1717 } | 1769 } |
| 1718 } | 1770 } |
| 1719 | 1771 |
| 1720 | 1772 |
| 1721 void ValueGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { | 1773 void ValueGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { |
| 1774 InlineBailout("ValueGraphVisitor::VisitConstructorCallNode"); |
| 1722 if (node->constructor().IsFactory()) { | 1775 if (node->constructor().IsFactory()) { |
| 1723 EffectGraphVisitor::VisitConstructorCallNode(node); | 1776 EffectGraphVisitor::VisitConstructorCallNode(node); |
| 1724 return; | 1777 return; |
| 1725 } | 1778 } |
| 1726 | 1779 |
| 1727 // t_n contains the allocated and initialized object. | 1780 // t_n contains the allocated and initialized object. |
| 1728 // t_n <- AllocateObject(class) | 1781 // t_n <- AllocateObject(class) |
| 1729 // t_n <- StoreLocal(temp, t_n); | 1782 // t_n <- StoreLocal(temp, t_n); |
| 1730 // t_n+1 <- ctor-arg | 1783 // t_n+1 <- ctor-arg |
| 1731 // t_n+2... <- constructor arguments start here | 1784 // t_n+2... <- constructor arguments start here |
| 1732 // StaticCall(constructor, t_n, t_n+1, ...) | 1785 // StaticCall(constructor, t_n, t_n+1, ...) |
| 1733 // tn <- LoadLocal(temp) | 1786 // tn <- LoadLocal(temp) |
| 1734 | 1787 |
| 1735 Value* allocate = BuildObjectAllocation(node); | 1788 Value* allocate = BuildObjectAllocation(node); |
| 1736 Computation* store_allocated = BuildStoreLocal( | 1789 Computation* store_allocated = BuildStoreLocal( |
| 1737 node->allocated_object_var(), | 1790 node->allocated_object_var(), |
| 1738 allocate); | 1791 allocate); |
| 1739 Value* allocated_value = Bind(store_allocated); | 1792 Value* allocated_value = Bind(store_allocated); |
| 1740 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); | 1793 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); |
| 1741 BuildConstructorCall(node, push_allocated_value); | 1794 BuildConstructorCall(node, push_allocated_value); |
| 1742 Computation* load_allocated = BuildLoadLocal( | 1795 Computation* load_allocated = BuildLoadLocal( |
| 1743 node->allocated_object_var()); | 1796 node->allocated_object_var()); |
| 1744 allocated_value = Bind(load_allocated); | 1797 allocated_value = Bind(load_allocated); |
| 1745 ReturnValue(allocated_value); | 1798 ReturnValue(allocated_value); |
| 1746 } | 1799 } |
| 1747 | 1800 |
| 1748 | 1801 |
| 1749 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { | 1802 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { |
| 1803 InlineBailout("EffectGraphVisitor::VisitConstructorCallNode"); |
| 1750 ValueGraphVisitor for_receiver(owner(), temp_index()); | 1804 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 1751 node->receiver()->Visit(&for_receiver); | 1805 node->receiver()->Visit(&for_receiver); |
| 1752 Append(for_receiver); | 1806 Append(for_receiver); |
| 1753 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); | 1807 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); |
| 1754 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1808 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1755 new ZoneGrowableArray<PushArgumentInstr*>(1); | 1809 new ZoneGrowableArray<PushArgumentInstr*>(1); |
| 1756 arguments->Add(push_receiver); | 1810 arguments->Add(push_receiver); |
| 1757 const String& name = | 1811 const String& name = |
| 1758 String::ZoneHandle(Field::GetterSymbol(node->field_name())); | 1812 String::ZoneHandle(Field::GetterSymbol(node->field_name())); |
| 1759 InstanceCallComp* call = new InstanceCallComp( | 1813 InstanceCallComp* call = new InstanceCallComp( |
| 1760 node->token_pos(), name, Token::kGET, | 1814 node->token_pos(), name, Token::kGET, |
| 1761 arguments, Array::ZoneHandle(), 1); | 1815 arguments, Array::ZoneHandle(), 1); |
| 1762 ReturnComputation(call); | 1816 ReturnComputation(call); |
| 1763 } | 1817 } |
| 1764 | 1818 |
| 1765 | 1819 |
| 1766 void EffectGraphVisitor::BuildInstanceSetterArguments( | 1820 void EffectGraphVisitor::BuildInstanceSetterArguments( |
| 1767 InstanceSetterNode* node, | 1821 InstanceSetterNode* node, |
| 1768 ZoneGrowableArray<PushArgumentInstr*>* arguments, | 1822 ZoneGrowableArray<PushArgumentInstr*>* arguments, |
| 1769 bool result_is_needed) { | 1823 bool result_is_needed) { |
| 1824 InlineBailout("EffectGraphVisitor::BuildInstanceSetterArguments"); |
| 1770 ValueGraphVisitor for_receiver(owner(), temp_index()); | 1825 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 1771 node->receiver()->Visit(&for_receiver); | 1826 node->receiver()->Visit(&for_receiver); |
| 1772 Append(for_receiver); | 1827 Append(for_receiver); |
| 1773 arguments->Add(PushArgument(for_receiver.value())); | 1828 arguments->Add(PushArgument(for_receiver.value())); |
| 1774 | 1829 |
| 1775 ValueGraphVisitor for_value(owner(), temp_index()); | 1830 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1776 node->value()->Visit(&for_value); | 1831 node->value()->Visit(&for_value); |
| 1777 Append(for_value); | 1832 Append(for_value); |
| 1778 | 1833 |
| 1779 Value* value = NULL; | 1834 Value* value = NULL; |
| 1780 if (result_is_needed) { | 1835 if (result_is_needed) { |
| 1781 value = Bind( | 1836 value = Bind( |
| 1782 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(), | 1837 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(), |
| 1783 for_value.value())); | 1838 for_value.value())); |
| 1784 } else { | 1839 } else { |
| 1785 value = for_value.value(); | 1840 value = for_value.value(); |
| 1786 } | 1841 } |
| 1787 arguments->Add(PushArgument(value)); | 1842 arguments->Add(PushArgument(value)); |
| 1788 } | 1843 } |
| 1789 | 1844 |
| 1790 | 1845 |
| 1791 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { | 1846 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { |
| 1847 InlineBailout("EffectGraphVisitor::VisitInstanceSetterNode"); |
| 1792 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1848 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1793 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1849 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1794 BuildInstanceSetterArguments(node, arguments, false); // Value not used. | 1850 BuildInstanceSetterArguments(node, arguments, false); // Value not used. |
| 1795 const String& name = | 1851 const String& name = |
| 1796 String::ZoneHandle(Field::SetterSymbol(node->field_name())); | 1852 String::ZoneHandle(Field::SetterSymbol(node->field_name())); |
| 1797 InstanceCallComp* call = new InstanceCallComp(node->token_pos(), | 1853 InstanceCallComp* call = new InstanceCallComp(node->token_pos(), |
| 1798 name, | 1854 name, |
| 1799 Token::kSET, | 1855 Token::kSET, |
| 1800 arguments, | 1856 arguments, |
| 1801 Array::ZoneHandle(), | 1857 Array::ZoneHandle(), |
| 1802 1); // Checked argument count. | 1858 1); // Checked argument count. |
| 1803 ReturnComputation(call); | 1859 ReturnComputation(call); |
| 1804 } | 1860 } |
| 1805 | 1861 |
| 1806 | 1862 |
| 1807 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { | 1863 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { |
| 1864 InlineBailout("ValueGraphVisitor::VisitInstanceSetterNode"); |
| 1808 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1865 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1809 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1866 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1810 BuildInstanceSetterArguments(node, arguments, true); // Value used. | 1867 BuildInstanceSetterArguments(node, arguments, true); // Value used. |
| 1811 const String& name = | 1868 const String& name = |
| 1812 String::ZoneHandle(Field::SetterSymbol(node->field_name())); | 1869 String::ZoneHandle(Field::SetterSymbol(node->field_name())); |
| 1813 Do(new InstanceCallComp(node->token_pos(), | 1870 Do(new InstanceCallComp(node->token_pos(), |
| 1814 name, | 1871 name, |
| 1815 Token::kSET, | 1872 Token::kSET, |
| 1816 arguments, | 1873 arguments, |
| 1817 Array::ZoneHandle(), | 1874 Array::ZoneHandle(), |
| 1818 1)); // Checked argument count. | 1875 1)); // Checked argument count. |
| 1819 ReturnComputation( | 1876 ReturnComputation( |
| 1820 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | 1877 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); |
| 1821 } | 1878 } |
| 1822 | 1879 |
| 1823 | 1880 |
| 1824 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { | 1881 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { |
| 1882 InlineBailout("EffectGraphVisitor::VisitStaticGetterNode"); |
| 1825 const String& getter_name = | 1883 const String& getter_name = |
| 1826 String::Handle(Field::GetterName(node->field_name())); | 1884 String::Handle(Field::GetterName(node->field_name())); |
| 1827 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1885 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1828 new ZoneGrowableArray<PushArgumentInstr*>(); | 1886 new ZoneGrowableArray<PushArgumentInstr*>(); |
| 1829 Function& getter_function = Function::ZoneHandle(); | 1887 Function& getter_function = Function::ZoneHandle(); |
| 1830 if (node->is_super_getter()) { | 1888 if (node->is_super_getter()) { |
| 1831 // Statically resolved instance getter, i.e. "super getter". | 1889 // Statically resolved instance getter, i.e. "super getter". |
| 1832 getter_function = | 1890 getter_function = |
| 1833 Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); | 1891 Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); |
| 1834 ASSERT(!getter_function.IsNull()); | 1892 ASSERT(!getter_function.IsNull()); |
| 1835 ASSERT(node->receiver() != NULL); | 1893 ASSERT(node->receiver() != NULL); |
| 1836 ValueGraphVisitor receiver_value(owner(), temp_index()); | 1894 ValueGraphVisitor receiver_value(owner(), temp_index()); |
| 1837 node->receiver()->Visit(&receiver_value); | 1895 node->receiver()->Visit(&receiver_value); |
| 1838 Append(receiver_value); | 1896 Append(receiver_value); |
| 1839 arguments->Add(PushArgument(receiver_value.value())); | 1897 arguments->Add(PushArgument(receiver_value.value())); |
| 1840 } else { | 1898 } else { |
| 1841 getter_function = node->cls().LookupStaticFunction(getter_name); | 1899 getter_function = node->cls().LookupStaticFunction(getter_name); |
| 1842 ASSERT(!getter_function.IsNull()); | 1900 ASSERT(!getter_function.IsNull()); |
| 1843 } | 1901 } |
| 1844 StaticCallComp* call = new StaticCallComp(node->token_pos(), | 1902 StaticCallComp* call = new StaticCallComp(node->token_pos(), |
| 1845 getter_function, | 1903 getter_function, |
| 1846 Array::ZoneHandle(), // No names. | 1904 Array::ZoneHandle(), // No names. |
| 1847 arguments); | 1905 arguments); |
| 1848 ReturnComputation(call); | 1906 ReturnComputation(call); |
| 1849 } | 1907 } |
| 1850 | 1908 |
| 1851 | 1909 |
| 1852 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, | 1910 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, |
| 1853 bool result_is_needed) { | 1911 bool result_is_needed) { |
| 1912 InlineBailout("EffectGraphVisitor::BuildStaticSetter"); |
| 1854 const String& setter_name = | 1913 const String& setter_name = |
| 1855 String::Handle(Field::SetterName(node->field_name())); | 1914 String::Handle(Field::SetterName(node->field_name())); |
| 1856 // A super setter is an instance setter whose setter function is | 1915 // A super setter is an instance setter whose setter function is |
| 1857 // resolved at compile time (in the caller instance getter's super class). | 1916 // resolved at compile time (in the caller instance getter's super class). |
| 1858 // Unlike a static getter, a super getter has a receiver parameter. | 1917 // Unlike a static getter, a super getter has a receiver parameter. |
| 1859 const bool is_super_setter = (node->receiver() != NULL); | 1918 const bool is_super_setter = (node->receiver() != NULL); |
| 1860 const Function& setter_function = | 1919 const Function& setter_function = |
| 1861 Function::ZoneHandle(is_super_setter | 1920 Function::ZoneHandle(is_super_setter |
| 1862 ? Resolver::ResolveDynamicAnyArgs(node->cls(), setter_name) | 1921 ? Resolver::ResolveDynamicAnyArgs(node->cls(), setter_name) |
| 1863 : node->cls().LookupStaticFunction(setter_name)); | 1922 : node->cls().LookupStaticFunction(setter_name)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1893 Do(call); | 1952 Do(call); |
| 1894 ReturnComputation( | 1953 ReturnComputation( |
| 1895 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | 1954 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); |
| 1896 } else { | 1955 } else { |
| 1897 ReturnComputation(call); | 1956 ReturnComputation(call); |
| 1898 } | 1957 } |
| 1899 } | 1958 } |
| 1900 | 1959 |
| 1901 | 1960 |
| 1902 void EffectGraphVisitor::VisitStaticSetterNode(StaticSetterNode* node) { | 1961 void EffectGraphVisitor::VisitStaticSetterNode(StaticSetterNode* node) { |
| 1962 InlineBailout("EffectGraphVisitor::VisitStaticSetterNode"); |
| 1903 BuildStaticSetter(node, false); // Result not needed. | 1963 BuildStaticSetter(node, false); // Result not needed. |
| 1904 } | 1964 } |
| 1905 | 1965 |
| 1906 | 1966 |
| 1907 void ValueGraphVisitor::VisitStaticSetterNode(StaticSetterNode* node) { | 1967 void ValueGraphVisitor::VisitStaticSetterNode(StaticSetterNode* node) { |
| 1968 InlineBailout("ValueGraphVisitor::VisitStaticSetterNode"); |
| 1908 BuildStaticSetter(node, true); // Result needed. | 1969 BuildStaticSetter(node, true); // Result needed. |
| 1909 } | 1970 } |
| 1910 | 1971 |
| 1911 | 1972 |
| 1912 void EffectGraphVisitor::VisitNativeBodyNode(NativeBodyNode* node) { | 1973 void EffectGraphVisitor::VisitNativeBodyNode(NativeBodyNode* node) { |
| 1974 InlineBailout("EffectGraphVisitor::VisitNativeBodyNode"); |
| 1913 NativeCallComp* native_call = new NativeCallComp(node); | 1975 NativeCallComp* native_call = new NativeCallComp(node); |
| 1914 ReturnComputation(native_call); | 1976 ReturnComputation(native_call); |
| 1915 } | 1977 } |
| 1916 | 1978 |
| 1917 | 1979 |
| 1918 void EffectGraphVisitor::VisitPrimaryNode(PrimaryNode* node) { | 1980 void EffectGraphVisitor::VisitPrimaryNode(PrimaryNode* node) { |
| 1981 InlineBailout("EffectGraphVisitor::VisitPrimaryNode"); |
| 1919 // PrimaryNodes are temporary during parsing. | 1982 // PrimaryNodes are temporary during parsing. |
| 1920 UNREACHABLE(); | 1983 UNREACHABLE(); |
| 1921 } | 1984 } |
| 1922 | 1985 |
| 1923 | 1986 |
| 1924 // <Expression> ::= LoadLocal { local: LocalVariable } | 1987 // <Expression> ::= LoadLocal { local: LocalVariable } |
| 1925 void EffectGraphVisitor::VisitLoadLocalNode(LoadLocalNode* node) { | 1988 void EffectGraphVisitor::VisitLoadLocalNode(LoadLocalNode* node) { |
| 1989 InlineBailout("EffectGraphVisitor::VisitLoadLocalNode"); |
| 1926 if (node->HasPseudo()) { | 1990 if (node->HasPseudo()) { |
| 1927 EffectGraphVisitor for_pseudo(owner(), temp_index()); | 1991 EffectGraphVisitor for_pseudo(owner(), temp_index()); |
| 1928 node->pseudo()->Visit(&for_pseudo); | 1992 node->pseudo()->Visit(&for_pseudo); |
| 1929 Append(for_pseudo); | 1993 Append(for_pseudo); |
| 1930 } | 1994 } |
| 1931 } | 1995 } |
| 1932 | 1996 |
| 1933 | 1997 |
| 1934 void ValueGraphVisitor::VisitLoadLocalNode(LoadLocalNode* node) { | 1998 void ValueGraphVisitor::VisitLoadLocalNode(LoadLocalNode* node) { |
| 1999 InlineBailout("ValueGraphVisitor::VisitLoadLocalNode"); |
| 1935 EffectGraphVisitor::VisitLoadLocalNode(node); | 2000 EffectGraphVisitor::VisitLoadLocalNode(node); |
| 1936 Computation* load = BuildLoadLocal(node->local()); | 2001 Computation* load = BuildLoadLocal(node->local()); |
| 1937 ReturnComputation(load); | 2002 ReturnComputation(load); |
| 1938 } | 2003 } |
| 1939 | 2004 |
| 1940 | 2005 |
| 1941 // <Expression> ::= StoreLocal { local: LocalVariable | 2006 // <Expression> ::= StoreLocal { local: LocalVariable |
| 1942 // value: <Expression> } | 2007 // value: <Expression> } |
| 1943 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { | 2008 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
| 2009 InlineBailout("EffectGraphVisitor::VisitStoreLocalNode"); |
| 1944 ValueGraphVisitor for_value(owner(), temp_index()); | 2010 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1945 node->value()->Visit(&for_value); | 2011 node->value()->Visit(&for_value); |
| 1946 Append(for_value); | 2012 Append(for_value); |
| 1947 Value* store_value = for_value.value(); | 2013 Value* store_value = for_value.value(); |
| 1948 if (FLAG_enable_type_checks) { | 2014 if (FLAG_enable_type_checks) { |
| 1949 store_value = BuildAssignableValue(node->value()->token_pos(), | 2015 store_value = BuildAssignableValue(node->value()->token_pos(), |
| 1950 store_value, | 2016 store_value, |
| 1951 node->local().type(), | 2017 node->local().type(), |
| 1952 node->local().name()); | 2018 node->local().name()); |
| 1953 } | 2019 } |
| 1954 Computation* store = BuildStoreLocal(node->local(), store_value); | 2020 Computation* store = BuildStoreLocal(node->local(), store_value); |
| 1955 ReturnComputation(store); | 2021 ReturnComputation(store); |
| 1956 } | 2022 } |
| 1957 | 2023 |
| 1958 | 2024 |
| 1959 void EffectGraphVisitor::VisitLoadInstanceFieldNode( | 2025 void EffectGraphVisitor::VisitLoadInstanceFieldNode( |
| 1960 LoadInstanceFieldNode* node) { | 2026 LoadInstanceFieldNode* node) { |
| 2027 InlineBailout("EffectGraphVisitor::VisitLoadInstanceFieldNode"); |
| 1961 ValueGraphVisitor for_instance(owner(), temp_index()); | 2028 ValueGraphVisitor for_instance(owner(), temp_index()); |
| 1962 node->instance()->Visit(&for_instance); | 2029 node->instance()->Visit(&for_instance); |
| 1963 Append(for_instance); | 2030 Append(for_instance); |
| 1964 LoadInstanceFieldComp* load = new LoadInstanceFieldComp( | 2031 LoadInstanceFieldComp* load = new LoadInstanceFieldComp( |
| 1965 node->field(), for_instance.value()); | 2032 node->field(), for_instance.value()); |
| 1966 ReturnComputation(load); | 2033 ReturnComputation(load); |
| 1967 } | 2034 } |
| 1968 | 2035 |
| 1969 | 2036 |
| 1970 void EffectGraphVisitor::VisitStoreInstanceFieldNode( | 2037 void EffectGraphVisitor::VisitStoreInstanceFieldNode( |
| 1971 StoreInstanceFieldNode* node) { | 2038 StoreInstanceFieldNode* node) { |
| 2039 InlineBailout("EffectGraphVisitor::VisitStoreInstanceFieldNode"); |
| 1972 ValueGraphVisitor for_instance(owner(), temp_index()); | 2040 ValueGraphVisitor for_instance(owner(), temp_index()); |
| 1973 node->instance()->Visit(&for_instance); | 2041 node->instance()->Visit(&for_instance); |
| 1974 Append(for_instance); | 2042 Append(for_instance); |
| 1975 ValueGraphVisitor for_value(owner(), for_instance.temp_index()); | 2043 ValueGraphVisitor for_value(owner(), for_instance.temp_index()); |
| 1976 node->value()->Visit(&for_value); | 2044 node->value()->Visit(&for_value); |
| 1977 Append(for_value); | 2045 Append(for_value); |
| 1978 Value* store_value = for_value.value(); | 2046 Value* store_value = for_value.value(); |
| 1979 if (FLAG_enable_type_checks) { | 2047 if (FLAG_enable_type_checks) { |
| 1980 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); | 2048 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); |
| 1981 const String& dst_name = String::ZoneHandle(node->field().name()); | 2049 const String& dst_name = String::ZoneHandle(node->field().name()); |
| 1982 store_value = BuildAssignableValue(node->value()->token_pos(), | 2050 store_value = BuildAssignableValue(node->value()->token_pos(), |
| 1983 store_value, | 2051 store_value, |
| 1984 type, | 2052 type, |
| 1985 dst_name); | 2053 dst_name); |
| 1986 } | 2054 } |
| 1987 StoreInstanceFieldComp* store = new StoreInstanceFieldComp( | 2055 StoreInstanceFieldComp* store = new StoreInstanceFieldComp( |
| 1988 node->field(), for_instance.value(), store_value); | 2056 node->field(), for_instance.value(), store_value); |
| 1989 ReturnComputation(store); | 2057 ReturnComputation(store); |
| 1990 } | 2058 } |
| 1991 | 2059 |
| 1992 | 2060 |
| 1993 // StoreInstanceFieldNode does not return result. | 2061 // StoreInstanceFieldNode does not return result. |
| 1994 void ValueGraphVisitor::VisitStoreInstanceFieldNode( | 2062 void ValueGraphVisitor::VisitStoreInstanceFieldNode( |
| 1995 StoreInstanceFieldNode* node) { | 2063 StoreInstanceFieldNode* node) { |
| 2064 InlineBailout("ValueGraphVisitor::VisitStoreInstanceFieldNode"); |
| 1996 UNIMPLEMENTED(); | 2065 UNIMPLEMENTED(); |
| 1997 } | 2066 } |
| 1998 | 2067 |
| 1999 | 2068 |
| 2000 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { | 2069 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { |
| 2070 InlineBailout("EffectGraphVisitor::VisitLoadStaticFieldNode"); |
| 2001 LoadStaticFieldComp* load = new LoadStaticFieldComp(node->field()); | 2071 LoadStaticFieldComp* load = new LoadStaticFieldComp(node->field()); |
| 2002 ReturnComputation(load); | 2072 ReturnComputation(load); |
| 2003 } | 2073 } |
| 2004 | 2074 |
| 2005 | 2075 |
| 2006 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { | 2076 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { |
| 2077 InlineBailout("EffectGraphVisitor::VisitStoreStaticFieldNode"); |
| 2007 ValueGraphVisitor for_value(owner(), temp_index()); | 2078 ValueGraphVisitor for_value(owner(), temp_index()); |
| 2008 node->value()->Visit(&for_value); | 2079 node->value()->Visit(&for_value); |
| 2009 Append(for_value); | 2080 Append(for_value); |
| 2010 Value* store_value = for_value.value(); | 2081 Value* store_value = for_value.value(); |
| 2011 if (FLAG_enable_type_checks) { | 2082 if (FLAG_enable_type_checks) { |
| 2012 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); | 2083 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); |
| 2013 const String& dst_name = String::ZoneHandle(node->field().name()); | 2084 const String& dst_name = String::ZoneHandle(node->field().name()); |
| 2014 store_value = BuildAssignableValue(node->value()->token_pos(), | 2085 store_value = BuildAssignableValue(node->value()->token_pos(), |
| 2015 store_value, | 2086 store_value, |
| 2016 type, | 2087 type, |
| 2017 dst_name); | 2088 dst_name); |
| 2018 } | 2089 } |
| 2019 StoreStaticFieldComp* store = | 2090 StoreStaticFieldComp* store = |
| 2020 new StoreStaticFieldComp(node->field(), store_value); | 2091 new StoreStaticFieldComp(node->field(), store_value); |
| 2021 ReturnComputation(store); | 2092 ReturnComputation(store); |
| 2022 } | 2093 } |
| 2023 | 2094 |
| 2024 | 2095 |
| 2025 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { | 2096 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { |
| 2097 InlineBailout("EffectGraphVisitor::VisitLoadIndexedNode"); |
| 2026 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 2098 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 2027 new ZoneGrowableArray<PushArgumentInstr*>(2); | 2099 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 2028 ValueGraphVisitor for_array(owner(), temp_index()); | 2100 ValueGraphVisitor for_array(owner(), temp_index()); |
| 2029 node->array()->Visit(&for_array); | 2101 node->array()->Visit(&for_array); |
| 2030 Append(for_array); | 2102 Append(for_array); |
| 2031 arguments->Add(PushArgument(for_array.value())); | 2103 arguments->Add(PushArgument(for_array.value())); |
| 2032 | 2104 |
| 2033 ValueGraphVisitor for_index(owner(), temp_index()); | 2105 ValueGraphVisitor for_index(owner(), temp_index()); |
| 2034 node->index_expr()->Visit(&for_index); | 2106 node->index_expr()->Visit(&for_index); |
| 2035 Append(for_index); | 2107 Append(for_index); |
| 2036 arguments->Add(PushArgument(for_index.value())); | 2108 arguments->Add(PushArgument(for_index.value())); |
| 2037 | 2109 |
| 2038 const intptr_t checked_argument_count = 1; | 2110 const intptr_t checked_argument_count = 1; |
| 2039 const String& name = | 2111 const String& name = |
| 2040 String::ZoneHandle(Symbols::New(Token::Str(Token::kINDEX))); | 2112 String::ZoneHandle(Symbols::New(Token::Str(Token::kINDEX))); |
| 2041 InstanceCallComp* load = new InstanceCallComp(node->token_pos(), | 2113 InstanceCallComp* load = new InstanceCallComp(node->token_pos(), |
| 2042 name, | 2114 name, |
| 2043 Token::kINDEX, | 2115 Token::kINDEX, |
| 2044 arguments, | 2116 arguments, |
| 2045 Array::ZoneHandle(), | 2117 Array::ZoneHandle(), |
| 2046 checked_argument_count); | 2118 checked_argument_count); |
| 2047 ReturnComputation(load); | 2119 ReturnComputation(load); |
| 2048 } | 2120 } |
| 2049 | 2121 |
| 2050 | 2122 |
| 2051 Computation* EffectGraphVisitor::BuildStoreIndexedValues( | 2123 Computation* EffectGraphVisitor::BuildStoreIndexedValues( |
| 2052 StoreIndexedNode* node, | 2124 StoreIndexedNode* node, |
| 2053 bool result_is_needed) { | 2125 bool result_is_needed) { |
| 2126 InlineBailout("EffectGraphVisitor::BuildStoreIndexedValues"); |
| 2054 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 2127 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 2055 new ZoneGrowableArray<PushArgumentInstr*>(3); | 2128 new ZoneGrowableArray<PushArgumentInstr*>(3); |
| 2056 ValueGraphVisitor for_array(owner(), temp_index()); | 2129 ValueGraphVisitor for_array(owner(), temp_index()); |
| 2057 node->array()->Visit(&for_array); | 2130 node->array()->Visit(&for_array); |
| 2058 Append(for_array); | 2131 Append(for_array); |
| 2059 arguments->Add(PushArgument(for_array.value())); | 2132 arguments->Add(PushArgument(for_array.value())); |
| 2060 | 2133 |
| 2061 ValueGraphVisitor for_index(owner(), temp_index()); | 2134 ValueGraphVisitor for_index(owner(), temp_index()); |
| 2062 node->index_expr()->Visit(&for_index); | 2135 node->index_expr()->Visit(&for_index); |
| 2063 Append(for_index); | 2136 Append(for_index); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2088 if (result_is_needed) { | 2161 if (result_is_needed) { |
| 2089 Do(store); | 2162 Do(store); |
| 2090 return BuildLoadLocal(*owner()->parsed_function().expression_temp_var()); | 2163 return BuildLoadLocal(*owner()->parsed_function().expression_temp_var()); |
| 2091 } else { | 2164 } else { |
| 2092 return store; | 2165 return store; |
| 2093 } | 2166 } |
| 2094 } | 2167 } |
| 2095 | 2168 |
| 2096 | 2169 |
| 2097 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { | 2170 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { |
| 2171 InlineBailout("EffectGraphVisitor::VisitStoreIndexedNode"); |
| 2098 ReturnComputation(BuildStoreIndexedValues(node, | 2172 ReturnComputation(BuildStoreIndexedValues(node, |
| 2099 false)); // Result not needed. | 2173 false)); // Result not needed. |
| 2100 } | 2174 } |
| 2101 | 2175 |
| 2102 | 2176 |
| 2103 void ValueGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { | 2177 void ValueGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { |
| 2178 InlineBailout("ValueGraphVisitor::VisitStoreIndexedNode"); |
| 2104 ReturnComputation(BuildStoreIndexedValues(node, | 2179 ReturnComputation(BuildStoreIndexedValues(node, |
| 2105 true)); // Result is needed. | 2180 true)); // Result is needed. |
| 2106 } | 2181 } |
| 2107 | 2182 |
| 2108 | 2183 |
| 2109 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { | 2184 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { |
| 2110 return (node == owner()->parsed_function().node_sequence()) && | 2185 return (node == owner()->parsed_function().node_sequence()) && |
| 2111 (owner()->parsed_function().saved_context_var() != NULL); | 2186 (owner()->parsed_function().saved_context_var() != NULL); |
| 2112 } | 2187 } |
| 2113 | 2188 |
| 2114 | 2189 |
| 2115 void EffectGraphVisitor::UnchainContext() { | 2190 void EffectGraphVisitor::UnchainContext() { |
| 2191 InlineBailout("EffectGraphVisitor::UnchainContext"); |
| 2116 Value* context = Bind(new CurrentContextComp()); | 2192 Value* context = Bind(new CurrentContextComp()); |
| 2117 Value* parent = Bind( | 2193 Value* parent = Bind( |
| 2118 new LoadVMFieldComp(context, | 2194 new LoadVMFieldComp(context, |
| 2119 Context::parent_offset(), | 2195 Context::parent_offset(), |
| 2120 Type::ZoneHandle())); // Not an instance, no type. | 2196 Type::ZoneHandle())); // Not an instance, no type. |
| 2121 Do(new StoreContextComp(parent)); | 2197 Do(new StoreContextComp(parent)); |
| 2122 } | 2198 } |
| 2123 | 2199 |
| 2124 | 2200 |
| 2125 // <Statement> ::= Sequence { scope: LocalScope | 2201 // <Statement> ::= Sequence { scope: LocalScope |
| 2126 // nodes: <Statement>* | 2202 // nodes: <Statement>* |
| 2127 // label: SourceLabel } | 2203 // label: SourceLabel } |
| 2128 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { | 2204 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { |
| 2129 LocalScope* scope = node->scope(); | 2205 LocalScope* scope = node->scope(); |
| 2130 const intptr_t num_context_variables = | 2206 const intptr_t num_context_variables = |
| 2131 (scope != NULL) ? scope->num_context_variables() : 0; | 2207 (scope != NULL) ? scope->num_context_variables() : 0; |
| 2132 int previous_context_level = owner()->context_level(); | 2208 int previous_context_level = owner()->context_level(); |
| 2133 if (num_context_variables > 0) { | 2209 if (num_context_variables > 0) { |
| 2210 InlineBailout("EffectGraphVisitor::VisitSequenceNode (captured vars)"); |
| 2134 // The loop local scope declares variables that are captured. | 2211 // The loop local scope declares variables that are captured. |
| 2135 // Allocate and chain a new context. | 2212 // Allocate and chain a new context. |
| 2136 // Allocate context computation (uses current CTX) | 2213 // Allocate context computation (uses current CTX) |
| 2137 Value* allocated_context = | 2214 Value* allocated_context = |
| 2138 Bind(new AllocateContextComp(node->token_pos(), num_context_variables)); | 2215 Bind(new AllocateContextComp(node->token_pos(), num_context_variables)); |
| 2139 | 2216 |
| 2140 // If this node_sequence is the body of the function being compiled, and if | 2217 // If this node_sequence is the body of the function being compiled, and if |
| 2141 // this function is not a closure, do not link the current context as the | 2218 // this function is not a closure, do not link the current context as the |
| 2142 // parent of the newly allocated context, as it is not accessible. Instead, | 2219 // parent of the newly allocated context, as it is not accessible. Instead, |
| 2143 // save it in a pre-allocated variable and restore it on exit. | 2220 // save it in a pre-allocated variable and restore it on exit. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 Value* null_constant = | 2259 Value* null_constant = |
| 2183 Bind(new ConstantComp(Object::ZoneHandle())); | 2260 Bind(new ConstantComp(Object::ZoneHandle())); |
| 2184 Do(BuildStoreLocal(*temp_local, null_constant)); | 2261 Do(BuildStoreLocal(*temp_local, null_constant)); |
| 2185 } | 2262 } |
| 2186 } | 2263 } |
| 2187 } | 2264 } |
| 2188 } | 2265 } |
| 2189 | 2266 |
| 2190 if (FLAG_enable_type_checks && | 2267 if (FLAG_enable_type_checks && |
| 2191 (node == owner()->parsed_function().node_sequence())) { | 2268 (node == owner()->parsed_function().node_sequence())) { |
| 2269 InlineBailout("EffectGraphVisitor::VisitSequenceNode (type check)"); |
| 2192 const Function& function = owner()->parsed_function().function(); | 2270 const Function& function = owner()->parsed_function().function(); |
| 2193 const int num_params = function.NumberOfParameters(); | 2271 const int num_params = function.NumberOfParameters(); |
| 2194 int pos = 0; | 2272 int pos = 0; |
| 2195 if (function.IsConstructor()) { | 2273 if (function.IsConstructor()) { |
| 2196 // Skip type checking of receiver and phase for constructor functions. | 2274 // Skip type checking of receiver and phase for constructor functions. |
| 2197 pos = 2; | 2275 pos = 2; |
| 2198 } else if (function.IsFactory() || function.IsDynamicFunction()) { | 2276 } else if (function.IsFactory() || function.IsDynamicFunction()) { |
| 2199 // Skip type checking of type arguments for factory functions. | 2277 // Skip type checking of type arguments for factory functions. |
| 2200 // Skip type checking of receiver for instance functions. | 2278 // Skip type checking of receiver for instance functions. |
| 2201 pos = 1; | 2279 pos = 1; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2255 } | 2333 } |
| 2256 | 2334 |
| 2257 // The outermost function sequence cannot contain a label. | 2335 // The outermost function sequence cannot contain a label. |
| 2258 ASSERT((node->label() == NULL) || | 2336 ASSERT((node->label() == NULL) || |
| 2259 (node != owner()->parsed_function().node_sequence())); | 2337 (node != owner()->parsed_function().node_sequence())); |
| 2260 owner()->set_context_level(previous_context_level); | 2338 owner()->set_context_level(previous_context_level); |
| 2261 } | 2339 } |
| 2262 | 2340 |
| 2263 | 2341 |
| 2264 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { | 2342 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { |
| 2343 InlineBailout("EffectGraphVisitor::VisitCatchClauseNode"); |
| 2265 // NOTE: The implicit variables ':saved_context', ':exception_var' | 2344 // NOTE: The implicit variables ':saved_context', ':exception_var' |
| 2266 // and ':stacktrace_var' can never be captured variables. | 2345 // and ':stacktrace_var' can never be captured variables. |
| 2267 // Restores CTX from local variable ':saved_context'. | 2346 // Restores CTX from local variable ':saved_context'. |
| 2268 Do(new CatchEntryComp(node->exception_var(), node->stacktrace_var())); | 2347 Do(new CatchEntryComp(node->exception_var(), node->stacktrace_var())); |
| 2269 BuildLoadContext(node->context_var()); | 2348 BuildLoadContext(node->context_var()); |
| 2270 | 2349 |
| 2271 EffectGraphVisitor for_catch(owner(), temp_index()); | 2350 EffectGraphVisitor for_catch(owner(), temp_index()); |
| 2272 node->VisitChildren(&for_catch); | 2351 node->VisitChildren(&for_catch); |
| 2273 Append(for_catch); | 2352 Append(for_catch); |
| 2274 } | 2353 } |
| 2275 | 2354 |
| 2276 | 2355 |
| 2277 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { | 2356 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { |
| 2357 InlineBailout("EffectGraphVisitor::VisitTryCatchNode"); |
| 2278 intptr_t old_try_index = owner()->try_index(); | 2358 intptr_t old_try_index = owner()->try_index(); |
| 2279 intptr_t try_index = owner()->AllocateTryIndex(); | 2359 intptr_t try_index = owner()->AllocateTryIndex(); |
| 2280 owner()->set_try_index(try_index); | 2360 owner()->set_try_index(try_index); |
| 2281 | 2361 |
| 2282 // Preserve CTX into local variable '%saved_context'. | 2362 // Preserve CTX into local variable '%saved_context'. |
| 2283 BuildStoreContext(node->context_var()); | 2363 BuildStoreContext(node->context_var()); |
| 2284 | 2364 |
| 2285 EffectGraphVisitor for_try_block(owner(), temp_index()); | 2365 EffectGraphVisitor for_try_block(owner(), temp_index()); |
| 2286 node->try_block()->Visit(&for_try_block); | 2366 node->try_block()->Visit(&for_try_block); |
| 2287 | 2367 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 // Generate code for the finally block if one exists. | 2405 // Generate code for the finally block if one exists. |
| 2326 if ((node->finally_block() != NULL) && is_open()) { | 2406 if ((node->finally_block() != NULL) && is_open()) { |
| 2327 EffectGraphVisitor for_finally_block(owner(), temp_index()); | 2407 EffectGraphVisitor for_finally_block(owner(), temp_index()); |
| 2328 node->finally_block()->Visit(&for_finally_block); | 2408 node->finally_block()->Visit(&for_finally_block); |
| 2329 Append(for_finally_block); | 2409 Append(for_finally_block); |
| 2330 } | 2410 } |
| 2331 } | 2411 } |
| 2332 | 2412 |
| 2333 | 2413 |
| 2334 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { | 2414 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { |
| 2415 InlineBailout("EffectGraphVisitor::BuildThrowNode"); |
| 2335 ValueGraphVisitor for_exception(owner(), temp_index()); | 2416 ValueGraphVisitor for_exception(owner(), temp_index()); |
| 2336 node->exception()->Visit(&for_exception); | 2417 node->exception()->Visit(&for_exception); |
| 2337 Append(for_exception); | 2418 Append(for_exception); |
| 2338 PushArgument(for_exception.value()); | 2419 PushArgument(for_exception.value()); |
| 2339 Instruction* instr = NULL; | 2420 Instruction* instr = NULL; |
| 2340 if (node->stacktrace() == NULL) { | 2421 if (node->stacktrace() == NULL) { |
| 2341 instr = new ThrowInstr(node->token_pos()); | 2422 instr = new ThrowInstr(node->token_pos()); |
| 2342 } else { | 2423 } else { |
| 2343 ValueGraphVisitor for_stack_trace(owner(), temp_index()); | 2424 ValueGraphVisitor for_stack_trace(owner(), temp_index()); |
| 2344 node->stacktrace()->Visit(&for_stack_trace); | 2425 node->stacktrace()->Visit(&for_stack_trace); |
| 2345 Append(for_stack_trace); | 2426 Append(for_stack_trace); |
| 2346 PushArgument(for_stack_trace.value()); | 2427 PushArgument(for_stack_trace.value()); |
| 2347 instr = new ReThrowInstr(node->token_pos()); | 2428 instr = new ReThrowInstr(node->token_pos()); |
| 2348 } | 2429 } |
| 2349 AddInstruction(instr); | 2430 AddInstruction(instr); |
| 2350 } | 2431 } |
| 2351 | 2432 |
| 2352 | 2433 |
| 2353 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) { | 2434 void EffectGraphVisitor::VisitThrowNode(ThrowNode* node) { |
| 2435 InlineBailout("EffectGraphVisitor::VisitThrowNode"); |
| 2354 BuildThrowNode(node); | 2436 BuildThrowNode(node); |
| 2355 CloseFragment(); | 2437 CloseFragment(); |
| 2356 } | 2438 } |
| 2357 | 2439 |
| 2358 | 2440 |
| 2359 // A throw cannot be part of an expression, however, the parser may replace | 2441 // A throw cannot be part of an expression, however, the parser may replace |
| 2360 // certain expression nodes with a throw. In that case generate a literal null | 2442 // certain expression nodes with a throw. In that case generate a literal null |
| 2361 // so that the fragment is not closed in the middle of an expression. | 2443 // so that the fragment is not closed in the middle of an expression. |
| 2362 void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) { | 2444 void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) { |
| 2445 InlineBailout("ValueGraphVisitor::VisitThrowNode"); |
| 2363 BuildThrowNode(node); | 2446 BuildThrowNode(node); |
| 2364 ReturnComputation(new ConstantComp(Instance::ZoneHandle())); | 2447 ReturnComputation(new ConstantComp(Instance::ZoneHandle())); |
| 2365 } | 2448 } |
| 2366 | 2449 |
| 2367 | 2450 |
| 2368 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { | 2451 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { |
| 2452 InlineBailout("EffectGraphVisitor::VisitInlinedFinallyNode"); |
| 2369 const intptr_t try_index = owner()->try_index(); | 2453 const intptr_t try_index = owner()->try_index(); |
| 2370 if (try_index >= 0) { | 2454 if (try_index >= 0) { |
| 2371 // We are about to generate code for an inlined finally block. Exceptions | 2455 // We are about to generate code for an inlined finally block. Exceptions |
| 2372 // thrown in this block of code should be treated as though they are | 2456 // thrown in this block of code should be treated as though they are |
| 2373 // thrown not from the current try block but the outer try block if any. | 2457 // thrown not from the current try block but the outer try block if any. |
| 2374 owner()->set_try_index((try_index - 1)); | 2458 owner()->set_try_index((try_index - 1)); |
| 2375 } | 2459 } |
| 2376 BuildLoadContext(node->context_var()); | 2460 BuildLoadContext(node->context_var()); |
| 2377 | 2461 |
| 2378 JoinEntryInstr* finally_entry = new JoinEntryInstr(owner()->try_index()); | 2462 JoinEntryInstr* finally_entry = new JoinEntryInstr(owner()->try_index()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 // stack check on entry for leaf routines). | 2494 // stack check on entry for leaf routines). |
| 2411 for_effect.Do(new CheckStackOverflowComp(function.token_pos())); | 2495 for_effect.Do(new CheckStackOverflowComp(function.token_pos())); |
| 2412 parsed_function().node_sequence()->Visit(&for_effect); | 2496 parsed_function().node_sequence()->Visit(&for_effect); |
| 2413 AppendFragment(normal_entry, for_effect); | 2497 AppendFragment(normal_entry, for_effect); |
| 2414 // Check that the graph is properly terminated. | 2498 // Check that the graph is properly terminated. |
| 2415 ASSERT(!for_effect.is_open()); | 2499 ASSERT(!for_effect.is_open()); |
| 2416 return new FlowGraph(*this, graph_entry_); | 2500 return new FlowGraph(*this, graph_entry_); |
| 2417 } | 2501 } |
| 2418 | 2502 |
| 2419 | 2503 |
| 2504 FlowGraph* FlowGraphBuilder::BuildGraphForInlining(InliningContext context) { |
| 2505 ASSERT(inlining_context_ == kNotInlining); |
| 2506 inlining_context_ = context; |
| 2507 exits_ = new ZoneGrowableArray<ReturnInstr*>(); |
| 2508 TargetEntryInstr* normal_entry = new TargetEntryInstr( |
| 2509 CatchClauseNode::kInvalidTryIndex); |
| 2510 graph_entry_ = new GraphEntryInstr(normal_entry); |
| 2511 EffectGraphVisitor for_effect(this, 0); |
| 2512 parsed_function().node_sequence()->Visit(&for_effect); |
| 2513 AppendFragment(normal_entry, for_effect); |
| 2514 ASSERT(!for_effect.is_open()); |
| 2515 FlowGraph* graph = new FlowGraph(*this, graph_entry_); |
| 2516 graph->set_exits(exits_); |
| 2517 return graph; |
| 2518 } |
| 2519 |
| 2520 |
| 2420 void FlowGraphBuilder::Bailout(const char* reason) { | 2521 void FlowGraphBuilder::Bailout(const char* reason) { |
| 2421 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; | 2522 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; |
| 2422 const char* function_name = parsed_function_.function().ToCString(); | 2523 const char* function_name = parsed_function_.function().ToCString(); |
| 2423 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2524 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2424 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2525 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2425 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2526 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2426 const Error& error = Error::Handle( | 2527 const Error& error = Error::Handle( |
| 2427 LanguageError::New(String::Handle(String::New(chars)))); | 2528 LanguageError::New(String::Handle(String::New(chars)))); |
| 2428 Isolate::Current()->long_jump_base()->Jump(1, error); | 2529 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2429 } | 2530 } |
| 2430 | 2531 |
| 2431 | 2532 |
| 2432 } // namespace dart | 2533 } // namespace dart |
| OLD | NEW |