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

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

Issue 12449008: Consistently unlink evacuation candidates before sweeping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 // 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 3758 matching lines...) Expand 10 before | Expand all | Expand 10 after
3769 3769
3770 int pages_swept = 0; 3770 int pages_swept = 0;
3771 bool lazy_sweeping_active = false; 3771 bool lazy_sweeping_active = false;
3772 bool unused_page_present = false; 3772 bool unused_page_present = false;
3773 bool parallel_sweeping_active = false; 3773 bool parallel_sweeping_active = false;
3774 3774
3775 while (it.has_next()) { 3775 while (it.has_next()) {
3776 Page* p = it.next(); 3776 Page* p = it.next();
3777 3777
3778 ASSERT(p->parallel_sweeping() == 0); 3778 ASSERT(p->parallel_sweeping() == 0);
3779 ASSERT(!p->IsEvacuationCandidate());
3780
3779 // Clear sweeping flags indicating that marking bits are still intact. 3781 // Clear sweeping flags indicating that marking bits are still intact.
3780 p->ClearSweptPrecisely(); 3782 p->ClearSweptPrecisely();
3781 p->ClearSweptConservatively(); 3783 p->ClearSweptConservatively();
3782 3784
3783 if (p->IsEvacuationCandidate()) { 3785 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
3786 // Will be processed in EvacuateNewSpaceAndCandidates.
3784 ASSERT(evacuation_candidates_.length() > 0); 3787 ASSERT(evacuation_candidates_.length() > 0);
3785 continue; 3788 continue;
3786 } 3789 }
3787 3790
3788 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
3789 // Will be processed in EvacuateNewSpaceAndCandidates.
3790 continue;
3791 }
3792
3793 // One unused page is kept, all further are released before sweeping them. 3791 // One unused page is kept, all further are released before sweeping them.
3794 if (p->LiveBytes() == 0) { 3792 if (p->LiveBytes() == 0) {
3795 if (unused_page_present) { 3793 if (unused_page_present) {
3796 if (FLAG_gc_verbose) { 3794 if (FLAG_gc_verbose) {
3797 PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n", 3795 PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n",
3798 reinterpret_cast<intptr_t>(p)); 3796 reinterpret_cast<intptr_t>(p));
3799 } 3797 }
3800 // Adjust unswept free bytes because releasing a page expects said 3798 // Adjust unswept free bytes because releasing a page expects said
3801 // counter to be accurate for unswept pages. 3799 // counter to be accurate for unswept pages.
3802 space->IncreaseUnsweptFreeBytes(p); 3800 space->IncreaseUnsweptFreeBytes(p);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP); 3887 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP);
3890 #ifdef DEBUG 3888 #ifdef DEBUG
3891 state_ = SWEEP_SPACES; 3889 state_ = SWEEP_SPACES;
3892 #endif 3890 #endif
3893 SweeperType how_to_sweep = 3891 SweeperType how_to_sweep =
3894 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE; 3892 FLAG_lazy_sweeping ? LAZY_CONSERVATIVE : CONSERVATIVE;
3895 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE; 3893 if (FLAG_parallel_sweeping) how_to_sweep = PARALLEL_CONSERVATIVE;
3896 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE; 3894 if (FLAG_concurrent_sweeping) how_to_sweep = CONCURRENT_CONSERVATIVE;
3897 if (FLAG_expose_gc) how_to_sweep = CONSERVATIVE; 3895 if (FLAG_expose_gc) how_to_sweep = CONSERVATIVE;
3898 if (sweep_precisely_) how_to_sweep = PRECISE; 3896 if (sweep_precisely_) how_to_sweep = PRECISE;
3897
3898 // Unlink evacuation candidates before sweeper threads access the list of
3899 // pages to avoid race condition.
3900 UnlinkEvacuationCandidates();
3901
3899 // Noncompacting collections simply sweep the spaces to clear the mark 3902 // Noncompacting collections simply sweep the spaces to clear the mark
3900 // bits and free the nonlive blocks (for old and map spaces). We sweep 3903 // bits and free the nonlive blocks (for old and map spaces). We sweep
3901 // the map space last because freeing non-live maps overwrites them and 3904 // the map space last because freeing non-live maps overwrites them and
3902 // the other spaces rely on possibly non-live maps to get the sizes for 3905 // the other spaces rely on possibly non-live maps to get the sizes for
3903 // non-live objects. 3906 // non-live objects.
3904 SequentialSweepingScope scope(this); 3907 SequentialSweepingScope scope(this);
3905 SweepSpace(heap()->old_pointer_space(), how_to_sweep); 3908 SweepSpace(heap()->old_pointer_space(), how_to_sweep);
3906 SweepSpace(heap()->old_data_space(), how_to_sweep); 3909 SweepSpace(heap()->old_data_space(), how_to_sweep);
3907 3910
3908 // Unlink evacuation candidates before sweeper threads access the list of
3909 // pages to avoid race condition.
3910 UnlinkEvacuationCandidates();
3911
3912 if (how_to_sweep == PARALLEL_CONSERVATIVE || 3911 if (how_to_sweep == PARALLEL_CONSERVATIVE ||
3913 how_to_sweep == CONCURRENT_CONSERVATIVE) { 3912 how_to_sweep == CONCURRENT_CONSERVATIVE) {
3914 // TODO(hpayer): fix race with concurrent sweeper 3913 // TODO(hpayer): fix race with concurrent sweeper
3915 StartSweeperThreads(); 3914 StartSweeperThreads();
3916 } 3915 }
3917 3916
3918 if (how_to_sweep == PARALLEL_CONSERVATIVE) { 3917 if (how_to_sweep == PARALLEL_CONSERVATIVE) {
3919 WaitUntilSweepingCompleted(); 3918 WaitUntilSweepingCompleted();
3920 } 3919 }
3921 3920
3922 RemoveDeadInvalidatedCode(); 3921 RemoveDeadInvalidatedCode();
3923 SweepSpace(heap()->code_space(), PRECISE); 3922 SweepSpace(heap()->code_space(), PRECISE);
3924 3923
3925 SweepSpace(heap()->cell_space(), PRECISE); 3924 SweepSpace(heap()->cell_space(), PRECISE);
3926 3925
3927 EvacuateNewSpaceAndCandidates(); 3926 EvacuateNewSpaceAndCandidates();
3928 3927
3929 // ClearNonLiveTransitions depends on precise sweeping of map space to 3928 // ClearNonLiveTransitions depends on precise sweeping of map space to
3930 // detect whether unmarked map became dead in this collection or in one 3929 // detect whether unmarked map became dead in this collection or in one
3931 // of the previous ones. 3930 // of the previous ones.
3932 SweepSpace(heap()->map_space(), PRECISE); 3931 SweepSpace(heap()->map_space(), PRECISE);
3933 3932
3934 // Deallocate unmarked objects and clear marked bits for marked objects. 3933 // Deallocate unmarked objects and clear marked bits for marked objects.
3935 heap_->lo_space()->FreeUnmarkedObjects(); 3934 heap_->lo_space()->FreeUnmarkedObjects();
3936 3935
3936 // Deallocate evacuated candidate pages.
3937 ReleaseEvacuationCandidates(); 3937 ReleaseEvacuationCandidates();
3938 } 3938 }
3939 3939
3940 3940
3941 void MarkCompactCollector::EnableCodeFlushing(bool enable) { 3941 void MarkCompactCollector::EnableCodeFlushing(bool enable) {
3942 #ifdef ENABLE_DEBUGGER_SUPPORT 3942 #ifdef ENABLE_DEBUGGER_SUPPORT
3943 if (heap()->isolate()->debug()->IsLoaded() || 3943 if (heap()->isolate()->debug()->IsLoaded() ||
3944 heap()->isolate()->debug()->has_break_points()) { 3944 heap()->isolate()->debug()->has_break_points()) {
3945 enable = false; 3945 enable = false;
3946 } 3946 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 while (buffer != NULL) { 4128 while (buffer != NULL) {
4129 SlotsBuffer* next_buffer = buffer->next(); 4129 SlotsBuffer* next_buffer = buffer->next();
4130 DeallocateBuffer(buffer); 4130 DeallocateBuffer(buffer);
4131 buffer = next_buffer; 4131 buffer = next_buffer;
4132 } 4132 }
4133 *buffer_address = NULL; 4133 *buffer_address = NULL;
4134 } 4134 }
4135 4135
4136 4136
4137 } } // namespace v8::internal 4137 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698