Commit b3b824ba authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[offthread] Allow ReadOnlyRoots from OffThreadHeap

Allow ReadOnlyRoots initialization from an OffThreadHeap, by creating
a FromHeap getter on OffThreadIsolate analogous to the one on Isolate.

Bug: chromium:1075999
Change-Id: Ie00e1547160e24d35bd7b0dd36d1b7eead87341e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2184289Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67600}
parent 4f7b00c7
......@@ -78,6 +78,11 @@ class V8_EXPORT_PRIVATE OffThreadIsolate final
explicit OffThreadIsolate(Isolate* isolate, Zone* zone);
~OffThreadIsolate();
static OffThreadIsolate* FromHeap(OffThreadHeap* heap) {
return reinterpret_cast<OffThreadIsolate*>(
reinterpret_cast<Address>(heap) - OFFSET_OF(OffThreadIsolate, heap_));
}
OffThreadHeap* heap() { return &heap_; }
inline Address isolate_root() const;
......
......@@ -228,7 +228,7 @@ HeapObject OffThreadHeap::AllocateRaw(int size, AllocationType allocation,
HeapObject OffThreadHeap::CreateFillerObjectAt(
Address addr, int size, ClearFreedMemoryMode clear_memory_mode) {
ReadOnlyRoots roots(lo_space_.heap());
ReadOnlyRoots roots(this);
HeapObject filler =
Heap::CreateFillerObjectAt(roots, addr, size, clear_memory_mode);
return filler;
......
......@@ -62,6 +62,9 @@ bool RootsTable::IsRootHandle(Handle<T> handle, RootIndex* index) const {
ReadOnlyRoots::ReadOnlyRoots(Heap* heap)
: ReadOnlyRoots(Isolate::FromHeap(heap)) {}
ReadOnlyRoots::ReadOnlyRoots(OffThreadHeap* heap)
: ReadOnlyRoots(OffThreadIsolate::FromHeap(heap)) {}
ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate)
: read_only_roots_(reinterpret_cast<Address*>(
isolate->roots_table().read_only_roots_begin().address())) {}
......
......@@ -19,6 +19,7 @@ namespace internal {
// Forward declarations.
enum ElementsKind : uint8_t;
class OffThreadHeap;
class OffThreadIsolate;
template <typename T>
class Handle;
......@@ -498,6 +499,7 @@ class ReadOnlyRoots {
static_cast<size_t>(RootIndex::kReadOnlyRootsCount);
V8_INLINE explicit ReadOnlyRoots(Heap* heap);
V8_INLINE explicit ReadOnlyRoots(OffThreadHeap* heap);
V8_INLINE explicit ReadOnlyRoots(Isolate* isolate);
V8_INLINE explicit ReadOnlyRoots(OffThreadIsolate* isolate);
......
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