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/remembered-set.h" |
9 #include "src/heap/spaces-inl.h" | 10 #include "src/heap/spaces-inl.h" |
10 #include "src/heap/store-buffer.h" | 11 #include "src/heap/store-buffer.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 uint32_t StoreBuffer::AddressToSlotSetAndOffset(Address addr, SlotSet** slots) { | |
16 MemoryChunk* chunk = MemoryChunk::FromAddress(addr); | |
17 uintptr_t offset = addr - chunk->address(); | |
18 if (offset < MemoryChunk::kHeaderSize || chunk->owner() == nullptr) { | |
19 chunk = heap_->lo_space()->FindPage(addr); | |
20 offset = addr - chunk->address(); | |
21 } | |
22 if (chunk->old_to_new_slots() == nullptr) { | |
23 chunk->AllocateOldToNewSlots(); | |
24 } | |
25 if (offset < Page::kPageSize) { | |
26 *slots = chunk->old_to_new_slots(); | |
27 } else { | |
28 *slots = &chunk->old_to_new_slots()[offset / Page::kPageSize]; | |
29 offset = offset % Page::kPageSize; | |
30 } | |
31 return static_cast<uint32_t>(offset); | |
32 } | |
33 | |
34 void LocalStoreBuffer::Record(Address addr) { | 16 void LocalStoreBuffer::Record(Address addr) { |
35 if (top_->is_full()) top_ = new Node(top_); | 17 if (top_->is_full()) top_ = new Node(top_); |
36 top_->buffer[top_->count++] = addr; | 18 top_->buffer[top_->count++] = addr; |
37 } | 19 } |
38 | 20 |
39 void LocalStoreBuffer::Process(StoreBuffer* store_buffer) { | 21 void LocalStoreBuffer::Process(StoreBuffer* store_buffer) { |
40 Node* current = top_; | 22 Node* current = top_; |
41 while (current != nullptr) { | 23 while (current != nullptr) { |
42 for (int i = 0; i < current->count; i++) { | 24 for (int i = 0; i < current->count; i++) { |
43 store_buffer->Mark(current->buffer[i]); | 25 Address slot = current->buffer[i]; |
| 26 Page* page = Page::FromAnyPointerAddress(heap_, slot); |
| 27 RememberedSet<OLD_TO_NEW>::Insert(page, slot); |
44 } | 28 } |
45 current = current->next; | 29 current = current->next; |
46 } | 30 } |
47 } | 31 } |
48 | 32 |
49 void StoreBuffer::Mark(Address addr) { | |
50 SlotSet* slots; | |
51 uint32_t offset; | |
52 offset = AddressToSlotSetAndOffset(addr, &slots); | |
53 slots->Insert(offset); | |
54 } | |
55 | |
56 } // namespace internal | 33 } // namespace internal |
57 } // namespace v8 | 34 } // namespace v8 |
58 | 35 |
59 #endif // V8_STORE_BUFFER_INL_H_ | 36 #endif // V8_STORE_BUFFER_INL_H_ |
OLD | NEW |