| 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 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 EffectGraphVisitor for_left_value(owner()); | 1517 EffectGraphVisitor for_left_value(owner()); |
| 1518 node->left()->Visit(&for_left_value); | 1518 node->left()->Visit(&for_left_value); |
| 1519 Append(for_left_value); | 1519 Append(for_left_value); |
| 1520 ReturnDefinition(new (Z) ConstantInstr(Bool::Get(!negate_result))); | 1520 ReturnDefinition(new (Z) ConstantInstr(Bool::Get(!negate_result))); |
| 1521 return; | 1521 return; |
| 1522 } | 1522 } |
| 1523 ValueGraphVisitor for_left_value(owner()); | 1523 ValueGraphVisitor for_left_value(owner()); |
| 1524 node->left()->Visit(&for_left_value); | 1524 node->left()->Visit(&for_left_value); |
| 1525 Append(for_left_value); | 1525 Append(for_left_value); |
| 1526 | 1526 |
| 1527 if (type.IsNumberType() || type.IsIntType() || type.IsDoubleType() || |
| 1528 type.IsSmiType() || type.IsStringType()) { |
| 1529 String& method_name = String::ZoneHandle(Z); |
| 1530 if (type.IsNumberType()) { |
| 1531 method_name = Symbols::_instanceOfNum().raw(); |
| 1532 } else if (type.IsIntType()) { |
| 1533 method_name = Symbols::_instanceOfInt().raw(); |
| 1534 } else if (type.IsDoubleType()) { |
| 1535 method_name = Symbols::_instanceOfDouble().raw(); |
| 1536 } else if (type.IsSmiType()) { |
| 1537 method_name = Symbols::_instanceOfSmi().raw(); |
| 1538 } else if (type.IsStringType()) { |
| 1539 method_name = Symbols::_instanceOfString().raw(); |
| 1540 } |
| 1541 ASSERT(!method_name.IsNull()); |
| 1542 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); |
| 1543 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1544 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1545 arguments->Add(push_left); |
| 1546 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); |
| 1547 Value* negate_arg = Bind(new (Z) ConstantInstr(negate)); |
| 1548 arguments->Add(PushArgument(negate_arg)); |
| 1549 const intptr_t kNumArgsChecked = 1; |
| 1550 InstanceCallInstr* call = new (Z) InstanceCallInstr( |
| 1551 node->token_pos(), Library::PrivateCoreLibName(method_name), |
| 1552 node->kind(), arguments, |
| 1553 Object::null_array(), // No argument names. |
| 1554 kNumArgsChecked, owner()->ic_data_array()); |
| 1555 ReturnDefinition(call); |
| 1556 return; |
| 1557 } |
| 1558 |
| 1527 // We now know type is a real class (!num, !int, !smi, !string) | 1559 // We now know type is a real class (!num, !int, !smi, !string) |
| 1528 // and the type check could NOT be removed at compile time. | 1560 // and the type check could NOT be removed at compile time. |
| 1529 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); | 1561 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); |
| 1530 if (simpleInstanceOfType(type)) { | 1562 if (simpleInstanceOfType(type)) { |
| 1531 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | 1563 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
| 1532 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1564 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1533 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); | 1565 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1534 arguments->Add(push_left); | 1566 arguments->Add(push_left); |
| 1535 Value* type_const = Bind(new (Z) ConstantInstr(type)); | 1567 Value* type_const = Bind(new (Z) ConstantInstr(type)); |
| 1536 arguments->Add(PushArgument(type_const)); | 1568 arguments->Add(PushArgument(type_const)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1548 return; | 1580 return; |
| 1549 } | 1581 } |
| 1550 | 1582 |
| 1551 PushArgumentInstr* push_type_args = NULL; | 1583 PushArgumentInstr* push_type_args = NULL; |
| 1552 if (type.IsInstantiated()) { | 1584 if (type.IsInstantiated()) { |
| 1553 push_type_args = PushArgument(BuildNullValue(node->token_pos())); | 1585 push_type_args = PushArgument(BuildNullValue(node->token_pos())); |
| 1554 } else { | 1586 } else { |
| 1555 BuildTypecheckPushArguments(node->token_pos(), &push_type_args); | 1587 BuildTypecheckPushArguments(node->token_pos(), &push_type_args); |
| 1556 } | 1588 } |
| 1557 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1589 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1558 new (Z) ZoneGrowableArray<PushArgumentInstr*>(3); | 1590 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4); |
| 1559 arguments->Add(push_left); | 1591 arguments->Add(push_left); |
| 1560 arguments->Add(push_type_args); | 1592 arguments->Add(push_type_args); |
| 1561 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | 1593 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
| 1562 Value* type_const = Bind(new (Z) ConstantInstr(type)); | 1594 Value* type_const = Bind(new (Z) ConstantInstr(type)); |
| 1563 arguments->Add(PushArgument(type_const)); | 1595 arguments->Add(PushArgument(type_const)); |
| 1596 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); |
| 1597 Value* negate_arg = Bind(new (Z) ConstantInstr(negate)); |
| 1598 arguments->Add(PushArgument(negate_arg)); |
| 1564 const intptr_t kNumArgsChecked = 1; | 1599 const intptr_t kNumArgsChecked = 1; |
| 1565 Definition* result = new (Z) InstanceCallInstr( | 1600 InstanceCallInstr* call = new (Z) InstanceCallInstr( |
| 1566 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()), | 1601 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()), |
| 1567 node->kind(), arguments, | 1602 node->kind(), arguments, |
| 1568 Object::null_array(), // No argument names. | 1603 Object::null_array(), // No argument names. |
| 1569 kNumArgsChecked, owner()->ic_data_array()); | 1604 kNumArgsChecked, owner()->ic_data_array()); |
| 1570 if (negate_result) { | 1605 ReturnDefinition(call); |
| 1571 result = new (Z) BooleanNegateInstr(Bind(result)); | |
| 1572 } | |
| 1573 ReturnDefinition(result); | |
| 1574 } | 1606 } |
| 1575 | 1607 |
| 1576 | 1608 |
| 1577 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { | 1609 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { |
| 1578 ASSERT(Token::IsTypeCastOperator(node->kind())); | 1610 ASSERT(Token::IsTypeCastOperator(node->kind())); |
| 1579 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | 1611 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
| 1580 const AbstractType& type = node->right()->AsTypeNode()->type(); | 1612 const AbstractType& type = node->right()->AsTypeNode()->type(); |
| 1581 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 1613 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
| 1582 ValueGraphVisitor for_value(owner()); | 1614 ValueGraphVisitor for_value(owner()); |
| 1583 node->left()->Visit(&for_value); | 1615 node->left()->Visit(&for_value); |
| (...skipping 2774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4358 graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks); | 4390 graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks); |
| 4359 ASSERT(found); | 4391 ASSERT(found); |
| 4360 } | 4392 } |
| 4361 | 4393 |
| 4362 | 4394 |
| 4363 void FlowGraphBuilder::Bailout(const char* reason) const { | 4395 void FlowGraphBuilder::Bailout(const char* reason) const { |
| 4364 parsed_function_.Bailout("FlowGraphBuilder", reason); | 4396 parsed_function_.Bailout("FlowGraphBuilder", reason); |
| 4365 } | 4397 } |
| 4366 | 4398 |
| 4367 } // namespace dart | 4399 } // namespace dart |
| OLD | NEW |