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

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

Issue 8380038: Speed up debug mode GC. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.h ('k') | src/mark-compact-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 MarkCompactCollector::MarkCompactCollector() : // NOLINT 58 MarkCompactCollector::MarkCompactCollector() : // NOLINT
59 #ifdef DEBUG 59 #ifdef DEBUG
60 state_(IDLE), 60 state_(IDLE),
61 #endif 61 #endif
62 sweep_precisely_(false), 62 sweep_precisely_(false),
63 compacting_(false), 63 compacting_(false),
64 was_marked_incrementally_(false), 64 was_marked_incrementally_(false),
65 collect_maps_(FLAG_collect_maps), 65 collect_maps_(FLAG_collect_maps),
66 tracer_(NULL), 66 tracer_(NULL),
67 migration_slots_buffer_(NULL), 67 migration_slots_buffer_(NULL),
68 #ifdef DEBUG
69 live_young_objects_size_(0),
70 live_old_pointer_objects_size_(0),
71 live_old_data_objects_size_(0),
72 live_code_objects_size_(0),
73 live_map_objects_size_(0),
74 live_cell_objects_size_(0),
75 live_lo_objects_size_(0),
76 live_bytes_(0),
77 #endif
78 heap_(NULL), 68 heap_(NULL),
79 code_flusher_(NULL), 69 code_flusher_(NULL),
80 encountered_weak_maps_(NULL) { } 70 encountered_weak_maps_(NULL) { }
81 71
82 72
83 #ifdef DEBUG 73 #ifdef DEBUG
84 class VerifyMarkingVisitor: public ObjectVisitor { 74 class VerifyMarkingVisitor: public ObjectVisitor {
85 public: 75 public:
86 void VisitPointers(Object** start, Object** end) { 76 void VisitPointers(Object** start, Object** end) {
87 for (Object** current = start; current < end; current++) { 77 for (Object** current = start; current < end; current++) {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 506 }
517 507
518 PagedSpaces spaces; 508 PagedSpaces spaces;
519 for (PagedSpace* space = spaces.next(); 509 for (PagedSpace* space = spaces.next();
520 space != NULL; 510 space != NULL;
521 space = spaces.next()) { 511 space = spaces.next()) {
522 space->PrepareForMarkCompact(); 512 space->PrepareForMarkCompact();
523 } 513 }
524 514
525 #ifdef DEBUG 515 #ifdef DEBUG
526 if (!was_marked_incrementally_) { 516 if (!was_marked_incrementally_ && FLAG_verify_heap) {
527 VerifyMarkbitsAreClean(); 517 VerifyMarkbitsAreClean();
528 } 518 }
529 #endif 519 #endif
530
531 #ifdef DEBUG
532 live_bytes_ = 0;
533 live_young_objects_size_ = 0;
534 live_old_pointer_objects_size_ = 0;
535 live_old_data_objects_size_ = 0;
536 live_code_objects_size_ = 0;
537 live_map_objects_size_ = 0;
538 live_cell_objects_size_ = 0;
539 live_lo_objects_size_ = 0;
540 #endif
541 } 520 }
542 521
543 522
544 void MarkCompactCollector::Finish() { 523 void MarkCompactCollector::Finish() {
545 #ifdef DEBUG 524 #ifdef DEBUG
546 ASSERT(state_ == SWEEP_SPACES || state_ == RELOCATE_OBJECTS); 525 ASSERT(state_ == SWEEP_SPACES || state_ == RELOCATE_OBJECTS);
547 state_ = IDLE; 526 state_ = IDLE;
548 #endif 527 #endif
549 // The stub cache is not traversed during GC; clear the cache to 528 // The stub cache is not traversed during GC; clear the cache to
550 // force lazy re-initialization of it. This must be done after the 529 // force lazy re-initialization of it. This must be done after the
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 } 2148 }
2170 } 2149 }
2171 } 2150 }
2172 // Move to next element in the list. 2151 // Move to next element in the list.
2173 raw_context = context->get(Context::NEXT_CONTEXT_LINK); 2152 raw_context = context->get(Context::NEXT_CONTEXT_LINK);
2174 } 2153 }
2175 ProcessMarkingDeque(); 2154 ProcessMarkingDeque();
2176 } 2155 }
2177 2156
2178 2157
2179 #ifdef DEBUG
2180 void MarkCompactCollector::UpdateLiveObjectCount(HeapObject* obj) {
2181 live_bytes_ += obj->Size();
2182 if (heap()->new_space()->Contains(obj)) {
2183 live_young_objects_size_ += obj->Size();
2184 } else if (heap()->map_space()->Contains(obj)) {
2185 ASSERT(obj->IsMap());
2186 live_map_objects_size_ += obj->Size();
2187 } else if (heap()->cell_space()->Contains(obj)) {
2188 ASSERT(obj->IsJSGlobalPropertyCell());
2189 live_cell_objects_size_ += obj->Size();
2190 } else if (heap()->old_pointer_space()->Contains(obj)) {
2191 live_old_pointer_objects_size_ += obj->Size();
2192 } else if (heap()->old_data_space()->Contains(obj)) {
2193 live_old_data_objects_size_ += obj->Size();
2194 } else if (heap()->code_space()->Contains(obj)) {
2195 live_code_objects_size_ += obj->Size();
2196 } else if (heap()->lo_space()->Contains(obj)) {
2197 live_lo_objects_size_ += obj->Size();
2198 } else {
2199 UNREACHABLE();
2200 }
2201 }
2202 #endif // DEBUG
2203
2204
2205 void MarkCompactCollector::ReattachInitialMaps() { 2158 void MarkCompactCollector::ReattachInitialMaps() {
2206 HeapObjectIterator map_iterator(heap()->map_space()); 2159 HeapObjectIterator map_iterator(heap()->map_space());
2207 for (HeapObject* obj = map_iterator.Next(); 2160 for (HeapObject* obj = map_iterator.Next();
2208 obj != NULL; 2161 obj != NULL;
2209 obj = map_iterator.Next()) { 2162 obj = map_iterator.Next()) {
2210 if (obj->IsFreeSpace()) continue; 2163 if (obj->IsFreeSpace()) continue;
2211 Map* map = Map::cast(obj); 2164 Map* map = Map::cast(obj);
2212 2165
2213 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); 2166 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
2214 if (map->instance_type() < FIRST_JS_RECEIVER_TYPE) continue; 2167 if (map->instance_type() < FIRST_JS_RECEIVER_TYPE) continue;
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 3595
3643 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE); 3596 { GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE);
3644 EvacuateNewSpaceAndCandidates(); 3597 EvacuateNewSpaceAndCandidates();
3645 } 3598 }
3646 3599
3647 // ClearNonLiveTransitions depends on precise sweeping of map space to 3600 // ClearNonLiveTransitions depends on precise sweeping of map space to
3648 // detect whether unmarked map became dead in this collection or in one 3601 // detect whether unmarked map became dead in this collection or in one
3649 // of the previous ones. 3602 // of the previous ones.
3650 SweepSpace(heap()->map_space(), PRECISE); 3603 SweepSpace(heap()->map_space(), PRECISE);
3651 3604
3652 ASSERT(live_map_objects_size_ <= heap()->map_space()->Size());
3653
3654 // Deallocate unmarked objects and clear marked bits for marked objects. 3605 // Deallocate unmarked objects and clear marked bits for marked objects.
3655 heap_->lo_space()->FreeUnmarkedObjects(); 3606 heap_->lo_space()->FreeUnmarkedObjects();
3656 } 3607 }
3657 3608
3658 3609
3659 void MarkCompactCollector::EnableCodeFlushing(bool enable) { 3610 void MarkCompactCollector::EnableCodeFlushing(bool enable) {
3660 if (enable) { 3611 if (enable) {
3661 if (code_flusher_ != NULL) return; 3612 if (code_flusher_ != NULL) return;
3662 code_flusher_ = new CodeFlusher(heap()->isolate()); 3613 code_flusher_ = new CodeFlusher(heap()->isolate());
3663 } else { 3614 } else {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3823 while (buffer != NULL) { 3774 while (buffer != NULL) {
3824 SlotsBuffer* next_buffer = buffer->next(); 3775 SlotsBuffer* next_buffer = buffer->next();
3825 DeallocateBuffer(buffer); 3776 DeallocateBuffer(buffer);
3826 buffer = next_buffer; 3777 buffer = next_buffer;
3827 } 3778 }
3828 *buffer_address = NULL; 3779 *buffer_address = NULL;
3829 } 3780 }
3830 3781
3831 3782
3832 } } // namespace v8::internal 3783 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.h ('k') | src/mark-compact-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698