Commit 1c5d1135 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[cleanup][ptr-compr] Add Isolate parameter to Map::ElementsTransitionMap().

Tbr: yangguo@chromium.org
Bug: v8:9183, v8:8948
Change-Id: I7d68344479c67027be3ef63dec2c927c103b3fa6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1647165
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62025}
parent 04beaf63
......@@ -1636,7 +1636,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
InstallSpeciesGetter(isolate_, array_function);
// Cache the array maps, needed by ArrayConstructorStub
CacheInitialJSArrayMaps(native_context(), initial_map);
CacheInitialJSArrayMaps(isolate_, native_context(), initial_map);
// Set up %ArrayPrototype%.
// The %ArrayPrototype% has TERMINAL_FAST_ELEMENTS_KIND in order to ensure
......
......@@ -132,7 +132,8 @@ class JSArray : public JSObject {
OBJECT_CONSTRUCTORS(JSArray, JSObject);
};
Handle<Object> CacheInitialJSArrayMaps(Handle<Context> native_context,
Handle<Object> CacheInitialJSArrayMaps(Isolate* isolate,
Handle<Context> native_context,
Handle<Map> initial_map);
// The JSArrayIterator describes JavaScript Array Iterators Objects, as
......
......@@ -4991,7 +4991,7 @@ void SetInstancePrototype(Isolate* isolate, Handle<JSFunction> function,
native_context->get(Context::ARRAY_FUNCTION_INDEX), isolate);
if (array_function->IsJSFunction() &&
*function == JSFunction::cast(*array_function)) {
CacheInitialJSArrayMaps(native_context, new_map);
CacheInitialJSArrayMaps(isolate, native_context, new_map);
}
}
......
......@@ -692,13 +692,10 @@ HeapObject Map::GetBackPointer() const {
return GetReadOnlyRoots().undefined_value();
}
Map Map::ElementsTransitionMap() {
Map Map::ElementsTransitionMap(Isolate* isolate) {
DisallowHeapAllocation no_gc;
// TODO(delphick): While it's safe to pass nullptr for Isolate* here as
// SearchSpecial doesn't need it, this is really ugly. Perhaps factor out a
// base class for methods not requiring an Isolate?
return TransitionsAccessor(nullptr, *this, &no_gc)
.SearchSpecial(GetReadOnlyRoots().elements_transition_symbol());
return TransitionsAccessor(isolate, *this, &no_gc)
.SearchSpecial(ReadOnlyRoots(isolate).elements_transition_symbol());
}
Object Map::prototype_info() const {
......
......@@ -1234,9 +1234,9 @@ Map Map::FindElementsKindTransitionedMap(Isolate* isolate,
// Starting from the next existing elements kind transition try to
// replay the property transitions that does not involve instance rewriting
// (ElementsTransitionAndStoreStub does not support that).
for (root_map = root_map.ElementsTransitionMap();
for (root_map = root_map.ElementsTransitionMap(isolate);
!root_map.is_null() && root_map.has_fast_elements();
root_map = root_map.ElementsTransitionMap()) {
root_map = root_map.ElementsTransitionMap(isolate)) {
// If root_map's elements kind doesn't match any of the elements kind in
// the candidates there is no need to do any additional work.
if (!HasElementsKind(candidates, root_map.elements_kind())) continue;
......@@ -1263,7 +1263,7 @@ static Map FindClosestElementsTransition(Isolate* isolate, Map map,
ElementsKind kind = map.elements_kind();
while (kind != to_kind) {
Map next_map = current_map.ElementsTransitionMap();
Map next_map = current_map.ElementsTransitionMap(isolate);
if (next_map.is_null()) return current_map;
kind = next_map.elements_kind();
current_map = next_map;
......@@ -1869,7 +1869,7 @@ Handle<Map> Map::CopyAsElementsKind(Isolate* isolate, Handle<Map> map,
DCHECK_EQ(map->FindRootMap(isolate).NumberOfOwnDescriptors(),
map->NumberOfOwnDescriptors());
maybe_elements_transition_map = map->ElementsTransitionMap();
maybe_elements_transition_map = map->ElementsTransitionMap(isolate);
DCHECK(
maybe_elements_transition_map.is_null() ||
(maybe_elements_transition_map.elements_kind() == DICTIONARY_ELEMENTS &&
......
......@@ -428,7 +428,7 @@ class Map : public HeapObject {
// map with DICTIONARY_ELEMENTS was found in the prototype chain.
bool DictionaryElementsInPrototypeChainOnly(Isolate* isolate);
inline Map ElementsTransitionMap();
inline Map ElementsTransitionMap(Isolate* isolate);
inline FixedArrayBase GetInitialElements() const;
......
......@@ -4500,7 +4500,8 @@ uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
return value;
}
Handle<Object> CacheInitialJSArrayMaps(Handle<Context> native_context,
Handle<Object> CacheInitialJSArrayMaps(Isolate* isolate,
Handle<Context> native_context,
Handle<Map> initial_map) {
// Replace all of the cached initial array maps in the native context with
// the appropriate transitioned elements kind maps.
......@@ -4512,13 +4513,12 @@ Handle<Object> CacheInitialJSArrayMaps(Handle<Context> native_context,
i < kFastElementsKindCount; ++i) {
Handle<Map> new_map;
ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i);
Map maybe_elements_transition = current_map->ElementsTransitionMap();
Map maybe_elements_transition = current_map->ElementsTransitionMap(isolate);
if (!maybe_elements_transition.is_null()) {
new_map = handle(maybe_elements_transition, native_context->GetIsolate());
new_map = handle(maybe_elements_transition, isolate);
} else {
new_map =
Map::CopyAsElementsKind(native_context->GetIsolate(), current_map,
next_kind, INSERT_TRANSITION);
new_map = Map::CopyAsElementsKind(isolate, current_map, next_kind,
INSERT_TRANSITION);
}
DCHECK_EQ(next_kind, new_map->elements_kind());
native_context->set(Context::ArrayMapIndex(next_kind), *new_map);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment