Retain maps that have live prototypes.

BUG=v8:3664
LOG=NO

Review URL: https://codereview.chromium.org/1009343002

Cr-Commit-Position: refs/heads/master@{#27233}
This commit is contained in:
ulan 2015-03-17 03:52:00 -07:00 committed by Commit bot
parent ca3abde2fa
commit d4cd05e6df
2 changed files with 15 additions and 1 deletions

View File

@ -2153,7 +2153,16 @@ void MarkCompactCollector::RetainMaps() {
// be created. Do not retain this map.
continue;
}
new_age = age - 1;
Object* prototype = map->prototype();
if (prototype->IsHeapObject() &&
!Marking::MarkBitFrom(HeapObject::cast(prototype)).Get()) {
// The prototype is not marked, age the map.
new_age = age - 1;
} else {
// The prototype and the constructor are marked, this map keeps only
// transition tree alive, not JSObjects. Do not age the map.
new_age = age;
}
MarkObject(map, map_mark);
} else {
new_age = FLAG_retain_maps_for_n_gc;

View File

@ -5101,6 +5101,11 @@ void CheckMapRetainingFor(int n) {
{
HandleScope inner_scope(isolate);
Handle<Map> map = Map::Create(isolate, 1);
v8::Local<v8::Value> result =
CompileRun("(function () { return {x : 10}; })();");
Handle<JSObject> proto =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
map->set_prototype(*proto);
heap->AddRetainedMap(map);
weak_cell = inner_scope.CloseAndEscape(Map::WeakCellForMap(map));
}