Remove two ReconfigureX methods on Map
.. and inline them into callsites. These were thin wrappers around MapUpdater methods. This is part of moving towards MapUpdater as the bottleneck for map updates. Bug: v8:7790 Change-Id: Ie79ee063b83892d3c233581832361295aeb8e90f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2807600 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Auto-Submit: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/master@{#73804}
This commit is contained in:
parent
064ca18ca2
commit
089218a87a
@ -29,6 +29,7 @@
|
||||
#include "src/objects/js-array-buffer-inl.h"
|
||||
#include "src/objects/js-array-inl.h"
|
||||
#include "src/objects/lookup.h"
|
||||
#include "src/objects/map-updater.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#ifdef V8_INTL_SUPPORT
|
||||
#include "src/objects/js-break-iterator.h"
|
||||
@ -3151,6 +3152,7 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
|
||||
DCHECK(object->map().GetInObjectProperties() == map->GetInObjectProperties());
|
||||
ElementsKind obj_kind = object->map().elements_kind();
|
||||
ElementsKind map_kind = map->elements_kind();
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
if (map_kind != obj_kind) {
|
||||
ElementsKind to_kind = GetMoreGeneralElementsKind(map_kind, obj_kind);
|
||||
if (IsDictionaryElementsKind(obj_kind)) {
|
||||
@ -3161,7 +3163,7 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
|
||||
} else {
|
||||
TransitionElementsKind(object, to_kind);
|
||||
}
|
||||
map = Map::ReconfigureElementsKind(object->GetIsolate(), map, to_kind);
|
||||
map = MapUpdater{isolate, map}.ReconfigureElementsKind(to_kind);
|
||||
}
|
||||
int number_of_fields = map->NumberOfFields();
|
||||
int inobject = map->GetInObjectProperties();
|
||||
@ -3171,7 +3173,6 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
|
||||
// Allocate mutable double boxes if necessary. It is always necessary if we
|
||||
// have external properties, but is also necessary if we only have inobject
|
||||
// properties but don't unbox double fields.
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
|
||||
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
|
||||
isolate);
|
||||
|
@ -47,7 +47,7 @@ namespace internal {
|
||||
// - Otherwise, invalidate the outdated transition target from |target_map|, and
|
||||
// replace its transition tree with a new branch for the updated descriptors.
|
||||
// - If the |old_map| had integrity level transition, create the new map for it.
|
||||
class MapUpdater {
|
||||
class V8_EXPORT_PRIVATE MapUpdater {
|
||||
public:
|
||||
MapUpdater(Isolate* isolate, Handle<Map> old_map);
|
||||
|
||||
|
@ -806,29 +806,6 @@ void Map::GeneralizeField(Isolate* isolate, Handle<Map> map,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(ishell): remove.
|
||||
// static
|
||||
Handle<Map> Map::ReconfigureProperty(Isolate* isolate, Handle<Map> map,
|
||||
InternalIndex modify_index,
|
||||
PropertyKind new_kind,
|
||||
PropertyAttributes new_attributes,
|
||||
Representation new_representation,
|
||||
Handle<FieldType> new_field_type) {
|
||||
DCHECK_EQ(kData, new_kind); // Only kData case is supported.
|
||||
MapUpdater mu(isolate, map);
|
||||
return mu.ReconfigureToDataField(modify_index, new_attributes,
|
||||
PropertyConstness::kConst,
|
||||
new_representation, new_field_type);
|
||||
}
|
||||
|
||||
// TODO(ishell): remove.
|
||||
// static
|
||||
Handle<Map> Map::ReconfigureElementsKind(Isolate* isolate, Handle<Map> map,
|
||||
ElementsKind new_elements_kind) {
|
||||
MapUpdater mu(isolate, map);
|
||||
return mu.ReconfigureElementsKind(new_elements_kind);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
Map SearchMigrationTarget(Isolate* isolate, Map old_map) {
|
||||
@ -1324,7 +1301,7 @@ Handle<Map> Map::TransitionElementsTo(Isolate* isolate, Handle<Map> map,
|
||||
return Map::CopyAsElementsKind(isolate, map, to_kind, OMIT_TRANSITION);
|
||||
}
|
||||
|
||||
return Map::ReconfigureElementsKind(isolate, map, to_kind);
|
||||
return MapUpdater{isolate, map}.ReconfigureElementsKind(to_kind);
|
||||
}
|
||||
|
||||
static Handle<Map> AddMissingElementsTransitions(Isolate* isolate,
|
||||
|
@ -512,14 +512,6 @@ class Map : public HeapObject {
|
||||
Isolate* isolate, InstanceType instance_type,
|
||||
Representation* representation, Handle<FieldType>* field_type);
|
||||
|
||||
V8_EXPORT_PRIVATE static Handle<Map> ReconfigureProperty(
|
||||
Isolate* isolate, Handle<Map> map, InternalIndex modify_index,
|
||||
PropertyKind new_kind, PropertyAttributes new_attributes,
|
||||
Representation new_representation, Handle<FieldType> new_field_type);
|
||||
|
||||
V8_EXPORT_PRIVATE static Handle<Map> ReconfigureElementsKind(
|
||||
Isolate* isolate, Handle<Map> map, ElementsKind new_elements_kind);
|
||||
|
||||
V8_EXPORT_PRIVATE static Handle<Map> PrepareForDataProperty(
|
||||
Isolate* isolate, Handle<Map> old_map, InternalIndex descriptor_number,
|
||||
PropertyConstness constness, Handle<Object> value);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "src/init/v8.h"
|
||||
#include "src/objects/field-type.h"
|
||||
#include "src/objects/heap-number-inl.h"
|
||||
#include "src/objects/map-updater.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/objects/property.h"
|
||||
#include "src/objects/struct-inl.h"
|
||||
@ -461,6 +462,23 @@ class Expectations {
|
||||
// branch.
|
||||
//
|
||||
|
||||
namespace {
|
||||
|
||||
Handle<Map> ReconfigureProperty(Isolate* isolate, Handle<Map> map,
|
||||
InternalIndex modify_index,
|
||||
PropertyKind new_kind,
|
||||
PropertyAttributes new_attributes,
|
||||
Representation new_representation,
|
||||
Handle<FieldType> new_field_type) {
|
||||
DCHECK_EQ(kData, new_kind); // Only kData case is supported.
|
||||
MapUpdater mu(isolate, map);
|
||||
return mu.ReconfigureToDataField(modify_index, new_attributes,
|
||||
PropertyConstness::kConst,
|
||||
new_representation, new_field_type);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(ReconfigureAccessorToNonExistingDataField) {
|
||||
CcTest::InitializeVM();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
@ -482,8 +500,8 @@ TEST(ReconfigureAccessorToNonExistingDataField) {
|
||||
CHECK(expectations.Check(*map));
|
||||
|
||||
InternalIndex first(0);
|
||||
Handle<Map> new_map = Map::ReconfigureProperty(
|
||||
isolate, map, first, kData, NONE, Representation::None(), none_type);
|
||||
Handle<Map> new_map = ReconfigureProperty(isolate, map, first, kData, NONE,
|
||||
Representation::None(), none_type);
|
||||
// |map| did not change except marked unstable.
|
||||
CHECK(!map->is_deprecated());
|
||||
CHECK(!map->is_stable());
|
||||
@ -497,8 +515,8 @@ TEST(ReconfigureAccessorToNonExistingDataField) {
|
||||
CHECK(new_map->is_stable());
|
||||
CHECK(expectations.Check(*new_map));
|
||||
|
||||
Handle<Map> new_map2 = Map::ReconfigureProperty(
|
||||
isolate, map, first, kData, NONE, Representation::None(), none_type);
|
||||
Handle<Map> new_map2 = ReconfigureProperty(isolate, map, first, kData, NONE,
|
||||
Representation::None(), none_type);
|
||||
CHECK_EQ(*new_map, *new_map2);
|
||||
|
||||
Handle<Object> value(Smi::zero(), isolate);
|
||||
@ -670,7 +688,7 @@ void TestGeneralizeField(int detach_property_at_index, int property_index,
|
||||
CHECK(expectations.Check(*map));
|
||||
|
||||
if (is_detached_map) {
|
||||
detach_point_map = Map::ReconfigureProperty(
|
||||
detach_point_map = ReconfigureProperty(
|
||||
isolate, detach_point_map, InternalIndex(detach_property_at_index),
|
||||
kData, NONE, Representation::Double(), any_type);
|
||||
expectations.SetDataField(detach_property_at_index,
|
||||
@ -703,8 +721,8 @@ void TestGeneralizeField(int detach_property_at_index, int property_index,
|
||||
|
||||
// Create new maps by generalizing representation of propX field.
|
||||
Handle<Map> new_map =
|
||||
Map::ReconfigureProperty(isolate, map, InternalIndex(property_index),
|
||||
kData, NONE, to.representation, to.type);
|
||||
ReconfigureProperty(isolate, map, InternalIndex(property_index), kData,
|
||||
NONE, to.representation, to.type);
|
||||
|
||||
expectations.SetDataField(property_index, expected.constness,
|
||||
expected.representation, expected.type);
|
||||
@ -978,8 +996,8 @@ TEST(GeneralizeFieldWithAccessorProperties) {
|
||||
continue;
|
||||
}
|
||||
Handle<Map> new_map =
|
||||
Map::ReconfigureProperty(isolate, map, InternalIndex(i), kData, NONE,
|
||||
Representation::Double(), any_type);
|
||||
ReconfigureProperty(isolate, map, InternalIndex(i), kData, NONE,
|
||||
Representation::Double(), any_type);
|
||||
maps[i] = new_map;
|
||||
|
||||
expectations.SetDataField(i, PropertyConstness::kMutable,
|
||||
@ -1798,7 +1816,7 @@ static void TestReconfigureElementsKind_GeneralizeFieldInPlace(
|
||||
// Reconfigure elements kinds of |map2|, which should generalize
|
||||
// representations in |map|.
|
||||
Handle<Map> new_map =
|
||||
Map::ReconfigureElementsKind(isolate, map2, PACKED_ELEMENTS);
|
||||
MapUpdater{isolate, map2}.ReconfigureElementsKind(PACKED_ELEMENTS);
|
||||
|
||||
// |map2| should be left unchanged but marked unstable.
|
||||
CHECK(!map2->is_stable());
|
||||
@ -2064,9 +2082,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
|
||||
map2 = handle(target, isolate);
|
||||
}
|
||||
|
||||
map2 = Map::ReconfigureProperty(isolate, map2, InternalIndex(kSplitProp),
|
||||
kData, NONE, Representation::Double(),
|
||||
any_type);
|
||||
map2 = ReconfigureProperty(isolate, map2, InternalIndex(kSplitProp), kData,
|
||||
NONE, Representation::Double(), any_type);
|
||||
expectations.SetDataField(kSplitProp, PropertyConstness::kMutable,
|
||||
Representation::Double(), any_type);
|
||||
|
||||
@ -2163,8 +2180,8 @@ static void TestGeneralizeFieldWithSpecialTransition(
|
||||
Handle<Map> maps[kPropCount];
|
||||
for (int i = 0; i < kPropCount; i++) {
|
||||
Handle<Map> new_map =
|
||||
Map::ReconfigureProperty(isolate, map, InternalIndex(i), kData, NONE,
|
||||
to.representation, to.type);
|
||||
ReconfigureProperty(isolate, map, InternalIndex(i), kData, NONE,
|
||||
to.representation, to.type);
|
||||
maps[i] = new_map;
|
||||
|
||||
expectations.SetDataField(i, expected.constness, expected.representation,
|
||||
|
Loading…
Reference in New Issue
Block a user