OLD | NEW |
---|---|
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 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1324 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(heap_object); | 1324 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(heap_object); |
1325 Address value_address = cell->ValueAddress(); | 1325 Address value_address = cell->ValueAddress(); |
1326 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | 1326 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); |
1327 } | 1327 } |
1328 } | 1328 } |
1329 | 1329 |
1330 // Scavenge object reachable from the native contexts list directly. | 1330 // Scavenge object reachable from the native contexts list directly. |
1331 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_)); | 1331 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_)); |
1332 | 1332 |
1333 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1333 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1334 | |
1335 while (1) { | |
Michael Starzinger
2012/11/05 10:47:27
Can we rewrite this to not be an infinite loop? I
haraken
2012/11/05 12:42:07
Done.
| |
1336 if (!IterateObjectGroups(&scavenge_visitor)) | |
1337 break; | |
1338 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | |
1339 } | |
1340 isolate()->global_handles()->RemoveObjectGroups(); | |
1341 | |
1334 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( | 1342 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( |
1335 &IsUnscavengedHeapObject); | 1343 &IsUnscavengedHeapObject); |
1336 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( | 1344 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( |
1337 &scavenge_visitor); | 1345 &scavenge_visitor); |
1338 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1346 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1339 | 1347 |
1340 UpdateNewSpaceReferencesInExternalStringTable( | 1348 UpdateNewSpaceReferencesInExternalStringTable( |
1341 &UpdateNewSpaceReferenceInExternalStringTableEntry); | 1349 &UpdateNewSpaceReferenceInExternalStringTableEntry); |
1342 | 1350 |
1343 promotion_queue_.Destroy(); | 1351 promotion_queue_.Destroy(); |
(...skipping 20 matching lines...) Expand all Loading... | |
1364 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1372 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
1365 | 1373 |
1366 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1374 LOG(isolate_, ResourceEvent("scavenge", "end")); |
1367 | 1375 |
1368 gc_state_ = NOT_IN_GC; | 1376 gc_state_ = NOT_IN_GC; |
1369 | 1377 |
1370 scavenges_since_last_idle_round_++; | 1378 scavenges_since_last_idle_round_++; |
1371 } | 1379 } |
1372 | 1380 |
1373 | 1381 |
1382 bool Heap::IterateObjectGroups(ObjectVisitor* scavenge_visitor) { | |
haraken
2012/11/05 06:55:23
Note for review: The logic of this method is copie
Michael Starzinger
2012/11/05 10:47:27
Yes, I realized that. It would be cool to unify th
haraken
2012/11/05 12:42:07
Done.
| |
1383 List<ObjectGroup*>* object_groups = | |
1384 isolate()->global_handles()->object_groups(); | |
1385 | |
1386 int last = 0; | |
1387 bool changed = false; | |
1388 for (int i = 0; i < object_groups->length(); i++) { | |
1389 ObjectGroup* entry = object_groups->at(i); | |
1390 ASSERT(entry != NULL); | |
1391 | |
1392 Object*** objects = entry->objects_; | |
1393 bool group_marked = false; | |
1394 for (size_t j = 0; j < entry->length_; j++) { | |
1395 Object* object = *objects[j]; | |
1396 if (object->IsHeapObject()) { | |
1397 if (!IsUnscavengedHeapObject(this, &object)) { | |
1398 group_marked = true; | |
1399 break; | |
1400 } | |
1401 } | |
1402 } | |
1403 | |
1404 if (!group_marked) { | |
1405 (*object_groups)[last++] = entry; | |
1406 continue; | |
1407 } | |
1408 | |
1409 // An object in the group is marked, so mark as grey all white heap | |
Michael Starzinger
2012/11/05 10:47:27
Can we drop the comment from this copy of the meth
haraken
2012/11/05 12:42:07
Done.
| |
1410 // objects in the group. | |
1411 for (size_t j = 0; j < entry->length_; ++j) { | |
1412 Object* object = *objects[j]; | |
1413 if (object->IsHeapObject()) { | |
1414 scavenge_visitor->VisitPointer(&object); | |
1415 changed = true; | |
1416 } | |
1417 } | |
1418 | |
1419 // Once the entire group has been colored grey, set the object group | |
1420 // to NULL so it won't be processed again. | |
Michael Starzinger
2012/11/05 10:47:27
Likewise.
haraken
2012/11/05 12:42:07
Done.
| |
1421 entry->Dispose(); | |
1422 object_groups->at(i) = NULL; | |
1423 } | |
1424 object_groups->Rewind(last); | |
1425 return changed; | |
1426 } | |
1427 | |
1428 | |
1374 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, | 1429 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, |
1375 Object** p) { | 1430 Object** p) { |
1376 MapWord first_word = HeapObject::cast(*p)->map_word(); | 1431 MapWord first_word = HeapObject::cast(*p)->map_word(); |
1377 | 1432 |
1378 if (!first_word.IsForwardingAddress()) { | 1433 if (!first_word.IsForwardingAddress()) { |
1379 // Unreachable external string can be finalized. | 1434 // Unreachable external string can be finalized. |
1380 heap->FinalizeExternalString(String::cast(*p)); | 1435 heap->FinalizeExternalString(String::cast(*p)); |
1381 return NULL; | 1436 return NULL; |
1382 } | 1437 } |
1383 | 1438 |
(...skipping 5976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7360 static_cast<int>(object_sizes_last_time_[index])); | 7415 static_cast<int>(object_sizes_last_time_[index])); |
7361 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7416 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7362 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7417 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7363 | 7418 |
7364 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7419 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7365 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7420 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7366 ClearObjectStats(); | 7421 ClearObjectStats(); |
7367 } | 7422 } |
7368 | 7423 |
7369 } } // namespace v8::internal | 7424 } } // namespace v8::internal |
OLD | NEW |