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

Side by Side Diff: src/sweeper-thread.cc

Issue 11782028: Parallel and concurrent sweeping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 | « src/sweeper-thread.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #include "sweeper-thread.h"
29
30 #include "v8.h"
31
32 #include "isolate.h"
33 #include "v8threads.h"
34
35 namespace v8 {
36 namespace internal {
37
38 SweeperThread::SweeperThread(Isolate* isolate)
39 : Thread("SweeperThread"),
40 isolate_(isolate),
41 heap_(isolate->heap()),
42 collector_(heap_->mark_compact_collector()),
43 start_sweeping_semaphore_(OS::CreateSemaphore(0)),
44 end_sweeping_semaphore_(OS::CreateSemaphore(0)),
45 stop_semaphore_(OS::CreateSemaphore(0)),
46 free_list_old_data_space_(heap_->paged_space(OLD_DATA_SPACE)),
47 free_list_old_pointer_space_(heap_->paged_space(OLD_POINTER_SPACE)),
48 private_free_list_old_data_space_(heap_->paged_space(OLD_DATA_SPACE)),
49 private_free_list_old_pointer_space_(
50 heap_->paged_space(OLD_POINTER_SPACE)) {
51 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
52 }
53
54
55 bool SweeperThread::sweeping_pending_ = false;
56
57
58 void SweeperThread::Run() {
59 Isolate::SetIsolateThreadLocals(isolate_, NULL);
60 while (true) {
61 start_sweeping_semaphore_->Wait();
62
63 if (Acquire_Load(&stop_thread_)) {
64 stop_semaphore_->Signal();
65 return;
66 }
67
68 collector_->SweepInParallel(heap_->old_data_space(),
69 &private_free_list_old_data_space_,
70 &free_list_old_data_space_);
71 collector_->SweepInParallel(heap_->old_pointer_space(),
72 &private_free_list_old_pointer_space_,
73 &free_list_old_pointer_space_);
74 end_sweeping_semaphore_->Signal();
75 }
76 }
77
78 intptr_t SweeperThread::StealMemory(PagedSpace* space) {
79 intptr_t free_bytes = 0;
80 if (space->identity() == OLD_POINTER_SPACE) {
81 free_bytes = space->free_list()->Concatenate(&free_list_old_pointer_space_);
82 space->AddToAccountingStats(free_bytes);
83 } else if (space->identity() == OLD_DATA_SPACE) {
84 free_bytes = space->free_list()->Concatenate(&free_list_old_data_space_);
85 space->AddToAccountingStats(free_bytes);
86 }
87 return free_bytes;
88 }
89
90 void SweeperThread::Stop() {
91 Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
92 start_sweeping_semaphore_->Signal();
93 stop_semaphore_->Wait();
94 }
95
96
97 void SweeperThread::StartSweeping() {
98 start_sweeping_semaphore_->Signal();
99 }
100
101
102 void SweeperThread::WaitForSweeperThread() {
103 end_sweeping_semaphore_->Wait();
104 }
105 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/sweeper-thread.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698