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

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 1657863004: [turbofan] Introduce proper ObjectIsReceiver operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 ProcessRemainingInputs(node, 3); 1233 ProcessRemainingInputs(node, 3);
1234 SetOutput(node, NodeOutputInfo::None()); 1234 SetOutput(node, NodeOutputInfo::None());
1235 break; 1235 break;
1236 } 1236 }
1237 case IrOpcode::kObjectIsNumber: { 1237 case IrOpcode::kObjectIsNumber: {
1238 ProcessInput(node, 0, UseInfo::AnyTagged()); 1238 ProcessInput(node, 0, UseInfo::AnyTagged());
1239 SetOutput(node, NodeOutputInfo::Bool()); 1239 SetOutput(node, NodeOutputInfo::Bool());
1240 if (lower()) lowering->DoObjectIsNumber(node); 1240 if (lower()) lowering->DoObjectIsNumber(node);
1241 break; 1241 break;
1242 } 1242 }
1243 case IrOpcode::kObjectIsReceiver: {
1244 ProcessInput(node, 0, UseInfo::AnyTagged());
1245 SetOutput(node, NodeOutputInfo::Bool());
1246 if (lower()) lowering->DoObjectIsReceiver(node);
1247 break;
1248 }
1243 case IrOpcode::kObjectIsSmi: { 1249 case IrOpcode::kObjectIsSmi: {
1244 ProcessInput(node, 0, UseInfo::AnyTagged()); 1250 ProcessInput(node, 0, UseInfo::AnyTagged());
1245 SetOutput(node, NodeOutputInfo::Bool()); 1251 SetOutput(node, NodeOutputInfo::Bool());
1246 if (lower()) lowering->DoObjectIsSmi(node); 1252 if (lower()) lowering->DoObjectIsSmi(node);
1247 break; 1253 break;
1248 } 1254 }
1249 1255
1250 //------------------------------------------------------------------ 1256 //------------------------------------------------------------------
1251 // Machine-level operators. 1257 // Machine-level operators.
1252 //------------------------------------------------------------------ 1258 //------------------------------------------------------------------
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 DCHECK_EQ(IrOpcode::kStoreBuffer, node->opcode()); 1582 DCHECK_EQ(IrOpcode::kStoreBuffer, node->opcode());
1577 MachineRepresentation const rep = 1583 MachineRepresentation const rep =
1578 BufferAccessOf(node->op()).machine_type().representation(); 1584 BufferAccessOf(node->op()).machine_type().representation();
1579 NodeProperties::ChangeOp(node, machine()->CheckedStore(rep)); 1585 NodeProperties::ChangeOp(node, machine()->CheckedStore(rep));
1580 } 1586 }
1581 1587
1582 1588
1583 void SimplifiedLowering::DoObjectIsNumber(Node* node) { 1589 void SimplifiedLowering::DoObjectIsNumber(Node* node) {
1584 Node* input = NodeProperties::GetValueInput(node, 0); 1590 Node* input = NodeProperties::GetValueInput(node, 0);
1585 // TODO(bmeurer): Optimize somewhat based on input type. 1591 // TODO(bmeurer): Optimize somewhat based on input type.
1586 Node* check = 1592 Node* check = IsSmi(input);
1587 graph()->NewNode(machine()->WordEqual(),
1588 graph()->NewNode(machine()->WordAnd(), input,
1589 jsgraph()->IntPtrConstant(kSmiTagMask)),
1590 jsgraph()->IntPtrConstant(kSmiTag));
1591 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); 1593 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start());
1592 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 1594 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
1593 Node* vtrue = jsgraph()->Int32Constant(1); 1595 Node* vtrue = jsgraph()->Int32Constant(1);
1594 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 1596 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
1595 Node* vfalse = graph()->NewNode( 1597 Node* vfalse = graph()->NewNode(
1596 machine()->WordEqual(), 1598 machine()->WordEqual(), LoadHeapObjectMap(input, if_false),
1597 graph()->NewNode(
1598 machine()->Load(MachineType::AnyTagged()), input,
1599 jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag),
1600 graph()->start(), if_false),
1601 jsgraph()->HeapConstant(isolate()->factory()->heap_number_map())); 1599 jsgraph()->HeapConstant(isolate()->factory()->heap_number_map()));
1602 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); 1600 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false);
1603 node->ReplaceInput(0, vtrue); 1601 node->ReplaceInput(0, vtrue);
1604 node->AppendInput(graph()->zone(), vfalse); 1602 node->AppendInput(graph()->zone(), vfalse);
1605 node->AppendInput(graph()->zone(), control); 1603 node->AppendInput(graph()->zone(), control);
1606 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); 1604 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2));
1607 } 1605 }
1608 1606
1609 1607
1608 void SimplifiedLowering::DoObjectIsReceiver(Node* node) {
1609 Node* input = NodeProperties::GetValueInput(node, 0);
1610 // TODO(bmeurer): Optimize somewhat based on input type.
1611 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
1612 Node* check = IsSmi(input);
1613 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start());
1614 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
1615 Node* vtrue = jsgraph()->Int32Constant(0);
1616 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
1617 Node* vfalse =
1618 graph()->NewNode(machine()->Uint32LessThanOrEqual(),
1619 jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE),
1620 LoadMapInstanceType(LoadHeapObjectMap(input, if_false)));
1621 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false);
1622 node->ReplaceInput(0, vtrue);
1623 node->AppendInput(graph()->zone(), vfalse);
1624 node->AppendInput(graph()->zone(), control);
1625 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2));
1626 }
1627
1628
1610 void SimplifiedLowering::DoObjectIsSmi(Node* node) { 1629 void SimplifiedLowering::DoObjectIsSmi(Node* node) {
1611 node->ReplaceInput(0, 1630 node->ReplaceInput(0,
1612 graph()->NewNode(machine()->WordAnd(), node->InputAt(0), 1631 graph()->NewNode(machine()->WordAnd(), node->InputAt(0),
1613 jsgraph()->IntPtrConstant(kSmiTagMask))); 1632 jsgraph()->IntPtrConstant(kSmiTagMask)));
1614 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag)); 1633 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag));
1615 NodeProperties::ChangeOp(node, machine()->WordEqual()); 1634 NodeProperties::ChangeOp(node, machine()->WordEqual());
1616 } 1635 }
1617 1636
1618 1637
1638 Node* SimplifiedLowering::IsSmi(Node* value) {
1639 return graph()->NewNode(
1640 machine()->WordEqual(),
1641 graph()->NewNode(machine()->WordAnd(), value,
1642 jsgraph()->IntPtrConstant(kSmiTagMask)),
1643 jsgraph()->IntPtrConstant(kSmiTag));
1644 }
1645
1646
1647 Node* SimplifiedLowering::LoadHeapObjectMap(Node* object, Node* control) {
1648 return graph()->NewNode(
1649 machine()->Load(MachineType::AnyTagged()), object,
1650 jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag),
1651 graph()->start(), control);
1652 }
1653
1654
1655 Node* SimplifiedLowering::LoadMapInstanceType(Node* map) {
1656 return graph()->NewNode(
1657 machine()->Load(MachineType::Uint8()), map,
1658 jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag),
1659 graph()->start(), graph()->start());
1660 }
1661
1662
1619 Node* SimplifiedLowering::StringComparison(Node* node) { 1663 Node* SimplifiedLowering::StringComparison(Node* node) {
1620 Operator::Properties properties = node->op()->properties(); 1664 Operator::Properties properties = node->op()->properties();
1621 Callable callable = CodeFactory::StringCompare(isolate()); 1665 Callable callable = CodeFactory::StringCompare(isolate());
1622 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; 1666 CallDescriptor::Flags flags = CallDescriptor::kNoFlags;
1623 CallDescriptor* desc = Linkage::GetStubCallDescriptor( 1667 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1624 isolate(), zone(), callable.descriptor(), 0, flags, properties); 1668 isolate(), zone(), callable.descriptor(), 0, flags, properties);
1625 return graph()->NewNode( 1669 return graph()->NewNode(
1626 common()->Call(desc), jsgraph()->HeapConstant(callable.code()), 1670 common()->Call(desc), jsgraph()->HeapConstant(callable.code()),
1627 NodeProperties::GetValueInput(node, 0), 1671 NodeProperties::GetValueInput(node, 0),
1628 NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant(), 1672 NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant(),
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 ReplaceEffectUses(node, comparison); 1980 ReplaceEffectUses(node, comparison);
1937 node->ReplaceInput(0, comparison); 1981 node->ReplaceInput(0, comparison);
1938 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); 1982 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
1939 node->TrimInputCount(2); 1983 node->TrimInputCount(2);
1940 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); 1984 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual());
1941 } 1985 }
1942 1986
1943 } // namespace compiler 1987 } // namespace compiler
1944 } // namespace internal 1988 } // namespace internal
1945 } // namespace v8 1989 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698