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

Side by Side Diff: src/heap/store-buffer.cc

Issue 2548213004: [heap] Use callbacks to dispatch store buffer operations. (Closed)
Patch Set: restructure Created 4 years 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
« src/heap/store-buffer.h ('K') | « src/heap/store-buffer.h ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/store-buffer.h" 5 #include "src/heap/store-buffer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/counters.h" 9 #include "src/counters.h"
10 #include "src/heap/incremental-marking.h" 10 #include "src/heap/incremental-marking.h"
11 #include "src/isolate.h" 11 #include "src/isolate.h"
12 #include "src/objects-inl.h" 12 #include "src/objects-inl.h"
13 #include "src/v8.h" 13 #include "src/v8.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 StoreBuffer::StoreBuffer(Heap* heap) 18 StoreBuffer::StoreBuffer(Heap* heap)
19 : heap_(heap), top_(nullptr), current_(0), virtual_memory_(nullptr) { 19 : heap_(heap), top_(nullptr), current_(0), virtual_memory_(nullptr) {
20 for (int i = 0; i < kStoreBuffers; i++) { 20 for (int i = 0; i < kStoreBuffers; i++) {
21 start_[i] = nullptr; 21 start_[i] = nullptr;
22 limit_[i] = nullptr; 22 limit_[i] = nullptr;
23 lazy_top_[i] = nullptr; 23 lazy_top_[i] = nullptr;
24 } 24 }
25 task_running_ = false; 25 task_running_ = false;
26 insertion_callback = &InsertDuringRuntime;
27 deletion_callback = &DeleteDuringRuntime;
26 } 28 }
27 29
28 void StoreBuffer::SetUp() { 30 void StoreBuffer::SetUp() {
29 // Allocate 3x the buffer size, so that we can start the new store buffer 31 // Allocate 3x the buffer size, so that we can start the new store buffer
30 // aligned to 2x the size. This lets us use a bit test to detect the end of 32 // aligned to 2x the size. This lets us use a bit test to detect the end of
31 // the area. 33 // the area.
32 virtual_memory_ = new base::VirtualMemory(kStoreBufferSize * 3); 34 virtual_memory_ = new base::VirtualMemory(kStoreBufferSize * 3);
33 uintptr_t start_as_int = 35 uintptr_t start_as_int =
34 reinterpret_cast<uintptr_t>(virtual_memory_->address()); 36 reinterpret_cast<uintptr_t>(virtual_memory_->address());
35 start_[0] = 37 start_[0] =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 top_ = start_[current_]; 132 top_ = start_[current_];
131 } 133 }
132 134
133 void StoreBuffer::ConcurrentlyProcessStoreBuffer() { 135 void StoreBuffer::ConcurrentlyProcessStoreBuffer() {
134 base::LockGuard<base::Mutex> guard(&mutex_); 136 base::LockGuard<base::Mutex> guard(&mutex_);
135 int other = (current_ + 1) % kStoreBuffers; 137 int other = (current_ + 1) % kStoreBuffers;
136 MoveEntriesToRememberedSet(other); 138 MoveEntriesToRememberedSet(other);
137 task_running_ = false; 139 task_running_ = false;
138 } 140 }
139 141
140 void StoreBuffer::DeleteEntry(Address start, Address end) {
141 // Deletions coming from the GC are directly deleted from the remembered
142 // set. Deletions coming from the runtime are added to the store buffer
143 // to allow concurrent processing.
144 if (heap_->gc_state() == Heap::NOT_IN_GC) {
145 if (top_ + sizeof(Address) * 2 > limit_[current_]) {
146 StoreBufferOverflow(heap_->isolate());
147 }
148 *top_ = MarkDeletionAddress(start);
149 top_++;
150 *top_ = end;
151 top_++;
152 } else {
153 // In GC the store buffer has to be empty at any time.
154 DCHECK(Empty());
155 Page* page = Page::FromAddress(start);
156 if (end) {
157 RememberedSet<OLD_TO_NEW>::RemoveRange(page, start, end,
158 SlotSet::PREFREE_EMPTY_BUCKETS);
159 } else {
160 RememberedSet<OLD_TO_NEW>::Remove(page, start);
161 }
162 }
163 }
164 } // namespace internal 142 } // namespace internal
165 } // namespace v8 143 } // namespace v8
OLDNEW
« src/heap/store-buffer.h ('K') | « src/heap/store-buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698