#include "src/handles/global-handles.h"
#include <algorithm>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <map>
#include "src/api/api-inl.h"
#include "src/base/compiler-specific.h"
#include "src/base/logging.h"
#include "src/base/sanitizer/asan.h"
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/execution/vm-state-inl.h"
#include "src/heap/base/stack.h"
#include "src/heap/gc-tracer-inl.h"
#include "src/heap/gc-tracer.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap-write-barrier-inl.h"
#include "src/heap/heap-write-barrier.h"
#include "src/heap/local-heap.h"
#include "src/init/v8.h"
#include "src/logging/counters.h"
#include "src/objects/objects-inl.h"
#include "src/objects/slots.h"
#include "src/objects/visitors.h"
#include "src/tasks/cancelable-task.h"
#include "src/tasks/task-utils.h"
#include "src/utils/utils.h"
namespace v8 {
namespace internal {
namespace {
constexpr size_t kBlockSize = …;
}
enum class WeaknessType { … };
template <class _NodeType>
class GlobalHandles::NodeBlock final { … };
template <class NodeType>
const GlobalHandles::NodeBlock<NodeType>*
GlobalHandles::NodeBlock<NodeType>::From(const NodeType* node) { … }
template <class NodeType>
GlobalHandles::NodeBlock<NodeType>* GlobalHandles::NodeBlock<NodeType>::From(
NodeType* node) { … }
template <class NodeType>
bool GlobalHandles::NodeBlock<NodeType>::IncreaseUsage() { … }
template <class NodeType>
void GlobalHandles::NodeBlock<NodeType>::ListAdd(BlockType** top) { … }
template <class NodeType>
bool GlobalHandles::NodeBlock<NodeType>::DecreaseUsage() { … }
template <class NodeType>
void GlobalHandles::NodeBlock<NodeType>::ListRemove(BlockType** top) { … }
template <class BlockType>
class GlobalHandles::NodeIterator final { … };
template <class NodeType>
class GlobalHandles::NodeSpace final { … };
template <class NodeType>
GlobalHandles::NodeSpace<NodeType>::~NodeSpace() { … }
template <class NodeType>
NodeType* GlobalHandles::NodeSpace<NodeType>::Allocate() { … }
template <class NodeType>
void GlobalHandles::NodeSpace<NodeType>::PutNodesOnFreeList(BlockType* block) { … }
template <class NodeType>
void GlobalHandles::NodeSpace<NodeType>::Release(NodeType* node) { … }
template <class NodeType>
void GlobalHandles::NodeSpace<NodeType>::Free(NodeType* node) { … }
template <class Child>
class NodeBase { … };
namespace {
void ExtractInternalFields(Tagged<JSObject> jsobject, void** embedder_fields,
int len) { … }
}
class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> { … };
size_t GlobalHandles::TotalSize() const { … }
size_t GlobalHandles::UsedSize() const { … }
size_t GlobalHandles::handles_count() const { … }
GlobalHandles::GlobalHandles(Isolate* isolate)
: … { … }
GlobalHandles::~GlobalHandles() = default;
namespace {
template <typename NodeType>
bool NeedsTrackingInYoungNodes(Tagged<Object> value, NodeType* node) { … }
}
Handle<Object> GlobalHandles::Create(Tagged<Object> value) { … }
Handle<Object> GlobalHandles::Create(Address value) { … }
Handle<Object> GlobalHandles::CopyGlobal(Address* location) { … }
void GlobalHandles::MoveGlobal(Address** from, Address** to) { … }
void GlobalHandles::Destroy(Address* location) { … }
GenericCallback;
void GlobalHandles::MakeWeak(Address* location, void* parameter,
GenericCallback phantom_callback,
v8::WeakCallbackType type) { … }
void GlobalHandles::MakeWeak(Address** location_addr) { … }
void* GlobalHandles::ClearWeakness(Address* location) { … }
void GlobalHandles::AnnotateStrongRetainer(Address* location,
const char* label) { … }
bool GlobalHandles::IsWeak(Address* location) { … }
V8_INLINE bool GlobalHandles::ResetWeakNodeIfDead(
Node* node, WeakSlotCallbackWithHeap should_reset_handle) { … }
DISABLE_CFI_PERF
void GlobalHandles::IterateWeakRootsForPhantomHandles(
WeakSlotCallbackWithHeap should_reset_handle) { … }
void GlobalHandles::IterateYoungStrongAndDependentRoots(RootVisitor* v) { … }
void GlobalHandles::ProcessWeakYoungObjects(
RootVisitor* v, WeakSlotCallbackWithHeap should_reset_handle) { … }
void GlobalHandles::InvokeSecondPassPhantomCallbacks() { … }
namespace {
template <typename T>
void UpdateListOfYoungNodesImpl(Isolate* isolate, std::vector<T*>* node_list) { … }
template <typename T>
void ClearListOfYoungNodesImpl(Isolate* isolate, std::vector<T*>* node_list) { … }
}
void GlobalHandles::UpdateListOfYoungNodes() { … }
void GlobalHandles::ClearListOfYoungNodes() { … }
size_t GlobalHandles::InvokeFirstPassWeakCallbacks() { … }
void GlobalHandles::PendingPhantomCallback::Invoke(Isolate* isolate,
InvocationType type) { … }
void GlobalHandles::PostGarbageCollectionProcessing(
v8::GCCallbackFlags gc_callback_flags) { … }
void GlobalHandles::IterateStrongRoots(RootVisitor* v) { … }
void GlobalHandles::IterateWeakRoots(RootVisitor* v) { … }
DISABLE_CFI_PERF
void GlobalHandles::IterateAllRoots(RootVisitor* v) { … }
DISABLE_CFI_PERF
void GlobalHandles::IterateAllYoungRoots(RootVisitor* v) { … }
DISABLE_CFI_PERF
void GlobalHandles::ApplyPersistentHandleVisitor(
v8::PersistentHandleVisitor* visitor, GlobalHandles::Node* node) { … }
void GlobalHandles::IterateAllRootsForTesting(
v8::PersistentHandleVisitor* visitor) { … }
void GlobalHandles::RecordStats(HeapStats* stats) { … }
#ifdef DEBUG
void GlobalHandles::PrintStats() { … }
void GlobalHandles::Print() { … }
#endif
EternalHandles::~EternalHandles() { … }
void EternalHandles::IterateAllRoots(RootVisitor* visitor) { … }
void EternalHandles::IterateYoungRoots(RootVisitor* visitor) { … }
void EternalHandles::PostGarbageCollectionProcessing() { … }
void EternalHandles::Create(Isolate* isolate, Tagged<Object> object,
int* index) { … }
}
}