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 ArrayBufferView;
46class Boolean;
47class Context;
48class EscapableHandleScope;
49template <class F>
50class FunctionCallbackInfo;
51class Isolate;
52class Object;
53template <class F1, class F2, class F3>
54class PersistentValueMapBase;
55class Primitive;
56class Private;
57template <class F>
58class PropertyCallbackInfo;
59class RegExp;
60template <class F>
61class ReturnValue;
62class String;
63template <class F>
64class Traced;
66class Utils;
67class Value;
69
70namespace debug {
71class ConsoleCallArguments;
72}
73
74namespace internal {
75template <typename T>
77template <typename T>
78class LocalUnchecked;
79class SamplingHeapProfiler;
80} // namespace internal
81
82namespace api_internal {
83// Called when ToLocalChecked is called on an empty Local.
85
86#ifdef V8_ENABLE_CHECKS
87template <typename T, typename V = Value>
88void TypeCheckLocal(V* value) {
89 // If `T` does not provide a `Cast` method we cannot check anything.
90 if constexpr (requires { T::Cast(value); }) {
91 // Execute the actual check (part of the cast).
92 T::Cast(value);
93 }
94}
95#endif
96} // namespace api_internal
97
113 public:
114 V8_INLINE explicit HandleScope(Isolate* isolate);
115
117
121 static int NumberOfHandles(Isolate* isolate);
122
123 V8_INLINE Isolate* GetIsolate() const { return isolate_; }
124
125 HandleScope(const HandleScope&) = delete;
126 void operator=(const HandleScope&) = delete;
127
129 internal::Address value);
130
131 protected:
133
134 V8_INLINE void Initialize(Isolate* isolate);
135
136 V8_INLINE static internal::Address* CreateHandle(Isolate* i_isolate,
137 internal::Address value);
138
139 private:
140 // Extend the HandleScope making room for more handles. Not inlined.
141 static internal::Address* Extend(Isolate* isolate);
142 // Delete any extensions in HandleScope destructor. Not called unless there
143 // are extensions. Not inlined.
144 void DeleteExtensions(Isolate* isolate);
145
146#ifdef V8_ENABLE_CHECKS
147 // Non-inlined asserts on HandleScope constructor.
148 void DoInitializeAsserts(Isolate* isolate);
149 // Non-inlined assert for HandleScope destructor.
150 void AssertScopeLevelsMatch();
151 // Non-inlined asserts for HandleScope destructor. Also zaps the slots
152 // if this is enabled.
153 void DoCloseScopeAsserts(int before, internal::Address* limit,
155#endif
156
157 // Declaring operator new and delete as deleted is not spec compliant.
158 // Therefore declare them private instead to disable dynamic alloc
159 void* operator new(size_t size);
160 void* operator new[](size_t size);
161 void operator delete(void*, size_t);
162 void operator delete[](void*, size_t);
163
164 Isolate* isolate_;
165 internal::Address* prev_next_;
166 internal::Address* prev_limit_;
167#ifdef V8_ENABLE_CHECKS
168 int scope_level_ = 0;
169#endif
170
171 // LocalBase<T>::New uses CreateHandle with an Isolate* parameter.
172 template <typename T>
173 friend class LocalBase;
174
175 // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
176 // a HeapObject in their shortcuts.
177 friend class Object;
178 friend class Context;
179};
180
181HandleScope::HandleScope(Isolate* v8_isolate) { Initialize(v8_isolate); }
182
184 using I = internal::Internals;
185 internal::HandleScopeData* current = I::GetHandleScopeData(v8_isolate);
186 isolate_ = v8_isolate;
187 prev_next_ = current->next;
188 prev_limit_ = current->limit;
189 current->level++;
190#ifdef V8_ENABLE_CHECKS
191 DoInitializeAsserts(v8_isolate);
192 scope_level_ = current->level;
193#endif
194}
195
197 if (V8_UNLIKELY(isolate_ == nullptr)) return;
198#ifdef V8_ENABLE_CHECKS
199 AssertScopeLevelsMatch();
200 int handle_count_before = NumberOfHandles(isolate_);
201#endif
202
203 using I = internal::Internals;
204 internal::HandleScopeData* current = I::GetHandleScopeData(isolate_);
205 std::swap(current->next, prev_next_);
206 current->level--;
207 internal::Address* limit = prev_next_;
208 if (V8_UNLIKELY(current->limit != prev_limit_)) {
209 current->limit = prev_limit_;
210 limit = prev_limit_;
211 DeleteExtensions(isolate_);
212 }
213#ifdef V8_ENABLE_CHECKS
214 DoCloseScopeAsserts(handle_count_before, limit, current);
215#else
216 (void)limit; // Avoid unused variable warning.
217#endif
218}
219
221 internal::Address value) {
222 using I = internal::Internals;
223 internal::HandleScopeData* data = I::GetHandleScopeData(v8_isolate);
224 internal::Address* result = data->next;
225 if (V8_UNLIKELY(result == data->limit)) {
226 result = Extend(v8_isolate);
227 }
228 // Update the current next field, set the value in the created handle,
229 // and return the result.
230 data->next = reinterpret_cast<internal::Address*>(
231 reinterpret_cast<internal::Address>(result) + sizeof(internal::Address));
232 *result = value;
233 return result;
234}
235
242#ifdef V8_ENABLE_DIRECT_HANDLE
243
244template <typename T>
245class LocalBase : public api_internal::DirectHandleBase {
246 protected:
247 template <class F>
248 friend class Local;
249
250 V8_INLINE LocalBase() = default;
251
252 V8_INLINE explicit LocalBase(internal::Address ptr) : DirectHandleBase(ptr) {
253#ifdef V8_ENABLE_CHECKS
254 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
255#endif
256 }
257
258 template <typename S>
259 V8_INLINE LocalBase(const LocalBase<S>& other) : DirectHandleBase(other) {}
260
261 V8_INLINE static LocalBase<T> New(Isolate* isolate, internal::Address value) {
262 return LocalBase<T>(value);
263 }
264
265 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
266 return LocalBase<T>::New(isolate,
268 }
269
270 V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
271 if (slot == nullptr) return LocalBase<T>();
272 return LocalBase<T>(*slot);
273 }
274
275 V8_INLINE static LocalBase<T> FromRepr(
277 return LocalBase<T>(repr);
278 }
279};
280
281#else // !V8_ENABLE_DIRECT_HANDLE
282
283template <typename T>
285 protected:
286 template <class F>
287 friend class Local;
288
289 V8_INLINE LocalBase() = default;
290
292 : IndirectHandleBase(location) {
293#ifdef V8_ENABLE_CHECKS
294 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
295#endif
296 }
297
298 template <typename S>
300
302 return LocalBase(HandleScope::CreateHandle(isolate, value));
303 }
304
305 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
307 return LocalBase<T>::New(isolate,
309 }
310
312 return LocalBase<T>(slot);
313 }
314
317 return LocalBase<T>(repr);
318 }
319};
320
321#endif // V8_ENABLE_DIRECT_HANDLE
322
352template <class T>
354#ifdef V8_ENABLE_LOCAL_OFF_STACK_CHECK
356#else
357 public api_internal::StackAllocated<false>
358#endif
359{
360 public:
364 V8_INLINE Local() = default;
365
371 template <class S>
372 requires std::is_base_of_v<T, S>
373 V8_INLINE Local(Local<S> that) : LocalBase<T>(that) {}
374
375 V8_INLINE T* operator->() const { return this->template value<T>(); }
376
377 V8_INLINE T* operator*() const { return this->operator->(); }
378
390 template <class S>
391 V8_INLINE bool operator==(const Local<S>& that) const {
392 return internal::HandleHelper::EqualHandles(*this, that);
393 }
394
395 template <class S>
396 V8_INLINE bool operator==(const PersistentBase<S>& that) const {
397 return internal::HandleHelper::EqualHandles(*this, that);
398 }
399
400 template <class S>
401 V8_INLINE bool operator!=(const Local<S>& that) const {
402 return !operator==(that);
403 }
404
405 template <class S>
406 V8_INLINE bool operator!=(const Persistent<S>& that) const {
407 return !operator==(that);
408 }
409
415 template <class S>
417#ifdef V8_ENABLE_CHECKS
418 // If we're going to perform the type check then we have to check
419 // that the handle isn't empty before doing the checked cast.
420 if (that.IsEmpty()) return Local<T>();
421 T::Cast(that.template value<S>());
422#endif
423 return Local<T>(LocalBase<T>(that));
424 }
425
431 template <class S>
433 return Local<S>::Cast(*this);
434 }
435
441 V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that) {
442 return New(isolate, that.template value<T, true>());
443 }
444
445 V8_INLINE static Local<T> New(Isolate* isolate,
446 const PersistentBase<T>& that) {
447 return New(isolate, that.template value<T, true>());
448 }
449
450 V8_INLINE static Local<T> New(Isolate* isolate,
451 const BasicTracedReference<T>& that) {
452 return New(isolate, that.template value<T, true>());
453 }
454
455 private:
457 friend class Utils;
458 template <class F>
459 friend class Eternal;
460 template <class F>
461 friend class Global;
462 template <class F>
463 friend class Local;
464 template <class F>
465 friend class MaybeLocal;
466 template <class F, class M>
467 friend class Persistent;
468 template <class F>
470 template <class F>
472 friend class ArrayBufferView;
473 friend class String;
474 friend class Object;
475 friend class Context;
476 friend class Isolate;
477 friend class Private;
478 friend class RegExp;
479 friend class WasmMemoryObject;
480 template <class F>
482 friend Local<Primitive> Undefined(Isolate* isolate);
483 friend Local<Primitive> Null(Isolate* isolate);
484 friend Local<Boolean> True(Isolate* isolate);
485 friend Local<Boolean> False(Isolate* isolate);
486 friend class HandleScope;
489 template <class F1, class F2, class F3>
491 template <class F>
492 friend class ReturnValue;
493 template <class F>
494 friend class Traced;
495 friend class internal::SamplingHeapProfiler;
497 friend class debug::ConsoleCallArguments;
498 friend class internal::LocalUnchecked<T>;
499
500 explicit Local(no_checking_tag do_not_check)
501 : LocalBase<T>(), StackAllocated(do_not_check) {}
502 explicit Local(const Local<T>& other, no_checking_tag do_not_check)
503 : LocalBase<T>(other), StackAllocated(do_not_check) {}
504
505 V8_INLINE explicit Local(const LocalBase<T>& other) : LocalBase<T>(other) {}
506
507 V8_INLINE static Local<T> FromRepr(
508 internal::ValueHelper::InternalRepresentationType repr) {
509 return Local<T>(LocalBase<T>::FromRepr(repr));
510 }
511
512 V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
513 return Local<T>(LocalBase<T>::FromSlot(slot));
514 }
515
516#ifdef V8_ENABLE_DIRECT_HANDLE
517 friend class TypecheckWitness;
518
519 V8_INLINE static Local<T> FromAddress(internal::Address ptr) {
520 return Local<T>(LocalBase<T>(ptr));
521 }
522#endif // V8_ENABLE_DIRECT_HANDLE
523
524 V8_INLINE static Local<T> New(Isolate* isolate, internal::Address value) {
525 return Local<T>(LocalBase<T>::New(isolate, value));
526 }
527
528 V8_INLINE static Local<T> New(Isolate* isolate, T* that) {
529 return Local<T>(LocalBase<T>::New(isolate, that));
530 }
531
532 // Unsafe cast, should be avoided.
533 template <class S>
534 V8_INLINE Local<S> UnsafeAs() const {
535 return Local<S>(LocalBase<S>(*this));
536 }
537};
538
539namespace internal {
540// A local variant that is suitable for off-stack allocation.
541// Used internally by LocalVector<T>. Not to be used directly!
542template <typename T>
544 public:
545 LocalUnchecked() : Local<T>(Local<T>::do_not_check) {}
546
547#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
548 // In this case, the check is also enforced in the copy constructor and we
549 // need to suppress it.
551 const LocalUnchecked& other) noexcept // NOLINT(runtime/explicit)
553 LocalUnchecked& operator=(const LocalUnchecked&) noexcept = default;
554#endif
555
556 // Implicit conversion from Local.
557 LocalUnchecked(const Local<T>& other) noexcept // NOLINT(runtime/explicit)
559};
560
561#ifdef V8_ENABLE_DIRECT_HANDLE
562// Off-stack allocated direct locals must be registered as strong roots.
563// For off-stack indirect locals, this is not necessary.
564
565template <typename T>
566class StrongRootAllocator<LocalUnchecked<T>> : public StrongRootAllocatorBase {
567 public:
568 using value_type = LocalUnchecked<T>;
569 static_assert(std::is_standard_layout_v<value_type>);
570 static_assert(sizeof(value_type) == sizeof(Address));
571
572 template <typename HeapOrIsolateT>
573 explicit StrongRootAllocator(HeapOrIsolateT* heap_or_isolate)
574 : StrongRootAllocatorBase(heap_or_isolate) {}
575 template <typename U>
576 StrongRootAllocator(const StrongRootAllocator<U>& other) noexcept
577 : StrongRootAllocatorBase(other) {}
578
579 value_type* allocate(size_t n) {
580 return reinterpret_cast<value_type*>(allocate_impl(n));
581 }
582 void deallocate(value_type* p, size_t n) noexcept {
583 return deallocate_impl(reinterpret_cast<Address*>(p), n);
584 }
585};
586#endif // V8_ENABLE_DIRECT_HANDLE
587} // namespace internal
588
589template <typename T>
591 private:
593
594#ifdef V8_ENABLE_DIRECT_HANDLE
595 using allocator_type = internal::StrongRootAllocator<element_type>;
596
597 static allocator_type make_allocator(Isolate* isolate) noexcept {
598 return allocator_type(isolate);
599 }
600#else
601 using allocator_type = std::allocator<element_type>;
602
603 static allocator_type make_allocator(Isolate* isolate) noexcept {
604 return allocator_type();
605 }
606#endif // V8_ENABLE_DIRECT_HANDLE
607
608 using vector_type = std::vector<element_type, allocator_type>;
609
610 public:
614 using size_type = size_t;
615 using difference_type = ptrdiff_t;
616 using iterator =
619 internal::WrappedIterator<typename vector_type::const_iterator,
620 const Local<T>>;
621
622 explicit LocalVector(Isolate* isolate) : backing_(make_allocator(isolate)) {}
623 LocalVector(Isolate* isolate, size_t n)
624 : backing_(n, make_allocator(isolate)) {}
625 explicit LocalVector(Isolate* isolate, std::initializer_list<Local<T>> init)
626 : backing_(make_allocator(isolate)) {
627 if (init.size() == 0) return;
628 backing_.reserve(init.size());
629 backing_.insert(backing_.end(), init.begin(), init.end());
630 }
631
632 iterator begin() noexcept { return iterator(backing_.begin()); }
633 const_iterator begin() const noexcept {
634 return const_iterator(backing_.begin());
635 }
636 iterator end() noexcept { return iterator(backing_.end()); }
637 const_iterator end() const noexcept { return const_iterator(backing_.end()); }
638
639 size_t size() const noexcept { return backing_.size(); }
640 bool empty() const noexcept { return backing_.empty(); }
641 void reserve(size_t n) { backing_.reserve(n); }
642 void shrink_to_fit() { backing_.shrink_to_fit(); }
643
644 Local<T>& operator[](size_t n) { return backing_[n]; }
645 const Local<T>& operator[](size_t n) const { return backing_[n]; }
646
647 Local<T>& at(size_t n) { return backing_.at(n); }
648 const Local<T>& at(size_t n) const { return backing_.at(n); }
649
650 Local<T>& front() { return backing_.front(); }
651 const Local<T>& front() const { return backing_.front(); }
652 Local<T>& back() { return backing_.back(); }
653 const Local<T>& back() const { return backing_.back(); }
654
655 Local<T>* data() noexcept { return backing_.data(); }
656 const Local<T>* data() const noexcept { return backing_.data(); }
657
659 return iterator(backing_.insert(pos.base(), value));
660 }
661
662 template <typename InputIt>
663 iterator insert(const_iterator pos, InputIt first, InputIt last) {
664 return iterator(backing_.insert(pos.base(), first, last));
665 }
666
667 iterator insert(const_iterator pos, std::initializer_list<Local<T>> init) {
668 return iterator(backing_.insert(pos.base(), init.begin(), init.end()));
669 }
670
671 LocalVector<T>& operator=(std::initializer_list<Local<T>> init) {
672 backing_.clear();
673 backing_.reserve(init.size());
674 backing_.insert(backing_.end(), init.begin(), init.end());
675 return *this;
676 }
677
678 void push_back(const Local<T>& x) { backing_.push_back(x); }
679 void pop_back() { backing_.pop_back(); }
680
681 template <typename... Args>
682 void emplace_back(Args&&... args) {
683 backing_.push_back(value_type{std::forward<Args>(args)...});
684 }
685
686 void clear() noexcept { backing_.clear(); }
687 void resize(size_t n) { backing_.resize(n); }
688 void swap(LocalVector<T>& other) { backing_.swap(other.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 friend bool operator<=(const LocalVector<T>& x, const LocalVector<T>& y) {
703 return x.backing_ <= y.backing_;
704 }
705 friend bool operator>=(const LocalVector<T>& x, const LocalVector<T>& y) {
706 return x.backing_ >= y.backing_;
707 }
708
709 private:
710 vector_type backing_;
711};
712
713#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
714// Handle is an alias for Local for historical reasons.
715template <class T>
717#endif
718
729template <class T>
731 public:
739 template <class S>
740 requires std::is_base_of_v<T, S>
741 V8_INLINE MaybeLocal(Local<S> that) : local_(that) {}
745 template <class S>
746 requires std::is_base_of_v<T, S>
747 V8_INLINE MaybeLocal(MaybeLocal<S> that) : local_(that.local_) {}
748
749 V8_INLINE bool IsEmpty() const { return local_.IsEmpty(); }
750
755 template <class S>
757 *out = local_;
758 return !IsEmpty();
759 }
760
767 return local_;
768 }
769
774 template <class S>
775 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
776 return IsEmpty() ? default_value : Local<S>(local_);
777 }
778
784 template <class S>
786 return MaybeLocal<T>{Local<T>::Cast(that.local_)};
787 }
788
794 template <class S>
796 return MaybeLocal<S>::Cast(*this);
797 }
798
799 private:
800 Local<T> local_;
801
802 template <typename S>
803 friend class MaybeLocal;
804};
805
811 public:
814
816 void operator=(const EscapableHandleScopeBase&) = delete;
817 void* operator new(size_t size) = delete;
818 void* operator new[](size_t size) = delete;
819 void operator delete(void*, size_t) = delete;
820 void operator delete[](void*, size_t) = delete;
821
822 protected:
828
829 private:
830 internal::Address* escape_slot_;
831};
832
834 : public EscapableHandleScopeBase {
835 public:
836 explicit EscapableHandleScope(Isolate* isolate)
837 : EscapableHandleScopeBase(isolate) {}
839 template <class T>
841#ifdef V8_ENABLE_DIRECT_HANDLE
842 return value;
843#else
844 if (value.IsEmpty()) return value;
845 return Local<T>::FromSlot(EscapeSlot(value.slot()));
846#endif
847 }
848
849 template <class T>
851 return Escape(value.FromMaybe(Local<T>()));
852 }
853};
854
861 public:
862 explicit SealHandleScope(Isolate* isolate);
864
866 void operator=(const SealHandleScope&) = delete;
867 void* operator new(size_t size) = delete;
868 void* operator new[](size_t size) = delete;
869 void operator delete(void*, size_t) = delete;
870 void operator delete[](void*, size_t) = delete;
871
872 private:
873 internal::Isolate* const i_isolate_;
874 internal::Address* prev_limit_;
875 int prev_sealed_level_;
876};
877
878} // namespace v8
879
880#endif // INCLUDE_V8_LOCAL_HANDLE_H_
Definition: v8-traced-handle.h:125
Definition: v8-context.h:55
Definition: v8-local-handle.h:810
EscapableHandleScopeBase(Isolate *isolate)
internal::Address * EscapeSlot(internal::Address *escape_value)
EscapableHandleScopeBase(const EscapableHandleScopeBase &)=delete
void operator=(const EscapableHandleScopeBase &)=delete
Definition: v8-local-handle.h:834
Local< T > Escape(Local< T > value)
Definition: v8-local-handle.h:840
MaybeLocal< T > EscapeMaybe(MaybeLocal< T > value)
Definition: v8-local-handle.h:850
EscapableHandleScope(Isolate *isolate)
Definition: v8-local-handle.h:836
Definition: v8-local-handle.h:112
HandleScope()=default
void operator=(const HandleScope &)=delete
void Initialize(Isolate *isolate)
Definition: v8-local-handle.h:183
HandleScope(const HandleScope &)=delete
Isolate * GetIsolate() const
Definition: v8-local-handle.h:123
static int NumberOfHandles(Isolate *isolate)
~HandleScope()
Definition: v8-local-handle.h:196
static internal::Address * CreateHandle(Isolate *i_isolate, internal::Address value)
Definition: v8-local-handle.h:220
static internal::Address * CreateHandleForCurrentIsolate(internal::Address value)
Definition: v8-isolate.h:305
Definition: v8-local-handle.h:284
static LocalBase< T > New(Isolate *isolate, T *that)
Definition: v8-local-handle.h:305
static LocalBase< T > FromSlot(internal::Address *slot)
Definition: v8-local-handle.h:311
LocalBase(const LocalBase< S > &other)
Definition: v8-local-handle.h:299
static LocalBase< T > FromRepr(internal::ValueHelper::InternalRepresentationType repr)
Definition: v8-local-handle.h:315
LocalBase(internal::Address *location)
Definition: v8-local-handle.h:291
LocalBase()=default
static LocalBase< T > New(Isolate *isolate, internal::Address value)
Definition: v8-local-handle.h:301
Definition: v8-local-handle.h:590
LocalVector< T > & operator=(std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:671
const Local< T > & front() const
Definition: v8-local-handle.h:651
friend bool operator>=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:705
bool empty() const noexcept
Definition: v8-local-handle.h:640
const Local< T > * data() const noexcept
Definition: v8-local-handle.h:656
const_iterator end() const noexcept
Definition: v8-local-handle.h:637
const Local< T > & operator[](size_t n) const
Definition: v8-local-handle.h:645
friend bool operator<(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:696
const Local< T > & back() const
Definition: v8-local-handle.h:653
void shrink_to_fit()
Definition: v8-local-handle.h:642
Local< T > * data() noexcept
Definition: v8-local-handle.h:655
void reserve(size_t n)
Definition: v8-local-handle.h:641
Local< T > & front()
Definition: v8-local-handle.h:650
internal::WrappedIterator< typename vector_type::iterator, Local< T > > iterator
Definition: v8-local-handle.h:617
friend bool operator<=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:702
friend bool operator!=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:693
Local< T > & operator[](size_t n)
Definition: v8-local-handle.h:644
size_t size_type
Definition: v8-local-handle.h:614
void emplace_back(Args &&... args)
Definition: v8-local-handle.h:682
const_iterator begin() const noexcept
Definition: v8-local-handle.h:633
iterator insert(const_iterator pos, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:667
Local< T > & at(size_t n)
Definition: v8-local-handle.h:647
ptrdiff_t difference_type
Definition: v8-local-handle.h:615
iterator insert(const_iterator pos, const Local< T > &value)
Definition: v8-local-handle.h:658
internal::WrappedIterator< typename vector_type::const_iterator, const Local< T > > const_iterator
Definition: v8-local-handle.h:620
void pop_back()
Definition: v8-local-handle.h:679
LocalVector(Isolate *isolate, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:625
iterator end() noexcept
Definition: v8-local-handle.h:636
const Local< T > & at(size_t n) const
Definition: v8-local-handle.h:648
void clear() noexcept
Definition: v8-local-handle.h:686
void swap(LocalVector< T > &other)
Definition: v8-local-handle.h:688
iterator insert(const_iterator pos, InputIt first, InputIt last)
Definition: v8-local-handle.h:663
friend bool operator==(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:690
LocalVector(Isolate *isolate)
Definition: v8-local-handle.h:622
size_t size() const noexcept
Definition: v8-local-handle.h:639
void resize(size_t n)
Definition: v8-local-handle.h:687
Local< T > & back()
Definition: v8-local-handle.h:652
LocalVector(Isolate *isolate, size_t n)
Definition: v8-local-handle.h:623
void push_back(const Local< T > &x)
Definition: v8-local-handle.h:678
iterator begin() noexcept
Definition: v8-local-handle.h:632
friend bool operator>(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:699
Definition: v8-local-handle.h:359
friend class TracedReferenceBase
Definition: v8-local-handle.h:456
friend class Object
Definition: v8-local-handle.h:474
friend class PersistentValueMapBase
Definition: v8-local-handle.h:490
friend class WasmMemoryObject
Definition: v8-local-handle.h:479
friend class RegExp
Definition: v8-local-handle.h:478
friend class ArrayBufferView
Definition: v8-local-handle.h:472
static Local< T > New(Isolate *isolate, const PersistentBase< T > &that)
Definition: v8-local-handle.h:445
friend class PropertyCallbackInfo
Definition: v8-local-handle.h:471
friend class ReturnValue
Definition: v8-local-handle.h:492
friend class HandleScope
Definition: v8-local-handle.h:486
friend class Traced
Definition: v8-local-handle.h:494
T * operator*() const
Definition: v8-local-handle.h:377
static Local< T > Cast(Local< S > that)
Definition: v8-local-handle.h:416
Local()=default
friend class FunctionCallbackInfo
Definition: v8-local-handle.h:469
Local< S > As() const
Definition: v8-local-handle.h:432
friend class String
Definition: v8-local-handle.h:473
bool operator!=(const Local< S > &that) const
Definition: v8-local-handle.h:401
friend class MaybeLocal
Definition: v8-local-handle.h:465
static Local< T > New(Isolate *isolate, const BasicTracedReference< T > &that)
Definition: v8-local-handle.h:450
bool operator==(const PersistentBase< S > &that) const
Definition: v8-local-handle.h:396
bool operator!=(const Persistent< S > &that) const
Definition: v8-local-handle.h:406
friend class Isolate
Definition: v8-local-handle.h:476
friend class Utils
Definition: v8-local-handle.h:457
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:441
friend class Context
Definition: v8-local-handle.h:475
friend class Private
Definition: v8-local-handle.h:477
friend class Persistent
Definition: v8-local-handle.h:467
friend class Global
Definition: v8-local-handle.h:461
T * operator->() const
Definition: v8-local-handle.h:375
friend class EscapableHandleScope
Definition: v8-local-handle.h:487
friend class Eternal
Definition: v8-local-handle.h:459
bool operator==(const Local< S > &that) const
Definition: v8-local-handle.h:391
Local(Local< S > that)
Definition: v8-local-handle.h:373
friend class InternalEscapableScope
Definition: v8-local-handle.h:488
friend class Local
Definition: v8-local-handle.h:463
Definition: v8-local-handle.h:730
bool ToLocal(Local< S > *out) const
Definition: v8-local-handle.h:756
static MaybeLocal< T > Cast(MaybeLocal< S > that)
Definition: v8-local-handle.h:785
MaybeLocal< S > As() const
Definition: v8-local-handle.h:795
Local< T > ToLocalChecked()
Definition: v8-local-handle.h:765
Local< S > FromMaybe(Local< S > default_value) const
Definition: v8-local-handle.h:775
MaybeLocal()=default
bool IsEmpty() const
Definition: v8-local-handle.h:749
MaybeLocal(Local< S > that)
Definition: v8-local-handle.h:741
MaybeLocal(MaybeLocal< S > that)
Definition: v8-local-handle.h:747
Definition: v8-object.h:262
Definition: v8-persistent-handle.h:93
Definition: v8-persistent-handle.h:250
Definition: v8-local-handle.h:860
SealHandleScope(const SealHandleScope &)=delete
void operator=(const SealHandleScope &)=delete
SealHandleScope(Isolate *isolate)
Definition: v8-local-handle.h:64
Definition: v8-value.h:527
Definition: v8-value.h:32
Definition: v8-wasm.h:104
Definition: v8-handle-base.h:57
T * value() const
Definition: v8-handle-base.h:89
internal::Address ptr() const
Definition: v8-handle-base.h:80
internal::Address *const & slot() const
Definition: v8-handle-base.h:83
bool IsEmpty() const
Definition: v8-handle-base.h:60
internal::ValueHelper::InternalRepresentationType repr() const
Definition: v8-handle-base.h:98
Definition: v8-handle-base.h:13
Definition: v8-local-handle.h:76
Definition: v8-internal.h:1863
Definition: v8-internal.h:969
Definition: v8-local-handle.h:543
LocalUnchecked()
Definition: v8-local-handle.h:545
LocalUnchecked(const Local< T > &other) noexcept
Definition: v8-local-handle.h:557
Definition: v8-internal.h:1594
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1837
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1791
static bool IsEmpty(T *value)
Definition: v8-internal.h:1796
Definition: v8-internal.h:1642
constexpr const Iterator & base() const noexcept
Definition: v8-internal.h:1768
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:1090
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8-primitive.h:1082
Local< Boolean > False(Isolate *isolate)
Definition: v8-primitive.h:1106
Local< Boolean > True(Isolate *isolate)
Definition: v8-primitive.h:1098
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