| 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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 1340 |
| 1341 while (IterateObjectGroups(&scavenge_visitor)) { | 1341 while (isolate()->global_handles()->IterateObjectGroups( |
| 1342 &scavenge_visitor, &IsUnscavengedHeapObject)) { |
| 1342 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1343 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
| 1343 } | 1344 } |
| 1344 isolate()->global_handles()->RemoveObjectGroups(); | 1345 isolate()->global_handles()->RemoveObjectGroups(); |
| 1345 | 1346 |
| 1346 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( | 1347 isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( |
| 1347 &IsUnscavengedHeapObject); | 1348 &IsUnscavengedHeapObject); |
| 1348 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( | 1349 isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( |
| 1349 &scavenge_visitor); | 1350 &scavenge_visitor); |
| 1350 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1351 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
| 1351 | 1352 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1376 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1377 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
| 1377 | 1378 |
| 1378 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1379 LOG(isolate_, ResourceEvent("scavenge", "end")); |
| 1379 | 1380 |
| 1380 gc_state_ = NOT_IN_GC; | 1381 gc_state_ = NOT_IN_GC; |
| 1381 | 1382 |
| 1382 scavenges_since_last_idle_round_++; | 1383 scavenges_since_last_idle_round_++; |
| 1383 } | 1384 } |
| 1384 | 1385 |
| 1385 | 1386 |
| 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 | |
| 1431 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, | 1387 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, |
| 1432 Object** p) { | 1388 Object** p) { |
| 1433 MapWord first_word = HeapObject::cast(*p)->map_word(); | 1389 MapWord first_word = HeapObject::cast(*p)->map_word(); |
| 1434 | 1390 |
| 1435 if (!first_word.IsForwardingAddress()) { | 1391 if (!first_word.IsForwardingAddress()) { |
| 1436 // Unreachable external string can be finalized. | 1392 // Unreachable external string can be finalized. |
| 1437 heap->FinalizeExternalString(String::cast(*p)); | 1393 heap->FinalizeExternalString(String::cast(*p)); |
| 1438 return NULL; | 1394 return NULL; |
| 1439 } | 1395 } |
| 1440 | 1396 |
| (...skipping 5887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7328 static_cast<int>(object_sizes_last_time_[index])); | 7284 static_cast<int>(object_sizes_last_time_[index])); |
| 7329 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7285 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7330 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7286 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7331 | 7287 |
| 7332 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7288 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7333 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7289 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7334 ClearObjectStats(); | 7290 ClearObjectStats(); |
| 7335 } | 7291 } |
| 7336 | 7292 |
| 7337 } } // namespace v8::internal | 7293 } } // namespace v8::internal |
| OLD | NEW |