[turbofan] Move lowering of ObjectIs* nodes to ChangeLowering.
Review URL: https://codereview.chromium.org/1712563002 Cr-Commit-Position: refs/heads/master@{#34137}
This commit is contained in:
parent
ba2077aac3
commit
a56af88942
@ -49,6 +49,12 @@ Reduction ChangeLowering::Reduce(Node* node) {
|
|||||||
return StoreElement(node);
|
return StoreElement(node);
|
||||||
case IrOpcode::kAllocate:
|
case IrOpcode::kAllocate:
|
||||||
return Allocate(node);
|
return Allocate(node);
|
||||||
|
case IrOpcode::kObjectIsReceiver:
|
||||||
|
return ObjectIsReceiver(node);
|
||||||
|
case IrOpcode::kObjectIsSmi:
|
||||||
|
return ObjectIsSmi(node);
|
||||||
|
case IrOpcode::kObjectIsNumber:
|
||||||
|
return ObjectIsNumber(node);
|
||||||
default:
|
default:
|
||||||
return NoChange();
|
return NoChange();
|
||||||
}
|
}
|
||||||
@ -582,6 +588,76 @@ Reduction ChangeLowering::Allocate(Node* node) {
|
|||||||
return Changed(node);
|
return Changed(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node* ChangeLowering::IsSmi(Node* value) {
|
||||||
|
return graph()->NewNode(
|
||||||
|
machine()->WordEqual(),
|
||||||
|
graph()->NewNode(machine()->WordAnd(), value,
|
||||||
|
jsgraph()->IntPtrConstant(kSmiTagMask)),
|
||||||
|
jsgraph()->IntPtrConstant(kSmiTag));
|
||||||
|
}
|
||||||
|
|
||||||
|
Node* ChangeLowering::LoadHeapObjectMap(Node* object, Node* control) {
|
||||||
|
return graph()->NewNode(
|
||||||
|
machine()->Load(MachineType::AnyTagged()), object,
|
||||||
|
jsgraph()->IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag),
|
||||||
|
graph()->start(), control);
|
||||||
|
}
|
||||||
|
|
||||||
|
Node* ChangeLowering::LoadMapInstanceType(Node* map) {
|
||||||
|
return graph()->NewNode(
|
||||||
|
machine()->Load(MachineType::Uint8()), map,
|
||||||
|
jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag),
|
||||||
|
graph()->start(), graph()->start());
|
||||||
|
}
|
||||||
|
|
||||||
|
Reduction ChangeLowering::ObjectIsNumber(Node* node) {
|
||||||
|
Node* input = NodeProperties::GetValueInput(node, 0);
|
||||||
|
// TODO(bmeurer): Optimize somewhat based on input 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(1);
|
||||||
|
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
|
||||||
|
Node* vfalse = graph()->NewNode(
|
||||||
|
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);
|
||||||
|
node->AppendInput(graph()->zone(), vfalse);
|
||||||
|
node->AppendInput(graph()->zone(), control);
|
||||||
|
NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2));
|
||||||
|
return Changed(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
Reduction ChangeLowering::ObjectIsReceiver(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));
|
||||||
|
return Changed(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
Reduction ChangeLowering::ObjectIsSmi(Node* node) {
|
||||||
|
node->ReplaceInput(0,
|
||||||
|
graph()->NewNode(machine()->WordAnd(), node->InputAt(0),
|
||||||
|
jsgraph()->IntPtrConstant(kSmiTagMask)));
|
||||||
|
node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag));
|
||||||
|
NodeProperties::ChangeOp(node, machine()->WordEqual());
|
||||||
|
return Changed(node);
|
||||||
|
}
|
||||||
|
|
||||||
Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); }
|
Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); }
|
||||||
|
|
||||||
|
@ -56,6 +56,14 @@ class ChangeLowering final : public Reducer {
|
|||||||
Reduction StoreElement(Node* node);
|
Reduction StoreElement(Node* node);
|
||||||
Reduction Allocate(Node* node);
|
Reduction Allocate(Node* node);
|
||||||
|
|
||||||
|
Node* IsSmi(Node* value);
|
||||||
|
Node* LoadHeapObjectMap(Node* object, Node* control);
|
||||||
|
Node* LoadMapInstanceType(Node* map);
|
||||||
|
|
||||||
|
Reduction ObjectIsNumber(Node* node);
|
||||||
|
Reduction ObjectIsReceiver(Node* node);
|
||||||
|
Reduction ObjectIsSmi(Node* node);
|
||||||
|
|
||||||
Node* ComputeIndex(const ElementAccess& access, Node* const key);
|
Node* ComputeIndex(const ElementAccess& access, Node* const key);
|
||||||
Graph* graph() const;
|
Graph* graph() const;
|
||||||
Isolate* isolate() const;
|
Isolate* isolate() const;
|
||||||
|
@ -1241,19 +1241,16 @@ class RepresentationSelector {
|
|||||||
case IrOpcode::kObjectIsNumber: {
|
case IrOpcode::kObjectIsNumber: {
|
||||||
ProcessInput(node, 0, UseInfo::AnyTagged());
|
ProcessInput(node, 0, UseInfo::AnyTagged());
|
||||||
SetOutput(node, NodeOutputInfo::Bool());
|
SetOutput(node, NodeOutputInfo::Bool());
|
||||||
if (lower()) lowering->DoObjectIsNumber(node);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IrOpcode::kObjectIsReceiver: {
|
case IrOpcode::kObjectIsReceiver: {
|
||||||
ProcessInput(node, 0, UseInfo::AnyTagged());
|
ProcessInput(node, 0, UseInfo::AnyTagged());
|
||||||
SetOutput(node, NodeOutputInfo::Bool());
|
SetOutput(node, NodeOutputInfo::Bool());
|
||||||
if (lower()) lowering->DoObjectIsReceiver(node);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IrOpcode::kObjectIsSmi: {
|
case IrOpcode::kObjectIsSmi: {
|
||||||
ProcessInput(node, 0, UseInfo::AnyTagged());
|
ProcessInput(node, 0, UseInfo::AnyTagged());
|
||||||
SetOutput(node, NodeOutputInfo::Bool());
|
SetOutput(node, NodeOutputInfo::Bool());
|
||||||
if (lower()) lowering->DoObjectIsSmi(node);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1591,80 +1588,6 @@ 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 = 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(), 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);
|
|
||||||
node->AppendInput(graph()->zone(), vfalse);
|
|
||||||
node->AppendInput(graph()->zone(), control);
|
|
||||||
NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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),
|
|
||||||
jsgraph()->IntPtrConstant(kSmiTagMask)));
|
|
||||||
node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag));
|
|
||||||
NodeProperties::ChangeOp(node, machine()->WordEqual());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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) {
|
Node* SimplifiedLowering::StringComparison(Node* node) {
|
||||||
Operator::Properties properties = node->op()->properties();
|
Operator::Properties properties = node->op()->properties();
|
||||||
Callable callable = CodeFactory::StringCompare(isolate());
|
Callable callable = CodeFactory::StringCompare(isolate());
|
||||||
|
@ -36,9 +36,6 @@ class SimplifiedLowering final {
|
|||||||
void DoLoadBuffer(Node* node, MachineRepresentation rep,
|
void DoLoadBuffer(Node* node, MachineRepresentation rep,
|
||||||
RepresentationChanger* changer);
|
RepresentationChanger* changer);
|
||||||
void DoStoreBuffer(Node* node);
|
void DoStoreBuffer(Node* node);
|
||||||
void DoObjectIsNumber(Node* node);
|
|
||||||
void DoObjectIsReceiver(Node* node);
|
|
||||||
void DoObjectIsSmi(Node* node);
|
|
||||||
void DoShift(Node* node, Operator const* op, Type* rhs_type);
|
void DoShift(Node* node, Operator const* op, Type* rhs_type);
|
||||||
void DoStringEqual(Node* node);
|
void DoStringEqual(Node* node);
|
||||||
void DoStringLessThan(Node* node);
|
void DoStringLessThan(Node* node);
|
||||||
@ -56,9 +53,6 @@ class SimplifiedLowering final {
|
|||||||
// position information via the SourcePositionWrapper like all other reducers.
|
// position information via the SourcePositionWrapper like all other reducers.
|
||||||
SourcePositionTable* source_positions_;
|
SourcePositionTable* source_positions_;
|
||||||
|
|
||||||
Node* IsSmi(Node* value);
|
|
||||||
Node* LoadHeapObjectMap(Node* object, Node* control);
|
|
||||||
Node* LoadMapInstanceType(Node* map);
|
|
||||||
Node* StringComparison(Node* node);
|
Node* StringComparison(Node* node);
|
||||||
Node* Int32Div(Node* const node);
|
Node* Int32Div(Node* const node);
|
||||||
Node* Int32Mod(Node* const node);
|
Node* Int32Mod(Node* const node);
|
||||||
|
Loading…
Reference in New Issue
Block a user