5#ifndef V8_HANDLES_HANDLES_INL_H_
6#define V8_HANDLES_HANDLES_INL_H_
38 (that.
location_ ==
nullptr || that.IsDereferenceAllowed()));
50template <
typename T,
typename U>
52 return value.is_null() ||
Is<T>(*value);
54template <
typename To,
typename From>
109#ifdef V8_ENABLE_DIRECT_HANDLE
113 : DirectHandle(object.ptr()) {}
115template <
typename T,
typename U>
116inline bool Is(DirectHandle<U> value) {
117 return value.is_null() || Is<T>(*value);
119template <
typename To,
typename From>
120inline DirectHandle<To>
UncheckedCast(DirectHandle<From> value) {
121 return DirectHandle<To>(value.obj_);
126template <
typename T,
typename U>
128 return value.is_null() || Is<T>(*value);
130template <
typename To,
typename From>
161 static_assert(kTaggedCanConvertToRawObjects);
167 static_assert(kTaggedCanConvertToRawObjects);
173 static_assert(kTaggedCanConvertToRawObjects);
183#ifdef V8_ENABLE_CHECKS
184 scope_level_ = data->level;
190 prev_next_(other.prev_next_),
191 prev_limit_(other.prev_limit_) {
192 other.isolate_ =
nullptr;
193#ifdef V8_ENABLE_CHECKS
194 scope_level_ = other.scope_level_;
200#ifdef V8_ENABLE_CHECKS
211#ifdef V8_ENABLE_CHECKS
214 CloseScope(
isolate_, prev_next_, prev_limit_);
216 prev_next_ = other.prev_next_;
217 prev_limit_ = other.prev_limit_;
218 other.isolate_ =
nullptr;
219#ifdef V8_ENABLE_CHECKS
220 scope_level_ = other.scope_level_;
225void HandleScope::CloseScope(
Isolate* isolate, Address* prev_next,
226 Address* prev_limit) {
233 std::swap(current->next, prev_next);
235 Address* limit = prev_next;
237 current->limit = prev_limit;
239 DeleteExtensions(isolate);
241#ifdef ENABLE_LOCAL_HANDLE_ZAPPING
242 ZapRange(current->next, limit);
246 static_cast<size_t>(
reinterpret_cast<Address
>(limit) -
247 reinterpret_cast<Address
>(current->next)));
250 DCHECK_LT(after - before, kCheckHandleThreshold);
251 DCHECK_LT(before, kCheckHandleThreshold);
255template <
typename T,
template <
typename>
typename HandleType>
257HandleType<T> HandleScope::CloseAndEscape(HandleType<T> handle_value) {
260#ifdef V8_ENABLE_CHECKS
264 CloseScope(
isolate_, prev_next_, prev_limit_);
266 DCHECK(current->level > current->sealed_level);
270 prev_next_ = current->next;
271 prev_limit_ = current->limit;
277 DCHECK(AllowHandleAllocation::IsAllowed());
279 if (!AllowHandleUsageOnAllThreads::IsAllowed()) {
280 DCHECK(isolate->main_thread_local_heap()->IsRunning());
282 isolate->thread_id() == ThreadId::Current(),
283 "main-thread handle can only be created on the main thread.");
287 Address*
result = data->next;
294 reinterpret_cast<Address
>(data->limit));
295 data->next =
reinterpret_cast<Address*
>(
reinterpret_cast<Address
>(
result) +
304 DCHECK(AllowHandleAllocation::IsAllowed());
309 current->limit = current->next;
310 prev_sealed_level_ = current->sealed_level;
311 current->sealed_level = current->level;
317 HandleScopeData* current =
isolate_->handle_scope_data();
318 DCHECK_EQ(current->next, current->limit);
319 current->limit = prev_limit_;
320 DCHECK_EQ(current->level, current->sealed_level);
321 current->sealed_level = prev_sealed_level_;
325#ifdef V8_ENABLE_DIRECT_HANDLE
337bool DirectHandleBase::is_identical_to(
const HandleBase& that)
const {
340 (that.location_ ==
nullptr || that.IsDereferenceAllowed()));
348bool DirectHandleBase::is_identical_to(
const DirectHandleBase& that)
const {
#define SLOW_DCHECK(condition)
internal::Address * prev_next_
void operator=(const HandleScope &)=delete
static int NumberOfHandles(Isolate *isolate)
V8_INLINE HandleScope()=default
internal::Address * prev_limit_
static internal::Address * CreateHandle(internal::Isolate *i_isolate, internal::Address value)
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
SealHandleScope(Isolate *isolate)
friend class DirectHandle
V8_INLINE HandleBase(Address *location)
V8_INLINE bool is_identical_to(const HandleBase &that) const
V8_INLINE bool IsDereferenceAllowed() const
static V8_INLINE Address * CreateHandle(Isolate *isolate, Address value)
V8_INLINE HandleScopeData * handle_scope_data()
~SealHandleScope()=default
ZoneVector< RpoNumber > & result
LinkageLocation location_
#define MSAN_ALLOCATED_UNINITIALIZED_MEMORY(start, size)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
constexpr Address kTaggedNullAddress
bool Is(IndirectHandle< U > value)
static constexpr bool kTaggedCanConvertToRawObjects
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)
Handle< To > UncheckedCast(Handle< From > value)
V8_EXPORT_PRIVATE FlagValues v8_flags
std::ostream & operator<<(std::ostream &os, const Operation &operation)
#define DCHECK_WITH_MSG(condition, msg)
#define DCHECK_NOT_NULL(val)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define V8_UNLIKELY(condition)
std::unique_ptr< ValueMirror > value