Skip to content

Commit 70322ea

Browse files
Milad FarazmandBethGriggs
Milad Farazmand
authored andcommitted
deps: V8: cherry-pick d0468de
Original commit message: [heap] Fix StoreBuffer setup. - Solves a problem for PPC in a configuration where commit page size is 64K. https://chromium-review.googlesource.com/c/v8/v8/+/1149515 - Uses existing VM allocation code to get properly aligned memory. - Makes sure the size for SetPermissions is a multiple of system page size. Bug:chromium:756050 Change-Id: Ib3799ab7a3bb44b0091c234234c1cc47938379c2 Reviewed-on: https://chromium-review.googlesource.com/1161210 Commit-Queue: Bill Budge <[email protected]> Reviewed-by: Michael Lippautz <[email protected]> Reviewed-by: Michael Starzinger <[email protected]> Cr-Commit-Position: refs/heads/master@{#54930} Refs: v8/v8@d0468de PR-URL: #25827 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Yang Guo <[email protected]>
1 parent 741c5ef commit 70322ea

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
# Reset this number to 0 on major V8 upgrades.
3535
# Increment by one for each non-official patch applied to deps/v8.
36-
'v8_embedder_string': '-node.49',
36+
'v8_embedder_string': '-node.50',
3737

3838
# Enable disassembler for `--print-code` v8 options
3939
'v8_enable_disassembler': 1,

deps/v8/src/heap/store-buffer.cc

+17-11
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,28 @@ StoreBuffer::StoreBuffer(Heap* heap)
3030
}
3131

3232
void StoreBuffer::SetUp() {
33-
// Allocate 3x the buffer size, so that we can start the new store buffer
34-
// aligned to 2x the size. This lets us use a bit test to detect the end of
35-
// the area.
33+
const size_t requested_size = kStoreBufferSize * kStoreBuffers;
34+
// Allocate buffer memory aligned at least to kStoreBufferSize. This lets us
35+
// use a bit test to detect the ends of the buffers.
36+
const size_t alignment =
37+
std::max<size_t>(kStoreBufferSize, AllocatePageSize());
38+
void* hint = AlignedAddress(heap_->GetRandomMmapAddr(), alignment);
3639
VirtualMemory reservation;
37-
if (!AllocVirtualMemory(kStoreBufferSize * 3, heap_->GetRandomMmapAddr(),
38-
&reservation)) {
40+
if (!AlignedAllocVirtualMemory(requested_size, alignment, hint,
41+
&reservation)) {
3942
heap_->FatalProcessOutOfMemory("StoreBuffer::SetUp");
4043
}
44+
4145
Address start = reservation.address();
42-
start_[0] = reinterpret_cast<Address*>(::RoundUp(start, kStoreBufferSize));
46+
const size_t allocated_size = reservation.size();
47+
48+
start_[0] = reinterpret_cast<Address*>(start);
4349
limit_[0] = start_[0] + (kStoreBufferSize / kPointerSize);
4450
start_[1] = limit_[0];
4551
limit_[1] = start_[1] + (kStoreBufferSize / kPointerSize);
4652

47-
Address* vm_limit = reinterpret_cast<Address*>(start + reservation.size());
48-
53+
// Sanity check the buffers.
54+
Address* vm_limit = reinterpret_cast<Address*>(start + allocated_size);
4955
USE(vm_limit);
5056
for (int i = 0; i < kStoreBuffers; i++) {
5157
DCHECK(reinterpret_cast<Address>(start_[i]) >= reservation.address());
@@ -55,8 +61,9 @@ void StoreBuffer::SetUp() {
5561
DCHECK_EQ(0, reinterpret_cast<Address>(limit_[i]) & kStoreBufferMask);
5662
}
5763

58-
if (!reservation.SetPermissions(reinterpret_cast<Address>(start_[0]),
59-
kStoreBufferSize * kStoreBuffers,
64+
// Set RW permissions only on the pages we use.
65+
const size_t used_size = RoundUp(requested_size, CommitPageSize());
66+
if (!reservation.SetPermissions(start, used_size,
6067
PageAllocator::kReadWrite)) {
6168
heap_->FatalProcessOutOfMemory("StoreBuffer::SetUp");
6269
}
@@ -65,7 +72,6 @@ void StoreBuffer::SetUp() {
6572
virtual_memory_.TakeControl(&reservation);
6673
}
6774

68-
6975
void StoreBuffer::TearDown() {
7076
if (virtual_memory_.IsReserved()) virtual_memory_.Free();
7177
top_ = nullptr;

0 commit comments

Comments
 (0)