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 #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), | 19 : heap_(heap), |
20 top_(nullptr), | 20 top_(nullptr), |
21 start_(nullptr), | 21 start_(nullptr), |
22 limit_(nullptr), | 22 limit_(nullptr), |
23 virtual_memory_(nullptr) {} | 23 virtual_memory_(nullptr) {} |
24 | 24 |
25 void StoreBuffer::SetUp() { | 25 void StoreBuffer::SetUp() { |
26 // Allocate 3x the buffer size, so that we can start the new store buffer | 26 // Allocate 3x the buffer size, so that we can start the new store buffer |
27 // aligned to 2x the size. This lets us use a bit test to detect the end of | 27 // aligned to 2x the size. This lets us use a bit test to detect the end of |
28 // the area. | 28 // the area. |
29 virtual_memory_ = new base::VirtualMemory(kStoreBufferSize * 3); | 29 virtual_memory_ = new base::VirtualMemory(kStoreBufferSize * 2); |
30 uintptr_t start_as_int = | 30 uintptr_t start_as_int = |
31 reinterpret_cast<uintptr_t>(virtual_memory_->address()); | 31 reinterpret_cast<uintptr_t>(virtual_memory_->address()); |
32 start_ = | 32 start_ = reinterpret_cast<Address*>(RoundUp(start_as_int, kStoreBufferSize)); |
33 reinterpret_cast<Address*>(RoundUp(start_as_int, kStoreBufferSize * 2)); | |
34 limit_ = start_ + (kStoreBufferSize / kPointerSize); | 33 limit_ = start_ + (kStoreBufferSize / kPointerSize); |
35 | 34 |
36 DCHECK(reinterpret_cast<Address>(start_) >= virtual_memory_->address()); | 35 DCHECK(reinterpret_cast<Address>(start_) >= virtual_memory_->address()); |
37 DCHECK(reinterpret_cast<Address>(limit_) >= virtual_memory_->address()); | 36 DCHECK(reinterpret_cast<Address>(limit_) >= virtual_memory_->address()); |
38 Address* vm_limit = reinterpret_cast<Address*>( | 37 Address* vm_limit = reinterpret_cast<Address*>( |
39 reinterpret_cast<char*>(virtual_memory_->address()) + | 38 reinterpret_cast<char*>(virtual_memory_->address()) + |
40 virtual_memory_->size()); | 39 virtual_memory_->size()); |
41 DCHECK(start_ <= vm_limit); | 40 DCHECK(start_ <= vm_limit); |
42 DCHECK(limit_ <= vm_limit); | 41 DCHECK(limit_ <= vm_limit); |
43 USE(vm_limit); | 42 USE(vm_limit); |
44 DCHECK((reinterpret_cast<uintptr_t>(limit_) & kStoreBufferOverflowBit) != 0); | 43 DCHECK((reinterpret_cast<uintptr_t>(limit_) & kStoreBufferMask) == 0); |
45 DCHECK((reinterpret_cast<uintptr_t>(limit_ - 1) & kStoreBufferOverflowBit) == | |
46 0); | |
47 | 44 |
48 if (!virtual_memory_->Commit(reinterpret_cast<Address>(start_), | 45 if (!virtual_memory_->Commit(reinterpret_cast<Address>(start_), |
49 kStoreBufferSize, | 46 kStoreBufferSize, |
50 false)) { // Not executable. | 47 false)) { // Not executable. |
51 V8::FatalProcessOutOfMemory("StoreBuffer::SetUp"); | 48 V8::FatalProcessOutOfMemory("StoreBuffer::SetUp"); |
52 } | 49 } |
53 top_ = start_; | 50 top_ = start_; |
54 } | 51 } |
55 | 52 |
56 | 53 |
(...skipping 15 matching lines...) Expand all Loading... |
72 DCHECK(!heap_->code_space()->Contains(*current)); | 69 DCHECK(!heap_->code_space()->Contains(*current)); |
73 Address addr = *current; | 70 Address addr = *current; |
74 Page* page = Page::FromAnyPointerAddress(heap_, addr); | 71 Page* page = Page::FromAnyPointerAddress(heap_, addr); |
75 RememberedSet<OLD_TO_NEW>::Insert(page, addr); | 72 RememberedSet<OLD_TO_NEW>::Insert(page, addr); |
76 } | 73 } |
77 top_ = start_; | 74 top_ = start_; |
78 } | 75 } |
79 | 76 |
80 } // namespace internal | 77 } // namespace internal |
81 } // namespace v8 | 78 } // namespace v8 |
OLD | NEW |