#ifndef V8_HANDLES_HANDLES_INL_H_
#define V8_HANDLES_HANDLES_INL_H_
#include "src/base/sanitizer/msan.h"
#include "src/execution/isolate.h"
#include "src/execution/local-isolate.h"
#include "src/handles/handles.h"
#include "src/handles/local-handles-inl.h"
#include "src/objects/casting.h"
#include "src/objects/objects.h"
#ifdef DEBUG
#include "src/utils/ostreams.h"
#endif
namespace v8 {
namespace internal {
class LocalHeap;
HandleBase::HandleBase(Address object, Isolate* isolate)
: … { … }
HandleBase::HandleBase(Address object, LocalIsolate* isolate)
: … { … }
HandleBase::HandleBase(Address object, LocalHeap* local_heap)
: … { … }
bool HandleBase::is_identical_to(const HandleBase& that) const { … }
template <typename T>
Handle<T> Handle<T>::New(Tagged<T> object, Isolate* isolate) { … }
template <typename To, typename From>
inline Handle<To> Cast(Handle<From> value, const v8::SourceLocation& loc) { … }
template <typename T>
Handle<T>::Handle(Tagged<T> object, Isolate* isolate)
: … { … }
template <typename T>
Handle<T>::Handle(Tagged<T> object, LocalIsolate* isolate)
: … { … }
template <typename T>
Handle<T>::Handle(Tagged<T> object, LocalHeap* local_heap)
: … { … }
template <typename T>
V8_INLINE Handle<T> handle(Tagged<T> object, Isolate* isolate) { … }
template <typename T>
V8_INLINE Handle<T> handle(Tagged<T> object, LocalIsolate* isolate) { … }
template <typename T>
V8_INLINE Handle<T> handle(Tagged<T> object, LocalHeap* local_heap) { … }
template <typename T>
V8_INLINE Handle<T> handle(T object, Isolate* isolate) { … }
template <typename T>
V8_INLINE Handle<T> handle(T object, LocalIsolate* isolate) { … }
template <typename T>
V8_INLINE Handle<T> handle(T object, LocalHeap* local_heap) { … }
template <typename T>
inline std::ostream& operator<<(std::ostream& os, Handle<T> handle) { … }
#ifdef V8_ENABLE_DIRECT_HANDLE
template <typename T>
V8_INLINE DirectHandle<T>::DirectHandle(Tagged<T> object)
: DirectHandle(object.ptr()) {}
template <typename To, typename From>
inline DirectHandle<To> Cast(DirectHandle<From> value,
const v8::SourceLocation& loc) {
DCHECK_WITH_MSG_AND_LOC(value.is_null() || Is<To>(*value),
V8_PRETTY_FUNCTION_VALUE_OR("Cast type check"), loc);
return DirectHandle<To>(value.obj_);
}
template <typename T>
inline std::ostream& operator<<(std::ostream& os, DirectHandle<T> handle) {
return os << Brief(*handle);
}
#endif
template <typename T>
V8_INLINE DirectHandle<T> direct_handle(Tagged<T> object, Isolate* isolate) { … }
template <typename T>
V8_INLINE DirectHandle<T> direct_handle(Tagged<T> object,
LocalIsolate* isolate) { … }
template <typename T>
V8_INLINE DirectHandle<T> direct_handle(Tagged<T> object,
LocalHeap* local_heap) { … }
template <typename T>
V8_INLINE DirectHandle<T> direct_handle(T object, Isolate* isolate) { … }
template <typename T>
V8_INLINE DirectHandle<T> direct_handle(T object, LocalIsolate* isolate) { … }
template <typename T>
V8_INLINE DirectHandle<T> direct_handle(T object, LocalHeap* local_heap) { … }
HandleScope::HandleScope(Isolate* isolate) { … }
HandleScope::HandleScope(HandleScope&& other) V8_NOEXCEPT
: … { … }
HandleScope::~HandleScope() { … }
HandleScope& HandleScope::operator=(HandleScope&& other) V8_NOEXCEPT { … }
void HandleScope::CloseScope(Isolate* isolate, Address* prev_next,
Address* prev_limit) { … }
template <typename T>
Handle<T> HandleScope::CloseAndEscape(Handle<T> handle_value) { … }
Address* HandleScope::CreateHandle(Isolate* isolate, Address value) { … }
#ifdef DEBUG
inline SealHandleScope::SealHandleScope(Isolate* isolate) : … { … }
inline SealHandleScope::~SealHandleScope() { … }
#endif
#ifdef V8_ENABLE_DIRECT_HANDLE
bool HandleBase::is_identical_to(const DirectHandleBase& that) const {
SLOW_DCHECK(
(this->location_ == nullptr || this->IsDereferenceAllowed()) &&
(that.address() == kTaggedNullAddress || that.IsDereferenceAllowed()));
if (this->location_ == nullptr && that.address() == kTaggedNullAddress)
return true;
if (this->location_ == nullptr || that.address() == kTaggedNullAddress)
return false;
return Tagged<Object>(*this->location_) == Tagged<Object>(that.address());
}
bool DirectHandleBase::is_identical_to(const HandleBase& that) const {
SLOW_DCHECK(
(this->address() == kTaggedNullAddress || this->IsDereferenceAllowed()) &&
(that.location_ == nullptr || that.IsDereferenceAllowed()));
if (this->address() == kTaggedNullAddress && that.location_ == nullptr)
return true;
if (this->address() == kTaggedNullAddress || that.location_ == nullptr)
return false;
return Tagged<Object>(this->address()) == Tagged<Object>(*that.location_);
}
bool DirectHandleBase::is_identical_to(const DirectHandleBase& that) const {
SLOW_DCHECK(
(this->address() == kTaggedNullAddress || this->IsDereferenceAllowed()) &&
(that.address() == kTaggedNullAddress || that.IsDereferenceAllowed()));
if (this->address() == kTaggedNullAddress &&
that.address() == kTaggedNullAddress)
return true;
if (this->address() == kTaggedNullAddress ||
that.address() == kTaggedNullAddress)
return false;
return Tagged<Object>(this->address()) == Tagged<Object>(that.address());
}
#endif
template <typename T>
V8_INLINE Handle<T> indirect_handle(DirectHandle<T> handle, Isolate* isolate) { … }
template <typename T>
V8_INLINE Handle<T> indirect_handle(DirectHandle<T> handle,
LocalIsolate* isolate) { … }
}
}
#endif