Commit 7b2a211b authored by mvstanton's avatar mvstanton Committed by Commit bot

[turbofan] Use MachineRepresentation for PropertyCell access.

And not the Representation dimension of Type*.

BUG=

Review-Url: https://codereview.chromium.org/2312703002
Cr-Commit-Position: refs/heads/master@{#39179}
parent 9b53e7cb
...@@ -609,29 +609,6 @@ FieldAccess AccessBuilder::ForContextSlot(size_t index) { ...@@ -609,29 +609,6 @@ FieldAccess AccessBuilder::ForContextSlot(size_t index) {
return access; return access;
} }
// static
FieldAccess AccessBuilder::ForPropertyCellValue() {
return ForPropertyCellValue(Type::Tagged());
}
// static
FieldAccess AccessBuilder::ForPropertyCellValue(Type* type) {
// Extract representation dimension of {type} into MachineType {r}.
MachineType r = MachineType::AnyTagged();
WriteBarrierKind w = kFullWriteBarrier;
if (type->Is(Type::TaggedSigned())) {
r = MachineType::TaggedSigned();
w = kNoWriteBarrier;
} else if (type->Is(Type::TaggedPointer())) {
r = MachineType::TaggedPointer();
}
FieldAccess access = {
kTaggedBase, PropertyCell::kValueOffset, Handle<Name>(), type, r, w};
return access;
}
// static // static
FieldAccess AccessBuilder::ForContextExtensionScopeInfo() { FieldAccess AccessBuilder::ForContextExtensionScopeInfo() {
FieldAccess access = {kTaggedBase, FieldAccess access = {kTaggedBase,
......
...@@ -195,10 +195,6 @@ class AccessBuilder final : public AllStatic { ...@@ -195,10 +195,6 @@ class AccessBuilder final : public AllStatic {
// Provides access to Context slots. // Provides access to Context slots.
static FieldAccess ForContextSlot(size_t index); static FieldAccess ForContextSlot(size_t index);
// Provides access to PropertyCell::value() field.
static FieldAccess ForPropertyCellValue();
static FieldAccess ForPropertyCellValue(Type* type);
// Provides access to ContextExtension fields. // Provides access to ContextExtension fields.
static FieldAccess ForContextExtensionScopeInfo(); static FieldAccess ForContextExtensionScopeInfo();
static FieldAccess ForContextExtensionExtension(); static FieldAccess ForContextExtensionExtension();
......
...@@ -48,6 +48,23 @@ Reduction JSGlobalObjectSpecialization::Reduce(Node* node) { ...@@ -48,6 +48,23 @@ Reduction JSGlobalObjectSpecialization::Reduce(Node* node) {
return NoChange(); return NoChange();
} }
namespace {
FieldAccess ForPropertyCellValue(MachineRepresentation representation,
Type* type, Handle<Name> name) {
WriteBarrierKind kind = kFullWriteBarrier;
if (representation == MachineRepresentation::kTaggedSigned) {
kind = kNoWriteBarrier;
} else if (representation == MachineRepresentation::kTaggedPointer) {
kind = kPointerWriteBarrier;
}
MachineType r = MachineType::TypeForRepresentation(representation);
FieldAccess access = {kTaggedBase, PropertyCell::kValueOffset, name, type, r,
kind};
return access;
}
} // namespace
Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) { Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode()); DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode());
Handle<Name> name = LoadGlobalParametersOf(node->op()).name(); Handle<Name> name = LoadGlobalParametersOf(node->op()).name();
...@@ -104,25 +121,31 @@ Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) { ...@@ -104,25 +121,31 @@ Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
} }
// Load from constant type cell can benefit from type feedback. // Load from constant type cell can benefit from type feedback.
Type* property_cell_value_type = Type::Tagged(); Type* property_cell_value_type = Type::NonInternal();
MachineRepresentation representation = MachineRepresentation::kTagged;
if (property_details.cell_type() == PropertyCellType::kConstantType) { if (property_details.cell_type() == PropertyCellType::kConstantType) {
// Compute proper type based on the current value in the cell. // Compute proper type based on the current value in the cell.
if (property_cell_value->IsSmi()) { if (property_cell_value->IsSmi()) {
property_cell_value_type = type_cache_.kSmi; property_cell_value_type = type_cache_.kSmi;
representation = MachineRepresentation::kTaggedSigned;
} else if (property_cell_value->IsNumber()) { } else if (property_cell_value->IsNumber()) {
// TODO(mvstanton): Remove kHeapNumber from type cache, it's just
// Type::Number().
property_cell_value_type = type_cache_.kHeapNumber; property_cell_value_type = type_cache_.kHeapNumber;
representation = MachineRepresentation::kTaggedPointer;
} else { } else {
// TODO(turbofan): Track the property_cell_value_map on the FieldAccess // TODO(turbofan): Track the property_cell_value_map on the FieldAccess
// below and use it in LoadElimination to eliminate map checks. // below and use it in LoadElimination to eliminate map checks.
Handle<Map> property_cell_value_map( Handle<Map> property_cell_value_map(
Handle<HeapObject>::cast(property_cell_value)->map(), isolate()); Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
property_cell_value_type = Type::For(property_cell_value_map); property_cell_value_type = Type::For(property_cell_value_map);
representation = MachineRepresentation::kTaggedPointer;
} }
} }
Node* value = effect = graph()->NewNode( Node* value = effect =
simplified()->LoadField( graph()->NewNode(simplified()->LoadField(ForPropertyCellValue(
AccessBuilder::ForPropertyCellValue(property_cell_value_type)), representation, property_cell_value_type, name)),
jsgraph()->HeapConstant(property_cell), effect, control); jsgraph()->HeapConstant(property_cell), effect, control);
ReplaceWithValue(node, value, effect, control); ReplaceWithValue(node, value, effect, control);
return Replace(value); return Replace(value);
} }
...@@ -181,6 +204,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { ...@@ -181,6 +204,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
// values' type doesn't match the type of the previous value in the cell. // values' type doesn't match the type of the previous value in the cell.
dependencies()->AssumePropertyCell(property_cell); dependencies()->AssumePropertyCell(property_cell);
Type* property_cell_value_type; Type* property_cell_value_type;
MachineRepresentation representation = MachineRepresentation::kTagged;
if (property_cell_value->IsHeapObject()) { if (property_cell_value->IsHeapObject()) {
// Check that the {value} is a HeapObject. // Check that the {value} is a HeapObject.
value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(), value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(),
...@@ -192,16 +216,18 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { ...@@ -192,16 +216,18 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->CheckMaps(1), value, simplified()->CheckMaps(1), value,
jsgraph()->HeapConstant(property_cell_value_map), effect, control); jsgraph()->HeapConstant(property_cell_value_map), effect, control);
property_cell_value_type = Type::TaggedPointer(); property_cell_value_type = Type::OtherInternal();
representation = MachineRepresentation::kTaggedPointer;
} else { } else {
// Check that the {value} is a Smi. // Check that the {value} is a Smi.
value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(), value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(),
value, effect, control); value, effect, control);
property_cell_value_type = Type::TaggedSigned(); property_cell_value_type = Type::SignedSmall();
representation = MachineRepresentation::kTaggedSigned;
} }
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->StoreField( simplified()->StoreField(ForPropertyCellValue(
AccessBuilder::ForPropertyCellValue(property_cell_value_type)), representation, property_cell_value_type, name)),
jsgraph()->HeapConstant(property_cell), value, effect, control); jsgraph()->HeapConstant(property_cell), value, effect, control);
break; break;
} }
...@@ -215,7 +241,8 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { ...@@ -215,7 +241,8 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
dependencies()->AssumePropertyCell(property_cell); dependencies()->AssumePropertyCell(property_cell);
} }
effect = graph()->NewNode( effect = graph()->NewNode(
simplified()->StoreField(AccessBuilder::ForPropertyCellValue()), simplified()->StoreField(ForPropertyCellValue(
MachineRepresentation::kTagged, Type::NonInternal(), name)),
jsgraph()->HeapConstant(property_cell), value, effect, control); jsgraph()->HeapConstant(property_cell), value, effect, control);
break; break;
} }
......
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