Commit 4fc4978c authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Improve lowering of ObjectIs<Type> somewhat.

If we already know that the input to one of the ObjectIs<Type> nodes is
TaggedPointer, we don't need to perform the Smi check at runtime.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1872143002

Cr-Commit-Position: refs/heads/master@{#35368}
parent a62104df
...@@ -621,66 +621,101 @@ Node* ChangeLowering::LoadMapInstanceType(Node* map) { ...@@ -621,66 +621,101 @@ Node* ChangeLowering::LoadMapInstanceType(Node* map) {
Reduction ChangeLowering::ObjectIsNumber(Node* node) { Reduction ChangeLowering::ObjectIsNumber(Node* node) {
Node* input = NodeProperties::GetValueInput(node, 0); Node* input = NodeProperties::GetValueInput(node, 0);
// TODO(bmeurer): Optimize somewhat based on input type. Type* input_type = NodeProperties::GetType(input);
Node* check = IsSmi(input); if (input_type->Is(Type::TaggedPointer())) {
Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); node->ReplaceInput(0, LoadHeapObjectMap(input, graph()->start()));
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); node->AppendInput(
Node* vtrue = jsgraph()->Int32Constant(1); graph()->zone(),
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); jsgraph()->HeapConstant(isolate()->factory()->heap_number_map()));
Node* vfalse = graph()->NewNode( NodeProperties::ChangeOp(node, machine()->WordEqual());
machine()->WordEqual(), LoadHeapObjectMap(input, if_false), } else {
jsgraph()->HeapConstant(isolate()->factory()->heap_number_map())); Node* check = IsSmi(input);
Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); Node* branch =
node->ReplaceInput(0, vtrue); graph()->NewNode(common()->Branch(), check, graph()->start());
node->AppendInput(graph()->zone(), vfalse); Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
node->AppendInput(graph()->zone(), control); Node* vtrue = jsgraph()->Int32Constant(1);
NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); 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); return Changed(node);
} }
Reduction ChangeLowering::ObjectIsReceiver(Node* 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); STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
Node* check = IsSmi(input); Node* input = NodeProperties::GetValueInput(node, 0);
Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); Type* input_type = NodeProperties::GetType(input);
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); if (input_type->Is(Type::TaggedPointer())) {
Node* vtrue = jsgraph()->Int32Constant(0); node->ReplaceInput(0, jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE));
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); node->AppendInput(graph()->zone(), LoadMapInstanceType(LoadHeapObjectMap(
Node* vfalse = input, graph()->start())));
graph()->NewNode(machine()->Uint32LessThanOrEqual(), NodeProperties::ChangeOp(node, machine()->Uint32LessThanOrEqual());
jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE), } else {
LoadMapInstanceType(LoadHeapObjectMap(input, if_false))); Node* check = IsSmi(input);
Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); Node* branch =
node->ReplaceInput(0, vtrue); graph()->NewNode(common()->Branch(), check, graph()->start());
node->AppendInput(graph()->zone(), vfalse); Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
node->AppendInput(graph()->zone(), control); Node* vtrue = jsgraph()->Int32Constant(0);
NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); 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); return Changed(node);
} }
Reduction ChangeLowering::ObjectIsUndetectable(Node* node) { Reduction ChangeLowering::ObjectIsUndetectable(Node* node) {
Node* input = NodeProperties::GetValueInput(node, 0); Node* input = NodeProperties::GetValueInput(node, 0);
// TODO(bmeurer): Optimize somewhat based on input type. Type* input_type = NodeProperties::GetType(input);
Node* check = IsSmi(input); if (input_type->Is(Type::TaggedPointer())) {
Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); node->ReplaceInput(
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 0, graph()->NewNode(
Node* vtrue = jsgraph()->Int32Constant(0); machine()->Word32Equal(),
Node* if_false = graph()->NewNode(common()->IfFalse(), branch); graph()->NewNode(
Node* vfalse = graph()->NewNode( machine()->Word32And(),
machine()->Word32Equal(), jsgraph()->Uint32Constant(1 << Map::kIsUndetectable),
graph()->NewNode( LoadMapBitField(LoadHeapObjectMap(input, graph()->start()))),
machine()->Word32Equal(), jsgraph()->Int32Constant(0)));
graph()->NewNode(machine()->Word32And(), node->AppendInput(graph()->zone(), jsgraph()->Int32Constant(0));
jsgraph()->Uint32Constant(1 << Map::kIsUndetectable), NodeProperties::ChangeOp(node, machine()->Word32Equal());
LoadMapBitField(LoadHeapObjectMap(input, if_false))), } else {
jsgraph()->Int32Constant(0)), Node* check = IsSmi(input);
jsgraph()->Int32Constant(0)); Node* branch =
Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); graph()->NewNode(common()->Branch(), check, graph()->start());
node->ReplaceInput(0, vtrue); Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
node->AppendInput(graph()->zone(), vfalse); Node* vtrue = jsgraph()->Int32Constant(0);
node->AppendInput(graph()->zone(), control); Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); Node* vfalse = graph()->NewNode(
machine()->Word32Equal(),
graph()->NewNode(
machine()->Word32Equal(),
graph()->NewNode(
machine()->Word32And(),
jsgraph()->Uint32Constant(1 << Map::kIsUndetectable),
LoadMapBitField(LoadHeapObjectMap(input, if_false))),
jsgraph()->Int32Constant(0)),
jsgraph()->Int32Constant(0));
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); return Changed(node);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment