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

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

Issue 2859673002: Pass type argument vector to generic functions (if --reify-generic-functions is (Closed)
Patch Set: address review comments and sync Created 3 years, 7 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
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 } 1133 }
1134 1134
1135 if (FLAG_causal_async_stacks && 1135 if (FLAG_causal_async_stacks &&
1136 (function.IsAsyncClosure() || function.IsAsyncGenClosure())) { 1136 (function.IsAsyncClosure() || function.IsAsyncGenClosure())) {
1137 // We are returning from an asynchronous closure. Before we do that, be 1137 // We are returning from an asynchronous closure. Before we do that, be
1138 // sure to clear the thread's asynchronous stack trace. 1138 // sure to clear the thread's asynchronous stack trace.
1139 const Function& async_clear_thread_stack_trace = Function::ZoneHandle( 1139 const Function& async_clear_thread_stack_trace = Function::ZoneHandle(
1140 Z, isolate()->object_store()->async_clear_thread_stack_trace()); 1140 Z, isolate()->object_store()->async_clear_thread_stack_trace());
1141 ZoneGrowableArray<PushArgumentInstr*>* no_arguments = 1141 ZoneGrowableArray<PushArgumentInstr*>* no_arguments =
1142 new (Z) ZoneGrowableArray<PushArgumentInstr*>(0); 1142 new (Z) ZoneGrowableArray<PushArgumentInstr*>(0);
1143 StaticCallInstr* call_async_clear_thread_stack_trace = new (Z) 1143 const int kTypeArgsLen = 0;
1144 StaticCallInstr(node->token_pos().ToSynthetic(), 1144 StaticCallInstr* call_async_clear_thread_stack_trace =
1145 async_clear_thread_stack_trace, Object::null_array(), 1145 new (Z) StaticCallInstr(node->token_pos().ToSynthetic(),
1146 no_arguments, owner()->ic_data_array()); 1146 async_clear_thread_stack_trace, kTypeArgsLen,
1147 Object::null_array(), no_arguments,
1148 owner()->ic_data_array());
1147 Do(call_async_clear_thread_stack_trace); 1149 Do(call_async_clear_thread_stack_trace);
1148 } 1150 }
1149 1151
1150 // Async functions contain two types of return statements: 1152 // Async functions contain two types of return statements:
1151 // 1) Returns that should complete the completer once all finally blocks have 1153 // 1) Returns that should complete the completer once all finally blocks have
1152 // been inlined (call: :async_completer.complete(return_value)). These 1154 // been inlined (call: :async_completer.complete(return_value)). These
1153 // returns end up returning null in the end. 1155 // returns end up returning null in the end.
1154 // 2) "Continuation" returns that should not complete the completer but return 1156 // 2) "Continuation" returns that should not complete the completer but return
1155 // the value. 1157 // the value.
1156 // 1158 //
(...skipping 11 matching lines...) Expand all
1168 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 1170 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
1169 Value* rcv_value = Bind(BuildLoadLocal(*rcv_var, node->token_pos())); 1171 Value* rcv_value = Bind(BuildLoadLocal(*rcv_var, node->token_pos()));
1170 arguments->Add(PushArgument(rcv_value)); 1172 arguments->Add(PushArgument(rcv_value));
1171 Value* returned_value = Bind(BuildLoadExprTemp(node->token_pos())); 1173 Value* returned_value = Bind(BuildLoadExprTemp(node->token_pos()));
1172 arguments->Add(PushArgument(returned_value)); 1174 arguments->Add(PushArgument(returned_value));
1173 // Call a helper function to complete the completer. The debugger 1175 // Call a helper function to complete the completer. The debugger
1174 // uses the helper function to know when to step-out. 1176 // uses the helper function to know when to step-out.
1175 const Function& complete_on_async_return = Function::ZoneHandle( 1177 const Function& complete_on_async_return = Function::ZoneHandle(
1176 Z, isolate()->object_store()->complete_on_async_return()); 1178 Z, isolate()->object_store()->complete_on_async_return());
1177 ASSERT(!complete_on_async_return.IsNull()); 1179 ASSERT(!complete_on_async_return.IsNull());
1180 const int kTypeArgsLen = 0;
1178 StaticCallInstr* call = new (Z) StaticCallInstr( 1181 StaticCallInstr* call = new (Z) StaticCallInstr(
1179 node->token_pos().ToSynthetic(), complete_on_async_return, 1182 node->token_pos().ToSynthetic(), complete_on_async_return, kTypeArgsLen,
1180 Object::null_array(), arguments, owner()->ic_data_array()); 1183 Object::null_array(), arguments, owner()->ic_data_array());
1181 Do(call); 1184 Do(call);
1182 1185
1183 // Rebind the return value for the actual return call to be null. 1186 // Rebind the return value for the actual return call to be null.
1184 return_value = BuildNullValue(node->token_pos()); 1187 return_value = BuildNullValue(node->token_pos());
1185 } 1188 }
1186 1189
1187 intptr_t current_context_level = owner()->context_level(); 1190 intptr_t current_context_level = owner()->context_level();
1188 ASSERT(current_context_level >= 0); 1191 ASSERT(current_context_level >= 0);
1189 if (HasContextScope()) { 1192 if (HasContextScope()) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 ValueGraphVisitor for_right_value(owner()); 1359 ValueGraphVisitor for_right_value(owner());
1357 node->right()->Visit(&for_right_value); 1360 node->right()->Visit(&for_right_value);
1358 Append(for_right_value); 1361 Append(for_right_value);
1359 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); 1362 PushArgumentInstr* push_right = PushArgument(for_right_value.value());
1360 1363
1361 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1364 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1362 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 1365 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
1363 arguments->Add(push_left); 1366 arguments->Add(push_left);
1364 arguments->Add(push_right); 1367 arguments->Add(push_right);
1365 const String& name = Symbols::Token(node->kind()); 1368 const String& name = Symbols::Token(node->kind());
1369 const intptr_t kTypeArgsLen = 0;
1366 const intptr_t kNumArgsChecked = 2; 1370 const intptr_t kNumArgsChecked = 2;
1367 InstanceCallInstr* call = new (Z) InstanceCallInstr( 1371 InstanceCallInstr* call = new (Z) InstanceCallInstr(
1368 node->token_pos(), name, node->kind(), arguments, Object::null_array(), 1372 node->token_pos(), name, node->kind(), arguments, kTypeArgsLen,
1369 kNumArgsChecked, owner()->ic_data_array()); 1373 Object::null_array(), kNumArgsChecked, owner()->ic_data_array());
1370 ReturnDefinition(call); 1374 ReturnDefinition(call);
1371 } 1375 }
1372 1376
1373 1377
1374 // Special handling for AND/OR. 1378 // Special handling for AND/OR.
1375 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { 1379 void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
1376 // Operators "&&" and "||" cannot be overloaded therefore do not call 1380 // Operators "&&" and "||" cannot be overloaded therefore do not call
1377 // operator. 1381 // operator.
1378 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { 1382 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
1379 // Implement short-circuit logic: do not evaluate right if evaluation 1383 // Implement short-circuit logic: do not evaluate right if evaluation
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 1521
1518 // We now know type is a real class (!num, !int, !smi, !string) 1522 // We now know type is a real class (!num, !int, !smi, !string)
1519 // and the type check could NOT be removed at compile time. 1523 // and the type check could NOT be removed at compile time.
1520 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 1524 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1521 if (FlowGraphBuilder::SimpleInstanceOfType(type)) { 1525 if (FlowGraphBuilder::SimpleInstanceOfType(type)) {
1522 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1526 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1523 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 1527 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
1524 arguments->Add(push_left); 1528 arguments->Add(push_left);
1525 Value* type_const = Bind(new (Z) ConstantInstr(type)); 1529 Value* type_const = Bind(new (Z) ConstantInstr(type));
1526 arguments->Add(PushArgument(type_const)); 1530 arguments->Add(PushArgument(type_const));
1531 const intptr_t kTypeArgsLen = 0;
1527 const intptr_t kNumArgsChecked = 2; 1532 const intptr_t kNumArgsChecked = 2;
1528 Definition* result = new (Z) InstanceCallInstr( 1533 Definition* result = new (Z) InstanceCallInstr(
1529 node->token_pos(), 1534 node->token_pos(),
1530 Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()), node->kind(), 1535 Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()), node->kind(),
1531 arguments, 1536 arguments, kTypeArgsLen,
1532 Object::null_array(), // No argument names. 1537 Object::null_array(), // No argument names.
1533 kNumArgsChecked, owner()->ic_data_array()); 1538 kNumArgsChecked, owner()->ic_data_array());
1534 if (negate_result) { 1539 if (negate_result) {
1535 result = new (Z) BooleanNegateInstr(Bind(result)); 1540 result = new (Z) BooleanNegateInstr(Bind(result));
1536 } 1541 }
1537 ReturnDefinition(result); 1542 ReturnDefinition(result);
1538 return; 1543 return;
1539 } 1544 }
1540 1545
1541 PushArgumentInstr* push_instantiator_type_args = 1546 PushArgumentInstr* push_instantiator_type_args =
1542 PushInstantiatorTypeArguments(type, node->token_pos()); 1547 PushInstantiatorTypeArguments(type, node->token_pos());
1543 PushArgumentInstr* push_function_type_args = 1548 PushArgumentInstr* push_function_type_args =
1544 PushFunctionTypeArguments(type, node->token_pos()); 1549 PushFunctionTypeArguments(type, node->token_pos());
1545 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1550 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1546 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4); 1551 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4);
1547 arguments->Add(push_left); 1552 arguments->Add(push_left);
1548 arguments->Add(push_instantiator_type_args); 1553 arguments->Add(push_instantiator_type_args);
1549 arguments->Add(push_function_type_args); 1554 arguments->Add(push_function_type_args);
1550 Value* type_const = Bind(new (Z) ConstantInstr(type)); 1555 Value* type_const = Bind(new (Z) ConstantInstr(type));
1551 arguments->Add(PushArgument(type_const)); 1556 arguments->Add(PushArgument(type_const));
1557 const intptr_t kTypeArgsLen = 0;
1552 const intptr_t kNumArgsChecked = 1; 1558 const intptr_t kNumArgsChecked = 1;
1553 Definition* result = new (Z) InstanceCallInstr( 1559 Definition* result = new (Z) InstanceCallInstr(
1554 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()), 1560 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()),
1555 node->kind(), arguments, 1561 node->kind(), arguments, kTypeArgsLen,
1556 Object::null_array(), // No argument names. 1562 Object::null_array(), // No argument names.
1557 kNumArgsChecked, owner()->ic_data_array()); 1563 kNumArgsChecked, owner()->ic_data_array());
1558 if (negate_result) { 1564 if (negate_result) {
1559 result = new (Z) BooleanNegateInstr(Bind(result)); 1565 result = new (Z) BooleanNegateInstr(Bind(result));
1560 } 1566 }
1561 ReturnDefinition(result); 1567 ReturnDefinition(result);
1562 } 1568 }
1563 1569
1564 1570
1565 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { 1571 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) {
(...skipping 14 matching lines...) Expand all
1580 PushInstantiatorTypeArguments(type, node->token_pos()); 1586 PushInstantiatorTypeArguments(type, node->token_pos());
1581 PushArgumentInstr* push_function_type_args = 1587 PushArgumentInstr* push_function_type_args =
1582 PushFunctionTypeArguments(type, node->token_pos()); 1588 PushFunctionTypeArguments(type, node->token_pos());
1583 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1589 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1584 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4); 1590 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4);
1585 arguments->Add(push_left); 1591 arguments->Add(push_left);
1586 arguments->Add(push_instantiator_type_args); 1592 arguments->Add(push_instantiator_type_args);
1587 arguments->Add(push_function_type_args); 1593 arguments->Add(push_function_type_args);
1588 Value* type_arg = Bind(new (Z) ConstantInstr(type)); 1594 Value* type_arg = Bind(new (Z) ConstantInstr(type));
1589 arguments->Add(PushArgument(type_arg)); 1595 arguments->Add(PushArgument(type_arg));
1596 const int kTypeArgsLen = 0;
1590 const intptr_t kNumArgsChecked = 1; 1597 const intptr_t kNumArgsChecked = 1;
1591 InstanceCallInstr* call = new (Z) InstanceCallInstr( 1598 InstanceCallInstr* call = new (Z) InstanceCallInstr(
1592 node->token_pos(), Library::PrivateCoreLibName(Symbols::_as()), 1599 node->token_pos(), Library::PrivateCoreLibName(Symbols::_as()),
1593 node->kind(), arguments, 1600 node->kind(), arguments, kTypeArgsLen,
1594 Object::null_array(), // No argument names. 1601 Object::null_array(), // No argument names.
1595 kNumArgsChecked, owner()->ic_data_array()); 1602 kNumArgsChecked, owner()->ic_data_array());
1596 ReturnDefinition(call); 1603 ReturnDefinition(call);
1597 } 1604 }
1598 1605
1599 1606
1600 StrictCompareInstr* EffectGraphVisitor::BuildStrictCompare( 1607 StrictCompareInstr* EffectGraphVisitor::BuildStrictCompare(
1601 AstNode* left, 1608 AstNode* left,
1602 AstNode* right, 1609 AstNode* right,
1603 Token::Kind kind, 1610 Token::Kind kind,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 Append(for_left_value); 1664 Append(for_left_value);
1658 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 1665 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1659 arguments->Add(push_left); 1666 arguments->Add(push_left);
1660 1667
1661 ValueGraphVisitor for_right_value(owner()); 1668 ValueGraphVisitor for_right_value(owner());
1662 node->right()->Visit(&for_right_value); 1669 node->right()->Visit(&for_right_value);
1663 Append(for_right_value); 1670 Append(for_right_value);
1664 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); 1671 PushArgumentInstr* push_right = PushArgument(for_right_value.value());
1665 arguments->Add(push_right); 1672 arguments->Add(push_right);
1666 1673
1674 const intptr_t kTypeArgsLen = 0;
1667 const intptr_t kNumArgsChecked = 2; 1675 const intptr_t kNumArgsChecked = 2;
1668 Definition* result = new (Z) 1676 Definition* result = new (Z)
1669 InstanceCallInstr(node->token_pos(), Symbols::EqualOperator(), 1677 InstanceCallInstr(node->token_pos(), Symbols::EqualOperator(),
1670 Token::kEQ, // Result is negated later for kNE. 1678 Token::kEQ, // Result is negated later for kNE.
1671 arguments, Object::null_array(), kNumArgsChecked, 1679 arguments, kTypeArgsLen, Object::null_array(),
1672 owner()->ic_data_array()); 1680 kNumArgsChecked, owner()->ic_data_array());
1673 if (node->kind() == Token::kNE) { 1681 if (node->kind() == Token::kNE) {
1674 Isolate* isolate = Isolate::Current(); 1682 Isolate* isolate = Isolate::Current();
1675 if (isolate->type_checks() || isolate->asserts()) { 1683 if (isolate->type_checks() || isolate->asserts()) {
1676 Value* value = Bind(result); 1684 Value* value = Bind(result);
1677 result = new (Z) AssertBooleanInstr(node->token_pos(), value); 1685 result = new (Z) AssertBooleanInstr(node->token_pos(), value);
1678 } 1686 }
1679 Value* value = Bind(result); 1687 Value* value = Bind(result);
1680 result = new (Z) BooleanNegateInstr(value); 1688 result = new (Z) BooleanNegateInstr(value);
1681 } 1689 }
1682 ReturnDefinition(result); 1690 ReturnDefinition(result);
1683 return; 1691 return;
1684 } 1692 }
1685 1693
1686 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1694 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1687 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 1695 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
1688 1696
1689 ValueGraphVisitor for_left_value(owner()); 1697 ValueGraphVisitor for_left_value(owner());
1690 node->left()->Visit(&for_left_value); 1698 node->left()->Visit(&for_left_value);
1691 Append(for_left_value); 1699 Append(for_left_value);
1692 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 1700 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1693 arguments->Add(push_left); 1701 arguments->Add(push_left);
1694 1702
1695 ValueGraphVisitor for_right_value(owner()); 1703 ValueGraphVisitor for_right_value(owner());
1696 node->right()->Visit(&for_right_value); 1704 node->right()->Visit(&for_right_value);
1697 Append(for_right_value); 1705 Append(for_right_value);
1698 PushArgumentInstr* push_right = PushArgument(for_right_value.value()); 1706 PushArgumentInstr* push_right = PushArgument(for_right_value.value());
1699 arguments->Add(push_right); 1707 arguments->Add(push_right);
1700 1708
1701 ASSERT(Token::IsRelationalOperator(node->kind())); 1709 ASSERT(Token::IsRelationalOperator(node->kind()));
1710 const intptr_t kTypeArgsLen = 0;
1702 InstanceCallInstr* comp = new (Z) InstanceCallInstr( 1711 InstanceCallInstr* comp = new (Z) InstanceCallInstr(
1703 node->token_pos(), Symbols::Token(node->kind()), node->kind(), arguments, 1712 node->token_pos(), Symbols::Token(node->kind()), node->kind(), arguments,
1704 Object::null_array(), 2, owner()->ic_data_array()); 1713 kTypeArgsLen, Object::null_array(), 2, owner()->ic_data_array());
1705 ReturnDefinition(comp); 1714 ReturnDefinition(comp);
1706 } 1715 }
1707 1716
1708 1717
1709 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { 1718 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) {
1710 // "!" cannot be overloaded, therefore do not call operator. 1719 // "!" cannot be overloaded, therefore do not call operator.
1711 if (node->kind() == Token::kNOT) { 1720 if (node->kind() == Token::kNOT) {
1712 ValueGraphVisitor for_value(owner()); 1721 ValueGraphVisitor for_value(owner());
1713 node->operand()->Visit(&for_value); 1722 node->operand()->Visit(&for_value);
1714 Append(for_value); 1723 Append(for_value);
1715 Value* value = for_value.value(); 1724 Value* value = for_value.value();
1716 Isolate* isolate = Isolate::Current(); 1725 Isolate* isolate = Isolate::Current();
1717 if (isolate->type_checks() || isolate->asserts()) { 1726 if (isolate->type_checks() || isolate->asserts()) {
1718 value = 1727 value =
1719 Bind(new (Z) AssertBooleanInstr(node->operand()->token_pos(), value)); 1728 Bind(new (Z) AssertBooleanInstr(node->operand()->token_pos(), value));
1720 } 1729 }
1721 BooleanNegateInstr* negate = new (Z) BooleanNegateInstr(value); 1730 BooleanNegateInstr* negate = new (Z) BooleanNegateInstr(value);
1722 ReturnDefinition(negate); 1731 ReturnDefinition(negate);
1723 return; 1732 return;
1724 } 1733 }
1725 1734
1726 ValueGraphVisitor for_value(owner()); 1735 ValueGraphVisitor for_value(owner());
1727 node->operand()->Visit(&for_value); 1736 node->operand()->Visit(&for_value);
1728 Append(for_value); 1737 Append(for_value);
1729 PushArgumentInstr* push_value = PushArgument(for_value.value()); 1738 PushArgumentInstr* push_value = PushArgument(for_value.value());
1730 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1739 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1731 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1); 1740 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1);
1732 arguments->Add(push_value); 1741 arguments->Add(push_value);
1742 const intptr_t kTypeArgsLen = 0;
1733 InstanceCallInstr* call = new (Z) InstanceCallInstr( 1743 InstanceCallInstr* call = new (Z) InstanceCallInstr(
1734 node->token_pos(), Symbols::Token(node->kind()), node->kind(), arguments, 1744 node->token_pos(), Symbols::Token(node->kind()), node->kind(), arguments,
1735 Object::null_array(), 1, owner()->ic_data_array()); 1745 kTypeArgsLen, Object::null_array(), 1, owner()->ic_data_array());
1736 ReturnDefinition(call); 1746 ReturnDefinition(call);
1737 } 1747 }
1738 1748
1739 1749
1740 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { 1750 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
1741 TestGraphVisitor for_test(owner(), node->condition()->token_pos()); 1751 TestGraphVisitor for_test(owner(), node->condition()->token_pos());
1742 node->condition()->Visit(&for_test); 1752 node->condition()->Visit(&for_test);
1743 1753
1744 // Translate the subexpressions for their effects. 1754 // Translate the subexpressions for their effects.
1745 EffectGraphVisitor for_true(owner()); 1755 EffectGraphVisitor for_true(owner());
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 StringInterpolateNode* node) { 2282 StringInterpolateNode* node) {
2273 ValueGraphVisitor for_argument(owner()); 2283 ValueGraphVisitor for_argument(owner());
2274 ArrayNode* arguments = node->value(); 2284 ArrayNode* arguments = node->value();
2275 if (arguments->length() == 1) { 2285 if (arguments->length() == 1) {
2276 ZoneGrowableArray<PushArgumentInstr*>* values = 2286 ZoneGrowableArray<PushArgumentInstr*>* values =
2277 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1); 2287 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1);
2278 arguments->ElementAt(0)->Visit(&for_argument); 2288 arguments->ElementAt(0)->Visit(&for_argument);
2279 Append(for_argument); 2289 Append(for_argument);
2280 PushArgumentInstr* push_arg = PushArgument(for_argument.value()); 2290 PushArgumentInstr* push_arg = PushArgument(for_argument.value());
2281 values->Add(push_arg); 2291 values->Add(push_arg);
2292 const int kTypeArgsLen = 0;
2282 const int kNumberOfArguments = 1; 2293 const int kNumberOfArguments = 1;
2283 const Array& kNoArgumentNames = Object::null_array(); 2294 const Array& kNoArgumentNames = Object::null_array();
2284 const Class& cls = 2295 const Class& cls =
2285 Class::Handle(Library::LookupCoreClass(Symbols::StringBase())); 2296 Class::Handle(Library::LookupCoreClass(Symbols::StringBase()));
2286 ASSERT(!cls.IsNull()); 2297 ASSERT(!cls.IsNull());
2287 const Function& function = Function::ZoneHandle( 2298 const Function& function = Function::ZoneHandle(
2288 Z, Resolver::ResolveStatic( 2299 Z, Resolver::ResolveStatic(
2289 cls, Library::PrivateCoreLibName(Symbols::InterpolateSingle()), 2300 cls, Library::PrivateCoreLibName(Symbols::InterpolateSingle()),
2290 kNumberOfArguments, kNoArgumentNames)); 2301 kTypeArgsLen, kNumberOfArguments, kNoArgumentNames));
2291 StaticCallInstr* call = 2302 StaticCallInstr* call = new (Z)
2292 new (Z) StaticCallInstr(node->token_pos(), function, kNoArgumentNames, 2303 StaticCallInstr(node->token_pos(), function, kTypeArgsLen,
2293 values, owner()->ic_data_array()); 2304 kNoArgumentNames, values, owner()->ic_data_array());
2294 ReturnDefinition(call); 2305 ReturnDefinition(call);
2295 return; 2306 return;
2296 } 2307 }
2297 arguments->Visit(&for_argument); 2308 arguments->Visit(&for_argument);
2298 Append(for_argument); 2309 Append(for_argument);
2299 StringInterpolateInstr* instr = 2310 StringInterpolateInstr* instr =
2300 new (Z) StringInterpolateInstr(for_argument.value(), node->token_pos()); 2311 new (Z) StringInterpolateInstr(for_argument.value(), node->token_pos());
2301 ReturnDefinition(instr); 2312 ReturnDefinition(instr);
2302 } 2313 }
2303 2314
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 Value* context = Bind(BuildCurrentContext(node->token_pos())); 2425 Value* context = Bind(BuildCurrentContext(node->token_pos()));
2415 Do(new (Z) StoreInstanceFieldInstr(Closure::context_offset(), 2426 Do(new (Z) StoreInstanceFieldInstr(Closure::context_offset(),
2416 closure_tmp_val, context, 2427 closure_tmp_val, context,
2417 kEmitStoreBarrier, node->token_pos())); 2428 kEmitStoreBarrier, node->token_pos()));
2418 } 2429 }
2419 ReturnDefinition(ExitTempLocalScope(closure_val)); 2430 ReturnDefinition(ExitTempLocalScope(closure_val));
2420 } 2431 }
2421 } 2432 }
2422 2433
2423 2434
2435 void EffectGraphVisitor::BuildPushTypeArguments(
2436 const ArgumentListNode& node,
2437 ZoneGrowableArray<PushArgumentInstr*>* values) {
2438 if (node.type_args_len() > 0) {
2439 Value* type_args_val;
2440 if (node.type_args_var() != NULL) {
2441 type_args_val =
2442 Bind(new (Z) LoadLocalInstr(*node.type_args_var(), node.token_pos()));
2443 } else {
2444 const TypeArguments& type_args = node.type_arguments();
2445 ASSERT(!type_args.IsNull() &&
2446 (type_args.Length() == node.type_args_len()));
2447 type_args_val =
2448 BuildInstantiatedTypeArguments(node.token_pos(), type_args);
2449 }
2450 PushArgumentInstr* push_type_args = PushArgument(type_args_val);
2451 values->Add(push_type_args);
2452 }
2453 }
2454
2455
2424 void EffectGraphVisitor::BuildPushArguments( 2456 void EffectGraphVisitor::BuildPushArguments(
2425 const ArgumentListNode& node, 2457 const ArgumentListNode& node,
2426 ZoneGrowableArray<PushArgumentInstr*>* values) { 2458 ZoneGrowableArray<PushArgumentInstr*>* values) {
2427 for (intptr_t i = 0; i < node.length(); ++i) { 2459 for (intptr_t i = 0; i < node.length(); ++i) {
2428 ValueGraphVisitor for_argument(owner()); 2460 ValueGraphVisitor for_argument(owner());
2429 node.NodeAt(i)->Visit(&for_argument); 2461 node.NodeAt(i)->Visit(&for_argument);
2430 Append(for_argument); 2462 Append(for_argument);
2431 PushArgumentInstr* push_arg = PushArgument(for_argument.value()); 2463 PushArgumentInstr* push_arg = PushArgument(for_argument.value());
2432 values->Add(push_arg); 2464 values->Add(push_arg);
2433 } 2465 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 Do(BuildStoreExprTemp(for_receiver.value(), node->token_pos())); 2503 Do(BuildStoreExprTemp(for_receiver.value(), node->token_pos()));
2472 BuildInstanceCallConditional(node); 2504 BuildInstanceCallConditional(node);
2473 ReturnDefinition(BuildLoadExprTemp(node->token_pos())); 2505 ReturnDefinition(BuildLoadExprTemp(node->token_pos()));
2474 } else { 2506 } else {
2475 EffectGraphVisitor::VisitInstanceCallNode(node); 2507 EffectGraphVisitor::VisitInstanceCallNode(node);
2476 } 2508 }
2477 } 2509 }
2478 2510
2479 2511
2480 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { 2512 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) {
2481 ValueGraphVisitor for_receiver(owner());
2482 node->receiver()->Visit(&for_receiver);
2483 Append(for_receiver);
2484 if (node->is_conditional()) { 2513 if (node->is_conditional()) {
2514 ValueGraphVisitor for_receiver(owner());
2515 node->receiver()->Visit(&for_receiver);
2516 Append(for_receiver);
2485 Do(BuildStoreExprTemp(for_receiver.value(), node->token_pos())); 2517 Do(BuildStoreExprTemp(for_receiver.value(), node->token_pos()));
2486 BuildInstanceCallConditional(node); 2518 BuildInstanceCallConditional(node);
2487 } else { 2519 } else {
2520 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2521 new (Z) ZoneGrowableArray<PushArgumentInstr*>(
2522 node->arguments()->LengthWithTypeArgs() + 1);
2523 BuildPushTypeArguments(*node->arguments(), arguments);
2524 ValueGraphVisitor for_receiver(owner());
2525 node->receiver()->Visit(&for_receiver);
2526 Append(for_receiver);
2488 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); 2527 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value());
2489 ZoneGrowableArray<PushArgumentInstr*>* arguments = new (Z)
2490 ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length() + 1);
2491 arguments->Add(push_receiver); 2528 arguments->Add(push_receiver);
2492
2493 BuildPushArguments(*node->arguments(), arguments); 2529 BuildPushArguments(*node->arguments(), arguments);
2494 InstanceCallInstr* call = new (Z) InstanceCallInstr( 2530 InstanceCallInstr* call = new (Z) InstanceCallInstr(
2495 node->token_pos(), node->function_name(), Token::kILLEGAL, arguments, 2531 node->token_pos(), node->function_name(), Token::kILLEGAL, arguments,
2496 node->arguments()->names(), 1, owner()->ic_data_array()); 2532 node->arguments()->type_args_len(), node->arguments()->names(), 1,
2533 owner()->ic_data_array());
2497 ReturnDefinition(call); 2534 ReturnDefinition(call);
2498 } 2535 }
2499 } 2536 }
2500 2537
2501 2538
2502 // <Expression> ::= StaticCall { function: Function 2539 // <Expression> ::= StaticCall { function: Function
2503 // arguments: <ArgumentList> } 2540 // arguments: <ArgumentList> }
2504 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { 2541 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) {
2505 ZoneGrowableArray<PushArgumentInstr*>* arguments = new (Z) 2542 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2506 ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); 2543 new (Z) ZoneGrowableArray<PushArgumentInstr*>(
2544 node->arguments()->LengthWithTypeArgs());
2545 BuildPushTypeArguments(*node->arguments(), arguments);
2507 BuildPushArguments(*node->arguments(), arguments); 2546 BuildPushArguments(*node->arguments(), arguments);
2508 StaticCallInstr* call = new (Z) StaticCallInstr( 2547 StaticCallInstr* call = new (Z) StaticCallInstr(
2509 node->token_pos(), node->function(), node->arguments()->names(), 2548 node->token_pos(), node->function(), node->arguments()->type_args_len(),
2510 arguments, owner()->ic_data_array()); 2549 node->arguments()->names(), arguments, owner()->ic_data_array());
2511 if (node->function().recognized_kind() != MethodRecognizer::kUnknown) { 2550 if (node->function().recognized_kind() != MethodRecognizer::kUnknown) {
2512 call->set_result_cid(MethodRecognizer::ResultCid(node->function())); 2551 call->set_result_cid(MethodRecognizer::ResultCid(node->function()));
2513 } 2552 }
2514 ReturnDefinition(call); 2553 ReturnDefinition(call);
2515 } 2554 }
2516 2555
2517 2556
2518 void EffectGraphVisitor::BuildClosureCall(ClosureCallNode* node, 2557 void EffectGraphVisitor::BuildClosureCall(ClosureCallNode* node,
2519 bool result_needed) { 2558 bool result_needed) {
2559 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2560 new (Z) ZoneGrowableArray<PushArgumentInstr*>(
2561 node->arguments()->LengthWithTypeArgs() + 1);
2562 BuildPushTypeArguments(*node->arguments(), arguments);
2563
2520 ValueGraphVisitor for_closure(owner()); 2564 ValueGraphVisitor for_closure(owner());
2521 node->closure()->Visit(&for_closure); 2565 node->closure()->Visit(&for_closure);
2522 Append(for_closure); 2566 Append(for_closure);
2523
2524 Value* closure_value = for_closure.value(); 2567 Value* closure_value = for_closure.value();
2525 LocalVariable* tmp_var = EnterTempLocalScope(closure_value); 2568 LocalVariable* tmp_var = EnterTempLocalScope(closure_value);
2526 2569
2527 ZoneGrowableArray<PushArgumentInstr*>* arguments = new (Z)
2528 ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length());
2529 Value* closure_val = 2570 Value* closure_val =
2530 Bind(new (Z) LoadLocalInstr(*tmp_var, node->token_pos())); 2571 Bind(new (Z) LoadLocalInstr(*tmp_var, node->token_pos()));
2531 PushArgumentInstr* push_closure = PushArgument(closure_val); 2572 PushArgumentInstr* push_closure = PushArgument(closure_val);
2532 arguments->Add(push_closure); 2573 arguments->Add(push_closure);
2533 BuildPushArguments(*node->arguments(), arguments); 2574 BuildPushArguments(*node->arguments(), arguments);
2534 2575
2535 closure_val = Bind(new (Z) LoadLocalInstr(*tmp_var, node->token_pos())); 2576 closure_val = Bind(new (Z) LoadLocalInstr(*tmp_var, node->token_pos()));
2536 LoadFieldInstr* function_load = new (Z) LoadFieldInstr( 2577 LoadFieldInstr* function_load = new (Z) LoadFieldInstr(
2537 closure_val, Closure::function_offset(), 2578 closure_val, Closure::function_offset(),
2538 AbstractType::ZoneHandle(Z, AbstractType::null()), node->token_pos()); 2579 AbstractType::ZoneHandle(Z, AbstractType::null()), node->token_pos());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 2637
2597 2638
2598 void EffectGraphVisitor::BuildConstructorCall( 2639 void EffectGraphVisitor::BuildConstructorCall(
2599 ConstructorCallNode* node, 2640 ConstructorCallNode* node,
2600 PushArgumentInstr* push_alloc_value) { 2641 PushArgumentInstr* push_alloc_value) {
2601 ZoneGrowableArray<PushArgumentInstr*>* arguments = 2642 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2602 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 2643 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
2603 arguments->Add(push_alloc_value); 2644 arguments->Add(push_alloc_value);
2604 2645
2605 BuildPushArguments(*node->arguments(), arguments); 2646 BuildPushArguments(*node->arguments(), arguments);
2647 const intptr_t kTypeArgsLen = 0;
2606 Do(new (Z) StaticCallInstr(node->token_pos(), node->constructor(), 2648 Do(new (Z) StaticCallInstr(node->token_pos(), node->constructor(),
2607 node->arguments()->names(), arguments, 2649 kTypeArgsLen, node->arguments()->names(),
2608 owner()->ic_data_array())); 2650 arguments, owner()->ic_data_array()));
2609 } 2651 }
2610 2652
2611 2653
2612 static intptr_t GetResultCidOfListFactory(ConstructorCallNode* node) { 2654 static intptr_t GetResultCidOfListFactory(ConstructorCallNode* node) {
2613 const Function& function = node->constructor(); 2655 const Function& function = node->constructor();
2614 const Class& function_class = Class::Handle(function.Owner()); 2656 const Class& function_class = Class::Handle(function.Owner());
2615 2657
2616 if ((function_class.library() != Library::CoreLibrary()) && 2658 if ((function_class.library() != Library::CoreLibrary()) &&
2617 (function_class.library() != Library::TypedDataLibrary())) { 2659 (function_class.library() != Library::TypedDataLibrary())) {
2618 return kDynamicCid; 2660 return kDynamicCid;
(...skipping 17 matching lines...) Expand all
2636 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { 2678 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) {
2637 if (node->constructor().IsFactory()) { 2679 if (node->constructor().IsFactory()) {
2638 ZoneGrowableArray<PushArgumentInstr*>* arguments = 2680 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2639 new (Z) ZoneGrowableArray<PushArgumentInstr*>(); 2681 new (Z) ZoneGrowableArray<PushArgumentInstr*>();
2640 PushArgumentInstr* push_type_arguments = 2682 PushArgumentInstr* push_type_arguments =
2641 PushArgument(BuildInstantiatedTypeArguments(node->token_pos(), 2683 PushArgument(BuildInstantiatedTypeArguments(node->token_pos(),
2642 node->type_arguments())); 2684 node->type_arguments()));
2643 arguments->Add(push_type_arguments); 2685 arguments->Add(push_type_arguments);
2644 ASSERT(arguments->length() == 1); 2686 ASSERT(arguments->length() == 1);
2645 BuildPushArguments(*node->arguments(), arguments); 2687 BuildPushArguments(*node->arguments(), arguments);
2688 const int kTypeArgsLen = 0;
2646 StaticCallInstr* call = new (Z) StaticCallInstr( 2689 StaticCallInstr* call = new (Z) StaticCallInstr(
2647 node->token_pos(), node->constructor(), node->arguments()->names(), 2690 node->token_pos(), node->constructor(), kTypeArgsLen,
2648 arguments, owner()->ic_data_array()); 2691 node->arguments()->names(), arguments, owner()->ic_data_array());
2649 const intptr_t result_cid = GetResultCidOfListFactory(node); 2692 const intptr_t result_cid = GetResultCidOfListFactory(node);
2650 if (result_cid != kDynamicCid) { 2693 if (result_cid != kDynamicCid) {
2651 call->set_result_cid(result_cid); 2694 call->set_result_cid(result_cid);
2652 call->set_is_known_list_constructor(true); 2695 call->set_is_known_list_constructor(true);
2653 // Recognized fixed length array factory must have two arguments: 2696 // Recognized fixed length array factory must have two arguments:
2654 // (0) type-arguments, (1) length. 2697 // (0) type-arguments, (1) length.
2655 ASSERT(!LoadFieldInstr::IsFixedLengthArrayCid(result_cid) || 2698 ASSERT(!LoadFieldInstr::IsFixedLengthArrayCid(result_cid) ||
2656 arguments->length() == 2); 2699 arguments->length() == 2);
2657 } else if (node->constructor().recognized_kind() != 2700 } else if (node->constructor().recognized_kind() !=
2658 MethodRecognizer::kUnknown) { 2701 MethodRecognizer::kUnknown) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 if (node->is_conditional()) { 2911 if (node->is_conditional()) {
2869 Do(BuildStoreExprTemp(for_receiver.value(), node->token_pos())); 2912 Do(BuildStoreExprTemp(for_receiver.value(), node->token_pos()));
2870 BuildInstanceGetterConditional(node); 2913 BuildInstanceGetterConditional(node);
2871 } else { 2914 } else {
2872 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value()); 2915 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value());
2873 ZoneGrowableArray<PushArgumentInstr*>* arguments = 2916 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2874 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1); 2917 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1);
2875 arguments->Add(push_receiver); 2918 arguments->Add(push_receiver);
2876 const String& name = 2919 const String& name =
2877 String::ZoneHandle(Z, Field::GetterSymbol(node->field_name())); 2920 String::ZoneHandle(Z, Field::GetterSymbol(node->field_name()));
2878 InstanceCallInstr* call = new (Z) 2921 const intptr_t kTypeArgsLen = 0;
2879 InstanceCallInstr(node->token_pos(), name, Token::kGET, arguments, 2922 InstanceCallInstr* call = new (Z) InstanceCallInstr(
2880 Object::null_array(), 1, owner()->ic_data_array()); 2923 node->token_pos(), name, Token::kGET, arguments, kTypeArgsLen,
2924 Object::null_array(), 1, owner()->ic_data_array());
2881 ReturnDefinition(call); 2925 ReturnDefinition(call);
2882 } 2926 }
2883 } 2927 }
2884 2928
2885 2929
2886 void EffectGraphVisitor::BuildInstanceSetterArguments( 2930 void EffectGraphVisitor::BuildInstanceSetterArguments(
2887 InstanceSetterNode* node, 2931 InstanceSetterNode* node,
2888 ZoneGrowableArray<PushArgumentInstr*>* arguments, 2932 ZoneGrowableArray<PushArgumentInstr*>* arguments,
2889 bool result_is_needed) { 2933 bool result_is_needed) {
2890 ValueGraphVisitor for_receiver(owner()); 2934 ValueGraphVisitor for_receiver(owner());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2930 token_pos, load_temp, node->field_name(), node->value()); 2974 token_pos, load_temp, node->field_name(), node->value());
2931 setter->Visit(&for_false); 2975 setter->Visit(&for_false);
2932 Join(for_test, for_true, for_false); 2976 Join(for_test, for_true, for_false);
2933 return; 2977 return;
2934 } 2978 }
2935 ZoneGrowableArray<PushArgumentInstr*>* arguments = 2979 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2936 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 2980 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
2937 BuildInstanceSetterArguments(node, arguments, kResultNotNeeded); 2981 BuildInstanceSetterArguments(node, arguments, kResultNotNeeded);
2938 const String& name = 2982 const String& name =
2939 String::ZoneHandle(Z, Field::SetterSymbol(node->field_name())); 2983 String::ZoneHandle(Z, Field::SetterSymbol(node->field_name()));
2984 const int kTypeArgsLen = 0;
2940 const intptr_t kNumArgsChecked = 1; // Do not check value type. 2985 const intptr_t kNumArgsChecked = 1; // Do not check value type.
2941 InstanceCallInstr* call = new (Z) InstanceCallInstr( 2986 InstanceCallInstr* call = new (Z) InstanceCallInstr(
2942 token_pos, name, Token::kSET, arguments, Object::null_array(), 2987 token_pos, name, Token::kSET, arguments, kTypeArgsLen,
2943 kNumArgsChecked, owner()->ic_data_array()); 2988 Object::null_array(), kNumArgsChecked, owner()->ic_data_array());
2944 ReturnDefinition(call); 2989 ReturnDefinition(call);
2945 } 2990 }
2946 2991
2947 2992
2948 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { 2993 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) {
2949 const TokenPosition token_pos = node->token_pos(); 2994 const TokenPosition token_pos = node->token_pos();
2950 if (node->is_conditional()) { 2995 if (node->is_conditional()) {
2951 ValueGraphVisitor for_receiver(owner()); 2996 ValueGraphVisitor for_receiver(owner());
2952 node->receiver()->Visit(&for_receiver); 2997 node->receiver()->Visit(&for_receiver);
2953 Append(for_receiver); 2998 Append(for_receiver);
(...skipping 20 matching lines...) Expand all
2974 3019
2975 Join(for_test, for_true, for_false); 3020 Join(for_test, for_true, for_false);
2976 ReturnDefinition(BuildLoadExprTemp(token_pos)); 3021 ReturnDefinition(BuildLoadExprTemp(token_pos));
2977 return; 3022 return;
2978 } 3023 }
2979 ZoneGrowableArray<PushArgumentInstr*>* arguments = 3024 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2980 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 3025 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
2981 BuildInstanceSetterArguments(node, arguments, kResultNeeded); 3026 BuildInstanceSetterArguments(node, arguments, kResultNeeded);
2982 const String& name = 3027 const String& name =
2983 String::ZoneHandle(Z, Field::SetterSymbol(node->field_name())); 3028 String::ZoneHandle(Z, Field::SetterSymbol(node->field_name()));
3029 const intptr_t kTypeArgsLen = 0;
2984 const intptr_t kNumArgsChecked = 1; // Do not check value type. 3030 const intptr_t kNumArgsChecked = 1; // Do not check value type.
2985 Do(new (Z) InstanceCallInstr(token_pos, name, Token::kSET, arguments, 3031 Do(new (Z) InstanceCallInstr(token_pos, name, Token::kSET, arguments,
2986 Object::null_array(), kNumArgsChecked, 3032 kTypeArgsLen, Object::null_array(),
2987 owner()->ic_data_array())); 3033 kNumArgsChecked, owner()->ic_data_array()));
2988 ReturnDefinition(BuildLoadExprTemp(token_pos)); 3034 ReturnDefinition(BuildLoadExprTemp(token_pos));
2989 } 3035 }
2990 3036
2991 3037
2992 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { 3038 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) {
2993 const String& getter_name = 3039 const String& getter_name =
2994 String::ZoneHandle(Z, Field::GetterSymbol(node->field_name())); 3040 String::ZoneHandle(Z, Field::GetterSymbol(node->field_name()));
2995 ZoneGrowableArray<PushArgumentInstr*>* arguments = 3041 ZoneGrowableArray<PushArgumentInstr*>* arguments =
2996 new (Z) ZoneGrowableArray<PushArgumentInstr*>(); 3042 new (Z) ZoneGrowableArray<PushArgumentInstr*>();
2997 Function& getter_function = Function::ZoneHandle(Z, Function::null()); 3043 Function& getter_function = Function::ZoneHandle(Z, Function::null());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 NULL, // No Arguments to getter. 3085 NULL, // No Arguments to getter.
3040 InvocationMirror::EncodeType(node->cls().IsTopLevel() 3086 InvocationMirror::EncodeType(node->cls().IsTopLevel()
3041 ? InvocationMirror::kTopLevel 3087 ? InvocationMirror::kTopLevel
3042 : InvocationMirror::kStatic, 3088 : InvocationMirror::kStatic,
3043 InvocationMirror::kGetter)); 3089 InvocationMirror::kGetter));
3044 ReturnDefinition(call); 3090 ReturnDefinition(call);
3045 return; 3091 return;
3046 } 3092 }
3047 } 3093 }
3048 ASSERT(!getter_function.IsNull()); 3094 ASSERT(!getter_function.IsNull());
3095 const intptr_t kTypeArgsLen = 0;
3049 StaticCallInstr* call = 3096 StaticCallInstr* call =
3050 new (Z) StaticCallInstr(node->token_pos(), getter_function, 3097 new (Z) StaticCallInstr(node->token_pos(), getter_function, kTypeArgsLen,
3051 Object::null_array(), // No names 3098 Object::null_array(), // No names
3052 arguments, owner()->ic_data_array()); 3099 arguments, owner()->ic_data_array());
3053 ReturnDefinition(call); 3100 ReturnDefinition(call);
3054 } 3101 }
3055 3102
3056 3103
3057 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node, 3104 void EffectGraphVisitor::BuildStaticSetter(StaticSetterNode* node,
3058 bool result_is_needed) { 3105 bool result_is_needed) {
3059 const String& setter_name = 3106 const String& setter_name =
3060 String::ZoneHandle(Z, Field::SetterSymbol(node->field_name())); 3107 String::ZoneHandle(Z, Field::SetterSymbol(node->field_name()));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 ValueGraphVisitor for_value(owner()); 3148 ValueGraphVisitor for_value(owner());
3102 node->value()->Visit(&for_value); 3149 node->value()->Visit(&for_value);
3103 Append(for_value); 3150 Append(for_value);
3104 Value* value = NULL; 3151 Value* value = NULL;
3105 if (result_is_needed) { 3152 if (result_is_needed) {
3106 value = Bind(BuildStoreExprTemp(for_value.value(), token_pos)); 3153 value = Bind(BuildStoreExprTemp(for_value.value(), token_pos));
3107 } else { 3154 } else {
3108 value = for_value.value(); 3155 value = for_value.value();
3109 } 3156 }
3110 arguments->Add(PushArgument(value)); 3157 arguments->Add(PushArgument(value));
3111 3158 const intptr_t kTypeArgsLen = 0;
3112 call = new (Z) StaticCallInstr(token_pos, setter_function, 3159 call = new (Z) StaticCallInstr(token_pos, setter_function, kTypeArgsLen,
3113 Object::null_array(), // No names. 3160 Object::null_array(), // No names.
3114 arguments, owner()->ic_data_array()); 3161 arguments, owner()->ic_data_array());
3115 } 3162 }
3116 if (result_is_needed) { 3163 if (result_is_needed) {
3117 Do(call); 3164 Do(call);
3118 ReturnDefinition(BuildLoadExprTemp(token_pos)); 3165 ReturnDefinition(BuildLoadExprTemp(token_pos));
3119 } else { 3166 } else {
3120 ReturnDefinition(call); 3167 ReturnDefinition(call);
3121 } 3168 }
3122 } 3169 }
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
3548 ValueGraphVisitor for_array(owner()); 3595 ValueGraphVisitor for_array(owner());
3549 node->array()->Visit(&for_array); 3596 node->array()->Visit(&for_array);
3550 Append(for_array); 3597 Append(for_array);
3551 arguments->Add(PushArgument(for_array.value())); 3598 arguments->Add(PushArgument(for_array.value()));
3552 3599
3553 ValueGraphVisitor for_index(owner()); 3600 ValueGraphVisitor for_index(owner());
3554 node->index_expr()->Visit(&for_index); 3601 node->index_expr()->Visit(&for_index);
3555 Append(for_index); 3602 Append(for_index);
3556 arguments->Add(PushArgument(for_index.value())); 3603 arguments->Add(PushArgument(for_index.value()));
3557 3604
3605 const intptr_t kTypeArgsLen = 0;
3558 if (super_function != NULL) { 3606 if (super_function != NULL) {
3559 // Generate static call to super operator. 3607 // Generate static call to super operator.
3560 StaticCallInstr* load = new (Z) StaticCallInstr( 3608 StaticCallInstr* load = new (Z) StaticCallInstr(
3561 node->token_pos(), *super_function, Object::null_array(), arguments, 3609 node->token_pos(), *super_function, kTypeArgsLen, Object::null_array(),
3562 owner()->ic_data_array()); 3610 arguments, owner()->ic_data_array());
3563 ReturnDefinition(load); 3611 ReturnDefinition(load);
3564 } else { 3612 } else {
3565 // Generate dynamic call to index operator. 3613 // Generate dynamic call to index operator.
3566 const intptr_t checked_argument_count = 1; 3614 const intptr_t checked_argument_count = 1;
3567 InstanceCallInstr* load = new (Z) InstanceCallInstr( 3615 InstanceCallInstr* load = new (Z) InstanceCallInstr(
3568 node->token_pos(), Symbols::IndexToken(), Token::kINDEX, arguments, 3616 node->token_pos(), Symbols::IndexToken(), Token::kINDEX, arguments,
3569 Object::null_array(), checked_argument_count, owner()->ic_data_array()); 3617 kTypeArgsLen, Object::null_array(), checked_argument_count,
3618 owner()->ic_data_array());
3570 ReturnDefinition(load); 3619 ReturnDefinition(load);
3571 } 3620 }
3572 } 3621 }
3573 3622
3574 3623
3575 Definition* EffectGraphVisitor::BuildStoreIndexedValues(StoreIndexedNode* node, 3624 Definition* EffectGraphVisitor::BuildStoreIndexedValues(StoreIndexedNode* node,
3576 bool result_is_needed) { 3625 bool result_is_needed) {
3577 Function* super_function = NULL; 3626 Function* super_function = NULL;
3578 const TokenPosition token_pos = node->token_pos(); 3627 const TokenPosition token_pos = node->token_pos();
3579 if (node->IsSuperStore()) { 3628 if (node->IsSuperStore()) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3619 node->value()->Visit(&for_value); 3668 node->value()->Visit(&for_value);
3620 Append(for_value); 3669 Append(for_value);
3621 Value* value = NULL; 3670 Value* value = NULL;
3622 if (result_is_needed) { 3671 if (result_is_needed) {
3623 value = Bind(BuildStoreExprTemp(for_value.value(), token_pos)); 3672 value = Bind(BuildStoreExprTemp(for_value.value(), token_pos));
3624 } else { 3673 } else {
3625 value = for_value.value(); 3674 value = for_value.value();
3626 } 3675 }
3627 arguments->Add(PushArgument(value)); 3676 arguments->Add(PushArgument(value));
3628 3677
3678 const intptr_t kTypeArgsLen = 0;
3629 if (super_function != NULL) { 3679 if (super_function != NULL) {
3630 // Generate static call to super operator []=. 3680 // Generate static call to super operator []=.
3631 3681
3632 StaticCallInstr* store = new (Z) 3682 StaticCallInstr* store = new (Z) StaticCallInstr(
3633 StaticCallInstr(token_pos, *super_function, Object::null_array(), 3683 token_pos, *super_function, kTypeArgsLen, Object::null_array(),
3634 arguments, owner()->ic_data_array()); 3684 arguments, owner()->ic_data_array());
3635 if (result_is_needed) { 3685 if (result_is_needed) {
3636 Do(store); 3686 Do(store);
3637 return BuildLoadExprTemp(token_pos); 3687 return BuildLoadExprTemp(token_pos);
3638 } else { 3688 } else {
3639 return store; 3689 return store;
3640 } 3690 }
3641 } else { 3691 } else {
3642 // Generate dynamic call to operator []=. 3692 // Generate dynamic call to operator []=.
3643 const intptr_t checked_argument_count = 2; // Do not check for value type. 3693 const intptr_t checked_argument_count = 2; // Do not check for value type.
3644 InstanceCallInstr* store = new (Z) InstanceCallInstr( 3694 InstanceCallInstr* store = new (Z) InstanceCallInstr(
3645 token_pos, Symbols::AssignIndexToken(), Token::kASSIGN_INDEX, arguments, 3695 token_pos, Symbols::AssignIndexToken(), Token::kASSIGN_INDEX, arguments,
3646 Object::null_array(), checked_argument_count, owner()->ic_data_array()); 3696 kTypeArgsLen, Object::null_array(), checked_argument_count,
3697 owner()->ic_data_array());
3647 if (result_is_needed) { 3698 if (result_is_needed) {
3648 Do(store); 3699 Do(store);
3649 return BuildLoadExprTemp(token_pos); 3700 return BuildLoadExprTemp(token_pos);
3650 } else { 3701 } else {
3651 return store; 3702 return store;
3652 } 3703 }
3653 } 3704 }
3654 } 3705 }
3655 3706
3656 3707
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3806 *async_stack_trace_var, node->token_pos().ToSynthetic())); 3857 *async_stack_trace_var, node->token_pos().ToSynthetic()));
3807 // Setup arguments for _asyncSetThreadStackTrace. 3858 // Setup arguments for _asyncSetThreadStackTrace.
3808 ZoneGrowableArray<PushArgumentInstr*>* arguments = 3859 ZoneGrowableArray<PushArgumentInstr*>* arguments =
3809 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1); 3860 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1);
3810 arguments->Add(PushArgument(async_stack_trace_value)); 3861 arguments->Add(PushArgument(async_stack_trace_value));
3811 3862
3812 const Function& async_set_thread_stack_trace = Function::ZoneHandle( 3863 const Function& async_set_thread_stack_trace = Function::ZoneHandle(
3813 Z, isolate()->object_store()->async_set_thread_stack_trace()); 3864 Z, isolate()->object_store()->async_set_thread_stack_trace());
3814 ASSERT(!async_set_thread_stack_trace.IsNull()); 3865 ASSERT(!async_set_thread_stack_trace.IsNull());
3815 // Call _asyncSetThreadStackTrace 3866 // Call _asyncSetThreadStackTrace
3816 StaticCallInstr* call_async_set_thread_stack_trace = new (Z) 3867 const intptr_t kTypeArgsLen = 0;
3817 StaticCallInstr(node->token_pos().ToSynthetic(), 3868 StaticCallInstr* call_async_set_thread_stack_trace =
3818 async_set_thread_stack_trace, Object::null_array(), 3869 new (Z) StaticCallInstr(node->token_pos().ToSynthetic(),
3819 arguments, owner()->ic_data_array()); 3870 async_set_thread_stack_trace, kTypeArgsLen,
3871 Object::null_array(), arguments,
3872 owner()->ic_data_array());
3820 Do(call_async_set_thread_stack_trace); 3873 Do(call_async_set_thread_stack_trace);
3821 } 3874 }
3822 3875
3823 3876
3824 if (FLAG_support_debugger && is_top_level_sequence && 3877 if (FLAG_support_debugger && is_top_level_sequence &&
3825 function.is_debuggable()) { 3878 function.is_debuggable()) {
3826 // Place a debug check at method entry to ensure breaking on a method always 3879 // Place a debug check at method entry to ensure breaking on a method always
3827 // happens, even if there are no assignments/calls/runtimecalls in the first 3880 // happens, even if there are no assignments/calls/runtimecalls in the first
3828 // basic block. Place this check at the last parameter to ensure parameters 3881 // basic block. Place this check at the last parameter to ensure parameters
3829 // are in scope in the debugger at method entry. 3882 // are in scope in the debugger at method entry.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
4143 bool is_super_invocation) { 4196 bool is_super_invocation) {
4144 TokenPosition args_pos = method_arguments->token_pos(); 4197 TokenPosition args_pos = method_arguments->token_pos();
4145 LocalVariable* temp = NULL; 4198 LocalVariable* temp = NULL;
4146 if (save_last_arg) { 4199 if (save_last_arg) {
4147 temp = owner()->parsed_function().expression_temp_var(); 4200 temp = owner()->parsed_function().expression_temp_var();
4148 } 4201 }
4149 ArgumentListNode* args = Parser::BuildNoSuchMethodArguments( 4202 ArgumentListNode* args = Parser::BuildNoSuchMethodArguments(
4150 args_pos, method_name, *method_arguments, temp, is_super_invocation); 4203 args_pos, method_name, *method_arguments, temp, is_super_invocation);
4151 // Make sure we resolve to a compatible noSuchMethod, otherwise call 4204 // Make sure we resolve to a compatible noSuchMethod, otherwise call
4152 // noSuchMethod of class Object. 4205 // noSuchMethod of class Object.
4206 const int kTypeArgsLen = 0;
4153 const int kNumArguments = 2; 4207 const int kNumArguments = 2;
4154 ArgumentsDescriptor args_desc( 4208 ArgumentsDescriptor args_desc(Array::ZoneHandle(
4155 Array::ZoneHandle(Z, ArgumentsDescriptor::New(kNumArguments))); 4209 Z, ArgumentsDescriptor::New(kTypeArgsLen, kNumArguments)));
4156 Function& no_such_method_func = Function::ZoneHandle( 4210 Function& no_such_method_func = Function::ZoneHandle(
4157 Z, Resolver::ResolveDynamicForReceiverClass( 4211 Z, Resolver::ResolveDynamicForReceiverClass(
4158 target_class, Symbols::NoSuchMethod(), args_desc)); 4212 target_class, Symbols::NoSuchMethod(), args_desc));
4159 if (no_such_method_func.IsNull()) { 4213 if (no_such_method_func.IsNull()) {
4160 const Class& object_class = 4214 const Class& object_class =
4161 Class::ZoneHandle(Z, isolate()->object_store()->object_class()); 4215 Class::ZoneHandle(Z, isolate()->object_store()->object_class());
4162 no_such_method_func = Resolver::ResolveDynamicForReceiverClass( 4216 no_such_method_func = Resolver::ResolveDynamicForReceiverClass(
4163 object_class, Symbols::NoSuchMethod(), args_desc); 4217 object_class, Symbols::NoSuchMethod(), args_desc);
4164 } 4218 }
4165 // We are guaranteed to find noSuchMethod of class Object. 4219 // We are guaranteed to find noSuchMethod of class Object.
4166 ASSERT(!no_such_method_func.IsNull()); 4220 ASSERT(!no_such_method_func.IsNull());
4167 ZoneGrowableArray<PushArgumentInstr*>* push_arguments = 4221 ZoneGrowableArray<PushArgumentInstr*>* push_arguments =
4168 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 4222 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
4169 BuildPushArguments(*args, push_arguments); 4223 BuildPushArguments(*args, push_arguments);
4170 return new (Z) 4224 return new (Z) StaticCallInstr(args_pos, no_such_method_func, kTypeArgsLen,
4171 StaticCallInstr(args_pos, no_such_method_func, Object::null_array(), 4225 Object::null_array(), push_arguments,
4172 push_arguments, owner()->ic_data_array()); 4226 owner()->ic_data_array());
4173 } 4227 }
4174 4228
4175 4229
4176 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( 4230 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError(
4177 TokenPosition token_pos, 4231 TokenPosition token_pos,
4178 const Class& function_class, 4232 const Class& function_class,
4179 const String& function_name, 4233 const String& function_name,
4180 ArgumentListNode* function_arguments, 4234 ArgumentListNode* function_arguments,
4181 int invocation_type) { 4235 int invocation_type) {
4182 ZoneGrowableArray<PushArgumentInstr*>* arguments = 4236 ZoneGrowableArray<PushArgumentInstr*>* arguments =
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4220 4274
4221 // List existingArgumentNames. 4275 // List existingArgumentNames.
4222 Value* existing_argument_names_value = 4276 Value* existing_argument_names_value =
4223 Bind(new (Z) ConstantInstr(Array::ZoneHandle(Z, Array::null()))); 4277 Bind(new (Z) ConstantInstr(Array::ZoneHandle(Z, Array::null())));
4224 arguments->Add(PushArgument(existing_argument_names_value)); 4278 arguments->Add(PushArgument(existing_argument_names_value));
4225 // Resolve and call NoSuchMethodError._throwNew. 4279 // Resolve and call NoSuchMethodError._throwNew.
4226 const Library& core_lib = Library::Handle(Z, Library::CoreLibrary()); 4280 const Library& core_lib = Library::Handle(Z, Library::CoreLibrary());
4227 const Class& cls = 4281 const Class& cls =
4228 Class::Handle(Z, core_lib.LookupClass(Symbols::NoSuchMethodError())); 4282 Class::Handle(Z, core_lib.LookupClass(Symbols::NoSuchMethodError()));
4229 ASSERT(!cls.IsNull()); 4283 ASSERT(!cls.IsNull());
4284 const intptr_t kTypeArgsLen = 0;
4230 const Function& func = Function::ZoneHandle( 4285 const Function& func = Function::ZoneHandle(
4231 Z, Resolver::ResolveStatic( 4286 Z, Resolver::ResolveStatic(
4232 cls, Library::PrivateCoreLibName(Symbols::ThrowNew()), 4287 cls, Library::PrivateCoreLibName(Symbols::ThrowNew()),
4233 arguments->length(), Object::null_array())); 4288 kTypeArgsLen, arguments->length(), Object::null_array()));
4234 ASSERT(!func.IsNull()); 4289 ASSERT(!func.IsNull());
4235 return new (Z) StaticCallInstr(token_pos, func, 4290 return new (Z) StaticCallInstr(token_pos, func, kTypeArgsLen,
4236 Object::null_array(), // No names. 4291 Object::null_array(), // No names.
4237 arguments, owner()->ic_data_array()); 4292 arguments, owner()->ic_data_array());
4238 } 4293 }
4239 4294
4240 4295
4241 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) { 4296 void EffectGraphVisitor::BuildThrowNode(ThrowNode* node) {
4242 if (FLAG_support_debugger) { 4297 if (FLAG_support_debugger) {
4243 if (node->exception()->IsLiteralNode() || 4298 if (node->exception()->IsLiteralNode() ||
4244 node->exception()->IsLoadLocalNode() || 4299 node->exception()->IsLoadLocalNode() ||
4245 node->exception()->IsLoadStaticFieldNode() || 4300 node->exception()->IsLoadStaticFieldNode() ||
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
4394 ASSERT(type.HasResolvedTypeClass()); 4449 ASSERT(type.HasResolvedTypeClass());
4395 const Class& type_class = Class::Handle(type.type_class()); 4450 const Class& type_class = Class::Handle(type.type_class());
4396 // Bail if the type has any type parameters. 4451 // Bail if the type has any type parameters.
4397 if (type_class.IsGeneric()) return false; 4452 if (type_class.IsGeneric()) return false;
4398 4453
4399 // Finally a simple class for instance of checking. 4454 // Finally a simple class for instance of checking.
4400 return true; 4455 return true;
4401 } 4456 }
4402 4457
4403 } // namespace dart 4458 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698