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 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 Object::null_array(), // No argument names. | 1611 Object::null_array(), // No argument names. |
1612 kNumArgsChecked, | 1612 kNumArgsChecked, |
1613 owner()->ic_data_array()); | 1613 owner()->ic_data_array()); |
1614 ReturnDefinition(call); | 1614 ReturnDefinition(call); |
1615 return; | 1615 return; |
1616 } | 1616 } |
1617 | 1617 |
1618 // We now know type is a real class (!num, !int, !smi, !string) | 1618 // We now know type is a real class (!num, !int, !smi, !string) |
1619 // and the type check could NOT be removed at compile time. | 1619 // and the type check could NOT be removed at compile time. |
1620 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); | 1620 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); |
1621 if (simpleInstanceOfType(type) && (node->kind() == Token::kIS)) { | 1621 if (simpleInstanceOfType(type)) { |
1622 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | 1622 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
1623 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1623 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
1624 new(Z) ZoneGrowableArray<PushArgumentInstr*>(2); | 1624 new(Z) ZoneGrowableArray<PushArgumentInstr*>(2); |
1625 arguments->Add(push_left); | 1625 arguments->Add(push_left); |
1626 Value* type_const = Bind(new(Z) ConstantInstr(type)); | 1626 Value* type_const = Bind(new(Z) ConstantInstr(type)); |
1627 arguments->Add(PushArgument(type_const)); | 1627 arguments->Add(PushArgument(type_const)); |
1628 const intptr_t kNumArgsChecked = 2; | 1628 const intptr_t kNumArgsChecked = 2; |
1629 InstanceCallInstr* call = new(Z) InstanceCallInstr( | 1629 Definition* result = new(Z) InstanceCallInstr( |
1630 node->token_pos(), | 1630 node->token_pos(), |
1631 Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()), | 1631 Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()), |
1632 node->kind(), | 1632 node->kind(), |
1633 arguments, | 1633 arguments, |
1634 Object::null_array(), // No argument names. | 1634 Object::null_array(), // No argument names. |
1635 kNumArgsChecked, | 1635 kNumArgsChecked, |
1636 owner()->ic_data_array()); | 1636 owner()->ic_data_array()); |
1637 ReturnDefinition(call); | 1637 if (negate_result) { |
| 1638 result = new(Z) BooleanNegateInstr(Bind(result)); |
| 1639 } |
| 1640 ReturnDefinition(result); |
| 1641 return; |
| 1642 } |
| 1643 |
| 1644 PushArgumentInstr* push_type_args = NULL; |
| 1645 if (type.IsInstantiated()) { |
| 1646 push_type_args = PushArgument(BuildNullValue(node->token_pos())); |
1638 } else { | 1647 } else { |
1639 PushArgumentInstr* push_type_args = NULL; | 1648 BuildTypecheckPushArguments(node->token_pos(), &push_type_args); |
1640 if (type.IsInstantiated()) { | |
1641 push_type_args = PushArgument(BuildNullValue(node->token_pos())); | |
1642 } else { | |
1643 BuildTypecheckPushArguments(node->token_pos(), &push_type_args); | |
1644 } | |
1645 ZoneGrowableArray<PushArgumentInstr*>* arguments = | |
1646 new(Z) ZoneGrowableArray<PushArgumentInstr*>(4); | |
1647 arguments->Add(push_left); | |
1648 arguments->Add(push_type_args); | |
1649 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | |
1650 Value* type_const = Bind(new(Z) ConstantInstr(type)); | |
1651 arguments->Add(PushArgument(type_const)); | |
1652 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); | |
1653 Value* negate_arg = Bind(new(Z) ConstantInstr(negate)); | |
1654 arguments->Add(PushArgument(negate_arg)); | |
1655 const intptr_t kNumArgsChecked = 1; | |
1656 InstanceCallInstr* call = new(Z) InstanceCallInstr( | |
1657 node->token_pos(), | |
1658 Library::PrivateCoreLibName(Symbols::_instanceOf()), | |
1659 node->kind(), | |
1660 arguments, | |
1661 Object::null_array(), // No argument names. | |
1662 kNumArgsChecked, | |
1663 owner()->ic_data_array()); | |
1664 ReturnDefinition(call); | |
1665 } | 1649 } |
| 1650 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1651 new(Z) ZoneGrowableArray<PushArgumentInstr*>(4); |
| 1652 arguments->Add(push_left); |
| 1653 arguments->Add(push_type_args); |
| 1654 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
| 1655 Value* type_const = Bind(new(Z) ConstantInstr(type)); |
| 1656 arguments->Add(PushArgument(type_const)); |
| 1657 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); |
| 1658 Value* negate_arg = Bind(new(Z) ConstantInstr(negate)); |
| 1659 arguments->Add(PushArgument(negate_arg)); |
| 1660 const intptr_t kNumArgsChecked = 1; |
| 1661 InstanceCallInstr* call = new(Z) InstanceCallInstr( |
| 1662 node->token_pos(), |
| 1663 Library::PrivateCoreLibName(Symbols::_instanceOf()), |
| 1664 node->kind(), |
| 1665 arguments, |
| 1666 Object::null_array(), // No argument names. |
| 1667 kNumArgsChecked, |
| 1668 owner()->ic_data_array()); |
| 1669 ReturnDefinition(call); |
1666 } | 1670 } |
1667 | 1671 |
1668 | 1672 |
1669 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { | 1673 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { |
1670 ASSERT(Token::IsTypeCastOperator(node->kind())); | 1674 ASSERT(Token::IsTypeCastOperator(node->kind())); |
1671 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | 1675 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
1672 const AbstractType& type = node->right()->AsTypeNode()->type(); | 1676 const AbstractType& type = node->right()->AsTypeNode()->type(); |
1673 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 1677 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
1674 ValueGraphVisitor for_value(owner()); | 1678 ValueGraphVisitor for_value(owner()); |
1675 node->left()->Visit(&for_value); | 1679 node->left()->Visit(&for_value); |
(...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4618 block_marks); | 4622 block_marks); |
4619 ASSERT(found); | 4623 ASSERT(found); |
4620 } | 4624 } |
4621 | 4625 |
4622 | 4626 |
4623 void FlowGraphBuilder::Bailout(const char* reason) const { | 4627 void FlowGraphBuilder::Bailout(const char* reason) const { |
4624 parsed_function_.Bailout("FlowGraphBuilder", reason); | 4628 parsed_function_.Bailout("FlowGraphBuilder", reason); |
4625 } | 4629 } |
4626 | 4630 |
4627 } // namespace dart | 4631 } // namespace dart |
OLD | NEW |