Commit 54a18895 authored by Maciej Goszczycki's avatar Maciej Goszczycki Committed by Commit Bot

[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/1454494Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Maciej Goszczycki <goszczycki@google.com>
Cr-Commit-Position: refs/heads/master@{#59432}
parent f9e5a7bb
...@@ -3296,9 +3296,6 @@ void ReadOnlyPage::MakeHeaderRelocatable() { ...@@ -3296,9 +3296,6 @@ void ReadOnlyPage::MakeHeaderRelocatable() {
} }
void ReadOnlySpace::SetPermissionsForPages(PageAllocator::Permission access) { 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(); MemoryAllocator* memory_allocator = heap()->memory_allocator();
for (Page* p : *this) { for (Page* p : *this) {
ReadOnlyPage* page = static_cast<ReadOnlyPage*>(p); ReadOnlyPage* page = static_cast<ReadOnlyPage*>(p);
...@@ -3310,10 +3307,8 @@ void ReadOnlySpace::SetPermissionsForPages(PageAllocator::Permission access) { ...@@ -3310,10 +3307,8 @@ void ReadOnlySpace::SetPermissionsForPages(PageAllocator::Permission access) {
// page allocator manually. // page allocator manually.
v8::PageAllocator* page_allocator = v8::PageAllocator* page_allocator =
memory_allocator->page_allocator(page->executable()); memory_allocator->page_allocator(page->executable());
// TODO(v8:7464): Map the whole space's memory read only (do not ignore the CHECK(
// first page). SetPermissions(page_allocator, page->address(), page->size(), access));
CHECK(SetPermissions(page_allocator, page->address() + area_start_offset,
page->size() - area_start_offset, access));
} }
} }
......
...@@ -2973,6 +2973,10 @@ class ReadOnlySpace : public PagedSpace { ...@@ -2973,6 +2973,10 @@ class ReadOnlySpace : public PagedSpace {
explicit ReadOnlySpace(Heap* heap); 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_; } bool writable() const { return !is_marked_read_only_; }
void ClearStringPaddingIfNeeded(); void ClearStringPaddingIfNeeded();
......
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