Commit 19c9a905 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr] Reimplement NeverReadOnlySpaceObject::GetIsolate/GetHeap()

Bug: v8:8948
Change-Id: Ia123989ed1ca68781d2b38b1485b8e83b03a523c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1648477Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62052}
parent e3758aee
......@@ -915,6 +915,9 @@ class Isolate final : private HiddenFactory {
static size_t isolate_root_bias() {
return OFFSET_OF(Isolate, isolate_data_) + IsolateData::kIsolateRootBias;
}
static Isolate* FromRoot(Address isolate_root) {
return reinterpret_cast<Isolate*>(isolate_root - isolate_root_bias());
}
RootsTable& roots_table() { return isolate_data()->roots(); }
......
......@@ -221,19 +221,35 @@ inline WriteBarrierMode GetWriteBarrierModeForObject(
return UPDATE_WRITE_BARRIER;
}
inline bool ObjectInYoungGeneration(const Object object) {
inline bool ObjectInYoungGeneration(Object object) {
if (object.IsSmi()) return false;
return heap_internals::MemoryChunk::FromHeapObject(HeapObject::cast(object))
->InYoungGeneration();
}
inline Heap* GetHeapFromWritableObject(const HeapObject object) {
inline Heap* GetHeapFromWritableObject(HeapObject object) {
#ifdef V8_COMPRESS_POINTERS
return GetIsolateFromWritableObject(object)->heap();
#else
heap_internals::MemoryChunk* chunk =
heap_internals::MemoryChunk::FromHeapObject(object);
return chunk->GetHeap();
#endif // V8_COMPRESS_POINTERS
}
inline Isolate* GetIsolateFromWritableObject(HeapObject object) {
#ifdef V8_COMPRESS_POINTERS
return Isolate::FromRoot(GetIsolateRoot(object.ptr()));
#else
return Isolate::FromHeap(GetHeapFromWritableObject(object));
#endif // V8_COMPRESS_POINTERS
}
inline bool GetIsolateFromWritableObject(HeapObject obj, Isolate** isolate) {
#ifdef V8_COMPRESS_POINTERS
*isolate = GetIsolateFromWritableObject(obj);
return true;
#else
heap_internals::MemoryChunk* chunk =
heap_internals::MemoryChunk::FromHeapObject(obj);
if (chunk->InReadOnlySpace()) {
......@@ -242,6 +258,7 @@ inline bool GetIsolateFromWritableObject(HeapObject obj, Isolate** isolate) {
}
*isolate = Isolate::FromHeap(chunk->GetHeap());
return true;
#endif // V8_COMPRESS_POINTERS
}
} // namespace internal
......
......@@ -41,7 +41,8 @@ void MarkingBarrierForDescriptorArray(Heap* heap, HeapObject host,
HeapObject descriptor_array,
int number_of_own_descriptors);
Heap* GetHeapFromWritableObject(const HeapObject object);
inline Heap* GetHeapFromWritableObject(HeapObject object);
inline Isolate* GetIsolateFromWritableObject(HeapObject object);
} // namespace internal
} // namespace v8
......
......@@ -31,7 +31,7 @@ Heap* NeverReadOnlySpaceObject::GetHeap(const HeapObject object) {
// static
Isolate* NeverReadOnlySpaceObject::GetIsolate(const HeapObject object) {
return Isolate::FromHeap(GetHeap(object));
return GetIsolateFromWritableObject(object);
}
} // namespace internal
......
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