Commit 668b1e68 authored by Hannes Payer's avatar Hannes Payer Committed by Commit Bot

[deoptimizer] Make deoptimizer entry code memory rx.

Bug: chromium:774108,v8:6792
Change-Id: If91b709779912c37b88f3c57e46f7910b59cc240
Reviewed-on: https://chromium-review.googlesource.com/737870
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48967}
parent 537f73e9
......@@ -24,9 +24,15 @@ namespace v8 {
namespace internal {
static MemoryChunk* AllocateCodeChunk(MemoryAllocator* allocator) {
return allocator->AllocateChunk(Deoptimizer::GetMaxDeoptTableSize(),
MemoryAllocator::GetCommitPageSize(),
EXECUTABLE, nullptr);
MemoryChunk* chunk = allocator->AllocateChunk(
Deoptimizer::GetMaxDeoptTableSize(), MemoryAllocator::GetCommitPageSize(),
EXECUTABLE, nullptr);
if (FLAG_write_protect_code_memory) {
// TODO(hpayer): Ensure code memory chunk allocation gives us rx by default.
chunk->SetReadAndWritable();
chunk->SetReadAndExecutable();
}
return chunk;
}
DeoptimizerData::DeoptimizerData(MemoryAllocator* allocator)
......@@ -2009,6 +2015,11 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
DCHECK(!RelocInfo::RequiresRelocation(isolate, desc));
MemoryChunk* chunk = data->deopt_entry_code_[type];
// TODO(mstarzinger,6792): This code-space modification section should be
// moved into {Heap} eventually and a safe wrapper be provided.
CodePageMemoryModificationScope modification_scope(chunk);
CHECK(static_cast<int>(Deoptimizer::GetMaxDeoptTableSize()) >=
desc.instr_size);
if (!chunk->CommitArea(desc.instr_size)) {
......
......@@ -530,7 +530,10 @@ void MemoryChunk::InitializationMemoryFence() {
void MemoryChunk::SetReadAndExecutable() {
DCHECK(IsFlagSet(MemoryChunk::IS_EXECUTABLE));
DCHECK(owner()->identity() == CODE_SPACE || owner()->identity() == LO_SPACE);
// TODO(hpayer): owner() can only be null if we use the MemoryChunk outside
// of spaces. We actually should not do that and we should untangle this.
DCHECK(owner() == nullptr || owner()->identity() == CODE_SPACE ||
owner()->identity() == LO_SPACE);
// Decrementing the write_unprotect_counter_ and changing the page
// protection mode has to be atomic.
base::LockGuard<base::Mutex> guard(page_protection_change_mutex_);
......
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