Commit e9c93639 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Brokerize more pieces of JSNativeContextSpecialization.

Bug: v8:7790
Change-Id: I8cc88aadaaacca4cc6b87a6f5bead9129b8dfa14
Reviewed-on: https://chromium-review.googlesource.com/c/1394550Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58583}
parent 2681ec65
...@@ -647,6 +647,8 @@ class MapData : public HeapObjectData { ...@@ -647,6 +647,8 @@ class MapData : public HeapObjectData {
return in_object_properties_; return in_object_properties_;
} }
int constructor_function_index() const { return constructor_function_index_; } int constructor_function_index() const { return constructor_function_index_; }
int NextFreePropertyIndex() const { return next_free_property_index_; }
int UnusedPropertyFields() const { return unused_property_fields_; }
// Extra information. // Extra information.
...@@ -687,6 +689,8 @@ class MapData : public HeapObjectData { ...@@ -687,6 +689,8 @@ class MapData : public HeapObjectData {
int const in_object_properties_start_in_words_; int const in_object_properties_start_in_words_;
int const in_object_properties_; int const in_object_properties_;
int const constructor_function_index_; int const constructor_function_index_;
int const next_free_property_index_;
int const unused_property_fields_;
bool serialized_elements_kind_generalizations_ = false; bool serialized_elements_kind_generalizations_ = false;
ZoneVector<MapData*> elements_kind_generalizations_; ZoneVector<MapData*> elements_kind_generalizations_;
...@@ -767,6 +771,8 @@ MapData::MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object) ...@@ -767,6 +771,8 @@ MapData::MapData(JSHeapBroker* broker, ObjectData** storage, Handle<Map> object)
constructor_function_index_(object->IsPrimitiveMap() constructor_function_index_(object->IsPrimitiveMap()
? object->GetConstructorFunctionIndex() ? object->GetConstructorFunctionIndex()
: Map::kNoConstructorFunctionIndex), : Map::kNoConstructorFunctionIndex),
next_free_property_index_(object->NextFreePropertyIndex()),
unused_property_fields_(object->UnusedPropertyFields()),
elements_kind_generalizations_(broker->zone()) {} elements_kind_generalizations_(broker->zone()) {}
JSFunctionData::JSFunctionData(JSHeapBroker* broker, ObjectData** storage, JSFunctionData::JSFunctionData(JSHeapBroker* broker, ObjectData** storage,
...@@ -2155,6 +2161,8 @@ BIMODAL_ACCESSOR_B(Map, bit_field, is_callable, Map::IsCallableBit) ...@@ -2155,6 +2161,8 @@ BIMODAL_ACCESSOR_B(Map, bit_field, is_callable, Map::IsCallableBit)
BIMODAL_ACCESSOR_B(Map, bit_field, is_constructor, Map::IsConstructorBit) BIMODAL_ACCESSOR_B(Map, bit_field, is_constructor, Map::IsConstructorBit)
BIMODAL_ACCESSOR_B(Map, bit_field, is_undetectable, Map::IsUndetectableBit) BIMODAL_ACCESSOR_B(Map, bit_field, is_undetectable, Map::IsUndetectableBit)
BIMODAL_ACCESSOR_C(Map, int, instance_size) BIMODAL_ACCESSOR_C(Map, int, instance_size)
BIMODAL_ACCESSOR_C(Map, int, NextFreePropertyIndex)
BIMODAL_ACCESSOR_C(Map, int, UnusedPropertyFields)
BIMODAL_ACCESSOR(Map, Object, prototype) BIMODAL_ACCESSOR(Map, Object, prototype)
BIMODAL_ACCESSOR_C(Map, InstanceType, instance_type) BIMODAL_ACCESSOR_C(Map, InstanceType, instance_type)
BIMODAL_ACCESSOR(Map, Object, GetConstructor) BIMODAL_ACCESSOR(Map, Object, GetConstructor)
......
...@@ -415,6 +415,8 @@ class MapRef : public HeapObjectRef { ...@@ -415,6 +415,8 @@ class MapRef : public HeapObjectRef {
int NumberOfOwnDescriptors() const; int NumberOfOwnDescriptors() const;
int GetInObjectPropertyOffset(int index) const; int GetInObjectPropertyOffset(int index) const;
int constructor_function_index() const; int constructor_function_index() const;
int NextFreePropertyIndex() const;
int UnusedPropertyFields() const;
ElementsKind elements_kind() const; ElementsKind elements_kind() const;
bool is_stable() const; bool is_stable() const;
bool is_extensible() const; bool is_extensible() const;
......
...@@ -1344,15 +1344,16 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) { ...@@ -1344,15 +1344,16 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode()); DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode());
NamedAccess const& p = NamedAccessOf(node->op()); NamedAccess const& p = NamedAccessOf(node->op());
Node* const receiver = NodeProperties::GetValueInput(node, 0); Node* const receiver = NodeProperties::GetValueInput(node, 0);
Node* const value = jsgraph()->Dead();
// Check if we have a constant receiver. // Check if we have a constant receiver.
HeapObjectMatcher m(receiver); HeapObjectMatcher m(receiver);
if (m.HasValue()) { if (m.HasValue()) {
if (m.Value()->IsJSFunction() && ObjectRef object = m.Ref(broker());
p.name().is_identical_to(factory()->prototype_string())) { NameRef name(broker(), p.name());
if (object.IsJSFunction() &&
name.equals(ObjectRef(broker(), factory()->prototype_string()))) {
// Optimize "prototype" property of functions. // Optimize "prototype" property of functions.
JSFunctionRef function = m.Ref(broker()).AsJSFunction(); JSFunctionRef function = object.AsJSFunction();
// TODO(neis): This is a temporary hack needed because the copy reducer // TODO(neis): This is a temporary hack needed because the copy reducer
// runs only after this pass. // runs only after this pass.
function.Serialize(); function.Serialize();
...@@ -1366,11 +1367,10 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) { ...@@ -1366,11 +1367,10 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) {
Node* value = jsgraph()->Constant(prototype); Node* value = jsgraph()->Constant(prototype);
ReplaceWithValue(node, value); ReplaceWithValue(node, value);
return Replace(value); return Replace(value);
} else if (m.Value()->IsString() && } else if (object.IsString() &&
p.name().is_identical_to(factory()->length_string())) { name.equals(ObjectRef(broker(), factory()->length_string()))) {
// Constant-fold "length" property on constant strings. // Constant-fold "length" property on constant strings.
Handle<String> string = Handle<String>::cast(m.Value()); Node* value = jsgraph()->Constant(object.AsString().length());
Node* value = jsgraph()->Constant(string->length());
ReplaceWithValue(node, value); ReplaceWithValue(node, value);
return Replace(value); return Replace(value);
} }
...@@ -1381,7 +1381,7 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) { ...@@ -1381,7 +1381,7 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) {
FeedbackNexus nexus(p.feedback().vector(), p.feedback().slot()); FeedbackNexus nexus(p.feedback().vector(), p.feedback().slot());
// Try to lower the named access based on the {receiver_maps}. // Try to lower the named access based on the {receiver_maps}.
return ReduceNamedAccessFromNexus(node, value, nexus, p.name(), return ReduceNamedAccessFromNexus(node, jsgraph()->Dead(), nexus, p.name(),
AccessMode::kLoad); AccessMode::kLoad);
} }
...@@ -2285,7 +2285,7 @@ JSNativeContextSpecialization::BuildPropertyStore( ...@@ -2285,7 +2285,7 @@ JSNativeContextSpecialization::BuildPropertyStore(
// Reallocate the properties {storage}. // Reallocate the properties {storage}.
storage = effect = BuildExtendPropertiesBackingStore( storage = effect = BuildExtendPropertiesBackingStore(
original_map, storage, effect, control); MapRef(broker(), original_map), storage, effect, control);
// Perform the actual store. // Perform the actual store.
effect = graph()->NewNode(simplified()->StoreField(field_access), effect = graph()->NewNode(simplified()->StoreField(field_access),
...@@ -3014,7 +3014,7 @@ Node* JSNativeContextSpecialization::BuildIndexedStringLoad( ...@@ -3014,7 +3014,7 @@ Node* JSNativeContextSpecialization::BuildIndexedStringLoad(
} }
Node* JSNativeContextSpecialization::BuildExtendPropertiesBackingStore( Node* JSNativeContextSpecialization::BuildExtendPropertiesBackingStore(
Handle<Map> map, Node* properties, Node* effect, Node* control) { const MapRef& map, Node* properties, Node* effect, Node* control) {
// TODO(bmeurer/jkummerow): Property deletions can undo map transitions // TODO(bmeurer/jkummerow): Property deletions can undo map transitions
// while keeping the backing store around, meaning that even though the // while keeping the backing store around, meaning that even though the
// map might believe that objects have no unused property fields, there // map might believe that objects have no unused property fields, there
...@@ -3024,9 +3024,9 @@ Node* JSNativeContextSpecialization::BuildExtendPropertiesBackingStore( ...@@ -3024,9 +3024,9 @@ Node* JSNativeContextSpecialization::BuildExtendPropertiesBackingStore(
// difficult for escape analysis to get rid of the backing stores used // difficult for escape analysis to get rid of the backing stores used
// for intermediate states of chains of property additions. That makes // for intermediate states of chains of property additions. That makes
// it unclear what the best approach is here. // it unclear what the best approach is here.
DCHECK_EQ(0, map->UnusedPropertyFields()); DCHECK_EQ(0, map.UnusedPropertyFields());
// Compute the length of the old {properties} and the new properties. // Compute the length of the old {properties} and the new properties.
int length = map->NextFreePropertyIndex() - map->GetInObjectProperties(); int length = map.NextFreePropertyIndex() - map.GetInObjectProperties();
int new_length = length + JSObject::kFieldsAdded; int new_length = length + JSObject::kFieldsAdded;
// Collect the field values from the {properties}. // Collect the field values from the {properties}.
ZoneVector<Node*> values(zone()); ZoneVector<Node*> values(zone());
......
...@@ -186,7 +186,7 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final ...@@ -186,7 +186,7 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final
KeyedAccessLoadMode load_mode); KeyedAccessLoadMode load_mode);
// Construct appropriate subgraph to extend properties backing store. // Construct appropriate subgraph to extend properties backing store.
Node* BuildExtendPropertiesBackingStore(Handle<Map> map, Node* properties, Node* BuildExtendPropertiesBackingStore(const MapRef& map, Node* properties,
Node* effect, Node* control); Node* effect, Node* control);
// Construct appropriate subgraph to check that the {value} matches // Construct appropriate subgraph to check that the {value} matches
......
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