OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } else { | 59 } else { |
60 exit()->set_next(other_fragment.entry()); | 60 exit()->set_next(other_fragment.entry()); |
61 exit_ = other_fragment.exit(); | 61 exit_ = other_fragment.exit(); |
62 } | 62 } |
63 temp_index_ = other_fragment.temp_index(); | 63 temp_index_ = other_fragment.temp_index(); |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 Value* EffectGraphVisitor::Bind(Definition* definition) { | 67 Value* EffectGraphVisitor::Bind(Definition* definition) { |
68 ASSERT(is_open()); | 68 ASSERT(is_open()); |
69 ASSERT(!owner()->InInliningContext() || !definition->CanDeoptimize()); | |
70 DeallocateTempIndex(definition->InputCount()); | 69 DeallocateTempIndex(definition->InputCount()); |
71 definition->set_use_kind(Definition::kValue); | 70 definition->set_use_kind(Definition::kValue); |
72 definition->set_temp_index(AllocateTempIndex()); | 71 definition->set_temp_index(AllocateTempIndex()); |
73 if (is_empty()) { | 72 if (is_empty()) { |
74 entry_ = definition; | 73 entry_ = definition; |
75 } else { | 74 } else { |
76 exit()->set_next(definition); | 75 exit()->set_next(definition); |
77 } | 76 } |
78 exit_ = definition; | 77 exit_ = definition; |
79 return new Value(definition); | 78 return new Value(definition); |
80 } | 79 } |
81 | 80 |
82 | 81 |
83 void EffectGraphVisitor::Do(Definition* definition) { | 82 void EffectGraphVisitor::Do(Definition* definition) { |
84 ASSERT(is_open()); | 83 ASSERT(is_open()); |
85 ASSERT(!owner()->InInliningContext() || !definition->CanDeoptimize()); | |
86 DeallocateTempIndex(definition->InputCount()); | 84 DeallocateTempIndex(definition->InputCount()); |
87 definition->set_use_kind(Definition::kEffect); | 85 definition->set_use_kind(Definition::kEffect); |
88 if (is_empty()) { | 86 if (is_empty()) { |
89 entry_ = definition; | 87 entry_ = definition; |
90 } else { | 88 } else { |
91 exit()->set_next(definition); | 89 exit()->set_next(definition); |
92 } | 90 } |
93 exit_ = definition; | 91 exit_ = definition; |
94 } | 92 } |
95 | 93 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 MergeBranchWithNegate(neg); | 408 MergeBranchWithNegate(neg); |
411 return; | 409 return; |
412 } | 410 } |
413 } | 411 } |
414 ReturnValue(Bind(definition)); | 412 ReturnValue(Bind(definition)); |
415 } | 413 } |
416 | 414 |
417 | 415 |
418 // Special handling for AND/OR. | 416 // Special handling for AND/OR. |
419 void TestGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { | 417 void TestGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { |
420 InlineBailout("TestGraphVisitor::VisitBinaryOpNode"); | |
421 | |
422 // Operators "&&" and "||" cannot be overloaded therefore do not call | 418 // Operators "&&" and "||" cannot be overloaded therefore do not call |
423 // operator. | 419 // operator. |
424 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { | 420 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { |
425 TestGraphVisitor for_left(owner(), | 421 TestGraphVisitor for_left(owner(), |
426 temp_index(), | 422 temp_index(), |
427 node->left()->token_pos()); | 423 node->left()->token_pos()); |
428 node->left()->Visit(&for_left); | 424 node->left()->Visit(&for_left); |
429 | 425 |
430 TestGraphVisitor for_right(owner(), | 426 TestGraphVisitor for_right(owner(), |
431 temp_index(), | 427 temp_index(), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 460 |
465 | 461 |
466 // <Statement> ::= Return { value: <Expression> | 462 // <Statement> ::= Return { value: <Expression> |
467 // inlined_finally_list: <InlinedFinally>* } | 463 // inlined_finally_list: <InlinedFinally>* } |
468 void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) { | 464 void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) { |
469 ValueGraphVisitor for_value(owner(), temp_index()); | 465 ValueGraphVisitor for_value(owner(), temp_index()); |
470 node->value()->Visit(&for_value); | 466 node->value()->Visit(&for_value); |
471 Append(for_value); | 467 Append(for_value); |
472 | 468 |
473 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { | 469 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { |
474 InlineBailout("EffectGraphVisitor::VisitReturnNode (finally)"); | 470 InlineBailout("EffectGraphVisitor::VisitReturnNode (exception)"); |
475 EffectGraphVisitor for_effect(owner(), temp_index()); | 471 EffectGraphVisitor for_effect(owner(), temp_index()); |
476 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); | 472 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); |
477 Append(for_effect); | 473 Append(for_effect); |
478 if (!is_open()) return; | 474 if (!is_open()) return; |
479 } | 475 } |
480 | 476 |
481 Value* return_value = for_value.value(); | 477 Value* return_value = for_value.value(); |
482 if (FLAG_enable_type_checks) { | 478 if (FLAG_enable_type_checks) { |
483 const Function& function = owner()->parsed_function().function(); | 479 const Function& function = owner()->parsed_function().function(); |
484 const bool is_implicit_dynamic_getter = | 480 const bool is_implicit_dynamic_getter = |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 EffectGraphVisitor for_right(owner(), temp_index()); | 617 EffectGraphVisitor for_right(owner(), temp_index()); |
622 node->right()->Visit(&for_right); | 618 node->right()->Visit(&for_right); |
623 EffectGraphVisitor empty(owner(), temp_index()); | 619 EffectGraphVisitor empty(owner(), temp_index()); |
624 if (node->kind() == Token::kAND) { | 620 if (node->kind() == Token::kAND) { |
625 Join(for_left, for_right, empty); | 621 Join(for_left, for_right, empty); |
626 } else { | 622 } else { |
627 Join(for_left, empty, for_right); | 623 Join(for_left, empty, for_right); |
628 } | 624 } |
629 return; | 625 return; |
630 } | 626 } |
631 InlineBailout("EffectGraphVisitor::VisitBinaryOpNode (deopt)"); | |
632 ValueGraphVisitor for_left_value(owner(), temp_index()); | 627 ValueGraphVisitor for_left_value(owner(), temp_index()); |
633 node->left()->Visit(&for_left_value); | 628 node->left()->Visit(&for_left_value); |
634 Append(for_left_value); | 629 Append(for_left_value); |
635 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); | 630 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); |
636 | 631 |
637 ValueGraphVisitor for_right_value(owner(), temp_index()); | 632 ValueGraphVisitor for_right_value(owner(), temp_index()); |
638 node->right()->Visit(&for_right_value); | 633 node->right()->Visit(&for_right_value); |
639 Append(for_right_value); | 634 Append(for_right_value); |
640 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); | 635 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); |
641 | 636 |
(...skipping 26 matching lines...) Expand all Loading... |
668 | 663 |
669 TestGraphVisitor for_test(owner(), | 664 TestGraphVisitor for_test(owner(), |
670 temp_index(), | 665 temp_index(), |
671 node->left()->token_pos()); | 666 node->left()->token_pos()); |
672 node->left()->Visit(&for_test); | 667 node->left()->Visit(&for_test); |
673 | 668 |
674 ValueGraphVisitor for_right(owner(), temp_index()); | 669 ValueGraphVisitor for_right(owner(), temp_index()); |
675 node->right()->Visit(&for_right); | 670 node->right()->Visit(&for_right); |
676 Value* right_value = for_right.value(); | 671 Value* right_value = for_right.value(); |
677 if (FLAG_enable_type_checks) { | 672 if (FLAG_enable_type_checks) { |
678 InlineBailout("ValueGraphVisitor::VisitBinaryOpNode (type check)"); | |
679 right_value = | 673 right_value = |
680 for_right.Bind(new AssertBooleanInstr(node->right()->token_pos(), | 674 for_right.Bind(new AssertBooleanInstr(node->right()->token_pos(), |
681 right_value)); | 675 right_value)); |
682 } | 676 } |
683 Value* constant_true = for_right.Bind(new ConstantInstr(bool_true)); | 677 Value* constant_true = for_right.Bind(new ConstantInstr(bool_true)); |
684 Value* compare = | 678 Value* compare = |
685 for_right.Bind(new StrictCompareInstr(Token::kEQ_STRICT, | 679 for_right.Bind(new StrictCompareInstr(Token::kEQ_STRICT, |
686 right_value, | 680 right_value, |
687 constant_true)); | 681 constant_true)); |
688 for_right.Do(BuildStoreExprTemp(compare)); | 682 for_right.Do(BuildStoreExprTemp(compare)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 return Bind(new ConstantInstr(Object::ZoneHandle())); | 732 return Bind(new ConstantInstr(Object::ZoneHandle())); |
739 } | 733 } |
740 | 734 |
741 | 735 |
742 // Used for testing incoming arguments. | 736 // Used for testing incoming arguments. |
743 AssertAssignableInstr* EffectGraphVisitor::BuildAssertAssignable( | 737 AssertAssignableInstr* EffectGraphVisitor::BuildAssertAssignable( |
744 intptr_t token_pos, | 738 intptr_t token_pos, |
745 Value* value, | 739 Value* value, |
746 const AbstractType& dst_type, | 740 const AbstractType& dst_type, |
747 const String& dst_name) { | 741 const String& dst_name) { |
748 InlineBailout("EffectGraphVisitor::BuildAssertAssignable (deopt)"); | |
749 // Build the type check computation. | 742 // Build the type check computation. |
750 Value* instantiator = NULL; | 743 Value* instantiator = NULL; |
751 Value* instantiator_type_arguments = NULL; | 744 Value* instantiator_type_arguments = NULL; |
752 if (dst_type.IsInstantiated()) { | 745 if (dst_type.IsInstantiated()) { |
753 instantiator = BuildNullValue(); | 746 instantiator = BuildNullValue(); |
754 instantiator_type_arguments = BuildNullValue(); | 747 instantiator_type_arguments = BuildNullValue(); |
755 } else { | 748 } else { |
756 BuildTypecheckArguments(token_pos, | 749 BuildTypecheckArguments(token_pos, |
757 &instantiator, | 750 &instantiator, |
758 &instantiator_type_arguments); | 751 &instantiator_type_arguments); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 } else { | 829 } else { |
837 if (literal_value.IsInstanceOf(type, TypeArguments::Handle(), NULL)) { | 830 if (literal_value.IsInstanceOf(type, TypeArguments::Handle(), NULL)) { |
838 result = new ConstantInstr(negate_result ? bool_false : bool_true); | 831 result = new ConstantInstr(negate_result ? bool_false : bool_true); |
839 } else { | 832 } else { |
840 result = new ConstantInstr(negate_result ? bool_true : bool_false); | 833 result = new ConstantInstr(negate_result ? bool_true : bool_false); |
841 } | 834 } |
842 } | 835 } |
843 ReturnDefinition(result); | 836 ReturnDefinition(result); |
844 return; | 837 return; |
845 } | 838 } |
846 InlineBailout("ValueGraphVisitor::BuildTypeTest (deopt)"); | |
847 | 839 |
848 ValueGraphVisitor for_left_value(owner(), temp_index()); | 840 ValueGraphVisitor for_left_value(owner(), temp_index()); |
849 node->left()->Visit(&for_left_value); | 841 node->left()->Visit(&for_left_value); |
850 Append(for_left_value); | 842 Append(for_left_value); |
851 Value* instantiator = NULL; | 843 Value* instantiator = NULL; |
852 Value* instantiator_type_arguments = NULL; | 844 Value* instantiator_type_arguments = NULL; |
853 if (type.IsInstantiated()) { | 845 if (type.IsInstantiated()) { |
854 instantiator = BuildNullValue(); | 846 instantiator = BuildNullValue(); |
855 instantiator_type_arguments = BuildNullValue(); | 847 instantiator_type_arguments = BuildNullValue(); |
856 } else { | 848 } else { |
857 BuildTypecheckArguments(node->token_pos(), | 849 BuildTypecheckArguments(node->token_pos(), |
858 &instantiator, | 850 &instantiator, |
859 &instantiator_type_arguments); | 851 &instantiator_type_arguments); |
860 } | 852 } |
| 853 // TODO(zerny): Remove this when issues 5216 and 5217 are fixed. |
| 854 InlineBailout("instance of"); |
861 InstanceOfInstr* instance_of = | 855 InstanceOfInstr* instance_of = |
862 new InstanceOfInstr(node->token_pos(), | 856 new InstanceOfInstr(node->token_pos(), |
863 for_left_value.value(), | 857 for_left_value.value(), |
864 instantiator, | 858 instantiator, |
865 instantiator_type_arguments, | 859 instantiator_type_arguments, |
866 node->right()->AsTypeNode()->type(), | 860 node->right()->AsTypeNode()->type(), |
867 (node->kind() == Token::kISNOT)); | 861 (node->kind() == Token::kISNOT)); |
868 ReturnDefinition(instance_of); | 862 ReturnDefinition(instance_of); |
869 } | 863 } |
870 | 864 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 node->left()->Visit(&for_left_value); | 898 node->left()->Visit(&for_left_value); |
905 Append(for_left_value); | 899 Append(for_left_value); |
906 ValueGraphVisitor for_right_value(owner(), temp_index()); | 900 ValueGraphVisitor for_right_value(owner(), temp_index()); |
907 node->right()->Visit(&for_right_value); | 901 node->right()->Visit(&for_right_value); |
908 Append(for_right_value); | 902 Append(for_right_value); |
909 StrictCompareInstr* comp = new StrictCompareInstr( | 903 StrictCompareInstr* comp = new StrictCompareInstr( |
910 node->kind(), for_left_value.value(), for_right_value.value()); | 904 node->kind(), for_left_value.value(), for_right_value.value()); |
911 ReturnDefinition(comp); | 905 ReturnDefinition(comp); |
912 return; | 906 return; |
913 } | 907 } |
914 InlineBailout("EffectGraphVisitor::VisitComparisonNode (deopt)"); | |
915 | 908 |
916 if ((node->kind() == Token::kEQ) || (node->kind() == Token::kNE)) { | 909 if ((node->kind() == Token::kEQ) || (node->kind() == Token::kNE)) { |
917 ValueGraphVisitor for_left_value(owner(), temp_index()); | 910 ValueGraphVisitor for_left_value(owner(), temp_index()); |
918 node->left()->Visit(&for_left_value); | 911 node->left()->Visit(&for_left_value); |
919 Append(for_left_value); | 912 Append(for_left_value); |
920 ValueGraphVisitor for_right_value(owner(), temp_index()); | 913 ValueGraphVisitor for_right_value(owner(), temp_index()); |
921 node->right()->Visit(&for_right_value); | 914 node->right()->Visit(&for_right_value); |
922 Append(for_right_value); | 915 Append(for_right_value); |
923 if (FLAG_enable_type_checks) { | 916 if (FLAG_enable_type_checks) { |
924 EqualityCompareInstr* comp = new EqualityCompareInstr( | 917 EqualityCompareInstr* comp = new EqualityCompareInstr( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 Append(for_value); | 959 Append(for_value); |
967 Value* value = for_value.value(); | 960 Value* value = for_value.value(); |
968 if (FLAG_enable_type_checks) { | 961 if (FLAG_enable_type_checks) { |
969 value = | 962 value = |
970 Bind(new AssertBooleanInstr(node->operand()->token_pos(), value)); | 963 Bind(new AssertBooleanInstr(node->operand()->token_pos(), value)); |
971 } | 964 } |
972 BooleanNegateInstr* negate = new BooleanNegateInstr(value); | 965 BooleanNegateInstr* negate = new BooleanNegateInstr(value); |
973 ReturnDefinition(negate); | 966 ReturnDefinition(negate); |
974 return; | 967 return; |
975 } | 968 } |
976 InlineBailout("EffectGraphVisitor::VisitUnaryOpNode (deopt)"); | |
977 | 969 |
978 ValueGraphVisitor for_value(owner(), temp_index()); | 970 ValueGraphVisitor for_value(owner(), temp_index()); |
979 node->operand()->Visit(&for_value); | 971 node->operand()->Visit(&for_value); |
980 Append(for_value); | 972 Append(for_value); |
981 PushArgumentInstr* push_value = PushArgument(for_value.value()); | 973 PushArgumentInstr* push_value = PushArgument(for_value.value()); |
982 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 974 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
983 new ZoneGrowableArray<PushArgumentInstr*>(1); | 975 new ZoneGrowableArray<PushArgumentInstr*>(1); |
984 arguments->Add(push_value); | 976 arguments->Add(push_value); |
985 InstanceCallInstr* call = (node->kind() == Token::kSUB) | 977 InstanceCallInstr* call = (node->kind() == Token::kSUB) |
986 ? new InstanceCallInstr(node->token_pos(), | 978 ? new InstanceCallInstr(node->token_pos(), |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 // e) true-target-0 -> case-statements-join | 1078 // e) true-target-0 -> case-statements-join |
1087 // f) true-target-1 -> case-statements-join | 1079 // f) true-target-1 -> case-statements-join |
1088 // g) case-statements-join | 1080 // g) case-statements-join |
1089 // h) [ case-statements ] -> exit-join | 1081 // h) [ case-statements ] -> exit-join |
1090 // i) exit-target -> exit-join | 1082 // i) exit-target -> exit-join |
1091 // j) exit-join | 1083 // j) exit-join |
1092 // | 1084 // |
1093 // Note: The specification of switch/case is under discussion and may change | 1085 // Note: The specification of switch/case is under discussion and may change |
1094 // drastically. | 1086 // drastically. |
1095 void EffectGraphVisitor::VisitCaseNode(CaseNode* node) { | 1087 void EffectGraphVisitor::VisitCaseNode(CaseNode* node) { |
1096 InlineBailout("EffectGraphVisitor::VisitCaseNode"); | 1088 InlineBailout("EffectGraphVisitor::VisitCaseNode (control)"); |
1097 const intptr_t len = node->case_expressions()->length(); | 1089 const intptr_t len = node->case_expressions()->length(); |
1098 // Create case statements instructions. | 1090 // Create case statements instructions. |
1099 EffectGraphVisitor for_case_statements(owner(), temp_index()); | 1091 EffectGraphVisitor for_case_statements(owner(), temp_index()); |
1100 // Compute start of statements fragment. | 1092 // Compute start of statements fragment. |
1101 JoinEntryInstr* statement_start = NULL; | 1093 JoinEntryInstr* statement_start = NULL; |
1102 if ((node->label() != NULL) && node->label()->is_continue_target()) { | 1094 if ((node->label() != NULL) && node->label()->is_continue_target()) { |
1103 // Since a labeled jump continue statement occur in a different case node, | 1095 // Since a labeled jump continue statement occur in a different case node, |
1104 // allocate JoinNode here and use it as statement start. | 1096 // allocate JoinNode here and use it as statement start. |
1105 statement_start = node->label()->join_for_continue(); | 1097 statement_start = node->label()->join_for_continue(); |
1106 if (statement_start == NULL) { | 1098 if (statement_start == NULL) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 // body: <Sequence> } | 1171 // body: <Sequence> } |
1180 // The fragment is composed as follows: | 1172 // The fragment is composed as follows: |
1181 // a) loop-join | 1173 // a) loop-join |
1182 // b) [ test ] -> (body-entry-target, loop-exit-target) | 1174 // b) [ test ] -> (body-entry-target, loop-exit-target) |
1183 // c) body-entry-target | 1175 // c) body-entry-target |
1184 // d) [ body ] -> (continue-join) | 1176 // d) [ body ] -> (continue-join) |
1185 // e) continue-join -> (loop-join) | 1177 // e) continue-join -> (loop-join) |
1186 // f) loop-exit-target | 1178 // f) loop-exit-target |
1187 // g) break-join (optional) | 1179 // g) break-join (optional) |
1188 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { | 1180 void EffectGraphVisitor::VisitWhileNode(WhileNode* node) { |
1189 InlineBailout("EffectGraphVisitor::VisitWhileNode"); | 1181 InlineBailout("EffectGraphVisitor::VisitWhileNode (control)"); |
1190 TestGraphVisitor for_test(owner(), | 1182 TestGraphVisitor for_test(owner(), |
1191 temp_index(), | 1183 temp_index(), |
1192 node->condition()->token_pos()); | 1184 node->condition()->token_pos()); |
1193 node->condition()->Visit(&for_test); | 1185 node->condition()->Visit(&for_test); |
1194 ASSERT(!for_test.is_empty()); // Language spec. | 1186 ASSERT(!for_test.is_empty()); // Language spec. |
1195 | 1187 |
1196 EffectGraphVisitor for_body(owner(), temp_index()); | 1188 EffectGraphVisitor for_body(owner(), temp_index()); |
1197 for_body.Do( | 1189 for_body.Do( |
1198 new CheckStackOverflowInstr(node->token_pos())); | 1190 new CheckStackOverflowInstr(node->token_pos())); |
1199 node->body()->Visit(&for_body); | 1191 node->body()->Visit(&for_body); |
(...skipping 17 matching lines...) Expand all Loading... |
1217 | 1209 |
1218 // The fragment is composed as follows: | 1210 // The fragment is composed as follows: |
1219 // a) body-entry-join | 1211 // a) body-entry-join |
1220 // b) [ body ] | 1212 // b) [ body ] |
1221 // c) test-entry (continue-join or body-exit-target) | 1213 // c) test-entry (continue-join or body-exit-target) |
1222 // d) [ test-entry ] -> (back-target, loop-exit-target) | 1214 // d) [ test-entry ] -> (back-target, loop-exit-target) |
1223 // e) back-target -> (body-entry-join) | 1215 // e) back-target -> (body-entry-join) |
1224 // f) loop-exit-target | 1216 // f) loop-exit-target |
1225 // g) break-join | 1217 // g) break-join |
1226 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { | 1218 void EffectGraphVisitor::VisitDoWhileNode(DoWhileNode* node) { |
1227 InlineBailout("EffectGraphVisitor::VisitDoWhileNode"); | 1219 InlineBailout("EffectGraphVisitor::VisitDoWhileNode (control)"); |
1228 // Traverse body first in order to generate continue and break labels. | 1220 // Traverse body first in order to generate continue and break labels. |
1229 EffectGraphVisitor for_body(owner(), temp_index()); | 1221 EffectGraphVisitor for_body(owner(), temp_index()); |
1230 for_body.Do( | 1222 for_body.Do( |
1231 new CheckStackOverflowInstr(node->token_pos())); | 1223 new CheckStackOverflowInstr(node->token_pos())); |
1232 node->body()->Visit(&for_body); | 1224 node->body()->Visit(&for_body); |
1233 | 1225 |
1234 TestGraphVisitor for_test(owner(), | 1226 TestGraphVisitor for_test(owner(), |
1235 temp_index(), | 1227 temp_index(), |
1236 node->condition()->token_pos()); | 1228 node->condition()->token_pos()); |
1237 node->condition()->Visit(&for_test); | 1229 node->condition()->Visit(&for_test); |
(...skipping 30 matching lines...) Expand all Loading... |
1268 // a) [ initializer ] | 1260 // a) [ initializer ] |
1269 // b) loop-join | 1261 // b) loop-join |
1270 // c) [ test ] -> (body-entry-target, loop-exit-target) | 1262 // c) [ test ] -> (body-entry-target, loop-exit-target) |
1271 // d) body-entry-target | 1263 // d) body-entry-target |
1272 // e) [ body ] | 1264 // e) [ body ] |
1273 // f) continue-join (optional) | 1265 // f) continue-join (optional) |
1274 // g) [ increment ] -> (loop-join) | 1266 // g) [ increment ] -> (loop-join) |
1275 // h) loop-exit-target | 1267 // h) loop-exit-target |
1276 // i) break-join | 1268 // i) break-join |
1277 void EffectGraphVisitor::VisitForNode(ForNode* node) { | 1269 void EffectGraphVisitor::VisitForNode(ForNode* node) { |
1278 InlineBailout("EffectGraphVisitor::VisitForNode"); | 1270 InlineBailout("EffectGraphVisitor::VisitForNode (control)"); |
1279 EffectGraphVisitor for_initializer(owner(), temp_index()); | 1271 EffectGraphVisitor for_initializer(owner(), temp_index()); |
1280 node->initializer()->Visit(&for_initializer); | 1272 node->initializer()->Visit(&for_initializer); |
1281 Append(for_initializer); | 1273 Append(for_initializer); |
1282 ASSERT(is_open()); | 1274 ASSERT(is_open()); |
1283 | 1275 |
1284 // Compose body to set any jump labels. | 1276 // Compose body to set any jump labels. |
1285 EffectGraphVisitor for_body(owner(), temp_index()); | 1277 EffectGraphVisitor for_body(owner(), temp_index()); |
1286 for_body.Do( | 1278 for_body.Do( |
1287 new CheckStackOverflowInstr(node->token_pos())); | 1279 new CheckStackOverflowInstr(node->token_pos())); |
1288 node->body()->Visit(&for_body); | 1280 node->body()->Visit(&for_body); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 exit_ = for_test.CreateFalseSuccessor(); | 1332 exit_ = for_test.CreateFalseSuccessor(); |
1341 } else { | 1333 } else { |
1342 for_test.IfFalseGoto(node->label()->join_for_break()); | 1334 for_test.IfFalseGoto(node->label()->join_for_break()); |
1343 exit_ = node->label()->join_for_break(); | 1335 exit_ = node->label()->join_for_break(); |
1344 } | 1336 } |
1345 } | 1337 } |
1346 } | 1338 } |
1347 | 1339 |
1348 | 1340 |
1349 void EffectGraphVisitor::VisitJumpNode(JumpNode* node) { | 1341 void EffectGraphVisitor::VisitJumpNode(JumpNode* node) { |
1350 InlineBailout("EffectGraphVisitor::VisitJumpNode"); | 1342 InlineBailout("EffectGraphVisitor::VisitJumpNode (control)"); |
1351 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { | 1343 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { |
1352 EffectGraphVisitor for_effect(owner(), temp_index()); | 1344 EffectGraphVisitor for_effect(owner(), temp_index()); |
1353 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); | 1345 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); |
1354 Append(for_effect); | 1346 Append(for_effect); |
1355 if (!is_open()) return; | 1347 if (!is_open()) return; |
1356 } | 1348 } |
1357 | 1349 |
1358 // Unchain the context(s) up to the outer context level of the scope which | 1350 // Unchain the context(s) up to the outer context level of the scope which |
1359 // contains the destination label. | 1351 // contains the destination label. |
1360 SourceLabel* label = node->label(); | 1352 SourceLabel* label = node->label(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 ValueGraphVisitor for_argument(owner(), temp_index()); | 1497 ValueGraphVisitor for_argument(owner(), temp_index()); |
1506 node.NodeAt(i)->Visit(&for_argument); | 1498 node.NodeAt(i)->Visit(&for_argument); |
1507 Append(for_argument); | 1499 Append(for_argument); |
1508 PushArgumentInstr* push_arg = PushArgument(for_argument.value()); | 1500 PushArgumentInstr* push_arg = PushArgument(for_argument.value()); |
1509 values->Add(push_arg); | 1501 values->Add(push_arg); |
1510 } | 1502 } |
1511 } | 1503 } |
1512 | 1504 |
1513 | 1505 |
1514 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { | 1506 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { |
1515 InlineBailout("EffectGraphVisitor::VisitInstanceCallNode (deopt)"); | |
1516 ValueGraphVisitor for_receiver(owner(), temp_index()); | 1507 ValueGraphVisitor for_receiver(owner(), temp_index()); |
1517 node->receiver()->Visit(&for_receiver); | 1508 node->receiver()->Visit(&for_receiver); |
1518 Append(for_receiver); | 1509 Append(for_receiver); |
1519 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); | 1510 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); |
1520 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1511 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1521 new ZoneGrowableArray<PushArgumentInstr*>( | 1512 new ZoneGrowableArray<PushArgumentInstr*>( |
1522 node->arguments()->length() + 1); | 1513 node->arguments()->length() + 1); |
1523 arguments->Add(push_receiver); | 1514 arguments->Add(push_receiver); |
1524 | 1515 |
1525 BuildPushArguments(*node->arguments(), arguments); | 1516 BuildPushArguments(*node->arguments(), arguments); |
1526 InstanceCallInstr* call = new InstanceCallInstr( | 1517 InstanceCallInstr* call = new InstanceCallInstr( |
1527 node->token_pos(), | 1518 node->token_pos(), |
1528 node->function_name(), Token::kILLEGAL, arguments, | 1519 node->function_name(), Token::kILLEGAL, arguments, |
1529 node->arguments()->names(), 1); | 1520 node->arguments()->names(), 1); |
1530 ReturnDefinition(call); | 1521 ReturnDefinition(call); |
1531 } | 1522 } |
1532 | 1523 |
1533 | 1524 |
1534 // <Expression> ::= StaticCall { function: Function | 1525 // <Expression> ::= StaticCall { function: Function |
1535 // arguments: <ArgumentList> } | 1526 // arguments: <ArgumentList> } |
1536 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { | 1527 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { |
1537 InlineBailout("EffectGraphVisitor::VisitStaticCallNode (deopt)"); | |
1538 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1528 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1539 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); | 1529 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); |
1540 BuildPushArguments(*node->arguments(), arguments); | 1530 BuildPushArguments(*node->arguments(), arguments); |
1541 StaticCallInstr* call = | 1531 StaticCallInstr* call = |
1542 new StaticCallInstr(node->token_pos(), | 1532 new StaticCallInstr(node->token_pos(), |
1543 node->function(), | 1533 node->function(), |
1544 node->arguments()->names(), | 1534 node->arguments()->names(), |
1545 arguments); | 1535 arguments); |
1546 ReturnDefinition(call); | 1536 ReturnDefinition(call); |
1547 } | 1537 } |
1548 | 1538 |
1549 | 1539 |
1550 ClosureCallInstr* EffectGraphVisitor::BuildClosureCall( | 1540 ClosureCallInstr* EffectGraphVisitor::BuildClosureCall( |
1551 ClosureCallNode* node) { | 1541 ClosureCallNode* node) { |
1552 InlineBailout("EffectGraphVisitor::BuildClosureCall (deopt)"); | |
1553 ValueGraphVisitor for_closure(owner(), temp_index()); | 1542 ValueGraphVisitor for_closure(owner(), temp_index()); |
1554 node->closure()->Visit(&for_closure); | 1543 node->closure()->Visit(&for_closure); |
1555 Append(for_closure); | 1544 Append(for_closure); |
1556 PushArgumentInstr* push_closure = PushArgument(for_closure.value()); | 1545 PushArgumentInstr* push_closure = PushArgument(for_closure.value()); |
1557 | 1546 |
1558 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1547 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1559 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); | 1548 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); |
1560 arguments->Add(push_closure); | 1549 arguments->Add(push_closure); |
1561 BuildPushArguments(*node->arguments(), arguments); | 1550 BuildPushArguments(*node->arguments(), arguments); |
1562 | 1551 |
(...skipping 12 matching lines...) Expand all Loading... |
1575 | 1564 |
1576 void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { | 1565 void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { |
1577 Value* result = Bind(BuildClosureCall(node)); | 1566 Value* result = Bind(BuildClosureCall(node)); |
1578 // Restore context from temp. | 1567 // Restore context from temp. |
1579 BuildLoadContext(*owner()->parsed_function().expression_temp_var()); | 1568 BuildLoadContext(*owner()->parsed_function().expression_temp_var()); |
1580 ReturnValue(result); | 1569 ReturnValue(result); |
1581 } | 1570 } |
1582 | 1571 |
1583 | 1572 |
1584 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { | 1573 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { |
1585 InlineBailout("EffectGraphVisitor::VisitCloneContextNode (deopt)"); | 1574 InlineBailout("EffectGraphVisitor::VisitCloneContextNode (context)"); |
1586 Value* context = Bind(new CurrentContextInstr()); | 1575 Value* context = Bind(new CurrentContextInstr()); |
1587 Value* clone = Bind(new CloneContextInstr(node->token_pos(), context)); | 1576 Value* clone = Bind(new CloneContextInstr(node->token_pos(), context)); |
1588 ReturnDefinition(new StoreContextInstr(clone)); | 1577 ReturnDefinition(new StoreContextInstr(clone)); |
1589 } | 1578 } |
1590 | 1579 |
1591 | 1580 |
1592 Value* EffectGraphVisitor::BuildObjectAllocation( | 1581 Value* EffectGraphVisitor::BuildObjectAllocation( |
1593 ConstructorCallNode* node) { | 1582 ConstructorCallNode* node) { |
1594 const Class& cls = Class::ZoneHandle(node->constructor().Owner()); | 1583 const Class& cls = Class::ZoneHandle(node->constructor().Owner()); |
1595 const bool requires_type_arguments = cls.HasTypeArguments(); | 1584 const bool requires_type_arguments = cls.HasTypeArguments(); |
(...skipping 10 matching lines...) Expand all Loading... |
1606 NULL)) { | 1595 NULL)) { |
1607 Value* type_arguments = NULL; | 1596 Value* type_arguments = NULL; |
1608 Value* instantiator = NULL; | 1597 Value* instantiator = NULL; |
1609 BuildConstructorTypeArguments(node, &type_arguments, &instantiator, NULL); | 1598 BuildConstructorTypeArguments(node, &type_arguments, &instantiator, NULL); |
1610 | 1599 |
1611 // The uninstantiated type arguments cannot be verified to be within their | 1600 // The uninstantiated type arguments cannot be verified to be within their |
1612 // bounds at compile time, so verify them at runtime. | 1601 // bounds at compile time, so verify them at runtime. |
1613 // Although the type arguments may be uninstantiated at compile time, they | 1602 // Although the type arguments may be uninstantiated at compile time, they |
1614 // may represent the identity vector and may be replaced by the instantiated | 1603 // may represent the identity vector and may be replaced by the instantiated |
1615 // type arguments of the instantiator at run time. | 1604 // type arguments of the instantiator at run time. |
1616 InlineBailout("EffectGraphVisitor::BuildObjectAllocation (deopt)"); | |
1617 allocate_comp = new AllocateObjectWithBoundsCheckInstr(node, | 1605 allocate_comp = new AllocateObjectWithBoundsCheckInstr(node, |
1618 type_arguments, | 1606 type_arguments, |
1619 instantiator); | 1607 instantiator); |
1620 } else { | 1608 } else { |
1621 ZoneGrowableArray<PushArgumentInstr*>* allocate_arguments = | 1609 ZoneGrowableArray<PushArgumentInstr*>* allocate_arguments = |
1622 new ZoneGrowableArray<PushArgumentInstr*>(); | 1610 new ZoneGrowableArray<PushArgumentInstr*>(); |
1623 | 1611 |
1624 if (requires_type_arguments) { | 1612 if (requires_type_arguments) { |
1625 BuildConstructorTypeArguments(node, NULL, NULL, allocate_arguments); | 1613 BuildConstructorTypeArguments(node, NULL, NULL, allocate_arguments); |
1626 } | 1614 } |
1627 | 1615 |
1628 allocate_comp = new AllocateObjectInstr(node, allocate_arguments); | 1616 allocate_comp = new AllocateObjectInstr(node, allocate_arguments); |
1629 } | 1617 } |
1630 return Bind(allocate_comp); | 1618 return Bind(allocate_comp); |
1631 } | 1619 } |
1632 | 1620 |
1633 | 1621 |
1634 void EffectGraphVisitor::BuildConstructorCall( | 1622 void EffectGraphVisitor::BuildConstructorCall( |
1635 ConstructorCallNode* node, | 1623 ConstructorCallNode* node, |
1636 PushArgumentInstr* push_alloc_value) { | 1624 PushArgumentInstr* push_alloc_value) { |
1637 InlineBailout("EffectGraphVisitor::BuildConstructorCall (deopt)"); | |
1638 Value* ctor_arg = Bind( | 1625 Value* ctor_arg = Bind( |
1639 new ConstantInstr(Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll)))); | 1626 new ConstantInstr(Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll)))); |
1640 PushArgumentInstr* push_ctor_arg = PushArgument(ctor_arg); | 1627 PushArgumentInstr* push_ctor_arg = PushArgument(ctor_arg); |
1641 | 1628 |
1642 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1629 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1643 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1630 new ZoneGrowableArray<PushArgumentInstr*>(2); |
1644 arguments->Add(push_alloc_value); | 1631 arguments->Add(push_alloc_value); |
1645 arguments->Add(push_ctor_arg); | 1632 arguments->Add(push_ctor_arg); |
1646 | 1633 |
1647 BuildPushArguments(*node->arguments(), arguments); | 1634 BuildPushArguments(*node->arguments(), arguments); |
(...skipping 22 matching lines...) Expand all Loading... |
1670 } | 1657 } |
1671 } | 1658 } |
1672 } | 1659 } |
1673 } | 1660 } |
1674 return kDynamicCid; // Result cid not known. | 1661 return kDynamicCid; // Result cid not known. |
1675 } | 1662 } |
1676 | 1663 |
1677 | 1664 |
1678 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { | 1665 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { |
1679 if (node->constructor().IsFactory()) { | 1666 if (node->constructor().IsFactory()) { |
1680 InlineBailout("EffectGraphVisitor::VisitConstructorCallNode (deopt)"); | |
1681 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1667 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1682 new ZoneGrowableArray<PushArgumentInstr*>(); | 1668 new ZoneGrowableArray<PushArgumentInstr*>(); |
1683 PushArgumentInstr* push_type_arguments = PushArgument( | 1669 PushArgumentInstr* push_type_arguments = PushArgument( |
1684 BuildInstantiatedTypeArguments(node->token_pos(), | 1670 BuildInstantiatedTypeArguments(node->token_pos(), |
1685 node->type_arguments())); | 1671 node->type_arguments())); |
1686 arguments->Add(push_type_arguments); | 1672 arguments->Add(push_type_arguments); |
1687 ASSERT(arguments->length() == 1); | 1673 ASSERT(arguments->length() == 1); |
1688 BuildPushArguments(*node->arguments(), arguments); | 1674 BuildPushArguments(*node->arguments(), arguments); |
1689 StaticCallInstr* call = | 1675 StaticCallInstr* call = |
1690 new StaticCallInstr(node->token_pos(), | 1676 new StaticCallInstr(node->token_pos(), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 instantiator = BuildInstantiator(); | 1754 instantiator = BuildInstantiator(); |
1769 } | 1755 } |
1770 // The instantiator is the receiver of the caller, which is not a factory. | 1756 // The instantiator is the receiver of the caller, which is not a factory. |
1771 // The receiver cannot be null; extract its AbstractTypeArguments object. | 1757 // The receiver cannot be null; extract its AbstractTypeArguments object. |
1772 // Note that in the factory case, the instantiator is the first parameter | 1758 // Note that in the factory case, the instantiator is the first parameter |
1773 // of the factory, i.e. already an AbstractTypeArguments object. | 1759 // of the factory, i.e. already an AbstractTypeArguments object. |
1774 intptr_t type_arguments_instance_field_offset = | 1760 intptr_t type_arguments_instance_field_offset = |
1775 instantiator_class.type_arguments_instance_field_offset(); | 1761 instantiator_class.type_arguments_instance_field_offset(); |
1776 ASSERT(type_arguments_instance_field_offset != Class::kNoTypeArguments); | 1762 ASSERT(type_arguments_instance_field_offset != Class::kNoTypeArguments); |
1777 | 1763 |
1778 InlineBailout("EffectGraphVisitor::BuildInstantiatorTypeArguments (deopt)"); | |
1779 return Bind(new LoadFieldInstr( | 1764 return Bind(new LoadFieldInstr( |
1780 instantiator, | 1765 instantiator, |
1781 type_arguments_instance_field_offset, | 1766 type_arguments_instance_field_offset, |
1782 Type::ZoneHandle())); // Not an instance, no type. | 1767 Type::ZoneHandle())); // Not an instance, no type. |
1783 } | 1768 } |
1784 | 1769 |
1785 | 1770 |
1786 Value* EffectGraphVisitor::BuildInstantiatedTypeArguments( | 1771 Value* EffectGraphVisitor::BuildInstantiatedTypeArguments( |
1787 intptr_t token_pos, | 1772 intptr_t token_pos, |
1788 const AbstractTypeArguments& type_arguments) { | 1773 const AbstractTypeArguments& type_arguments) { |
1789 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { | 1774 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { |
1790 return Bind(new ConstantInstr(type_arguments)); | 1775 return Bind(new ConstantInstr(type_arguments)); |
1791 } | 1776 } |
1792 InlineBailout("EffectGraphVisitor::BuildInstantiatedTypeArguments (deopt)"); | |
1793 // The type arguments are uninstantiated. | 1777 // The type arguments are uninstantiated. |
1794 Value* instantiator_value = | 1778 Value* instantiator_value = |
1795 BuildInstantiatorTypeArguments(token_pos, NULL); | 1779 BuildInstantiatorTypeArguments(token_pos, NULL); |
1796 return Bind(new InstantiateTypeArgumentsInstr(token_pos, | 1780 return Bind(new InstantiateTypeArgumentsInstr(token_pos, |
1797 type_arguments, | 1781 type_arguments, |
1798 instantiator_value)); | 1782 instantiator_value)); |
1799 } | 1783 } |
1800 | 1784 |
1801 | 1785 |
1802 void EffectGraphVisitor::BuildConstructorTypeArguments( | 1786 void EffectGraphVisitor::BuildConstructorTypeArguments( |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); | 1886 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); |
1903 BuildConstructorCall(node, push_allocated_value); | 1887 BuildConstructorCall(node, push_allocated_value); |
1904 Definition* load_allocated = BuildLoadLocal( | 1888 Definition* load_allocated = BuildLoadLocal( |
1905 node->allocated_object_var()); | 1889 node->allocated_object_var()); |
1906 allocated_value = Bind(load_allocated); | 1890 allocated_value = Bind(load_allocated); |
1907 ReturnValue(allocated_value); | 1891 ReturnValue(allocated_value); |
1908 } | 1892 } |
1909 | 1893 |
1910 | 1894 |
1911 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { | 1895 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { |
1912 InlineBailout("EffectGraphVisitor::VisitInstanceGetterNode (deopt)"); | |
1913 ValueGraphVisitor for_receiver(owner(), temp_index()); | 1896 ValueGraphVisitor for_receiver(owner(), temp_index()); |
1914 node->receiver()->Visit(&for_receiver); | 1897 node->receiver()->Visit(&for_receiver); |
1915 Append(for_receiver); | 1898 Append(for_receiver); |
1916 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); | 1899 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); |
1917 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1900 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1918 new ZoneGrowableArray<PushArgumentInstr*>(1); | 1901 new ZoneGrowableArray<PushArgumentInstr*>(1); |
1919 arguments->Add(push_receiver); | 1902 arguments->Add(push_receiver); |
1920 const String& name = | 1903 const String& name = |
1921 String::ZoneHandle(Field::GetterSymbol(node->field_name())); | 1904 String::ZoneHandle(Field::GetterSymbol(node->field_name())); |
1922 InstanceCallInstr* call = new InstanceCallInstr( | 1905 InstanceCallInstr* call = new InstanceCallInstr( |
(...skipping 20 matching lines...) Expand all Loading... |
1943 if (result_is_needed) { | 1926 if (result_is_needed) { |
1944 value = Bind(BuildStoreExprTemp(for_value.value())); | 1927 value = Bind(BuildStoreExprTemp(for_value.value())); |
1945 } else { | 1928 } else { |
1946 value = for_value.value(); | 1929 value = for_value.value(); |
1947 } | 1930 } |
1948 arguments->Add(PushArgument(value)); | 1931 arguments->Add(PushArgument(value)); |
1949 } | 1932 } |
1950 | 1933 |
1951 | 1934 |
1952 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { | 1935 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { |
1953 InlineBailout("EffectGraphVisitor::VisitInstanceSetterNode (deopt)"); | |
1954 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1936 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1955 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1937 new ZoneGrowableArray<PushArgumentInstr*>(2); |
1956 BuildInstanceSetterArguments(node, arguments, kResultNotNeeded); | 1938 BuildInstanceSetterArguments(node, arguments, kResultNotNeeded); |
1957 const String& name = | 1939 const String& name = |
1958 String::ZoneHandle(Field::SetterSymbol(node->field_name())); | 1940 String::ZoneHandle(Field::SetterSymbol(node->field_name())); |
1959 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(), | 1941 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(), |
1960 name, | 1942 name, |
1961 Token::kSET, | 1943 Token::kSET, |
1962 arguments, | 1944 arguments, |
1963 Array::ZoneHandle(), | 1945 Array::ZoneHandle(), |
1964 2); // Checked arg count. | 1946 2); // Checked arg count. |
1965 ReturnDefinition(call); | 1947 ReturnDefinition(call); |
1966 } | 1948 } |
1967 | 1949 |
1968 | 1950 |
1969 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { | 1951 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { |
1970 InlineBailout("ValueGraphVisitor::VisitInstanceSetterNode (deopt)"); | |
1971 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1952 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1972 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1953 new ZoneGrowableArray<PushArgumentInstr*>(2); |
1973 BuildInstanceSetterArguments(node, arguments, kResultNeeded); | 1954 BuildInstanceSetterArguments(node, arguments, kResultNeeded); |
1974 const String& name = | 1955 const String& name = |
1975 String::ZoneHandle(Field::SetterSymbol(node->field_name())); | 1956 String::ZoneHandle(Field::SetterSymbol(node->field_name())); |
1976 Do(new InstanceCallInstr(node->token_pos(), | 1957 Do(new InstanceCallInstr(node->token_pos(), |
1977 name, | 1958 name, |
1978 Token::kSET, | 1959 Token::kSET, |
1979 arguments, | 1960 arguments, |
1980 Array::ZoneHandle(), | 1961 Array::ZoneHandle(), |
1981 2)); // Checked argument count. | 1962 2)); // Checked argument count. |
1982 ReturnDefinition(BuildLoadExprTemp()); | 1963 ReturnDefinition(BuildLoadExprTemp()); |
1983 } | 1964 } |
1984 | 1965 |
1985 | 1966 |
1986 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { | 1967 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { |
1987 InlineBailout("EffectGraphVisitor::VisitStaticGetterNode (deopt)"); | |
1988 const String& getter_name = | 1968 const String& getter_name = |
1989 String::Handle(Field::GetterName(node->field_name())); | 1969 String::Handle(Field::GetterName(node->field_name())); |
1990 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1970 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1991 new ZoneGrowableArray<PushArgumentInstr*>(); | 1971 new ZoneGrowableArray<PushArgumentInstr*>(); |
1992 Function& getter_function = Function::ZoneHandle(); | 1972 Function& getter_function = Function::ZoneHandle(); |
1993 if (node->is_super_getter()) { | 1973 if (node->is_super_getter()) { |
1994 // Statically resolved instance getter, i.e. "super getter". | 1974 // Statically resolved instance getter, i.e. "super getter". |
1995 getter_function = | 1975 getter_function = |
1996 Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); | 1976 Resolver::ResolveDynamicAnyArgs(node->cls(), getter_name); |
1997 ASSERT(!getter_function.IsNull()); | 1977 ASSERT(!getter_function.IsNull()); |
1998 ASSERT(node->receiver() != NULL); | 1978 ASSERT(node->receiver() != NULL); |
1999 ValueGraphVisitor receiver_value(owner(), temp_index()); | 1979 ValueGraphVisitor receiver_value(owner(), temp_index()); |
2000 node->receiver()->Visit(&receiver_value); | 1980 node->receiver()->Visit(&receiver_value); |
2001 Append(receiver_value); | 1981 Append(receiver_value); |
2002 arguments->Add(PushArgument(receiver_value.value())); | 1982 arguments->Add(PushArgument(receiver_value.value())); |
2003 } else { | 1983 } else { |
2004 getter_function = node->cls().LookupStaticFunction(getter_name); | 1984 getter_function = node->cls().LookupStaticFunction(getter_name); |
2005 ASSERT(!getter_function.IsNull()); | 1985 ASSERT(!getter_function.IsNull()); |
2006 } | 1986 } |
2007 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), | 1987 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), |
2008 getter_function, | 1988 getter_function, |
2009 Array::ZoneHandle(), // No names. | 1989 Array::ZoneHandle(), // No names. |
2010 arguments); | 1990 arguments); |
2011 ReturnDefinition(call); | 1991 ReturnDefinition(call); |
2012 } | 1992 } |
2013 | 1993 |
2014 | 1994 |
2015 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, | 1995 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, |
2016 bool result_is_needed) { | 1996 bool result_is_needed) { |
2017 InlineBailout("EffectGraphVisitor::VisitStaticSetter (deopt)"); | |
2018 const String& setter_name = | 1997 const String& setter_name = |
2019 String::Handle(Field::SetterName(node->field_name())); | 1998 String::Handle(Field::SetterName(node->field_name())); |
2020 // A super setter is an instance setter whose setter function is | 1999 // A super setter is an instance setter whose setter function is |
2021 // resolved at compile time (in the caller instance getter's super class). | 2000 // resolved at compile time (in the caller instance getter's super class). |
2022 // Unlike a static getter, a super getter has a receiver parameter. | 2001 // Unlike a static getter, a super getter has a receiver parameter. |
2023 const bool is_super_setter = (node->receiver() != NULL); | 2002 const bool is_super_setter = (node->receiver() != NULL); |
2024 const Function& setter_function = | 2003 const Function& setter_function = |
2025 Function::ZoneHandle(is_super_setter | 2004 Function::ZoneHandle(is_super_setter |
2026 ? Resolver::ResolveDynamicAnyArgs(node->cls(), setter_name) | 2005 ? Resolver::ResolveDynamicAnyArgs(node->cls(), setter_name) |
2027 : node->cls().LookupStaticFunction(setter_name)); | 2006 : node->cls().LookupStaticFunction(setter_name)); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 ReturnDefinition(BuildStoreStaticField(node, kResultNotNeeded)); | 2195 ReturnDefinition(BuildStoreStaticField(node, kResultNotNeeded)); |
2217 } | 2196 } |
2218 | 2197 |
2219 | 2198 |
2220 void ValueGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { | 2199 void ValueGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { |
2221 ReturnDefinition(BuildStoreStaticField(node, kResultNeeded)); | 2200 ReturnDefinition(BuildStoreStaticField(node, kResultNeeded)); |
2222 } | 2201 } |
2223 | 2202 |
2224 | 2203 |
2225 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { | 2204 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { |
2226 InlineBailout("EffectGraphVisitor::VisitLoadIndexedNode (deopt)"); | |
2227 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 2205 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
2228 new ZoneGrowableArray<PushArgumentInstr*>(2); | 2206 new ZoneGrowableArray<PushArgumentInstr*>(2); |
2229 ValueGraphVisitor for_array(owner(), temp_index()); | 2207 ValueGraphVisitor for_array(owner(), temp_index()); |
2230 node->array()->Visit(&for_array); | 2208 node->array()->Visit(&for_array); |
2231 Append(for_array); | 2209 Append(for_array); |
2232 arguments->Add(PushArgument(for_array.value())); | 2210 arguments->Add(PushArgument(for_array.value())); |
2233 | 2211 |
2234 ValueGraphVisitor for_index(owner(), temp_index()); | 2212 ValueGraphVisitor for_index(owner(), temp_index()); |
2235 node->index_expr()->Visit(&for_index); | 2213 node->index_expr()->Visit(&for_index); |
2236 Append(for_index); | 2214 Append(for_index); |
2237 arguments->Add(PushArgument(for_index.value())); | 2215 arguments->Add(PushArgument(for_index.value())); |
2238 | 2216 |
2239 const intptr_t checked_argument_count = 1; | 2217 const intptr_t checked_argument_count = 1; |
2240 const String& name = | 2218 const String& name = |
2241 String::ZoneHandle(Symbols::New(Token::Str(Token::kINDEX))); | 2219 String::ZoneHandle(Symbols::New(Token::Str(Token::kINDEX))); |
2242 InstanceCallInstr* load = new InstanceCallInstr(node->token_pos(), | 2220 InstanceCallInstr* load = new InstanceCallInstr(node->token_pos(), |
2243 name, | 2221 name, |
2244 Token::kINDEX, | 2222 Token::kINDEX, |
2245 arguments, | 2223 arguments, |
2246 Array::ZoneHandle(), | 2224 Array::ZoneHandle(), |
2247 checked_argument_count); | 2225 checked_argument_count); |
2248 ReturnDefinition(load); | 2226 ReturnDefinition(load); |
2249 } | 2227 } |
2250 | 2228 |
2251 | 2229 |
2252 Definition* EffectGraphVisitor::BuildStoreIndexedValues( | 2230 Definition* EffectGraphVisitor::BuildStoreIndexedValues( |
2253 StoreIndexedNode* node, | 2231 StoreIndexedNode* node, |
2254 bool result_is_needed) { | 2232 bool result_is_needed) { |
2255 InlineBailout("EffectGraphVisitor::BuildStoreIndexedValues (deopt)"); | |
2256 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 2233 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
2257 new ZoneGrowableArray<PushArgumentInstr*>(3); | 2234 new ZoneGrowableArray<PushArgumentInstr*>(3); |
2258 ValueGraphVisitor for_array(owner(), temp_index()); | 2235 ValueGraphVisitor for_array(owner(), temp_index()); |
2259 node->array()->Visit(&for_array); | 2236 node->array()->Visit(&for_array); |
2260 Append(for_array); | 2237 Append(for_array); |
2261 arguments->Add(PushArgument(for_array.value())); | 2238 arguments->Add(PushArgument(for_array.value())); |
2262 | 2239 |
2263 ValueGraphVisitor for_index(owner(), temp_index()); | 2240 ValueGraphVisitor for_index(owner(), temp_index()); |
2264 node->index_expr()->Visit(&for_index); | 2241 node->index_expr()->Visit(&for_index); |
2265 Append(for_index); | 2242 Append(for_index); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 } | 2281 } |
2305 | 2282 |
2306 | 2283 |
2307 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { | 2284 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { |
2308 return (node == owner()->parsed_function().node_sequence()) && | 2285 return (node == owner()->parsed_function().node_sequence()) && |
2309 (owner()->parsed_function().saved_context_var() != NULL); | 2286 (owner()->parsed_function().saved_context_var() != NULL); |
2310 } | 2287 } |
2311 | 2288 |
2312 | 2289 |
2313 void EffectGraphVisitor::UnchainContext() { | 2290 void EffectGraphVisitor::UnchainContext() { |
2314 InlineBailout("EffectGraphVisitor::UnchainContext (deopt)"); | 2291 InlineBailout("EffectGraphVisitor::UnchainContext (context)"); |
2315 Value* context = Bind(new CurrentContextInstr()); | 2292 Value* context = Bind(new CurrentContextInstr()); |
2316 Value* parent = Bind( | 2293 Value* parent = Bind( |
2317 new LoadFieldInstr(context, | 2294 new LoadFieldInstr(context, |
2318 Context::parent_offset(), | 2295 Context::parent_offset(), |
2319 Type::ZoneHandle())); // Not an instance, no type. | 2296 Type::ZoneHandle())); // Not an instance, no type. |
2320 Do(new StoreContextInstr(parent)); | 2297 Do(new StoreContextInstr(parent)); |
2321 } | 2298 } |
2322 | 2299 |
2323 | 2300 |
2324 // <Statement> ::= Sequence { scope: LocalScope | 2301 // <Statement> ::= Sequence { scope: LocalScope |
2325 // nodes: <Statement>* | 2302 // nodes: <Statement>* |
2326 // label: SourceLabel } | 2303 // label: SourceLabel } |
2327 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { | 2304 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { |
2328 LocalScope* scope = node->scope(); | 2305 LocalScope* scope = node->scope(); |
2329 const intptr_t num_context_variables = | 2306 const intptr_t num_context_variables = |
2330 (scope != NULL) ? scope->num_context_variables() : 0; | 2307 (scope != NULL) ? scope->num_context_variables() : 0; |
2331 int previous_context_level = owner()->context_level(); | 2308 int previous_context_level = owner()->context_level(); |
2332 if (num_context_variables > 0) { | 2309 if (num_context_variables > 0) { |
2333 InlineBailout("EffectGraphVisitor::VisitSequenceNode (deopt)"); | 2310 InlineBailout("EffectGraphVisitor::VisitSequenceNode (context)"); |
2334 // The loop local scope declares variables that are captured. | 2311 // The loop local scope declares variables that are captured. |
2335 // Allocate and chain a new context. | 2312 // Allocate and chain a new context. |
2336 // Allocate context computation (uses current CTX) | 2313 // Allocate context computation (uses current CTX) |
2337 Value* allocated_context = | 2314 Value* allocated_context = |
2338 Bind(new AllocateContextInstr(node->token_pos(), | 2315 Bind(new AllocateContextInstr(node->token_pos(), |
2339 num_context_variables)); | 2316 num_context_variables)); |
2340 | 2317 |
2341 // If this node_sequence is the body of the function being compiled, and if | 2318 // If this node_sequence is the body of the function being compiled, and if |
2342 // this function is not a closure, do not link the current context as the | 2319 // this function is not a closure, do not link the current context as the |
2343 // parent of the newly allocated context, as it is not accessible. Instead, | 2320 // parent of the newly allocated context, as it is not accessible. Instead, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 } | 2438 } |
2462 | 2439 |
2463 // The outermost function sequence cannot contain a label. | 2440 // The outermost function sequence cannot contain a label. |
2464 ASSERT((node->label() == NULL) || | 2441 ASSERT((node->label() == NULL) || |
2465 (node != owner()->parsed_function().node_sequence())); | 2442 (node != owner()->parsed_function().node_sequence())); |
2466 owner()->set_context_level(previous_context_level); | 2443 owner()->set_context_level(previous_context_level); |
2467 } | 2444 } |
2468 | 2445 |
2469 | 2446 |
2470 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { | 2447 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { |
2471 InlineBailout("EffectGraphVisitor::VisitCatchClauseNode"); | 2448 InlineBailout("EffectGraphVisitor::VisitCatchClauseNode (exception)"); |
2472 // NOTE: The implicit variables ':saved_context', ':exception_var' | 2449 // NOTE: The implicit variables ':saved_context', ':exception_var' |
2473 // and ':stacktrace_var' can never be captured variables. | 2450 // and ':stacktrace_var' can never be captured variables. |
2474 // Restores CTX from local variable ':saved_context'. | 2451 // Restores CTX from local variable ':saved_context'. |
2475 Do(new CatchEntryInstr(node->exception_var(), node->stacktrace_var())); | 2452 Do(new CatchEntryInstr(node->exception_var(), node->stacktrace_var())); |
2476 BuildLoadContext(node->context_var()); | 2453 BuildLoadContext(node->context_var()); |
2477 | 2454 |
2478 EffectGraphVisitor for_catch(owner(), temp_index()); | 2455 EffectGraphVisitor for_catch(owner(), temp_index()); |
2479 node->VisitChildren(&for_catch); | 2456 node->VisitChildren(&for_catch); |
2480 Append(for_catch); | 2457 Append(for_catch); |
2481 } | 2458 } |
2482 | 2459 |
2483 | 2460 |
2484 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { | 2461 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { |
2485 InlineBailout("EffectGraphVisitor::VisitTryCatchNode"); | 2462 InlineBailout("EffectGraphVisitor::VisitTryCatchNode (exception)"); |
2486 intptr_t old_try_index = owner()->try_index(); | 2463 intptr_t old_try_index = owner()->try_index(); |
2487 intptr_t try_index = owner()->AllocateTryIndex(); | 2464 intptr_t try_index = owner()->AllocateTryIndex(); |
2488 owner()->set_try_index(try_index); | 2465 owner()->set_try_index(try_index); |
2489 | 2466 |
2490 // Preserve CTX into local variable '%saved_context'. | 2467 // Preserve CTX into local variable '%saved_context'. |
2491 BuildStoreContext(node->context_var()); | 2468 BuildStoreContext(node->context_var()); |
2492 | 2469 |
2493 EffectGraphVisitor for_try_block(owner(), temp_index()); | 2470 EffectGraphVisitor for_try_block(owner(), temp_index()); |
2494 node->try_block()->Visit(&for_try_block); | 2471 node->try_block()->Visit(&for_try_block); |
2495 | 2472 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 EffectGraphVisitor for_finally_block(owner(), temp_index()); | 2512 EffectGraphVisitor for_finally_block(owner(), temp_index()); |
2536 node->finally_block()->Visit(&for_finally_block); | 2513 node->finally_block()->Visit(&for_finally_block); |
2537 Append(for_finally_block); | 2514 Append(for_finally_block); |
2538 } | 2515 } |
2539 } | 2516 } |
2540 | 2517 |
2541 | 2518 |
2542 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { | 2519 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { |
2543 // TODO(kmillikin) non-local control flow is not handled correctly | 2520 // TODO(kmillikin) non-local control flow is not handled correctly |
2544 // by the inliner. | 2521 // by the inliner. |
2545 InlineBailout("EffectGraphVisitor::BuildThrowNode"); | 2522 InlineBailout("EffectGraphVisitor::BuildThrowNode (exception)"); |
2546 ValueGraphVisitor for_exception(owner(), temp_index()); | 2523 ValueGraphVisitor for_exception(owner(), temp_index()); |
2547 node->exception()->Visit(&for_exception); | 2524 node->exception()->Visit(&for_exception); |
2548 Append(for_exception); | 2525 Append(for_exception); |
2549 PushArgument(for_exception.value()); | 2526 PushArgument(for_exception.value()); |
2550 Instruction* instr = NULL; | 2527 Instruction* instr = NULL; |
2551 if (node->stacktrace() == NULL) { | 2528 if (node->stacktrace() == NULL) { |
2552 instr = new ThrowInstr(node->token_pos()); | 2529 instr = new ThrowInstr(node->token_pos()); |
2553 } else { | 2530 } else { |
2554 ValueGraphVisitor for_stack_trace(owner(), temp_index()); | 2531 ValueGraphVisitor for_stack_trace(owner(), temp_index()); |
2555 node->stacktrace()->Visit(&for_stack_trace); | 2532 node->stacktrace()->Visit(&for_stack_trace); |
(...skipping 14 matching lines...) Expand all Loading... |
2570 // A throw cannot be part of an expression, however, the parser may replace | 2547 // A throw cannot be part of an expression, however, the parser may replace |
2571 // certain expression nodes with a throw. In that case generate a literal null | 2548 // certain expression nodes with a throw. In that case generate a literal null |
2572 // so that the fragment is not closed in the middle of an expression. | 2549 // so that the fragment is not closed in the middle of an expression. |
2573 void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) { | 2550 void ValueGraphVisitor::VisitThrowNode(ThrowNode* node) { |
2574 BuildThrowNode(node); | 2551 BuildThrowNode(node); |
2575 ReturnDefinition(new ConstantInstr(Instance::ZoneHandle())); | 2552 ReturnDefinition(new ConstantInstr(Instance::ZoneHandle())); |
2576 } | 2553 } |
2577 | 2554 |
2578 | 2555 |
2579 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { | 2556 void EffectGraphVisitor::VisitInlinedFinallyNode(InlinedFinallyNode* node) { |
2580 InlineBailout("EffectGraphVisitor::VisitInlinedFinallyNode"); | 2557 InlineBailout("EffectGraphVisitor::VisitInlinedFinallyNode (exception)"); |
2581 const intptr_t try_index = owner()->try_index(); | 2558 const intptr_t try_index = owner()->try_index(); |
2582 if (try_index >= 0) { | 2559 if (try_index >= 0) { |
2583 // We are about to generate code for an inlined finally block. Exceptions | 2560 // We are about to generate code for an inlined finally block. Exceptions |
2584 // thrown in this block of code should be treated as though they are | 2561 // thrown in this block of code should be treated as though they are |
2585 // thrown not from the current try block but the outer try block if any. | 2562 // thrown not from the current try block but the outer try block if any. |
2586 owner()->set_try_index((try_index - 1)); | 2563 owner()->set_try_index((try_index - 1)); |
2587 } | 2564 } |
2588 BuildLoadContext(node->context_var()); | 2565 BuildLoadContext(node->context_var()); |
2589 | 2566 |
2590 JoinEntryInstr* finally_entry = new JoinEntryInstr(owner()->try_index()); | 2567 JoinEntryInstr* finally_entry = new JoinEntryInstr(owner()->try_index()); |
(...skipping 24 matching lines...) Expand all Loading... |
2615 // Set the inlining context. | 2592 // Set the inlining context. |
2616 ASSERT(inlining_context_ == kNotInlining); | 2593 ASSERT(inlining_context_ == kNotInlining); |
2617 inlining_context_ = context; | 2594 inlining_context_ = context; |
2618 if (InInliningContext()) exits_ = new ZoneGrowableArray<ReturnInstr*>(); | 2595 if (InInliningContext()) exits_ = new ZoneGrowableArray<ReturnInstr*>(); |
2619 // Compilation can be nested, preserve the computation-id. | 2596 // Compilation can be nested, preserve the computation-id. |
2620 const Function& function = parsed_function().function(); | 2597 const Function& function = parsed_function().function(); |
2621 TargetEntryInstr* normal_entry = new TargetEntryInstr( | 2598 TargetEntryInstr* normal_entry = new TargetEntryInstr( |
2622 CatchClauseNode::kInvalidTryIndex); | 2599 CatchClauseNode::kInvalidTryIndex); |
2623 graph_entry_ = new GraphEntryInstr(normal_entry); | 2600 graph_entry_ = new GraphEntryInstr(normal_entry); |
2624 EffectGraphVisitor for_effect(this, 0); | 2601 EffectGraphVisitor for_effect(this, 0); |
| 2602 if (InInliningContext()) { |
| 2603 exits_ = new ZoneGrowableArray<ReturnInstr*>(); |
| 2604 } |
2625 // TODO(kmillikin): We can eliminate stack checks in some cases (e.g., the | 2605 // TODO(kmillikin): We can eliminate stack checks in some cases (e.g., the |
2626 // stack check on entry for leaf routines). | 2606 // stack check on entry for leaf routines). |
2627 for_effect.Do(new CheckStackOverflowInstr(function.token_pos())); | 2607 for_effect.Do(new CheckStackOverflowInstr(function.token_pos())); |
2628 parsed_function().node_sequence()->Visit(&for_effect); | 2608 parsed_function().node_sequence()->Visit(&for_effect); |
2629 AppendFragment(normal_entry, for_effect); | 2609 AppendFragment(normal_entry, for_effect); |
2630 // Check that the graph is properly terminated. | 2610 // Check that the graph is properly terminated. |
2631 ASSERT(!for_effect.is_open()); | 2611 ASSERT(!for_effect.is_open()); |
2632 FlowGraph* graph = new FlowGraph(*this, graph_entry_); | 2612 FlowGraph* graph = new FlowGraph(*this, graph_entry_); |
2633 if (InInliningContext()) graph->set_exits(exits_); | 2613 if (InInliningContext()) graph->set_exits(exits_); |
2634 return graph; | 2614 return graph; |
2635 } | 2615 } |
2636 | 2616 |
2637 | 2617 |
2638 void FlowGraphBuilder::Bailout(const char* reason) { | 2618 void FlowGraphBuilder::Bailout(const char* reason) { |
2639 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; | 2619 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; |
2640 const char* function_name = parsed_function_.function().ToCString(); | 2620 const char* function_name = parsed_function_.function().ToCString(); |
2641 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2621 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
2642 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2622 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
2643 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2623 OS::SNPrint(chars, len, kFormat, function_name, reason); |
2644 const Error& error = Error::Handle( | 2624 const Error& error = Error::Handle( |
2645 LanguageError::New(String::Handle(String::New(chars)))); | 2625 LanguageError::New(String::Handle(String::New(chars)))); |
2646 Isolate::Current()->long_jump_base()->Jump(1, error); | 2626 Isolate::Current()->long_jump_base()->Jump(1, error); |
2647 } | 2627 } |
2648 | 2628 |
2649 | 2629 |
2650 } // namespace dart | 2630 } // namespace dart |
OLD | NEW |