[heap] Make ReadOnlySpace fully read-only

Up until now the first page of ReadOnlySpace was not read-only.
Changing this means that the space needs to be made writable before
PagedSpace's TearDown tries to free it.

Bug: v8:7464
Change-Id: I162b45b662a6e5ab61a35be280ef087375fdcc9b
Reviewed-on: https://chromium-review.googlesource.com/c/1454494
Reviewed-by: Dan Elphick <delphick@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Maciej Goszczycki <goszczycki@google.com>
Cr-Commit-Position: refs/heads/master@{#59432}
This commit is contained in:
Maciej Goszczycki 2019-02-05 17:22:16 +00:00 committed by Commit Bot
parent f9e5a7bbc1
commit 54a1889585
2 changed files with 6 additions and 7 deletions

View File

@ -3296,9 +3296,6 @@ void ReadOnlyPage::MakeHeaderRelocatable() {
}
void ReadOnlySpace::SetPermissionsForPages(PageAllocator::Permission access) {
const size_t page_size = MemoryAllocator::GetCommitPageSize();
const size_t area_start_offset =
RoundUp(MemoryChunkLayout::ObjectStartOffsetInDataPage(), page_size);
MemoryAllocator* memory_allocator = heap()->memory_allocator();
for (Page* p : *this) {
ReadOnlyPage* page = static_cast<ReadOnlyPage*>(p);
@ -3310,10 +3307,8 @@ void ReadOnlySpace::SetPermissionsForPages(PageAllocator::Permission access) {
// page allocator manually.
v8::PageAllocator* page_allocator =
memory_allocator->page_allocator(page->executable());
// TODO(v8:7464): Map the whole space's memory read only (do not ignore the
// first page).
CHECK(SetPermissions(page_allocator, page->address() + area_start_offset,
page->size() - area_start_offset, access));
CHECK(
SetPermissions(page_allocator, page->address(), page->size(), access));
}
}

View File

@ -2973,6 +2973,10 @@ class ReadOnlySpace : public PagedSpace {
explicit ReadOnlySpace(Heap* heap);
// TODO(v8:7464): Remove this once PagedSpace::TearDown no longer writes to
// memory_chunk_list_.
~ReadOnlySpace() override { MarkAsReadWrite(); }
bool writable() const { return !is_marked_read_only_; }
void ClearStringPaddingIfNeeded();