Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/heap.cc

Issue 11085015: Allow collection of DOM objects in minor GC cycles. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: All comments addressed Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/global-handles.cc ('K') | « src/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 // Copy objects reachable from the code flushing candidates list. 1330 // Copy objects reachable from the code flushing candidates list.
1331 MarkCompactCollector* collector = mark_compact_collector(); 1331 MarkCompactCollector* collector = mark_compact_collector();
1332 if (collector->is_code_flushing_enabled()) { 1332 if (collector->is_code_flushing_enabled()) {
1333 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); 1333 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor);
1334 } 1334 }
1335 1335
1336 // Scavenge object reachable from the native contexts list directly. 1336 // Scavenge object reachable from the native contexts list directly.
1337 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_)); 1337 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_));
1338 1338
1339 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); 1339 new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
1340
1341 while (IterateObjectGroups(&scavenge_visitor)) {
1342 new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
1343 }
1344 isolate()->global_handles()->RemoveObjectGroups();
1345
1340 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( 1346 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles(
1341 &IsUnscavengedHeapObject); 1347 &IsUnscavengedHeapObject);
1342 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( 1348 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots(
1343 &scavenge_visitor); 1349 &scavenge_visitor);
1344 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); 1350 new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
1345 1351
1346 UpdateNewSpaceReferencesInExternalStringTable( 1352 UpdateNewSpaceReferencesInExternalStringTable(
1347 &UpdateNewSpaceReferenceInExternalStringTableEntry); 1353 &UpdateNewSpaceReferenceInExternalStringTableEntry);
1348 1354
1349 promotion_queue_.Destroy(); 1355 promotion_queue_.Destroy();
(...skipping 20 matching lines...) Expand all
1370 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); 1376 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size()));
1371 1377
1372 LOG(isolate_, ResourceEvent("scavenge", "end")); 1378 LOG(isolate_, ResourceEvent("scavenge", "end"));
1373 1379
1374 gc_state_ = NOT_IN_GC; 1380 gc_state_ = NOT_IN_GC;
1375 1381
1376 scavenges_since_last_idle_round_++; 1382 scavenges_since_last_idle_round_++;
1377 } 1383 }
1378 1384
1379 1385
1386 // TODO(mstarzinger): Unify this method with
1387 // MarkCompactCollector::MarkObjectGroups().
1388 bool Heap::IterateObjectGroups(ObjectVisitor* scavenge_visitor) {
1389 List<ObjectGroup*>* object_groups =
1390 isolate()->global_handles()->object_groups();
1391
1392 int last = 0;
1393 bool changed = false;
1394 for (int i = 0; i < object_groups->length(); i++) {
1395 ObjectGroup* entry = object_groups->at(i);
1396 ASSERT(entry != NULL);
1397
1398 Object*** objects = entry->objects_;
1399 bool group_marked = false;
1400 for (size_t j = 0; j < entry->length_; j++) {
1401 Object* object = *objects[j];
1402 if (object->IsHeapObject()) {
1403 if (!IsUnscavengedHeapObject(this, &object)) {
1404 group_marked = true;
1405 break;
1406 }
1407 }
1408 }
1409
1410 if (!group_marked) {
1411 (*object_groups)[last++] = entry;
1412 continue;
1413 }
1414
1415 for (size_t j = 0; j < entry->length_; ++j) {
1416 Object* object = *objects[j];
1417 if (object->IsHeapObject()) {
1418 scavenge_visitor->VisitPointer(&object);
1419 changed = true;
1420 }
1421 }
1422
1423 entry->Dispose();
1424 object_groups->at(i) = NULL;
1425 }
1426 object_groups->Rewind(last);
1427 return changed;
1428 }
1429
1430
1380 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, 1431 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
1381 Object** p) { 1432 Object** p) {
1382 MapWord first_word = HeapObject::cast(*p)->map_word(); 1433 MapWord first_word = HeapObject::cast(*p)->map_word();
1383 1434
1384 if (!first_word.IsForwardingAddress()) { 1435 if (!first_word.IsForwardingAddress()) {
1385 // Unreachable external string can be finalized. 1436 // Unreachable external string can be finalized.
1386 heap->FinalizeExternalString(String::cast(*p)); 1437 heap->FinalizeExternalString(String::cast(*p));
1387 return NULL; 1438 return NULL;
1388 } 1439 }
1389 1440
(...skipping 6005 matching lines...) Expand 10 before | Expand all | Expand 10 after
7395 static_cast<int>(object_sizes_last_time_[index])); 7446 static_cast<int>(object_sizes_last_time_[index]));
7396 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7447 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7397 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7448 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7398 7449
7399 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7450 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7400 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7451 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7401 ClearObjectStats(); 7452 ClearObjectStats();
7402 } 7453 }
7403 7454
7404 } } // namespace v8::internal 7455 } } // namespace v8::internal
OLDNEW
« src/global-handles.cc ('K') | « src/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698