• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_HEAP_READ_ONLY_HEAP_INL_H_
6 #define V8_HEAP_READ_ONLY_HEAP_INL_H_
7 
8 #include "src/execution/isolate-utils-inl.h"
9 #include "src/heap/read-only-heap.h"
10 #include "src/roots/roots-inl.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 // static
GetReadOnlyRoots(HeapObject object)16 ReadOnlyRoots ReadOnlyHeap::GetReadOnlyRoots(HeapObject object) {
17 #ifdef V8_COMPRESS_POINTERS
18   IsolateRoot isolate = GetIsolateForPtrCompr(object);
19   return ReadOnlyRoots(Isolate::FromRootAddress(isolate.address()));
20 #else
21 #ifdef V8_SHARED_RO_HEAP
22   // This fails if we are creating heap objects and the roots haven't yet been
23   // copied into the read-only heap.
24   auto* shared_ro_heap = SoleReadOnlyHeap::shared_ro_heap_;
25   if (shared_ro_heap != nullptr && shared_ro_heap->init_complete_) {
26     return ReadOnlyRoots(shared_ro_heap->read_only_roots_);
27   }
28 #endif  // V8_SHARED_RO_HEAP
29   return ReadOnlyRoots(GetHeapFromWritableObject(object));
30 #endif  // V8_COMPRESS_POINTERS
31 }
32 
33 }  // namespace internal
34 }  // namespace v8
35 
36 #endif  // V8_HEAP_READ_ONLY_HEAP_INL_H_
37