Commit bdc95055 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Avoid some unnecessary write barriers.

Use the type specified for StoreField and StoreElement to check whether
we are storing a TaggedSigned value, and skip the write barrier for the
write completely in that case.  Also make sure to set that field type
appropriately for JSGlobalObjectSpecialization.

R=jarin@chromium.org
BUG=v8:4470
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#31772}
parent 6471fbf7
...@@ -195,7 +195,9 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { ...@@ -195,7 +195,9 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
if (!(flags() & kDeoptimizationEnabled)) return NoChange(); if (!(flags() & kDeoptimizationEnabled)) return NoChange();
dependencies()->AssumePropertyCell(property_cell); dependencies()->AssumePropertyCell(property_cell);
Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
Type* property_cell_value_type = Type::TaggedSigned();
if (property_cell_value->IsHeapObject()) { if (property_cell_value->IsHeapObject()) {
// Deoptimize if the {value} is a Smi.
Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse),
check, control); check, control);
Node* if_true = graph()->NewNode(common()->IfTrue(), branch); Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
...@@ -204,7 +206,9 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { ...@@ -204,7 +206,9 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
// TODO(bmeurer): This should be on the AdvancedReducer somehow. // TODO(bmeurer): This should be on the AdvancedReducer somehow.
NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
control = graph()->NewNode(common()->IfFalse(), branch); control = graph()->NewNode(common()->IfFalse(), branch);
Node* value_map =
// Load the {value} map check against the {property_cell} map.
Node* value_map = effect =
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
value, effect, control); value, effect, control);
Handle<Map> property_cell_value_map( Handle<Map> property_cell_value_map(
...@@ -212,6 +216,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { ...@@ -212,6 +216,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
check = graph()->NewNode( check = graph()->NewNode(
simplified()->ReferenceEqual(Type::Any()), value_map, simplified()->ReferenceEqual(Type::Any()), value_map,
jsgraph()->HeapConstant(property_cell_value_map)); jsgraph()->HeapConstant(property_cell_value_map));
property_cell_value_type = Type::TaggedPointer();
} }
Node* branch = Node* branch =
graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
...@@ -222,7 +227,8 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { ...@@ -222,7 +227,8 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); NodeProperties::MergeControlToEnd(graph(), common(), deoptimize);
control = graph()->NewNode(common()->IfTrue(), branch); control = graph()->NewNode(common()->IfTrue(), branch);
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->StoreField(AccessBuilder::ForPropertyCellValue()), simplified()->StoreField(
AccessBuilder::ForPropertyCellValue(property_cell_value_type)),
jsgraph()->HeapConstant(property_cell), value, effect, control); jsgraph()->HeapConstant(property_cell), value, effect, control);
break; break;
} }
......
...@@ -1171,8 +1171,9 @@ namespace { ...@@ -1171,8 +1171,9 @@ namespace {
WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
MachineType representation, MachineType representation,
Type* type) { Type* field_type, Type* input_type) {
if (type->Is(Type::TaggedSigned())) { if (field_type->Is(Type::TaggedSigned()) ||
input_type->Is(Type::TaggedSigned())) {
// Write barriers are only for writes of heap objects. // Write barriers are only for writes of heap objects.
return kNoWriteBarrier; return kNoWriteBarrier;
} }
...@@ -1229,8 +1230,8 @@ void SimplifiedLowering::DoLoadField(Node* node) { ...@@ -1229,8 +1230,8 @@ void SimplifiedLowering::DoLoadField(Node* node) {
void SimplifiedLowering::DoStoreField(Node* node) { void SimplifiedLowering::DoStoreField(Node* node) {
const FieldAccess& access = FieldAccessOf(node->op()); const FieldAccess& access = FieldAccessOf(node->op());
Type* type = NodeProperties::GetType(node->InputAt(1)); Type* type = NodeProperties::GetType(node->InputAt(1));
WriteBarrierKind kind = WriteBarrierKind kind = ComputeWriteBarrierKind(
ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type, type); access.base_is_tagged, access.machine_type, access.type, type);
Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag());
node->InsertInput(graph()->zone(), 1, offset); node->InsertInput(graph()->zone(), 1, offset);
NodeProperties::ChangeOp( NodeProperties::ChangeOp(
...@@ -1338,10 +1339,11 @@ void SimplifiedLowering::DoStoreElement(Node* node) { ...@@ -1338,10 +1339,11 @@ void SimplifiedLowering::DoStoreElement(Node* node) {
Type* type = NodeProperties::GetType(node->InputAt(2)); Type* type = NodeProperties::GetType(node->InputAt(2));
node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
NodeProperties::ChangeOp( NodeProperties::ChangeOp(
node, machine()->Store(StoreRepresentation( node,
access.machine_type, machine()->Store(StoreRepresentation(
ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type,
access.machine_type, type)))); ComputeWriteBarrierKind(access.base_is_tagged, access.machine_type,
access.type, type))));
} }
......
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