[roheap][ptr-compr] Move ReadOnlyHeap::GetReadOnlyRoots() to inl file
The implementation is already quite trivial and in addition in case of ptr-compr this implementation becomes even simpler and C++ compiler gets the opportunity to hoist common computation of isolate root. Tbr: yangguo@chromium.org Bug: v8:7464, v8:7703 Change-Id: I6e59cd43253c9ade5a0e27025ea7fabecd5b7af7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1647171 Commit-Queue: Igor Sheludko <ishell@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#62024}
This commit is contained in:
parent
5a39c2d6b4
commit
04beaf63cb
1
BUILD.gn
1
BUILD.gn
@ -2264,6 +2264,7 @@ v8_source_set("v8_base_without_compiler") {
|
|||||||
"src/heap/objects-visiting-inl.h",
|
"src/heap/objects-visiting-inl.h",
|
||||||
"src/heap/objects-visiting.cc",
|
"src/heap/objects-visiting.cc",
|
||||||
"src/heap/objects-visiting.h",
|
"src/heap/objects-visiting.h",
|
||||||
|
"src/heap/read-only-heap-inl.h",
|
||||||
"src/heap/read-only-heap.cc",
|
"src/heap/read-only-heap.cc",
|
||||||
"src/heap/read-only-heap.h",
|
"src/heap/read-only-heap.h",
|
||||||
"src/heap/remembered-set.h",
|
"src/heap/remembered-set.h",
|
||||||
|
1
src/DEPS
1
src/DEPS
@ -16,6 +16,7 @@ include_rules = [
|
|||||||
"+src/heap/heap-inl.h",
|
"+src/heap/heap-inl.h",
|
||||||
"+src/heap/heap-write-barrier-inl.h",
|
"+src/heap/heap-write-barrier-inl.h",
|
||||||
"+src/heap/heap-write-barrier.h",
|
"+src/heap/heap-write-barrier.h",
|
||||||
|
"+src/heap/read-only-heap-inl.h",
|
||||||
"+src/heap/read-only-heap.h",
|
"+src/heap/read-only-heap.h",
|
||||||
"-src/inspector",
|
"-src/inspector",
|
||||||
"-src/interpreter",
|
"-src/interpreter",
|
||||||
|
31
src/heap/read-only-heap-inl.h
Normal file
31
src/heap/read-only-heap-inl.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2019 the V8 project authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef V8_HEAP_READ_ONLY_HEAP_INL_H_
|
||||||
|
#define V8_HEAP_READ_ONLY_HEAP_INL_H_
|
||||||
|
|
||||||
|
#include "src/heap/read-only-heap.h"
|
||||||
|
|
||||||
|
#include "src/heap/heap-write-barrier-inl.h"
|
||||||
|
#include "src/roots/roots-inl.h"
|
||||||
|
|
||||||
|
namespace v8 {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
// static
|
||||||
|
ReadOnlyRoots ReadOnlyHeap::GetReadOnlyRoots(HeapObject object) {
|
||||||
|
#ifdef V8_SHARED_RO_HEAP
|
||||||
|
// This fails if we are creating heap objects and the roots haven't yet been
|
||||||
|
// copied into the read-only heap or it has been cleared for testing.
|
||||||
|
if (shared_ro_heap_ != nullptr && shared_ro_heap_->init_complete_) {
|
||||||
|
return ReadOnlyRoots(shared_ro_heap_->read_only_roots_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ReadOnlyRoots(GetHeapFromWritableObject(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace v8
|
||||||
|
|
||||||
|
#endif // V8_HEAP_READ_ONLY_HEAP_INL_H_
|
@ -21,7 +21,7 @@ namespace internal {
|
|||||||
|
|
||||||
#ifdef V8_SHARED_RO_HEAP
|
#ifdef V8_SHARED_RO_HEAP
|
||||||
V8_DECLARE_ONCE(setup_ro_heap_once);
|
V8_DECLARE_ONCE(setup_ro_heap_once);
|
||||||
ReadOnlyHeap* shared_ro_heap = nullptr;
|
ReadOnlyHeap* ReadOnlyHeap::shared_ro_heap_ = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -32,18 +32,18 @@ void ReadOnlyHeap::SetUp(Isolate* isolate, ReadOnlyDeserializer* des) {
|
|||||||
// we would be trying to create heap objects inside an already initialized
|
// we would be trying to create heap objects inside an already initialized
|
||||||
// read-only space. Use ClearSharedHeapForTest if you need a new read-only
|
// read-only space. Use ClearSharedHeapForTest if you need a new read-only
|
||||||
// space.
|
// space.
|
||||||
DCHECK_IMPLIES(shared_ro_heap != nullptr, des != nullptr);
|
DCHECK_IMPLIES(shared_ro_heap_ != nullptr, des != nullptr);
|
||||||
|
|
||||||
base::CallOnce(&setup_ro_heap_once, [isolate, des]() {
|
base::CallOnce(&setup_ro_heap_once, [isolate, des]() {
|
||||||
shared_ro_heap = CreateAndAttachToIsolate(isolate);
|
shared_ro_heap_ = CreateAndAttachToIsolate(isolate);
|
||||||
if (des != nullptr) shared_ro_heap->DeseralizeIntoIsolate(isolate, des);
|
if (des != nullptr) shared_ro_heap_->DeseralizeIntoIsolate(isolate, des);
|
||||||
});
|
});
|
||||||
|
|
||||||
isolate->heap()->SetUpFromReadOnlyHeap(shared_ro_heap);
|
isolate->heap()->SetUpFromReadOnlyHeap(shared_ro_heap_);
|
||||||
if (des != nullptr) {
|
if (des != nullptr) {
|
||||||
void* const isolate_ro_roots = reinterpret_cast<void*>(
|
void* const isolate_ro_roots = reinterpret_cast<void*>(
|
||||||
isolate->roots_table().read_only_roots_begin().address());
|
isolate->roots_table().read_only_roots_begin().address());
|
||||||
std::memcpy(isolate_ro_roots, shared_ro_heap->read_only_roots_,
|
std::memcpy(isolate_ro_roots, shared_ro_heap_->read_only_roots_,
|
||||||
kEntriesCount * sizeof(Address));
|
kEntriesCount * sizeof(Address));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -98,10 +98,10 @@ void ReadOnlyHeap::OnHeapTearDown() {
|
|||||||
// static
|
// static
|
||||||
void ReadOnlyHeap::ClearSharedHeapForTest() {
|
void ReadOnlyHeap::ClearSharedHeapForTest() {
|
||||||
#ifdef V8_SHARED_RO_HEAP
|
#ifdef V8_SHARED_RO_HEAP
|
||||||
DCHECK_NOT_NULL(shared_ro_heap);
|
DCHECK_NOT_NULL(shared_ro_heap_);
|
||||||
// TODO(v8:7464): Just leak read-only space for now. The paged-space heap
|
// TODO(v8:7464): Just leak read-only space for now. The paged-space heap
|
||||||
// is null so there isn't a nice way to do this.
|
// is null so there isn't a nice way to do this.
|
||||||
shared_ro_heap = nullptr;
|
shared_ro_heap_ = nullptr;
|
||||||
setup_ro_heap_once = 0;
|
setup_ro_heap_once = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -111,18 +111,6 @@ bool ReadOnlyHeap::Contains(HeapObject object) {
|
|||||||
return MemoryChunk::FromHeapObject(object)->InReadOnlySpace();
|
return MemoryChunk::FromHeapObject(object)->InReadOnlySpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
ReadOnlyRoots ReadOnlyHeap::GetReadOnlyRoots(HeapObject object) {
|
|
||||||
#ifdef V8_SHARED_RO_HEAP
|
|
||||||
// This fails if we are creating heap objects and the roots haven't yet been
|
|
||||||
// copied into the read-only heap or it has been cleared for testing.
|
|
||||||
if (shared_ro_heap != nullptr && shared_ro_heap->init_complete_) {
|
|
||||||
return ReadOnlyRoots(shared_ro_heap->read_only_roots_);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return ReadOnlyRoots(GetHeapFromWritableObject(object));
|
|
||||||
}
|
|
||||||
|
|
||||||
Object* ReadOnlyHeap::ExtendReadOnlyObjectCache() {
|
Object* ReadOnlyHeap::ExtendReadOnlyObjectCache() {
|
||||||
read_only_object_cache_.push_back(Smi::kZero);
|
read_only_object_cache_.push_back(Smi::kZero);
|
||||||
return &read_only_object_cache_.back();
|
return &read_only_object_cache_.back();
|
||||||
|
@ -44,7 +44,8 @@ class ReadOnlyHeap final {
|
|||||||
// Gets read-only roots from an appropriate root list: shared read-only root
|
// Gets read-only roots from an appropriate root list: shared read-only root
|
||||||
// list if the shared read-only heap has been initialized or the isolate
|
// list if the shared read-only heap has been initialized or the isolate
|
||||||
// specific roots table.
|
// specific roots table.
|
||||||
V8_EXPORT_PRIVATE static ReadOnlyRoots GetReadOnlyRoots(HeapObject object);
|
V8_EXPORT_PRIVATE inline static ReadOnlyRoots GetReadOnlyRoots(
|
||||||
|
HeapObject object);
|
||||||
|
|
||||||
// Clears any shared read-only heap artifacts for testing, forcing read-only
|
// Clears any shared read-only heap artifacts for testing, forcing read-only
|
||||||
// heap to be re-created on next set up.
|
// heap to be re-created on next set up.
|
||||||
@ -77,6 +78,8 @@ class ReadOnlyHeap final {
|
|||||||
|
|
||||||
#ifdef V8_SHARED_RO_HEAP
|
#ifdef V8_SHARED_RO_HEAP
|
||||||
Address read_only_roots_[kEntriesCount];
|
Address read_only_roots_[kEntriesCount];
|
||||||
|
|
||||||
|
V8_EXPORT_PRIVATE static ReadOnlyHeap* shared_ro_heap_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
explicit ReadOnlyHeap(ReadOnlySpace* ro_space) : read_only_space_(ro_space) {}
|
explicit ReadOnlyHeap(ReadOnlySpace* ro_space) : read_only_space_(ro_space) {}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "src/handles/handles-inl.h"
|
#include "src/handles/handles-inl.h"
|
||||||
#include "src/heap/factory.h"
|
#include "src/heap/factory.h"
|
||||||
#include "src/heap/heap-write-barrier-inl.h"
|
#include "src/heap/heap-write-barrier-inl.h"
|
||||||
|
#include "src/heap/read-only-heap-inl.h"
|
||||||
#include "src/numbers/conversions.h"
|
#include "src/numbers/conversions.h"
|
||||||
#include "src/numbers/double.h"
|
#include "src/numbers/double.h"
|
||||||
#include "src/objects/bigint.h"
|
#include "src/objects/bigint.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user