Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef V8_STORE_BUFFER_INL_H_ | 5 #ifndef V8_STORE_BUFFER_INL_H_ |
| 6 #define V8_STORE_BUFFER_INL_H_ | 6 #define V8_STORE_BUFFER_INL_H_ |
| 7 | 7 |
| 8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
| 9 #include "src/heap/spaces-inl.h" | 9 #include "src/heap/spaces-inl.h" |
| 10 #include "src/heap/store-buffer.h" | 10 #include "src/heap/store-buffer.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 void StoreBuffer::Mark(Address addr) { | 15 uint32_t StoreBuffer::SlotAddressToOffset(Address addr, SlotSet** slots) { |
|
Michael Lippautz
2016/01/22 08:03:49
Maybe rename to AddressToSlotSetAndOffset, as it's
ulan
2016/01/28 19:07:22
Done.
| |
| 16 DCHECK(!heap_->code_space()->Contains(addr)); | 16 MemoryChunk* chunk = MemoryChunk::FromAddress(addr); |
| 17 Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top()); | 17 Space* owner = chunk->owner(); |
| 18 *top++ = addr; | 18 if (owner == NULL) { |
|
Michael Lippautz
2016/01/22 08:03:49
nullptr
ulan
2016/01/28 19:07:22
Done.
| |
| 19 heap_->set_store_buffer_top(reinterpret_cast<Smi*>(top)); | 19 chunk = heap_->lo_space()->FindPage(addr); |
| 20 if ((reinterpret_cast<uintptr_t>(top) & kStoreBufferOverflowBit) != 0) { | 20 } |
| 21 DCHECK(top == limit_); | 21 uintptr_t offset = addr - chunk->address(); |
| 22 Compact(); | 22 if (chunk->old_to_new_slots() == nullptr) { |
| 23 chunk->AllocateOldToNewSlots(); | |
| 24 } | |
| 25 if (offset < Page::kPageSize) { | |
| 26 *slots = chunk->old_to_new_slots(); | |
| 23 } else { | 27 } else { |
| 24 DCHECK(top < limit_); | 28 *slots = &chunk->old_to_new_slots()[offset / Page::kPageSize]; |
| 29 offset = offset % Page::kPageSize; | |
| 25 } | 30 } |
| 31 return static_cast<uint32_t>(offset); | |
| 26 } | 32 } |
| 27 | 33 |
| 28 | 34 |
| 29 inline void StoreBuffer::MarkSynchronized(Address addr) { | 35 void StoreBuffer::Mark(Address addr) { |
| 36 SlotSet* slots; | |
| 37 uint32_t offset; | |
| 38 offset = SlotAddressToOffset(addr, &slots); | |
| 39 slots->Insert(offset); | |
| 40 } | |
| 41 | |
| 42 | |
| 43 void StoreBuffer::MarkSynchronized(Address addr) { | |
| 30 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 44 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 31 Mark(addr); | 45 Mark(addr); |
| 32 } | 46 } |
| 33 | 47 |
| 34 | |
| 35 void 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 | 48 } // namespace internal |
| 52 } // namespace v8 | 49 } // namespace v8 |
| 53 | 50 |
| 54 #endif // V8_STORE_BUFFER_INL_H_ | 51 #endif // V8_STORE_BUFFER_INL_H_ |
| OLD | NEW |