[explicit isolates] Eliminate GetIsolate from transitions.cc
Removes all explicit calls to GetIsolate() in transitions.cc by passing it through calling functions and implicit calls via the single argument Handle constructor and handle function. Unfortunately in the interests of making these changes vaguely manageable, I've also pushed some new GetIsolates down into objects-debug.cc, objects-printer.cc and objects.cc. Bug: v8:7786 Change-Id: I1f98530dec6c004e17dc3336f3cef09fbb446bae Reviewed-on: https://chromium-review.googlesource.com/1085451 Commit-Queue: Dan Elphick <delphick@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#53518}
This commit is contained in:
parent
5eaa03b2d3
commit
4ce2adc326
@ -663,7 +663,7 @@ bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name,
|
||||
PropertyAccessInfo* access_info) {
|
||||
// Check if the {map} has a data transition with the given {name}.
|
||||
Map* transition =
|
||||
TransitionsAccessor(map).SearchTransition(*name, kData, NONE);
|
||||
TransitionsAccessor(isolate_, map).SearchTransition(*name, kData, NONE);
|
||||
if (transition == nullptr) return false;
|
||||
|
||||
Handle<Map> transition_map(transition);
|
||||
|
@ -1708,7 +1708,7 @@ void MarkCompactCollector::ClearPotentialSimpleMapTransition(Map* dead_target) {
|
||||
Map* parent = Map::cast(potential_parent);
|
||||
DisallowHeapAllocation no_gc_obviously;
|
||||
if (non_atomic_marking_state()->IsBlackOrGrey(parent) &&
|
||||
TransitionsAccessor(parent, &no_gc_obviously)
|
||||
TransitionsAccessor(isolate(), parent, &no_gc_obviously)
|
||||
.HasSimpleTransitionTo(dead_target)) {
|
||||
ClearPotentialSimpleMapTransition(parent, dead_target);
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
|
||||
Handle<Map> target;
|
||||
if (seq_one_byte) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
TransitionsAccessor transitions(*map, &no_gc);
|
||||
TransitionsAccessor transitions(isolate(), *map, &no_gc);
|
||||
key = transitions.ExpectedTransitionKey();
|
||||
follow_expected = !key.is_null() && ParseJsonString(key);
|
||||
// If the expected transition hits, follow it.
|
||||
@ -419,9 +419,9 @@ Handle<Object> JsonParser<seq_one_byte>::ParseJsonObject() {
|
||||
if (key.is_null()) return ReportUnexpectedCharacter();
|
||||
|
||||
// If a transition was found, follow it and continue.
|
||||
transitioning =
|
||||
TransitionsAccessor(map).FindTransitionToField(key).ToHandle(
|
||||
&target);
|
||||
transitioning = TransitionsAccessor(isolate(), map)
|
||||
.FindTransitionToField(key)
|
||||
.ToHandle(&target);
|
||||
}
|
||||
if (c0_ != ':') return ReportUnexpectedCharacter();
|
||||
|
||||
|
@ -307,7 +307,7 @@ MapUpdater::State MapUpdater::FindTargetMap() {
|
||||
int root_nof = root_map_->NumberOfOwnDescriptors();
|
||||
for (int i = root_nof; i < old_nof_; ++i) {
|
||||
PropertyDetails old_details = GetDetails(i);
|
||||
Map* transition = TransitionsAccessor(target_map_)
|
||||
Map* transition = TransitionsAccessor(isolate_, target_map_)
|
||||
.SearchTransition(GetKey(i), old_details.kind(),
|
||||
old_details.attributes());
|
||||
if (transition == nullptr) break;
|
||||
@ -393,7 +393,7 @@ MapUpdater::State MapUpdater::FindTargetMap() {
|
||||
// Find the last compatible target map in the transition tree.
|
||||
for (int i = target_nof; i < old_nof_; ++i) {
|
||||
PropertyDetails old_details = GetDetails(i);
|
||||
Map* transition = TransitionsAccessor(target_map_)
|
||||
Map* transition = TransitionsAccessor(isolate_, target_map_)
|
||||
.SearchTransition(GetKey(i), old_details.kind(),
|
||||
old_details.attributes());
|
||||
if (transition == nullptr) break;
|
||||
@ -603,7 +603,7 @@ Handle<Map> MapUpdater::FindSplitMap(Handle<DescriptorArray> descriptors) {
|
||||
Name* name = descriptors->GetKey(i);
|
||||
PropertyDetails details = descriptors->GetDetails(i);
|
||||
Map* next =
|
||||
TransitionsAccessor(current, &no_allocation)
|
||||
TransitionsAccessor(isolate_, current, &no_allocation)
|
||||
.SearchTransition(name, details.kind(), details.attributes());
|
||||
if (next == nullptr) break;
|
||||
DescriptorArray* next_descriptors = next->instance_descriptors();
|
||||
@ -639,7 +639,7 @@ MapUpdater::State MapUpdater::ConstructNewMap() {
|
||||
DCHECK_NE(old_nof_, split_nof);
|
||||
|
||||
PropertyDetails split_details = GetDetails(split_nof);
|
||||
TransitionsAccessor transitions(split_map);
|
||||
TransitionsAccessor transitions(isolate_, split_map);
|
||||
|
||||
// Invalidate a transition target at |key|.
|
||||
Map* maybe_transition = transitions.SearchTransition(
|
||||
|
@ -542,7 +542,8 @@ void JSObject::JSObjectVerify() {
|
||||
|
||||
|
||||
void Map::MapVerify() {
|
||||
Heap* heap = GetHeap();
|
||||
Isolate* isolate = GetIsolate();
|
||||
Heap* heap = isolate->heap();
|
||||
CHECK(!heap->InNewSpace(this));
|
||||
CHECK(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE);
|
||||
CHECK(instance_size() == kVariableSizeSentinel ||
|
||||
@ -554,8 +555,10 @@ void Map::MapVerify() {
|
||||
VerifyHeapPointer(instance_descriptors());
|
||||
SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates());
|
||||
DisallowHeapAllocation no_gc;
|
||||
SLOW_DCHECK(TransitionsAccessor(this, &no_gc).IsSortedNoDuplicates());
|
||||
SLOW_DCHECK(TransitionsAccessor(this, &no_gc).IsConsistentWithBackPointers());
|
||||
SLOW_DCHECK(
|
||||
TransitionsAccessor(isolate, this, &no_gc).IsSortedNoDuplicates());
|
||||
SLOW_DCHECK(TransitionsAccessor(isolate, this, &no_gc)
|
||||
.IsConsistentWithBackPointers());
|
||||
SLOW_DCHECK(!FLAG_unbox_double_fields ||
|
||||
layout_descriptor()->IsConsistentWithMap(this));
|
||||
if (!may_have_interesting_symbols()) {
|
||||
@ -1966,15 +1969,16 @@ bool TransitionArray::IsSortedNoDuplicates(int valid_entries) {
|
||||
PropertyKind prev_kind = kData;
|
||||
PropertyAttributes prev_attributes = NONE;
|
||||
uint32_t prev_hash = 0;
|
||||
Isolate* isolate = GetIsolate();
|
||||
for (int i = 0; i < number_of_transitions(); i++) {
|
||||
Name* key = GetSortedKey(i);
|
||||
uint32_t hash = key->Hash();
|
||||
PropertyKind kind = kData;
|
||||
PropertyAttributes attributes = NONE;
|
||||
if (!TransitionsAccessor::IsSpecialTransition(key)) {
|
||||
if (!TransitionsAccessor::IsSpecialTransition(isolate, key)) {
|
||||
Map* target = GetTarget(i);
|
||||
PropertyDetails details =
|
||||
TransitionsAccessor::GetTargetDetails(key, target);
|
||||
TransitionsAccessor::GetTargetDetails(isolate, key, target);
|
||||
kind = details.kind();
|
||||
attributes = details.attributes();
|
||||
} else {
|
||||
|
@ -769,7 +769,7 @@ void Map::MapPrint(std::ostream& os) { // NOLINT
|
||||
}
|
||||
{
|
||||
DisallowHeapAllocation no_gc;
|
||||
TransitionsAccessor transitions(this, &no_gc);
|
||||
TransitionsAccessor transitions(GetIsolate(), this, &no_gc);
|
||||
int nof_transitions = transitions.NumberOfTransitions();
|
||||
if (nof_transitions > 0) {
|
||||
os << "\n - transitions #" << nof_transitions << ": ";
|
||||
@ -2237,7 +2237,7 @@ void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name* key,
|
||||
} else if (key == heap->strict_function_transition_symbol()) {
|
||||
os << " (transition to strict function)";
|
||||
} else {
|
||||
DCHECK(!IsSpecialTransition(key));
|
||||
DCHECK(!IsSpecialTransition(key->GetIsolate(), key));
|
||||
os << "(transition to ";
|
||||
int descriptor = target->LastAdded();
|
||||
DescriptorArray* descriptors = target->instance_descriptors();
|
||||
@ -2302,7 +2302,7 @@ void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level,
|
||||
ss << Brief(target);
|
||||
os << std::left << std::setw(50) << ss.str() << ": ";
|
||||
|
||||
Heap* heap = key->GetHeap();
|
||||
Heap* heap = isolate_->heap();
|
||||
if (key == heap->nonextensible_symbol()) {
|
||||
os << "to non-extensible";
|
||||
} else if (key == heap->sealed_symbol()) {
|
||||
@ -2320,21 +2320,21 @@ void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level,
|
||||
key->ShortPrint(os);
|
||||
#endif
|
||||
os << " ";
|
||||
DCHECK(!IsSpecialTransition(key));
|
||||
DCHECK(!IsSpecialTransition(isolate_, key));
|
||||
os << "to ";
|
||||
int descriptor = target->LastAdded();
|
||||
DescriptorArray* descriptors = target->instance_descriptors();
|
||||
descriptors->PrintDescriptorDetails(os, descriptor,
|
||||
PropertyDetails::kForTransitions);
|
||||
}
|
||||
TransitionsAccessor transitions(target, no_gc);
|
||||
TransitionsAccessor transitions(isolate_, target, no_gc);
|
||||
transitions.PrintTransitionTree(os, level + 1, no_gc);
|
||||
}
|
||||
}
|
||||
|
||||
void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
|
||||
DisallowHeapAllocation no_gc;
|
||||
TransitionsAccessor ta(map(), &no_gc);
|
||||
TransitionsAccessor ta(GetIsolate(), map(), &no_gc);
|
||||
if (ta.NumberOfTransitions() == 0) return;
|
||||
os << "\n - transitions";
|
||||
ta.PrintTransitions(os);
|
||||
@ -2437,8 +2437,8 @@ extern void _v8_internal_Print_TransitionTree(void* object) {
|
||||
} else {
|
||||
#if defined(DEBUG) || defined(OBJECT_PRINT)
|
||||
i::DisallowHeapAllocation no_gc;
|
||||
i::TransitionsAccessor transitions(reinterpret_cast<i::Map*>(object),
|
||||
&no_gc);
|
||||
i::Map* map = reinterpret_cast<i::Map*>(object);
|
||||
i::TransitionsAccessor transitions(map->GetIsolate(), map, &no_gc);
|
||||
transitions.PrintTransitionTree();
|
||||
#endif
|
||||
}
|
||||
|
@ -3653,7 +3653,7 @@ void HeapObject::RehashBasedOnMap() {
|
||||
DescriptorArray::cast(this)->Sort();
|
||||
break;
|
||||
case TRANSITION_ARRAY_TYPE:
|
||||
TransitionArray::cast(this)->Sort();
|
||||
TransitionArray::cast(this)->Sort(GetIsolate());
|
||||
break;
|
||||
case SMALL_ORDERED_HASH_MAP_TYPE:
|
||||
DCHECK_EQ(0, SmallOrderedHashMap::cast(this)->NumberOfElements());
|
||||
@ -4330,8 +4330,9 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map,
|
||||
old_map->set_owns_descriptors(false);
|
||||
DCHECK(old_map->is_abandoned_prototype_map());
|
||||
// Ensure that no transition was inserted for prototype migrations.
|
||||
DCHECK_EQ(0, TransitionsAccessor(old_map).NumberOfTransitions());
|
||||
DCHECK(new_map->GetBackPointer()->IsUndefined(new_map->GetIsolate()));
|
||||
DCHECK_EQ(0, TransitionsAccessor(old_map->GetIsolate(), old_map)
|
||||
.NumberOfTransitions());
|
||||
DCHECK(new_map->GetBackPointer()->IsUndefined(old_map->GetIsolate()));
|
||||
DCHECK(object->map() != *old_map);
|
||||
}
|
||||
} else {
|
||||
@ -4440,7 +4441,8 @@ Handle<Map> Map::CopyGeneralizeAllFields(Handle<Map> map,
|
||||
void Map::DeprecateTransitionTree() {
|
||||
if (is_deprecated()) return;
|
||||
DisallowHeapAllocation no_gc;
|
||||
TransitionsAccessor transitions(this, &no_gc);
|
||||
Isolate* isolate = GetIsolate();
|
||||
TransitionsAccessor transitions(isolate, this, &no_gc);
|
||||
int num_transitions = transitions.NumberOfTransitions();
|
||||
for (int i = 0; i < num_transitions; ++i) {
|
||||
transitions.GetTarget(i)->DeprecateTransitionTree();
|
||||
@ -4448,10 +4450,10 @@ void Map::DeprecateTransitionTree() {
|
||||
DCHECK(!constructor_or_backpointer()->IsFunctionTemplateInfo());
|
||||
set_is_deprecated(true);
|
||||
if (FLAG_trace_maps) {
|
||||
LOG(GetIsolate(), MapEvent("Deprecate", this, nullptr));
|
||||
LOG(isolate, MapEvent("Deprecate", this, nullptr));
|
||||
}
|
||||
dependent_code()->DeoptimizeDependentCodeGroup(
|
||||
GetIsolate(), DependentCode::kTransitionGroup);
|
||||
isolate, DependentCode::kTransitionGroup);
|
||||
NotifyLeafMapLayoutChange();
|
||||
}
|
||||
|
||||
@ -4525,7 +4527,8 @@ void Map::UpdateFieldType(int descriptor, Handle<Name> name,
|
||||
if (details.location() != kField) return;
|
||||
DCHECK_EQ(kData, details.kind());
|
||||
|
||||
Zone zone(GetIsolate()->allocator(), ZONE_NAME);
|
||||
Isolate* isolate = GetIsolate();
|
||||
Zone zone(isolate->allocator(), ZONE_NAME);
|
||||
ZoneQueue<Map*> backlog(&zone);
|
||||
backlog.push(this);
|
||||
|
||||
@ -4533,7 +4536,7 @@ void Map::UpdateFieldType(int descriptor, Handle<Name> name,
|
||||
Map* current = backlog.front();
|
||||
backlog.pop();
|
||||
|
||||
TransitionsAccessor transitions(current, &no_allocation);
|
||||
TransitionsAccessor transitions(isolate, current, &no_allocation);
|
||||
int num_transitions = transitions.NumberOfTransitions();
|
||||
for (int i = 0; i < num_transitions; ++i) {
|
||||
Map* target = transitions.GetTarget(i);
|
||||
@ -4725,7 +4728,8 @@ MaybeHandle<Map> Map::TryUpdate(Handle<Map> old_map) {
|
||||
|
||||
Map* Map::TryReplayPropertyTransitions(Map* old_map) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
DisallowDeoptimization no_deoptimization(GetIsolate());
|
||||
Isolate* isolate = GetIsolate();
|
||||
DisallowDeoptimization no_deoptimization(isolate);
|
||||
|
||||
int root_nof = NumberOfOwnDescriptors();
|
||||
|
||||
@ -4736,7 +4740,7 @@ Map* Map::TryReplayPropertyTransitions(Map* old_map) {
|
||||
for (int i = root_nof; i < old_nof; ++i) {
|
||||
PropertyDetails old_details = old_descriptors->GetDetails(i);
|
||||
Map* transition =
|
||||
TransitionsAccessor(new_map, &no_allocation)
|
||||
TransitionsAccessor(isolate, new_map, &no_allocation)
|
||||
.SearchTransition(old_descriptors->GetKey(i), old_details.kind(),
|
||||
old_details.attributes());
|
||||
if (transition == nullptr) return nullptr;
|
||||
@ -8510,7 +8514,7 @@ Maybe<bool> JSObject::PreventExtensionsWithTransition(
|
||||
}
|
||||
|
||||
Handle<Map> old_map(object->map(), isolate);
|
||||
TransitionsAccessor transitions(old_map);
|
||||
TransitionsAccessor transitions(isolate, old_map);
|
||||
Map* transition = transitions.SearchSpecial(*transition_marker);
|
||||
if (transition != nullptr) {
|
||||
Handle<Map> transition_map(transition, isolate);
|
||||
@ -9366,7 +9370,7 @@ void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child,
|
||||
LOG(isolate, MapEvent("Transition", *parent, *child, "prototype", *name));
|
||||
}
|
||||
} else {
|
||||
TransitionsAccessor(parent).Insert(name, child, flag);
|
||||
TransitionsAccessor(isolate, parent).Insert(name, child, flag);
|
||||
if (FLAG_trace_maps) {
|
||||
LOG(isolate, MapEvent("Transition", *parent, *child, "", *name));
|
||||
}
|
||||
@ -9389,9 +9393,10 @@ Handle<Map> Map::CopyReplaceDescriptors(
|
||||
result->set_may_have_interesting_symbols(true);
|
||||
}
|
||||
|
||||
Isolate* isolate = map->GetIsolate();
|
||||
if (!map->is_prototype_map()) {
|
||||
if (flag == INSERT_TRANSITION &&
|
||||
TransitionsAccessor(map).CanHaveMoreTransitions()) {
|
||||
TransitionsAccessor(isolate, map).CanHaveMoreTransitions()) {
|
||||
result->InitializeDescriptors(*descriptors, *layout_descriptor);
|
||||
|
||||
DCHECK(!maybe_name.is_null());
|
||||
@ -9408,9 +9413,9 @@ Handle<Map> Map::CopyReplaceDescriptors(
|
||||
// Mirror conditions above that did not call ConnectTransition().
|
||||
(map->is_prototype_map() ||
|
||||
!(flag == INSERT_TRANSITION &&
|
||||
TransitionsAccessor(map).CanHaveMoreTransitions()))) {
|
||||
LOG(map->GetIsolate(), MapEvent("ReplaceDescriptors", *map, *result, reason,
|
||||
maybe_name.is_null() ? nullptr : *name));
|
||||
TransitionsAccessor(isolate, map).CanHaveMoreTransitions()))) {
|
||||
LOG(isolate, MapEvent("ReplaceDescriptors", *map, *result, reason,
|
||||
maybe_name.is_null() ? nullptr : *name));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -9526,15 +9531,16 @@ Handle<Map> Map::CopyAsElementsKind(Handle<Map> map, ElementsKind kind,
|
||||
DCHECK(kind != map->elements_kind());
|
||||
}
|
||||
|
||||
bool insert_transition = flag == INSERT_TRANSITION &&
|
||||
TransitionsAccessor(map).CanHaveMoreTransitions() &&
|
||||
maybe_elements_transition_map == nullptr;
|
||||
Isolate* isolate = map->GetIsolate();
|
||||
bool insert_transition =
|
||||
flag == INSERT_TRANSITION &&
|
||||
TransitionsAccessor(isolate, map).CanHaveMoreTransitions() &&
|
||||
maybe_elements_transition_map == nullptr;
|
||||
|
||||
if (insert_transition) {
|
||||
Handle<Map> new_map = CopyForTransition(map, "CopyAsElementsKind");
|
||||
new_map->set_elements_kind(kind);
|
||||
|
||||
Isolate* isolate = map->GetIsolate();
|
||||
Handle<Name> name = isolate->factory()->elements_transition_symbol();
|
||||
ConnectTransition(map, new_map, name, SPECIAL_TRANSITION);
|
||||
return new_map;
|
||||
@ -9562,8 +9568,8 @@ Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map,
|
||||
DCHECK_EQ(LanguageMode::kStrict, shared_info->language_mode());
|
||||
Handle<Symbol> transition_symbol =
|
||||
isolate->factory()->strict_function_transition_symbol();
|
||||
Map* maybe_transition =
|
||||
TransitionsAccessor(initial_map).SearchSpecial(*transition_symbol);
|
||||
Map* maybe_transition = TransitionsAccessor(isolate, initial_map)
|
||||
.SearchSpecial(*transition_symbol);
|
||||
if (maybe_transition != nullptr) {
|
||||
return handle(maybe_transition, isolate);
|
||||
}
|
||||
@ -9579,7 +9585,7 @@ Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map,
|
||||
map->set_prototype(initial_map->prototype());
|
||||
map->set_construction_counter(initial_map->construction_counter());
|
||||
|
||||
if (TransitionsAccessor(initial_map).CanHaveMoreTransitions()) {
|
||||
if (TransitionsAccessor(isolate, initial_map).CanHaveMoreTransitions()) {
|
||||
Map::ConnectTransition(initial_map, map, transition_symbol,
|
||||
SPECIAL_TRANSITION);
|
||||
}
|
||||
@ -9756,8 +9762,9 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
|
||||
// Migrate to the newest map before storing the property.
|
||||
map = Update(map);
|
||||
|
||||
Map* maybe_transition =
|
||||
TransitionsAccessor(map).SearchTransition(*name, kData, attributes);
|
||||
Isolate* isolate = map->GetIsolate();
|
||||
Map* maybe_transition = TransitionsAccessor(isolate, map)
|
||||
.SearchTransition(*name, kData, attributes);
|
||||
if (maybe_transition != nullptr) {
|
||||
Handle<Map> transition(maybe_transition);
|
||||
int descriptor = transition->LastAdded();
|
||||
@ -9775,7 +9782,6 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
|
||||
if (!FLAG_track_constant_fields && value->IsJSFunction()) {
|
||||
maybe_map = Map::CopyWithConstant(map, name, value, attributes, flag);
|
||||
} else {
|
||||
Isolate* isolate = name->GetIsolate();
|
||||
Representation representation = value->OptimalRepresentation();
|
||||
Handle<FieldType> type = value->OptimalType(isolate, representation);
|
||||
maybe_map = Map::CopyWithField(map, name, type, attributes, constness,
|
||||
@ -9880,8 +9886,8 @@ Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
|
||||
? KEEP_INOBJECT_PROPERTIES
|
||||
: CLEAR_INOBJECT_PROPERTIES;
|
||||
|
||||
Map* maybe_transition =
|
||||
TransitionsAccessor(map).SearchTransition(*name, kAccessor, attributes);
|
||||
Map* maybe_transition = TransitionsAccessor(isolate, map)
|
||||
.SearchTransition(*name, kAccessor, attributes);
|
||||
if (maybe_transition != nullptr) {
|
||||
Handle<Map> transition(maybe_transition, isolate);
|
||||
DescriptorArray* descriptors = transition->instance_descriptors();
|
||||
@ -9964,10 +9970,11 @@ Handle<Map> Map::CopyAddDescriptor(Handle<Map> map,
|
||||
TransitionFlag flag) {
|
||||
Handle<DescriptorArray> descriptors(map->instance_descriptors());
|
||||
|
||||
Isolate* isolate = map->GetIsolate();
|
||||
// Share descriptors only if map owns descriptors and it not an initial map.
|
||||
if (flag == INSERT_TRANSITION && map->owns_descriptors() &&
|
||||
!map->GetBackPointer()->IsUndefined(map->GetIsolate()) &&
|
||||
TransitionsAccessor(map).CanHaveMoreTransitions()) {
|
||||
!map->GetBackPointer()->IsUndefined(isolate) &&
|
||||
TransitionsAccessor(isolate, map).CanHaveMoreTransitions()) {
|
||||
return ShareDescriptor(map, descriptors, descriptor);
|
||||
}
|
||||
|
||||
@ -12379,11 +12386,12 @@ static void StopSlackTracking(Map* map, void* data) {
|
||||
|
||||
void Map::CompleteInobjectSlackTracking() {
|
||||
DisallowHeapAllocation no_gc;
|
||||
Isolate* isolate = GetIsolate();
|
||||
// Has to be an initial map.
|
||||
DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
|
||||
DCHECK(GetBackPointer()->IsUndefined(isolate));
|
||||
|
||||
int slack = UnusedPropertyFields();
|
||||
TransitionsAccessor transitions(this, &no_gc);
|
||||
TransitionsAccessor transitions(isolate, this, &no_gc);
|
||||
transitions.TraverseTransitionTree(&GetMinInobjectSlack, &slack);
|
||||
if (slack != 0) {
|
||||
// Resize the initial map and all maps in its transition tree.
|
||||
@ -15131,11 +15139,13 @@ const char* DependentCode::DependencyGroupName(DependencyGroup group) {
|
||||
|
||||
Handle<Map> Map::TransitionToPrototype(Handle<Map> map,
|
||||
Handle<Object> prototype) {
|
||||
Isolate* isolate = map->GetIsolate();
|
||||
Handle<Map> new_map =
|
||||
TransitionsAccessor(map).GetPrototypeTransition(prototype);
|
||||
TransitionsAccessor(isolate, map).GetPrototypeTransition(prototype);
|
||||
if (new_map.is_null()) {
|
||||
new_map = Copy(map, "TransitionToPrototype");
|
||||
TransitionsAccessor(map).PutPrototypeTransition(prototype, new_map);
|
||||
TransitionsAccessor(isolate, map)
|
||||
.PutPrototypeTransition(prototype, new_map);
|
||||
Map::SetPrototype(new_map, prototype);
|
||||
}
|
||||
return new_map;
|
||||
|
@ -636,7 +636,7 @@ Object* Map::GetBackPointer() const {
|
||||
|
||||
Map* Map::ElementsTransitionMap() {
|
||||
DisallowHeapAllocation no_gc;
|
||||
return TransitionsAccessor(this, &no_gc)
|
||||
return TransitionsAccessor(GetIsolate(), this, &no_gc)
|
||||
.SearchSpecial(GetHeap()->elements_transition_symbol());
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,9 @@ HeapObjectReference** TransitionArray::GetTargetSlot(int transition_number) {
|
||||
}
|
||||
|
||||
// static
|
||||
PropertyDetails TransitionsAccessor::GetTargetDetails(Name* name, Map* target) {
|
||||
DCHECK(!IsSpecialTransition(name));
|
||||
PropertyDetails TransitionsAccessor::GetTargetDetails(Isolate* isolate,
|
||||
Name* name, Map* target) {
|
||||
DCHECK(!IsSpecialTransition(isolate, name));
|
||||
int descriptor = target->LastAdded();
|
||||
DescriptorArray* descriptors = target->instance_descriptors();
|
||||
// Transitions are allowed only for the last added property.
|
||||
|
@ -58,7 +58,6 @@ bool TransitionsAccessor::HasSimpleTransitionTo(Map* map) {
|
||||
void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
SimpleTransitionFlag flag) {
|
||||
DCHECK(!map_handle_.is_null());
|
||||
Isolate* isolate = map_->GetIsolate();
|
||||
target->SetBackPointer(map_);
|
||||
|
||||
// If the map doesn't have any transitions at all yet, install the new one.
|
||||
@ -69,7 +68,7 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
}
|
||||
// If the flag requires a full TransitionArray, allocate one.
|
||||
Handle<TransitionArray> result =
|
||||
isolate->factory()->NewTransitionArray(0, 1);
|
||||
isolate_->factory()->NewTransitionArray(0, 1);
|
||||
ReplaceTransitions(MaybeObject::FromObject(*result));
|
||||
Reload();
|
||||
}
|
||||
@ -80,9 +79,9 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
if (simple_transition != nullptr) {
|
||||
Name* key = GetSimpleTransitionKey(simple_transition);
|
||||
PropertyDetails old_details = GetSimpleTargetDetails(simple_transition);
|
||||
PropertyDetails new_details = is_special_transition
|
||||
? PropertyDetails::Empty()
|
||||
: GetTargetDetails(*name, *target);
|
||||
PropertyDetails new_details =
|
||||
is_special_transition ? PropertyDetails::Empty()
|
||||
: GetTargetDetails(isolate_, *name, *target);
|
||||
if (flag == SIMPLE_PROPERTY_TRANSITION && key->Equals(*name) &&
|
||||
old_details.kind() == new_details.kind() &&
|
||||
old_details.attributes() == new_details.attributes()) {
|
||||
@ -90,9 +89,9 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
return;
|
||||
}
|
||||
// Otherwise allocate a full TransitionArray with slack for a new entry.
|
||||
Handle<Map> map(simple_transition);
|
||||
Handle<Map> map(simple_transition, isolate_);
|
||||
Handle<TransitionArray> result =
|
||||
isolate->factory()->NewTransitionArray(1, 1);
|
||||
isolate_->factory()->NewTransitionArray(1, 1);
|
||||
// Reload state; allocations might have caused it to be cleared.
|
||||
Reload();
|
||||
simple_transition = GetSimpleTransition();
|
||||
@ -117,10 +116,10 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
int number_of_transitions = 0;
|
||||
int new_nof = 0;
|
||||
int insertion_index = kNotFound;
|
||||
DCHECK_EQ(is_special_transition, IsSpecialTransition(*name));
|
||||
DCHECK_EQ(is_special_transition, IsSpecialTransition(isolate_, *name));
|
||||
PropertyDetails details = is_special_transition
|
||||
? PropertyDetails::Empty()
|
||||
: GetTargetDetails(*name, *target);
|
||||
: GetTargetDetails(isolate_, *name, *target);
|
||||
|
||||
{
|
||||
DisallowHeapAllocation no_gc;
|
||||
@ -131,8 +130,8 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
int index =
|
||||
is_special_transition
|
||||
? array->SearchSpecial(Symbol::cast(*name), &insertion_index)
|
||||
: array->Search(details.kind(), *name, details.attributes(),
|
||||
&insertion_index);
|
||||
: array->Search(isolate_, details.kind(), *name,
|
||||
details.attributes(), &insertion_index);
|
||||
// If an existing entry was found, overwrite it and return.
|
||||
if (index != kNotFound) {
|
||||
array->SetRawTarget(index, HeapObjectReference::Weak(*target));
|
||||
@ -158,7 +157,7 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
}
|
||||
|
||||
// We're gonna need a bigger TransitionArray.
|
||||
Handle<TransitionArray> result = isolate->factory()->NewTransitionArray(
|
||||
Handle<TransitionArray> result = isolate_->factory()->NewTransitionArray(
|
||||
new_nof,
|
||||
Map::SlackForArraySize(number_of_transitions, kMaxNumberOfTransitions));
|
||||
|
||||
@ -178,8 +177,8 @@ void TransitionsAccessor::Insert(Handle<Name> name, Handle<Map> target,
|
||||
int index =
|
||||
is_special_transition
|
||||
? array->SearchSpecial(Symbol::cast(*name), &insertion_index)
|
||||
: array->Search(details.kind(), *name, details.attributes(),
|
||||
&insertion_index);
|
||||
: array->Search(isolate_, details.kind(), *name,
|
||||
details.attributes(), &insertion_index);
|
||||
if (index == kNotFound) {
|
||||
++new_nof;
|
||||
} else {
|
||||
@ -220,7 +219,7 @@ Map* TransitionsAccessor::SearchTransition(Name* name, PropertyKind kind,
|
||||
return map;
|
||||
}
|
||||
case kFullTransitionArray: {
|
||||
int transition = transitions()->Search(kind, name, attributes);
|
||||
int transition = transitions()->Search(isolate_, kind, name, attributes);
|
||||
if (transition == kNotFound) return nullptr;
|
||||
return transitions()->GetTarget(transition);
|
||||
}
|
||||
@ -236,9 +235,9 @@ Map* TransitionsAccessor::SearchSpecial(Symbol* name) {
|
||||
}
|
||||
|
||||
// static
|
||||
bool TransitionsAccessor::IsSpecialTransition(Name* name) {
|
||||
bool TransitionsAccessor::IsSpecialTransition(Isolate* isolate, Name* name) {
|
||||
if (!name->IsSymbol()) return false;
|
||||
Heap* heap = name->GetHeap();
|
||||
Heap* heap = isolate->heap();
|
||||
return name == heap->nonextensible_symbol() ||
|
||||
name == heap->sealed_symbol() || name == heap->frozen_symbol() ||
|
||||
name == heap->elements_transition_symbol() ||
|
||||
@ -258,7 +257,7 @@ MaybeHandle<Map> TransitionsAccessor::FindTransitionToDataProperty(
|
||||
if (requested_location == kFieldOnly && details.location() != kField) {
|
||||
return MaybeHandle<Map>();
|
||||
}
|
||||
return Handle<Map>(target);
|
||||
return Handle<Map>(target, isolate_);
|
||||
}
|
||||
|
||||
Handle<String> TransitionsAccessor::ExpectedTransitionKey() {
|
||||
@ -276,7 +275,7 @@ Handle<String> TransitionsAccessor::ExpectedTransitionKey() {
|
||||
if (details.attributes() != NONE) return Handle<String>::null();
|
||||
Name* name = GetSimpleTransitionKey(target);
|
||||
if (!name->IsString()) return Handle<String>::null();
|
||||
return handle(String::cast(name));
|
||||
return handle(String::cast(name), isolate_);
|
||||
}
|
||||
}
|
||||
UNREACHABLE();
|
||||
@ -284,7 +283,7 @@ Handle<String> TransitionsAccessor::ExpectedTransitionKey() {
|
||||
|
||||
Handle<Map> TransitionsAccessor::ExpectedTransitionTarget() {
|
||||
DCHECK(!ExpectedTransitionKey().is_null());
|
||||
return handle(GetTarget(0));
|
||||
return handle(GetTarget(0), isolate_);
|
||||
}
|
||||
|
||||
bool TransitionsAccessor::CanHaveMoreTransitions() {
|
||||
@ -308,7 +307,8 @@ bool TransitionsAccessor::IsMatchingMap(Map* target, Name* name,
|
||||
}
|
||||
|
||||
// static
|
||||
bool TransitionArray::CompactPrototypeTransitionArray(WeakFixedArray* array) {
|
||||
bool TransitionArray::CompactPrototypeTransitionArray(Isolate* isolate,
|
||||
WeakFixedArray* array) {
|
||||
const int header = kProtoTransitionHeaderSize;
|
||||
int number_of_transitions = NumberOfPrototypeTransitions(array);
|
||||
if (number_of_transitions == 0) {
|
||||
@ -328,8 +328,8 @@ bool TransitionArray::CompactPrototypeTransitionArray(WeakFixedArray* array) {
|
||||
}
|
||||
}
|
||||
// Fill slots that became free with undefined value.
|
||||
MaybeObject* undefined = MaybeObject::FromObject(
|
||||
*array->GetIsolate()->factory()->undefined_value());
|
||||
MaybeObject* undefined =
|
||||
MaybeObject::FromObject(*isolate->factory()->undefined_value());
|
||||
for (int i = new_number_of_transitions; i < number_of_transitions; i++) {
|
||||
array->Set(header + i, undefined);
|
||||
}
|
||||
@ -368,16 +368,16 @@ void TransitionsAccessor::PutPrototypeTransition(Handle<Object> prototype,
|
||||
|
||||
const int header = TransitionArray::kProtoTransitionHeaderSize;
|
||||
|
||||
Handle<WeakFixedArray> cache(GetPrototypeTransitions());
|
||||
Handle<WeakFixedArray> cache(GetPrototypeTransitions(), isolate_);
|
||||
int capacity = cache->length() - header;
|
||||
int transitions = TransitionArray::NumberOfPrototypeTransitions(*cache) + 1;
|
||||
|
||||
if (transitions > capacity) {
|
||||
// Grow the array if compacting it doesn't free space.
|
||||
if (!TransitionArray::CompactPrototypeTransitionArray(*cache)) {
|
||||
if (!TransitionArray::CompactPrototypeTransitionArray(isolate_, *cache)) {
|
||||
if (capacity == TransitionArray::kMaxCachedPrototypeTransitions) return;
|
||||
cache = TransitionArray::GrowPrototypeTransitionArray(
|
||||
cache, 2 * transitions, target_map->GetIsolate());
|
||||
cache, 2 * transitions, isolate_);
|
||||
Reload();
|
||||
SetPrototypeTransitions(cache);
|
||||
}
|
||||
@ -403,7 +403,7 @@ Handle<Map> TransitionsAccessor::GetPrototypeTransition(
|
||||
if (!target->IsClearedWeakHeapObject()) {
|
||||
Map* map = Map::cast(target->ToWeakHeapObject());
|
||||
if (map->prototype() == *prototype) {
|
||||
return handle(map);
|
||||
return handle(map, isolate_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -413,7 +413,7 @@ Handle<Map> TransitionsAccessor::GetPrototypeTransition(
|
||||
WeakFixedArray* TransitionsAccessor::GetPrototypeTransitions() {
|
||||
if (encoding() != kFullTransitionArray ||
|
||||
!transitions()->HasPrototypeTransitions()) {
|
||||
return map_->GetHeap()->empty_weak_fixed_array();
|
||||
return isolate_->heap()->empty_weak_fixed_array();
|
||||
}
|
||||
return transitions()->GetPrototypeTransitions();
|
||||
}
|
||||
@ -440,9 +440,9 @@ int TransitionsAccessor::NumberOfTransitions() {
|
||||
return 0; // Make GCC happy.
|
||||
}
|
||||
|
||||
void TransitionArray::Zap() {
|
||||
void TransitionArray::Zap(Isolate* isolate) {
|
||||
MemsetPointer(data_start() + kPrototypeTransitionsIndex,
|
||||
MaybeObject::FromObject(GetHeap()->the_hole_value()),
|
||||
MaybeObject::FromObject(isolate->heap()->the_hole_value()),
|
||||
length() - kPrototypeTransitionsIndex);
|
||||
SetNumberOfTransitions(0);
|
||||
}
|
||||
@ -459,7 +459,7 @@ void TransitionsAccessor::ReplaceTransitions(MaybeObject* new_transitions) {
|
||||
// keep referenced objects alive, so we zap it.
|
||||
// When there is another reference to the array somewhere (e.g. a handle),
|
||||
// not zapping turns from a waste of memory into a source of crashes.
|
||||
old_transitions->Zap();
|
||||
old_transitions->Zap(isolate_);
|
||||
}
|
||||
map_->set_raw_transitions(new_transitions);
|
||||
MarkNeedsReload();
|
||||
@ -474,8 +474,7 @@ void TransitionsAccessor::SetPrototypeTransitions(
|
||||
void TransitionsAccessor::EnsureHasFullTransitionArray() {
|
||||
if (encoding() == kFullTransitionArray) return;
|
||||
int nof = encoding() == kUninitialized ? 0 : 1;
|
||||
Handle<TransitionArray> result =
|
||||
map_->GetIsolate()->factory()->NewTransitionArray(nof);
|
||||
Handle<TransitionArray> result = isolate_->factory()->NewTransitionArray(nof);
|
||||
Reload(); // Reload after possible GC.
|
||||
if (nof == 1) {
|
||||
if (encoding() == kUninitialized) {
|
||||
@ -483,7 +482,7 @@ void TransitionsAccessor::EnsureHasFullTransitionArray() {
|
||||
result->SetNumberOfTransitions(0);
|
||||
} else {
|
||||
// Otherwise populate the new array.
|
||||
Handle<Map> target(GetSimpleTransition());
|
||||
Handle<Map> target(GetSimpleTransition(), isolate_);
|
||||
Name* key = GetSimpleTransitionKey(*target);
|
||||
result->Set(0, key, HeapObjectReference::Weak(*target));
|
||||
}
|
||||
@ -500,7 +499,7 @@ void TransitionsAccessor::TraverseTransitionTreeInternal(
|
||||
break;
|
||||
case kWeakRef: {
|
||||
Map* simple_target = Map::cast(raw_transitions_->ToWeakHeapObject());
|
||||
TransitionsAccessor(simple_target, no_gc)
|
||||
TransitionsAccessor(isolate_, simple_target, no_gc)
|
||||
.TraverseTransitionTreeInternal(callback, data, no_gc);
|
||||
break;
|
||||
}
|
||||
@ -514,12 +513,13 @@ void TransitionsAccessor::TraverseTransitionTreeInternal(
|
||||
DCHECK(target->IsClearedWeakHeapObject() ||
|
||||
target->IsWeakHeapObject());
|
||||
if (target->IsClearedWeakHeapObject()) continue;
|
||||
TransitionsAccessor(Map::cast(target->ToWeakHeapObject()), no_gc)
|
||||
TransitionsAccessor(isolate_, Map::cast(target->ToWeakHeapObject()),
|
||||
no_gc)
|
||||
.TraverseTransitionTreeInternal(callback, data, no_gc);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transitions()->number_of_transitions(); ++i) {
|
||||
TransitionsAccessor(transitions()->GetTarget(i), no_gc)
|
||||
TransitionsAccessor(isolate_, transitions()->GetTarget(i), no_gc)
|
||||
.TraverseTransitionTreeInternal(callback, data, no_gc);
|
||||
}
|
||||
break;
|
||||
@ -539,12 +539,12 @@ void TransitionsAccessor::CheckNewTransitionsAreConsistent(
|
||||
if (target->instance_descriptors() == map_->instance_descriptors()) {
|
||||
Name* key = old_transitions->GetKey(i);
|
||||
int new_target_index;
|
||||
if (IsSpecialTransition(key)) {
|
||||
if (IsSpecialTransition(isolate_, key)) {
|
||||
new_target_index = new_transitions->SearchSpecial(Symbol::cast(key));
|
||||
} else {
|
||||
PropertyDetails details = GetTargetDetails(key, target);
|
||||
new_target_index =
|
||||
new_transitions->Search(details.kind(), key, details.attributes());
|
||||
PropertyDetails details = GetTargetDetails(isolate_, key, target);
|
||||
new_target_index = new_transitions->Search(isolate_, details.kind(),
|
||||
key, details.attributes());
|
||||
}
|
||||
DCHECK_NE(TransitionArray::kNotFound, new_target_index);
|
||||
DCHECK_EQ(target, new_transitions->GetTarget(new_target_index));
|
||||
@ -555,7 +555,8 @@ void TransitionsAccessor::CheckNewTransitionsAreConsistent(
|
||||
|
||||
// Private non-static helper functions (operating on full transition arrays).
|
||||
|
||||
int TransitionArray::SearchDetails(int transition, PropertyKind kind,
|
||||
int TransitionArray::SearchDetails(Isolate* isolate, int transition,
|
||||
PropertyKind kind,
|
||||
PropertyAttributes attributes,
|
||||
int* out_insertion_index) {
|
||||
int nof_transitions = number_of_transitions();
|
||||
@ -565,7 +566,7 @@ int TransitionArray::SearchDetails(int transition, PropertyKind kind,
|
||||
transition++) {
|
||||
Map* target = GetTarget(transition);
|
||||
PropertyDetails target_details =
|
||||
TransitionsAccessor::GetTargetDetails(key, target);
|
||||
TransitionsAccessor::GetTargetDetails(isolate, key, target);
|
||||
|
||||
int cmp = CompareDetails(kind, attributes, target_details.kind(),
|
||||
target_details.attributes());
|
||||
@ -579,16 +580,16 @@ int TransitionArray::SearchDetails(int transition, PropertyKind kind,
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
int TransitionArray::Search(PropertyKind kind, Name* name,
|
||||
int TransitionArray::Search(Isolate* isolate, PropertyKind kind, Name* name,
|
||||
PropertyAttributes attributes,
|
||||
int* out_insertion_index) {
|
||||
int transition = SearchName(name, out_insertion_index);
|
||||
if (transition == kNotFound) return kNotFound;
|
||||
return SearchDetails(transition, kind, attributes, out_insertion_index);
|
||||
return SearchDetails(isolate, transition, kind, attributes,
|
||||
out_insertion_index);
|
||||
}
|
||||
|
||||
void TransitionArray::Sort() {
|
||||
void TransitionArray::Sort(Isolate* isolate) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
// In-place insertion sort.
|
||||
int length = number_of_transitions();
|
||||
@ -597,10 +598,10 @@ void TransitionArray::Sort() {
|
||||
MaybeObject* target = GetRawTarget(i);
|
||||
PropertyKind kind = kData;
|
||||
PropertyAttributes attributes = NONE;
|
||||
if (!TransitionsAccessor::IsSpecialTransition(key)) {
|
||||
if (!TransitionsAccessor::IsSpecialTransition(isolate, key)) {
|
||||
Map* target_map = TransitionsAccessor::GetTargetFromRaw(target);
|
||||
PropertyDetails details =
|
||||
TransitionsAccessor::GetTargetDetails(key, target_map);
|
||||
TransitionsAccessor::GetTargetDetails(isolate, key, target_map);
|
||||
kind = details.kind();
|
||||
attributes = details.attributes();
|
||||
}
|
||||
@ -610,11 +611,11 @@ void TransitionArray::Sort() {
|
||||
MaybeObject* temp_target = GetRawTarget(j);
|
||||
PropertyKind temp_kind = kData;
|
||||
PropertyAttributes temp_attributes = NONE;
|
||||
if (!TransitionsAccessor::IsSpecialTransition(temp_key)) {
|
||||
if (!TransitionsAccessor::IsSpecialTransition(isolate, temp_key)) {
|
||||
Map* temp_target_map =
|
||||
TransitionsAccessor::GetTargetFromRaw(temp_target);
|
||||
PropertyDetails details =
|
||||
TransitionsAccessor::GetTargetDetails(temp_key, temp_target_map);
|
||||
PropertyDetails details = TransitionsAccessor::GetTargetDetails(
|
||||
isolate, temp_key, temp_target_map);
|
||||
temp_kind = details.kind();
|
||||
temp_attributes = details.attributes();
|
||||
}
|
||||
|
@ -37,11 +37,13 @@ namespace internal {
|
||||
// cleared when the map they refer to is not otherwise reachable.
|
||||
class TransitionsAccessor {
|
||||
public:
|
||||
TransitionsAccessor(Map* map, DisallowHeapAllocation* no_gc) : map_(map) {
|
||||
TransitionsAccessor(Isolate* isolate, Map* map, DisallowHeapAllocation* no_gc)
|
||||
: isolate_(isolate), map_(map) {
|
||||
Initialize();
|
||||
USE(no_gc);
|
||||
}
|
||||
explicit TransitionsAccessor(Handle<Map> map) : map_handle_(map), map_(*map) {
|
||||
TransitionsAccessor(Isolate* isolate, Handle<Map> map)
|
||||
: isolate_(isolate), map_handle_(map), map_(*map) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@ -57,7 +59,7 @@ class TransitionsAccessor {
|
||||
Map* SearchSpecial(Symbol* name);
|
||||
// Returns true for non-property transitions like elements kind, or
|
||||
// or frozen/sealed transitions.
|
||||
static bool IsSpecialTransition(Name* name);
|
||||
static bool IsSpecialTransition(Isolate* isolate, Name* name);
|
||||
|
||||
enum RequestedLocation { kAnyLocation, kFieldOnly };
|
||||
MaybeHandle<Map> FindTransitionToDataProperty(
|
||||
@ -78,7 +80,8 @@ class TransitionsAccessor {
|
||||
bool CanHaveMoreTransitions();
|
||||
inline Name* GetKey(int transition_number);
|
||||
inline Map* GetTarget(int transition_number);
|
||||
static inline PropertyDetails GetTargetDetails(Name* name, Map* target);
|
||||
static inline PropertyDetails GetTargetDetails(Isolate* isolate, Name* name,
|
||||
Map* target);
|
||||
|
||||
static bool IsMatchingMap(Map* target, Name* name, PropertyKind kind,
|
||||
PropertyAttributes attributes);
|
||||
@ -177,6 +180,7 @@ class TransitionsAccessor {
|
||||
|
||||
inline TransitionArray* transitions();
|
||||
|
||||
Isolate* isolate_;
|
||||
Handle<Map> map_handle_;
|
||||
Map* map_;
|
||||
MaybeObject* raw_transitions_;
|
||||
@ -230,7 +234,7 @@ class TransitionArray : public WeakFixedArray {
|
||||
bool IsSortedNoDuplicates(int valid_entries = -1);
|
||||
#endif
|
||||
|
||||
void Sort();
|
||||
void Sort(Isolate* isolate);
|
||||
|
||||
#if defined(DEBUG) || defined(OBJECT_PRINT)
|
||||
// For our gdb macros.
|
||||
@ -298,8 +302,8 @@ class TransitionArray : public WeakFixedArray {
|
||||
}
|
||||
|
||||
// Search a transition for a given kind, property name and attributes.
|
||||
int Search(PropertyKind kind, Name* name, PropertyAttributes attributes,
|
||||
int* out_insertion_index = nullptr);
|
||||
int Search(Isolate* isolate, PropertyKind kind, Name* name,
|
||||
PropertyAttributes attributes, int* out_insertion_index = nullptr);
|
||||
|
||||
// Search a non-property transition (like elements kind, observe or frozen
|
||||
// transitions).
|
||||
@ -308,12 +312,13 @@ class TransitionArray : public WeakFixedArray {
|
||||
}
|
||||
// Search a first transition for a given property name.
|
||||
inline int SearchName(Name* name, int* out_insertion_index = nullptr);
|
||||
int SearchDetails(int transition, PropertyKind kind,
|
||||
int SearchDetails(Isolate* isolate, int transition, PropertyKind kind,
|
||||
PropertyAttributes attributes, int* out_insertion_index);
|
||||
|
||||
inline int number_of_transitions() const;
|
||||
|
||||
static bool CompactPrototypeTransitionArray(WeakFixedArray* array);
|
||||
static bool CompactPrototypeTransitionArray(Isolate* isolate,
|
||||
WeakFixedArray* array);
|
||||
|
||||
static Handle<WeakFixedArray> GrowPrototypeTransitionArray(
|
||||
Handle<WeakFixedArray> array, int new_capacity, Isolate* isolate);
|
||||
@ -339,7 +344,7 @@ class TransitionArray : public WeakFixedArray {
|
||||
|
||||
inline void Set(int transition_number, Name* key, MaybeObject* target);
|
||||
|
||||
void Zap();
|
||||
void Zap(Isolate* isolate);
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(TransitionArray);
|
||||
};
|
||||
|
@ -1904,7 +1904,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
|
||||
// transition was found.
|
||||
Handle<Object> key;
|
||||
Handle<Map> target;
|
||||
TransitionsAccessor transitions(map);
|
||||
TransitionsAccessor transitions(isolate_, map);
|
||||
Handle<String> expected_key = transitions.ExpectedTransitionKey();
|
||||
if (!expected_key.is_null() && ReadExpectedString(expected_key)) {
|
||||
key = expected_key;
|
||||
@ -1917,7 +1917,7 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
|
||||
key =
|
||||
isolate_->factory()->InternalizeString(Handle<String>::cast(key));
|
||||
// Don't reuse |transitions| because it could be stale.
|
||||
transitioning = TransitionsAccessor(map)
|
||||
transitioning = TransitionsAccessor(isolate_, map)
|
||||
.FindTransitionToField(Handle<String>::cast(key))
|
||||
.ToHandle(&target);
|
||||
} else {
|
||||
|
@ -2703,10 +2703,9 @@ TEST(OptimizedAllocationArrayLiterals) {
|
||||
CHECK(CcTest::heap()->InNewSpace(o->elements()));
|
||||
}
|
||||
|
||||
|
||||
static int CountMapTransitions(Map* map) {
|
||||
static int CountMapTransitions(i::Isolate* isolate, Map* map) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
return TransitionsAccessor(map, &no_gc).NumberOfTransitions();
|
||||
return TransitionsAccessor(isolate, map, &no_gc).NumberOfTransitions();
|
||||
}
|
||||
|
||||
|
||||
@ -2720,8 +2719,10 @@ TEST(Regress1465) {
|
||||
FLAG_trace_incremental_marking = true;
|
||||
FLAG_retain_maps_for_n_gc = 0;
|
||||
CcTest::InitializeVM();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
i::Isolate* i_isolate = CcTest::i_isolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Local<v8::Context> ctx = isolate->GetCurrentContext();
|
||||
static const int transitions_count = 256;
|
||||
|
||||
CompileRun("function F() {}");
|
||||
@ -2740,7 +2741,7 @@ TEST(Regress1465) {
|
||||
CcTest::global()->Get(ctx, v8_str("root")).ToLocalChecked()));
|
||||
|
||||
// Count number of live transitions before marking.
|
||||
int transitions_before = CountMapTransitions(root->map());
|
||||
int transitions_before = CountMapTransitions(i_isolate, root->map());
|
||||
CompileRun("%DebugPrint(root);");
|
||||
CHECK_EQ(transitions_count, transitions_before);
|
||||
|
||||
@ -2749,7 +2750,7 @@ TEST(Regress1465) {
|
||||
|
||||
// Count number of live transitions after marking. Note that one transition
|
||||
// is left, because 'o' still holds an instance of one transition target.
|
||||
int transitions_after = CountMapTransitions(root->map());
|
||||
int transitions_after = CountMapTransitions(i_isolate, root->map());
|
||||
CompileRun("%DebugPrint(root);");
|
||||
CHECK_EQ(1, transitions_after);
|
||||
}
|
||||
@ -2796,6 +2797,7 @@ TEST(TransitionArrayShrinksDuringAllocToZero) {
|
||||
FLAG_stress_incremental_marking = false;
|
||||
FLAG_allow_natives_syntax = true;
|
||||
CcTest::InitializeVM();
|
||||
i::Isolate* i_isolate = CcTest::i_isolate();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
static const int transitions_count = 10;
|
||||
CompileRun("function F() { }");
|
||||
@ -2804,7 +2806,7 @@ TEST(TransitionArrayShrinksDuringAllocToZero) {
|
||||
Handle<JSObject> root = GetByName("root");
|
||||
|
||||
// Count number of live transitions before marking.
|
||||
int transitions_before = CountMapTransitions(root->map());
|
||||
int transitions_before = CountMapTransitions(i_isolate, root->map());
|
||||
CHECK_EQ(transitions_count, transitions_before);
|
||||
|
||||
// Get rid of o
|
||||
@ -2816,8 +2818,8 @@ TEST(TransitionArrayShrinksDuringAllocToZero) {
|
||||
|
||||
// Count number of live transitions after marking. Note that one transition
|
||||
// is left, because 'o' still holds an instance of one transition target.
|
||||
int transitions_after = CountMapTransitions(
|
||||
Map::cast(root->map()->GetBackPointer()));
|
||||
int transitions_after =
|
||||
CountMapTransitions(i_isolate, Map::cast(root->map()->GetBackPointer()));
|
||||
CHECK_EQ(1, transitions_after);
|
||||
}
|
||||
|
||||
@ -2827,6 +2829,7 @@ TEST(TransitionArrayShrinksDuringAllocToOne) {
|
||||
FLAG_stress_incremental_marking = false;
|
||||
FLAG_allow_natives_syntax = true;
|
||||
CcTest::InitializeVM();
|
||||
i::Isolate* i_isolate = CcTest::i_isolate();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
static const int transitions_count = 10;
|
||||
CompileRun("function F() {}");
|
||||
@ -2835,7 +2838,7 @@ TEST(TransitionArrayShrinksDuringAllocToOne) {
|
||||
Handle<JSObject> root = GetByName("root");
|
||||
|
||||
// Count number of live transitions before marking.
|
||||
int transitions_before = CountMapTransitions(root->map());
|
||||
int transitions_before = CountMapTransitions(i_isolate, root->map());
|
||||
CHECK_EQ(transitions_count, transitions_before);
|
||||
|
||||
root = GetByName("root");
|
||||
@ -2844,8 +2847,8 @@ TEST(TransitionArrayShrinksDuringAllocToOne) {
|
||||
|
||||
// Count number of live transitions after marking. Note that one transition
|
||||
// is left, because 'o' still holds an instance of one transition target.
|
||||
int transitions_after = CountMapTransitions(
|
||||
Map::cast(root->map()->GetBackPointer()));
|
||||
int transitions_after =
|
||||
CountMapTransitions(i_isolate, Map::cast(root->map()->GetBackPointer()));
|
||||
CHECK_EQ(2, transitions_after);
|
||||
}
|
||||
|
||||
@ -2855,6 +2858,7 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) {
|
||||
FLAG_stress_incremental_marking = false;
|
||||
FLAG_allow_natives_syntax = true;
|
||||
CcTest::InitializeVM();
|
||||
i::Isolate* i_isolate = CcTest::i_isolate();
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
static const int transitions_count = 10;
|
||||
CompileRun("function F() {}");
|
||||
@ -2863,7 +2867,7 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) {
|
||||
Handle<JSObject> root = GetByName("root");
|
||||
|
||||
// Count number of live transitions before marking.
|
||||
int transitions_before = CountMapTransitions(root->map());
|
||||
int transitions_before = CountMapTransitions(i_isolate, root->map());
|
||||
CHECK_EQ(transitions_count, transitions_before);
|
||||
|
||||
root = GetByName("root");
|
||||
@ -2872,8 +2876,8 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) {
|
||||
|
||||
// Count number of live transitions after marking. Note that one transition
|
||||
// is left, because 'o' still holds an instance of one transition target.
|
||||
int transitions_after = CountMapTransitions(
|
||||
Map::cast(root->map()->GetBackPointer()));
|
||||
int transitions_after =
|
||||
CountMapTransitions(i_isolate, Map::cast(root->map()->GetBackPointer()));
|
||||
CHECK_EQ(1, transitions_after);
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
@ -909,7 +909,7 @@ TEST(TransitionLookup) {
|
||||
|
||||
// Ensure we didn't overflow transition array and therefore all the
|
||||
// combinations of cases are covered.
|
||||
CHECK(TransitionsAccessor(root_map).CanHaveMoreTransitions());
|
||||
CHECK(TransitionsAccessor(isolate, root_map).CanHaveMoreTransitions());
|
||||
|
||||
// Now try querying keys.
|
||||
bool positive_lookup_tested = false;
|
||||
|
@ -397,8 +397,8 @@ class Expectations {
|
||||
heap_type);
|
||||
|
||||
Handle<String> name = MakeName("prop", property_index);
|
||||
Map* target =
|
||||
TransitionsAccessor(map).SearchTransition(*name, kData, attributes);
|
||||
Map* target = TransitionsAccessor(isolate_, map)
|
||||
.SearchTransition(*name, kData, attributes);
|
||||
CHECK_NOT_NULL(target);
|
||||
return handle(target);
|
||||
}
|
||||
@ -2153,8 +2153,8 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
|
||||
}
|
||||
|
||||
Handle<String> name = MakeName("prop", i);
|
||||
Map* target =
|
||||
TransitionsAccessor(map2).SearchTransition(*name, kData, NONE);
|
||||
Map* target = TransitionsAccessor(isolate, map2)
|
||||
.SearchTransition(*name, kData, NONE);
|
||||
CHECK_NOT_NULL(target);
|
||||
map2 = handle(target);
|
||||
}
|
||||
@ -2177,13 +2177,13 @@ TEST(ReconfigurePropertySplitMapTransitionsOverflow) {
|
||||
|
||||
// Fill in transition tree of |map2| so that it can't have more transitions.
|
||||
for (int i = 0; i < TransitionsAccessor::kMaxNumberOfTransitions; i++) {
|
||||
CHECK(TransitionsAccessor(map2).CanHaveMoreTransitions());
|
||||
CHECK(TransitionsAccessor(isolate, map2).CanHaveMoreTransitions());
|
||||
Handle<String> name = MakeName("foo", i);
|
||||
Map::CopyWithField(map2, name, any_type, NONE, PropertyConstness::kMutable,
|
||||
Representation::Smi(), INSERT_TRANSITION)
|
||||
.ToHandleChecked();
|
||||
}
|
||||
CHECK(!TransitionsAccessor(map2).CanHaveMoreTransitions());
|
||||
CHECK(!TransitionsAccessor(isolate, map2).CanHaveMoreTransitions());
|
||||
|
||||
// Try to update |map|, since there is no place for propX transition at |map2|
|
||||
// |map| should become "copy-generalized".
|
||||
|
@ -45,11 +45,11 @@ TEST(TransitionArray_SimpleFieldTransitions) {
|
||||
CHECK(map0->raw_transitions()->IsSmi());
|
||||
|
||||
{
|
||||
TestTransitionsAccessor transitions(map0);
|
||||
TestTransitionsAccessor transitions(isolate, map0);
|
||||
transitions.Insert(name1, map1, SIMPLE_PROPERTY_TRANSITION);
|
||||
}
|
||||
{
|
||||
TestTransitionsAccessor transitions(map0);
|
||||
TestTransitionsAccessor transitions(isolate, map0);
|
||||
CHECK(transitions.IsWeakRefEncoding());
|
||||
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
|
||||
CHECK_EQ(1, transitions.NumberOfTransitions());
|
||||
@ -59,7 +59,7 @@ TEST(TransitionArray_SimpleFieldTransitions) {
|
||||
transitions.Insert(name2, map2, SIMPLE_PROPERTY_TRANSITION);
|
||||
}
|
||||
{
|
||||
TestTransitionsAccessor transitions(map0);
|
||||
TestTransitionsAccessor transitions(isolate, map0);
|
||||
CHECK(transitions.IsFullTransitionArrayEncoding());
|
||||
|
||||
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
|
||||
@ -102,11 +102,11 @@ TEST(TransitionArray_FullFieldTransitions) {
|
||||
CHECK(map0->raw_transitions()->IsSmi());
|
||||
|
||||
{
|
||||
TestTransitionsAccessor transitions(map0);
|
||||
TestTransitionsAccessor transitions(isolate, map0);
|
||||
transitions.Insert(name1, map1, PROPERTY_TRANSITION);
|
||||
}
|
||||
{
|
||||
TestTransitionsAccessor transitions(map0);
|
||||
TestTransitionsAccessor transitions(isolate, map0);
|
||||
CHECK(transitions.IsFullTransitionArrayEncoding());
|
||||
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
|
||||
CHECK_EQ(1, transitions.NumberOfTransitions());
|
||||
@ -116,7 +116,7 @@ TEST(TransitionArray_FullFieldTransitions) {
|
||||
transitions.Insert(name2, map2, PROPERTY_TRANSITION);
|
||||
}
|
||||
{
|
||||
TestTransitionsAccessor transitions(map0);
|
||||
TestTransitionsAccessor transitions(isolate, map0);
|
||||
CHECK(transitions.IsFullTransitionArrayEncoding());
|
||||
|
||||
CHECK_EQ(*map1, transitions.SearchTransition(*name1, kData, attributes));
|
||||
@ -160,10 +160,10 @@ TEST(TransitionArray_DifferentFieldNames) {
|
||||
names[i] = name;
|
||||
maps[i] = map;
|
||||
|
||||
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
}
|
||||
|
||||
TransitionsAccessor transitions(map0);
|
||||
TransitionsAccessor transitions(isolate, map0);
|
||||
for (int i = 0; i < PROPS_COUNT; i++) {
|
||||
CHECK_EQ(*maps[i],
|
||||
transitions.SearchTransition(*names[i], kData, attributes));
|
||||
@ -208,11 +208,11 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributesSimple) {
|
||||
.ToHandleChecked();
|
||||
attr_maps[i] = map;
|
||||
|
||||
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
}
|
||||
|
||||
// Ensure that transitions for |name| field are valid.
|
||||
TransitionsAccessor transitions(map0);
|
||||
TransitionsAccessor transitions(isolate, map0);
|
||||
for (int i = 0; i < ATTRS_COUNT; i++) {
|
||||
PropertyAttributes attributes = static_cast<PropertyAttributes>(i);
|
||||
CHECK_EQ(*attr_maps[i],
|
||||
@ -252,7 +252,7 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
|
||||
names[i] = name;
|
||||
maps[i] = map;
|
||||
|
||||
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
}
|
||||
|
||||
const int ATTRS_COUNT = (READ_ONLY | DONT_ENUM | DONT_DELETE) + 1;
|
||||
@ -271,11 +271,11 @@ TEST(TransitionArray_SameFieldNamesDifferentAttributes) {
|
||||
.ToHandleChecked();
|
||||
attr_maps[i] = map;
|
||||
|
||||
TransitionsAccessor(map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
TransitionsAccessor(isolate, map0).Insert(name, map, PROPERTY_TRANSITION);
|
||||
}
|
||||
|
||||
// Ensure that transitions for |name| field are valid.
|
||||
TransitionsAccessor transitions(map0);
|
||||
TransitionsAccessor transitions(isolate, map0);
|
||||
for (int i = 0; i < ATTRS_COUNT; i++) {
|
||||
PropertyAttributes attr = static_cast<PropertyAttributes>(i);
|
||||
CHECK_EQ(*attr_maps[i], transitions.SearchTransition(*name, kData, attr));
|
||||
|
@ -12,10 +12,11 @@ namespace internal {
|
||||
|
||||
class TestTransitionsAccessor : public TransitionsAccessor {
|
||||
public:
|
||||
TestTransitionsAccessor(Map* map, DisallowHeapAllocation* no_gc)
|
||||
: TransitionsAccessor(map, no_gc) {}
|
||||
explicit TestTransitionsAccessor(Handle<Map> map)
|
||||
: TransitionsAccessor(map) {}
|
||||
TestTransitionsAccessor(Isolate* isolate, Map* map,
|
||||
DisallowHeapAllocation* no_gc)
|
||||
: TransitionsAccessor(isolate, map, no_gc) {}
|
||||
TestTransitionsAccessor(Isolate* isolate, Handle<Map> map)
|
||||
: TransitionsAccessor(isolate, map) {}
|
||||
|
||||
// Expose internals for tests.
|
||||
bool IsWeakRefEncoding() { return encoding() == kWeakRef; }
|
||||
|
Loading…
Reference in New Issue
Block a user