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

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

Powered by Google App Engine
This is Rietveld 408576698