Loading...
Searching...
No Matches
v8-local-handle.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_LOCAL_HANDLE_H_
6#define INCLUDE_V8_LOCAL_HANDLE_H_
7
8#include <stddef.h>
9
10#include <type_traits>
11#include <vector>
12
13#include "v8-handle-base.h" // NOLINT(build/include_directory)
14#include "v8-internal.h" // NOLINT(build/include_directory)
15
16namespace v8 {
17
18template <class T>
19class LocalBase;
20template <class T>
21class Local;
22template <class T>
23class LocalVector;
24template <class F>
25class MaybeLocal;
26
27template <class T>
28class Eternal;
29template <class T>
30class Global;
31
32template <class T>
33class NonCopyablePersistentTraits;
34template <class T>
35class PersistentBase;
36template <class T, class M = NonCopyablePersistentTraits<T>>
37class Persistent;
38
39class TracedReferenceBase;
40template <class T>
41class BasicTracedReference;
42template <class F>
43class TracedReference;
44
45class Boolean;
46class Context;
47class EscapableHandleScope;
48template <class F>
49class FunctionCallbackInfo;
50class Isolate;
51class Object;
52template <class F1, class F2, class F3>
53class PersistentValueMapBase;
54class Primitive;
55class Private;
56template <class F>
57class PropertyCallbackInfo;
58template <class F>
59class ReturnValue;
60class String;
61template <class F>
62class Traced;
64class Utils;
65class Value;
66
67namespace debug {
68class ConsoleCallArguments;
69}
70
71namespace internal {
72template <typename T>
74template <typename T>
75class LocalUnchecked;
76class SamplingHeapProfiler;
77} // namespace internal
78
79namespace api_internal {
80// Called when ToLocalChecked is called on an empty Local.
82
83#ifdef V8_ENABLE_CHECKS
84template <typename T, typename V = Value>
85void TypeCheckLocal(V* value) {
86 // If `T` does not provide a `Cast` method we cannot check anything.
87 if constexpr (requires { T::Cast(value); }) {
88 // Execute the actual check (part of the cast).
89 T::Cast(value);
90 }
91}
92#endif
93} // namespace api_internal
94
110 public:
111 V8_INLINE explicit HandleScope(Isolate* isolate);
112
114
118 static int NumberOfHandles(Isolate* isolate);
119
120 V8_INLINE Isolate* GetIsolate() const { return isolate_; }
121
122 HandleScope(const HandleScope&) = delete;
123 void operator=(const HandleScope&) = delete;
124
126 internal::Address value);
127
128 protected:
130
131 V8_INLINE void Initialize(Isolate* isolate);
132
133 V8_INLINE static internal::Address* CreateHandle(Isolate* i_isolate,
134 internal::Address value);
135
136 private:
137 // Extend the HandleScope making room for more handles. Not inlined.
138 static internal::Address* Extend(Isolate* isolate);
139 // Delete any extensions in HandleScope destructor. Not called unless there
140 // are extensions. Not inlined.
141 void DeleteExtensions(Isolate* isolate);
142
143#ifdef V8_ENABLE_CHECKS
144 // Non-inlined asserts on HandleScope constructor.
145 void DoInitializeAsserts(Isolate* isolate);
146 // Non-inlined assert for HandleScope destructor.
147 void AssertScopeLevelsMatch();
148 // Non-inlined asserts for HandleScope destructor. Also zaps the slots
149 // if this is enabled.
150 void DoCloseScopeAsserts(int before, internal::Address* limit,
152#endif
153
154 // Declaring operator new and delete as deleted is not spec compliant.
155 // Therefore declare them private instead to disable dynamic alloc
156 void* operator new(size_t size);
157 void* operator new[](size_t size);
158 void operator delete(void*, size_t);
159 void operator delete[](void*, size_t);
160
161 Isolate* isolate_;
162 internal::Address* prev_next_;
163 internal::Address* prev_limit_;
164#ifdef V8_ENABLE_CHECKS
165 int scope_level_ = 0;
166#endif
167
168 // LocalBase<T>::New uses CreateHandle with an Isolate* parameter.
169 template <typename T>
170 friend class LocalBase;
171
172 // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
173 // a HeapObject in their shortcuts.
174 friend class Object;
175 friend class Context;
176};
177
178HandleScope::HandleScope(Isolate* v8_isolate) { Initialize(v8_isolate); }
179
181 using I = internal::Internals;
182 internal::HandleScopeData* current = I::GetHandleScopeData(v8_isolate);
183 isolate_ = v8_isolate;
184 prev_next_ = current->next;
185 prev_limit_ = current->limit;
186 current->level++;
187#ifdef V8_ENABLE_CHECKS
188 DoInitializeAsserts(v8_isolate);
189 scope_level_ = current->level;
190#endif
191}
192
194 if (V8_UNLIKELY(isolate_ == nullptr)) return;
195#ifdef V8_ENABLE_CHECKS
196 AssertScopeLevelsMatch();
197 int handle_count_before = NumberOfHandles(isolate_);
198#endif
199
200 using I = internal::Internals;
201 internal::HandleScopeData* current = I::GetHandleScopeData(isolate_);
202 std::swap(current->next, prev_next_);
203 current->level--;
204 internal::Address* limit = prev_next_;
205 if (V8_UNLIKELY(current->limit != prev_limit_)) {
206 current->limit = prev_limit_;
207 limit = prev_limit_;
208 DeleteExtensions(isolate_);
209 }
210#ifdef V8_ENABLE_CHECKS
211 DoCloseScopeAsserts(handle_count_before, limit, current);
212#else
213 (void)limit; // Avoid unused variable warning.
214#endif
215}
216
218 internal::Address value) {
219 using I = internal::Internals;
220 internal::HandleScopeData* data = I::GetHandleScopeData(v8_isolate);
221 internal::Address* result = data->next;
222 if (V8_UNLIKELY(result == data->limit)) {
223 result = Extend(v8_isolate);
224 }
225 // Update the current next field, set the value in the created handle,
226 // and return the result.
227 data->next = reinterpret_cast<internal::Address*>(
228 reinterpret_cast<internal::Address>(result) + sizeof(internal::Address));
229 *result = value;
230 return result;
231}
232
239#ifdef V8_ENABLE_DIRECT_HANDLE
240
241template <typename T>
242class LocalBase : public api_internal::DirectHandleBase {
243 protected:
244 template <class F>
245 friend class Local;
246
247 V8_INLINE LocalBase() = default;
248
249 V8_INLINE explicit LocalBase(internal::Address ptr) : DirectHandleBase(ptr) {
250#ifdef V8_ENABLE_CHECKS
251 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
252#endif
253 }
254
255 template <typename S>
256 V8_INLINE LocalBase(const LocalBase<S>& other) : DirectHandleBase(other) {}
257
258 V8_INLINE static LocalBase<T> New(Isolate* isolate, internal::Address value) {
259 return LocalBase<T>(value);
260 }
261
262 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
263 return LocalBase<T>::New(isolate,
265 }
266
267 V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
268 if (slot == nullptr) return LocalBase<T>();
269 return LocalBase<T>(*slot);
270 }
271
272 V8_INLINE static LocalBase<T> FromRepr(
274 return LocalBase<T>(repr);
275 }
276};
277
278#else // !V8_ENABLE_DIRECT_HANDLE
279
280template <typename T>
282 protected:
283 template <class F>
284 friend class Local;
285
286 V8_INLINE LocalBase() = default;
287
289 : IndirectHandleBase(location) {
290#ifdef V8_ENABLE_CHECKS
291 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
292#endif
293 }
294
295 template <typename S>
297
299 return LocalBase(HandleScope::CreateHandle(isolate, value));
300 }
301
302 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
304 return LocalBase<T>::New(isolate,
306 }
307
309 return LocalBase<T>(slot);
310 }
311
314 return LocalBase<T>(repr);
315 }
316};
317
318#endif // V8_ENABLE_DIRECT_HANDLE
319
349template <class T>
351#ifdef V8_ENABLE_LOCAL_OFF_STACK_CHECK
353#else
354 public api_internal::StackAllocated<false>
355#endif
356{
357 public:
361 V8_INLINE Local() = default;
362
368 template <class S>
369 requires std::is_base_of_v<T, S>
370 V8_INLINE Local(Local<S> that) : LocalBase<T>(that) {}
371
372 V8_INLINE T* operator->() const { return this->template value<T>(); }
373
374 V8_INLINE T* operator*() const { return this->operator->(); }
375
387 template <class S>
388 V8_INLINE bool operator==(const Local<S>& that) const {
389 return internal::HandleHelper::EqualHandles(*this, that);
390 }
391
392 template <class S>
393 V8_INLINE bool operator==(const PersistentBase<S>& that) const {
394 return internal::HandleHelper::EqualHandles(*this, that);
395 }
396
397 template <class S>
398 V8_INLINE bool operator!=(const Local<S>& that) const {
399 return !operator==(that);
400 }
401
402 template <class S>
403 V8_INLINE bool operator!=(const Persistent<S>& that) const {
404 return !operator==(that);
405 }
406
412 template <class S>
414#ifdef V8_ENABLE_CHECKS
415 // If we're going to perform the type check then we have to check
416 // that the handle isn't empty before doing the checked cast.
417 if (that.IsEmpty()) return Local<T>();
418 T::Cast(that.template value<S>());
419#endif
420 return Local<T>(LocalBase<T>(that));
421 }
422
428 template <class S>
430 return Local<S>::Cast(*this);
431 }
432
438 V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that) {
439 return New(isolate, that.template value<T, true>());
440 }
441
442 V8_INLINE static Local<T> New(Isolate* isolate,
443 const PersistentBase<T>& that) {
444 return New(isolate, that.template value<T, true>());
445 }
446
447 V8_INLINE static Local<T> New(Isolate* isolate,
448 const BasicTracedReference<T>& that) {
449 return New(isolate, that.template value<T, true>());
450 }
451
452 private:
454 friend class Utils;
455 template <class F>
456 friend class Eternal;
457 template <class F>
458 friend class Global;
459 template <class F>
460 friend class Local;
461 template <class F>
462 friend class MaybeLocal;
463 template <class F, class M>
464 friend class Persistent;
465 template <class F>
467 template <class F>
469 friend class String;
470 friend class Object;
471 friend class Context;
472 friend class Isolate;
473 friend class Private;
474 template <class F>
476 friend Local<Primitive> Undefined(Isolate* isolate);
477 friend Local<Primitive> Null(Isolate* isolate);
478 friend Local<Boolean> True(Isolate* isolate);
479 friend Local<Boolean> False(Isolate* isolate);
480 friend class HandleScope;
483 template <class F1, class F2, class F3>
485 template <class F>
486 friend class ReturnValue;
487 template <class F>
488 friend class Traced;
489 friend class internal::SamplingHeapProfiler;
491 friend class debug::ConsoleCallArguments;
492 friend class internal::LocalUnchecked<T>;
493
494 explicit Local(no_checking_tag do_not_check)
495 : LocalBase<T>(), StackAllocated(do_not_check) {}
496 explicit Local(const Local<T>& other, no_checking_tag do_not_check)
497 : LocalBase<T>(other), StackAllocated(do_not_check) {}
498
499 V8_INLINE explicit Local(const LocalBase<T>& other) : LocalBase<T>(other) {}
500
501 V8_INLINE static Local<T> FromRepr(
502 internal::ValueHelper::InternalRepresentationType repr) {
503 return Local<T>(LocalBase<T>::FromRepr(repr));
504 }
505
506 V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
507 return Local<T>(LocalBase<T>::FromSlot(slot));
508 }
509
510#ifdef V8_ENABLE_DIRECT_HANDLE
511 friend class TypecheckWitness;
512
513 V8_INLINE static Local<T> FromAddress(internal::Address ptr) {
514 return Local<T>(LocalBase<T>(ptr));
515 }
516#endif // V8_ENABLE_DIRECT_HANDLE
517
518 V8_INLINE static Local<T> New(Isolate* isolate, internal::Address value) {
519 return Local<T>(LocalBase<T>::New(isolate, value));
520 }
521
522 V8_INLINE static Local<T> New(Isolate* isolate, T* that) {
523 return Local<T>(LocalBase<T>::New(isolate, that));
524 }
525
526 // Unsafe cast, should be avoided.
527 template <class S>
528 V8_INLINE Local<S> UnsafeAs() const {
529 return Local<S>(LocalBase<S>(*this));
530 }
531};
532
533namespace internal {
534// A local variant that is suitable for off-stack allocation.
535// Used internally by LocalVector<T>. Not to be used directly!
536template <typename T>
538 public:
539 LocalUnchecked() : Local<T>(Local<T>::do_not_check) {}
540
541#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
542 // In this case, the check is also enforced in the copy constructor and we
543 // need to suppress it.
545 const LocalUnchecked& other) noexcept // NOLINT(runtime/explicit)
547 LocalUnchecked& operator=(const LocalUnchecked&) noexcept = default;
548#endif
549
550 // Implicit conversion from Local.
551 LocalUnchecked(const Local<T>& other) noexcept // NOLINT(runtime/explicit)
553};
554
555#ifdef V8_ENABLE_DIRECT_HANDLE
556// Off-stack allocated direct locals must be registered as strong roots.
557// For off-stack indirect locals, this is not necessary.
558
559template <typename T>
560class StrongRootAllocator<LocalUnchecked<T>> : public StrongRootAllocatorBase {
561 public:
562 using value_type = LocalUnchecked<T>;
563 static_assert(std::is_standard_layout_v<value_type>);
564 static_assert(sizeof(value_type) == sizeof(Address));
565
566 template <typename HeapOrIsolateT>
567 explicit StrongRootAllocator(HeapOrIsolateT* heap_or_isolate)
568 : StrongRootAllocatorBase(heap_or_isolate) {}
569 template <typename U>
570 StrongRootAllocator(const StrongRootAllocator<U>& other) noexcept
571 : StrongRootAllocatorBase(other) {}
572
573 value_type* allocate(size_t n) {
574 return reinterpret_cast<value_type*>(allocate_impl(n));
575 }
576 void deallocate(value_type* p, size_t n) noexcept {
577 return deallocate_impl(reinterpret_cast<Address*>(p), n);
578 }
579};
580#endif // V8_ENABLE_DIRECT_HANDLE
581} // namespace internal
582
583template <typename T>
585 private:
587
588#ifdef V8_ENABLE_DIRECT_HANDLE
589 using allocator_type = internal::StrongRootAllocator<element_type>;
590
591 static allocator_type make_allocator(Isolate* isolate) noexcept {
592 return allocator_type(isolate);
593 }
594#else
595 using allocator_type = std::allocator<element_type>;
596
597 static allocator_type make_allocator(Isolate* isolate) noexcept {
598 return allocator_type();
599 }
600#endif // V8_ENABLE_DIRECT_HANDLE
601
602 using vector_type = std::vector<element_type, allocator_type>;
603
604 public:
608 using size_type = size_t;
609 using difference_type = ptrdiff_t;
610 using iterator =
613 internal::WrappedIterator<typename vector_type::const_iterator,
614 const Local<T>>;
615
616 explicit LocalVector(Isolate* isolate) : backing_(make_allocator(isolate)) {}
617 LocalVector(Isolate* isolate, size_t n)
618 : backing_(n, make_allocator(isolate)) {}
619 explicit LocalVector(Isolate* isolate, std::initializer_list<Local<T>> init)
620 : backing_(make_allocator(isolate)) {
621 if (init.size() == 0) return;
622 backing_.reserve(init.size());
623 backing_.insert(backing_.end(), init.begin(), init.end());
624 }
625
626 iterator begin() noexcept { return iterator(backing_.begin()); }
627 const_iterator begin() const noexcept {
628 return const_iterator(backing_.begin());
629 }
630 iterator end() noexcept { return iterator(backing_.end()); }
631 const_iterator end() const noexcept { return const_iterator(backing_.end()); }
632
633 size_t size() const noexcept { return backing_.size(); }
634 bool empty() const noexcept { return backing_.empty(); }
635 void reserve(size_t n) { backing_.reserve(n); }
636 void shrink_to_fit() { backing_.shrink_to_fit(); }
637
638 Local<T>& operator[](size_t n) { return backing_[n]; }
639 const Local<T>& operator[](size_t n) const { return backing_[n]; }
640
641 Local<T>& at(size_t n) { return backing_.at(n); }
642 const Local<T>& at(size_t n) const { return backing_.at(n); }
643
644 Local<T>& front() { return backing_.front(); }
645 const Local<T>& front() const { return backing_.front(); }
646 Local<T>& back() { return backing_.back(); }
647 const Local<T>& back() const { return backing_.back(); }
648
649 Local<T>* data() noexcept { return backing_.data(); }
650 const Local<T>* data() const noexcept { return backing_.data(); }
651
653 return iterator(backing_.insert(pos.base(), value));
654 }
655
656 template <typename InputIt>
657 iterator insert(const_iterator pos, InputIt first, InputIt last) {
658 return iterator(backing_.insert(pos.base(), first, last));
659 }
660
661 iterator insert(const_iterator pos, std::initializer_list<Local<T>> init) {
662 return iterator(backing_.insert(pos.base(), init.begin(), init.end()));
663 }
664
665 LocalVector<T>& operator=(std::initializer_list<Local<T>> init) {
666 backing_.clear();
667 backing_.reserve(init.size());
668 backing_.insert(backing_.end(), init.begin(), init.end());
669 return *this;
670 }
671
672 void push_back(const Local<T>& x) { backing_.push_back(x); }
673 void pop_back() { backing_.pop_back(); }
674
675 template <typename... Args>
676 void emplace_back(Args&&... args) {
677 backing_.push_back(value_type{std::forward<Args>(args)...});
678 }
679
680 void clear() noexcept { backing_.clear(); }
681 void resize(size_t n) { backing_.resize(n); }
682 void swap(LocalVector<T>& other) { backing_.swap(other.backing_); }
683
684 friend bool operator==(const LocalVector<T>& x, const LocalVector<T>& y) {
685 return x.backing_ == y.backing_;
686 }
687 friend bool operator!=(const LocalVector<T>& x, const LocalVector<T>& y) {
688 return x.backing_ != y.backing_;
689 }
690 friend bool operator<(const LocalVector<T>& x, const LocalVector<T>& y) {
691 return x.backing_ < y.backing_;
692 }
693 friend bool operator>(const LocalVector<T>& x, const LocalVector<T>& y) {
694 return x.backing_ > y.backing_;
695 }
696 friend bool operator<=(const LocalVector<T>& x, const LocalVector<T>& y) {
697 return x.backing_ <= y.backing_;
698 }
699 friend bool operator>=(const LocalVector<T>& x, const LocalVector<T>& y) {
700 return x.backing_ >= y.backing_;
701 }
702
703 private:
704 vector_type backing_;
705};
706
707#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
708// Handle is an alias for Local for historical reasons.
709template <class T>
711#endif
712
723template <class T>
725 public:
733 template <class S>
734 requires std::is_base_of_v<T, S>
735 V8_INLINE MaybeLocal(Local<S> that) : local_(that) {}
739 template <class S>
740 requires std::is_base_of_v<T, S>
741 V8_INLINE MaybeLocal(MaybeLocal<S> that) : local_(that.local_) {}
742
743 V8_INLINE bool IsEmpty() const { return local_.IsEmpty(); }
744
749 template <class S>
751 *out = local_;
752 return !IsEmpty();
753 }
754
761 return local_;
762 }
763
768 template <class S>
769 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
770 return IsEmpty() ? default_value : Local<S>(local_);
771 }
772
778 template <class S>
780 return MaybeLocal<T>{Local<T>::Cast(that.local_)};
781 }
782
788 template <class S>
790 return MaybeLocal<S>::Cast(*this);
791 }
792
793 private:
794 Local<T> local_;
795
796 template <typename S>
797 friend class MaybeLocal;
798};
799
805 public:
808
810 void operator=(const EscapableHandleScopeBase&) = delete;
811 void* operator new(size_t size) = delete;
812 void* operator new[](size_t size) = delete;
813 void operator delete(void*, size_t) = delete;
814 void operator delete[](void*, size_t) = delete;
815
816 protected:
822
823 private:
824 internal::Address* escape_slot_;
825};
826
828 : public EscapableHandleScopeBase {
829 public:
830 explicit EscapableHandleScope(Isolate* isolate)
831 : EscapableHandleScopeBase(isolate) {}
833 template <class T>
835#ifdef V8_ENABLE_DIRECT_HANDLE
836 return value;
837#else
838 if (value.IsEmpty()) return value;
839 return Local<T>::FromSlot(EscapeSlot(value.slot()));
840#endif
841 }
842
843 template <class T>
845 return Escape(value.FromMaybe(Local<T>()));
846 }
847};
848
855 public:
856 explicit SealHandleScope(Isolate* isolate);
858
860 void operator=(const SealHandleScope&) = delete;
861 void* operator new(size_t size) = delete;
862 void* operator new[](size_t size) = delete;
863 void operator delete(void*, size_t) = delete;
864 void operator delete[](void*, size_t) = delete;
865
866 private:
867 internal::Isolate* const i_isolate_;
868 internal::Address* prev_limit_;
869 int prev_sealed_level_;
870};
871
872} // namespace v8
873
874#endif // INCLUDE_V8_LOCAL_HANDLE_H_
Definition: v8-traced-handle.h:125
Definition: v8-context.h:55
Definition: v8-local-handle.h:804
EscapableHandleScopeBase(Isolate *isolate)
internal::Address * EscapeSlot(internal::Address *escape_value)
EscapableHandleScopeBase(const EscapableHandleScopeBase &)=delete
void operator=(const EscapableHandleScopeBase &)=delete
Definition: v8-local-handle.h:828
Local< T > Escape(Local< T > value)
Definition: v8-local-handle.h:834
MaybeLocal< T > EscapeMaybe(MaybeLocal< T > value)
Definition: v8-local-handle.h:844
EscapableHandleScope(Isolate *isolate)
Definition: v8-local-handle.h:830
Definition: v8-local-handle.h:109
HandleScope()=default
void operator=(const HandleScope &)=delete
void Initialize(Isolate *isolate)
Definition: v8-local-handle.h:180
HandleScope(const HandleScope &)=delete
Isolate * GetIsolate() const
Definition: v8-local-handle.h:120
static int NumberOfHandles(Isolate *isolate)
~HandleScope()
Definition: v8-local-handle.h:193
static internal::Address * CreateHandle(Isolate *i_isolate, internal::Address value)
Definition: v8-local-handle.h:217
static internal::Address * CreateHandleForCurrentIsolate(internal::Address value)
Definition: v8-isolate.h:305
Definition: v8-local-handle.h:281
static LocalBase< T > New(Isolate *isolate, T *that)
Definition: v8-local-handle.h:302
static LocalBase< T > FromSlot(internal::Address *slot)
Definition: v8-local-handle.h:308
LocalBase(const LocalBase< S > &other)
Definition: v8-local-handle.h:296
static LocalBase< T > FromRepr(internal::ValueHelper::InternalRepresentationType repr)
Definition: v8-local-handle.h:312
LocalBase(internal::Address *location)
Definition: v8-local-handle.h:288
LocalBase()=default
static LocalBase< T > New(Isolate *isolate, internal::Address value)
Definition: v8-local-handle.h:298
Definition: v8-local-handle.h:584
LocalVector< T > & operator=(std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:665
const Local< T > & front() const
Definition: v8-local-handle.h:645
friend bool operator>=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:699
bool empty() const noexcept
Definition: v8-local-handle.h:634
const Local< T > * data() const noexcept
Definition: v8-local-handle.h:650
const_iterator end() const noexcept
Definition: v8-local-handle.h:631
const Local< T > & operator[](size_t n) const
Definition: v8-local-handle.h:639
friend bool operator<(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:690
const Local< T > & back() const
Definition: v8-local-handle.h:647
void shrink_to_fit()
Definition: v8-local-handle.h:636
Local< T > * data() noexcept
Definition: v8-local-handle.h:649
void reserve(size_t n)
Definition: v8-local-handle.h:635
Local< T > & front()
Definition: v8-local-handle.h:644
internal::WrappedIterator< typename vector_type::iterator, Local< T > > iterator
Definition: v8-local-handle.h:611
friend bool operator<=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:696
friend bool operator!=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:687
Local< T > & operator[](size_t n)
Definition: v8-local-handle.h:638
size_t size_type
Definition: v8-local-handle.h:608
void emplace_back(Args &&... args)
Definition: v8-local-handle.h:676
const_iterator begin() const noexcept
Definition: v8-local-handle.h:627
iterator insert(const_iterator pos, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:661
Local< T > & at(size_t n)
Definition: v8-local-handle.h:641
ptrdiff_t difference_type
Definition: v8-local-handle.h:609
iterator insert(const_iterator pos, const Local< T > &value)
Definition: v8-local-handle.h:652
internal::WrappedIterator< typename vector_type::const_iterator, const Local< T > > const_iterator
Definition: v8-local-handle.h:614
void pop_back()
Definition: v8-local-handle.h:673
LocalVector(Isolate *isolate, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:619
iterator end() noexcept
Definition: v8-local-handle.h:630
const Local< T > & at(size_t n) const
Definition: v8-local-handle.h:642
void clear() noexcept
Definition: v8-local-handle.h:680
void swap(LocalVector< T > &other)
Definition: v8-local-handle.h:682
iterator insert(const_iterator pos, InputIt first, InputIt last)
Definition: v8-local-handle.h:657
friend bool operator==(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:684
LocalVector(Isolate *isolate)
Definition: v8-local-handle.h:616
size_t size() const noexcept
Definition: v8-local-handle.h:633
void resize(size_t n)
Definition: v8-local-handle.h:681
Local< T > & back()
Definition: v8-local-handle.h:646
LocalVector(Isolate *isolate, size_t n)
Definition: v8-local-handle.h:617
void push_back(const Local< T > &x)
Definition: v8-local-handle.h:672
iterator begin() noexcept
Definition: v8-local-handle.h:626
friend bool operator>(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:693
Definition: v8-local-handle.h:356
friend class TracedReferenceBase
Definition: v8-local-handle.h:453
friend class Object
Definition: v8-local-handle.h:470
friend class PersistentValueMapBase
Definition: v8-local-handle.h:484
static Local< T > New(Isolate *isolate, const PersistentBase< T > &that)
Definition: v8-local-handle.h:442
friend class PropertyCallbackInfo
Definition: v8-local-handle.h:468
friend class ReturnValue
Definition: v8-local-handle.h:486
friend class HandleScope
Definition: v8-local-handle.h:480
friend class Traced
Definition: v8-local-handle.h:488
T * operator*() const
Definition: v8-local-handle.h:374
static Local< T > Cast(Local< S > that)
Definition: v8-local-handle.h:413
Local()=default
friend class FunctionCallbackInfo
Definition: v8-local-handle.h:466
Local< S > As() const
Definition: v8-local-handle.h:429
friend class String
Definition: v8-local-handle.h:469
bool operator!=(const Local< S > &that) const
Definition: v8-local-handle.h:398
friend class MaybeLocal
Definition: v8-local-handle.h:462
static Local< T > New(Isolate *isolate, const BasicTracedReference< T > &that)
Definition: v8-local-handle.h:447
bool operator==(const PersistentBase< S > &that) const
Definition: v8-local-handle.h:393
bool operator!=(const Persistent< S > &that) const
Definition: v8-local-handle.h:403
friend class Isolate
Definition: v8-local-handle.h:472
friend class Utils
Definition: v8-local-handle.h:454
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:438
friend class Context
Definition: v8-local-handle.h:471
friend class Private
Definition: v8-local-handle.h:473
friend class Persistent
Definition: v8-local-handle.h:464
friend class Global
Definition: v8-local-handle.h:458
T * operator->() const
Definition: v8-local-handle.h:372
friend class EscapableHandleScope
Definition: v8-local-handle.h:481
friend class Eternal
Definition: v8-local-handle.h:456
bool operator==(const Local< S > &that) const
Definition: v8-local-handle.h:388
Local(Local< S > that)
Definition: v8-local-handle.h:370
friend class InternalEscapableScope
Definition: v8-local-handle.h:482
friend class Local
Definition: v8-local-handle.h:460
Definition: v8-local-handle.h:724
bool ToLocal(Local< S > *out) const
Definition: v8-local-handle.h:750
static MaybeLocal< T > Cast(MaybeLocal< S > that)
Definition: v8-local-handle.h:779
MaybeLocal< S > As() const
Definition: v8-local-handle.h:789
Local< T > ToLocalChecked()
Definition: v8-local-handle.h:759
Local< S > FromMaybe(Local< S > default_value) const
Definition: v8-local-handle.h:769
MaybeLocal()=default
bool IsEmpty() const
Definition: v8-local-handle.h:743
MaybeLocal(Local< S > that)
Definition: v8-local-handle.h:735
MaybeLocal(MaybeLocal< S > that)
Definition: v8-local-handle.h:741
Definition: v8-object.h:269
Definition: v8-persistent-handle.h:93
Definition: v8-persistent-handle.h:250
Definition: v8-local-handle.h:854
SealHandleScope(const SealHandleScope &)=delete
void operator=(const SealHandleScope &)=delete
SealHandleScope(Isolate *isolate)
Definition: v8-local-handle.h:62
Definition: v8-value.h:527
Definition: v8-value.h:32
Definition: v8-handle-base.h:57
T * value() const
Definition: v8-handle-base.h:99
internal::Address ptr() const
Definition: v8-handle-base.h:80
internal::Address *const & slot() const
Definition: v8-handle-base.h:93
bool IsEmpty() const
Definition: v8-handle-base.h:60
internal::ValueHelper::InternalRepresentationType repr() const
Definition: v8-handle-base.h:108
Definition: v8-handle-base.h:13
Definition: v8-local-handle.h:73
Definition: v8-internal.h:1866
Definition: v8-internal.h:969
Definition: v8-local-handle.h:537
LocalUnchecked()
Definition: v8-local-handle.h:539
LocalUnchecked(const Local< T > &other) noexcept
Definition: v8-local-handle.h:551
Definition: v8-internal.h:1597
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1840
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1794
static bool IsEmpty(T *value)
Definition: v8-internal.h:1799
Definition: v8-internal.h:1645
constexpr const Iterator & base() const noexcept
Definition: v8-internal.h:1771
internal::BasicPersistent< T, internal::StrongPersistentPolicy > Persistent
Definition: persistent.h:362
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
Local< Primitive > Null(Isolate *isolate)
Definition: v8-primitive.h:1088
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8-primitive.h:1080
Local< Boolean > False(Isolate *isolate)
Definition: v8-primitive.h:1104
Local< Boolean > True(Isolate *isolate)
Definition: v8-primitive.h:1096
Definition: v8-internal.h:947
Address * next
Definition: v8-internal.h:951
int level
Definition: v8-internal.h:953
Address * limit
Definition: v8-internal.h:952
#define V(Name)
#define V8_EXPORT
Definition: v8config.h:875
#define V8_INLINE
Definition: v8config.h:519
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:689
#define V8_UNLIKELY(condition)
Definition: v8config.h:678
#define V8_TRIVIAL_ABI
Definition: v8config.h:828
#define V8_NODISCARD
Definition: v8config.h:711