summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/js-global-object-specialization.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/js-global-object-specialization.cc')
-rw-r--r--deps/v8/src/compiler/js-global-object-specialization.cc62
1 files changed, 45 insertions, 17 deletions
diff --git a/deps/v8/src/compiler/js-global-object-specialization.cc b/deps/v8/src/compiler/js-global-object-specialization.cc
index 2b4bf1c019..10130f4039 100644
--- a/deps/v8/src/compiler/js-global-object-specialization.cc
+++ b/deps/v8/src/compiler/js-global-object-specialization.cc
@@ -11,9 +11,9 @@
#include "src/compiler/js-operator.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
+#include "src/compiler/type-cache.h"
#include "src/lookup.h"
#include "src/objects-inl.h"
-#include "src/type-cache.h"
namespace v8 {
namespace internal {
@@ -48,6 +48,23 @@ Reduction JSGlobalObjectSpecialization::Reduce(Node* node) {
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) {
DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode());
Handle<Name> name = LoadGlobalParametersOf(node->op()).name();
@@ -104,24 +121,31 @@ Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
}
// 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) {
// Compute proper type based on the current value in the cell.
if (property_cell_value->IsSmi()) {
property_cell_value_type = type_cache_.kSmi;
+ representation = MachineRepresentation::kTaggedSigned;
} 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;
+ representation = MachineRepresentation::kTaggedPointer;
} else {
+ // TODO(turbofan): Track the property_cell_value_map on the FieldAccess
+ // below and use it in LoadElimination to eliminate map checks.
Handle<Map> property_cell_value_map(
Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
- property_cell_value_type =
- Type::Class(property_cell_value_map, graph()->zone());
+ property_cell_value_type = Type::For(property_cell_value_map);
+ representation = MachineRepresentation::kTaggedPointer;
}
}
- Node* value = effect = graph()->NewNode(
- simplified()->LoadField(
- AccessBuilder::ForPropertyCellValue(property_cell_value_type)),
- jsgraph()->HeapConstant(property_cell), effect, control);
+ Node* value = effect =
+ graph()->NewNode(simplified()->LoadField(ForPropertyCellValue(
+ representation, property_cell_value_type, name)),
+ jsgraph()->HeapConstant(property_cell), effect, control);
ReplaceWithValue(node, value, effect, control);
return Replace(value);
}
@@ -180,6 +204,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
// values' type doesn't match the type of the previous value in the cell.
dependencies()->AssumePropertyCell(property_cell);
Type* property_cell_value_type;
+ MachineRepresentation representation = MachineRepresentation::kTagged;
if (property_cell_value->IsHeapObject()) {
// We cannot do anything if the {property_cell_value}s map is no
// longer stable.
@@ -189,23 +214,25 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
dependencies()->AssumeMapStable(property_cell_value_map);
// Check that the {value} is a HeapObject.
- value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(),
+ value = effect = graph()->NewNode(simplified()->CheckHeapObject(),
value, effect, control);
// Check {value} map agains the {property_cell} map.
effect = graph()->NewNode(
simplified()->CheckMaps(1), value,
jsgraph()->HeapConstant(property_cell_value_map), effect, control);
- property_cell_value_type = Type::TaggedPointer();
+ property_cell_value_type = Type::OtherInternal();
+ representation = MachineRepresentation::kTaggedPointer;
} else {
// Check that the {value} is a Smi.
- value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(),
- value, effect, control);
- property_cell_value_type = Type::TaggedSigned();
+ value = effect =
+ graph()->NewNode(simplified()->CheckSmi(), value, effect, control);
+ property_cell_value_type = Type::SignedSmall();
+ representation = MachineRepresentation::kTaggedSigned;
}
effect = graph()->NewNode(
- simplified()->StoreField(
- AccessBuilder::ForPropertyCellValue(property_cell_value_type)),
+ simplified()->StoreField(ForPropertyCellValue(
+ representation, property_cell_value_type, name)),
jsgraph()->HeapConstant(property_cell), value, effect, control);
break;
}
@@ -219,7 +246,8 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
dependencies()->AssumePropertyCell(property_cell);
}
effect = graph()->NewNode(
- simplified()->StoreField(AccessBuilder::ForPropertyCellValue()),
+ simplified()->StoreField(ForPropertyCellValue(
+ MachineRepresentation::kTagged, Type::NonInternal(), name)),
jsgraph()->HeapConstant(property_cell), value, effect, control);
break;
}
@@ -251,7 +279,7 @@ bool JSGlobalObjectSpecialization::LookupInScriptContextTable(
Handle<Context> script_context = ScriptContextTable::GetContext(
script_context_table, lookup_result.context_index);
result->context = script_context;
- result->immutable = IsImmutableVariableMode(lookup_result.mode);
+ result->immutable = lookup_result.mode == CONST;
result->index = lookup_result.slot_index;
return true;
}