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

Side by Side Diff: runtime/vm/gc_sweeper.cc

Issue 649743002: - Fine grain locking of free list when sweeping concurrently. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/gc_sweeper.h" 5 #include "vm/gc_sweeper.h"
6 6
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
11 #include "vm/pages.h" 11 #include "vm/pages.h"
12 #include "vm/thread_pool.h" 12 #include "vm/thread_pool.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 bool GCSweeper::SweepPage(HeapPage* page, FreeList* freelist) { 16 bool GCSweeper::SweepPage(HeapPage* page, FreeList* freelist, bool locked) {
17 // Keep track whether this page is still in use. 17 // Keep track whether this page is still in use.
18 bool in_use = false; 18 bool in_use = false;
19 19
20 bool is_executable = (page->type() == HeapPage::kExecutable); 20 bool is_executable = (page->type() == HeapPage::kExecutable);
21 uword start = page->object_start(); 21 uword start = page->object_start();
22 uword end = page->object_end(); 22 uword end = page->object_end();
23 uword current = start; 23 uword current = start;
24 24
25 while (current < end) { 25 while (current < end) {
26 intptr_t obj_size; 26 intptr_t obj_size;
(...skipping 13 matching lines...) Expand all
40 } 40 }
41 // Expand the free block by the size of this object. 41 // Expand the free block by the size of this object.
42 free_end += next_obj->Size(); 42 free_end += next_obj->Size();
43 } 43 }
44 obj_size = free_end - current; 44 obj_size = free_end - current;
45 if (is_executable) { 45 if (is_executable) {
46 memset(reinterpret_cast<void*>(current), 0xcc, obj_size); 46 memset(reinterpret_cast<void*>(current), 0xcc, obj_size);
47 } 47 }
48 if ((current != start) || (free_end != end)) { 48 if ((current != start) || (free_end != end)) {
49 // Only add to the free list if not covering the whole page. 49 // Only add to the free list if not covering the whole page.
50 freelist->FreeLocked(current, obj_size); 50 if (locked) {
51 freelist->FreeLocked(current, obj_size);
52 } else {
53 freelist->Free(current, obj_size);
54 }
51 } 55 }
52 } 56 }
53 current += obj_size; 57 current += obj_size;
54 } 58 }
55 ASSERT(current == end); 59 ASSERT(current == end);
56 60
57 return in_use; 61 return in_use;
58 } 62 }
59 63
60 64
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 virtual void Run() { 109 virtual void Run() {
106 Isolate::SetCurrent(task_isolate_); 110 Isolate::SetCurrent(task_isolate_);
107 GCSweeper sweeper; 111 GCSweeper sweeper;
108 112
109 HeapPage* page = first_; 113 HeapPage* page = first_;
110 HeapPage* prev_page = NULL; 114 HeapPage* prev_page = NULL;
111 115
112 while (page != NULL) { 116 while (page != NULL) {
113 HeapPage* next_page = page->next(); 117 HeapPage* next_page = page->next();
114 ASSERT(page->type() == HeapPage::kData); 118 ASSERT(page->type() == HeapPage::kData);
115 bool page_in_use = true; 119 bool page_in_use = sweeper.SweepPage(page, freelist_, false);
116 {
117 MutexLocker ml(freelist_->mutex());
118 page_in_use = sweeper.SweepPage(page, freelist_);
119 }
120 if (page_in_use) { 120 if (page_in_use) {
121 prev_page = page; 121 prev_page = page;
122 } else { 122 } else {
123 old_space_->FreePage(page, prev_page); 123 old_space_->FreePage(page, prev_page);
124 } 124 }
125 { 125 {
126 // Notify the mutator thread that we have added elements to the free 126 // Notify the mutator thread that we have added elements to the free
127 // list or that more capacity is available. 127 // list or that more capacity is available.
128 MonitorLocker ml(old_space_->tasks_lock()); 128 MonitorLocker ml(old_space_->tasks_lock());
129 ml.Notify(); 129 ml.Notify();
(...skipping 27 matching lines...) Expand all
157 SweeperTask* task = 157 SweeperTask* task =
158 new SweeperTask(isolate->ShallowCopy(), 158 new SweeperTask(isolate->ShallowCopy(),
159 isolate->heap()->old_space(), 159 isolate->heap()->old_space(),
160 first, last, 160 first, last,
161 freelist); 161 freelist);
162 ThreadPool* pool = Dart::thread_pool(); 162 ThreadPool* pool = Dart::thread_pool();
163 pool->Run(task); 163 pool->Run(task);
164 } 164 }
165 165
166 } // namespace dart 166 } // namespace dart
OLDNEW
« runtime/vm/gc_sweeper.h ('K') | « runtime/vm/gc_sweeper.h ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698