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 ArrayBuffer;
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;
59template <class F>
60class ReturnValue;
61class String;
62template <class F>
63class Traced;
65class Utils;
66class Uint32;
67class Value;
68
69namespace debug {
70class ConsoleCallArguments;
71}
72
73namespace internal {
74template <typename T>
76template <typename T>
77class LocalUnchecked;
78class SamplingHeapProfiler;
79} // namespace internal
80
81namespace api_internal {
82// Called when ToLocalChecked is called on an empty Local.
84
85#ifdef V8_ENABLE_CHECKS
86template <typename T, typename V = Value>
87void TypeCheckLocal(V* value) {
88 // If `T` does not provide a `Cast` method we cannot check anything.
89 if constexpr (requires { T::Cast(value); }) {
90 // TODO(419454582): Remove all these exceptions.
91 if (std::is_same_v<Array, T> && value->IsArgumentsObject()) return;
92 if (std::is_same_v<ArrayBuffer, T> && value->IsSharedArrayBuffer()) return;
93 if (std::is_same_v<Object, T> && value->IsNull()) return;
94 if (std::is_same_v<Object, T> && value->IsString()) return;
95 if (std::is_same_v<Object, T> && value->IsUndefined()) return;
96 if (std::is_same_v<Uint32, T> && value->IsInt32()) return;
97 if (std::is_same_v<Object, T> && value->IsNumber()) return;
98 // Execute the actual check (part of the cast).
99 T::Cast(value);
100 }
101}
102#endif
103} // namespace api_internal
104
120 public:
121 V8_INLINE explicit HandleScope(Isolate* isolate);
122
124
128 static int NumberOfHandles(Isolate* isolate);
129
130 V8_INLINE Isolate* GetIsolate() const { return isolate_; }
131
132 HandleScope(const HandleScope&) = delete;
133 void operator=(const HandleScope&) = delete;
134
136 internal::Address value);
137
138 protected:
140
141 V8_INLINE void Initialize(Isolate* isolate);
142
143 V8_INLINE static internal::Address* CreateHandle(Isolate* i_isolate,
144 internal::Address value);
145
146 private:
147 // Extend the HandleScope making room for more handles. Not inlined.
148 static internal::Address* Extend(Isolate* isolate);
149 // Delete any extensions in HandleScope destructor. Not called unless there
150 // are extensions. Not inlined.
151 void DeleteExtensions(Isolate* isolate);
152
153#ifdef V8_ENABLE_CHECKS
154 // Non-inlined asserts on HandleScope constructor.
155 void DoInitializeAsserts(Isolate* isolate);
156 // Non-inlined assert for HandleScope destructor.
157 void AssertScopeLevelsMatch();
158 // Non-inlined asserts for HandleScope destructor. Also zaps the slots
159 // if this is enabled.
160 void DoCloseScopeAsserts(int before, internal::Address* limit,
162#endif
163
164 // Declaring operator new and delete as deleted is not spec compliant.
165 // Therefore declare them private instead to disable dynamic alloc
166 void* operator new(size_t size);
167 void* operator new[](size_t size);
168 void operator delete(void*, size_t);
169 void operator delete[](void*, size_t);
170
171 Isolate* isolate_;
172 internal::Address* prev_next_;
173 internal::Address* prev_limit_;
174#ifdef V8_ENABLE_CHECKS
175 int scope_level_ = 0;
176#endif
177
178 // LocalBase<T>::New uses CreateHandle with an Isolate* parameter.
179 template <typename T>
180 friend class LocalBase;
181
182 // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
183 // a HeapObject in their shortcuts.
184 friend class Object;
185 friend class Context;
186};
187
188HandleScope::HandleScope(Isolate* v8_isolate) { Initialize(v8_isolate); }
189
191 using I = internal::Internals;
192 internal::HandleScopeData* current = I::GetHandleScopeData(v8_isolate);
193 isolate_ = v8_isolate;
194 prev_next_ = current->next;
195 prev_limit_ = current->limit;
196 current->level++;
197#ifdef V8_ENABLE_CHECKS
198 DoInitializeAsserts(v8_isolate);
199 scope_level_ = current->level;
200#endif
201}
202
204 if (V8_UNLIKELY(isolate_ == nullptr)) return;
205#ifdef V8_ENABLE_CHECKS
206 AssertScopeLevelsMatch();
207 int handle_count_before = NumberOfHandles(isolate_);
208#endif
209
210 using I = internal::Internals;
211 internal::HandleScopeData* current = I::GetHandleScopeData(isolate_);
212 std::swap(current->next, prev_next_);
213 current->level--;
214 internal::Address* limit = prev_next_;
215 if (V8_UNLIKELY(current->limit != prev_limit_)) {
216 current->limit = prev_limit_;
217 limit = prev_limit_;
218 DeleteExtensions(isolate_);
219 }
220#ifdef V8_ENABLE_CHECKS
221 DoCloseScopeAsserts(handle_count_before, limit, current);
222#else
223 (void)limit; // Avoid unused variable warning.
224#endif
225}
226
228 internal::Address value) {
229 using I = internal::Internals;
230 internal::HandleScopeData* data = I::GetHandleScopeData(v8_isolate);
231 internal::Address* result = data->next;
232 if (V8_UNLIKELY(result == data->limit)) {
233 result = Extend(v8_isolate);
234 }
235 // Update the current next field, set the value in the created handle,
236 // and return the result.
237 data->next = reinterpret_cast<internal::Address*>(
238 reinterpret_cast<internal::Address>(result) + sizeof(internal::Address));
239 *result = value;
240 return result;
241}
242
249#ifdef V8_ENABLE_DIRECT_HANDLE
250
251template <typename T>
252class LocalBase : public api_internal::DirectHandleBase {
253 protected:
254 template <class F>
255 friend class Local;
256
257 V8_INLINE LocalBase() = default;
258
259 V8_INLINE explicit LocalBase(internal::Address ptr) : DirectHandleBase(ptr) {
260#ifdef V8_ENABLE_CHECKS
261 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
262#endif
263 }
264
265 template <typename S>
266 V8_INLINE LocalBase(const LocalBase<S>& other) : DirectHandleBase(other) {}
267
268 V8_INLINE static LocalBase<T> New(Isolate* isolate, internal::Address value) {
269 return LocalBase<T>(value);
270 }
271
272 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
273 return LocalBase<T>::New(isolate,
275 }
276
277 V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
278 if (slot == nullptr) return LocalBase<T>();
279 return LocalBase<T>(*slot);
280 }
281
282 V8_INLINE static LocalBase<T> FromRepr(
284 return LocalBase<T>(repr);
285 }
286};
287
288#else // !V8_ENABLE_DIRECT_HANDLE
289
290template <typename T>
292 protected:
293 template <class F>
294 friend class Local;
295
296 V8_INLINE LocalBase() = default;
297
299 : IndirectHandleBase(location) {
300#ifdef V8_ENABLE_CHECKS
301 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
302#endif
303 }
304
305 template <typename S>
307
309 return LocalBase(HandleScope::CreateHandle(isolate, value));
310 }
311
312 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
314 return LocalBase<T>::New(isolate,
316 }
317
319 return LocalBase<T>(slot);
320 }
321
324 return LocalBase<T>(repr);
325 }
326};
327
328#endif // V8_ENABLE_DIRECT_HANDLE
329
359template <class T>
361#ifdef V8_ENABLE_LOCAL_OFF_STACK_CHECK
363#else
364 public api_internal::StackAllocated<false>
365#endif
366{
367 public:
371 V8_INLINE Local() = default;
372
378 template <class S>
379 requires std::is_base_of_v<T, S>
380 V8_INLINE Local(Local<S> that) : LocalBase<T>(that) {}
381
382 V8_INLINE T* operator->() const { return this->template value<T>(); }
383
384 V8_INLINE T* operator*() const { return this->operator->(); }
385
397 template <class S>
398 V8_INLINE bool operator==(const Local<S>& that) const {
399 return internal::HandleHelper::EqualHandles(*this, that);
400 }
401
402 template <class S>
403 V8_INLINE bool operator==(const PersistentBase<S>& that) const {
404 return internal::HandleHelper::EqualHandles(*this, that);
405 }
406
407 template <class S>
408 V8_INLINE bool operator!=(const Local<S>& that) const {
409 return !operator==(that);
410 }
411
412 template <class S>
413 V8_INLINE bool operator!=(const Persistent<S>& that) const {
414 return !operator==(that);
415 }
416
422 template <class S>
424#ifdef V8_ENABLE_CHECKS
425 // If we're going to perform the type check then we have to check
426 // that the handle isn't empty before doing the checked cast.
427 if (that.IsEmpty()) return Local<T>();
428 T::Cast(that.template value<S>());
429#endif
430 return Local<T>(LocalBase<T>(that));
431 }
432
438 template <class S>
440 return Local<S>::Cast(*this);
441 }
442
448 V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that) {
449 return New(isolate, that.template value<T, true>());
450 }
451
452 V8_INLINE static Local<T> New(Isolate* isolate,
453 const PersistentBase<T>& that) {
454 return New(isolate, that.template value<T, true>());
455 }
456
457 V8_INLINE static Local<T> New(Isolate* isolate,
458 const BasicTracedReference<T>& that) {
459 return New(isolate, that.template value<T, true>());
460 }
461
462 private:
464 friend class Utils;
465 template <class F>
466 friend class Eternal;
467 template <class F>
468 friend class Global;
469 template <class F>
470 friend class Local;
471 template <class F>
472 friend class MaybeLocal;
473 template <class F, class M>
474 friend class Persistent;
475 template <class F>
477 template <class F>
479 friend class String;
480 friend class Object;
481 friend class Context;
482 friend class Isolate;
483 friend class Private;
484 template <class F>
486 friend Local<Primitive> Undefined(Isolate* isolate);
487 friend Local<Primitive> Null(Isolate* isolate);
488 friend Local<Boolean> True(Isolate* isolate);
489 friend Local<Boolean> False(Isolate* isolate);
490 friend class HandleScope;
493 template <class F1, class F2, class F3>
495 template <class F>
496 friend class ReturnValue;
497 template <class F>
498 friend class Traced;
499 friend class internal::SamplingHeapProfiler;
501 friend class debug::ConsoleCallArguments;
502 friend class internal::LocalUnchecked<T>;
503
504 explicit Local(no_checking_tag do_not_check)
505 : LocalBase<T>(), StackAllocated(do_not_check) {}
506 explicit Local(const Local<T>& other, no_checking_tag do_not_check)
507 : LocalBase<T>(other), StackAllocated(do_not_check) {}
508
509 V8_INLINE explicit Local(const LocalBase<T>& other) : LocalBase<T>(other) {}
510
511 V8_INLINE static Local<T> FromRepr(
512 internal::ValueHelper::InternalRepresentationType repr) {
513 return Local<T>(LocalBase<T>::FromRepr(repr));
514 }
515
516 V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
517 return Local<T>(LocalBase<T>::FromSlot(slot));
518 }
519
520#ifdef V8_ENABLE_DIRECT_HANDLE
521 friend class TypecheckWitness;
522
523 V8_INLINE static Local<T> FromAddress(internal::Address ptr) {
524 return Local<T>(LocalBase<T>(ptr));
525 }
526#endif // V8_ENABLE_DIRECT_HANDLE
527
528 V8_INLINE static Local<T> New(Isolate* isolate, internal::Address value) {
529 return Local<T>(LocalBase<T>::New(isolate, value));
530 }
531
532 V8_INLINE static Local<T> New(Isolate* isolate, T* that) {
533 return Local<T>(LocalBase<T>::New(isolate, that));
534 }
535
536 // Unsafe cast, should be avoided.
537 template <class S>
538 V8_INLINE Local<S> UnsafeAs() const {
539 return Local<S>(LocalBase<S>(*this));
540 }
541};
542
543namespace internal {
544// A local variant that is suitable for off-stack allocation.
545// Used internally by LocalVector<T>. Not to be used directly!
546template <typename T>
548 public:
549 LocalUnchecked() : Local<T>(Local<T>::do_not_check) {}
550
551#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
552 // In this case, the check is also enforced in the copy constructor and we
553 // need to suppress it.
555 const LocalUnchecked& other) noexcept // NOLINT(runtime/explicit)
557 LocalUnchecked& operator=(const LocalUnchecked&) noexcept = default;
558#endif
559
560 // Implicit conversion from Local.
561 LocalUnchecked(const Local<T>& other) noexcept // NOLINT(runtime/explicit)
563};
564
565#ifdef V8_ENABLE_DIRECT_HANDLE
566// Off-stack allocated direct locals must be registered as strong roots.
567// For off-stack indirect locals, this is not necessary.
568
569template <typename T>
570class StrongRootAllocator<LocalUnchecked<T>> : public StrongRootAllocatorBase {
571 public:
572 using value_type = LocalUnchecked<T>;
573 static_assert(std::is_standard_layout_v<value_type>);
574 static_assert(sizeof(value_type) == sizeof(Address));
575
576 template <typename HeapOrIsolateT>
577 explicit StrongRootAllocator(HeapOrIsolateT* heap_or_isolate)
578 : StrongRootAllocatorBase(heap_or_isolate) {}
579 template <typename U>
580 StrongRootAllocator(const StrongRootAllocator<U>& other) noexcept
581 : StrongRootAllocatorBase(other) {}
582
583 value_type* allocate(size_t n) {
584 return reinterpret_cast<value_type*>(allocate_impl(n));
585 }
586 void deallocate(value_type* p, size_t n) noexcept {
587 return deallocate_impl(reinterpret_cast<Address*>(p), n);
588 }
589};
590#endif // V8_ENABLE_DIRECT_HANDLE
591} // namespace internal
592
593template <typename T>
595 private:
597
598#ifdef V8_ENABLE_DIRECT_HANDLE
599 using allocator_type = internal::StrongRootAllocator<element_type>;
600
601 static allocator_type make_allocator(Isolate* isolate) noexcept {
602 return allocator_type(isolate);
603 }
604#else
605 using allocator_type = std::allocator<element_type>;
606
607 static allocator_type make_allocator(Isolate* isolate) noexcept {
608 return allocator_type();
609 }
610#endif // V8_ENABLE_DIRECT_HANDLE
611
612 using vector_type = std::vector<element_type, allocator_type>;
613
614 public:
618 using size_type = size_t;
619 using difference_type = ptrdiff_t;
620 using iterator =
623 internal::WrappedIterator<typename vector_type::const_iterator,
624 const Local<T>>;
625
626 explicit LocalVector(Isolate* isolate) : backing_(make_allocator(isolate)) {}
627 LocalVector(Isolate* isolate, size_t n)
628 : backing_(n, make_allocator(isolate)) {}
629 explicit LocalVector(Isolate* isolate, std::initializer_list<Local<T>> init)
630 : backing_(make_allocator(isolate)) {
631 if (init.size() == 0) return;
632 backing_.reserve(init.size());
633 backing_.insert(backing_.end(), init.begin(), init.end());
634 }
635
636 iterator begin() noexcept { return iterator(backing_.begin()); }
637 const_iterator begin() const noexcept {
638 return const_iterator(backing_.begin());
639 }
640 iterator end() noexcept { return iterator(backing_.end()); }
641 const_iterator end() const noexcept { return const_iterator(backing_.end()); }
642
643 size_t size() const noexcept { return backing_.size(); }
644 bool empty() const noexcept { return backing_.empty(); }
645 void reserve(size_t n) { backing_.reserve(n); }
646 void shrink_to_fit() { backing_.shrink_to_fit(); }
647
648 Local<T>& operator[](size_t n) { return backing_[n]; }
649 const Local<T>& operator[](size_t n) const { return backing_[n]; }
650
651 Local<T>& at(size_t n) { return backing_.at(n); }
652 const Local<T>& at(size_t n) const { return backing_.at(n); }
653
654 Local<T>& front() { return backing_.front(); }
655 const Local<T>& front() const { return backing_.front(); }
656 Local<T>& back() { return backing_.back(); }
657 const Local<T>& back() const { return backing_.back(); }
658
659 Local<T>* data() noexcept { return backing_.data(); }
660 const Local<T>* data() const noexcept { return backing_.data(); }
661
663 return iterator(backing_.insert(pos.base(), value));
664 }
665
666 template <typename InputIt>
667 iterator insert(const_iterator pos, InputIt first, InputIt last) {
668 return iterator(backing_.insert(pos.base(), first, last));
669 }
670
671 iterator insert(const_iterator pos, std::initializer_list<Local<T>> init) {
672 return iterator(backing_.insert(pos.base(), init.begin(), init.end()));
673 }
674
675 LocalVector<T>& operator=(std::initializer_list<Local<T>> init) {
676 backing_.clear();
677 backing_.reserve(init.size());
678 backing_.insert(backing_.end(), init.begin(), init.end());
679 return *this;
680 }
681
682 void push_back(const Local<T>& x) { backing_.push_back(x); }
683 void pop_back() { backing_.pop_back(); }
684
685 template <typename... Args>
686 void emplace_back(Args&&... args) {
687 backing_.push_back(value_type{std::forward<Args>(args)...});
688 }
689
690 void clear() noexcept { backing_.clear(); }
691 void resize(size_t n) { backing_.resize(n); }
692 void swap(LocalVector<T>& other) { backing_.swap(other.backing_); }
693
694 friend bool operator==(const LocalVector<T>& x, const LocalVector<T>& y) {
695 return x.backing_ == y.backing_;
696 }
697 friend bool operator!=(const LocalVector<T>& x, const LocalVector<T>& y) {
698 return x.backing_ != y.backing_;
699 }
700 friend bool operator<(const LocalVector<T>& x, const LocalVector<T>& y) {
701 return x.backing_ < y.backing_;
702 }
703 friend bool operator>(const LocalVector<T>& x, const LocalVector<T>& y) {
704 return x.backing_ > y.backing_;
705 }
706 friend bool operator<=(const LocalVector<T>& x, const LocalVector<T>& y) {
707 return x.backing_ <= y.backing_;
708 }
709 friend bool operator>=(const LocalVector<T>& x, const LocalVector<T>& y) {
710 return x.backing_ >= y.backing_;
711 }
712
713 private:
714 vector_type backing_;
715};
716
717#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
718// Handle is an alias for Local for historical reasons.
719template <class T>
721#endif
722
733template <class T>
735 public:
743 template <class S>
744 requires std::is_base_of_v<T, S>
745 V8_INLINE MaybeLocal(Local<S> that) : local_(that) {}
749 template <class S>
750 requires std::is_base_of_v<T, S>
751 V8_INLINE MaybeLocal(MaybeLocal<S> that) : local_(that.local_) {}
752
753 V8_INLINE bool IsEmpty() const { return local_.IsEmpty(); }
754
759 template <class S>
761 *out = local_;
762 return !IsEmpty();
763 }
764
771 return local_;
772 }
773
778 template <class S>
779 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
780 return IsEmpty() ? default_value : Local<S>(local_);
781 }
782
788 template <class S>
790 return MaybeLocal<T>{Local<T>::Cast(that.local_)};
791 }
792
798 template <class S>
800 return MaybeLocal<S>::Cast(*this);
801 }
802
803 private:
804 Local<T> local_;
805
806 template <typename S>
807 friend class MaybeLocal;
808};
809
815 public:
818
820 void operator=(const EscapableHandleScopeBase&) = delete;
821 void* operator new(size_t size) = delete;
822 void* operator new[](size_t size) = delete;
823 void operator delete(void*, size_t) = delete;
824 void operator delete[](void*, size_t) = delete;
825
826 protected:
832
833 private:
834 internal::Address* escape_slot_;
835};
836
838 : public EscapableHandleScopeBase {
839 public:
840 explicit EscapableHandleScope(Isolate* isolate)
841 : EscapableHandleScopeBase(isolate) {}
843 template <class T>
845#ifdef V8_ENABLE_DIRECT_HANDLE
846 return value;
847#else
848 if (value.IsEmpty()) return value;
849 return Local<T>::FromSlot(EscapeSlot(value.slot()));
850#endif
851 }
852
853 template <class T>
855 return Escape(value.FromMaybe(Local<T>()));
856 }
857};
858
865 public:
866 explicit SealHandleScope(Isolate* isolate);
868
870 void operator=(const SealHandleScope&) = delete;
871 void* operator new(size_t size) = delete;
872 void* operator new[](size_t size) = delete;
873 void operator delete(void*, size_t) = delete;
874 void operator delete[](void*, size_t) = delete;
875
876 private:
877 internal::Isolate* const i_isolate_;
878 internal::Address* prev_limit_;
879 int prev_sealed_level_;
880};
881
882} // namespace v8
883
884#endif // INCLUDE_V8_LOCAL_HANDLE_H_
Definition: v8-traced-handle.h:124
Definition: v8-context.h:48
Definition: v8-local-handle.h:814
EscapableHandleScopeBase(Isolate *isolate)
internal::Address * EscapeSlot(internal::Address *escape_value)
EscapableHandleScopeBase(const EscapableHandleScopeBase &)=delete
void operator=(const EscapableHandleScopeBase &)=delete
Definition: v8-local-handle.h:838
Local< T > Escape(Local< T > value)
Definition: v8-local-handle.h:844
MaybeLocal< T > EscapeMaybe(MaybeLocal< T > value)
Definition: v8-local-handle.h:854
EscapableHandleScope(Isolate *isolate)
Definition: v8-local-handle.h:840
Definition: v8-local-handle.h:119
HandleScope()=default
void operator=(const HandleScope &)=delete
void Initialize(Isolate *isolate)
Definition: v8-local-handle.h:190
HandleScope(const HandleScope &)=delete
Isolate * GetIsolate() const
Definition: v8-local-handle.h:130
static int NumberOfHandles(Isolate *isolate)
~HandleScope()
Definition: v8-local-handle.h:203
static internal::Address * CreateHandle(Isolate *i_isolate, internal::Address value)
Definition: v8-local-handle.h:227
static internal::Address * CreateHandleForCurrentIsolate(internal::Address value)
Definition: v8-isolate.h:290
Definition: v8-local-handle.h:291
static LocalBase< T > New(Isolate *isolate, T *that)
Definition: v8-local-handle.h:312
static LocalBase< T > FromSlot(internal::Address *slot)
Definition: v8-local-handle.h:318
LocalBase(const LocalBase< S > &other)
Definition: v8-local-handle.h:306
static LocalBase< T > FromRepr(internal::ValueHelper::InternalRepresentationType repr)
Definition: v8-local-handle.h:322
LocalBase(internal::Address *location)
Definition: v8-local-handle.h:298
LocalBase()=default
static LocalBase< T > New(Isolate *isolate, internal::Address value)
Definition: v8-local-handle.h:308
Definition: v8-local-handle.h:594
LocalVector< T > & operator=(std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:675
const Local< T > & front() const
Definition: v8-local-handle.h:655
friend bool operator>=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:709
bool empty() const noexcept
Definition: v8-local-handle.h:644
const Local< T > * data() const noexcept
Definition: v8-local-handle.h:660
const_iterator end() const noexcept
Definition: v8-local-handle.h:641
const Local< T > & operator[](size_t n) const
Definition: v8-local-handle.h:649
friend bool operator<(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:700
const Local< T > & back() const
Definition: v8-local-handle.h:657
void shrink_to_fit()
Definition: v8-local-handle.h:646
Local< T > * data() noexcept
Definition: v8-local-handle.h:659
void reserve(size_t n)
Definition: v8-local-handle.h:645
Local< T > & front()
Definition: v8-local-handle.h:654
internal::WrappedIterator< typename vector_type::iterator, Local< T > > iterator
Definition: v8-local-handle.h:621
friend bool operator<=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:706
friend bool operator!=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:697
Local< T > & operator[](size_t n)
Definition: v8-local-handle.h:648
size_t size_type
Definition: v8-local-handle.h:618
void emplace_back(Args &&... args)
Definition: v8-local-handle.h:686
const_iterator begin() const noexcept
Definition: v8-local-handle.h:637
iterator insert(const_iterator pos, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:671
Local< T > & at(size_t n)
Definition: v8-local-handle.h:651
ptrdiff_t difference_type
Definition: v8-local-handle.h:619
iterator insert(const_iterator pos, const Local< T > &value)
Definition: v8-local-handle.h:662
internal::WrappedIterator< typename vector_type::const_iterator, const Local< T > > const_iterator
Definition: v8-local-handle.h:624
void pop_back()
Definition: v8-local-handle.h:683
LocalVector(Isolate *isolate, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:629
iterator end() noexcept
Definition: v8-local-handle.h:640
const Local< T > & at(size_t n) const
Definition: v8-local-handle.h:652
void clear() noexcept
Definition: v8-local-handle.h:690
void swap(LocalVector< T > &other)
Definition: v8-local-handle.h:692
iterator insert(const_iterator pos, InputIt first, InputIt last)
Definition: v8-local-handle.h:667
friend bool operator==(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:694
LocalVector(Isolate *isolate)
Definition: v8-local-handle.h:626
size_t size() const noexcept
Definition: v8-local-handle.h:643
void resize(size_t n)
Definition: v8-local-handle.h:691
Local< T > & back()
Definition: v8-local-handle.h:656
LocalVector(Isolate *isolate, size_t n)
Definition: v8-local-handle.h:627
void push_back(const Local< T > &x)
Definition: v8-local-handle.h:682
iterator begin() noexcept
Definition: v8-local-handle.h:636
friend bool operator>(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:703
Definition: v8-local-handle.h:366
friend class TracedReferenceBase
Definition: v8-local-handle.h:463
friend class Object
Definition: v8-local-handle.h:480
friend class PersistentValueMapBase
Definition: v8-local-handle.h:494
static Local< T > New(Isolate *isolate, const PersistentBase< T > &that)
Definition: v8-local-handle.h:452
friend class PropertyCallbackInfo
Definition: v8-local-handle.h:478
friend class ReturnValue
Definition: v8-local-handle.h:496
friend class HandleScope
Definition: v8-local-handle.h:490
friend class Traced
Definition: v8-local-handle.h:498
T * operator*() const
Definition: v8-local-handle.h:384
static Local< T > Cast(Local< S > that)
Definition: v8-local-handle.h:423
Local()=default
friend class FunctionCallbackInfo
Definition: v8-local-handle.h:476
Local< S > As() const
Definition: v8-local-handle.h:439
friend class String
Definition: v8-local-handle.h:479
bool operator!=(const Local< S > &that) const
Definition: v8-local-handle.h:408
friend class MaybeLocal
Definition: v8-local-handle.h:472
static Local< T > New(Isolate *isolate, const BasicTracedReference< T > &that)
Definition: v8-local-handle.h:457
bool operator==(const PersistentBase< S > &that) const
Definition: v8-local-handle.h:403
bool operator!=(const Persistent< S > &that) const
Definition: v8-local-handle.h:413
friend class Isolate
Definition: v8-local-handle.h:482
friend class Utils
Definition: v8-local-handle.h:464
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:448
friend class Context
Definition: v8-local-handle.h:481
friend class Private
Definition: v8-local-handle.h:483
friend class Persistent
Definition: v8-local-handle.h:474
friend class Global
Definition: v8-local-handle.h:468
T * operator->() const
Definition: v8-local-handle.h:382
friend class EscapableHandleScope
Definition: v8-local-handle.h:491
friend class Eternal
Definition: v8-local-handle.h:466
bool operator==(const Local< S > &that) const
Definition: v8-local-handle.h:398
Local(Local< S > that)
Definition: v8-local-handle.h:380
friend class InternalEscapableScope
Definition: v8-local-handle.h:492
friend class Local
Definition: v8-local-handle.h:470
Definition: v8-local-handle.h:734
bool ToLocal(Local< S > *out) const
Definition: v8-local-handle.h:760
static MaybeLocal< T > Cast(MaybeLocal< S > that)
Definition: v8-local-handle.h:789
MaybeLocal< S > As() const
Definition: v8-local-handle.h:799
Local< T > ToLocalChecked()
Definition: v8-local-handle.h:769
Local< S > FromMaybe(Local< S > default_value) const
Definition: v8-local-handle.h:779
MaybeLocal()=default
bool IsEmpty() const
Definition: v8-local-handle.h:753
MaybeLocal(Local< S > that)
Definition: v8-local-handle.h:745
MaybeLocal(MaybeLocal< S > that)
Definition: v8-local-handle.h:751
Definition: v8-object.h:235
Definition: v8-persistent-handle.h:93
Definition: v8-persistent-handle.h:250
Definition: v8-local-handle.h:864
SealHandleScope(const SealHandleScope &)=delete
void operator=(const SealHandleScope &)=delete
SealHandleScope(Isolate *isolate)
Definition: v8-local-handle.h:63
Definition: v8-value.h:515
Definition: v8-primitive.h:920
Definition: v8-value.h:32
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:75
Definition: v8-internal.h:1774
Definition: v8-internal.h:874
Definition: v8-local-handle.h:547
LocalUnchecked()
Definition: v8-local-handle.h:549
LocalUnchecked(const Local< T > &other) noexcept
Definition: v8-local-handle.h:561
Definition: v8-internal.h:1456
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1748
internal::Address * InternalRepresentationType
Definition: v8-internal.h:1702
static bool IsEmpty(T *value)
Definition: v8-internal.h:1707
Definition: v8-internal.h:1515
constexpr const Iterator & base() const noexcept
Definition: v8-internal.h:1679
internal::BasicPersistent< T, internal::StrongPersistentPolicy > Persistent
Definition: persistent.h:363
uintptr_t Address
Definition: v8-internal.h:52
Definition: libplatform.h:15
Local< Primitive > Null(Isolate *isolate)
Definition: v8-primitive.h:1078
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8-primitive.h:1070
Local< Boolean > False(Isolate *isolate)
Definition: v8-primitive.h:1094
Local< Boolean > True(Isolate *isolate)
Definition: v8-primitive.h:1086
Definition: v8-internal.h:852
Address * next
Definition: v8-internal.h:856
int level
Definition: v8-internal.h:858
Address * limit
Definition: v8-internal.h:857
#define V(Name)
#define V8_EXPORT
Definition: v8config.h:849
#define V8_INLINE
Definition: v8config.h:513
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:684
#define V8_UNLIKELY(condition)
Definition: v8config.h:673
#define V8_TRIVIAL_ABI
Definition: v8config.h:802
#define V8_NODISCARD
Definition: v8config.h:706