Commit efe39d2b authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

Move Map::ReconfigureExistingProperty to MapUpdater

This is part of moving towards MapUpdater as the bottleneck for map
updates.

Drive-by: Move helpers.
Drive-by: Use a plain std::queue instead of a ZoneQueue in
UpdateFieldType.

Bug: v8:7790
Change-Id: Iff80a6e9bf3390a010305f7998d6f6dad2bce09f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2807602
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73851}
parent 5a625a83
......@@ -10,6 +10,7 @@
#include "src/numbers/hash-seed-inl.h"
#include "src/objects/field-type.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/map-updater.h"
#include "src/objects/objects-inl.h"
#include "src/objects/property-descriptor.h"
#include "src/strings/char-predicates-inl.h"
......@@ -509,17 +510,18 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
}
Handle<FieldType> value_type =
value->OptimalType(isolate(), representation);
Map::GeneralizeField(isolate(), target, descriptor_index,
details.constness(), representation, value_type);
MapUpdater::GeneralizeField(isolate(), target, descriptor_index,
details.constness(), representation,
value_type);
} else if (expected_representation.IsHeapObject() &&
!target->instance_descriptors(isolate())
.GetFieldType(descriptor_index)
.NowContains(value)) {
Handle<FieldType> value_type =
value->OptimalType(isolate(), expected_representation);
Map::GeneralizeField(isolate(), target, descriptor_index,
details.constness(), expected_representation,
value_type);
MapUpdater::GeneralizeField(isolate(), target, descriptor_index,
details.constness(), expected_representation,
value_type);
} else if (expected_representation.IsDouble() && value->IsSmi()) {
new_mutable_double++;
}
......
......@@ -15,6 +15,7 @@
#include "src/objects/field-type.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/heap-number-inl.h"
#include "src/objects/map-updater.h"
#include "src/objects/ordered-hash-table.h"
#include "src/objects/struct-inl.h"
......@@ -471,7 +472,7 @@ void LookupIterator::ReconfigureDataProperty(Handle<Object> value,
Handle<Map> old_map(holder_obj->map(isolate_), isolate_);
// Force mutable to avoid changing constant value by reconfiguring
// kData -> kAccessor -> kData.
Handle<Map> new_map = Map::ReconfigureExistingProperty(
Handle<Map> new_map = MapUpdater::ReconfigureExistingProperty(
isolate_, old_map, descriptor_number(), i::kData, attributes,
PropertyConstness::kMutable);
if (!new_map->is_dictionary_map()) {
......
......@@ -117,11 +117,18 @@ DEF_GETTER(Map, GetIndexedInterceptor, InterceptorInfo) {
return InterceptorInfo::cast(info.GetIndexedPropertyHandler(cage_base));
}
// static
bool Map::IsMostGeneralFieldType(Representation representation,
FieldType field_type) {
return !representation.IsHeapObject() || field_type.IsAny();
}
// static
bool Map::FieldTypeIsCleared(Representation rep, FieldType type) {
return type.IsNone() && rep.IsHeapObject();
}
// static
bool Map::CanHaveFastTransitionableElementsKind(InstanceType instance_type) {
return instance_type == JS_ARRAY_TYPE ||
instance_type == JS_PRIMITIVE_WRAPPER_TYPE ||
......
This diff is collapsed.
......@@ -67,6 +67,19 @@ class V8_EXPORT_PRIVATE MapUpdater {
// version and performs the steps 1-6.
Handle<Map> Update();
static Handle<Map> ReconfigureExistingProperty(Isolate* isolate,
Handle<Map> map,
InternalIndex descriptor,
PropertyKind kind,
PropertyAttributes attributes,
PropertyConstness constness);
static void GeneralizeField(Isolate* isolate, Handle<Map> map,
InternalIndex modify_index,
PropertyConstness new_constness,
Representation new_representation,
Handle<FieldType> new_field_type);
private:
enum State {
kInitialized,
......@@ -167,6 +180,16 @@ class V8_EXPORT_PRIVATE MapUpdater {
Handle<DescriptorArray> descriptors, InternalIndex descriptor,
PropertyLocation location, Representation representation);
// Update field type of the given descriptor to new representation and new
// type. The type must be prepared for storing in descriptor array:
// it must be either a simple type or a map wrapped in a weak cell.
static void UpdateFieldType(Isolate* isolate, Handle<Map> map,
InternalIndex descriptor_number,
Handle<Name> name,
PropertyConstness new_constness,
Representation new_representation,
const MaybeObjectHandle& new_wrapped_type);
void GeneralizeField(Handle<Map> map, InternalIndex modify_index,
PropertyConstness new_constness,
Representation new_representation,
......
This diff is collapsed.
......@@ -488,18 +488,11 @@ class Map : public HeapObject {
bool InstancesNeedRewriting(Map target, int target_number_of_fields,
int target_inobject, int target_unused,
int* old_number_of_fields) const;
V8_WARN_UNUSED_RESULT static Handle<FieldType> GeneralizeFieldType(
Representation rep1, Handle<FieldType> type1, Representation rep2,
Handle<FieldType> type2, Isolate* isolate);
static void GeneralizeField(Isolate* isolate, Handle<Map> map,
InternalIndex modify_index,
PropertyConstness new_constness,
Representation new_representation,
Handle<FieldType> new_field_type);
// Returns true if the |field_type| is the most general one for
// given |representation|.
static inline bool IsMostGeneralFieldType(Representation representation,
FieldType field_type);
static inline bool FieldTypeIsCleared(Representation rep, FieldType type);
// Generalizes representation and field_type if objects with given
// instance type can have fast elements that can be transitioned by
......@@ -715,10 +708,6 @@ class Map : public HeapObject {
Isolate* isolate, Handle<Map> map, Handle<Name> name,
InternalIndex descriptor, Handle<Object> getter, Handle<Object> setter,
PropertyAttributes attributes);
V8_EXPORT_PRIVATE static Handle<Map> ReconfigureExistingProperty(
Isolate* isolate, Handle<Map> map, InternalIndex descriptor,
PropertyKind kind, PropertyAttributes attributes,
PropertyConstness constness);
inline void AppendDescriptor(Isolate* isolate, Descriptor* desc);
......@@ -911,28 +900,6 @@ class Map : public HeapObject {
void ReplaceDescriptors(Isolate* isolate, DescriptorArray new_descriptors);
// Update field type of the given descriptor to new representation and new
// type. The type must be prepared for storing in descriptor array:
// it must be either a simple type or a map wrapped in a weak cell.
void UpdateFieldType(Isolate* isolate, InternalIndex descriptor_number,
Handle<Name> name, PropertyConstness new_constness,
Representation new_representation,
const MaybeObjectHandle& new_wrapped_type);
// TODO(ishell): Move to MapUpdater.
void PrintReconfiguration(Isolate* isolate, FILE* file,
InternalIndex modify_index, PropertyKind kind,
PropertyAttributes attributes);
// TODO(ishell): Move to MapUpdater.
void PrintGeneralization(
Isolate* isolate, FILE* file, const char* reason,
InternalIndex modify_index, int split, int descriptors,
bool constant_to_field, Representation old_representation,
Representation new_representation, PropertyConstness old_constness,
PropertyConstness new_constness, MaybeHandle<FieldType> old_field_type,
MaybeHandle<Object> old_value, MaybeHandle<FieldType> new_field_type,
MaybeHandle<Object> new_value);
// This is the equivalent of IsMap() but avoids reading the instance type so
// it can be used concurrently without acquire load.
V8_INLINE bool ConcurrentIsMap(PtrComprCageBase cage_base,
......
......@@ -22,6 +22,7 @@
#include "src/objects/js-array-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/map-updater.h"
#include "src/objects/objects-inl.h"
#include "src/objects/objects.h"
#include "src/objects/oddball-inl.h"
......@@ -2101,9 +2102,9 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
.NowContains(value)) {
Handle<FieldType> value_type =
value->OptimalType(isolate_, expected_representation);
Map::GeneralizeField(isolate_, target, descriptor,
details.constness(), expected_representation,
value_type);
MapUpdater::GeneralizeField(isolate_, target, descriptor,
details.constness(),
expected_representation, value_type);
}
DCHECK(target->instance_descriptors(isolate_)
.GetFieldType(descriptor)
......
......@@ -16,6 +16,7 @@
#include "src/logging/counters.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/map-updater.h"
#include "src/objects/property-descriptor-object.h"
#include "src/objects/property-descriptor.h"
#include "src/objects/swiss-name-dictionary-inl.h"
......@@ -139,9 +140,9 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver,
details.location() == kField) {
Handle<FieldType> field_type(descriptors->GetFieldType(descriptor),
isolate);
Map::GeneralizeField(isolate, receiver_map, descriptor,
PropertyConstness::kMutable, details.representation(),
field_type);
MapUpdater::GeneralizeField(isolate, receiver_map, descriptor,
PropertyConstness::kMutable,
details.representation(), field_type);
DCHECK_EQ(PropertyConstness::kMutable,
descriptors->GetDetails(descriptor).constness());
}
......
......@@ -1113,9 +1113,9 @@ void TestReconfigureDataFieldAttribute_GeneralizeField(
// Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which
// should generalize representations in |map1|.
Handle<Map> new_map =
Map::ReconfigureExistingProperty(isolate, map2, InternalIndex(kSplitProp),
kData, NONE, PropertyConstness::kConst);
Handle<Map> new_map = MapUpdater::ReconfigureExistingProperty(
isolate, map2, InternalIndex(kSplitProp), kData, NONE,
PropertyConstness::kConst);
// |map2| should be mosly left unchanged but marked unstable and if the
// source property was constant it should also be transitioned to kMutable.
......@@ -1510,9 +1510,9 @@ static void TestReconfigureProperty_CustomPropertyAfterTargetMap(
// Reconfigure attributes of property |kSplitProp| of |map2| to NONE, which
// should generalize representations in |map1|.
Handle<Map> new_map =
Map::ReconfigureExistingProperty(isolate, map2, InternalIndex(kSplitProp),
kData, NONE, PropertyConstness::kConst);
Handle<Map> new_map = MapUpdater::ReconfigureExistingProperty(
isolate, map2, InternalIndex(kSplitProp), kData, NONE,
PropertyConstness::kConst);
// |map2| should be left unchanged but marked unstable.
CHECK(!map2->is_stable());
......@@ -2558,9 +2558,9 @@ struct ReconfigureAsDataPropertyOperator {
expectations->SetDataField(descriptor_.as_int(),
PropertyConstness::kMutable, representation_,
heap_type_);
return Map::ReconfigureExistingProperty(isolate, map, descriptor_, kData,
attributes_,
PropertyConstness::kConst);
return MapUpdater::ReconfigureExistingProperty(isolate, map, descriptor_,
kData, attributes_,
PropertyConstness::kConst);
}
};
......@@ -2576,9 +2576,9 @@ struct ReconfigureAsAccessorPropertyOperator {
Handle<Map> DoTransition(Isolate* isolate, Expectations* expectations,
Handle<Map> map) {
expectations->SetAccessorField(descriptor_.as_int());
return Map::ReconfigureExistingProperty(isolate, map, descriptor_,
kAccessor, attributes_,
PropertyConstness::kConst);
return MapUpdater::ReconfigureExistingProperty(isolate, map, descriptor_,
kAccessor, attributes_,
PropertyConstness::kConst);
}
};
......
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