[heap] Introduce mutex for executable memory data structure

Lookups and updates to the executable_memory_ unordered_map need to be
protected with mutex.

Bug: v8:10315, v8:10546
Change-Id: Ic17e19d1e4fda18b99103a96052940e68e970586
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2208867
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67902}
This commit is contained in:
Dominik Inführ 2020-05-19 16:04:19 +02:00 committed by Commit Bot
parent e19eb649a3
commit 986254d25f

View File

@ -330,12 +330,14 @@ class MemoryAllocator {
}
void RegisterExecutableMemoryChunk(MemoryChunk* chunk) {
base::MutexGuard guard(&executable_memory_mutex_);
DCHECK(chunk->IsFlagSet(MemoryChunk::IS_EXECUTABLE));
DCHECK_EQ(executable_memory_.find(chunk), executable_memory_.end());
executable_memory_.insert(chunk);
}
void UnregisterExecutableMemoryChunk(MemoryChunk* chunk) {
base::MutexGuard guard(&executable_memory_mutex_);
DCHECK_NE(executable_memory_.find(chunk), executable_memory_.end());
executable_memory_.erase(chunk);
chunk->heap()->UnregisterUnprotectedMemoryChunk(chunk);
@ -396,6 +398,7 @@ class MemoryAllocator {
// Data structure to remember allocated executable memory chunks.
std::unordered_set<MemoryChunk*> executable_memory_;
base::Mutex executable_memory_mutex_;
friend class heap::TestCodePageAllocatorScope;