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

Side by Side Diff: src/heap/mark-compact.cc

Issue 1345273004: [heap] Add timer scopes to process weak cells and clear non-live references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months 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
« no previous file with comments | « src/heap/gc-tracer.cc ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/heap/mark-compact.h" 5 #include "src/heap/mark-compact.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 if (FLAG_track_gc_object_stats) { 2209 if (FLAG_track_gc_object_stats) {
2210 if (FLAG_trace_gc_object_stats) { 2210 if (FLAG_trace_gc_object_stats) {
2211 heap()->object_stats_->TraceObjectStats(); 2211 heap()->object_stats_->TraceObjectStats();
2212 } 2212 }
2213 heap()->object_stats_->CheckpointObjectStats(); 2213 heap()->object_stats_->CheckpointObjectStats();
2214 } 2214 }
2215 } 2215 }
2216 2216
2217 2217
2218 void MarkCompactCollector::ClearNonLiveReferences() { 2218 void MarkCompactCollector::ClearNonLiveReferences() {
2219 GCTracer::Scope gc_scope(heap()->tracer(),
2220 GCTracer::Scope::MC_NONLIVEREFERENCES);
2219 // Iterate over the map space, setting map transitions that go from 2221 // Iterate over the map space, setting map transitions that go from
2220 // a marked map to an unmarked map to null transitions. This action 2222 // a marked map to an unmarked map to null transitions. This action
2221 // is carried out only on maps of JSObjects and related subtypes. 2223 // is carried out only on maps of JSObjects and related subtypes.
2222 HeapObjectIterator map_iterator(heap()->map_space()); 2224 HeapObjectIterator map_iterator(heap()->map_space());
2223 for (HeapObject* obj = map_iterator.Next(); obj != NULL; 2225 for (HeapObject* obj = map_iterator.Next(); obj != NULL;
2224 obj = map_iterator.Next()) { 2226 obj = map_iterator.Next()) {
2225 Map* map = Map::cast(obj); 2227 Map* map = Map::cast(obj);
2226 2228
2227 if (!map->CanTransition()) continue; 2229 if (!map->CanTransition()) continue;
2228 2230
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 JSWeakCollection* weak_collection = 2504 JSWeakCollection* weak_collection =
2503 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); 2505 reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
2504 weak_collection_obj = weak_collection->next(); 2506 weak_collection_obj = weak_collection->next();
2505 weak_collection->set_next(heap()->undefined_value()); 2507 weak_collection->set_next(heap()->undefined_value());
2506 } 2508 }
2507 heap()->set_encountered_weak_collections(Smi::FromInt(0)); 2509 heap()->set_encountered_weak_collections(Smi::FromInt(0));
2508 } 2510 }
2509 2511
2510 2512
2511 void MarkCompactCollector::ProcessAndClearWeakCells() { 2513 void MarkCompactCollector::ProcessAndClearWeakCells() {
2514 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_WEAKCELL);
2512 Object* weak_cell_obj = heap()->encountered_weak_cells(); 2515 Object* weak_cell_obj = heap()->encountered_weak_cells();
2513 while (weak_cell_obj != Smi::FromInt(0)) { 2516 while (weak_cell_obj != Smi::FromInt(0)) {
2514 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); 2517 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj);
2515 // We do not insert cleared weak cells into the list, so the value 2518 // We do not insert cleared weak cells into the list, so the value
2516 // cannot be a Smi here. 2519 // cannot be a Smi here.
2517 HeapObject* value = HeapObject::cast(weak_cell->value()); 2520 HeapObject* value = HeapObject::cast(weak_cell->value());
2518 if (!MarkCompactCollector::IsMarked(value)) { 2521 if (!MarkCompactCollector::IsMarked(value)) {
2519 // Cells for new-space objects embedded in optimized code are wrapped in 2522 // Cells for new-space objects embedded in optimized code are wrapped in
2520 // WeakCell and put into Heap::weak_object_to_code_table. 2523 // WeakCell and put into Heap::weak_object_to_code_table.
2521 // Such cells do not have any strong references but we want to keep them 2524 // Such cells do not have any strong references but we want to keep them
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
4586 MarkBit mark_bit = Marking::MarkBitFrom(host); 4589 MarkBit mark_bit = Marking::MarkBitFrom(host);
4587 if (Marking::IsBlack(mark_bit)) { 4590 if (Marking::IsBlack(mark_bit)) {
4588 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); 4591 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host);
4589 RecordRelocSlot(&rinfo, target); 4592 RecordRelocSlot(&rinfo, target);
4590 } 4593 }
4591 } 4594 }
4592 } 4595 }
4593 4596
4594 } // namespace internal 4597 } // namespace internal
4595 } // namespace v8 4598 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698