Commit df91e1ed authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[heap] Rename PagedSpace::SetReadAndWritable

SetCodeModificationPermissions better reflects its current usage.

Change-Id: Ia9b42328a2d467613736878e2b560e0d5282ad3f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3173674Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77015}
parent 88c43927
......@@ -784,12 +784,12 @@ CodeSpaceMemoryModificationScope::CodeSpaceMemoryModificationScope(Heap* heap)
: heap_(heap) {
if (heap_->write_protect_code_memory()) {
heap_->increment_code_space_memory_modification_scope_depth();
heap_->code_space()->SetReadAndWritable();
heap_->code_space()->SetCodeModificationPermissions();
LargePage* page = heap_->code_lo_space()->first_page();
while (page != nullptr) {
DCHECK(page->IsFlagSet(MemoryChunk::IS_EXECUTABLE));
CHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
page->SetReadAndWritable();
page->SetCodeModificationPermissions();
page = page->next_page();
}
}
......@@ -847,7 +847,7 @@ CodePageMemoryModificationScope::CodePageMemoryModificationScope(
if (scope_active_) {
DCHECK(chunk_->owner()->identity() == CODE_SPACE ||
(chunk_->owner()->identity() == CODE_LO_SPACE));
MemoryChunk::cast(chunk_)->SetReadAndWritable();
MemoryChunk::cast(chunk_)->SetCodeModificationPermissions();
}
}
......
......@@ -2673,7 +2673,7 @@ void Heap::UnprotectAndRegisterMemoryChunk(MemoryChunk* chunk,
guard.emplace(&unprotected_memory_chunks_mutex_);
}
if (unprotected_memory_chunks_.insert(chunk).second) {
chunk->SetReadAndWritable();
chunk->SetCodeModificationPermissions();
}
}
}
......
......@@ -76,7 +76,7 @@ void MemoryChunk::SetReadAndExecutable() {
PageAllocator::kReadExecute);
}
void MemoryChunk::SetReadAndWritable() {
void MemoryChunk::SetCodeModificationPermissions() {
DCHECK(IsFlagSet(MemoryChunk::IS_EXECUTABLE));
DCHECK(owner_identity() == CODE_SPACE || owner_identity() == CODE_LO_SPACE);
// Incrementing the write_unprotect_counter_ and changing the page
......@@ -100,6 +100,14 @@ void MemoryChunk::SetReadAndWritable() {
}
}
void MemoryChunk::SetDefaultCodePermissions() {
if (FLAG_jitless) {
SetReadable();
} else {
SetReadAndExecutable();
}
}
namespace {
PageAllocator::Permission DefaultWritableCodePermissions() {
......
......@@ -191,15 +191,9 @@ class MemoryChunk : public BasicMemoryChunk {
V8_EXPORT_PRIVATE void SetReadable();
V8_EXPORT_PRIVATE void SetReadAndExecutable();
V8_EXPORT_PRIVATE void SetReadAndWritable();
void SetDefaultCodePermissions() {
if (FLAG_jitless) {
SetReadable();
} else {
SetReadAndExecutable();
}
}
V8_EXPORT_PRIVATE void SetCodeModificationPermissions();
V8_EXPORT_PRIVATE void SetDefaultCodePermissions();
heap::ListNode<MemoryChunk>& list_node() { return list_node_; }
const heap::ListNode<MemoryChunk>& list_node() const { return list_node_; }
......
......@@ -499,11 +499,11 @@ void PagedSpace::SetReadAndExecutable() {
}
}
void PagedSpace::SetReadAndWritable() {
void PagedSpace::SetCodeModificationPermissions() {
DCHECK(identity() == CODE_SPACE);
for (Page* page : *this) {
CHECK(heap()->memory_allocator()->IsMemoryChunkExecutable(page));
page->SetReadAndWritable();
page->SetCodeModificationPermissions();
}
}
......
......@@ -217,7 +217,7 @@ class V8_EXPORT_PRIVATE PagedSpace
void SetReadable();
void SetReadAndExecutable();
void SetReadAndWritable();
void SetCodeModificationPermissions();
void SetDefaultCodePermissions() {
if (FLAG_jitless) {
......
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