[cleanup] Move GetIsolateFromHeapObject() and friends to src/execution

Bug: v8:9183
Change-Id: Ib17445fe22da683c5be4c3f0249a31502040c2dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1672935
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62331}
This commit is contained in:
Igor Sheludko 2019-06-24 11:49:45 +02:00 committed by Commit Bot
parent 518ae54d17
commit 0f0b31744f
10 changed files with 103 additions and 61 deletions

View File

@ -2179,6 +2179,7 @@ v8_source_set("v8_base_without_compiler") {
"src/execution/interrupts-scope.h",
"src/execution/isolate-data.h",
"src/execution/isolate-inl.h",
"src/execution/isolate-utils.h",
"src/execution/isolate.cc",
"src/execution/isolate.h",
"src/execution/message-template.h",
@ -3304,15 +3305,15 @@ v8_source_set("v8_crash_keys") {
"//components/crash/core/common:crash_key",
]
sources = [
"src/diagnostics/crash-key.cc",
"src/diagnostics/crash-key.cc",
]
} else {
sources = [
"src/diagnostics/crash-key-noop.cc",
"src/diagnostics/crash-key-noop.cc",
]
}
configs = [ ":internal_config" ]
configs = [ ":internal_config" ]
}
group("v8_base") {

View File

@ -0,0 +1,56 @@
// 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_EXECUTION_ISOLATE_UTILS_INL_H_
#define V8_EXECUTION_ISOLATE_UTILS_INL_H_
#include "src/execution/isolate-utils.h"
#include "src/common/ptr-compr-inl.h"
#include "src/execution/isolate.h"
#include "src/heap/heap-write-barrier-inl.h"
namespace v8 {
namespace internal {
V8_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
}
V8_INLINE Isolate* GetIsolateFromWritableObject(HeapObject object) {
#ifdef V8_COMPRESS_POINTERS
Isolate* isolate = Isolate::FromRoot(GetIsolateRoot(object.ptr()));
DCHECK_NOT_NULL(isolate);
return isolate;
#else
return Isolate::FromHeap(GetHeapFromWritableObject(object));
#endif // V8_COMPRESS_POINTERS
}
V8_INLINE bool GetIsolateFromHeapObject(HeapObject object, Isolate** isolate) {
#ifdef V8_COMPRESS_POINTERS
*isolate = GetIsolateFromWritableObject(object);
return true;
#else
heap_internals::MemoryChunk* chunk =
heap_internals::MemoryChunk::FromHeapObject(object);
if (chunk->InReadOnlySpace()) {
*isolate = nullptr;
return false;
}
*isolate = Isolate::FromHeap(chunk->GetHeap());
return true;
#endif // V8_COMPRESS_POINTERS
}
} // namespace internal
} // namespace v8
#endif // V8_EXECUTION_ISOLATE_UTILS_INL_H_

View File

@ -0,0 +1,25 @@
// 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_EXECUTION_ISOLATE_UTILS_H_
#define V8_EXECUTION_ISOLATE_UTILS_H_
#include "src/common/globals.h"
namespace v8 {
namespace internal {
V8_INLINE Heap* GetHeapFromWritableObject(HeapObject object);
V8_INLINE Isolate* GetIsolateFromWritableObject(HeapObject object);
// Returns true if it succeeded to obtain isolate from given object.
// If it fails then the object is definitely a read-only object but it may also
// succeed for read only objects if pointer compression is enabled.
V8_INLINE bool GetIsolateFromHeapObject(HeapObject object, Isolate** isolate);
} // namespace internal
} // namespace v8
#endif // V8_EXECUTION_ISOLATE_UTILS_H_

View File

@ -11,9 +11,6 @@
#include "src/heap/heap-write-barrier.h"
#include "src/common/globals.h"
// TODO(jkummerow): Get rid of this by moving GetIsolateFromWritableObject
// elsewhere.
#include "src/execution/isolate.h"
#include "src/objects/code.h"
#include "src/objects/compressed-slots-inl.h"
#include "src/objects/fixed-array.h"
@ -42,6 +39,9 @@ V8_EXPORT_PRIVATE void Heap_MarkingBarrierForDescriptorArraySlow(
Heap* heap, HeapObject host, HeapObject descriptor_array,
int number_of_own_descriptors);
V8_EXPORT_PRIVATE void Heap_GenerationalEphemeronKeyBarrierSlow(
Heap* heap, EphemeronHashTable table, Address slot);
// Do not use these internal details anywhere outside of this file. These
// internals are only intended to shortcut write barrier checks.
namespace heap_internals {
@ -112,8 +112,7 @@ inline void GenerationalEphemeronKeyBarrierInternal(EphemeronHashTable table,
return;
}
Heap* heap = GetHeapFromWritableObject(table);
heap->RecordEphemeronKeyWrite(table, slot);
Heap_GenerationalEphemeronKeyBarrierSlow(table_chunk->GetHeap(), table, slot);
}
inline void MarkingBarrierInternal(HeapObject object, Address slot,
@ -227,42 +226,6 @@ inline bool ObjectInYoungGeneration(Object object) {
->InYoungGeneration();
}
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
Isolate* isolate = Isolate::FromRoot(GetIsolateRoot(object.ptr()));
DCHECK_NOT_NULL(isolate);
return isolate;
#else
return Isolate::FromHeap(GetHeapFromWritableObject(object));
#endif // V8_COMPRESS_POINTERS
}
inline bool GetIsolateFromHeapObject(HeapObject object, Isolate** isolate) {
#ifdef V8_COMPRESS_POINTERS
*isolate = GetIsolateFromWritableObject(object);
return true;
#else
heap_internals::MemoryChunk* chunk =
heap_internals::MemoryChunk::FromHeapObject(object);
if (chunk->InReadOnlySpace()) {
*isolate = nullptr;
return false;
}
*isolate = Isolate::FromHeap(chunk->GetHeap());
return true;
#endif // V8_COMPRESS_POINTERS
}
inline bool IsReadOnlyHeapObject(HeapObject object) {
heap_internals::MemoryChunk* chunk =
heap_internals::MemoryChunk::FromHeapObject(object);

View File

@ -41,14 +41,6 @@ void MarkingBarrierForDescriptorArray(Heap* heap, HeapObject host,
HeapObject descriptor_array,
int number_of_own_descriptors);
inline Heap* GetHeapFromWritableObject(HeapObject object);
inline Isolate* GetIsolateFromWritableObject(HeapObject object);
// Returns true if it succeeded to obtain isolate from given object.
// If it fails then the object is definitely a read-only object but it may also
// succeed for read only objects if pointer compression is enabled.
inline bool GetIsolateFromHeapObject(HeapObject object, Isolate** isolate);
inline bool IsReadOnlyHeapObject(HeapObject object);
} // namespace internal

View File

@ -119,6 +119,12 @@ void Heap_MarkingBarrierForDescriptorArraySlow(Heap* heap, HeapObject host,
number_of_own_descriptors);
}
void Heap_GenerationalEphemeronKeyBarrierSlow(Heap* heap,
EphemeronHashTable table,
Address slot) {
heap->RecordEphemeronKeyWrite(table, slot);
}
void Heap::SetArgumentsAdaptorDeoptPCOffset(int pc_offset) {
DCHECK_EQ(Smi::kZero, arguments_adaptor_deopt_pc_offset());
set_arguments_adaptor_deopt_pc_offset(Smi::FromInt(pc_offset));

View File

@ -361,8 +361,8 @@ class Heap {
V8_EXPORT_PRIVATE static void GenerationalBarrierSlow(HeapObject object,
Address slot,
HeapObject value);
V8_EXPORT_PRIVATE void RecordEphemeronKeyWrite(EphemeronHashTable table,
Address key_slot);
V8_EXPORT_PRIVATE inline void RecordEphemeronKeyWrite(
EphemeronHashTable table, Address key_slot);
V8_EXPORT_PRIVATE static void EphemeronKeyWriteBarrierFromCode(
Address raw_object, Address address, Isolate* isolate);
V8_EXPORT_PRIVATE static void GenerationalBarrierForCodeSlow(

View File

@ -7,7 +7,7 @@
#include "src/heap/read-only-heap.h"
#include "src/heap/heap-write-barrier-inl.h"
#include "src/execution/isolate-utils-inl.h"
#include "src/roots/roots-inl.h"
namespace v8 {

View File

@ -7,9 +7,8 @@
#include "src/objects/heap-object.h"
#include "src/heap/heap-write-barrier-inl.h"
// TODO(jkummerow): Get rid of this by moving NROSO::GetIsolate elsewhere.
#include "src/execution/isolate.h"
#include "src/execution/isolate-utils-inl.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@ -25,12 +24,12 @@ HeapObject::HeapObject(Address ptr, AllowInlineSmiStorage allow_smi)
}
// static
Heap* NeverReadOnlySpaceObject::GetHeap(const HeapObject object) {
Heap* NeverReadOnlySpaceObject::GetHeap(HeapObject object) {
return GetHeapFromWritableObject(object);
}
// static
Isolate* NeverReadOnlySpaceObject::GetIsolate(const HeapObject object) {
Isolate* NeverReadOnlySpaceObject::GetIsolate(HeapObject object) {
return GetIsolateFromWritableObject(object);
}

View File

@ -216,10 +216,10 @@ CAST_ACCESSOR(HeapObject)
class NeverReadOnlySpaceObject {
public:
// The Heap the object was allocated in. Used also to access Isolate.
static inline Heap* GetHeap(const HeapObject object);
static inline Heap* GetHeap(HeapObject object);
// Convenience method to get current isolate.
static inline Isolate* GetIsolate(const HeapObject object);
static inline Isolate* GetIsolate(HeapObject object);
};
} // namespace internal