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 3 // found in the LICENSE file. 4 5 #ifndef V8_STORE_BUFFER_INL_H_ 6 #define V8_STORE_BUFFER_INL_H_ 7 8 #include "src/heap/heap.h" 9 #include "src/heap/spaces-inl.h" 10 #include "src/heap/store-buffer.h" 11 12 namespace v8 { 13 namespace internal { 14 Mark(Address addr)15void StoreBuffer::Mark(Address addr) { 16 DCHECK(!heap_->code_space()->Contains(addr)); 17 Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top()); 18 *top++ = addr; 19 heap_->set_store_buffer_top(reinterpret_cast<Smi*>(top)); 20 if ((reinterpret_cast<uintptr_t>(top) & kStoreBufferOverflowBit) != 0) { 21 DCHECK(top == limit_); 22 Compact(); 23 } else { 24 DCHECK(top < limit_); 25 } 26 } 27 28 MarkSynchronized(Address addr)29inline void StoreBuffer::MarkSynchronized(Address addr) { 30 base::LockGuard<base::Mutex> lock_guard(&mutex_); 31 Mark(addr); 32 } 33 34 EnterDirectlyIntoStoreBuffer(Address addr)35void StoreBuffer::EnterDirectlyIntoStoreBuffer(Address addr) { 36 if (store_buffer_rebuilding_enabled_) { 37 SLOW_DCHECK(!heap_->code_space()->Contains(addr) && 38 !heap_->new_space()->Contains(addr)); 39 Address* top = old_top_; 40 *top++ = addr; 41 old_top_ = top; 42 old_buffer_is_sorted_ = false; 43 old_buffer_is_filtered_ = false; 44 if (top >= old_limit_) { 45 DCHECK(callback_ != NULL); 46 (*callback_)(heap_, MemoryChunk::FromAnyPointerAddress(heap_, addr), 47 kStoreBufferFullEvent); 48 } 49 } 50 } 51 } // namespace internal 52 } // namespace v8 53 54 #endif // V8_STORE_BUFFER_INL_H_ 55