Index: src/compiler/simplified-lowering.cc |
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc |
index 0132bf9272f8fe86c4afc668d575c7b13ab527fd..7b0545f049f552cf3fab905b1074df77a59a678a 100644 |
--- a/src/compiler/simplified-lowering.cc |
+++ b/src/compiler/simplified-lowering.cc |
@@ -1240,6 +1240,12 @@ class RepresentationSelector { |
if (lower()) lowering->DoObjectIsNumber(node); |
break; |
} |
+ case IrOpcode::kObjectIsReceiver: { |
+ ProcessInput(node, 0, UseInfo::AnyTagged()); |
+ SetOutput(node, NodeOutputInfo::Bool()); |
+ if (lower()) lowering->DoObjectIsReceiver(node); |
+ break; |
+ } |
case IrOpcode::kObjectIsSmi: { |
ProcessInput(node, 0, UseInfo::AnyTagged()); |
SetOutput(node, NodeOutputInfo::Bool()); |
@@ -1583,21 +1589,13 @@ void SimplifiedLowering::DoStoreBuffer(Node* node) { |
void SimplifiedLowering::DoObjectIsNumber(Node* node) { |
Node* input = NodeProperties::GetValueInput(node, 0); |
// TODO(bmeurer): Optimize somewhat based on input type. |
- Node* check = |
- graph()->NewNode(machine()->WordEqual(), |
- graph()->NewNode(machine()->WordAnd(), input, |
- jsgraph()->IntPtrConstant(kSmiTagMask)), |
- jsgraph()->IntPtrConstant(kSmiTag)); |
+ Node* check = IsSmi(input); |
Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
Node* vtrue = jsgraph()->Int32Constant(1); |
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
Node* vfalse = graph()->NewNode( |
- machine()->WordEqual(), |
- graph()->NewNode( |
- machine()->Load(MachineType::AnyTagged()), input, |
- jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), |
- graph()->start(), if_false), |
+ machine()->WordEqual(), LoadHeapObjectMap(input, if_false), |
jsgraph()->HeapConstant(isolate()->factory()->heap_number_map())); |
Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
node->ReplaceInput(0, vtrue); |
@@ -1607,6 +1605,27 @@ void SimplifiedLowering::DoObjectIsNumber(Node* node) { |
} |
+void SimplifiedLowering::DoObjectIsReceiver(Node* node) { |
+ Node* input = NodeProperties::GetValueInput(node, 0); |
+ // TODO(bmeurer): Optimize somewhat based on input type. |
+ STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); |
+ Node* check = IsSmi(input); |
+ Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); |
+ Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
+ Node* vtrue = jsgraph()->Int32Constant(0); |
+ Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
+ Node* vfalse = |
+ graph()->NewNode(machine()->Uint32LessThanOrEqual(), |
+ jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE), |
+ LoadMapInstanceType(LoadHeapObjectMap(input, if_false))); |
+ Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
+ node->ReplaceInput(0, vtrue); |
+ node->AppendInput(graph()->zone(), vfalse); |
+ node->AppendInput(graph()->zone(), control); |
+ NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); |
+} |
+ |
+ |
void SimplifiedLowering::DoObjectIsSmi(Node* node) { |
node->ReplaceInput(0, |
graph()->NewNode(machine()->WordAnd(), node->InputAt(0), |
@@ -1616,6 +1635,31 @@ void SimplifiedLowering::DoObjectIsSmi(Node* node) { |
} |
+Node* SimplifiedLowering::IsSmi(Node* value) { |
+ return graph()->NewNode( |
+ machine()->WordEqual(), |
+ graph()->NewNode(machine()->WordAnd(), value, |
+ jsgraph()->IntPtrConstant(kSmiTagMask)), |
+ jsgraph()->IntPtrConstant(kSmiTag)); |
+} |
+ |
+ |
+Node* SimplifiedLowering::LoadHeapObjectMap(Node* object, Node* control) { |
+ return graph()->NewNode( |
+ machine()->Load(MachineType::AnyTagged()), object, |
+ jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), |
+ graph()->start(), control); |
+} |
+ |
+ |
+Node* SimplifiedLowering::LoadMapInstanceType(Node* map) { |
+ return graph()->NewNode( |
+ machine()->Load(MachineType::Uint8()), map, |
+ jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag), |
+ graph()->start(), graph()->start()); |
+} |
+ |
+ |
Node* SimplifiedLowering::StringComparison(Node* node) { |
Operator::Properties properties = node->op()->properties(); |
Callable callable = CodeFactory::StringCompare(isolate()); |