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 // Non-inlined asserts on HandleScope constructor.
154 void DoInitializeAsserts(Isolate* isolate);
155 // Non-inlined assert for HandleScope destructor.
156 void AssertScopeLevelsMatch();
157 // Non-inlined asserts for HandleScope destructor. Also zaps the slots
158 // if this is enabled.
159 void DoCloseScopeAsserts(int before, internal::Address* limit,
161
162 // Declaring operator new and delete as deleted is not spec compliant.
163 // Therefore declare them private instead to disable dynamic alloc
164 void* operator new(size_t size);
165 void* operator new[](size_t size);
166 void operator delete(void*, size_t);
167 void operator delete[](void*, size_t);
168
169 Isolate* isolate_;
170 internal::Address* prev_next_;
171 internal::Address* prev_limit_;
172#ifdef V8_ENABLE_CHECKS
173 int scope_level_ = 0;
174#endif
175
176 // LocalBase<T>::New uses CreateHandle with an Isolate* parameter.
177 template <typename T>
178 friend class LocalBase;
179
180 // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
181 // a HeapObject in their shortcuts.
182 friend class Object;
183 friend class Context;
184};
185
186HandleScope::HandleScope(Isolate* v8_isolate) { Initialize(v8_isolate); }
187
189 using I = internal::Internals;
190 internal::HandleScopeData* current = I::GetHandleScopeData(v8_isolate);
191 isolate_ = v8_isolate;
192 prev_next_ = current->next;
193 prev_limit_ = current->limit;
194 current->level++;
195#ifdef V8_ENABLE_CHECKS
196 DoInitializeAsserts(v8_isolate);
197 scope_level_ = current->level;
198#endif
199}
200
202 if (V8_UNLIKELY(isolate_ == nullptr)) return;
203#ifdef V8_ENABLE_CHECKS
204 AssertScopeLevelsMatch();
205 int handle_count_before = NumberOfHandles(isolate_);
206#endif
207
208 using I = internal::Internals;
209 internal::HandleScopeData* current = I::GetHandleScopeData(isolate_);
210 std::swap(current->next, prev_next_);
211 current->level--;
212 internal::Address* limit = prev_next_;
213 if (V8_UNLIKELY(current->limit != prev_limit_)) {
214 current->limit = prev_limit_;
215 limit = prev_limit_;
216 DeleteExtensions(isolate_);
217 }
218#ifdef V8_ENABLE_CHECKS
219 DoCloseScopeAsserts(handle_count_before, limit, current);
220#else
221 (void)limit; // Avoid unused variable warning.
222#endif
223}
224
226 internal::Address value) {
227 using I = internal::Internals;
228 internal::HandleScopeData* data = I::GetHandleScopeData(v8_isolate);
229 internal::Address* result = data->next;
230 if (V8_UNLIKELY(result == data->limit)) {
231 result = Extend(v8_isolate);
232 }
233 // Update the current next field, set the value in the created handle,
234 // and return the result.
235 data->next = reinterpret_cast<internal::Address*>(
236 reinterpret_cast<internal::Address>(result) + sizeof(internal::Address));
237 *result = value;
238 return result;
239}
240
247#ifdef V8_ENABLE_DIRECT_HANDLE
248
249template <typename T>
250class LocalBase : public api_internal::DirectHandleBase {
251 protected:
252 template <class F>
253 friend class Local;
254
255 V8_INLINE LocalBase() = default;
256
257 V8_INLINE explicit LocalBase(internal::Address ptr) : DirectHandleBase(ptr) {
258#ifdef V8_ENABLE_CHECKS
259 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
260#endif
261 }
262
263 template <typename S>
264 V8_INLINE LocalBase(const LocalBase<S>& other) : DirectHandleBase(other) {}
265
266 V8_INLINE static LocalBase<T> New(Isolate* isolate, internal::Address value) {
267 return LocalBase<T>(value);
268 }
269
270 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
271 return LocalBase<T>::New(isolate,
273 }
274
275 V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
276 if (slot == nullptr) return LocalBase<T>();
277 return LocalBase<T>(*slot);
278 }
279
280 V8_INLINE static LocalBase<T> FromRepr(
282 return LocalBase<T>(repr);
283 }
284};
285
286#else // !V8_ENABLE_DIRECT_HANDLE
287
288template <typename T>
290 protected:
291 template <class F>
292 friend class Local;
293
294 V8_INLINE LocalBase() = default;
295
297 : IndirectHandleBase(location) {
298#ifdef V8_ENABLE_CHECKS
299 if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
300#endif
301 }
302
303 template <typename S>
305
307 return LocalBase(HandleScope::CreateHandle(isolate, value));
308 }
309
310 V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
312 return LocalBase<T>::New(isolate,
314 }
315
317 return LocalBase<T>(slot);
318 }
319
322 return LocalBase<T>(repr);
323 }
324};
325
326#endif // V8_ENABLE_DIRECT_HANDLE
327
357template <class T>
359#ifdef V8_ENABLE_LOCAL_OFF_STACK_CHECK
361#else
362 public api_internal::StackAllocated<false>
363#endif
364{
365 public:
369 V8_INLINE Local() = default;
370
376 template <class S>
377 requires std::is_base_of_v<T, S>
378 V8_INLINE Local(Local<S> that) : LocalBase<T>(that) {}
379
380 V8_INLINE T* operator->() const { return this->template value<T>(); }
381
382 V8_INLINE T* operator*() const { return this->operator->(); }
383
395 template <class S>
396 V8_INLINE bool operator==(const Local<S>& that) const {
397 return internal::HandleHelper::EqualHandles(*this, that);
398 }
399
400 template <class S>
401 V8_INLINE bool operator==(const PersistentBase<S>& that) const {
402 return internal::HandleHelper::EqualHandles(*this, that);
403 }
404
405 template <class S>
406 V8_INLINE bool operator!=(const Local<S>& that) const {
407 return !operator==(that);
408 }
409
410 template <class S>
411 V8_INLINE bool operator!=(const Persistent<S>& that) const {
412 return !operator==(that);
413 }
414
420 template <class S>
422#ifdef V8_ENABLE_CHECKS
423 // If we're going to perform the type check then we have to check
424 // that the handle isn't empty before doing the checked cast.
425 if (that.IsEmpty()) return Local<T>();
426 T::Cast(that.template value<S>());
427#endif
428 return Local<T>(LocalBase<T>(that));
429 }
430
436 template <class S>
438 return Local<S>::Cast(*this);
439 }
440
446 V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that) {
447 return New(isolate, that.template value<T, true>());
448 }
449
450 V8_INLINE static Local<T> New(Isolate* isolate,
451 const PersistentBase<T>& that) {
452 return New(isolate, that.template value<T, true>());
453 }
454
455 V8_INLINE static Local<T> New(Isolate* isolate,
456 const BasicTracedReference<T>& that) {
457 return New(isolate, that.template value<T, true>());
458 }
459
460 private:
462 friend class Utils;
463 template <class F>
464 friend class Eternal;
465 template <class F>
466 friend class Global;
467 template <class F>
468 friend class Local;
469 template <class F>
470 friend class MaybeLocal;
471 template <class F, class M>
472 friend class Persistent;
473 template <class F>
475 template <class F>
477 friend class String;
478 friend class Object;
479 friend class Context;
480 friend class Isolate;
481 friend class Private;
482 template <class F>
484 friend Local<Primitive> Undefined(Isolate* isolate);
485 friend Local<Primitive> Null(Isolate* isolate);
486 friend Local<Boolean> True(Isolate* isolate);
487 friend Local<Boolean> False(Isolate* isolate);
488 friend class HandleScope;
491 template <class F1, class F2, class F3>
493 template <class F>
494 friend class ReturnValue;
495 template <class F>
496 friend class Traced;
497 friend class internal::SamplingHeapProfiler;
499 friend class debug::ConsoleCallArguments;
500 friend class internal::LocalUnchecked<T>;
501
502 explicit Local(no_checking_tag do_not_check)
503 : LocalBase<T>(), StackAllocated(do_not_check) {}
504 explicit Local(const Local<T>& other, no_checking_tag do_not_check)
505 : LocalBase<T>(other), StackAllocated(do_not_check) {}
506
507 V8_INLINE explicit Local(const LocalBase<T>& other) : LocalBase<T>(other) {}
508
509 V8_INLINE static Local<T> FromRepr(
510 internal::ValueHelper::InternalRepresentationType repr) {
511 return Local<T>(LocalBase<T>::FromRepr(repr));
512 }
513
514 V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
515 return Local<T>(LocalBase<T>::FromSlot(slot));
516 }
517
518#ifdef V8_ENABLE_DIRECT_HANDLE
519 friend class TypecheckWitness;
520
521 V8_INLINE static Local<T> FromAddress(internal::Address ptr) {
522 return Local<T>(LocalBase<T>(ptr));
523 }
524#endif // V8_ENABLE_DIRECT_HANDLE
525
526 V8_INLINE static Local<T> New(Isolate* isolate, internal::Address value) {
527 return Local<T>(LocalBase<T>::New(isolate, value));
528 }
529
530 V8_INLINE static Local<T> New(Isolate* isolate, T* that) {
531 return Local<T>(LocalBase<T>::New(isolate, that));
532 }
533
534 // Unsafe cast, should be avoided.
535 template <class S>
536 V8_INLINE Local<S> UnsafeAs() const {
537 return Local<S>(LocalBase<S>(*this));
538 }
539};
540
541namespace internal {
542// A local variant that is suitable for off-stack allocation.
543// Used internally by LocalVector<T>. Not to be used directly!
544template <typename T>
546 public:
547 LocalUnchecked() : Local<T>(Local<T>::do_not_check) {}
548
549#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
550 // In this case, the check is also enforced in the copy constructor and we
551 // need to suppress it.
553 const LocalUnchecked& other) noexcept // NOLINT(runtime/explicit)
555 LocalUnchecked& operator=(const LocalUnchecked&) noexcept = default;
556#endif
557
558 // Implicit conversion from Local.
559 LocalUnchecked(const Local<T>& other) noexcept // NOLINT(runtime/explicit)
561};
562
563#ifdef V8_ENABLE_DIRECT_HANDLE
564// Off-stack allocated direct locals must be registered as strong roots.
565// For off-stack indirect locals, this is not necessary.
566
567template <typename T>
568class StrongRootAllocator<LocalUnchecked<T>> : public StrongRootAllocatorBase {
569 public:
570 using value_type = LocalUnchecked<T>;
571 static_assert(std::is_standard_layout_v<value_type>);
572 static_assert(sizeof(value_type) == sizeof(Address));
573
574 template <typename HeapOrIsolateT>
575 explicit StrongRootAllocator(HeapOrIsolateT* heap_or_isolate)
576 : StrongRootAllocatorBase(heap_or_isolate) {}
577 template <typename U>
578 StrongRootAllocator(const StrongRootAllocator<U>& other) noexcept
579 : StrongRootAllocatorBase(other) {}
580
581 value_type* allocate(size_t n) {
582 return reinterpret_cast<value_type*>(allocate_impl(n));
583 }
584 void deallocate(value_type* p, size_t n) noexcept {
585 return deallocate_impl(reinterpret_cast<Address*>(p), n);
586 }
587};
588#endif // V8_ENABLE_DIRECT_HANDLE
589} // namespace internal
590
591template <typename T>
593 private:
595
596#ifdef V8_ENABLE_DIRECT_HANDLE
597 using allocator_type = internal::StrongRootAllocator<element_type>;
598
599 static allocator_type make_allocator(Isolate* isolate) noexcept {
600 return allocator_type(isolate);
601 }
602#else
603 using allocator_type = std::allocator<element_type>;
604
605 static allocator_type make_allocator(Isolate* isolate) noexcept {
606 return allocator_type();
607 }
608#endif // V8_ENABLE_DIRECT_HANDLE
609
610 using vector_type = std::vector<element_type, allocator_type>;
611
612 public:
616 using size_type = size_t;
617 using difference_type = ptrdiff_t;
618 using iterator =
621 internal::WrappedIterator<typename vector_type::const_iterator,
622 const Local<T>>;
623
624 explicit LocalVector(Isolate* isolate) : backing_(make_allocator(isolate)) {}
625 LocalVector(Isolate* isolate, size_t n)
626 : backing_(n, make_allocator(isolate)) {}
627 explicit LocalVector(Isolate* isolate, std::initializer_list<Local<T>> init)
628 : backing_(make_allocator(isolate)) {
629 if (init.size() == 0) return;
630 backing_.reserve(init.size());
631 backing_.insert(backing_.end(), init.begin(), init.end());
632 }
633
634 iterator begin() noexcept { return iterator(backing_.begin()); }
635 const_iterator begin() const noexcept {
636 return const_iterator(backing_.begin());
637 }
638 iterator end() noexcept { return iterator(backing_.end()); }
639 const_iterator end() const noexcept { return const_iterator(backing_.end()); }
640
641 size_t size() const noexcept { return backing_.size(); }
642 bool empty() const noexcept { return backing_.empty(); }
643 void reserve(size_t n) { backing_.reserve(n); }
644 void shrink_to_fit() { backing_.shrink_to_fit(); }
645
646 Local<T>& operator[](size_t n) { return backing_[n]; }
647 const Local<T>& operator[](size_t n) const { return backing_[n]; }
648
649 Local<T>& at(size_t n) { return backing_.at(n); }
650 const Local<T>& at(size_t n) const { return backing_.at(n); }
651
652 Local<T>& front() { return backing_.front(); }
653 const Local<T>& front() const { return backing_.front(); }
654 Local<T>& back() { return backing_.back(); }
655 const Local<T>& back() const { return backing_.back(); }
656
657 Local<T>* data() noexcept { return backing_.data(); }
658 const Local<T>* data() const noexcept { return backing_.data(); }
659
661 return iterator(backing_.insert(pos.base(), value));
662 }
663
664 template <typename InputIt>
665 iterator insert(const_iterator pos, InputIt first, InputIt last) {
666 return iterator(backing_.insert(pos.base(), first, last));
667 }
668
669 iterator insert(const_iterator pos, std::initializer_list<Local<T>> init) {
670 return iterator(backing_.insert(pos.base(), init.begin(), init.end()));
671 }
672
673 LocalVector<T>& operator=(std::initializer_list<Local<T>> init) {
674 backing_.clear();
675 backing_.reserve(init.size());
676 backing_.insert(backing_.end(), init.begin(), init.end());
677 return *this;
678 }
679
680 void push_back(const Local<T>& x) { backing_.push_back(x); }
681 void pop_back() { backing_.pop_back(); }
682
683 template <typename... Args>
684 void emplace_back(Args&&... args) {
685 backing_.push_back(value_type{std::forward<Args>(args)...});
686 }
687
688 void clear() noexcept { backing_.clear(); }
689 void resize(size_t n) { backing_.resize(n); }
690 void swap(LocalVector<T>& other) { backing_.swap(other.backing_); }
691
692 friend bool operator==(const LocalVector<T>& x, const LocalVector<T>& y) {
693 return x.backing_ == y.backing_;
694 }
695 friend bool operator!=(const LocalVector<T>& x, const LocalVector<T>& y) {
696 return x.backing_ != y.backing_;
697 }
698 friend bool operator<(const LocalVector<T>& x, const LocalVector<T>& y) {
699 return x.backing_ < y.backing_;
700 }
701 friend bool operator>(const LocalVector<T>& x, const LocalVector<T>& y) {
702 return x.backing_ > y.backing_;
703 }
704 friend bool operator<=(const LocalVector<T>& x, const LocalVector<T>& y) {
705 return x.backing_ <= y.backing_;
706 }
707 friend bool operator>=(const LocalVector<T>& x, const LocalVector<T>& y) {
708 return x.backing_ >= y.backing_;
709 }
710
711 private:
712 vector_type backing_;
713};
714
715#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
716// Handle is an alias for Local for historical reasons.
717template <class T>
719#endif
720
731template <class T>
733 public:
741 template <class S>
742 requires std::is_base_of_v<T, S>
743 V8_INLINE MaybeLocal(Local<S> that) : local_(that) {}
747 template <class S>
748 requires std::is_base_of_v<T, S>
749 V8_INLINE MaybeLocal(MaybeLocal<S> that) : local_(that.local_) {}
750
751 V8_INLINE bool IsEmpty() const { return local_.IsEmpty(); }
752
757 template <class S>
759 *out = local_;
760 return !IsEmpty();
761 }
762
769 return local_;
770 }
771
776 template <class S>
777 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
778 return IsEmpty() ? default_value : Local<S>(local_);
779 }
780
786 template <class S>
788 return MaybeLocal<T>{Local<T>::Cast(that.local_)};
789 }
790
796 template <class S>
798 return MaybeLocal<S>::Cast(*this);
799 }
800
801 private:
802 Local<T> local_;
803
804 template <typename S>
805 friend class MaybeLocal;
806};
807
813 public:
816
818 void operator=(const EscapableHandleScopeBase&) = delete;
819 void* operator new(size_t size) = delete;
820 void* operator new[](size_t size) = delete;
821 void operator delete(void*, size_t) = delete;
822 void operator delete[](void*, size_t) = delete;
823
824 protected:
830
831 private:
832 internal::Address* escape_slot_;
833};
834
836 : public EscapableHandleScopeBase {
837 public:
838 explicit EscapableHandleScope(Isolate* isolate)
839 : EscapableHandleScopeBase(isolate) {}
841 template <class T>
843#ifdef V8_ENABLE_DIRECT_HANDLE
844 return value;
845#else
846 if (value.IsEmpty()) return value;
847 return Local<T>::FromSlot(EscapeSlot(value.slot()));
848#endif
849 }
850
851 template <class T>
853 return Escape(value.FromMaybe(Local<T>()));
854 }
855};
856
863 public:
864 explicit SealHandleScope(Isolate* isolate);
866
868 void operator=(const SealHandleScope&) = delete;
869 void* operator new(size_t size) = delete;
870 void* operator new[](size_t size) = delete;
871 void operator delete(void*, size_t) = delete;
872 void operator delete[](void*, size_t) = delete;
873
874 private:
875 internal::Isolate* const i_isolate_;
876 internal::Address* prev_limit_;
877 int prev_sealed_level_;
878};
879
880} // namespace v8
881
882#endif // INCLUDE_V8_LOCAL_HANDLE_H_
Definition: v8-traced-handle.h:124
Definition: v8-context.h:48
Definition: v8-local-handle.h:812
EscapableHandleScopeBase(Isolate *isolate)
internal::Address * EscapeSlot(internal::Address *escape_value)
EscapableHandleScopeBase(const EscapableHandleScopeBase &)=delete
void operator=(const EscapableHandleScopeBase &)=delete
Definition: v8-local-handle.h:836
Local< T > Escape(Local< T > value)
Definition: v8-local-handle.h:842
MaybeLocal< T > EscapeMaybe(MaybeLocal< T > value)
Definition: v8-local-handle.h:852
EscapableHandleScope(Isolate *isolate)
Definition: v8-local-handle.h:838
Definition: v8-local-handle.h:119
HandleScope()=default
void operator=(const HandleScope &)=delete
void Initialize(Isolate *isolate)
Definition: v8-local-handle.h:188
HandleScope(const HandleScope &)=delete
Isolate * GetIsolate() const
Definition: v8-local-handle.h:130
static int NumberOfHandles(Isolate *isolate)
~HandleScope()
Definition: v8-local-handle.h:201
static internal::Address * CreateHandle(Isolate *i_isolate, internal::Address value)
Definition: v8-local-handle.h:225
static internal::Address * CreateHandleForCurrentIsolate(internal::Address value)
Definition: v8-isolate.h:290
Definition: v8-local-handle.h:289
static LocalBase< T > New(Isolate *isolate, T *that)
Definition: v8-local-handle.h:310
static LocalBase< T > FromSlot(internal::Address *slot)
Definition: v8-local-handle.h:316
LocalBase(const LocalBase< S > &other)
Definition: v8-local-handle.h:304
static LocalBase< T > FromRepr(internal::ValueHelper::InternalRepresentationType repr)
Definition: v8-local-handle.h:320
LocalBase(internal::Address *location)
Definition: v8-local-handle.h:296
LocalBase()=default
static LocalBase< T > New(Isolate *isolate, internal::Address value)
Definition: v8-local-handle.h:306
Definition: v8-local-handle.h:592
LocalVector< T > & operator=(std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:673
const Local< T > & front() const
Definition: v8-local-handle.h:653
friend bool operator>=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:707
bool empty() const noexcept
Definition: v8-local-handle.h:642
const Local< T > * data() const noexcept
Definition: v8-local-handle.h:658
const_iterator end() const noexcept
Definition: v8-local-handle.h:639
const Local< T > & operator[](size_t n) const
Definition: v8-local-handle.h:647
friend bool operator<(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:698
const Local< T > & back() const
Definition: v8-local-handle.h:655
void shrink_to_fit()
Definition: v8-local-handle.h:644
Local< T > * data() noexcept
Definition: v8-local-handle.h:657
void reserve(size_t n)
Definition: v8-local-handle.h:643
Local< T > & front()
Definition: v8-local-handle.h:652
internal::WrappedIterator< typename vector_type::iterator, Local< T > > iterator
Definition: v8-local-handle.h:619
friend bool operator<=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:704
friend bool operator!=(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:695
Local< T > & operator[](size_t n)
Definition: v8-local-handle.h:646
size_t size_type
Definition: v8-local-handle.h:616
void emplace_back(Args &&... args)
Definition: v8-local-handle.h:684
const_iterator begin() const noexcept
Definition: v8-local-handle.h:635
iterator insert(const_iterator pos, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:669
Local< T > & at(size_t n)
Definition: v8-local-handle.h:649
ptrdiff_t difference_type
Definition: v8-local-handle.h:617
iterator insert(const_iterator pos, const Local< T > &value)
Definition: v8-local-handle.h:660
internal::WrappedIterator< typename vector_type::const_iterator, const Local< T > > const_iterator
Definition: v8-local-handle.h:622
void pop_back()
Definition: v8-local-handle.h:681
LocalVector(Isolate *isolate, std::initializer_list< Local< T > > init)
Definition: v8-local-handle.h:627
iterator end() noexcept
Definition: v8-local-handle.h:638
const Local< T > & at(size_t n) const
Definition: v8-local-handle.h:650
void clear() noexcept
Definition: v8-local-handle.h:688
void swap(LocalVector< T > &other)
Definition: v8-local-handle.h:690
iterator insert(const_iterator pos, InputIt first, InputIt last)
Definition: v8-local-handle.h:665
friend bool operator==(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:692
LocalVector(Isolate *isolate)
Definition: v8-local-handle.h:624
size_t size() const noexcept
Definition: v8-local-handle.h:641
void resize(size_t n)
Definition: v8-local-handle.h:689
Local< T > & back()
Definition: v8-local-handle.h:654
LocalVector(Isolate *isolate, size_t n)
Definition: v8-local-handle.h:625
void push_back(const Local< T > &x)
Definition: v8-local-handle.h:680
iterator begin() noexcept
Definition: v8-local-handle.h:634
friend bool operator>(const LocalVector< T > &x, const LocalVector< T > &y)
Definition: v8-local-handle.h:701
Definition: v8-local-handle.h:364
friend class TracedReferenceBase
Definition: v8-local-handle.h:461
friend class Object
Definition: v8-local-handle.h:478
friend class PersistentValueMapBase
Definition: v8-local-handle.h:492
static Local< T > New(Isolate *isolate, const PersistentBase< T > &that)
Definition: v8-local-handle.h:450
friend class PropertyCallbackInfo
Definition: v8-local-handle.h:476
friend class ReturnValue
Definition: v8-local-handle.h:494
friend class HandleScope
Definition: v8-local-handle.h:488
friend class Traced
Definition: v8-local-handle.h:496
T * operator*() const
Definition: v8-local-handle.h:382
static Local< T > Cast(Local< S > that)
Definition: v8-local-handle.h:421
Local()=default
friend class FunctionCallbackInfo
Definition: v8-local-handle.h:474
Local< S > As() const
Definition: v8-local-handle.h:437
friend class String
Definition: v8-local-handle.h:477
bool operator!=(const Local< S > &that) const
Definition: v8-local-handle.h:406
friend class MaybeLocal
Definition: v8-local-handle.h:470
static Local< T > New(Isolate *isolate, const BasicTracedReference< T > &that)
Definition: v8-local-handle.h:455
bool operator==(const PersistentBase< S > &that) const
Definition: v8-local-handle.h:401
bool operator!=(const Persistent< S > &that) const
Definition: v8-local-handle.h:411
friend class Isolate
Definition: v8-local-handle.h:480
friend class Utils
Definition: v8-local-handle.h:462
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:446
friend class Context
Definition: v8-local-handle.h:479
friend class Private
Definition: v8-local-handle.h:481
friend class Persistent
Definition: v8-local-handle.h:472
friend class Global
Definition: v8-local-handle.h:466
T * operator->() const
Definition: v8-local-handle.h:380
friend class EscapableHandleScope
Definition: v8-local-handle.h:489
friend class Eternal
Definition: v8-local-handle.h:464
bool operator==(const Local< S > &that) const
Definition: v8-local-handle.h:396
Local(Local< S > that)
Definition: v8-local-handle.h:378
friend class InternalEscapableScope
Definition: v8-local-handle.h:490
friend class Local
Definition: v8-local-handle.h:468
Definition: v8-local-handle.h:732
bool ToLocal(Local< S > *out) const
Definition: v8-local-handle.h:758
static MaybeLocal< T > Cast(MaybeLocal< S > that)
Definition: v8-local-handle.h:787
MaybeLocal< S > As() const
Definition: v8-local-handle.h:797
Local< T > ToLocalChecked()
Definition: v8-local-handle.h:767
Local< S > FromMaybe(Local< S > default_value) const
Definition: v8-local-handle.h:777
MaybeLocal()=default
bool IsEmpty() const
Definition: v8-local-handle.h:751
MaybeLocal(Local< S > that)
Definition: v8-local-handle.h:743
MaybeLocal(MaybeLocal< S > that)
Definition: v8-local-handle.h:749
Definition: v8-object.h:235
Definition: v8-persistent-handle.h:93
Definition: v8-persistent-handle.h:250
Definition: v8-local-handle.h:862
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:545
LocalUnchecked()
Definition: v8-local-handle.h:547
LocalUnchecked(const Local< T > &other) noexcept
Definition: v8-local-handle.h:559
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