Commit e8f5d29d authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[in-place weak refs] Use in-place weak refs in Context::map_cache

BUG=v8:7308

Change-Id: I940ed715949307abb831d47c197b7e75ed5b0fca
Reviewed-on: https://chromium-review.googlesource.com/1169047
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55019}
parent 6aa2a253
......@@ -3742,27 +3742,24 @@ Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> native_context,
Handle<Object> maybe_cache(native_context->map_cache(), isolate());
if (maybe_cache->IsUndefined(isolate())) {
// Allocate the new map cache for the native context.
maybe_cache = NewFixedArray(kMapCacheSize, TENURED);
maybe_cache = NewWeakFixedArray(kMapCacheSize, TENURED);
native_context->set_map_cache(*maybe_cache);
} else {
// Check to see whether there is a matching element in the cache.
Handle<FixedArray> cache = Handle<FixedArray>::cast(maybe_cache);
Object* result = cache->get(cache_index);
if (result->IsWeakCell()) {
WeakCell* cell = WeakCell::cast(result);
if (!cell->cleared()) {
Map* map = Map::cast(cell->value());
DCHECK(!map->is_dictionary_map());
return handle(map, isolate());
}
Handle<WeakFixedArray> cache = Handle<WeakFixedArray>::cast(maybe_cache);
MaybeObject* result = cache->Get(cache_index);
HeapObject* heap_object;
if (result->ToWeakHeapObject(&heap_object)) {
Map* map = Map::cast(heap_object);
DCHECK(!map->is_dictionary_map());
return handle(map, isolate());
}
}
// Create a new map and add it to the cache.
Handle<FixedArray> cache = Handle<FixedArray>::cast(maybe_cache);
Handle<WeakFixedArray> cache = Handle<WeakFixedArray>::cast(maybe_cache);
Handle<Map> map = Map::Create(isolate(), number_of_properties);
DCHECK(!map->is_dictionary_map());
Handle<WeakCell> cell = NewWeakCell(map);
cache->set(cache_index, *cell);
cache->Set(cache_index, HeapObjectReference::Weak(*map));
return map;
}
......
......@@ -21986,12 +21986,11 @@ THREADED_TEST(ReadOnlyIndexedProperties) {
static int CountLiveMapsInMapCache(i::Context* context) {
i::FixedArray* map_cache = i::FixedArray::cast(context->map_cache());
i::WeakFixedArray* map_cache = i::WeakFixedArray::cast(context->map_cache());
int length = map_cache->length();
int count = 0;
for (int i = 0; i < length; i++) {
i::Object* value = map_cache->get(i);
if (value->IsWeakCell() && !i::WeakCell::cast(value)->cleared()) count++;
if (map_cache->Get(i)->IsWeakHeapObject()) count++;
}
return count;
}
......
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