Commit 0f0b3174 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

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

Bug: v8:9183
Change-Id: Ib17445fe22da683c5be4c3f0249a31502040c2dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1672935Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62331}
parent 518ae54d
...@@ -2179,6 +2179,7 @@ v8_source_set("v8_base_without_compiler") { ...@@ -2179,6 +2179,7 @@ v8_source_set("v8_base_without_compiler") {
"src/execution/interrupts-scope.h", "src/execution/interrupts-scope.h",
"src/execution/isolate-data.h", "src/execution/isolate-data.h",
"src/execution/isolate-inl.h", "src/execution/isolate-inl.h",
"src/execution/isolate-utils.h",
"src/execution/isolate.cc", "src/execution/isolate.cc",
"src/execution/isolate.h", "src/execution/isolate.h",
"src/execution/message-template.h", "src/execution/message-template.h",
...@@ -3304,15 +3305,15 @@ v8_source_set("v8_crash_keys") { ...@@ -3304,15 +3305,15 @@ v8_source_set("v8_crash_keys") {
"//components/crash/core/common:crash_key", "//components/crash/core/common:crash_key",
] ]
sources = [ sources = [
"src/diagnostics/crash-key.cc", "src/diagnostics/crash-key.cc",
] ]
} else { } else {
sources = [ sources = [
"src/diagnostics/crash-key-noop.cc", "src/diagnostics/crash-key-noop.cc",
] ]
} }
configs = [ ":internal_config" ] configs = [ ":internal_config" ]
} }
group("v8_base") { group("v8_base") {
......
// 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_
// 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_
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
#include "src/heap/heap-write-barrier.h" #include "src/heap/heap-write-barrier.h"
#include "src/common/globals.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/code.h"
#include "src/objects/compressed-slots-inl.h" #include "src/objects/compressed-slots-inl.h"
#include "src/objects/fixed-array.h" #include "src/objects/fixed-array.h"
...@@ -42,6 +39,9 @@ V8_EXPORT_PRIVATE void Heap_MarkingBarrierForDescriptorArraySlow( ...@@ -42,6 +39,9 @@ V8_EXPORT_PRIVATE void Heap_MarkingBarrierForDescriptorArraySlow(
Heap* heap, HeapObject host, HeapObject descriptor_array, Heap* heap, HeapObject host, HeapObject descriptor_array,
int number_of_own_descriptors); 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 // Do not use these internal details anywhere outside of this file. These
// internals are only intended to shortcut write barrier checks. // internals are only intended to shortcut write barrier checks.
namespace heap_internals { namespace heap_internals {
...@@ -112,8 +112,7 @@ inline void GenerationalEphemeronKeyBarrierInternal(EphemeronHashTable table, ...@@ -112,8 +112,7 @@ inline void GenerationalEphemeronKeyBarrierInternal(EphemeronHashTable table,
return; return;
} }
Heap* heap = GetHeapFromWritableObject(table); Heap_GenerationalEphemeronKeyBarrierSlow(table_chunk->GetHeap(), table, slot);
heap->RecordEphemeronKeyWrite(table, slot);
} }
inline void MarkingBarrierInternal(HeapObject object, Address slot, inline void MarkingBarrierInternal(HeapObject object, Address slot,
...@@ -227,42 +226,6 @@ inline bool ObjectInYoungGeneration(Object object) { ...@@ -227,42 +226,6 @@ inline bool ObjectInYoungGeneration(Object object) {
->InYoungGeneration(); ->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) { inline bool IsReadOnlyHeapObject(HeapObject object) {
heap_internals::MemoryChunk* chunk = heap_internals::MemoryChunk* chunk =
heap_internals::MemoryChunk::FromHeapObject(object); heap_internals::MemoryChunk::FromHeapObject(object);
......
...@@ -41,14 +41,6 @@ void MarkingBarrierForDescriptorArray(Heap* heap, HeapObject host, ...@@ -41,14 +41,6 @@ void MarkingBarrierForDescriptorArray(Heap* heap, HeapObject host,
HeapObject descriptor_array, HeapObject descriptor_array,
int number_of_own_descriptors); 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); inline bool IsReadOnlyHeapObject(HeapObject object);
} // namespace internal } // namespace internal
......
...@@ -119,6 +119,12 @@ void Heap_MarkingBarrierForDescriptorArraySlow(Heap* heap, HeapObject host, ...@@ -119,6 +119,12 @@ void Heap_MarkingBarrierForDescriptorArraySlow(Heap* heap, HeapObject host,
number_of_own_descriptors); number_of_own_descriptors);
} }
void Heap_GenerationalEphemeronKeyBarrierSlow(Heap* heap,
EphemeronHashTable table,
Address slot) {
heap->RecordEphemeronKeyWrite(table, slot);
}
void Heap::SetArgumentsAdaptorDeoptPCOffset(int pc_offset) { void Heap::SetArgumentsAdaptorDeoptPCOffset(int pc_offset) {
DCHECK_EQ(Smi::kZero, arguments_adaptor_deopt_pc_offset()); DCHECK_EQ(Smi::kZero, arguments_adaptor_deopt_pc_offset());
set_arguments_adaptor_deopt_pc_offset(Smi::FromInt(pc_offset)); set_arguments_adaptor_deopt_pc_offset(Smi::FromInt(pc_offset));
......
...@@ -361,8 +361,8 @@ class Heap { ...@@ -361,8 +361,8 @@ class Heap {
V8_EXPORT_PRIVATE static void GenerationalBarrierSlow(HeapObject object, V8_EXPORT_PRIVATE static void GenerationalBarrierSlow(HeapObject object,
Address slot, Address slot,
HeapObject value); HeapObject value);
V8_EXPORT_PRIVATE void RecordEphemeronKeyWrite(EphemeronHashTable table, V8_EXPORT_PRIVATE inline void RecordEphemeronKeyWrite(
Address key_slot); EphemeronHashTable table, Address key_slot);
V8_EXPORT_PRIVATE static void EphemeronKeyWriteBarrierFromCode( V8_EXPORT_PRIVATE static void EphemeronKeyWriteBarrierFromCode(
Address raw_object, Address address, Isolate* isolate); Address raw_object, Address address, Isolate* isolate);
V8_EXPORT_PRIVATE static void GenerationalBarrierForCodeSlow( V8_EXPORT_PRIVATE static void GenerationalBarrierForCodeSlow(
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "src/heap/read-only-heap.h" #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" #include "src/roots/roots-inl.h"
namespace v8 { namespace v8 {
......
...@@ -7,9 +7,8 @@ ...@@ -7,9 +7,8 @@
#include "src/objects/heap-object.h" #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. // 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): // Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h" #include "src/objects/object-macros.h"
...@@ -25,12 +24,12 @@ HeapObject::HeapObject(Address ptr, AllowInlineSmiStorage allow_smi) ...@@ -25,12 +24,12 @@ HeapObject::HeapObject(Address ptr, AllowInlineSmiStorage allow_smi)
} }
// static // static
Heap* NeverReadOnlySpaceObject::GetHeap(const HeapObject object) { Heap* NeverReadOnlySpaceObject::GetHeap(HeapObject object) {
return GetHeapFromWritableObject(object); return GetHeapFromWritableObject(object);
} }
// static // static
Isolate* NeverReadOnlySpaceObject::GetIsolate(const HeapObject object) { Isolate* NeverReadOnlySpaceObject::GetIsolate(HeapObject object) {
return GetIsolateFromWritableObject(object); return GetIsolateFromWritableObject(object);
} }
......
...@@ -216,10 +216,10 @@ CAST_ACCESSOR(HeapObject) ...@@ -216,10 +216,10 @@ CAST_ACCESSOR(HeapObject)
class NeverReadOnlySpaceObject { class NeverReadOnlySpaceObject {
public: public:
// The Heap the object was allocated in. Used also to access Isolate. // 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. // Convenience method to get current isolate.
static inline Isolate* GetIsolate(const HeapObject object); static inline Isolate* GetIsolate(HeapObject object);
}; };
} // namespace internal } // 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