[cleanup] Remove atomic kRelaxed accessors in favour for non-atomic ones

If a method happens on the main thread and only on the main thread
(i.e. it will never be run on the background), it is safer to use
non-atomic accessors as TSAN will give warnings if we use them
improperly.

As a drive-by, pass the isolate as a parameter where it was readily
available as it saves us from getting the isolate from the object later
on.

Bug: v8:7790
Change-Id: Id9bdd69254edc60b0331a32fccf1479a95b7d286
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2732669
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73251}
This commit is contained in:
Santiago Aboy Solanes 2021-03-05 11:23:36 +00:00 committed by Commit Bot
parent 40f8b099b1
commit 73ea0da2d5
40 changed files with 241 additions and 278 deletions

View File

@ -4363,7 +4363,7 @@ MaybeLocal<Array> v8::Object::GetPropertyNames(
accumulator.GetKeys(static_cast<i::GetKeysConversion>(key_conversion));
DCHECK(self->map().EnumLength() == i::kInvalidEnumCacheSentinel ||
self->map().EnumLength() == 0 ||
self->map().instance_descriptors(kRelaxedLoad).enum_cache().keys() !=
self->map().instance_descriptors(isolate).enum_cache().keys() !=
*value);
auto result = isolate->factory()->NewJSArrayWithElements(value);
RETURN_ESCAPED(Utils::ToLocal(result));

View File

@ -403,7 +403,7 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo(
Handle<Map> receiver_map, Handle<Map> map, MaybeHandle<JSObject> holder,
InternalIndex descriptor, AccessMode access_mode) const {
DCHECK(descriptor.is_found());
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate()),
isolate());
PropertyDetails const details = descriptors->GetDetails(descriptor);
int index = descriptors->GetFieldIndex(descriptor);
@ -498,7 +498,7 @@ PropertyAccessInfo AccessInfoFactory::ComputeAccessorDescriptorAccessInfo(
MaybeHandle<JSObject> holder, InternalIndex descriptor,
AccessMode access_mode) const {
DCHECK(descriptor.is_found());
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate()),
isolate());
SLOW_DCHECK(descriptor == descriptors->Search(*name, *map));
if (map->instance_type() == JS_MODULE_NAMESPACE_TYPE) {

View File

@ -170,7 +170,7 @@ class FieldRepresentationDependency final : public CompilationDependency {
bool IsValid() const override {
DisallowGarbageCollection no_heap_allocation;
Handle<Map> owner = owner_.object();
return representation_.Equals(owner->instance_descriptors(kRelaxedLoad)
return representation_.Equals(owner->instance_descriptors(owner_.isolate())
.GetDetails(descriptor_)
.representation());
}
@ -209,8 +209,8 @@ class FieldTypeDependency final : public CompilationDependency {
DisallowGarbageCollection no_heap_allocation;
Handle<Map> owner = owner_.object();
Handle<Object> type = type_.object();
return *type ==
owner->instance_descriptors(kRelaxedLoad).GetFieldType(descriptor_);
return *type == owner->instance_descriptors(owner_.isolate())
.GetFieldType(descriptor_);
}
void Install(const MaybeObjectHandle& code) const override {
@ -238,7 +238,7 @@ class FieldConstnessDependency final : public CompilationDependency {
DisallowGarbageCollection no_heap_allocation;
Handle<Map> owner = owner_.object();
return PropertyConstness::kConst ==
owner->instance_descriptors(kRelaxedLoad)
owner->instance_descriptors(owner_.isolate())
.GetDetails(descriptor_)
.constness();
}

View File

@ -979,7 +979,7 @@ bool IsFastLiteralHelper(Handle<JSObject> boilerplate, int max_depth,
// Check the in-object properties.
Handle<DescriptorArray> descriptors(
boilerplate->map().instance_descriptors(kRelaxedLoad), isolate);
boilerplate->map().instance_descriptors(isolate, kRelaxedLoad), isolate);
for (InternalIndex i : boilerplate->map().IterateOwnDescriptors()) {
PropertyDetails details = descriptors->GetDetails(i);
if (details.location() != kField) continue;
@ -1264,7 +1264,8 @@ namespace {
bool IsReadOnlyLengthDescriptor(Isolate* isolate, Handle<Map> jsarray_map) {
DCHECK(!jsarray_map->is_dictionary_map());
Handle<Name> length_string = isolate->factory()->length_string();
DescriptorArray descriptors = jsarray_map->instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors =
jsarray_map->instance_descriptors(isolate, kRelaxedLoad);
// TODO(jkummerow): We could skip the search and hardcode number == 0.
InternalIndex number = descriptors.Search(*length_string, *jsarray_map);
DCHECK(number.is_found());
@ -1457,7 +1458,7 @@ void DescriptorArrayData::SerializeDescriptor(JSHeapBroker* broker,
Isolate* const isolate = broker->isolate();
auto descriptors = Handle<DescriptorArray>::cast(object());
CHECK_EQ(*descriptors, map->instance_descriptors(kRelaxedLoad));
CHECK_EQ(*descriptors, map->instance_descriptors(isolate));
PropertyDescriptor d;
d.key = broker->GetOrCreateData(descriptors->GetKey(descriptor_index));
@ -2247,10 +2248,11 @@ void MapData::SerializeOwnDescriptor(JSHeapBroker* broker,
InternalIndex descriptor_index) {
TraceScope tracer(broker, this, "MapData::SerializeOwnDescriptor");
Handle<Map> map = Handle<Map>::cast(object());
Isolate* isolate = broker->isolate();
if (instance_descriptors_ == nullptr) {
instance_descriptors_ =
broker->GetOrCreateData(map->instance_descriptors(kRelaxedLoad));
broker->GetOrCreateData(map->instance_descriptors(isolate));
}
if (instance_descriptors()->should_access_heap()) {
@ -2258,12 +2260,11 @@ void MapData::SerializeOwnDescriptor(JSHeapBroker* broker,
// owner map if it is different than the current map. This is because
// {instance_descriptors_} gets set on SerializeOwnDescriptor and otherwise
// we risk the field owner having a null {instance_descriptors_}.
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
broker->isolate());
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
if (descriptors->GetDetails(descriptor_index).location() == kField) {
Handle<Map> owner(
map->FindFieldOwner(broker->isolate(), descriptor_index),
broker->isolate());
Handle<Map> owner(map->FindFieldOwner(isolate, descriptor_index),
isolate);
if (!owner.equals(map)) {
broker->GetOrCreateData(owner)->AsMap()->SerializeOwnDescriptor(
broker, descriptor_index);
@ -2363,7 +2364,7 @@ void JSObjectData::SerializeRecursiveAsBoilerplate(JSHeapBroker* broker,
// Check the in-object properties.
Handle<DescriptorArray> descriptors(
boilerplate->map().instance_descriptors(kRelaxedLoad), isolate);
boilerplate->map().instance_descriptors(isolate), isolate);
for (InternalIndex i : boilerplate->map().IterateOwnDescriptors()) {
PropertyDetails details = descriptors->GetDetails(i);
if (details.location() != kField) continue;
@ -3652,8 +3653,9 @@ base::Optional<ObjectRef> MapRef::GetStrongValue(
DescriptorArrayRef MapRef::instance_descriptors() const {
if (data_->should_access_heap()) {
return DescriptorArrayRef(
broker(), broker()->CanonicalPersistentHandle(
object()->instance_descriptors(kRelaxedLoad)));
broker(),
broker()->CanonicalPersistentHandle(
object()->instance_descriptors(broker()->isolate(), kRelaxedLoad)));
}
return DescriptorArrayRef(broker(), data()->AsMap()->instance_descriptors());

View File

@ -1726,7 +1726,7 @@ void TranslatedState::EnsurePropertiesAllocatedAndMarked(
properties_slot->set_storage(object_storage);
// Set markers for out-of-object properties.
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate()),
isolate());
for (InternalIndex i : map->IterateOwnDescriptors()) {
FieldIndex index = FieldIndex::ForDescriptor(*map, i);
@ -1759,7 +1759,7 @@ void TranslatedState::EnsureJSObjectAllocated(TranslatedValue* slot,
Handle<ByteArray> object_storage = AllocateStorageFor(slot);
// Now we handle the interesting (JSObject) case.
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate()),
isolate());
// Set markers for in-object properties.

View File

@ -392,7 +392,7 @@ void JSObject::JSObjectVerify(Isolate* isolate) {
int delta = actual_unused_property_fields - map().UnusedPropertyFields();
CHECK_EQ(0, delta % JSObject::kFieldsAdded);
}
DescriptorArray descriptors = map().instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map().instance_descriptors(isolate);
bool is_transitionable_fast_elements_kind =
IsTransitionableFastElementsKind(map().elements_kind());
@ -462,13 +462,13 @@ void Map::MapVerify(Isolate* isolate) {
// Root maps must not have descriptors in the descriptor array that do not
// belong to the map.
CHECK_EQ(NumberOfOwnDescriptors(),
instance_descriptors(kRelaxedLoad).number_of_descriptors());
instance_descriptors(isolate).number_of_descriptors());
} else {
// If there is a parent map it must be non-stable.
Map parent = Map::cast(GetBackPointer());
CHECK(!parent.is_stable());
DescriptorArray descriptors = instance_descriptors(kRelaxedLoad);
if (descriptors == parent.instance_descriptors(kRelaxedLoad)) {
DescriptorArray descriptors = instance_descriptors(isolate);
if (descriptors == parent.instance_descriptors(isolate)) {
if (NumberOfOwnDescriptors() == parent.NumberOfOwnDescriptors() + 1) {
// Descriptors sharing through property transitions takes over
// ownership from the parent map.
@ -486,7 +486,7 @@ void Map::MapVerify(Isolate* isolate) {
}
}
}
SLOW_DCHECK(instance_descriptors(kRelaxedLoad).IsSortedNoDuplicates());
SLOW_DCHECK(instance_descriptors(isolate).IsSortedNoDuplicates());
DisallowGarbageCollection no_gc;
SLOW_DCHECK(
TransitionsAccessor(isolate, *this, &no_gc).IsSortedNoDuplicates());
@ -500,7 +500,7 @@ void Map::MapVerify(Isolate* isolate) {
CHECK(!has_named_interceptor());
CHECK(!is_dictionary_map());
CHECK(!is_access_check_needed());
DescriptorArray const descriptors = instance_descriptors(kRelaxedLoad);
DescriptorArray const descriptors = instance_descriptors(isolate);
for (InternalIndex i : IterateOwnDescriptors()) {
CHECK(!descriptors.GetKey(i).IsInterestingSymbol());
}
@ -524,7 +524,7 @@ void Map::DictionaryMapVerify(Isolate* isolate) {
CHECK(is_dictionary_map());
CHECK_EQ(kInvalidEnumCacheSentinel, EnumLength());
CHECK_EQ(ReadOnlyRoots(isolate).empty_descriptor_array(),
instance_descriptors(kRelaxedLoad));
instance_descriptors(isolate));
CHECK_EQ(0, UnusedPropertyFields());
CHECK_EQ(Map::GetVisitorId(*this), visitor_id());
}

View File

@ -280,7 +280,7 @@ void FreeSpace::FreeSpacePrint(std::ostream& os) { // NOLINT
bool JSObject::PrintProperties(std::ostream& os) { // NOLINT
if (HasFastProperties()) {
DescriptorArray descs = map().instance_descriptors(kRelaxedLoad);
DescriptorArray descs = map().instance_descriptors(GetIsolate());
int nof_inobject_properties = map().GetInObjectProperties();
for (InternalIndex i : map().IterateOwnDescriptors()) {
os << "\n ";
@ -2470,7 +2470,7 @@ int Name::NameShortPrint(Vector<char> str) {
void Map::PrintMapDetails(std::ostream& os) {
DisallowGarbageCollection no_gc;
this->MapPrint(os);
instance_descriptors(kRelaxedLoad).PrintDescriptors(os);
instance_descriptors().PrintDescriptors(os);
}
void Map::MapPrint(std::ostream& os) { // NOLINT
@ -2524,7 +2524,7 @@ void Map::MapPrint(std::ostream& os) { // NOLINT
os << "\n - prototype_validity cell: " << Brief(prototype_validity_cell());
os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "")
<< "#" << NumberOfOwnDescriptors() << ": "
<< Brief(instance_descriptors(kRelaxedLoad));
<< Brief(instance_descriptors());
// Read-only maps can't have transitions, which is fortunate because we need
// the isolate to iterate over the transitions.
@ -2636,7 +2636,7 @@ void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name key,
DCHECK(!IsSpecialTransition(roots, key));
os << "(transition to ";
InternalIndex descriptor = target.LastAdded();
DescriptorArray descriptors = target.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = target.instance_descriptors();
descriptors.PrintDescriptorDetails(os, descriptor,
PropertyDetails::kForTransitions);
os << ")";
@ -2714,7 +2714,7 @@ void TransitionsAccessor::PrintTransitionTree(
DCHECK(!IsSpecialTransition(ReadOnlyRoots(isolate_), key));
os << "to ";
InternalIndex descriptor = target.LastAdded();
DescriptorArray descriptors = target.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = target.instance_descriptors(isolate_);
descriptors.PrintDescriptorDetails(os, descriptor,
PropertyDetails::kForTransitions);
}

View File

@ -2090,7 +2090,7 @@ Handle<JSGlobalObject> Factory::NewJSGlobalObject(
// The global object might be created from an object template with accessors.
// Fill these accessors into the dictionary.
Handle<DescriptorArray> descs(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descs(map->instance_descriptors(isolate()),
isolate());
for (InternalIndex i : map->IterateOwnDescriptors()) {
PropertyDetails details = descs->GetDetails(i);
@ -3306,8 +3306,8 @@ Handle<Map> Factory::CreateSloppyFunctionMap(
map->AppendDescriptor(isolate(), &d);
}
DCHECK_EQ(inobject_properties_count, field_index);
DCHECK_EQ(
0, map->instance_descriptors(kRelaxedLoad).number_of_slack_descriptors());
DCHECK_EQ(0,
map->instance_descriptors(isolate()).number_of_slack_descriptors());
LOG(isolate(), MapDetails(*map));
return map;
}
@ -3384,8 +3384,8 @@ Handle<Map> Factory::CreateStrictFunctionMap(
map->AppendDescriptor(isolate(), &d);
}
DCHECK_EQ(inobject_properties_count, field_index);
DCHECK_EQ(
0, map->instance_descriptors(kRelaxedLoad).number_of_slack_descriptors());
DCHECK_EQ(0,
map->instance_descriptors(isolate()).number_of_slack_descriptors());
LOG(isolate(), MapDetails(*map));
return map;
}

View File

@ -2132,8 +2132,8 @@ void MarkCompactCollector::ClearPotentialSimpleMapTransition(Map map,
DCHECK_EQ(map.raw_transitions(), HeapObjectReference::Weak(dead_target));
// Take ownership of the descriptor array.
int number_of_own_descriptors = map.NumberOfOwnDescriptors();
DescriptorArray descriptors = map.instance_descriptors(kRelaxedLoad);
if (descriptors == dead_target.instance_descriptors(kRelaxedLoad) &&
DescriptorArray descriptors = map.instance_descriptors(isolate());
if (descriptors == dead_target.instance_descriptors(isolate()) &&
number_of_own_descriptors > 0) {
TrimDescriptorArray(map, descriptors);
DCHECK(descriptors.number_of_descriptors() == number_of_own_descriptors);
@ -2264,7 +2264,7 @@ void MarkCompactCollector::ClearFullMapTransitions() {
bool parent_is_alive =
non_atomic_marking_state()->IsBlackOrGrey(parent);
DescriptorArray descriptors =
parent_is_alive ? parent.instance_descriptors(kRelaxedLoad)
parent_is_alive ? parent.instance_descriptors(isolate())
: DescriptorArray();
bool descriptors_owner_died =
CompactTransitionArray(parent, array, descriptors);
@ -2325,7 +2325,7 @@ bool MarkCompactCollector::CompactTransitionArray(Map map,
DCHECK_EQ(target.constructor_or_back_pointer(), map);
if (non_atomic_marking_state()->IsWhite(target)) {
if (!descriptors.is_null() &&
target.instance_descriptors(kRelaxedLoad) == descriptors) {
target.instance_descriptors(isolate()) == descriptors) {
DCHECK(!target.is_prototype_map());
descriptors_owner_died = true;
}

View File

@ -132,7 +132,7 @@ FieldStatsCollector::GetInobjectFieldStats(Map map) {
JSObjectFieldStats stats;
stats.embedded_fields_count_ = JSObject::GetEmbedderFieldCount(map);
if (!map.is_dictionary_map()) {
DescriptorArray descriptors = map.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map.instance_descriptors();
for (InternalIndex descriptor : map.IterateOwnDescriptors()) {
PropertyDetails details = descriptors.GetDetails(descriptor);
if (details.location() == kField) {
@ -856,7 +856,7 @@ void ObjectStatsCollectorImpl::RecordVirtualMapDetails(Map map) {
// This will be logged as MAP_TYPE in Phase2.
}
DescriptorArray array = map.instance_descriptors(kRelaxedLoad);
DescriptorArray array = map.instance_descriptors(isolate());
if (map.owns_descriptors() &&
array != ReadOnlyRoots(heap_).empty_descriptor_array()) {
// Generally DescriptorArrays have their own instance type already

View File

@ -229,7 +229,7 @@ MaybeObjectHandle StoreHandler::StoreTransition(Isolate* isolate,
if (!is_dictionary_map) {
InternalIndex descriptor = transition_map->LastAdded();
Handle<DescriptorArray> descriptors(
transition_map->instance_descriptors(kRelaxedLoad), isolate);
transition_map->instance_descriptors(isolate), isolate);
PropertyDetails details = descriptors->GetDetails(descriptor);
if (descriptors->GetKey(descriptor).IsPrivate()) {
DCHECK_EQ(DONT_ENUM, details.attributes());

View File

@ -2723,7 +2723,7 @@ static bool CanFastCloneObject(Handle<Map> map) {
return false;
}
DescriptorArray descriptors = map->instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map->instance_descriptors();
for (InternalIndex i : map->IterateOwnDescriptors()) {
PropertyDetails details = descriptors.GetDetails(i);
Name key = descriptors.GetKey(i);
@ -2773,7 +2773,7 @@ static Handle<Map> FastCloneObjectMap(Isolate* isolate, Handle<Map> source_map,
}
Handle<DescriptorArray> source_descriptors(
source_map->instance_descriptors(kRelaxedLoad), isolate);
source_map->instance_descriptors(isolate), isolate);
int size = source_map->NumberOfOwnDescriptors();
int slack = 0;
Handle<DescriptorArray> descriptors = DescriptorArray::CopyForFastObjectClone(

View File

@ -1177,7 +1177,7 @@ namespace {
void ReplaceAccessors(Isolate* isolate, Handle<Map> map, Handle<String> name,
PropertyAttributes attributes,
Handle<AccessorPair> accessor_pair) {
DescriptorArray descriptors = map->instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map->instance_descriptors(isolate);
InternalIndex entry = descriptors.SearchWithCache(isolate, *name, *map);
Descriptor d = Descriptor::AccessorConstant(name, accessor_pair, attributes);
descriptors.Replace(entry, &d);
@ -5152,7 +5152,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
// in the snapshotted global object.
if (from->HasFastProperties()) {
Handle<DescriptorArray> descs = Handle<DescriptorArray>(
from->map().instance_descriptors(kRelaxedLoad), isolate());
from->map().instance_descriptors(isolate()), isolate());
for (InternalIndex i : from->map().IterateOwnDescriptors()) {
PropertyDetails details = descs->GetDetails(i);
if (details.location() == kField) {
@ -5304,7 +5304,7 @@ Handle<Map> Genesis::CreateInitialMapForArraySubclass(int size,
{
JSFunction array_function = native_context()->array_function();
Handle<DescriptorArray> array_descriptors(
array_function.initial_map().instance_descriptors(kRelaxedLoad),
array_function.initial_map().instance_descriptors(isolate()),
isolate());
Handle<String> length = factory()->length_string();
InternalIndex old = array_descriptors->SearchWithCache(

View File

@ -464,8 +464,8 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
InternalIndex descriptor_index(descriptor);
if (descriptor < feedback_descriptors) {
expected =
handle(String::cast(feedback->instance_descriptors(kRelaxedLoad)
.GetKey(descriptor_index)),
handle(String::cast(feedback->instance_descriptors(isolate_).GetKey(
descriptor_index)),
isolate_);
} else {
DisallowGarbageCollection no_gc;
@ -497,7 +497,7 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
Handle<Object> value = property.value;
PropertyDetails details =
target->instance_descriptors(kRelaxedLoad).GetDetails(descriptor_index);
target->instance_descriptors(isolate_).GetDetails(descriptor_index);
Representation expected_representation = details.representation();
if (!value->FitsRepresentation(expected_representation)) {
@ -512,7 +512,7 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
Map::GeneralizeField(isolate(), target, descriptor_index,
details.constness(), representation, value_type);
} else if (expected_representation.IsHeapObject() &&
!target->instance_descriptors(kRelaxedLoad)
!target->instance_descriptors(isolate())
.GetFieldType(descriptor_index)
.NowContains(value)) {
Handle<FieldType> value_type =
@ -524,7 +524,7 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
new_mutable_double++;
}
DCHECK(target->instance_descriptors(kRelaxedLoad)
DCHECK(target->instance_descriptors(isolate())
.GetFieldType(descriptor_index)
.NowContains(value));
map = target;
@ -574,7 +574,7 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
if (property.string.is_index()) continue;
InternalIndex descriptor_index(descriptor);
PropertyDetails details =
map->instance_descriptors(kRelaxedLoad).GetDetails(descriptor_index);
map->instance_descriptors(isolate()).GetDetails(descriptor_index);
Object value = *property.value;
FieldIndex index = FieldIndex::ForDescriptor(*map, descriptor_index);
descriptor++;

View File

@ -772,13 +772,13 @@ JsonStringifier::Result JsonStringifier::SerializeJSObject(
Indent();
bool comma = false;
for (InternalIndex i : map->IterateOwnDescriptors()) {
Handle<Name> name(map->instance_descriptors(kRelaxedLoad).GetKey(i),
Handle<Name> name(map->instance_descriptors(isolate_).GetKey(i),
isolate_);
// TODO(rossberg): Should this throw?
if (!name->IsString()) continue;
Handle<String> key = Handle<String>::cast(name);
PropertyDetails details =
map->instance_descriptors(kRelaxedLoad).GetDetails(i);
map->instance_descriptors(isolate_).GetDetails(i);
if (details.IsDontEnum()) continue;
Handle<Object> property;
if (details.location() == kField && *map == object->map()) {

View File

@ -821,7 +821,7 @@ bool UseFastFunctionNameLookup(Isolate* isolate, Map map) {
DCHECK(!map.is_dictionary_map());
HeapObject value;
ReadOnlyRoots roots(isolate);
auto descriptors = map.instance_descriptors(kRelaxedLoad);
auto descriptors = map.instance_descriptors(isolate);
InternalIndex kNameIndex{JSFunction::kNameDescriptorIndex};
if (descriptors.GetKey(kNameIndex) != roots.name_string() ||
!descriptors.GetValue(kNameIndex)

View File

@ -225,7 +225,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastAssign(
return Just(false);
}
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
bool stable = true;
@ -251,7 +251,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastAssign(
// shape.
if (stable) {
DCHECK_EQ(from->map(), *map);
DCHECK_EQ(*descriptors, map->instance_descriptors(kRelaxedLoad));
DCHECK_EQ(*descriptors, map->instance_descriptors(isolate));
PropertyDetails details = descriptors->GetDetails(i);
if (!details.IsEnumerable()) continue;
@ -270,7 +270,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastAssign(
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, prop_value, Object::GetProperty(&it), Nothing<bool>());
stable = from->map() == *map;
descriptors.PatchValue(map->instance_descriptors(kRelaxedLoad));
descriptors.PatchValue(map->instance_descriptors(isolate));
}
} else {
// If the map did change, do a slower lookup. We are still guaranteed
@ -296,7 +296,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastAssign(
if (result.IsNothing()) return result;
if (stable) {
stable = from->map() == *map;
descriptors.PatchValue(map->instance_descriptors(kRelaxedLoad));
descriptors.PatchValue(map->instance_descriptors(isolate));
}
} else {
if (excluded_properties != nullptr &&
@ -1917,7 +1917,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
if (!map->OnlyHasSimpleProperties()) return Just(false);
Handle<JSObject> object(JSObject::cast(*receiver), isolate);
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
@ -1946,7 +1946,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
// side-effects.
bool stable = *map == object->map();
if (stable) {
descriptors.PatchValue(map->instance_descriptors(kRelaxedLoad));
descriptors.PatchValue(map->instance_descriptors(isolate));
}
for (InternalIndex index : InternalIndex::Range(number_of_own_descriptors)) {
@ -1959,7 +1959,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
// Directly decode from the descriptor array if |from| did not change shape.
if (stable) {
DCHECK_EQ(object->map(), *map);
DCHECK_EQ(*descriptors, map->instance_descriptors(kRelaxedLoad));
DCHECK_EQ(*descriptors, map->instance_descriptors(isolate));
PropertyDetails details = descriptors->GetDetails(index);
if (!details.IsEnumerable()) continue;
@ -1980,7 +1980,7 @@ V8_WARN_UNUSED_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, prop_value, Object::GetProperty(&it), Nothing<bool>());
stable = object->map() == *map;
descriptors.PatchValue(map->instance_descriptors(kRelaxedLoad));
descriptors.PatchValue(map->instance_descriptors(isolate));
}
} else {
// If the map did change, do a slower lookup. We are still guaranteed that
@ -2655,8 +2655,9 @@ void JSObject::PrintInstanceMigration(FILE* file, Map original_map,
return;
}
PrintF(file, "[migrating]");
DescriptorArray o = original_map.instance_descriptors(kRelaxedLoad);
DescriptorArray n = new_map.instance_descriptors(kRelaxedLoad);
Isolate* isolate = GetIsolate();
DescriptorArray o = original_map.instance_descriptors(isolate);
DescriptorArray n = new_map.instance_descriptors(isolate);
for (InternalIndex i : original_map.IterateOwnDescriptors()) {
Representation o_r = o.GetDetails(i).representation();
Representation n_r = n.GetDetails(i).representation();
@ -2841,9 +2842,9 @@ void MigrateFastToFast(Isolate* isolate, Handle<JSObject> object,
isolate->factory()->NewFixedArray(inobject);
Handle<DescriptorArray> old_descriptors(
old_map->instance_descriptors(isolate, kRelaxedLoad), isolate);
old_map->instance_descriptors(isolate), isolate);
Handle<DescriptorArray> new_descriptors(
new_map->instance_descriptors(isolate, kRelaxedLoad), isolate);
new_map->instance_descriptors(isolate), isolate);
int old_nof = old_map->NumberOfOwnDescriptors();
int new_nof = new_map->NumberOfOwnDescriptors();
@ -2981,8 +2982,7 @@ void MigrateFastToSlow(Isolate* isolate, Handle<JSObject> object,
dictionary = isolate->factory()->NewNameDictionary(property_count);
}
Handle<DescriptorArray> descs(
map->instance_descriptors(isolate, kRelaxedLoad), isolate);
Handle<DescriptorArray> descs(map->instance_descriptors(isolate), isolate);
for (InternalIndex i : InternalIndex::Range(real_size)) {
PropertyDetails details = descs->GetDetails(i);
Handle<Name> key(descs->GetKey(isolate, i), isolate);
@ -3175,7 +3175,7 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
// properties but don't unbox double fields.
Isolate* isolate = object->GetIsolate();
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
Handle<FixedArray> storage = isolate->factory()->NewFixedArray(inobject);
@ -3781,7 +3781,7 @@ bool TestFastPropertiesIntegrityLevel(Map map, PropertyAttributes level) {
DCHECK(!map.IsCustomElementsReceiverMap());
DCHECK(!map.is_dictionary_map());
DescriptorArray descriptors = map.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map.instance_descriptors();
for (InternalIndex i : map.IterateOwnDescriptors()) {
if (descriptors.GetKey(i).IsPrivate()) continue;
PropertyDetails details = descriptors.GetDetails(i);
@ -4322,7 +4322,7 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
Object JSObject::SlowReverseLookup(Object value) {
if (HasFastProperties()) {
DescriptorArray descs = map().instance_descriptors(kRelaxedLoad);
DescriptorArray descs = map().instance_descriptors();
bool value_is_number = value.IsNumber();
for (InternalIndex i : map().IterateOwnDescriptors()) {
PropertyDetails details = descs.GetDetails(i);

View File

@ -69,8 +69,7 @@ static Handle<FixedArray> CombineKeys(Isolate* isolate,
int nof_descriptors = map.NumberOfOwnDescriptors();
if (nof_descriptors == 0 && !may_have_elements) return prototype_chain_keys;
Handle<DescriptorArray> descs(map.instance_descriptors(kRelaxedLoad),
isolate);
Handle<DescriptorArray> descs(map.instance_descriptors(isolate), isolate);
int own_keys_length = own_keys.is_null() ? 0 : own_keys->length();
Handle<FixedArray> combined_keys = isolate->factory()->NewFixedArray(
own_keys_length + prototype_chain_keys_length);
@ -373,7 +372,7 @@ Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate,
Handle<JSObject> object) {
Handle<Map> map(object->map(), isolate);
Handle<FixedArray> keys(
map->instance_descriptors(kRelaxedLoad).enum_cache().keys(), isolate);
map->instance_descriptors(isolate).enum_cache().keys(), isolate);
// Check if the {map} has a valid enum length, which implies that it
// must have a valid enum cache as well.
@ -398,7 +397,7 @@ Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate,
}
Handle<DescriptorArray> descriptors =
Handle<DescriptorArray>(map->instance_descriptors(kRelaxedLoad), isolate);
Handle<DescriptorArray>(map->instance_descriptors(isolate), isolate);
isolate->counters()->enum_cache_misses()->Increment();
// Create the keys array.
@ -992,7 +991,7 @@ Maybe<bool> KeyAccumulator::CollectOwnPropertyNames(Handle<JSReceiver> receiver,
if (map.prototype(isolate_) != ReadOnlyRoots(isolate_).null_value()) {
AllowGarbageCollection allow_gc;
Handle<DescriptorArray> descs = Handle<DescriptorArray>(
map.instance_descriptors(kRelaxedLoad), isolate_);
map.instance_descriptors(isolate_), isolate_);
for (InternalIndex i : InternalIndex::Range(nof_descriptors)) {
PropertyDetails details = descs->GetDetails(i);
if (!details.IsDontEnum()) continue;
@ -1028,7 +1027,7 @@ Maybe<bool> KeyAccumulator::CollectOwnPropertyNames(Handle<JSReceiver> receiver,
if (object->HasFastProperties()) {
int limit = object->map().NumberOfOwnDescriptors();
Handle<DescriptorArray> descs(
object->map().instance_descriptors(kRelaxedLoad), isolate_);
object->map().instance_descriptors(isolate_), isolate_);
// First collect the strings,
base::Optional<int> first_symbol =
CollectOwnPropertyNamesInternal<true>(object, this, descs, 0, limit);
@ -1060,8 +1059,8 @@ ExceptionStatus KeyAccumulator::CollectPrivateNames(Handle<JSReceiver> receiver,
DCHECK_EQ(mode_, KeyCollectionMode::kOwnOnly);
if (object->HasFastProperties()) {
int limit = object->map().NumberOfOwnDescriptors();
Handle<DescriptorArray> descs(
object->map().instance_descriptors(kRelaxedLoad), isolate_);
Handle<DescriptorArray> descs(object->map().instance_descriptors(isolate_),
isolate_);
CollectOwnPropertyNamesInternal<false>(object, this, descs, 0, limit);
} else if (object->IsJSGlobalObject()) {
RETURN_FAILURE_IF_NOT_SUCCESSFUL(CollectKeysFromDictionary(

View File

@ -411,9 +411,8 @@ void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
if (old_map.is_identical_to(new_map)) {
// Update the property details if the representation was None.
if (constness() != new_constness || representation().IsNone()) {
property_details_ =
new_map->instance_descriptors(isolate_, kRelaxedLoad)
.GetDetails(descriptor_number());
property_details_ = new_map->instance_descriptors(isolate_).GetDetails(
descriptor_number());
}
return;
}
@ -875,9 +874,9 @@ Handle<Object> LookupIterator::FetchValue(
return JSObject::FastPropertyAt(holder, property_details_.representation(),
field_index);
} else {
result = holder_->map(isolate_)
.instance_descriptors(isolate_, kRelaxedLoad)
.GetStrongValue(isolate_, descriptor_number());
result =
holder_->map(isolate_).instance_descriptors(isolate_).GetStrongValue(
isolate_, descriptor_number());
}
return handle(result, isolate_);
}
@ -993,10 +992,10 @@ Handle<FieldType> LookupIterator::GetFieldType() const {
DCHECK(has_property_);
DCHECK(holder_->HasFastProperties(isolate_));
DCHECK_EQ(kField, property_details_.location());
return handle(holder_->map(isolate_)
.instance_descriptors(isolate_, kRelaxedLoad)
.GetFieldType(isolate_, descriptor_number()),
isolate_);
return handle(
holder_->map(isolate_).instance_descriptors(isolate_).GetFieldType(
isolate_, descriptor_number()),
isolate_);
}
Handle<PropertyCell> LookupIterator::GetPropertyCell() const {
@ -1202,8 +1201,7 @@ LookupIterator::State LookupIterator::LookupInRegularHolder(
property_details_ = property_details_.CopyAddAttributes(SEALED);
}
} else if (!map.is_dictionary_map()) {
DescriptorArray descriptors =
map.instance_descriptors(isolate_, kRelaxedLoad);
DescriptorArray descriptors = map.instance_descriptors(isolate_);
number_ = descriptors.SearchWithCache(isolate_, *name_, map);
if (number_.is_not_found()) return NotFound(holder);
property_details_ = descriptors.GetDetails(number_);

View File

@ -33,6 +33,8 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(Map, HeapObject)
CAST_ACCESSOR(Map)
ACCESSORS(Map, instance_descriptors, DescriptorArray,
kInstanceDescriptorsOffset)
RELAXED_ACCESSORS(Map, instance_descriptors, DescriptorArray,
kInstanceDescriptorsOffset)
RELEASE_ACQUIRE_ACCESSORS(Map, instance_descriptors, DescriptorArray,
@ -172,7 +174,7 @@ bool Map::TooManyFastProperties(StoreOrigin store_origin) const {
}
PropertyDetails Map::GetLastDescriptorDetails(Isolate* isolate) const {
return instance_descriptors(isolate, kRelaxedLoad).GetDetails(LastAdded());
return instance_descriptors(isolate).GetDetails(LastAdded());
}
InternalIndex Map::LastAdded() const {
@ -186,7 +188,7 @@ int Map::NumberOfOwnDescriptors() const {
}
void Map::SetNumberOfOwnDescriptors(int number) {
DCHECK_LE(number, instance_descriptors(kRelaxedLoad).number_of_descriptors());
DCHECK_LE(number, instance_descriptors().number_of_descriptors());
CHECK_LE(static_cast<unsigned>(number),
static_cast<unsigned>(kMaxNumberOfDescriptors));
set_bit_field3(
@ -612,7 +614,7 @@ void Map::clear_padding() {
}
void Map::AppendDescriptor(Isolate* isolate, Descriptor* desc) {
DescriptorArray descriptors = instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = instance_descriptors(isolate);
int number_of_own_descriptors = NumberOfOwnDescriptors();
DCHECK(descriptors.number_of_descriptors() == number_of_own_descriptors);
{

View File

@ -28,7 +28,7 @@ inline bool EqualImmutableValues(Object obj1, Object obj2) {
MapUpdater::MapUpdater(Isolate* isolate, Handle<Map> old_map)
: isolate_(isolate),
old_map_(old_map),
old_descriptors_(old_map->instance_descriptors(kRelaxedLoad), isolate_),
old_descriptors_(old_map->instance_descriptors(isolate), isolate_),
old_nof_(old_map_->NumberOfOwnDescriptors()),
new_elements_kind_(old_map_->elements_kind()),
is_transitionable_fast_elements_kind_(
@ -232,9 +232,9 @@ void MapUpdater::GeneralizeField(Handle<Map> map, InternalIndex modify_index,
Map::GeneralizeField(isolate_, map, modify_index, new_constness,
new_representation, new_field_type);
DCHECK(*old_descriptors_ == old_map_->instance_descriptors(kRelaxedLoad) ||
DCHECK(*old_descriptors_ == old_map_->instance_descriptors(isolate_) ||
*old_descriptors_ ==
integrity_source_map_->instance_descriptors(kRelaxedLoad));
integrity_source_map_->instance_descriptors(isolate_));
}
MapUpdater::State MapUpdater::Normalize(const char* reason) {
@ -328,8 +328,8 @@ bool MapUpdater::TrySaveIntegrityLevelTransitions() {
integrity_source_map_->NumberOfOwnDescriptors());
has_integrity_level_transition_ = true;
old_descriptors_ = handle(
integrity_source_map_->instance_descriptors(kRelaxedLoad), isolate_);
old_descriptors_ =
handle(integrity_source_map_->instance_descriptors(isolate_), isolate_);
return true;
}
@ -425,7 +425,7 @@ MapUpdater::State MapUpdater::FindTargetMap() {
Handle<Map> tmp_map(transition, isolate_);
Handle<DescriptorArray> tmp_descriptors(
tmp_map->instance_descriptors(kRelaxedLoad), isolate_);
tmp_map->instance_descriptors(isolate_), isolate_);
// Check if target map is incompatible.
PropertyDetails tmp_details = tmp_descriptors->GetDetails(i);
@ -473,7 +473,7 @@ MapUpdater::State MapUpdater::FindTargetMap() {
#ifdef DEBUG
if (modified_descriptor_.is_found()) {
DescriptorArray target_descriptors =
target_map_->instance_descriptors(kRelaxedLoad);
target_map_->instance_descriptors(isolate_);
PropertyDetails details =
target_descriptors.GetDetails(modified_descriptor_);
DCHECK_EQ(new_kind_, details.kind());
@ -522,7 +522,7 @@ MapUpdater::State MapUpdater::FindTargetMap() {
if (transition.is_null()) break;
Handle<Map> tmp_map(transition, isolate_);
Handle<DescriptorArray> tmp_descriptors(
tmp_map->instance_descriptors(kRelaxedLoad), isolate_);
tmp_map->instance_descriptors(isolate_), isolate_);
#ifdef DEBUG
// Check that target map is compatible.
PropertyDetails tmp_details = tmp_descriptors->GetDetails(i);
@ -546,7 +546,7 @@ Handle<DescriptorArray> MapUpdater::BuildDescriptorArray() {
InstanceType instance_type = old_map_->instance_type();
int target_nof = target_map_->NumberOfOwnDescriptors();
Handle<DescriptorArray> target_descriptors(
target_map_->instance_descriptors(kRelaxedLoad), isolate_);
target_map_->instance_descriptors(isolate_), isolate_);
// Allocate a new descriptor array large enough to hold the required
// descriptors, with minimally the exact same size as the old descriptor
@ -721,7 +721,7 @@ Handle<Map> MapUpdater::FindSplitMap(Handle<DescriptorArray> descriptors) {
TransitionsAccessor(isolate_, current, &no_gc)
.SearchTransition(name, details.kind(), details.attributes());
if (next.is_null()) break;
DescriptorArray next_descriptors = next.instance_descriptors(kRelaxedLoad);
DescriptorArray next_descriptors = next.instance_descriptors(isolate_);
PropertyDetails next_details = next_descriptors.GetDetails(i);
DCHECK_EQ(details.kind(), next_details.kind());

View File

@ -64,7 +64,7 @@ void Map::PrintReconfiguration(Isolate* isolate, FILE* file,
PropertyAttributes attributes) {
OFStream os(file);
os << "[reconfiguring]";
Name name = instance_descriptors(kRelaxedLoad).GetKey(modify_index);
Name name = instance_descriptors(isolate).GetKey(modify_index);
if (name.IsString()) {
String::cast(name).PrintOn(file);
} else {
@ -393,7 +393,7 @@ void Map::PrintGeneralization(
MaybeHandle<Object> new_value) {
OFStream os(file);
os << "[generalizing]";
Name name = instance_descriptors(kRelaxedLoad).GetKey(modify_index);
Name name = instance_descriptors(isolate).GetKey(modify_index);
if (name.IsString()) {
String::cast(name).PrintOn(file);
} else {
@ -454,7 +454,7 @@ MaybeHandle<Map> Map::CopyWithField(Isolate* isolate, Handle<Map> map,
PropertyConstness constness,
Representation representation,
TransitionFlag flag) {
DCHECK(map->instance_descriptors(kRelaxedLoad)
DCHECK(map->instance_descriptors(isolate)
.Search(*name, map->NumberOfOwnDescriptors())
.is_not_found());
@ -520,8 +520,8 @@ bool Map::InstancesNeedRewriting(Map target, int target_number_of_fields,
if (target_number_of_fields != *old_number_of_fields) return true;
// If smi descriptors were replaced by double descriptors, rewrite.
DescriptorArray old_desc = instance_descriptors(kRelaxedLoad);
DescriptorArray new_desc = target.instance_descriptors(kRelaxedLoad);
DescriptorArray old_desc = instance_descriptors();
DescriptorArray new_desc = target.instance_descriptors();
for (InternalIndex i : IterateOwnDescriptors()) {
if (new_desc.GetDetails(i).representation().IsDouble() !=
old_desc.GetDetails(i).representation().IsDouble()) {
@ -545,7 +545,7 @@ bool Map::InstancesNeedRewriting(Map target, int target_number_of_fields,
}
int Map::NumberOfFields() const {
DescriptorArray descriptors = instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = instance_descriptors();
int result = 0;
for (InternalIndex i : IterateOwnDescriptors()) {
if (descriptors.GetDetails(i).location() == kField) result++;
@ -554,7 +554,7 @@ int Map::NumberOfFields() const {
}
Map::FieldCounts Map::GetFieldCounts() const {
DescriptorArray descriptors = instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = instance_descriptors();
int mutable_count = 0;
int const_count = 0;
for (InternalIndex i : IterateOwnDescriptors()) {
@ -606,7 +606,7 @@ void Map::ReplaceDescriptors(Isolate* isolate,
return;
}
DescriptorArray to_replace = instance_descriptors(kRelaxedLoad);
DescriptorArray to_replace = instance_descriptors(isolate);
// Replace descriptors by new_descriptors in all maps that share it. The old
// descriptors will not be trimmed in the mark-compactor, we need to mark
// all its elements.
@ -614,7 +614,7 @@ void Map::ReplaceDescriptors(Isolate* isolate,
#ifndef V8_DISABLE_WRITE_BARRIERS
WriteBarrier::Marking(to_replace, to_replace.number_of_descriptors());
#endif
while (current.instance_descriptors(isolate, kRelaxedLoad) == to_replace) {
while (current.instance_descriptors(isolate) == to_replace) {
Object next = current.GetBackPointer(isolate);
if (next.IsUndefined(isolate)) break; // Stop overwriting at initial map.
current.SetEnumLength(kInvalidEnumCacheSentinel);
@ -633,9 +633,9 @@ Map Map::FindRootMap(Isolate* isolate) const {
if (back.IsUndefined(isolate)) {
// Initial map must not contain descriptors in the descriptors array
// that do not belong to the map.
DCHECK_LE(
result.NumberOfOwnDescriptors(),
result.instance_descriptors(kRelaxedLoad).number_of_descriptors());
DCHECK_LE(result.NumberOfOwnDescriptors(),
result.instance_descriptors(isolate, kRelaxedLoad)
.number_of_descriptors());
return result;
}
result = Map::cast(back);
@ -666,7 +666,7 @@ void Map::UpdateFieldType(Isolate* isolate, InternalIndex descriptor,
// We store raw pointers in the queue, so no allocations are allowed.
DisallowGarbageCollection no_gc;
PropertyDetails details =
instance_descriptors(kRelaxedLoad).GetDetails(descriptor);
instance_descriptors(isolate).GetDetails(descriptor);
if (details.location() != kField) return;
DCHECK_EQ(kData, details.kind());
@ -688,7 +688,7 @@ void Map::UpdateFieldType(Isolate* isolate, InternalIndex descriptor,
Map target = transitions.GetTarget(i);
backlog.push(target);
}
DescriptorArray descriptors = current.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = current.instance_descriptors(isolate);
PropertyDetails details = descriptors.GetDetails(descriptor);
// It is allowed to change representation here only from None
@ -736,8 +736,8 @@ void Map::GeneralizeField(Isolate* isolate, Handle<Map> map,
Representation new_representation,
Handle<FieldType> new_field_type) {
// Check if we actually need to generalize the field type at all.
Handle<DescriptorArray> old_descriptors(
map->instance_descriptors(kRelaxedLoad), isolate);
Handle<DescriptorArray> old_descriptors(map->instance_descriptors(isolate),
isolate);
PropertyDetails old_details = old_descriptors->GetDetails(modify_index);
PropertyConstness old_constness = old_details.constness();
Representation old_representation = old_details.representation();
@ -761,7 +761,7 @@ void Map::GeneralizeField(Isolate* isolate, Handle<Map> map,
// Determine the field owner.
Handle<Map> field_owner(map->FindFieldOwner(isolate, modify_index), isolate);
Handle<DescriptorArray> descriptors(
field_owner->instance_descriptors(kRelaxedLoad), isolate);
field_owner->instance_descriptors(isolate), isolate);
DCHECK_EQ(*old_field_type, descriptors->GetFieldType(modify_index));
new_field_type =
@ -846,7 +846,7 @@ Map SearchMigrationTarget(Isolate* isolate, Map old_map) {
// types instead of old_map's types.
// Go to slow map updating if the old_map has fast properties with cleared
// field types.
DescriptorArray old_descriptors = old_map.instance_descriptors(kRelaxedLoad);
DescriptorArray old_descriptors = old_map.instance_descriptors(isolate);
for (InternalIndex i : old_map.IterateOwnDescriptors()) {
PropertyDetails old_details = old_descriptors.GetDetails(i);
if (old_details.location() == kField && old_details.kind() == kData) {
@ -1008,7 +1008,7 @@ Map Map::TryReplayPropertyTransitions(Isolate* isolate, Map old_map) {
int root_nof = NumberOfOwnDescriptors();
int old_nof = old_map.NumberOfOwnDescriptors();
DescriptorArray old_descriptors = old_map.instance_descriptors(kRelaxedLoad);
DescriptorArray old_descriptors = old_map.instance_descriptors(isolate);
Map new_map = *this;
for (InternalIndex i : InternalIndex::Range(root_nof, old_nof)) {
@ -1019,8 +1019,7 @@ Map Map::TryReplayPropertyTransitions(Isolate* isolate, Map old_map) {
old_details.attributes());
if (transition.is_null()) return Map();
new_map = transition;
DescriptorArray new_descriptors =
new_map.instance_descriptors(kRelaxedLoad);
DescriptorArray new_descriptors = new_map.instance_descriptors(isolate);
PropertyDetails new_details = new_descriptors.GetDetails(i);
DCHECK_EQ(old_details.kind(), new_details.kind());
@ -1085,7 +1084,7 @@ void Map::EnsureDescriptorSlack(Isolate* isolate, Handle<Map> map, int slack) {
// Only supports adding slack to owned descriptors.
DCHECK(map->owns_descriptors());
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
int old_size = map->NumberOfOwnDescriptors();
if (slack <= descriptors->number_of_slack_descriptors()) return;
@ -1115,7 +1114,7 @@ void Map::EnsureDescriptorSlack(Isolate* isolate, Handle<Map> map, int slack) {
#endif
Map current = *map;
while (current.instance_descriptors(kRelaxedLoad) == *descriptors) {
while (current.instance_descriptors(isolate) == *descriptors) {
Object next = current.GetBackPointer();
if (next.IsUndefined(isolate)) break; // Stop overwriting at initial map.
current.UpdateDescriptors(isolate, *new_descriptors,
@ -1378,7 +1377,7 @@ int Map::NumberOfEnumerableProperties() const {
int Map::NextFreePropertyIndex() const {
int number_of_own_descriptors = NumberOfOwnDescriptors();
DescriptorArray descs = instance_descriptors(kRelaxedLoad);
DescriptorArray descs = instance_descriptors();
// Search properties backwards to find the last field.
for (int i = number_of_own_descriptors - 1; i >= 0; --i) {
PropertyDetails details = descs.GetDetails(InternalIndex(i));
@ -1586,7 +1585,7 @@ void EnsureInitialMap(Isolate* isolate, Handle<Map> map) {
// Initial maps must not contain descriptors in the descriptors array
// that do not belong to the map.
DCHECK_EQ(map->NumberOfOwnDescriptors(),
map->instance_descriptors(kRelaxedLoad).number_of_descriptors());
map->instance_descriptors(isolate).number_of_descriptors());
}
} // namespace
@ -1612,7 +1611,7 @@ Handle<Map> Map::CopyInitialMap(Isolate* isolate, Handle<Map> map,
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
if (number_of_own_descriptors > 0) {
// The copy will use the same descriptors array without ownership.
DescriptorArray descriptors = map->instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map->instance_descriptors(isolate);
result->set_owns_descriptors(false);
result->UpdateDescriptors(isolate, descriptors, number_of_own_descriptors);
@ -1643,7 +1642,7 @@ Handle<Map> Map::ShareDescriptor(Isolate* isolate, Handle<Map> map,
// array, implying that its NumberOfOwnDescriptors equals the number of
// descriptors in the descriptor array.
DCHECK_EQ(map->NumberOfOwnDescriptors(),
map->instance_descriptors(kRelaxedLoad).number_of_descriptors());
map->instance_descriptors(isolate).number_of_descriptors());
Handle<Map> result = CopyDropDescriptors(isolate, map);
Handle<Name> name = descriptor->GetKey();
@ -1661,7 +1660,7 @@ Handle<Map> Map::ShareDescriptor(Isolate* isolate, Handle<Map> map,
} else {
int slack = SlackForArraySize(old_size, kMaxNumberOfDescriptors);
EnsureDescriptorSlack(isolate, map, slack);
descriptors = handle(map->instance_descriptors(kRelaxedLoad), isolate);
descriptors = handle(map->instance_descriptors(isolate), isolate);
}
}
@ -1689,9 +1688,8 @@ void Map::ConnectTransition(Isolate* isolate, Handle<Map> parent,
} else if (!parent->IsDetached(isolate)) {
// |parent| is initial map and it must not contain descriptors in the
// descriptors array that do not belong to the map.
DCHECK_EQ(
parent->NumberOfOwnDescriptors(),
parent->instance_descriptors(kRelaxedLoad).number_of_descriptors());
DCHECK_EQ(parent->NumberOfOwnDescriptors(),
parent->instance_descriptors(isolate).number_of_descriptors());
}
if (parent->IsDetached(isolate)) {
DCHECK(child->IsDetached(isolate));
@ -1905,12 +1903,11 @@ Handle<Map> Map::CopyForElementsTransition(Isolate* isolate, Handle<Map> map) {
// transfer ownership to the new map.
// The properties did not change, so reuse descriptors.
map->set_owns_descriptors(false);
new_map->InitializeDescriptors(isolate,
map->instance_descriptors(kRelaxedLoad));
new_map->InitializeDescriptors(isolate, map->instance_descriptors(isolate));
} else {
// In case the map did not own its own descriptors, a split is forced by
// copying the map; creating a new descriptor array cell.
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
Handle<DescriptorArray> new_descriptors = DescriptorArray::CopyUpTo(
@ -1921,7 +1918,7 @@ Handle<Map> Map::CopyForElementsTransition(Isolate* isolate, Handle<Map> map) {
}
Handle<Map> Map::Copy(Isolate* isolate, Handle<Map> map, const char* reason) {
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
Handle<DescriptorArray> new_descriptors = DescriptorArray::CopyUpTo(
@ -1961,7 +1958,7 @@ Handle<Map> Map::CopyForPreventExtensions(
bool old_map_is_dictionary_elements_kind) {
int num_descriptors = map->NumberOfOwnDescriptors();
Handle<DescriptorArray> new_desc = DescriptorArray::CopyUpToAddAttributes(
isolate, handle(map->instance_descriptors(kRelaxedLoad), isolate),
isolate, handle(map->instance_descriptors(isolate), isolate),
num_descriptors, attrs_to_add);
// Do not track transitions during bootstrapping.
TransitionFlag flag =
@ -2056,14 +2053,13 @@ Handle<Map> UpdateDescriptorForValue(Isolate* isolate, Handle<Map> map,
InternalIndex descriptor,
PropertyConstness constness,
Handle<Object> value) {
if (CanHoldValue(map->instance_descriptors(kRelaxedLoad), descriptor,
constness, *value)) {
if (CanHoldValue(map->instance_descriptors(isolate), descriptor, constness,
*value)) {
return map;
}
PropertyAttributes attributes = map->instance_descriptors(kRelaxedLoad)
.GetDetails(descriptor)
.attributes();
PropertyAttributes attributes =
map->instance_descriptors(isolate).GetDetails(descriptor).attributes();
Representation representation = value->OptimalRepresentation(isolate);
Handle<FieldType> type = value->OptimalType(isolate, representation);
@ -2110,7 +2106,7 @@ Handle<Map> Map::TransitionToDataProperty(Isolate* isolate, Handle<Map> map,
Handle<Map> transition(maybe_transition, isolate);
InternalIndex descriptor = transition->LastAdded();
DCHECK_EQ(attributes, transition->instance_descriptors(kRelaxedLoad)
DCHECK_EQ(attributes, transition->instance_descriptors(isolate)
.GetDetails(descriptor)
.attributes());
@ -2230,8 +2226,7 @@ Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
.SearchTransition(*name, kAccessor, attributes);
if (!maybe_transition.is_null()) {
Handle<Map> transition(maybe_transition, isolate);
DescriptorArray descriptors =
transition->instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = transition->instance_descriptors(isolate);
InternalIndex descriptor = transition->LastAdded();
DCHECK(descriptors.GetKey(descriptor).Equals(*name));
@ -2254,7 +2249,7 @@ Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
}
Handle<AccessorPair> pair;
DescriptorArray old_descriptors = map->instance_descriptors(kRelaxedLoad);
DescriptorArray old_descriptors = map->instance_descriptors(isolate);
if (descriptor.is_found()) {
if (descriptor != map->LastAdded()) {
return Map::Normalize(isolate, map, mode, "AccessorsOverwritingNonLast");
@ -2315,7 +2310,7 @@ Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
Handle<Map> Map::CopyAddDescriptor(Isolate* isolate, Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag) {
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
isolate);
// Share descriptors only if map owns descriptors and it not an initial map.
@ -2338,8 +2333,8 @@ Handle<Map> Map::CopyAddDescriptor(Isolate* isolate, Handle<Map> map,
Handle<Map> Map::CopyInsertDescriptor(Isolate* isolate, Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag) {
Handle<DescriptorArray> old_descriptors(
map->instance_descriptors(kRelaxedLoad), isolate);
Handle<DescriptorArray> old_descriptors(map->instance_descriptors(isolate),
isolate);
// We replace the key if it is already present.
InternalIndex index =
@ -2418,8 +2413,8 @@ bool Map::EquivalentToForTransition(const Map other) const {
// not equivalent to strict function.
int nof =
std::min(NumberOfOwnDescriptors(), other.NumberOfOwnDescriptors());
return instance_descriptors(kRelaxedLoad)
.IsEqualUpTo(other.instance_descriptors(kRelaxedLoad), nof);
return instance_descriptors().IsEqualUpTo(other.instance_descriptors(),
nof);
}
return true;
}
@ -2430,7 +2425,7 @@ bool Map::EquivalentToForElementsKindTransition(const Map other) const {
// Ensure that we don't try to generate elements kind transitions from maps
// with fields that may be generalized in-place. This must already be handled
// during addition of a new field.
DescriptorArray descriptors = instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = instance_descriptors();
for (InternalIndex i : IterateOwnDescriptors()) {
PropertyDetails details = descriptors.GetDetails(i);
if (details.location() == kField) {

View File

@ -576,6 +576,7 @@ class Map : public HeapObject {
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// [instance descriptors]: describes the object.
DECL_ACCESSORS(instance_descriptors, DescriptorArray)
DECL_RELAXED_ACCESSORS(instance_descriptors, DescriptorArray)
DECL_ACQUIRE_GETTER(instance_descriptors, DescriptorArray)
V8_EXPORT_PRIVATE void SetInstanceDescriptors(Isolate* isolate,

View File

@ -5123,11 +5123,9 @@ bool JSArray::MayHaveReadOnlyLength(Map js_array_map) {
// dictionary properties. Since it's not configurable, it's guaranteed to be
// the first in the descriptor array.
InternalIndex first(0);
DCHECK(js_array_map.instance_descriptors(kRelaxedLoad).GetKey(first) ==
DCHECK(js_array_map.instance_descriptors().GetKey(first) ==
js_array_map.GetReadOnlyRoots().length_string());
return js_array_map.instance_descriptors(kRelaxedLoad)
.GetDetails(first)
.IsReadOnly();
return js_array_map.instance_descriptors().GetDetails(first).IsReadOnly();
}
bool JSArray::HasReadOnlyLength(Handle<JSArray> array) {

View File

@ -57,7 +57,7 @@ bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<JSReceiver> obj,
// TODO(jkummerow): support dictionary properties?
if (map->is_dictionary_map()) return false;
Handle<DescriptorArray> descs =
Handle<DescriptorArray>(map->instance_descriptors(kRelaxedLoad), isolate);
Handle<DescriptorArray>(map->instance_descriptors(isolate), isolate);
for (InternalIndex i : map->IterateOwnDescriptors()) {
PropertyDetails details = descs->GetDetails(i);
Handle<Object> value;

View File

@ -256,7 +256,7 @@ PrimitiveHeapObject InferMethodNameFromFastObject(Isolate* isolate,
PrimitiveHeapObject name) {
ReadOnlyRoots roots(isolate);
Map map = receiver.map();
DescriptorArray descriptors = map.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map.instance_descriptors(isolate);
for (auto i : map.IterateOwnDescriptors()) {
PrimitiveHeapObject key = descriptors.GetKey(i);
if (key.IsSymbol()) continue;

View File

@ -113,7 +113,7 @@ PropertyDetails TransitionsAccessor::GetSimpleTargetDetails(Map transition) {
// static
Name TransitionsAccessor::GetSimpleTransitionKey(Map transition) {
InternalIndex descriptor = transition.LastAdded();
return transition.instance_descriptors(kRelaxedLoad).GetKey(descriptor);
return transition.instance_descriptors().GetKey(descriptor);
}
// static

View File

@ -529,8 +529,8 @@ void TransitionsAccessor::CheckNewTransitionsAreConsistent(
TransitionArray new_transitions = TransitionArray::cast(transitions);
for (int i = 0; i < old_transitions.number_of_transitions(); i++) {
Map target = old_transitions.GetTarget(i);
if (target.instance_descriptors(kRelaxedLoad) ==
map_.instance_descriptors(kRelaxedLoad)) {
if (target.instance_descriptors(isolate_) ==
map_.instance_descriptors(isolate_)) {
Name key = old_transitions.GetKey(i);
int new_target_index;
if (IsSpecialTransition(ReadOnlyRoots(isolate_), key)) {

View File

@ -602,11 +602,9 @@ Maybe<bool> ValueSerializer::WriteJSObject(Handle<JSObject> object) {
uint32_t properties_written = 0;
bool map_changed = false;
for (InternalIndex i : map->IterateOwnDescriptors()) {
Handle<Name> key(map->instance_descriptors(kRelaxedLoad).GetKey(i),
isolate_);
Handle<Name> key(map->instance_descriptors(isolate_).GetKey(i), isolate_);
if (!key->IsString()) continue;
PropertyDetails details =
map->instance_descriptors(kRelaxedLoad).GetDetails(i);
PropertyDetails details = map->instance_descriptors(isolate_).GetDetails(i);
if (details.IsDontEnum()) continue;
Handle<Object> value;
@ -2002,8 +2000,7 @@ static void CommitProperties(Handle<JSObject> object, Handle<Map> map,
DCHECK(!object->map().is_dictionary_map());
DisallowGarbageCollection no_gc;
DescriptorArray descriptors =
object->map().instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = object->map().instance_descriptors();
for (InternalIndex i : InternalIndex::Range(properties.size())) {
// Initializing store.
object->WriteToField(i, descriptors.GetDetails(i),
@ -2025,8 +2022,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
bool transitioning = true;
Handle<Map> map(object->map(), isolate_);
DCHECK(!map->is_dictionary_map());
DCHECK_EQ(0,
map->instance_descriptors(kRelaxedLoad).number_of_descriptors());
DCHECK_EQ(0, map->instance_descriptors(isolate_).number_of_descriptors());
std::vector<Handle<Object>> properties;
properties.reserve(8);
@ -2077,11 +2073,11 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
if (transitioning) {
InternalIndex descriptor(properties.size());
PropertyDetails details =
target->instance_descriptors(kRelaxedLoad).GetDetails(descriptor);
target->instance_descriptors(isolate_).GetDetails(descriptor);
Representation expected_representation = details.representation();
if (value->FitsRepresentation(expected_representation)) {
if (expected_representation.IsHeapObject() &&
!target->instance_descriptors(kRelaxedLoad)
!target->instance_descriptors(isolate_)
.GetFieldType(descriptor)
.NowContains(value)) {
Handle<FieldType> value_type =
@ -2090,7 +2086,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
details.constness(), expected_representation,
value_type);
}
DCHECK(target->instance_descriptors(kRelaxedLoad)
DCHECK(target->instance_descriptors(isolate_)
.GetFieldType(descriptor)
.NowContains(value));
properties.push_back(value);

View File

@ -1078,7 +1078,7 @@ void V8HeapExplorer::ExtractMapReferences(HeapEntry* entry, Map map) {
Map::kTransitionsOrPrototypeInfoOffset);
}
}
DescriptorArray descriptors = map.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map.instance_descriptors();
TagObject(descriptors, "(map descriptors)");
SetInternalReference(entry, "descriptors", descriptors,
Map::kInstanceDescriptorsOffset);
@ -1340,7 +1340,7 @@ void V8HeapExplorer::ExtractPropertyReferences(JSObject js_obj,
HeapEntry* entry) {
Isolate* isolate = js_obj.GetIsolate();
if (js_obj.HasFastProperties()) {
DescriptorArray descs = js_obj.map().instance_descriptors(kRelaxedLoad);
DescriptorArray descs = js_obj.map().instance_descriptors(isolate);
for (InternalIndex i : js_obj.map().IterateOwnDescriptors()) {
PropertyDetails details = descs.GetDetails(i);
switch (details.location()) {

View File

@ -173,8 +173,8 @@ bool RegExpUtils::IsUnmodifiedRegExp(Isolate* isolate, Handle<Object> obj) {
// with the init order in the bootstrapper).
InternalIndex kExecIndex(JSRegExp::kExecFunctionDescriptorIndex);
DCHECK_EQ(*(isolate->factory()->exec_string()),
proto_map.instance_descriptors(kRelaxedLoad).GetKey(kExecIndex));
if (proto_map.instance_descriptors(kRelaxedLoad)
proto_map.instance_descriptors(isolate).GetKey(kExecIndex));
if (proto_map.instance_descriptors(isolate)
.GetDetails(kExecIndex)
.constness() != PropertyConstness::kConst) {
return false;

View File

@ -111,8 +111,7 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
if (!copy->IsJSArray(isolate)) {
if (copy->HasFastProperties(isolate)) {
Handle<DescriptorArray> descriptors(
copy->map(isolate).instance_descriptors(isolate, kRelaxedLoad),
isolate);
copy->map(isolate).instance_descriptors(isolate), isolate);
for (InternalIndex i : copy->map(isolate).IterateOwnDescriptors()) {
PropertyDetails details = descriptors->GetDetails(i);
DCHECK_EQ(kField, details.location());

View File

@ -111,7 +111,7 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver,
if (nof == 0) return false;
InternalIndex descriptor(nof - 1);
Handle<DescriptorArray> descriptors(
receiver_map->instance_descriptors(kRelaxedLoad), isolate);
receiver_map->instance_descriptors(isolate), isolate);
if (descriptors->GetKey(descriptor) != *key) return false;
// (3) The property to be deleted must be deletable.
PropertyDetails details = descriptors->GetDetails(descriptor);

View File

@ -298,7 +298,7 @@ void StringStream::PrintName(Object name) {
void StringStream::PrintUsingMap(JSObject js_object) {
Map map = js_object.map();
DescriptorArray descs = map.instance_descriptors(kRelaxedLoad);
DescriptorArray descs = map.instance_descriptors(js_object.GetIsolate());
for (InternalIndex i : map.IterateOwnDescriptors()) {
PropertyDetails details = descs.GetDetails(i);
if (details.location() == kField) {

View File

@ -151,7 +151,7 @@ TEST(StressJS) {
// Patch the map to have an accessor for "get".
Handle<Map> map(function->initial_map(), isolate);
Handle<DescriptorArray> instance_descriptors(
map->instance_descriptors(kRelaxedLoad), isolate);
map->instance_descriptors(isolate), isolate);
CHECK_EQ(0, instance_descriptors->number_of_descriptors());
PropertyAttributes attrs = NONE;

View File

@ -2659,20 +2659,17 @@ static void ThrowingSymbolAccessorGetter(
THREADED_TEST(AccessorIsPreservedOnAttributeChange) {
v8::Isolate* isolate = CcTest::isolate();
i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope scope(isolate);
LocalContext env;
v8::Local<v8::Value> res = CompileRun("var a = []; a;");
i::Handle<i::JSReceiver> a(v8::Utils::OpenHandle(v8::Object::Cast(*res)));
CHECK_EQ(
1,
a->map().instance_descriptors(v8::kRelaxedLoad).number_of_descriptors());
CHECK_EQ(1, a->map().instance_descriptors(i_isolate).number_of_descriptors());
CompileRun("Object.defineProperty(a, 'length', { writable: false });");
CHECK_EQ(
0,
a->map().instance_descriptors(v8::kRelaxedLoad).number_of_descriptors());
CHECK_EQ(0, a->map().instance_descriptors(i_isolate).number_of_descriptors());
// But we should still have an AccessorInfo.
i::Handle<i::String> name = CcTest::i_isolate()->factory()->length_string();
i::LookupIterator it(CcTest::i_isolate(), a, name,
i::Handle<i::String> name = i_isolate->factory()->length_string();
i::LookupIterator it(i_isolate, a, name,
i::LookupIterator::OWN_SKIP_INTERCEPTOR);
CHECK_EQ(i::LookupIterator::ACCESSOR, it.state());
CHECK(it.GetAccessors()->IsAccessorInfo());

View File

@ -56,7 +56,7 @@ void CheckDescriptorArrayLookups(Isolate* isolate, Handle<Map> map,
// Test C++ implementation.
{
DisallowGarbageCollection no_gc;
DescriptorArray descriptors = map->instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map->instance_descriptors(isolate);
DCHECK(descriptors.IsSortedNoDuplicates());
int nof_descriptors = descriptors.number_of_descriptors();
@ -91,8 +91,8 @@ void CheckTransitionArrayLookups(Isolate* isolate,
for (size_t i = 0; i < maps.size(); ++i) {
Map expected_map = *maps[i];
Name name = expected_map.instance_descriptors(kRelaxedLoad)
.GetKey(expected_map.LastAdded());
Name name = expected_map.instance_descriptors(isolate).GetKey(
expected_map.LastAdded());
Map map = transitions->SearchAndGetTargetForTesting(PropertyKind::kData,
name, NONE);
@ -105,8 +105,8 @@ void CheckTransitionArrayLookups(Isolate* isolate,
if (!FLAG_jitless) {
for (size_t i = 0; i < maps.size(); ++i) {
Handle<Map> expected_map = maps[i];
Handle<Name> name(expected_map->instance_descriptors(kRelaxedLoad)
.GetKey(expected_map->LastAdded()),
Handle<Name> name(expected_map->instance_descriptors(isolate).GetKey(
expected_map->LastAdded()),
isolate);
Handle<Object> transition_map =
@ -260,7 +260,7 @@ TEST(DescriptorArrayHashCollisionMassive) {
CheckDescriptorArrayLookups(isolate, map, names, csa_lookup);
// Sort descriptor array and check it again.
map->instance_descriptors(kRelaxedLoad).Sort();
map->instance_descriptors(isolate).Sort();
CheckDescriptorArrayLookups(isolate, map, names, csa_lookup);
}
@ -309,7 +309,7 @@ TEST(DescriptorArrayHashCollision) {
CheckDescriptorArrayLookups(isolate, map, names, csa_lookup);
// Sort descriptor array and check it again.
map->instance_descriptors(kRelaxedLoad).Sort();
map->instance_descriptors(isolate).Sort();
CheckDescriptorArrayLookups(isolate, map, names, csa_lookup);
}

View File

@ -275,7 +275,7 @@ class Expectations {
CHECK_EQ(expected_nof, map.NumberOfOwnDescriptors());
CHECK(!map.is_dictionary_map());
DescriptorArray descriptors = map.instance_descriptors(kRelaxedLoad);
DescriptorArray descriptors = map.instance_descriptors();
CHECK(expected_nof <= number_of_properties_);
for (InternalIndex i : InternalIndex::Range(expected_nof)) {
if (!Check(descriptors, i)) {
@ -444,8 +444,9 @@ class Expectations {
Handle<Object> getter(pair->getter(), isolate);
Handle<Object> setter(pair->setter(), isolate);
InternalIndex descriptor = map->instance_descriptors(kRelaxedLoad)
.SearchWithCache(isolate, *name, *map);
InternalIndex descriptor =
map->instance_descriptors(isolate).SearchWithCache(isolate, *name,
*map);
map = Map::TransitionToAccessorProperty(isolate, map, name, descriptor,
getter, setter, attributes);
CHECK(!map->is_deprecated());
@ -553,7 +554,7 @@ TEST(ReconfigureAccessorToNonExistingDataFieldHeavy) {
CHECK_EQ(1, obj->map().NumberOfOwnDescriptors());
InternalIndex first(0);
CHECK(obj->map()
.instance_descriptors(kRelaxedLoad)
.instance_descriptors(isolate)
.GetStrongValue(first)
.IsAccessorPair());
@ -2829,13 +2830,12 @@ void TestStoreToConstantField(const char* store_func_source,
CHECK(!map->is_deprecated());
CHECK_EQ(1, map->NumberOfOwnDescriptors());
InternalIndex first(0);
CHECK(map->instance_descriptors(kRelaxedLoad)
CHECK(map->instance_descriptors(isolate)
.GetDetails(first)
.representation()
.Equals(expected_rep));
CHECK_EQ(
PropertyConstness::kConst,
map->instance_descriptors(kRelaxedLoad).GetDetails(first).constness());
CHECK_EQ(PropertyConstness::kConst,
map->instance_descriptors(isolate).GetDetails(first).constness());
// Store value2 to obj2 and check that it got same map and property details
// did not change.
@ -2847,13 +2847,12 @@ void TestStoreToConstantField(const char* store_func_source,
CHECK(!map->is_deprecated());
CHECK_EQ(1, map->NumberOfOwnDescriptors());
CHECK(map->instance_descriptors(kRelaxedLoad)
CHECK(map->instance_descriptors(isolate)
.GetDetails(first)
.representation()
.Equals(expected_rep));
CHECK_EQ(
PropertyConstness::kConst,
map->instance_descriptors(kRelaxedLoad).GetDetails(first).constness());
CHECK_EQ(PropertyConstness::kConst,
map->instance_descriptors(isolate).GetDetails(first).constness());
// Store value2 to obj1 and check that property became mutable.
Call(isolate, store_func, obj1, value2).Check();
@ -2863,13 +2862,12 @@ void TestStoreToConstantField(const char* store_func_source,
CHECK(!map->is_deprecated());
CHECK_EQ(1, map->NumberOfOwnDescriptors());
CHECK(map->instance_descriptors(kRelaxedLoad)
CHECK(map->instance_descriptors(isolate)
.GetDetails(first)
.representation()
.Equals(expected_rep));
CHECK_EQ(
expected_constness,
map->instance_descriptors(kRelaxedLoad).GetDetails(first).constness());
CHECK_EQ(expected_constness,
map->instance_descriptors(isolate).GetDetails(first).constness());
}
void TestStoreToConstantField_PlusMinusZero(const char* store_func_source,

View File

@ -115,14 +115,10 @@ TEST(EnumCache) {
*env->Global()->Get(env.local(), v8_str("cc")).ToLocalChecked()));
// Check the transition tree.
CHECK_EQ(a->map().instance_descriptors(kRelaxedLoad),
b->map().instance_descriptors(kRelaxedLoad));
CHECK_EQ(b->map().instance_descriptors(kRelaxedLoad),
c->map().instance_descriptors(kRelaxedLoad));
CHECK_NE(c->map().instance_descriptors(kRelaxedLoad),
cc->map().instance_descriptors(kRelaxedLoad));
CHECK_NE(b->map().instance_descriptors(kRelaxedLoad),
cc->map().instance_descriptors(kRelaxedLoad));
CHECK_EQ(a->map().instance_descriptors(), b->map().instance_descriptors());
CHECK_EQ(b->map().instance_descriptors(), c->map().instance_descriptors());
CHECK_NE(c->map().instance_descriptors(), cc->map().instance_descriptors());
CHECK_NE(b->map().instance_descriptors(), cc->map().instance_descriptors());
// Check that the EnumLength is unset.
CHECK_EQ(a->map().EnumLength(), kInvalidEnumCacheSentinel);
@ -131,13 +127,13 @@ TEST(EnumCache) {
CHECK_EQ(cc->map().EnumLength(), kInvalidEnumCacheSentinel);
// Check that the EnumCache is empty.
CHECK_EQ(a->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_EQ(a->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_EQ(b->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_EQ(b->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_EQ(c->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_EQ(c->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_EQ(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_EQ(cc->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
// The EnumCache is shared on the DescriptorArray, creating it on {cc} has no
@ -149,15 +145,14 @@ TEST(EnumCache) {
CHECK_EQ(c->map().EnumLength(), kInvalidEnumCacheSentinel);
CHECK_EQ(cc->map().EnumLength(), 3);
CHECK_EQ(a->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_EQ(a->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_EQ(b->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_EQ(b->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_EQ(c->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_EQ(c->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
EnumCache enum_cache =
cc->map().instance_descriptors(kRelaxedLoad).enum_cache();
EnumCache enum_cache = cc->map().instance_descriptors().enum_cache();
CHECK_NE(enum_cache, *factory->empty_enum_cache());
CHECK_EQ(enum_cache.keys().length(), 3);
CHECK_EQ(enum_cache.indices().length(), 3);
@ -174,19 +169,14 @@ TEST(EnumCache) {
// The enum cache is shared on the descriptor array of maps {a}, {b} and
// {c} only.
EnumCache enum_cache =
a->map().instance_descriptors(kRelaxedLoad).enum_cache();
EnumCache enum_cache = a->map().instance_descriptors().enum_cache();
CHECK_NE(enum_cache, *factory->empty_enum_cache());
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_NE(cc->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(a->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(b->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(c->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_NE(cc->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(a->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(b->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(c->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(enum_cache.keys().length(), 1);
CHECK_EQ(enum_cache.indices().length(), 1);
@ -195,8 +185,7 @@ TEST(EnumCache) {
// Creating the EnumCache for {c} will create a new EnumCache on the shared
// DescriptorArray.
Handle<EnumCache> previous_enum_cache(
a->map().instance_descriptors(kRelaxedLoad).enum_cache(),
a->GetIsolate());
a->map().instance_descriptors().enum_cache(), a->GetIsolate());
Handle<FixedArray> previous_keys(previous_enum_cache->keys(),
a->GetIsolate());
Handle<FixedArray> previous_indices(previous_enum_cache->indices(),
@ -208,8 +197,7 @@ TEST(EnumCache) {
CHECK_EQ(c->map().EnumLength(), 3);
CHECK_EQ(cc->map().EnumLength(), 3);
EnumCache enum_cache =
c->map().instance_descriptors(kRelaxedLoad).enum_cache();
EnumCache enum_cache = c->map().instance_descriptors().enum_cache();
CHECK_NE(enum_cache, *factory->empty_enum_cache());
// The keys and indices caches are updated.
CHECK_EQ(enum_cache, *previous_enum_cache);
@ -222,25 +210,20 @@ TEST(EnumCache) {
// The enum cache is shared on the descriptor array of maps {a}, {b} and
// {c} only.
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_NE(cc->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_NE(cc->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_NE(cc->map().instance_descriptors().enum_cache(),
*previous_enum_cache);
CHECK_EQ(a->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(b->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(c->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(a->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(b->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(c->map().instance_descriptors().enum_cache(), enum_cache);
}
// {b} can reuse the existing EnumCache, hence we only need to set the correct
// EnumLength on the map without modifying the cache itself.
previous_enum_cache =
handle(a->map().instance_descriptors(kRelaxedLoad).enum_cache(),
a->GetIsolate());
handle(a->map().instance_descriptors().enum_cache(), a->GetIsolate());
previous_keys = handle(previous_enum_cache->keys(), a->GetIsolate());
previous_indices = handle(previous_enum_cache->indices(), a->GetIsolate());
CompileRun("var s = 0; for (let key in b) { s += b[key] };");
@ -250,8 +233,7 @@ TEST(EnumCache) {
CHECK_EQ(c->map().EnumLength(), 3);
CHECK_EQ(cc->map().EnumLength(), 3);
EnumCache enum_cache =
c->map().instance_descriptors(kRelaxedLoad).enum_cache();
EnumCache enum_cache = c->map().instance_descriptors().enum_cache();
CHECK_NE(enum_cache, *factory->empty_enum_cache());
// The keys and indices caches are not updated.
CHECK_EQ(enum_cache, *previous_enum_cache);
@ -262,18 +244,14 @@ TEST(EnumCache) {
// The enum cache is shared on the descriptor array of maps {a}, {b} and
// {c} only.
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_NE(cc->map().instance_descriptors().enum_cache(),
*factory->empty_enum_cache());
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_NE(cc->map().instance_descriptors(kRelaxedLoad).enum_cache(),
CHECK_NE(cc->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_NE(cc->map().instance_descriptors().enum_cache(),
*previous_enum_cache);
CHECK_EQ(a->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(b->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(c->map().instance_descriptors(kRelaxedLoad).enum_cache(),
enum_cache);
CHECK_EQ(a->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(b->map().instance_descriptors().enum_cache(), enum_cache);
CHECK_EQ(c->map().instance_descriptors().enum_cache(), enum_cache);
}
}

View File

@ -70,7 +70,7 @@ TEST_PAIR(TestWrongStrongTypeInIndexedStructField) {
v8::Local<v8::Value> v = CompileRun("({a: 3, b: 4})");
Handle<Object> o = v8::Utils::OpenHandle(*v);
Handle<Map> map(Handle<HeapObject>::cast(o)->map(), i_isolate);
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(i_isolate),
i_isolate);
int offset = DescriptorArray::OffsetOfDescriptorAt(1) +
DescriptorArray::kEntryKeyOffset;
@ -102,7 +102,7 @@ TEST_PAIR(TestWrongWeakTypeInIndexedStructField) {
v8::Local<v8::Value> v = CompileRun("({a: 3, b: 4})");
Handle<Object> o = v8::Utils::OpenHandle(*v);
Handle<Map> map(Handle<HeapObject>::cast(o)->map(), i_isolate);
Handle<DescriptorArray> descriptors(map->instance_descriptors(kRelaxedLoad),
Handle<DescriptorArray> descriptors(map->instance_descriptors(i_isolate),
i_isolate);
int offset = DescriptorArray::OffsetOfDescriptorAt(0) +
DescriptorArray::kEntryValueOffset;