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

Side by Side Diff: runtime/vm/flow_graph_builder.cc

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

Powered by Google App Engine
This is Rietveld 408576698