diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-02-03 09:06:03 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-02-03 09:07:02 -0800 |
commit | c7cb4daa25966e4f9af3c6d5499d762736454da9 (patch) | |
tree | 27c6541f5a1207eb74797ed63a43126c9bf2ba81 /deps/v8/src/mark-compact.cc | |
parent | c723acc72192334a62bea6ff4baa33aab0da50ad (diff) | |
download | node-c7cb4daa25966e4f9af3c6d5499d762736454da9.tar.gz |
Upgrade V8 to 2.1.0
Diffstat (limited to 'deps/v8/src/mark-compact.cc')
-rw-r--r-- | deps/v8/src/mark-compact.cc | 76 |
1 files changed, 46 insertions, 30 deletions
diff --git a/deps/v8/src/mark-compact.cc b/deps/v8/src/mark-compact.cc index e284b4264..1f2c37d30 100644 --- a/deps/v8/src/mark-compact.cc +++ b/deps/v8/src/mark-compact.cc @@ -129,7 +129,8 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) { #endif PagedSpaces spaces; - while (PagedSpace* space = spaces.next()) { + for (PagedSpace* space = spaces.next(); + space != NULL; space = spaces.next()) { space->PrepareForMarkCompact(compacting_collection_); } @@ -172,7 +173,7 @@ void MarkCompactCollector::Finish() { int old_gen_used = 0; OldSpaces spaces; - while (OldSpace* space = spaces.next()) { + for (OldSpace* space = spaces.next(); space != NULL; space = spaces.next()) { old_gen_recoverable += space->Waste() + space->AvailableFree(); old_gen_used += space->Size(); } @@ -475,8 +476,8 @@ void MarkCompactCollector::MarkDescriptorArray( void MarkCompactCollector::CreateBackPointers() { HeapObjectIterator iterator(Heap::map_space()); - while (iterator.has_next()) { - Object* next_object = iterator.next(); + for (HeapObject* next_object = iterator.next(); + next_object != NULL; next_object = iterator.next()) { if (next_object->IsMap()) { // Could also be ByteArray on free list. Map* map = Map::cast(next_object); if (map->instance_type() >= FIRST_JS_OBJECT_TYPE && @@ -509,8 +510,7 @@ static void ScanOverflowedObjects(T* it) { // so that we don't waste effort pointlessly scanning for objects. ASSERT(!marking_stack.is_full()); - while (it->has_next()) { - HeapObject* object = it->next(); + for (HeapObject* object = it->next(); object != NULL; object = it->next()) { if (object->IsOverflowed()) { object->ClearOverflow(); ASSERT(object->IsMarked()); @@ -793,8 +793,9 @@ void MarkCompactCollector::ClearNonLiveTransitions() { // scan the descriptor arrays of those maps, not all maps. // All of these actions are carried out only on maps of JSObjects // and related subtypes. - while (map_iterator.has_next()) { - Map* map = reinterpret_cast<Map*>(map_iterator.next()); + for (HeapObject* obj = map_iterator.next(); + obj != NULL; obj = map_iterator.next()) { + Map* map = reinterpret_cast<Map*>(obj); if (!map->IsMarked() && map->IsByteArray()) continue; ASSERT(SafeIsMap(map)); @@ -969,12 +970,6 @@ inline void EncodeForwardingAddressInPagedSpace(HeapObject* old_object, inline void IgnoreNonLiveObject(HeapObject* object) {} -// A code deletion event is logged for non-live code objects. -inline void LogNonLiveCodeObject(HeapObject* object) { - if (object->IsCode()) LOG(CodeDeleteEvent(object->address())); -} - - // Function template that, given a range of addresses (eg, a semispace or a // paged space page), iterates through the objects in the range to clear // mark bits and compute and encode forwarding addresses. As a side effect, @@ -1122,10 +1117,7 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) { is_previous_alive = true; } } else { - if (object->IsCode()) { - // Notify the logger that compiled code has been collected. - LOG(CodeDeleteEvent(Code::cast(object)->address())); - } + MarkCompactCollector::ReportDeleteIfNeeded(object); if (is_previous_alive) { // Transition from live to free. free_start = current; is_previous_alive = false; @@ -1204,7 +1196,7 @@ void MarkCompactCollector::EncodeForwardingAddresses() { // Compute the forwarding pointers in each space. EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldPointerSpace, - IgnoreNonLiveObject>( + ReportDeleteIfNeeded>( Heap::old_pointer_space()); EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldDataSpace, @@ -1212,7 +1204,7 @@ void MarkCompactCollector::EncodeForwardingAddresses() { Heap::old_data_space()); EncodeForwardingAddressesInPagedSpace<MCAllocateFromCodeSpace, - LogNonLiveCodeObject>( + ReportDeleteIfNeeded>( Heap::code_space()); EncodeForwardingAddressesInPagedSpace<MCAllocateFromCellSpace, @@ -1291,6 +1283,7 @@ class MapCompact { MapIterator it; HeapObject* o = it.next(); for (; o != first_map_to_evacuate_; o = it.next()) { + ASSERT(o != NULL); Map* map = reinterpret_cast<Map*>(o); ASSERT(!map->IsMarked()); ASSERT(!map->IsOverflowed()); @@ -1316,10 +1309,8 @@ class MapCompact { void UpdateMapPointersInLargeObjectSpace() { LargeObjectIterator it(Heap::lo_space()); - while (true) { - if (!it.has_next()) break; - UpdateMapPointersInObject(it.next()); - } + for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) + UpdateMapPointersInObject(obj); } void Finish() { @@ -1362,8 +1353,8 @@ class MapCompact { static Map* NextMap(MapIterator* it, HeapObject* last, bool live) { while (true) { - ASSERT(it->has_next()); HeapObject* next = it->next(); + ASSERT(next != NULL); if (next == last) return NULL; ASSERT(!next->IsOverflowed()); @@ -1452,8 +1443,9 @@ class MapCompact { if (!FLAG_enable_slow_asserts) return; - while (map_to_evacuate_it_.has_next()) - ASSERT(FreeListNode::IsFreeListNode(map_to_evacuate_it_.next())); + for (HeapObject* obj = map_to_evacuate_it_.next(); + obj != NULL; obj = map_to_evacuate_it_.next()) + ASSERT(FreeListNode::IsFreeListNode(obj)); } #endif }; @@ -1486,7 +1478,8 @@ void MarkCompactCollector::SweepSpaces() { map_compact.FinishMapSpace(); PagedSpaces spaces; - while (PagedSpace* space = spaces.next()) { + for (PagedSpace* space = spaces.next(); + space != NULL; space = spaces.next()) { if (space == Heap::map_space()) continue; map_compact.UpdateMapPointersInPagedSpace(space); } @@ -1661,7 +1654,8 @@ void MarkCompactCollector::UpdatePointers() { // Large objects do not move, the map word can be updated directly. LargeObjectIterator it(Heap::lo_space()); - while (it.has_next()) UpdatePointersInNewObject(it.next()); + for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) + UpdatePointersInNewObject(obj); USE(live_maps); USE(live_pointer_olds); @@ -1825,7 +1819,8 @@ void MarkCompactCollector::RelocateObjects() { Page::set_rset_state(Page::IN_USE); #endif PagedSpaces spaces; - while (PagedSpace* space = spaces.next()) space->MCCommitRelocationInfo(); + for (PagedSpace* space = spaces.next(); space != NULL; space = spaces.next()) + space->MCCommitRelocationInfo(); } @@ -1906,6 +1901,11 @@ int MarkCompactCollector::RelocateOldNonCodeObject(HeapObject* obj, ASSERT(!HeapObject::FromAddress(new_addr)->IsCode()); + HeapObject* copied_to = HeapObject::FromAddress(new_addr); + if (copied_to->IsJSFunction()) { + LOG(FunctionMoveEvent(old_addr, new_addr)); + } + return obj_size; } @@ -1986,6 +1986,11 @@ int MarkCompactCollector::RelocateNewObject(HeapObject* obj) { } #endif + HeapObject* copied_to = HeapObject::FromAddress(new_addr); + if (copied_to->IsJSFunction()) { + LOG(FunctionMoveEvent(old_addr, new_addr)); + } + return obj_size; } @@ -2001,4 +2006,15 @@ void MarkCompactCollector::RebuildRSets() { Heap::RebuildRSets(); } + +void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj) { +#ifdef ENABLE_LOGGING_AND_PROFILING + if (obj->IsCode()) { + LOG(CodeDeleteEvent(obj->address())); + } else if (obj->IsJSFunction()) { + LOG(FunctionDeleteEvent(obj->address())); + } +#endif +} + } } // namespace v8::internal |