Commit ffbbc492 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[heap] Bump maximum nesting level of memory modification scopes.

This increases the maximum nesting level for memory modification scopes
from 3 to 4. It is a follow-up to WebAssembly optimizations which did
increase the total nesting in favor of performance. This also hoists
out the value into a constant, so that it is easier to change.

R=ahaas@chromium.org
BUG=v8:6792,chromium:787731

Change-Id: Ib60a7d66cdf42227d6b717a38c0923bcbbacf8dc
Reviewed-on: https://chromium-review.googlesource.com/788859Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49626}
parent 72702084
...@@ -537,7 +537,7 @@ void MemoryChunk::SetReadAndExecutable() { ...@@ -537,7 +537,7 @@ void MemoryChunk::SetReadAndExecutable() {
return; return;
} }
write_unprotect_counter_--; write_unprotect_counter_--;
DCHECK_LE(write_unprotect_counter_, 2); DCHECK_LT(write_unprotect_counter_, kMaxWriteUnprotectCounter);
if (write_unprotect_counter_ == 0) { if (write_unprotect_counter_ == 0) {
Address protect_start = Address protect_start =
address() + MemoryAllocator::CodePageAreaStartOffset(); address() + MemoryAllocator::CodePageAreaStartOffset();
...@@ -556,7 +556,7 @@ void MemoryChunk::SetReadAndWritable() { ...@@ -556,7 +556,7 @@ void MemoryChunk::SetReadAndWritable() {
// protection mode has to be atomic. // protection mode has to be atomic.
base::LockGuard<base::Mutex> guard(page_protection_change_mutex_); base::LockGuard<base::Mutex> guard(page_protection_change_mutex_);
write_unprotect_counter_++; write_unprotect_counter_++;
DCHECK_LE(write_unprotect_counter_, 3); DCHECK_LE(write_unprotect_counter_, kMaxWriteUnprotectCounter);
if (write_unprotect_counter_ == 1) { if (write_unprotect_counter_ == 1) {
Address unprotect_start = Address unprotect_start =
address() + MemoryAllocator::CodePageAreaStartOffset(); address() + MemoryAllocator::CodePageAreaStartOffset();
......
...@@ -400,6 +400,10 @@ class MemoryChunk { ...@@ -400,6 +400,10 @@ class MemoryChunk {
static const int kAllocatableMemory = kPageSize - kObjectStartOffset; static const int kAllocatableMemory = kPageSize - kObjectStartOffset;
// Maximum number of nested code memory modification scopes.
// TODO(6792,mstarzinger): Drop to 3 or lower once WebAssembly is off heap.
static const int kMaxWriteUnprotectCounter = 4;
// Only works if the pointer is in the first kPageSize of the MemoryChunk. // Only works if the pointer is in the first kPageSize of the MemoryChunk.
static MemoryChunk* FromAddress(Address a) { static MemoryChunk* FromAddress(Address a) {
return reinterpret_cast<MemoryChunk*>(OffsetFrom(a) & ~kAlignmentMask); return reinterpret_cast<MemoryChunk*>(OffsetFrom(a) & ~kAlignmentMask);
...@@ -695,7 +699,8 @@ class MemoryChunk { ...@@ -695,7 +699,8 @@ class MemoryChunk {
// counter is decremented when a component resets to read+executable. // counter is decremented when a component resets to read+executable.
// If Value() == 0 => The memory is read and executable. // If Value() == 0 => The memory is read and executable.
// If Value() >= 1 => The Memory is read and writable (and maybe executable). // If Value() >= 1 => The Memory is read and writable (and maybe executable).
// The maximum value can right now only be 3. // The maximum value is limited by {kMaxWriteUnprotectCounter} to prevent
// excessive nesting of scopes.
// All executable MemoryChunks are allocated rw based on the assumption that // All executable MemoryChunks are allocated rw based on the assumption that
// they will be used immediatelly for an allocation. They are initialized // they will be used immediatelly for an allocation. They are initialized
// with the number of open CodeSpaceMemoryModificationScopes. The caller // with the number of open CodeSpaceMemoryModificationScopes. The caller
......
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