Skip to content

Commit 594a1a0

Browse files
hannespayerCommit Bot
authored andcommitted
Revert "[heap] Register executable MemoryChunks."
This reverts commit e97daee. Bug: chromium:803046,chromium:774108,v8:6792 Change-Id: I15ee3c109b22fa9fe9658c93bd73cb4454310df5 Reviewed-on: https://chromium-review.googlesource.com/870837 Reviewed-by: Ulan Degenbaev <[email protected]> Commit-Queue: Hannes Payer <[email protected]> Cr-Commit-Position: refs/heads/master@{#50664}
1 parent 7dbfec5 commit 594a1a0

3 files changed

Lines changed: 2 additions & 35 deletions

File tree

src/heap/heap-inl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ CodeSpaceMemoryModificationScope::CodeSpaceMemoryModificationScope(Heap* heap)
626626
LargePage* page = heap_->lo_space()->first_page();
627627
while (page != nullptr) {
628628
if (page->IsFlagSet(MemoryChunk::IS_EXECUTABLE)) {
629-
CHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
630629
page->SetReadAndWritable();
631630
}
632631
page = page->next_page();
@@ -641,7 +640,6 @@ CodeSpaceMemoryModificationScope::~CodeSpaceMemoryModificationScope() {
641640
LargePage* page = heap_->lo_space()->first_page();
642641
while (page != nullptr) {
643642
if (page->IsFlagSet(MemoryChunk::IS_EXECUTABLE)) {
644-
CHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
645643
page->SetReadAndExecutable();
646644
}
647645
page = page->next_page();
@@ -658,14 +656,12 @@ CodePageMemoryModificationScope::CodePageMemoryModificationScope(
658656
DCHECK(chunk_->owner()->identity() == CODE_SPACE ||
659657
(chunk_->owner()->identity() == LO_SPACE &&
660658
chunk_->IsFlagSet(MemoryChunk::IS_EXECUTABLE)));
661-
CHECK(chunk_->heap()->memory_allocator()->IsMemoryChunkExecutable(chunk_));
662659
chunk_->SetReadAndWritable();
663660
}
664661
}
665662

666663
CodePageMemoryModificationScope::~CodePageMemoryModificationScope() {
667664
if (scope_active_) {
668-
CHECK(chunk_->heap()->memory_allocator()->IsMemoryChunkExecutable(chunk_));
669665
chunk_->SetReadAndExecutable();
670666
}
671667
}

src/heap/spaces.cc

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -826,13 +826,8 @@ MemoryChunk* MemoryAllocator::AllocateChunk(size_t reserve_area_size,
826826
owner);
827827
}
828828

829-
MemoryChunk* chunk =
830-
MemoryChunk::Initialize(heap, base, chunk_size, area_start, area_end,
831-
executable, owner, &reservation);
832-
833-
if (executable) RegisterExecutableMemoryChunk(chunk);
834-
835-
return chunk;
829+
return MemoryChunk::Initialize(heap, base, chunk_size, area_start, area_end,
830+
executable, owner, &reservation);
836831
}
837832

838833
void Page::ResetAllocatedBytes() { allocated_bytes_ = area_size(); }
@@ -975,8 +970,6 @@ void MemoryAllocator::PreFreeMemory(MemoryChunk* chunk) {
975970
}
976971

977972
chunk->SetFlag(MemoryChunk::PRE_FREED);
978-
979-
if (chunk->executable()) UnregisterExecutableMemoryChunk(chunk);
980973
}
981974

982975

@@ -1729,15 +1722,13 @@ void PagedSpace::ReleasePage(Page* page) {
17291722
void PagedSpace::SetReadAndExecutable() {
17301723
DCHECK(identity() == CODE_SPACE);
17311724
for (Page* page : *this) {
1732-
CHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
17331725
page->SetReadAndExecutable();
17341726
}
17351727
}
17361728

17371729
void PagedSpace::SetReadAndWritable() {
17381730
DCHECK(identity() == CODE_SPACE);
17391731
for (Page* page : *this) {
1740-
CHECK(heap_->memory_allocator()->IsMemoryChunkExecutable(page));
17411732
page->SetReadAndWritable();
17421733
}
17431734
}

src/heap/spaces.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,12 +1359,6 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
13591359
// and false otherwise.
13601360
bool CommitBlock(Address start, size_t size, Executability executable);
13611361

1362-
// Checks if an allocated MemoryChunk was intended to be used for executable
1363-
// memory.
1364-
bool IsMemoryChunkExecutable(MemoryChunk* chunk) {
1365-
return executable_memory_.find(chunk) != executable_memory_.end();
1366-
}
1367-
13681362
// Uncommit a contiguous block of memory [start..(start+size)[.
13691363
// start is not nullptr, the size is greater than zero, and the
13701364
// block is contained in the initial chunk. Returns true if it succeeded
@@ -1415,17 +1409,6 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
14151409
} while ((high > ptr) && !highest_ever_allocated_.TrySetValue(ptr, high));
14161410
}
14171411

1418-
void RegisterExecutableMemoryChunk(MemoryChunk* chunk) {
1419-
DCHECK(chunk->IsFlagSet(MemoryChunk::IS_EXECUTABLE));
1420-
DCHECK_EQ(executable_memory_.find(chunk), executable_memory_.end());
1421-
executable_memory_.insert(chunk);
1422-
}
1423-
1424-
void UnregisterExecutableMemoryChunk(MemoryChunk* chunk) {
1425-
DCHECK_NE(executable_memory_.find(chunk), executable_memory_.end());
1426-
executable_memory_.erase(chunk);
1427-
}
1428-
14291412
Isolate* isolate_;
14301413
CodeRange* code_range_;
14311414

@@ -1448,9 +1431,6 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
14481431
VirtualMemory last_chunk_;
14491432
Unmapper unmapper_;
14501433

1451-
// Data structure to remember allocated executable memory chunks.
1452-
std::unordered_set<MemoryChunk*> executable_memory_;
1453-
14541434
friend class heap::TestCodeRangeScope;
14551435

14561436
DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryAllocator);

0 commit comments

Comments
 (0)