OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 } | 1227 } |
1228 const TokenPosition token_pos = node->token_pos(); | 1228 const TokenPosition token_pos = node->token_pos(); |
1229 Value* instantiator_type_arguments = NULL; | 1229 Value* instantiator_type_arguments = NULL; |
1230 if (type.IsInstantiated(kCurrentClass)) { | 1230 if (type.IsInstantiated(kCurrentClass)) { |
1231 instantiator_type_arguments = BuildNullValue(token_pos); | 1231 instantiator_type_arguments = BuildNullValue(token_pos); |
1232 } else { | 1232 } else { |
1233 instantiator_type_arguments = BuildInstantiatorTypeArguments(token_pos); | 1233 instantiator_type_arguments = BuildInstantiatorTypeArguments(token_pos); |
1234 } | 1234 } |
1235 Value* function_type_arguments = NULL; | 1235 Value* function_type_arguments = NULL; |
1236 if (type.IsInstantiated(kCurrentFunction)) { | 1236 if (type.IsInstantiated(kCurrentFunction)) { |
1237 // TODO(regis): function_type_arguments = BuildNullValue((token_pos); | 1237 function_type_arguments = BuildNullValue(token_pos); |
1238 } else { | 1238 } else { |
1239 function_type_arguments = BuildFunctionTypeArguments(token_pos); | 1239 function_type_arguments = BuildFunctionTypeArguments(token_pos); |
1240 } | 1240 } |
1241 ReturnDefinition(new (Z) InstantiateTypeInstr( | 1241 ReturnDefinition(new (Z) InstantiateTypeInstr( |
1242 token_pos, type, instantiator_type_arguments, function_type_arguments)); | 1242 token_pos, type, instantiator_type_arguments, function_type_arguments)); |
1243 } | 1243 } |
1244 | 1244 |
1245 | 1245 |
1246 // Returns true if the type check can be skipped, for example, if the | 1246 // Returns true if the type check can be skipped, for example, if the |
1247 // destination type is dynamic or if the compile type of the value is a subtype | 1247 // destination type is dynamic or if the compile type of the value is a subtype |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 const String& dst_name) { | 1456 const String& dst_name) { |
1457 // Build the type check computation. | 1457 // Build the type check computation. |
1458 Value* instantiator_type_arguments = NULL; | 1458 Value* instantiator_type_arguments = NULL; |
1459 Value* function_type_arguments = NULL; | 1459 Value* function_type_arguments = NULL; |
1460 if (dst_type.IsInstantiated(kCurrentClass)) { | 1460 if (dst_type.IsInstantiated(kCurrentClass)) { |
1461 instantiator_type_arguments = BuildNullValue(token_pos); | 1461 instantiator_type_arguments = BuildNullValue(token_pos); |
1462 } else { | 1462 } else { |
1463 instantiator_type_arguments = BuildInstantiatorTypeArguments(token_pos); | 1463 instantiator_type_arguments = BuildInstantiatorTypeArguments(token_pos); |
1464 } | 1464 } |
1465 if (dst_type.IsInstantiated(kCurrentFunction)) { | 1465 if (dst_type.IsInstantiated(kCurrentFunction)) { |
1466 // TODO(regis): function_type_arguments = BuildNullValue(token_pos); | 1466 function_type_arguments = BuildNullValue(token_pos); |
1467 } else { | 1467 } else { |
1468 function_type_arguments = BuildFunctionTypeArguments(token_pos); | 1468 function_type_arguments = BuildFunctionTypeArguments(token_pos); |
1469 } | 1469 } |
1470 | 1470 |
1471 const intptr_t deopt_id = Thread::Current()->GetNextDeoptId(); | 1471 const intptr_t deopt_id = Thread::Current()->GetNextDeoptId(); |
1472 return new (Z) AssertAssignableInstr( | 1472 return new (Z) AssertAssignableInstr( |
1473 token_pos, value, instantiator_type_arguments, function_type_arguments, | 1473 token_pos, value, instantiator_type_arguments, function_type_arguments, |
1474 dst_type, dst_name, deopt_id); | 1474 dst_type, dst_name, deopt_id); |
1475 } | 1475 } |
1476 | 1476 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 kNumArgsChecked, owner()->ic_data_array()); | 1525 kNumArgsChecked, owner()->ic_data_array()); |
1526 if (negate_result) { | 1526 if (negate_result) { |
1527 result = new (Z) BooleanNegateInstr(Bind(result)); | 1527 result = new (Z) BooleanNegateInstr(Bind(result)); |
1528 } | 1528 } |
1529 ReturnDefinition(result); | 1529 ReturnDefinition(result); |
1530 return; | 1530 return; |
1531 } | 1531 } |
1532 | 1532 |
1533 PushArgumentInstr* push_instantiator_type_args = | 1533 PushArgumentInstr* push_instantiator_type_args = |
1534 PushInstantiatorTypeArguments(type, node->token_pos()); | 1534 PushInstantiatorTypeArguments(type, node->token_pos()); |
1535 // TODO(regis): PushArgumentInstr* push_function_type_args = | 1535 PushArgumentInstr* push_function_type_args = |
1536 // PushFunctionTypeArguments(type, node->token_pos()); | 1536 PushFunctionTypeArguments(type, node->token_pos()); |
1537 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1537 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1538 new (Z) ZoneGrowableArray<PushArgumentInstr*>(3); | 1538 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4); |
1539 arguments->Add(push_left); | 1539 arguments->Add(push_left); |
1540 arguments->Add(push_instantiator_type_args); | 1540 arguments->Add(push_instantiator_type_args); |
1541 // TODO(regis): arguments->Add(push_function_type_args); | 1541 arguments->Add(push_function_type_args); |
1542 Value* type_const = Bind(new (Z) ConstantInstr(type)); | 1542 Value* type_const = Bind(new (Z) ConstantInstr(type)); |
1543 arguments->Add(PushArgument(type_const)); | 1543 arguments->Add(PushArgument(type_const)); |
1544 const intptr_t kNumArgsChecked = 1; | 1544 const intptr_t kNumArgsChecked = 1; |
1545 Definition* result = new (Z) InstanceCallInstr( | 1545 Definition* result = new (Z) InstanceCallInstr( |
1546 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()), | 1546 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()), |
1547 node->kind(), arguments, | 1547 node->kind(), arguments, |
1548 Object::null_array(), // No argument names. | 1548 Object::null_array(), // No argument names. |
1549 kNumArgsChecked, owner()->ic_data_array()); | 1549 kNumArgsChecked, owner()->ic_data_array()); |
1550 if (negate_result) { | 1550 if (negate_result) { |
1551 result = new (Z) BooleanNegateInstr(Bind(result)); | 1551 result = new (Z) BooleanNegateInstr(Bind(result)); |
(...skipping 11 matching lines...) Expand all Loading... |
1563 node->left()->Visit(&for_value); | 1563 node->left()->Visit(&for_value); |
1564 Append(for_value); | 1564 Append(for_value); |
1565 if (CanSkipTypeCheck(node->token_pos(), for_value.value(), type, | 1565 if (CanSkipTypeCheck(node->token_pos(), for_value.value(), type, |
1566 Symbols::InTypeCast())) { | 1566 Symbols::InTypeCast())) { |
1567 ReturnValue(for_value.value()); | 1567 ReturnValue(for_value.value()); |
1568 return; | 1568 return; |
1569 } | 1569 } |
1570 PushArgumentInstr* push_left = PushArgument(for_value.value()); | 1570 PushArgumentInstr* push_left = PushArgument(for_value.value()); |
1571 PushArgumentInstr* push_instantiator_type_args = | 1571 PushArgumentInstr* push_instantiator_type_args = |
1572 PushInstantiatorTypeArguments(type, node->token_pos()); | 1572 PushInstantiatorTypeArguments(type, node->token_pos()); |
1573 // TODO(regis): PushArgumentInstr* push_function_type_args = | 1573 PushArgumentInstr* push_function_type_args = |
1574 // PushFunctionTypeArguments(type, node->token_pos()); | 1574 PushFunctionTypeArguments(type, node->token_pos()); |
1575 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1575 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1576 new (Z) ZoneGrowableArray<PushArgumentInstr*>(3); | 1576 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4); |
1577 arguments->Add(push_left); | 1577 arguments->Add(push_left); |
1578 arguments->Add(push_instantiator_type_args); | 1578 arguments->Add(push_instantiator_type_args); |
1579 // TODO(regis): arguments->Add(push_function_type_args); | 1579 arguments->Add(push_function_type_args); |
1580 Value* type_arg = Bind(new (Z) ConstantInstr(type)); | 1580 Value* type_arg = Bind(new (Z) ConstantInstr(type)); |
1581 arguments->Add(PushArgument(type_arg)); | 1581 arguments->Add(PushArgument(type_arg)); |
1582 const intptr_t kNumArgsChecked = 1; | 1582 const intptr_t kNumArgsChecked = 1; |
1583 InstanceCallInstr* call = new (Z) InstanceCallInstr( | 1583 InstanceCallInstr* call = new (Z) InstanceCallInstr( |
1584 node->token_pos(), Library::PrivateCoreLibName(Symbols::_as()), | 1584 node->token_pos(), Library::PrivateCoreLibName(Symbols::_as()), |
1585 node->kind(), arguments, | 1585 node->kind(), arguments, |
1586 Object::null_array(), // No argument names. | 1586 Object::null_array(), // No argument names. |
1587 kNumArgsChecked, owner()->ic_data_array()); | 1587 kNumArgsChecked, owner()->ic_data_array()); |
1588 ReturnDefinition(call); | 1588 ReturnDefinition(call); |
1589 } | 1589 } |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 Class::ZoneHandle(Z, owner()->function().Owner()); | 2731 Class::ZoneHandle(Z, owner()->function().Owner()); |
2732 Value* instantiator_type_args = BuildInstantiatorTypeArguments(token_pos); | 2732 Value* instantiator_type_args = BuildInstantiatorTypeArguments(token_pos); |
2733 const bool use_instantiator_type_args = | 2733 const bool use_instantiator_type_args = |
2734 type_arguments.IsUninstantiatedIdentity() || | 2734 type_arguments.IsUninstantiatedIdentity() || |
2735 type_arguments.CanShareInstantiatorTypeArguments(instantiator_class); | 2735 type_arguments.CanShareInstantiatorTypeArguments(instantiator_class); |
2736 if (use_instantiator_type_args) { | 2736 if (use_instantiator_type_args) { |
2737 return instantiator_type_args; | 2737 return instantiator_type_args; |
2738 } | 2738 } |
2739 Value* function_type_args = NULL; | 2739 Value* function_type_args = NULL; |
2740 if (type_arguments.IsInstantiated(kCurrentFunction)) { | 2740 if (type_arguments.IsInstantiated(kCurrentFunction)) { |
2741 // TODO(regis): function_type_args = BuildNullValue(token_pos); | 2741 function_type_args = BuildNullValue(token_pos); |
2742 } else { | 2742 } else { |
2743 function_type_args = BuildFunctionTypeArguments(token_pos); | 2743 function_type_args = BuildFunctionTypeArguments(token_pos); |
2744 } | 2744 } |
2745 return Bind(new (Z) InstantiateTypeArgumentsInstr( | 2745 return Bind(new (Z) InstantiateTypeArgumentsInstr( |
2746 token_pos, type_arguments, instantiator_class, instantiator_type_args, | 2746 token_pos, type_arguments, instantiator_class, instantiator_type_args, |
2747 function_type_args)); | 2747 function_type_args)); |
2748 } | 2748 } |
2749 | 2749 |
2750 | 2750 |
2751 void ValueGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { | 2751 void ValueGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4133 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( | 4133 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( |
4134 TokenPosition token_pos, | 4134 TokenPosition token_pos, |
4135 const Class& function_class, | 4135 const Class& function_class, |
4136 const String& function_name, | 4136 const String& function_name, |
4137 ArgumentListNode* function_arguments, | 4137 ArgumentListNode* function_arguments, |
4138 int invocation_type) { | 4138 int invocation_type) { |
4139 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 4139 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
4140 new (Z) ZoneGrowableArray<PushArgumentInstr*>(); | 4140 new (Z) ZoneGrowableArray<PushArgumentInstr*>(); |
4141 // Object receiver, actually a class literal of the unresolved method's owner. | 4141 // Object receiver, actually a class literal of the unresolved method's owner. |
4142 AbstractType& type = Type::ZoneHandle( | 4142 AbstractType& type = Type::ZoneHandle( |
4143 Z, | 4143 Z, Type::New(function_class, Object::null_type_arguments(), token_pos, |
4144 Type::New(function_class, TypeArguments::Handle(Z, TypeArguments::null()), | 4144 Heap::kOld)); |
4145 token_pos, Heap::kOld)); | |
4146 type ^= ClassFinalizer::FinalizeType(function_class, type); | 4145 type ^= ClassFinalizer::FinalizeType(function_class, type); |
4147 Value* receiver_value = Bind(new (Z) ConstantInstr(type)); | 4146 Value* receiver_value = Bind(new (Z) ConstantInstr(type)); |
4148 arguments->Add(PushArgument(receiver_value)); | 4147 arguments->Add(PushArgument(receiver_value)); |
4149 // String memberName. | 4148 // String memberName. |
4150 const String& member_name = | 4149 const String& member_name = |
4151 String::ZoneHandle(Z, Symbols::New(T, function_name)); | 4150 String::ZoneHandle(Z, Symbols::New(T, function_name)); |
4152 Value* member_name_value = Bind(new (Z) ConstantInstr(member_name)); | 4151 Value* member_name_value = Bind(new (Z) ConstantInstr(member_name)); |
4153 arguments->Add(PushArgument(member_name_value)); | 4152 arguments->Add(PushArgument(member_name_value)); |
4154 // Smi invocation_type. | 4153 // Smi invocation_type. |
4155 Value* invocation_type_value = Bind( | 4154 Value* invocation_type_value = Bind( |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4352 ASSERT(type.HasResolvedTypeClass()); | 4351 ASSERT(type.HasResolvedTypeClass()); |
4353 const Class& type_class = Class::Handle(type.type_class()); | 4352 const Class& type_class = Class::Handle(type.type_class()); |
4354 // Bail if the type has any type parameters. | 4353 // Bail if the type has any type parameters. |
4355 if (type_class.IsGeneric()) return false; | 4354 if (type_class.IsGeneric()) return false; |
4356 | 4355 |
4357 // Finally a simple class for instance of checking. | 4356 // Finally a simple class for instance of checking. |
4358 return true; | 4357 return true; |
4359 } | 4358 } |
4360 | 4359 |
4361 } // namespace dart | 4360 } // namespace dart |
OLD | NEW |