5#ifndef V8_OBJECTS_MANAGED_INL_H_
6#define V8_OBJECTS_MANAGED_INL_H_
18template <
typename CppType>
20 auto shared_ptr_ptr =
reinterpret_cast<std::shared_ptr<CppType>*
>(ptr);
21 delete shared_ptr_ptr;
26template <
class CppType>
28 Isolate* isolate,
size_t estimated_size,
29 std::shared_ptr<CppType> shared_ptr,
AllocationType allocation_type) {
33 estimated_size,
new std::shared_ptr<CppType>{std::move(shared_ptr)},
36 reinterpret_cast<v8::Isolate*
>(isolate), estimated_size);
39 reinterpret_cast<Address>(destructor), allocation_type));
41 isolate->global_handles()->Create(*
handle);
42 destructor->global_handle_location_ = global_handle.
location();
46 isolate->RegisterManagedPtrDestructor(destructor);
51template <
class CppType>
53 Isolate* isolate,
size_t estimated_size,
54 std::shared_ptr<CppType> shared_ptr) {
56 estimated_size,
new std::shared_ptr<CppType>{std::move(shared_ptr)},
59 reinterpret_cast<v8::Isolate*
>(isolate), estimated_size);
62 reinterpret_cast<Address>(destructor)));
64 isolate->global_handles()->Create(*
handle);
65 destructor->global_handle_location_ = global_handle.
location();
69 isolate->RegisterManagedPtrDestructor(destructor);
void Increase(Isolate *isolate, size_t size)
static void MakeWeak(Address *location, void *parameter, WeakCallbackInfo< void >::Callback weak_callback, v8::WeakCallbackType type)
V8_INLINE Address * location() const
static DirectHandle< Managed< CppType > > From(Isolate *isolate, size_t estimated_size, std::shared_ptr< CppType > shared_ptr, AllocationType allocation_type=AllocationType::kYoung)
static DirectHandle< TrustedManaged< CppType > > From(Isolate *isolate, size_t estimated_size, std::shared_ptr< CppType > shared_ptr)
static void Destructor(void *ptr)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
static V8_INLINE constexpr bool IsManagedExternalPointerType(ExternalPointerTagRange tag_range)
void ManagedObjectFinalizer(const v8::WeakCallbackInfo< void > &data)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
V8_NO_UNIQUE_ADDRESS ExternalMemoryAccounter external_memory_accounter_