From 4ce2adc3263e9556e4c414e682fedc41d376768b Mon Sep 17 00:00:00 2001 From: Dan Elphick Date: Tue, 5 Jun 2018 11:21:35 +0100 Subject: [PATCH] [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 Reviewed-by: Michael Starzinger Cr-Commit-Position: refs/heads/master@{#53518} --- src/compiler/access-info.cc | 2 +- src/heap/mark-compact.cc | 2 +- src/json-parser.cc | 8 +- src/map-updater.cc | 8 +- src/objects-debug.cc | 14 ++-- src/objects-printer.cc | 16 ++-- src/objects.cc | 78 ++++++++++-------- src/objects/map-inl.h | 2 +- src/transitions-inl.h | 5 +- src/transitions.cc | 105 ++++++++++++------------ src/transitions.h | 25 +++--- src/value-serializer.cc | 4 +- test/cctest/heap/test-heap.cc | 36 ++++---- test/cctest/test-code-stub-assembler.cc | 2 +- test/cctest/test-field-type-tracking.cc | 12 +-- test/cctest/test-transitions.cc | 26 +++--- test/cctest/test-transitions.h | 9 +- 17 files changed, 190 insertions(+), 164 deletions(-) diff --git a/src/compiler/access-info.cc b/src/compiler/access-info.cc index 15e9de8e6b..c2b4acece8 100644 --- a/src/compiler/access-info.cc +++ b/src/compiler/access-info.cc @@ -663,7 +663,7 @@ bool AccessInfoFactory::LookupTransition(Handle map, Handle 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 transition_map(transition); diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index b7c119e94d..02e1f0ac19 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -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); } diff --git a/src/json-parser.cc b/src/json-parser.cc index 7da11db9cf..cf33f6b10d 100644 --- a/src/json-parser.cc +++ b/src/json-parser.cc @@ -404,7 +404,7 @@ Handle JsonParser::ParseJsonObject() { Handle 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 JsonParser::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(); diff --git a/src/map-updater.cc b/src/map-updater.cc index f49b226a7b..c451fb1dbe 100644 --- a/src/map-updater.cc +++ b/src/map-updater.cc @@ -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 MapUpdater::FindSplitMap(Handle 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( diff --git a/src/objects-debug.cc b/src/objects-debug.cc index 4d43305a10..a1c64caa47 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -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 { diff --git a/src/objects-printer.cc b/src/objects-printer.cc index db402255e2..3b9b376f80 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -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(object), - &no_gc); + i::Map* map = reinterpret_cast(object); + i::TransitionsAccessor transitions(map->GetIsolate(), map, &no_gc); transitions.PrintTransitionTree(); #endif } diff --git a/src/objects.cc b/src/objects.cc index 23304d0b43..d6a6340338 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -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 object, Handle 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::CopyGeneralizeAllFields(Handle 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, 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 backlog(&zone); backlog.push(this); @@ -4533,7 +4536,7 @@ void Map::UpdateFieldType(int descriptor, Handle 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::TryUpdate(Handle 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 JSObject::PreventExtensionsWithTransition( } Handle old_map(object->map(), isolate); - TransitionsAccessor transitions(old_map); + TransitionsAccessor transitions(isolate, old_map); Map* transition = transitions.SearchSpecial(*transition_marker); if (transition != nullptr) { Handle transition_map(transition, isolate); @@ -9366,7 +9370,7 @@ void Map::ConnectTransition(Handle parent, Handle 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::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::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::CopyAsElementsKind(Handle 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 new_map = CopyForTransition(map, "CopyAsElementsKind"); new_map->set_elements_kind(kind); - Isolate* isolate = map->GetIsolate(); Handle name = isolate->factory()->elements_transition_symbol(); ConnectTransition(map, new_map, name, SPECIAL_TRANSITION); return new_map; @@ -9562,8 +9568,8 @@ Handle Map::AsLanguageMode(Handle initial_map, DCHECK_EQ(LanguageMode::kStrict, shared_info->language_mode()); Handle 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::AsLanguageMode(Handle 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::TransitionToDataProperty(Handle map, Handle 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 transition(maybe_transition); int descriptor = transition->LastAdded(); @@ -9775,7 +9782,6 @@ Handle Map::TransitionToDataProperty(Handle map, Handle 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 type = value->OptimalType(isolate, representation); maybe_map = Map::CopyWithField(map, name, type, attributes, constness, @@ -9880,8 +9886,8 @@ Handle Map::TransitionToAccessorProperty(Isolate* isolate, Handle 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 transition(maybe_transition, isolate); DescriptorArray* descriptors = transition->instance_descriptors(); @@ -9964,10 +9970,11 @@ Handle Map::CopyAddDescriptor(Handle map, TransitionFlag flag) { Handle 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::TransitionToPrototype(Handle map, Handle prototype) { + Isolate* isolate = map->GetIsolate(); Handle 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; diff --git a/src/objects/map-inl.h b/src/objects/map-inl.h index 78a4110a6d..d23d55129d 100644 --- a/src/objects/map-inl.h +++ b/src/objects/map-inl.h @@ -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()); } diff --git a/src/transitions-inl.h b/src/transitions-inl.h index 9a40c13569..d218bdc3c1 100644 --- a/src/transitions-inl.h +++ b/src/transitions-inl.h @@ -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. diff --git a/src/transitions.cc b/src/transitions.cc index 0913a208eb..1bfacd5881 100644 --- a/src/transitions.cc +++ b/src/transitions.cc @@ -58,7 +58,6 @@ bool TransitionsAccessor::HasSimpleTransitionTo(Map* map) { void TransitionsAccessor::Insert(Handle name, Handle 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, Handle target, } // If the flag requires a full TransitionArray, allocate one. Handle 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, Handle 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, Handle target, return; } // Otherwise allocate a full TransitionArray with slack for a new entry. - Handle map(simple_transition); + Handle map(simple_transition, isolate_); Handle 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, Handle 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, Handle 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, Handle target, } // We're gonna need a bigger TransitionArray. - Handle result = isolate->factory()->NewTransitionArray( + Handle result = isolate_->factory()->NewTransitionArray( new_nof, Map::SlackForArraySize(number_of_transitions, kMaxNumberOfTransitions)); @@ -178,8 +177,8 @@ void TransitionsAccessor::Insert(Handle name, Handle 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 TransitionsAccessor::FindTransitionToDataProperty( if (requested_location == kFieldOnly && details.location() != kField) { return MaybeHandle(); } - return Handle(target); + return Handle(target, isolate_); } Handle TransitionsAccessor::ExpectedTransitionKey() { @@ -276,7 +275,7 @@ Handle TransitionsAccessor::ExpectedTransitionKey() { if (details.attributes() != NONE) return Handle::null(); Name* name = GetSimpleTransitionKey(target); if (!name->IsString()) return Handle::null(); - return handle(String::cast(name)); + return handle(String::cast(name), isolate_); } } UNREACHABLE(); @@ -284,7 +283,7 @@ Handle TransitionsAccessor::ExpectedTransitionKey() { Handle 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 prototype, const int header = TransitionArray::kProtoTransitionHeaderSize; - Handle cache(GetPrototypeTransitions()); + Handle 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 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 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 result = - map_->GetIsolate()->factory()->NewTransitionArray(nof); + Handle 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 target(GetSimpleTransition()); + Handle 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(); } diff --git a/src/transitions.h b/src/transitions.h index 386097749e..6e31e916bd 100644 --- a/src/transitions.h +++ b/src/transitions.h @@ -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_handle_(map), map_(*map) { + TransitionsAccessor(Isolate* isolate, Handle 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 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_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 GrowPrototypeTransitionArray( Handle 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); }; diff --git a/src/value-serializer.cc b/src/value-serializer.cc index 75c7a462c2..23adfd2dff 100644 --- a/src/value-serializer.cc +++ b/src/value-serializer.cc @@ -1904,7 +1904,7 @@ Maybe ValueDeserializer::ReadJSObjectProperties( // transition was found. Handle key; Handle target; - TransitionsAccessor transitions(map); + TransitionsAccessor transitions(isolate_, map); Handle expected_key = transitions.ExpectedTransitionKey(); if (!expected_key.is_null() && ReadExpectedString(expected_key)) { key = expected_key; @@ -1917,7 +1917,7 @@ Maybe ValueDeserializer::ReadJSObjectProperties( key = isolate_->factory()->InternalizeString(Handle::cast(key)); // Don't reuse |transitions| because it could be stale. - transitioning = TransitionsAccessor(map) + transitioning = TransitionsAccessor(isolate_, map) .FindTransitionToField(Handle::cast(key)) .ToHandle(&target); } else { diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index a67268e2ba..224b1fa404 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -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 ctx = CcTest::isolate()->GetCurrentContext(); + v8::Isolate* isolate = CcTest::isolate(); + i::Isolate* i_isolate = CcTest::i_isolate(); + v8::HandleScope scope(isolate); + v8::Local 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 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 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 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 diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc index 68a1cb2e87..020fc175f3 100644 --- a/test/cctest/test-code-stub-assembler.cc +++ b/test/cctest/test-code-stub-assembler.cc @@ -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; diff --git a/test/cctest/test-field-type-tracking.cc b/test/cctest/test-field-type-tracking.cc index 814a4e7943..d60f3414cd 100644 --- a/test/cctest/test-field-type-tracking.cc +++ b/test/cctest/test-field-type-tracking.cc @@ -397,8 +397,8 @@ class Expectations { heap_type); Handle 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 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 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". diff --git a/test/cctest/test-transitions.cc b/test/cctest/test-transitions.cc index 6c2c357f42..4e61b43125 100644 --- a/test/cctest/test-transitions.cc +++ b/test/cctest/test-transitions.cc @@ -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(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(i); CHECK_EQ(*attr_maps[i], transitions.SearchTransition(*name, kData, attr)); diff --git a/test/cctest/test-transitions.h b/test/cctest/test-transitions.h index 87613a03be..08c5d2cab2 100644 --- a/test/cctest/test-transitions.h +++ b/test/cctest/test-transitions.h @@ -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) - : TransitionsAccessor(map) {} + TestTransitionsAccessor(Isolate* isolate, Map* map, + DisallowHeapAllocation* no_gc) + : TransitionsAccessor(isolate, map, no_gc) {} + TestTransitionsAccessor(Isolate* isolate, Handle map) + : TransitionsAccessor(isolate, map) {} // Expose internals for tests. bool IsWeakRefEncoding() { return encoding() == kWeakRef; }