5 #ifndef V8_HEAP_STORE_BUFFER_H_ 6 #define V8_HEAP_STORE_BUFFER_H_ 8 #include "src/allocation.h" 9 #include "src/base/logging.h" 10 #include "src/base/platform/platform.h" 11 #include "src/cancelable-task.h" 12 #include "src/globals.h" 13 #include "src/heap/gc-tracer.h" 14 #include "src/heap/remembered-set.h" 15 #include "src/heap/slot-set.h" 28 enum StoreBufferMode { IN_GC, NOT_IN_GC };
30 static const int kStoreBuffers = 2;
31 static const int kStoreBufferSize =
32 Max(static_cast<int>(kMinExpectedOSPageSize / kStoreBuffers),
33 1 << (11 + kPointerSizeLog2));
34 static const int kStoreBufferMask = kStoreBufferSize - 1;
35 static const intptr_t kDeletionTag = 1;
37 V8_EXPORT_PRIVATE
static int StoreBufferOverflow(
Isolate* isolate);
39 static void DeleteDuringGarbageCollection(
StoreBuffer* store_buffer,
41 static void InsertDuringGarbageCollection(
StoreBuffer* store_buffer,
53 inline Address* top_address() {
return reinterpret_cast<Address*
>(&top_); }
57 void MoveEntriesToRememberedSet(
int index);
61 void MoveAllEntriesToRememberedSet();
63 inline bool IsDeletionAddress(
Address address)
const {
64 return address & kDeletionTag;
68 return address | kDeletionTag;
72 return address & ~kDeletionTag;
75 inline void InsertDeletionIntoStoreBuffer(
Address start,
Address end);
76 inline void InsertIntoStoreBuffer(
Address slot);
78 void InsertEntry(
Address slot) {
82 insertion_callback(
this, slot);
92 deletion_callback(
this, start, end);
95 void SetMode(StoreBufferMode mode);
99 void ConcurrentlyProcessStoreBuffer();
102 for (
int i = 0;
i < kStoreBuffers;
i++) {
107 return top_ == start_[current_];
110 Heap* heap() {
return heap_; }
126 store_buffer_(store_buffer),
127 tracer_(isolate->heap()->tracer()) {}
128 ~Task()
override =
default;
131 void RunInternal()
override {
132 TRACE_BACKGROUND_GC(tracer_,
133 GCTracer::BackgroundScope::BACKGROUND_STORE_BUFFER);
134 store_buffer_->ConcurrentlyProcessStoreBuffer();
138 DISALLOW_COPY_AND_ASSIGN(Task);
141 StoreBufferMode mode()
const {
return mode_; }
143 void FlipStoreBuffers();
153 Address* start_[kStoreBuffers];
154 Address* limit_[kStoreBuffers];
157 Address* lazy_top_[kStoreBuffers];
169 StoreBufferMode mode_;
182 #endif // V8_HEAP_STORE_BUFFER_H_