Revert "[heap] Remove executable_memory_ from release code"
This reverts commit ef62cd066c
.
Reason for revert: Fails mjsunit/wasm/grow-memory (https://logs.chromium.org/logs/v8/buildbucket/cr-buildbucket/8831118281610576833/+/u/Check/grow-memory)
Original change's description:
> [heap] Remove executable_memory_ from release code
>
> The map is only used to check invariants.
>
> Bug: v8:12054
> Change-Id: I7d067cca801c9b6104efb22a26cf27f1f62920c5
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3268286
> Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
> Commit-Queue: Victor Gomes <victorgomes@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#77766}
Bug: v8:12054
Change-Id: I95af58404719855664a128047ed32e8022dd5dd3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3268300
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Owners-Override: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77767}
This commit is contained in:
parent
ef62cd066c
commit
13304adf03
@ -800,7 +800,7 @@ CodeSpaceMemoryModificationScope::CodeSpaceMemoryModificationScope(Heap* heap)
|
||||
LargePage* page = heap_->code_lo_space()->first_page();
|
||||
while (page != nullptr) {
|
||||
DCHECK(page->IsFlagSet(MemoryChunk::IS_EXECUTABLE));
|
||||
DCHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
CHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
page->SetCodeModificationPermissions();
|
||||
page = page->next_page();
|
||||
}
|
||||
@ -814,7 +814,7 @@ CodeSpaceMemoryModificationScope::~CodeSpaceMemoryModificationScope() {
|
||||
LargePage* page = heap_->code_lo_space()->first_page();
|
||||
while (page != nullptr) {
|
||||
DCHECK(page->IsFlagSet(MemoryChunk::IS_EXECUTABLE));
|
||||
DCHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
CHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
page->SetDefaultCodePermissions();
|
||||
page = page->next_page();
|
||||
}
|
||||
|
@ -2674,7 +2674,7 @@ void Heap::ProtectUnprotectedMemoryChunks() {
|
||||
DCHECK_EQ(code_page_collection_memory_modification_scope_depth_, 0);
|
||||
for (auto chunk = unprotected_memory_chunks_.begin();
|
||||
chunk != unprotected_memory_chunks_.end(); chunk++) {
|
||||
DCHECK(memory_allocator()->IsMemoryChunkExecutable(*chunk));
|
||||
CHECK(memory_allocator()->IsMemoryChunkExecutable(*chunk));
|
||||
(*chunk)->SetDefaultCodePermissions();
|
||||
}
|
||||
unprotected_memory_chunks_.clear();
|
||||
|
@ -409,9 +409,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(size_t reserve_area_size,
|
||||
MemoryChunk* chunk =
|
||||
MemoryChunk::Initialize(basic_chunk, isolate_->heap(), executable);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (chunk->executable()) RegisterExecutableMemoryChunk(chunk);
|
||||
#endif
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@ -460,9 +458,7 @@ void MemoryAllocator::UnregisterMemory(BasicMemoryChunk* chunk,
|
||||
if (executable == EXECUTABLE) {
|
||||
DCHECK_GE(size_executable_, size);
|
||||
size_executable_ -= size;
|
||||
#ifdef DEBUG
|
||||
UnregisterExecutableMemoryChunk(static_cast<MemoryChunk*>(chunk));
|
||||
#endif
|
||||
}
|
||||
chunk->SetFlag(MemoryChunk::UNREGISTERED);
|
||||
}
|
||||
|
@ -226,14 +226,11 @@ class MemoryAllocator {
|
||||
void PartialFreeMemory(BasicMemoryChunk* chunk, Address start_free,
|
||||
size_t bytes_to_free, Address new_area_end);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Checks if an allocated MemoryChunk was intended to be used for executable
|
||||
// memory.
|
||||
bool IsMemoryChunkExecutable(MemoryChunk* chunk) {
|
||||
base::MutexGuard guard(&executable_memory_mutex_);
|
||||
return executable_memory_.find(chunk) != executable_memory_.end();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Commit memory region owned by given reservation object. Returns true if
|
||||
// it succeeded and false otherwise.
|
||||
@ -314,7 +311,6 @@ class MemoryAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void RegisterExecutableMemoryChunk(MemoryChunk* chunk) {
|
||||
base::MutexGuard guard(&executable_memory_mutex_);
|
||||
DCHECK(chunk->IsFlagSet(MemoryChunk::IS_EXECUTABLE));
|
||||
@ -328,7 +324,6 @@ class MemoryAllocator {
|
||||
executable_memory_.erase(chunk);
|
||||
chunk->heap()->UnregisterUnprotectedMemoryChunk(chunk);
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
Isolate* isolate_;
|
||||
|
||||
@ -364,12 +359,9 @@ class MemoryAllocator {
|
||||
VirtualMemory last_chunk_;
|
||||
Unmapper unmapper_;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Data structure to remember allocated executable memory chunks.
|
||||
// This data structure is used only in DCHECKs.
|
||||
std::unordered_set<MemoryChunk*> executable_memory_;
|
||||
base::Mutex executable_memory_mutex_;
|
||||
#endif
|
||||
|
||||
friend class heap::TestCodePageAllocatorScope;
|
||||
friend class heap::TestMemoryAllocatorScope;
|
||||
|
@ -499,7 +499,7 @@ void PagedSpace::ReleasePage(Page* page) {
|
||||
void PagedSpace::SetReadable() {
|
||||
DCHECK(identity() == CODE_SPACE);
|
||||
for (Page* page : *this) {
|
||||
DCHECK(heap()->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
CHECK(heap()->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
page->SetReadable();
|
||||
}
|
||||
}
|
||||
@ -507,7 +507,7 @@ void PagedSpace::SetReadable() {
|
||||
void PagedSpace::SetReadAndExecutable() {
|
||||
DCHECK(identity() == CODE_SPACE);
|
||||
for (Page* page : *this) {
|
||||
DCHECK(heap()->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
CHECK(heap()->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
page->SetReadAndExecutable();
|
||||
}
|
||||
}
|
||||
@ -515,7 +515,7 @@ void PagedSpace::SetReadAndExecutable() {
|
||||
void PagedSpace::SetCodeModificationPermissions() {
|
||||
DCHECK(identity() == CODE_SPACE);
|
||||
for (Page* page : *this) {
|
||||
DCHECK(heap()->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
CHECK(heap()->memory_allocator()->IsMemoryChunkExecutable(page));
|
||||
page->SetCodeModificationPermissions();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user