Commit c280e7d4 authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

[heap] Clear the memory of pooled pages when allocating from the pool.

Bug: chromium:999634
Change-Id: Ia7a0dd6ddc2477a7656a26548e9a247470d9143f
Reviewed-on: https://chromium-review.googlesource.com/1041688
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52948}
parent 90415437
......@@ -882,8 +882,8 @@ MemoryChunk* MemoryAllocator::AllocateChunk(size_t reserve_area_size,
}
if (Heap::ShouldZapGarbage()) {
ZapBlock(base, CodePageGuardStartOffset());
ZapBlock(base + CodePageAreaStartOffset(), commit_area_size);
ZapBlock(base, CodePageGuardStartOffset(), kZapValue);
ZapBlock(base + CodePageAreaStartOffset(), commit_area_size, kZapValue);
}
area_start = base + CodePageAreaStartOffset();
......@@ -901,7 +901,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(size_t reserve_area_size,
if (base == kNullAddress) return nullptr;
if (Heap::ShouldZapGarbage()) {
ZapBlock(base, Page::kObjectStartOffset + commit_area_size);
ZapBlock(base, Page::kObjectStartOffset + commit_area_size, kZapValue);
}
area_start = base + Page::kObjectStartOffset;
......@@ -1191,9 +1191,8 @@ MemoryChunk* MemoryAllocator::AllocatePagePooled(SpaceType* owner) {
bool MemoryAllocator::CommitBlock(Address start, size_t size) {
if (!CommitMemory(start, size)) return false;
if (Heap::ShouldZapGarbage()) {
ZapBlock(start, size);
}
ZapBlock(start, size,
Heap::ShouldZapGarbage() ? kZapValue : kClearedFreeMemoryValue);
isolate_->counters()->memory_allocated()->Increment(static_cast<int>(size));
return true;
......@@ -1206,10 +1205,10 @@ bool MemoryAllocator::UncommitBlock(Address start, size_t size) {
return true;
}
void MemoryAllocator::ZapBlock(Address start, size_t size) {
void MemoryAllocator::ZapBlock(Address start, size_t size,
uintptr_t zap_value) {
for (size_t s = 0; s + kPointerSize <= size; s += kPointerSize) {
Memory::Address_at(start + s) = static_cast<Address>(kZapValue);
Memory::Address_at(start + s) = static_cast<Address>(zap_value);
}
}
......
......@@ -1391,7 +1391,7 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
// Zaps a contiguous block of memory [start..(start+size)[ thus
// filling it up with a recognizable non-nullptr bit pattern.
void ZapBlock(Address start, size_t size);
void ZapBlock(Address start, size_t size, uintptr_t zap_value);
V8_WARN_UNUSED_RESULT bool CommitExecutableMemory(VirtualMemory* vm,
Address start,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment