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

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

Issue 2748063003: Reland "VM: Simplify lowering of is-tests."" (Closed)
Patch Set: Created 3 years, 9 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/constants_dbc.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 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
1559 // We now know type is a real class (!num, !int, !smi, !string) 1527 // We now know type is a real class (!num, !int, !smi, !string)
1560 // and the type check could NOT be removed at compile time. 1528 // and the type check could NOT be removed at compile time.
1561 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 1529 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1562 if (simpleInstanceOfType(type)) { 1530 if (simpleInstanceOfType(type)) {
1563 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); 1531 ASSERT(!node->right()->AsTypeNode()->type().IsNull());
1564 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1532 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1565 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2); 1533 new (Z) ZoneGrowableArray<PushArgumentInstr*>(2);
1566 arguments->Add(push_left); 1534 arguments->Add(push_left);
1567 Value* type_const = Bind(new (Z) ConstantInstr(type)); 1535 Value* type_const = Bind(new (Z) ConstantInstr(type));
1568 arguments->Add(PushArgument(type_const)); 1536 arguments->Add(PushArgument(type_const));
(...skipping 11 matching lines...) Expand all
1580 return; 1548 return;
1581 } 1549 }
1582 1550
1583 PushArgumentInstr* push_type_args = NULL; 1551 PushArgumentInstr* push_type_args = NULL;
1584 if (type.IsInstantiated()) { 1552 if (type.IsInstantiated()) {
1585 push_type_args = PushArgument(BuildNullValue(node->token_pos())); 1553 push_type_args = PushArgument(BuildNullValue(node->token_pos()));
1586 } else { 1554 } else {
1587 BuildTypecheckPushArguments(node->token_pos(), &push_type_args); 1555 BuildTypecheckPushArguments(node->token_pos(), &push_type_args);
1588 } 1556 }
1589 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1557 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1590 new (Z) ZoneGrowableArray<PushArgumentInstr*>(4); 1558 new (Z) ZoneGrowableArray<PushArgumentInstr*>(3);
1591 arguments->Add(push_left); 1559 arguments->Add(push_left);
1592 arguments->Add(push_type_args); 1560 arguments->Add(push_type_args);
1593 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); 1561 ASSERT(!node->right()->AsTypeNode()->type().IsNull());
1594 Value* type_const = Bind(new (Z) ConstantInstr(type)); 1562 Value* type_const = Bind(new (Z) ConstantInstr(type));
1595 arguments->Add(PushArgument(type_const)); 1563 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));
1599 const intptr_t kNumArgsChecked = 1; 1564 const intptr_t kNumArgsChecked = 1;
1600 InstanceCallInstr* call = new (Z) InstanceCallInstr( 1565 Definition* result = new (Z) InstanceCallInstr(
1601 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()), 1566 node->token_pos(), Library::PrivateCoreLibName(Symbols::_instanceOf()),
1602 node->kind(), arguments, 1567 node->kind(), arguments,
1603 Object::null_array(), // No argument names. 1568 Object::null_array(), // No argument names.
1604 kNumArgsChecked, owner()->ic_data_array()); 1569 kNumArgsChecked, owner()->ic_data_array());
1605 ReturnDefinition(call); 1570 if (negate_result) {
1571 result = new (Z) BooleanNegateInstr(Bind(result));
1572 }
1573 ReturnDefinition(result);
1606 } 1574 }
1607 1575
1608 1576
1609 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { 1577 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) {
1610 ASSERT(Token::IsTypeCastOperator(node->kind())); 1578 ASSERT(Token::IsTypeCastOperator(node->kind()));
1611 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); 1579 ASSERT(!node->right()->AsTypeNode()->type().IsNull());
1612 const AbstractType& type = node->right()->AsTypeNode()->type(); 1580 const AbstractType& type = node->right()->AsTypeNode()->type();
1613 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); 1581 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded());
1614 ValueGraphVisitor for_value(owner()); 1582 ValueGraphVisitor for_value(owner());
1615 node->left()->Visit(&for_value); 1583 node->left()->Visit(&for_value);
(...skipping 2774 matching lines...) Expand 10 before | Expand all | Expand 10 after
4390 graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks); 4358 graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks);
4391 ASSERT(found); 4359 ASSERT(found);
4392 } 4360 }
4393 4361
4394 4362
4395 void FlowGraphBuilder::Bailout(const char* reason) const { 4363 void FlowGraphBuilder::Bailout(const char* reason) const {
4396 parsed_function_.Bailout("FlowGraphBuilder", reason); 4364 parsed_function_.Bailout("FlowGraphBuilder", reason);
4397 } 4365 }
4398 4366
4399 } // namespace dart 4367 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/constants_dbc.h ('k') | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698