v8  9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
v8.h
Go to the documentation of this file.
1 // Copyright 2012 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 /** \mainpage V8 API Reference Guide
6  *
7  * V8 is Google's open source JavaScript engine.
8  *
9  * This set of documents provides reference material generated from the
10  * V8 header file, include/v8.h.
11  *
12  * For other documentation see https://v8.dev/.
13  */
14 
15 #ifndef INCLUDE_V8_H_
16 #define INCLUDE_V8_H_
17 
18 #include <stddef.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 
22 #include <atomic>
23 #include <memory>
24 #include <string>
25 #include <type_traits>
26 #include <utility>
27 #include <vector>
28 
29 #include "cppgc/common.h"
30 #include "v8-internal.h" // NOLINT(build/include_directory)
31 #include "v8-version.h" // NOLINT(build/include_directory)
32 #include "v8config.h" // NOLINT(build/include_directory)
33 
34 // We reserve the V8_* prefix for macros defined in V8 public API and
35 // assume there are no name conflicts with the embedder's code.
36 
37 /**
38  * The v8 JavaScript engine.
39  */
40 namespace v8 {
41 
42 class AccessorSignature;
43 class Array;
44 class ArrayBuffer;
45 class BigInt;
46 class BigIntObject;
47 class Boolean;
48 class BooleanObject;
49 class CFunction;
50 class CallHandlerHelper;
51 class Context;
52 class CppHeap;
53 class Data;
54 class Date;
56 class External;
57 class Function;
58 class FunctionTemplate;
59 class HeapProfiler;
60 class ImplementationUtilities;
61 class Int32;
62 class Integer;
63 class Isolate;
64 class Isolate;
65 class MicrotaskQueue;
66 class Name;
67 class Number;
68 class NumberObject;
69 class Object;
70 class ObjectOperationDescriptor;
71 class ObjectTemplate;
72 class Platform;
73 class Primitive;
74 class PrimitiveArray;
75 class Private;
76 class Promise;
77 class PropertyDescriptor;
78 class Proxy;
79 class RawOperationDescriptor;
80 class Script;
81 class SharedArrayBuffer;
82 class Signature;
83 class StackFrame;
84 class StackTrace;
85 class StartupData;
86 class String;
87 class StringObject;
88 class Symbol;
89 class SymbolObject;
91 class Uint32;
92 class Utils;
93 class Value;
94 class WasmMemoryObject;
95 class WasmModuleObject;
96 template <class K, class V, class T>
97 class GlobalValueMap;
98 template <class K, class V, class T>
100 template<class T> class NonCopyablePersistentTraits;
101 template <class T, class M = NonCopyablePersistentTraits<T>>
103 template <class T>
105 template <class T>
106 class Eternal;
107 template <class T>
108 class Global;
109 template <class T>
110 class Local;
111 template <class T>
112 class Maybe;
113 template <class T>
115 template <class T>
117 template <class T>
119 template<class K, class V, class T> class PersistentValueMap;
120 template<class T, class P> class WeakCallbackObject;
121 template <class T>
123 template <class V, class T>
125 template<typename T> class FunctionCallbackInfo;
126 template<typename T> class PropertyCallbackInfo;
127 template<typename T> class ReturnValue;
128 
129 namespace internal {
130 class BasicTracedReferenceExtractor;
131 class ExternalString;
132 class FunctionCallbackArguments;
133 class GlobalHandles;
134 class Heap;
135 class HeapObject;
136 class Isolate;
137 class LocalEmbedderHeapTracer;
138 class MicrotaskQueue;
139 class PropertyCallbackArguments;
140 class ReadOnlyHeap;
141 class ScopedExternalStringLock;
142 class ThreadLocalTop;
143 struct ScriptStreamingData;
144 enum class ArgumentsType;
145 template <ArgumentsType>
146 class Arguments;
147 template <typename T>
149 
150 namespace wasm {
151 class NativeModule;
152 class StreamingDecoder;
153 } // namespace wasm
154 
155 } // namespace internal
156 
157 namespace metrics {
158 class Recorder;
159 } // namespace metrics
160 
161 namespace debug {
162 class ConsoleCallArguments;
163 } // namespace debug
164 
165 // --- Handles ---
166 
167 /**
168  * An object reference managed by the v8 garbage collector.
169  *
170  * All objects returned from v8 have to be tracked by the garbage
171  * collector so that it knows that the objects are still alive. Also,
172  * because the garbage collector may move objects, it is unsafe to
173  * point directly to an object. Instead, all objects are stored in
174  * handles which are known by the garbage collector and updated
175  * whenever an object moves. Handles should always be passed by value
176  * (except in cases like out-parameters) and they should never be
177  * allocated on the heap.
178  *
179  * There are two types of handles: local and persistent handles.
180  *
181  * Local handles are light-weight and transient and typically used in
182  * local operations. They are managed by HandleScopes. That means that a
183  * HandleScope must exist on the stack when they are created and that they are
184  * only valid inside of the HandleScope active during their creation.
185  * For passing a local handle to an outer HandleScope, an EscapableHandleScope
186  * and its Escape() method must be used.
187  *
188  * Persistent handles can be used when storing objects across several
189  * independent operations and have to be explicitly deallocated when they're no
190  * longer used.
191  *
192  * It is safe to extract the object stored in the handle by
193  * dereferencing the handle (for instance, to extract the Object* from
194  * a Local<Object>); the value will still be governed by a handle
195  * behind the scenes and the same rules apply to these values as to
196  * their handles.
197  */
198 template <class T>
199 class Local {
200  public:
201  V8_INLINE Local() : val_(nullptr) {}
202  template <class S>
204  : val_(reinterpret_cast<T*>(*that)) {
205  /**
206  * This check fails when trying to convert between incompatible
207  * handles. For example, converting from a Local<String> to a
208  * Local<Number>.
209  */
210  static_assert(std::is_base_of<T, S>::value, "type check");
211  }
212 
213  /**
214  * Returns true if the handle is empty.
215  */
216  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
217 
218  /**
219  * Sets the handle to be empty. IsEmpty() will then return true.
220  */
221  V8_INLINE void Clear() { val_ = nullptr; }
222 
223  V8_INLINE T* operator->() const { return val_; }
224 
225  V8_INLINE T* operator*() const { return val_; }
226 
227  /**
228  * Checks whether two handles are the same.
229  * Returns true if both are empty, or if the objects to which they refer
230  * are identical.
231  *
232  * If both handles refer to JS objects, this is the same as strict equality.
233  * For primitives, such as numbers or strings, a `false` return value does not
234  * indicate that the values aren't equal in the JavaScript sense.
235  * Use `Value::StrictEquals()` to check primitives for equality.
236  */
237  template <class S>
238  V8_INLINE bool operator==(const Local<S>& that) const {
239  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
240  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
241  if (a == nullptr) return b == nullptr;
242  if (b == nullptr) return false;
243  return *a == *b;
244  }
245 
246  template <class S> V8_INLINE bool operator==(
247  const PersistentBase<S>& that) const {
248  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
249  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
250  if (a == nullptr) return b == nullptr;
251  if (b == nullptr) return false;
252  return *a == *b;
253  }
254 
255  /**
256  * Checks whether two handles are different.
257  * Returns true if only one of the handles is empty, or if
258  * the objects to which they refer are different.
259  *
260  * If both handles refer to JS objects, this is the same as strict
261  * non-equality. For primitives, such as numbers or strings, a `true` return
262  * value does not indicate that the values aren't equal in the JavaScript
263  * sense. Use `Value::StrictEquals()` to check primitives for equality.
264  */
265  template <class S>
266  V8_INLINE bool operator!=(const Local<S>& that) const {
267  return !operator==(that);
268  }
269 
270  template <class S> V8_INLINE bool operator!=(
271  const Persistent<S>& that) const {
272  return !operator==(that);
273  }
274 
275  /**
276  * Cast a handle to a subclass, e.g. Local<Value> to Local<Object>.
277  * This is only valid if the handle actually refers to a value of the
278  * target type.
279  */
280  template <class S> V8_INLINE static Local<T> Cast(Local<S> that) {
281 #ifdef V8_ENABLE_CHECKS
282  // If we're going to perform the type check then we have to check
283  // that the handle isn't empty before doing the checked cast.
284  if (that.IsEmpty()) return Local<T>();
285 #endif
286  return Local<T>(T::Cast(*that));
287  }
288 
289  /**
290  * Calling this is equivalent to Local<S>::Cast().
291  * In particular, this is only valid if the handle actually refers to a value
292  * of the target type.
293  */
294  template <class S>
295  V8_INLINE Local<S> As() const {
296  return Local<S>::Cast(*this);
297  }
298 
299  /**
300  * Create a local handle for the content of another handle.
301  * The referee is kept alive by the local handle even when
302  * the original handle is destroyed/disposed.
303  */
304  V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that);
305  V8_INLINE static Local<T> New(Isolate* isolate,
306  const PersistentBase<T>& that);
307  V8_INLINE static Local<T> New(Isolate* isolate,
308  const BasicTracedReference<T>& that);
309 
310  private:
311  friend class TracedReferenceBase;
312  friend class Utils;
313  template<class F> friend class Eternal;
314  template<class F> friend class PersistentBase;
315  template<class F, class M> friend class Persistent;
316  template<class F> friend class Local;
317  template <class F>
318  friend class MaybeLocal;
319  template<class F> friend class FunctionCallbackInfo;
320  template<class F> friend class PropertyCallbackInfo;
321  friend class String;
322  friend class Object;
323  friend class Context;
324  friend class Isolate;
325  friend class Private;
326  template<class F> friend class internal::CustomArguments;
327  friend Local<Primitive> Undefined(Isolate* isolate);
328  friend Local<Primitive> Null(Isolate* isolate);
329  friend Local<Boolean> True(Isolate* isolate);
330  friend Local<Boolean> False(Isolate* isolate);
331  friend class HandleScope;
332  friend class EscapableHandleScope;
333  template <class F1, class F2, class F3>
335  template<class F1, class F2> friend class PersistentValueVector;
336  template <class F>
337  friend class ReturnValue;
338  template <class F>
339  friend class Traced;
340  template <class F>
341  friend class TracedGlobal;
342  template <class F>
343  friend class BasicTracedReference;
344  template <class F>
345  friend class TracedReference;
346 
347  explicit V8_INLINE Local(T* that) : val_(that) {}
348  V8_INLINE static Local<T> New(Isolate* isolate, T* that);
349  T* val_;
350 };
351 
352 
353 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
354 // Handle is an alias for Local for historical reasons.
355 template <class T>
356 using Handle = Local<T>;
357 #endif
358 
359 
360 /**
361  * A MaybeLocal<> is a wrapper around Local<> that enforces a check whether
362  * the Local<> is empty before it can be used.
363  *
364  * If an API method returns a MaybeLocal<>, the API method can potentially fail
365  * either because an exception is thrown, or because an exception is pending,
366  * e.g. because a previous API call threw an exception that hasn't been caught
367  * yet, or because a TerminateExecution exception was thrown. In that case, an
368  * empty MaybeLocal is returned.
369  */
370 template <class T>
371 class MaybeLocal {
372  public:
373  V8_INLINE MaybeLocal() : val_(nullptr) {}
374  template <class S>
376  : val_(reinterpret_cast<T*>(*that)) {
377  static_assert(std::is_base_of<T, S>::value, "type check");
378  }
379 
380  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
381 
382  /**
383  * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty,
384  * |false| is returned and |out| is left untouched.
385  */
386  template <class S>
388  out->val_ = IsEmpty() ? nullptr : this->val_;
389  return !IsEmpty();
390  }
391 
392  /**
393  * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty,
394  * V8 will crash the process.
395  */
397 
398  /**
399  * Converts this MaybeLocal<> to a Local<>, using a default value if this
400  * MaybeLocal<> is empty.
401  */
402  template <class S>
403  V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
404  return IsEmpty() ? default_value : Local<S>(val_);
405  }
406 
407  private:
408  T* val_;
409 };
410 
411 /**
412  * Eternal handles are set-once handles that live for the lifetime of the
413  * isolate.
414  */
415 template <class T> class Eternal {
416  public:
417  V8_INLINE Eternal() : val_(nullptr) {}
418  template <class S>
419  V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : val_(nullptr) {
420  Set(isolate, handle);
421  }
422  // Can only be safely called if already set.
423  V8_INLINE Local<T> Get(Isolate* isolate) const;
424  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
425  template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
426 
427  private:
428  T* val_;
429 };
430 
431 
432 static const int kInternalFieldsInWeakCallback = 2;
433 static const int kEmbedderFieldsInWeakCallback = 2;
434 
435 template <typename T>
437  public:
438  using Callback = void (*)(const WeakCallbackInfo<T>& data);
439 
440  WeakCallbackInfo(Isolate* isolate, T* parameter,
441  void* embedder_fields[kEmbedderFieldsInWeakCallback],
442  Callback* callback)
443  : isolate_(isolate), parameter_(parameter), callback_(callback) {
444  for (int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
445  embedder_fields_[i] = embedder_fields[i];
446  }
447  }
448 
449  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
450  V8_INLINE T* GetParameter() const { return parameter_; }
451  V8_INLINE void* GetInternalField(int index) const;
452 
453  // When first called, the embedder MUST Reset() the Global which triggered the
454  // callback. The Global itself is unusable for anything else. No v8 other api
455  // calls may be called in the first callback. Should additional work be
456  // required, the embedder must set a second pass callback, which will be
457  // called after all the initial callbacks are processed.
458  // Calling SetSecondPassCallback on the second pass will immediately crash.
459  void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
460 
461  private:
462  Isolate* isolate_;
463  T* parameter_;
464  Callback* callback_;
465  void* embedder_fields_[kEmbedderFieldsInWeakCallback];
466 };
467 
468 
469 // kParameter will pass a void* parameter back to the callback, kInternalFields
470 // will pass the first two internal fields back to the callback, kFinalizer
471 // will pass a void* parameter back, but is invoked before the object is
472 // actually collected, so it can be resurrected. In the last case, it is not
473 // possible to request a second pass callback.
475 
476 /**
477  * An object reference that is independent of any handle scope. Where
478  * a Local handle only lives as long as the HandleScope in which it was
479  * allocated, a PersistentBase handle remains valid until it is explicitly
480  * disposed using Reset().
481  *
482  * A persistent handle contains a reference to a storage cell within
483  * the V8 engine which holds an object value and which is updated by
484  * the garbage collector whenever the object is moved. A new storage
485  * cell can be created using the constructor or PersistentBase::Reset and
486  * existing handles can be disposed using PersistentBase::Reset.
487  *
488  */
489 template <class T> class PersistentBase {
490  public:
491  /**
492  * If non-empty, destroy the underlying storage cell
493  * IsEmpty() will return true after this call.
494  */
495  V8_INLINE void Reset();
496  /**
497  * If non-empty, destroy the underlying storage cell
498  * and create a new one with the contents of other if other is non empty
499  */
500  template <class S>
501  V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
502 
503  /**
504  * If non-empty, destroy the underlying storage cell
505  * and create a new one with the contents of other if other is non empty
506  */
507  template <class S>
508  V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
509 
510  V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
511  V8_INLINE void Empty() { val_ = 0; }
512 
513  V8_INLINE Local<T> Get(Isolate* isolate) const {
514  return Local<T>::New(isolate, *this);
515  }
516 
517  template <class S>
518  V8_INLINE bool operator==(const PersistentBase<S>& that) const {
519  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
520  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
521  if (a == nullptr) return b == nullptr;
522  if (b == nullptr) return false;
523  return *a == *b;
524  }
525 
526  template <class S>
527  V8_INLINE bool operator==(const Local<S>& that) const {
528  internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
529  internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
530  if (a == nullptr) return b == nullptr;
531  if (b == nullptr) return false;
532  return *a == *b;
533  }
534 
535  template <class S>
536  V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
537  return !operator==(that);
538  }
539 
540  template <class S>
541  V8_INLINE bool operator!=(const Local<S>& that) const {
542  return !operator==(that);
543  }
544 
545  /**
546  * Install a finalization callback on this object.
547  * NOTE: There is no guarantee as to *when* or even *if* the callback is
548  * invoked. The invocation is performed solely on a best effort basis.
549  * As always, GC-based finalization should *not* be relied upon for any
550  * critical form of resource management!
551  *
552  * The callback is supposed to reset the handle. No further V8 API may be
553  * called in this callback. In case additional work involving V8 needs to be
554  * done, a second callback can be scheduled using
555  * WeakCallbackInfo<void>::SetSecondPassCallback.
556  */
557  template <typename P>
558  V8_INLINE void SetWeak(P* parameter,
559  typename WeakCallbackInfo<P>::Callback callback,
560  WeakCallbackType type);
561 
562  /**
563  * Turns this handle into a weak phantom handle without finalization callback.
564  * The handle will be reset automatically when the garbage collector detects
565  * that the object is no longer reachable.
566  * A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall
567  * returns how many phantom handles were reset by the garbage collector.
568  */
569  V8_INLINE void SetWeak();
570 
571  template<typename P>
572  V8_INLINE P* ClearWeak();
573 
574  // TODO(dcarney): remove this.
575  V8_INLINE void ClearWeak() { ClearWeak<void>(); }
576 
577  /**
578  * Annotates the strong handle with the given label, which is then used by the
579  * heap snapshot generator as a name of the edge from the root to the handle.
580  * The function does not take ownership of the label and assumes that the
581  * label is valid as long as the handle is valid.
582  */
583  V8_INLINE void AnnotateStrongRetainer(const char* label);
584 
585  /** Returns true if the handle's reference is weak. */
586  V8_INLINE bool IsWeak() const;
587 
588  /**
589  * Assigns a wrapper class ID to the handle.
590  */
591  V8_INLINE void SetWrapperClassId(uint16_t class_id);
592 
593  /**
594  * Returns the class ID previously assigned to this handle or 0 if no class ID
595  * was previously assigned.
596  */
597  V8_INLINE uint16_t WrapperClassId() const;
598 
599  PersistentBase(const PersistentBase& other) = delete; // NOLINT
600  void operator=(const PersistentBase&) = delete;
601 
602  private:
603  friend class Isolate;
604  friend class Utils;
605  template<class F> friend class Local;
606  template<class F1, class F2> friend class Persistent;
607  template <class F>
608  friend class Global;
609  template<class F> friend class PersistentBase;
610  template<class F> friend class ReturnValue;
611  template <class F1, class F2, class F3>
613  template<class F1, class F2> friend class PersistentValueVector;
614  friend class Object;
615 
616  explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
617  V8_INLINE static T* New(Isolate* isolate, T* that);
618 
619  T* val_;
620 };
621 
622 
623 /**
624  * Default traits for Persistent. This class does not allow
625  * use of the copy constructor or assignment operator.
626  * At present kResetInDestructor is not set, but that will change in a future
627  * version.
628  */
629 template<class T>
630 class NonCopyablePersistentTraits {
631  public:
632  using NonCopyablePersistent = Persistent<T, NonCopyablePersistentTraits<T>>;
633  static const bool kResetInDestructor = false;
634  template<class S, class M>
635  V8_INLINE static void Copy(const Persistent<S, M>& source,
636  NonCopyablePersistent* dest) {
637  static_assert(sizeof(S) < 0,
638  "NonCopyablePersistentTraits::Copy is not instantiable");
639  }
640 };
641 
642 
643 /**
644  * Helper class traits to allow copying and assignment of Persistent.
645  * This will clone the contents of storage cell, but not any of the flags, etc.
646  */
647 template<class T>
649  using CopyablePersistent = Persistent<T, CopyablePersistentTraits<T>>;
650  static const bool kResetInDestructor = true;
651  template<class S, class M>
652  static V8_INLINE void Copy(const Persistent<S, M>& source,
653  CopyablePersistent* dest) {
654  // do nothing, just allow copy
655  }
656 };
657 
658 
659 /**
660  * A PersistentBase which allows copy and assignment.
661  *
662  * Copy, assignment and destructor behavior is controlled by the traits
663  * class M.
664  *
665  * Note: Persistent class hierarchy is subject to future changes.
666  */
667 template <class T, class M> class Persistent : public PersistentBase<T> {
668  public:
669  /**
670  * A Persistent with no storage cell.
671  */
673  /**
674  * Construct a Persistent from a Local.
675  * When the Local is non-empty, a new storage cell is created
676  * pointing to the same object, and no flags are set.
677  */
678  template <class S>
679  V8_INLINE Persistent(Isolate* isolate, Local<S> that)
680  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
681  static_assert(std::is_base_of<T, S>::value, "type check");
682  }
683  /**
684  * Construct a Persistent from a Persistent.
685  * When the Persistent is non-empty, a new storage cell is created
686  * pointing to the same object, and no flags are set.
687  */
688  template <class S, class M2>
689  V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
690  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
691  static_assert(std::is_base_of<T, S>::value, "type check");
692  }
693  /**
694  * The copy constructors and assignment operator create a Persistent
695  * exactly as the Persistent constructor, but the Copy function from the
696  * traits class is called, allowing the setting of flags based on the
697  * copied Persistent.
698  */
699  V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(nullptr) {
700  Copy(that);
701  }
702  template <class S, class M2>
703  V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) {
704  Copy(that);
705  }
707  Copy(that);
708  return *this;
709  }
710  template <class S, class M2>
711  V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT
712  Copy(that);
713  return *this;
714  }
715  /**
716  * The destructor will dispose the Persistent based on the
717  * kResetInDestructor flags in the traits class. Since not calling dispose
718  * can result in a memory leak, it is recommended to always set this flag.
719  */
721  if (M::kResetInDestructor) this->Reset();
722  }
723 
724  // TODO(dcarney): this is pretty useless, fix or remove
725  template <class S>
726  V8_INLINE static Persistent<T>& Cast(const Persistent<S>& that) { // NOLINT
727 #ifdef V8_ENABLE_CHECKS
728  // If we're going to perform the type check then we have to check
729  // that the handle isn't empty before doing the checked cast.
730  if (!that.IsEmpty()) T::Cast(*that);
731 #endif
732  return reinterpret_cast<Persistent<T>&>(const_cast<Persistent<S>&>(that));
733  }
734 
735  // TODO(dcarney): this is pretty useless, fix or remove
736  template <class S>
737  V8_INLINE Persistent<S>& As() const { // NOLINT
738  return Persistent<S>::Cast(*this);
739  }
740 
741  private:
742  friend class Isolate;
743  friend class Utils;
744  template<class F> friend class Local;
745  template<class F1, class F2> friend class Persistent;
746  template<class F> friend class ReturnValue;
747 
748  explicit V8_INLINE Persistent(T* that) : PersistentBase<T>(that) {}
749  V8_INLINE T* operator*() const { return this->val_; }
750  template<class S, class M2>
751  V8_INLINE void Copy(const Persistent<S, M2>& that);
752 };
753 
754 
755 /**
756  * A PersistentBase which has move semantics.
757  *
758  * Note: Persistent class hierarchy is subject to future changes.
759  */
760 template <class T>
761 class Global : public PersistentBase<T> {
762  public:
763  /**
764  * A Global with no storage cell.
765  */
766  V8_INLINE Global() : PersistentBase<T>(nullptr) {}
767 
768  /**
769  * Construct a Global from a Local.
770  * When the Local is non-empty, a new storage cell is created
771  * pointing to the same object, and no flags are set.
772  */
773  template <class S>
774  V8_INLINE Global(Isolate* isolate, Local<S> that)
775  : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
776  static_assert(std::is_base_of<T, S>::value, "type check");
777  }
778 
779  /**
780  * Construct a Global from a PersistentBase.
781  * When the Persistent is non-empty, a new storage cell is created
782  * pointing to the same object, and no flags are set.
783  */
784  template <class S>
785  V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
786  : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
787  static_assert(std::is_base_of<T, S>::value, "type check");
788  }
789 
790  /**
791  * Move constructor.
792  */
793  V8_INLINE Global(Global&& other);
794 
795  V8_INLINE ~Global() { this->Reset(); }
796 
797  /**
798  * Move via assignment.
799  */
800  template <class S>
801  V8_INLINE Global& operator=(Global<S>&& rhs);
802 
803  /**
804  * Pass allows returning uniques from functions, etc.
805  */
806  Global Pass() { return static_cast<Global&&>(*this); } // NOLINT
807 
808  /*
809  * For compatibility with Chromium's base::Bind (base::Passed).
810  */
811  using MoveOnlyTypeForCPP03 = void;
812 
813  Global(const Global&) = delete;
814  void operator=(const Global&) = delete;
815 
816  private:
817  template <class F>
818  friend class ReturnValue;
819  V8_INLINE T* operator*() const { return this->val_; }
820 };
821 
822 
823 // UniquePersistent is an alias for Global for historical reason.
824 template <class T>
825 using UniquePersistent = Global<T>;
826 
827 /**
828  * Deprecated. Use |TracedReference<T>| instead.
829  */
830 template <typename T>
832 
834  public:
835  /**
836  * Returns true if the reference is empty, i.e., has not been assigned
837  * object.
838  */
839  bool IsEmpty() const { return val_ == nullptr; }
840 
841  /**
842  * If non-empty, destroy the underlying storage cell. |IsEmpty| will return
843  * true after this call.
844  */
845  V8_INLINE void Reset();
846 
847  /**
848  * Construct a Local<Value> from this handle.
849  */
850  V8_INLINE v8::Local<v8::Value> Get(v8::Isolate* isolate) const;
851 
852  /**
853  * Returns true if this TracedReference is empty, i.e., has not been
854  * assigned an object. This version of IsEmpty is thread-safe.
855  */
856  bool IsEmptyThreadSafe() const {
857  return this->GetSlotThreadSafe() == nullptr;
858  }
859 
860  /**
861  * Assigns a wrapper class ID to the handle.
862  */
863  V8_INLINE void SetWrapperClassId(uint16_t class_id);
864 
865  /**
866  * Returns the class ID previously assigned to this handle or 0 if no class ID
867  * was previously assigned.
868  */
869  V8_INLINE uint16_t WrapperClassId() const;
870 
871  protected:
872  /**
873  * Update this reference in a thread-safe way.
874  */
875  void SetSlotThreadSafe(void* new_val) {
876  reinterpret_cast<std::atomic<void*>*>(&val_)->store(
877  new_val, std::memory_order_relaxed);
878  }
879 
880  /**
881  * Get this reference in a thread-safe way
882  */
883  const void* GetSlotThreadSafe() const {
884  return reinterpret_cast<std::atomic<const void*> const*>(&val_)->load(
885  std::memory_order_relaxed);
886  }
887 
888  // val_ points to a GlobalHandles node.
889  internal::Address* val_ = nullptr;
890 
891  friend class internal::BasicTracedReferenceExtractor;
892  template <typename F>
893  friend class Local;
894  template <typename U>
895  friend bool operator==(const TracedReferenceBase&, const Local<U>&);
896  friend bool operator==(const TracedReferenceBase&,
897  const TracedReferenceBase&);
898 };
899 
900 /**
901  * A traced handle with copy and move semantics. The handle is to be used
902  * together with |v8::EmbedderHeapTracer| or as part of GarbageCollected objects
903  * (see v8-cppgc.h) and specifies edges from C++ objects to JavaScript.
904  *
905  * The exact semantics are:
906  * - Tracing garbage collections use |v8::EmbedderHeapTracer| or cppgc.
907  * - Non-tracing garbage collections refer to
908  * |v8::EmbedderHeapTracer::IsRootForNonTracingGC()| whether the handle should
909  * be treated as root or not.
910  *
911  * Note that the base class cannot be instantiated itself. Choose from
912  * - TracedGlobal
913  * - TracedReference
914  */
915 template <typename T>
917  public:
918  /**
919  * Construct a Local<T> from this handle.
920  */
921  Local<T> Get(Isolate* isolate) const { return Local<T>::New(isolate, *this); }
922 
923  template <class S>
925  return reinterpret_cast<BasicTracedReference<S>&>(
926  const_cast<BasicTracedReference<T>&>(*this));
927  }
928 
929  T* operator->() const { return reinterpret_cast<T*>(val_); }
930  T* operator*() const { return reinterpret_cast<T*>(val_); }
931 
932  private:
933  enum DestructionMode { kWithDestructor, kWithoutDestructor };
934 
935  /**
936  * An empty BasicTracedReference without storage cell.
937  */
938  BasicTracedReference() = default;
939 
940  V8_INLINE static internal::Address* New(Isolate* isolate, T* that, void* slot,
941  DestructionMode destruction_mode);
942 
943  friend class EmbedderHeapTracer;
944  template <typename F>
945  friend class Local;
946  friend class Object;
947  template <typename F>
948  friend class TracedGlobal;
949  template <typename F>
950  friend class TracedReference;
951  template <typename F>
952  friend class BasicTracedReference;
953  template <typename F>
954  friend class ReturnValue;
955 };
956 
957 /**
958  * A traced handle with destructor that clears the handle. For more details see
959  * BasicTracedReference.
960  */
961 template <typename T>
962 class TracedGlobal : public BasicTracedReference<T> {
963  public:
964  using BasicTracedReference<T>::Reset;
965 
966  /**
967  * Destructor resetting the handle.Is
968  */
969  ~TracedGlobal() { this->Reset(); }
970 
971  /**
972  * An empty TracedGlobal without storage cell.
973  */
975 
976  /**
977  * Construct a TracedGlobal from a Local.
978  *
979  * When the Local is non-empty, a new storage cell is created
980  * pointing to the same object.
981  */
982  template <class S>
983  TracedGlobal(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
984  this->val_ = this->New(isolate, that.val_, &this->val_,
985  BasicTracedReference<T>::kWithDestructor);
986  static_assert(std::is_base_of<T, S>::value, "type check");
987  }
988 
989  /**
990  * Move constructor initializing TracedGlobal from an existing one.
991  */
993  // Forward to operator=.
994  *this = std::move(other);
995  }
996 
997  /**
998  * Move constructor initializing TracedGlobal from an existing one.
999  */
1000  template <typename S>
1002  // Forward to operator=.
1003  *this = std::move(other);
1004  }
1005 
1006  /**
1007  * Copy constructor initializing TracedGlobal from an existing one.
1008  */
1010  // Forward to operator=;
1011  *this = other;
1012  }
1013 
1014  /**
1015  * Copy constructor initializing TracedGlobal from an existing one.
1016  */
1017  template <typename S>
1019  // Forward to operator=;
1020  *this = other;
1021  }
1022 
1023  /**
1024  * Move assignment operator initializing TracedGlobal from an existing one.
1025  */
1027 
1028  /**
1029  * Move assignment operator initializing TracedGlobal from an existing one.
1030  */
1031  template <class S>
1033 
1034  /**
1035  * Copy assignment operator initializing TracedGlobal from an existing one.
1036  *
1037  * Note: Prohibited when |other| has a finalization callback set through
1038  * |SetFinalizationCallback|.
1039  */
1041 
1042  /**
1043  * Copy assignment operator initializing TracedGlobal from an existing one.
1044  *
1045  * Note: Prohibited when |other| has a finalization callback set through
1046  * |SetFinalizationCallback|.
1047  */
1048  template <class S>
1049  V8_INLINE TracedGlobal& operator=(const TracedGlobal<S>& rhs);
1050 
1051  /**
1052  * If non-empty, destroy the underlying storage cell and create a new one with
1053  * the contents of other if other is non empty
1054  */
1055  template <class S>
1056  V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
1057 
1058  template <class S>
1059  V8_INLINE TracedGlobal<S>& As() const {
1060  return reinterpret_cast<TracedGlobal<S>&>(
1061  const_cast<TracedGlobal<T>&>(*this));
1062  }
1063 
1064  /**
1065  * Adds a finalization callback to the handle. The type of this callback is
1066  * similar to WeakCallbackType::kInternalFields, i.e., it will pass the
1067  * parameter and the first two internal fields of the object.
1068  *
1069  * The callback is then supposed to reset the handle in the callback. No
1070  * further V8 API may be called in this callback. In case additional work
1071  * involving V8 needs to be done, a second callback can be scheduled using
1072  * WeakCallbackInfo<void>::SetSecondPassCallback.
1073  */
1075  void* parameter, WeakCallbackInfo<void>::Callback callback);
1076 };
1077 
1078 /**
1079  * A traced handle without destructor that clears the handle. The embedder needs
1080  * to ensure that the handle is not accessed once the V8 object has been
1081  * reclaimed. This can happen when the handle is not passed through the
1082  * EmbedderHeapTracer. For more details see BasicTracedReference.
1083  *
1084  * The reference assumes the embedder has precise knowledge about references at
1085  * all times. In case V8 needs to separately handle on-stack references, the
1086  * embedder is required to set the stack start through
1087  * |EmbedderHeapTracer::SetStackStart|.
1088  */
1089 template <typename T>
1090 class TracedReference : public BasicTracedReference<T> {
1091  public:
1092  using BasicTracedReference<T>::Reset;
1093 
1094  /**
1095  * An empty TracedReference without storage cell.
1096  */
1098 
1099  /**
1100  * Construct a TracedReference from a Local.
1101  *
1102  * When the Local is non-empty, a new storage cell is created
1103  * pointing to the same object.
1104  */
1105  template <class S>
1107  this->val_ = this->New(isolate, that.val_, &this->val_,
1108  BasicTracedReference<T>::kWithoutDestructor);
1109  static_assert(std::is_base_of<T, S>::value, "type check");
1110  }
1111 
1112  /**
1113  * Move constructor initializing TracedReference from an
1114  * existing one.
1115  */
1117  // Forward to operator=.
1118  *this = std::move(other);
1119  }
1120 
1121  /**
1122  * Move constructor initializing TracedReference from an
1123  * existing one.
1124  */
1125  template <typename S>
1127  // Forward to operator=.
1128  *this = std::move(other);
1129  }
1130 
1131  /**
1132  * Copy constructor initializing TracedReference from an
1133  * existing one.
1134  */
1136  // Forward to operator=;
1137  *this = other;
1138  }
1139 
1140  /**
1141  * Copy constructor initializing TracedReference from an
1142  * existing one.
1143  */
1144  template <typename S>
1146  // Forward to operator=;
1147  *this = other;
1148  }
1149 
1150  /**
1151  * Move assignment operator initializing TracedGlobal from an existing one.
1152  */
1154 
1155  /**
1156  * Move assignment operator initializing TracedGlobal from an existing one.
1157  */
1158  template <class S>
1160 
1161  /**
1162  * Copy assignment operator initializing TracedGlobal from an existing one.
1163  */
1165 
1166  /**
1167  * Copy assignment operator initializing TracedGlobal from an existing one.
1168  */
1169  template <class S>
1171 
1172  /**
1173  * If non-empty, destroy the underlying storage cell and create a new one with
1174  * the contents of other if other is non empty
1175  */
1176  template <class S>
1177  V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
1178 
1179  template <class S>
1181  return reinterpret_cast<TracedReference<S>&>(
1182  const_cast<TracedReference<T>&>(*this));
1183  }
1184 };
1185 
1186  /**
1187  * A stack-allocated class that governs a number of local handles.
1188  * After a handle scope has been created, all local handles will be
1189  * allocated within that handle scope until either the handle scope is
1190  * deleted or another handle scope is created. If there is already a
1191  * handle scope and a new one is created, all allocations will take
1192  * place in the new handle scope until it is deleted. After that,
1193  * new handles will again be allocated in the original handle scope.
1194  *
1195  * After the handle scope of a local handle has been deleted the
1196  * garbage collector will no longer track the object stored in the
1197  * handle and may deallocate it. The behavior of accessing a handle
1198  * for which the handle scope has been deleted is undefined.
1199  */
1201  public:
1202  explicit HandleScope(Isolate* isolate);
1203 
1204  ~HandleScope();
1205 
1206  /**
1207  * Counts the number of allocated handles.
1208  */
1209  static int NumberOfHandles(Isolate* isolate);
1210 
1212  return reinterpret_cast<Isolate*>(isolate_);
1213  }
1214 
1215  HandleScope(const HandleScope&) = delete;
1216  void operator=(const HandleScope&) = delete;
1217 
1218  protected:
1219  V8_INLINE HandleScope() = default;
1220 
1221  void Initialize(Isolate* isolate);
1222 
1223  static internal::Address* CreateHandle(internal::Isolate* isolate,
1224  internal::Address value);
1225 
1226  private:
1227  // Declaring operator new and delete as deleted is not spec compliant.
1228  // Therefore declare them private instead to disable dynamic alloc
1229  void* operator new(size_t size);
1230  void* operator new[](size_t size);
1231  void operator delete(void*, size_t);
1232  void operator delete[](void*, size_t);
1233 
1234  internal::Isolate* isolate_;
1235  internal::Address* prev_next_;
1236  internal::Address* prev_limit_;
1237 
1238  // Local::New uses CreateHandle with an Isolate* parameter.
1239  template<class F> friend class Local;
1240 
1241  // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
1242  // a HeapObject in their shortcuts.
1243  friend class Object;
1244  friend class Context;
1245 };
1246 
1247 /**
1248  * A HandleScope which first allocates a handle in the current scope
1249  * which will be later filled with the escape value.
1250  */
1252  public:
1253  explicit EscapableHandleScope(Isolate* isolate);
1254  V8_INLINE ~EscapableHandleScope() = default;
1255 
1256  /**
1257  * Pushes the value into the previous scope and returns a handle to it.
1258  * Cannot be called twice.
1259  */
1260  template <class T>
1261  V8_INLINE Local<T> Escape(Local<T> value) {
1262  internal::Address* slot =
1263  Escape(reinterpret_cast<internal::Address*>(*value));
1264  return Local<T>(reinterpret_cast<T*>(slot));
1265  }
1266 
1267  template <class T>
1269  return Escape(value.FromMaybe(Local<T>()));
1270  }
1271 
1272  EscapableHandleScope(const EscapableHandleScope&) = delete;
1273  void operator=(const EscapableHandleScope&) = delete;
1274 
1275  private:
1276  // Declaring operator new and delete as deleted is not spec compliant.
1277  // Therefore declare them private instead to disable dynamic alloc
1278  void* operator new(size_t size);
1279  void* operator new[](size_t size);
1280  void operator delete(void*, size_t);
1281  void operator delete[](void*, size_t);
1282 
1283  internal::Address* Escape(internal::Address* escape_value);
1284  internal::Address* escape_slot_;
1285 };
1286 
1287 /**
1288  * A SealHandleScope acts like a handle scope in which no handle allocations
1289  * are allowed. It can be useful for debugging handle leaks.
1290  * Handles can be allocated within inner normal HandleScopes.
1291  */
1293  public:
1294  explicit SealHandleScope(Isolate* isolate);
1295  ~SealHandleScope();
1296 
1297  SealHandleScope(const SealHandleScope&) = delete;
1298  void operator=(const SealHandleScope&) = delete;
1299 
1300  private:
1301  // Declaring operator new and delete as deleted is not spec compliant.
1302  // Therefore declare them private instead to disable dynamic alloc
1303  void* operator new(size_t size);
1304  void* operator new[](size_t size);
1305  void operator delete(void*, size_t);
1306  void operator delete[](void*, size_t);
1307 
1308  internal::Isolate* const isolate_;
1309  internal::Address* prev_limit_;
1310  int prev_sealed_level_;
1311 };
1312 
1313 // --- Special objects ---
1314 
1315 /**
1316  * The superclass of objects that can reside on V8's heap.
1317  */
1319  public:
1320  /**
1321  * Returns true if this data is a |v8::Value|.
1322  */
1323  bool IsValue() const;
1324 
1325  /**
1326  * Returns true if this data is a |v8::Module|.
1327  */
1328  bool IsModule() const;
1329 
1330  /**
1331  * Returns true if this data is a |v8::Private|.
1332  */
1333  bool IsPrivate() const;
1334 
1335  /**
1336  * Returns true if this data is a |v8::ObjectTemplate|.
1337  */
1338  bool IsObjectTemplate() const;
1339 
1340  /**
1341  * Returns true if this data is a |v8::FunctionTemplate|.
1342  */
1343  bool IsFunctionTemplate() const;
1344 
1345  /**
1346  * Returns true if this data is a |v8::Context|.
1347  */
1348  bool IsContext() const;
1349 
1350  private:
1351  Data();
1352 };
1353 
1354 /**
1355  * A container type that holds relevant metadata for module loading.
1356  *
1357  * This is passed back to the embedder as part of
1358  * HostImportModuleDynamicallyCallback for module loading.
1359  */
1361  public:
1362  /**
1363  * The name that was passed by the embedder as ResourceName to the
1364  * ScriptOrigin. This can be either a v8::String or v8::Undefined.
1365  */
1367 
1368  /**
1369  * The options that were passed by the embedder as HostDefinedOptions to
1370  * the ScriptOrigin.
1371  */
1373 };
1374 
1375 /**
1376  * An array to hold Primitive values. This is used by the embedder to
1377  * pass host defined options to the ScriptOptions during compilation.
1378  *
1379  * This is passed back to the embedder as part of
1380  * HostImportModuleDynamicallyCallback for module loading.
1381  *
1382  */
1384  public:
1385  static Local<PrimitiveArray> New(Isolate* isolate, int length);
1386  int Length() const;
1387  void Set(Isolate* isolate, int index, Local<Primitive> item);
1388  Local<Primitive> Get(Isolate* isolate, int index);
1389 };
1390 
1391 /**
1392  * The optional attributes of ScriptOrigin.
1393  */
1395  public:
1396  V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
1397  bool is_opaque = false, bool is_wasm = false,
1398  bool is_module = false)
1399  : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
1400  (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
1401  (is_module ? kIsModule : 0)) {}
1403  : flags_(flags &
1404  (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
1405 
1406  bool IsSharedCrossOrigin() const {
1407  return (flags_ & kIsSharedCrossOrigin) != 0;
1408  }
1409  bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
1410  bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
1411  bool IsModule() const { return (flags_ & kIsModule) != 0; }
1412 
1413  int Flags() const { return flags_; }
1414 
1415  private:
1416  enum {
1417  kIsSharedCrossOrigin = 1,
1418  kIsOpaque = 1 << 1,
1419  kIsWasm = 1 << 2,
1420  kIsModule = 1 << 3
1421  };
1422  const int flags_;
1423 };
1424 
1425 /**
1426  * The origin, within a file, of a script.
1427  */
1429  public:
1430  V8_DEPRECATE_SOON("Use constructor with primitive C++ types")
1431  V8_INLINE explicit ScriptOrigin(
1432  Local<Value> resource_name, Local<Integer> resource_line_offset,
1433  Local<Integer> resource_column_offset,
1434  Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(),
1435  Local<Integer> script_id = Local<Integer>(),
1436  Local<Value> source_map_url = Local<Value>(),
1437  Local<Boolean> resource_is_opaque = Local<Boolean>(),
1438  Local<Boolean> is_wasm = Local<Boolean>(),
1439  Local<Boolean> is_module = Local<Boolean>(),
1440  Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
1441  V8_DEPRECATE_SOON("Use constructor that takes an isolate")
1442  V8_INLINE explicit ScriptOrigin(
1443  Local<Value> resource_name, int resource_line_offset = 0,
1444  int resource_column_offset = 0,
1445  bool resource_is_shared_cross_origin = false, int script_id = -1,
1446  Local<Value> source_map_url = Local<Value>(),
1447  bool resource_is_opaque = false, bool is_wasm = false,
1448  bool is_module = false,
1449  Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
1450  V8_INLINE explicit ScriptOrigin(
1451  Isolate* isolate, Local<Value> resource_name,
1452  int resource_line_offset = 0, int resource_column_offset = 0,
1453  bool resource_is_shared_cross_origin = false, int script_id = -1,
1454  Local<Value> source_map_url = Local<Value>(),
1455  bool resource_is_opaque = false, bool is_wasm = false,
1456  bool is_module = false,
1457  Local<PrimitiveArray> host_defined_options = Local<PrimitiveArray>());
1458 
1459  V8_INLINE Local<Value> ResourceName() const;
1460  V8_DEPRECATE_SOON("Use getter with primitvie C++ types.")
1462  V8_DEPRECATE_SOON("Use getter with primitvie C++ types.")
1464  V8_DEPRECATE_SOON("Use getter with primitvie C++ types.")
1465  V8_INLINE Local<Integer> ScriptID() const;
1466  V8_INLINE int LineOffset() const;
1467  V8_INLINE int ColumnOffset() const;
1468  V8_INLINE int ScriptId() const;
1469  V8_INLINE Local<Value> SourceMapUrl() const;
1471  V8_INLINE ScriptOriginOptions Options() const { return options_; }
1472 
1473  private:
1474  Isolate* isolate_;
1475  Local<Value> resource_name_;
1476  int resource_line_offset_;
1477  int resource_column_offset_;
1478  ScriptOriginOptions options_;
1479  int script_id_;
1480  Local<Value> source_map_url_;
1481  Local<PrimitiveArray> host_defined_options_;
1482 };
1483 
1484 /**
1485  * A compiled JavaScript script, not yet tied to a Context.
1486  */
1488  public:
1489  /**
1490  * Binds the script to the currently entered context.
1491  */
1493 
1494  int GetId();
1496 
1497  /**
1498  * Data read from magic sourceURL comments.
1499  */
1501  /**
1502  * Data read from magic sourceMappingURL comments.
1503  */
1505 
1506  /**
1507  * Returns zero based line number of the code_pos location in the script.
1508  * -1 will be returned if no information available.
1509  */
1510  int GetLineNumber(int code_pos);
1511 
1512  static const int kNoScriptId = 0;
1513 };
1514 
1515 /**
1516  * A compiled JavaScript module, not yet tied to a Context.
1517  */
1519  // Only used as a container for code caching.
1520 };
1521 
1522 /**
1523  * A location in JavaScript source.
1524  */
1526  public:
1527  int GetLineNumber() { return line_number_; }
1528  int GetColumnNumber() { return column_number_; }
1529 
1530  Location(int line_number, int column_number)
1531  : line_number_(line_number), column_number_(column_number) {}
1532 
1533  private:
1534  int line_number_;
1535  int column_number_;
1536 };
1537 
1538 /**
1539  * A fixed-sized array with elements of type Data.
1540  */
1541 class V8_EXPORT FixedArray : public Data {
1542  public:
1543  int Length() const;
1544  Local<Data> Get(Local<Context> context, int i) const;
1545 };
1546 
1547 class V8_EXPORT ModuleRequest : public Data {
1548  public:
1549  /**
1550  * Returns the module specifier for this ModuleRequest.
1551  */
1552  Local<String> GetSpecifier() const;
1553 
1554  /**
1555  * Returns the source code offset of this module request.
1556  * Use Module::SourceOffsetToLocation to convert this to line/column numbers.
1557  */
1558  int GetSourceOffset() const;
1559 
1560  /**
1561  * Contains the import assertions for this request in the form:
1562  * [key1, value1, source_offset1, key2, value2, source_offset2, ...].
1563  * The keys and values are of type v8::String, and the source offsets are of
1564  * type Int32. Use Module::SourceOffsetToLocation to convert the source
1565  * offsets to Locations with line/column numbers.
1566  *
1567  * All assertions present in the module request will be supplied in this
1568  * list, regardless of whether they are supported by the host. Per
1569  * https://tc39.es/proposal-import-assertions/#sec-hostgetsupportedimportassertions,
1570  * hosts are expected to ignore assertions that they do not support (as
1571  * opposed to, for example, triggering an error if an unsupported assertion is
1572  * present).
1573  */
1575 
1576  V8_INLINE static ModuleRequest* Cast(Data* data);
1577 
1578  private:
1579  static void CheckCast(Data* obj);
1580 };
1581 
1582 /**
1583  * A compiled JavaScript module.
1584  */
1585 class V8_EXPORT Module : public Data {
1586  public:
1587  /**
1588  * The different states a module can be in.
1589  *
1590  * This corresponds to the states used in ECMAScript except that "evaluated"
1591  * is split into kEvaluated and kErrored, indicating success and failure,
1592  * respectively.
1593  */
1594  enum Status {
1601  };
1602 
1603  /**
1604  * Returns the module's current status.
1605  */
1606  Status GetStatus() const;
1607 
1608  /**
1609  * For a module in kErrored status, this returns the corresponding exception.
1610  */
1611  Local<Value> GetException() const;
1612 
1613  /**
1614  * Returns the number of modules requested by this module.
1615  */
1616  V8_DEPRECATE_SOON("Use Module::GetModuleRequests() and FixedArray::Length().")
1617  int GetModuleRequestsLength() const;
1618 
1619  /**
1620  * Returns the ith module specifier in this module.
1621  * i must be < GetModuleRequestsLength() and >= 0.
1622  */
1624  "Use Module::GetModuleRequests() and ModuleRequest::GetSpecifier().")
1625  Local<String> GetModuleRequest(int i) const;
1626 
1627  /**
1628  * Returns the source location (line number and column number) of the ith
1629  * module specifier's first occurrence in this module.
1630  */
1632  "Use Module::GetModuleRequests(), ModuleRequest::GetSourceOffset(), and "
1633  "Module::SourceOffsetToLocation().")
1634  Location GetModuleRequestLocation(int i) const;
1635 
1636  /**
1637  * Returns the ModuleRequests for this module.
1638  */
1640 
1641  /**
1642  * For the given source text offset in this module, returns the corresponding
1643  * Location with line and column numbers.
1644  */
1645  Location SourceOffsetToLocation(int offset) const;
1646 
1647  /**
1648  * Returns the identity hash for this object.
1649  */
1650  int GetIdentityHash() const;
1651 
1652  using ResolveCallback V8_DEPRECATE_SOON("Use ResolveModuleCallback") =
1653  MaybeLocal<Module> (*)(Local<Context> context, Local<String> specifier,
1654  Local<Module> referrer);
1655  using ResolveModuleCallback = MaybeLocal<Module> (*)(
1656  Local<Context> context, Local<String> specifier,
1657  Local<FixedArray> import_assertions, Local<Module> referrer);
1658 
1659  /**
1660  * Instantiates the module and its dependencies.
1661  *
1662  * Returns an empty Maybe<bool> if an exception occurred during
1663  * instantiation. (In the case where the callback throws an exception, that
1664  * exception is propagated.)
1665  */
1667  "Use the version of InstantiateModule that takes a ResolveModuleCallback "
1668  "parameter")
1669  V8_WARN_UNUSED_RESULT Maybe<bool> InstantiateModule(Local<Context> context,
1670  ResolveCallback callback);
1672  Local<Context> context, ResolveModuleCallback callback);
1673 
1674  /**
1675  * Evaluates the module and its dependencies.
1676  *
1677  * If status is kInstantiated, run the module's code. On success, set status
1678  * to kEvaluated and return the completion value; on failure, set status to
1679  * kErrored and propagate the thrown exception (which is then also available
1680  * via |GetException|).
1681  */
1683 
1684  /**
1685  * Returns the namespace object of this module.
1686  *
1687  * The module's status must be at least kInstantiated.
1688  */
1690 
1691  /**
1692  * Returns the corresponding context-unbound module script.
1693  *
1694  * The module must be unevaluated, i.e. its status must not be kEvaluating,
1695  * kEvaluated or kErrored.
1696  */
1698 
1699  /**
1700  * Returns the underlying script's id.
1701  *
1702  * The module must be a SourceTextModule and must not have a kErrored status.
1703  */
1704  int ScriptId();
1705 
1706  /**
1707  * Returns whether this module or any of its requested modules is async,
1708  * i.e. contains top-level await.
1709  *
1710  * The module's status must be at least kInstantiated.
1711  */
1712  bool IsGraphAsync() const;
1713 
1714  /**
1715  * Returns whether the module is a SourceTextModule.
1716  */
1717  bool IsSourceTextModule() const;
1718 
1719  /**
1720  * Returns whether the module is a SyntheticModule.
1721  */
1722  bool IsSyntheticModule() const;
1723 
1724  /*
1725  * Callback defined in the embedder. This is responsible for setting
1726  * the module's exported values with calls to SetSyntheticModuleExport().
1727  * The callback must return a resolved Promise to indicate success (where no
1728  * exception was thrown) and return an empy MaybeLocal to indicate falure
1729  * (where an exception was thrown).
1730  */
1731  using SyntheticModuleEvaluationSteps =
1732  MaybeLocal<Value> (*)(Local<Context> context, Local<Module> module);
1733 
1734  /**
1735  * Creates a new SyntheticModule with the specified export names, where
1736  * evaluation_steps will be executed upon module evaluation.
1737  * export_names must not contain duplicates.
1738  * module_name is used solely for logging/debugging and doesn't affect module
1739  * behavior.
1740  */
1742  Isolate* isolate, Local<String> module_name,
1743  const std::vector<Local<String>>& export_names,
1744  SyntheticModuleEvaluationSteps evaluation_steps);
1745 
1746  /**
1747  * Set this module's exported value for the name export_name to the specified
1748  * export_value. This method must be called only on Modules created via
1749  * CreateSyntheticModule. An error will be thrown if export_name is not one
1750  * of the export_names that were passed in that CreateSyntheticModule call.
1751  * Returns Just(true) on success, Nothing<bool>() if an error was thrown.
1752  */
1754  Isolate* isolate, Local<String> export_name, Local<Value> export_value);
1755  V8_DEPRECATED(
1756  "Use the preceding SetSyntheticModuleExport with an Isolate parameter, "
1757  "instead of the one that follows. The former will throw a runtime "
1758  "error if called for an export that doesn't exist (as per spec); "
1759  "the latter will crash with a failed CHECK().")
1760  void SetSyntheticModuleExport(Local<String> export_name,
1762 
1763  V8_INLINE static Module* Cast(Data* data);
1764 
1765  private:
1766  static void CheckCast(Data* obj);
1767 };
1768 
1769 /**
1770  * A compiled JavaScript script, tied to a Context which was active when the
1771  * script was compiled.
1772  */
1774  public:
1775  /**
1776  * A shorthand for ScriptCompiler::Compile().
1777  */
1779  Local<Context> context, Local<String> source,
1780  ScriptOrigin* origin = nullptr);
1781 
1782  /**
1783  * Runs the script returning the resulting value. It will be run in the
1784  * context in which it was created (ScriptCompiler::CompileBound or
1785  * UnboundScript::BindToCurrentContext()).
1786  */
1788 
1789  /**
1790  * Returns the corresponding context-unbound script.
1791  */
1793 };
1794 
1795 enum class ScriptType { kClassic, kModule };
1796 
1797 /**
1798  * For compiling scripts.
1799  */
1801  public:
1802  /**
1803  * Compilation data that the embedder can cache and pass back to speed up
1804  * future compilations. The data is produced if the CompilerOptions passed to
1805  * the compilation functions in ScriptCompiler contains produce_data_to_cache
1806  * = true. The data to cache can then can be retrieved from
1807  * UnboundScript.
1808  */
1813  };
1814 
1816  : data(nullptr),
1817  length(0),
1818  rejected(false),
1820 
1821  // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
1822  // data and guarantees that it stays alive until the CachedData object is
1823  // destroyed. If the policy is BufferOwned, the given data will be deleted
1824  // (with delete[]) when the CachedData object is destroyed.
1825  CachedData(const uint8_t* data, int length,
1826  BufferPolicy buffer_policy = BufferNotOwned);
1827  ~CachedData();
1828  // TODO(marja): Async compilation; add constructors which take a callback
1829  // which will be called when V8 no longer needs the data.
1830  const uint8_t* data;
1831  int length;
1832  bool rejected;
1834 
1835  // Prevent copying.
1836  CachedData(const CachedData&) = delete;
1837  CachedData& operator=(const CachedData&) = delete;
1838  };
1839 
1840  /**
1841  * Source code which can be then compiled to a UnboundScript or Script.
1842  */
1843  class Source {
1844  public:
1845  // Source takes ownership of CachedData.
1846  V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
1847  CachedData* cached_data = nullptr);
1848  V8_INLINE explicit Source(Local<String> source_string,
1849  CachedData* cached_data = nullptr);
1850  V8_INLINE ~Source();
1851 
1852  // Ownership of the CachedData or its buffers is *not* transferred to the
1853  // caller. The CachedData object is alive as long as the Source object is
1854  // alive.
1855  V8_INLINE const CachedData* GetCachedData() const;
1856 
1858 
1859  // Prevent copying.
1860  Source(const Source&) = delete;
1861  Source& operator=(const Source&) = delete;
1862 
1863  private:
1864  friend class ScriptCompiler;
1865 
1866  Local<String> source_string;
1867 
1868  // Origin information
1869  Local<Value> resource_name;
1870  int resource_line_offset;
1871  int resource_column_offset;
1872  ScriptOriginOptions resource_options;
1873  Local<Value> source_map_url;
1874  Local<PrimitiveArray> host_defined_options;
1875 
1876  // Cached data from previous compilation (if a kConsume*Cache flag is
1877  // set), or hold newly generated cache data (kProduce*Cache flags) are
1878  // set when calling a compile method.
1879  CachedData* cached_data;
1880  };
1881 
1882  /**
1883  * For streaming incomplete script data to V8. The embedder should implement a
1884  * subclass of this class.
1885  */
1887  public:
1888  virtual ~ExternalSourceStream() = default;
1889 
1890  /**
1891  * V8 calls this to request the next chunk of data from the embedder. This
1892  * function will be called on a background thread, so it's OK to block and
1893  * wait for the data, if the embedder doesn't have data yet. Returns the
1894  * length of the data returned. When the data ends, GetMoreData should
1895  * return 0. Caller takes ownership of the data.
1896  *
1897  * When streaming UTF-8 data, V8 handles multi-byte characters split between
1898  * two data chunks, but doesn't handle multi-byte characters split between
1899  * more than two data chunks. The embedder can avoid this problem by always
1900  * returning at least 2 bytes of data.
1901  *
1902  * When streaming UTF-16 data, V8 does not handle characters split between
1903  * two data chunks. The embedder has to make sure that chunks have an even
1904  * length.
1905  *
1906  * If the embedder wants to cancel the streaming, they should make the next
1907  * GetMoreData call return 0. V8 will interpret it as end of data (and most
1908  * probably, parsing will fail). The streaming task will return as soon as
1909  * V8 has parsed the data it received so far.
1910  */
1911  virtual size_t GetMoreData(const uint8_t** src) = 0;
1912 
1913  /**
1914  * V8 calls this method to set a 'bookmark' at the current position in
1915  * the source stream, for the purpose of (maybe) later calling
1916  * ResetToBookmark. If ResetToBookmark is called later, then subsequent
1917  * calls to GetMoreData should return the same data as they did when
1918  * SetBookmark was called earlier.
1919  *
1920  * The embedder may return 'false' to indicate it cannot provide this
1921  * functionality.
1922  */
1923  virtual bool SetBookmark();
1924 
1925  /**
1926  * V8 calls this to return to a previously set bookmark.
1927  */
1928  virtual void ResetToBookmark();
1929  };
1930 
1931  /**
1932  * Source code which can be streamed into V8 in pieces. It will be parsed
1933  * while streaming and compiled after parsing has completed. StreamedSource
1934  * must be kept alive while the streaming task is run (see ScriptStreamingTask
1935  * below).
1936  */
1938  public:
1940 
1941  V8_DEPRECATED(
1942  "This class takes ownership of source_stream, so use the constructor "
1943  "taking a unique_ptr to make these semantics clearer")
1944  StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
1945  StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
1946  Encoding encoding);
1947  ~StreamedSource();
1948 
1949  internal::ScriptStreamingData* impl() const { return impl_.get(); }
1950 
1951  // Prevent copying.
1952  StreamedSource(const StreamedSource&) = delete;
1953  StreamedSource& operator=(const StreamedSource&) = delete;
1954 
1955  private:
1956  std::unique_ptr<internal::ScriptStreamingData> impl_;
1957  };
1958 
1959  /**
1960  * A streaming task which the embedder must run on a background thread to
1961  * stream scripts into V8. Returned by ScriptCompiler::StartStreaming.
1962  */
1963  class V8_EXPORT ScriptStreamingTask final {
1964  public:
1965  void Run();
1966 
1967  private:
1968  friend class ScriptCompiler;
1969 
1970  explicit ScriptStreamingTask(internal::ScriptStreamingData* data)
1971  : data_(data) {}
1972 
1973  internal::ScriptStreamingData* data_;
1974  };
1975 
1980  };
1981 
1982  /**
1983  * The reason for which we are not requesting or providing a code cache.
1984  */
2001  };
2002 
2003  /**
2004  * Compiles the specified script (context-independent).
2005  * Cached data as part of the source object can be optionally produced to be
2006  * consumed later to speed up compilation of identical source scripts.
2007  *
2008  * Note that when producing cached data, the source must point to NULL for
2009  * cached data. When consuming cached data, the cached data must have been
2010  * produced by the same version of V8.
2011  *
2012  * \param source Script source code.
2013  * \return Compiled script object (context independent; for running it must be
2014  * bound to a context).
2015  */
2017  Isolate* isolate, Source* source,
2019  NoCacheReason no_cache_reason = kNoCacheNoReason);
2020 
2021  /**
2022  * Compiles the specified script (bound to current context).
2023  *
2024  * \param source Script source code.
2025  * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile()
2026  * using pre_data speeds compilation if it's done multiple times.
2027  * Owned by caller, no references are kept when this function returns.
2028  * \return Compiled script object, bound to the context that was active
2029  * when this function was called. When run it will always use this
2030  * context.
2031  */
2033  Local<Context> context, Source* source,
2035  NoCacheReason no_cache_reason = kNoCacheNoReason);
2036 
2037  /**
2038  * Returns a task which streams script data into V8, or NULL if the script
2039  * cannot be streamed. The user is responsible for running the task on a
2040  * background thread and deleting it. When ran, the task starts parsing the
2041  * script, and it will request data from the StreamedSource as needed. When
2042  * ScriptStreamingTask::Run exits, all data has been streamed and the script
2043  * can be compiled (see Compile below).
2044  *
2045  * This API allows to start the streaming with as little data as possible, and
2046  * the remaining data (for example, the ScriptOrigin) is passed to Compile.
2047  */
2048  V8_DEPRECATED("Use ScriptCompiler::StartStreaming instead.")
2049  static ScriptStreamingTask* StartStreamingScript(
2050  Isolate* isolate, StreamedSource* source,
2051  CompileOptions options = kNoCompileOptions);
2052  static ScriptStreamingTask* StartStreaming(
2053  Isolate* isolate, StreamedSource* source,
2055 
2056  /**
2057  * Compiles a streamed script (bound to current context).
2058  *
2059  * This can only be called after the streaming has finished
2060  * (ScriptStreamingTask has been run). V8 doesn't construct the source string
2061  * during streaming, so the embedder needs to pass the full source here.
2062  */
2064  Local<Context> context, StreamedSource* source,
2065  Local<String> full_source_string, const ScriptOrigin& origin);
2066 
2067  /**
2068  * Return a version tag for CachedData for the current V8 version & flags.
2069  *
2070  * This value is meant only for determining whether a previously generated
2071  * CachedData instance is still valid; the tag has no other meaing.
2072  *
2073  * Background: The data carried by CachedData may depend on the exact
2074  * V8 version number or current compiler flags. This means that when
2075  * persisting CachedData, the embedder must take care to not pass in
2076  * data from another V8 version, or the same version with different
2077  * features enabled.
2078  *
2079  * The easiest way to do so is to clear the embedder's cache on any
2080  * such change.
2081  *
2082  * Alternatively, this tag can be stored alongside the cached data and
2083  * compared when it is being used.
2084  */
2085  static uint32_t CachedDataVersionTag();
2086 
2087  /**
2088  * Compile an ES module, returning a Module that encapsulates
2089  * the compiled code.
2090  *
2091  * Corresponds to the ParseModule abstract operation in the
2092  * ECMAScript specification.
2093  */
2095  Isolate* isolate, Source* source,
2097  NoCacheReason no_cache_reason = kNoCacheNoReason);
2098 
2099  /**
2100  * Compiles a streamed module script.
2101  *
2102  * This can only be called after the streaming has finished
2103  * (ScriptStreamingTask has been run). V8 doesn't construct the source string
2104  * during streaming, so the embedder needs to pass the full source here.
2105  */
2107  Local<Context> context, StreamedSource* v8_source,
2108  Local<String> full_source_string, const ScriptOrigin& origin);
2109 
2110  /**
2111  * Compile a function for a given context. This is equivalent to running
2112  *
2113  * with (obj) {
2114  * return function(args) { ... }
2115  * }
2116  *
2117  * It is possible to specify multiple context extensions (obj in the above
2118  * example).
2119  */
2121  Local<Context> context, Source* source, size_t arguments_count,
2122  Local<String> arguments[], size_t context_extension_count,
2123  Local<Object> context_extensions[],
2125  NoCacheReason no_cache_reason = kNoCacheNoReason,
2126  Local<ScriptOrModule>* script_or_module_out = nullptr);
2127 
2128  /**
2129  * Creates and returns code cache for the specified unbound_script.
2130  * This will return nullptr if the script cannot be serialized. The
2131  * CachedData returned by this function should be owned by the caller.
2132  */
2133  static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script);
2134 
2135  /**
2136  * Creates and returns code cache for the specified unbound_module_script.
2137  * This will return nullptr if the script cannot be serialized. The
2138  * CachedData returned by this function should be owned by the caller.
2139  */
2140  static CachedData* CreateCodeCache(
2141  Local<UnboundModuleScript> unbound_module_script);
2142 
2143  /**
2144  * Creates and returns code cache for the specified function that was
2145  * previously produced by CompileFunctionInContext.
2146  * This will return nullptr if the script cannot be serialized. The
2147  * CachedData returned by this function should be owned by the caller.
2148  */
2150 
2151  private:
2152  static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
2153  Isolate* isolate, Source* source, CompileOptions options,
2154  NoCacheReason no_cache_reason);
2155 };
2156 
2157 
2158 /**
2159  * An error message.
2160  */
2162  public:
2163  Local<String> Get() const;
2164 
2165  /**
2166  * Return the isolate to which the Message belongs.
2167  */
2168  Isolate* GetIsolate() const;
2169 
2171  Local<Context> context) const;
2172 
2173  /**
2174  * Returns the origin for the script from where the function causing the
2175  * error originates.
2176  */
2177  ScriptOrigin GetScriptOrigin() const;
2178 
2179  /**
2180  * Returns the resource name for the script from where the function causing
2181  * the error originates.
2182  */
2184 
2185  /**
2186  * Exception stack trace. By default stack traces are not captured for
2187  * uncaught exceptions. SetCaptureStackTraceForUncaughtExceptions allows
2188  * to change this option.
2189  */
2190  Local<StackTrace> GetStackTrace() const;
2191 
2192  /**
2193  * Returns the number, 1-based, of the line where the error occurred.
2194  */
2195  V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const;
2196 
2197  /**
2198  * Returns the index within the script of the first character where
2199  * the error occurred.
2200  */
2201  int GetStartPosition() const;
2202 
2203  /**
2204  * Returns the index within the script of the last character where
2205  * the error occurred.
2206  */
2207  int GetEndPosition() const;
2208 
2209  /**
2210  * Returns the Wasm function index where the error occurred. Returns -1 if
2211  * message is not from a Wasm script.
2212  */
2213  int GetWasmFunctionIndex() const;
2214 
2215  /**
2216  * Returns the error level of the message.
2217  */
2218  int ErrorLevel() const;
2219 
2220  /**
2221  * Returns the index within the line of the first character where
2222  * the error occurred.
2223  */
2224  int GetStartColumn() const;
2226 
2227  /**
2228  * Returns the index within the line of the last character where
2229  * the error occurred.
2230  */
2231  int GetEndColumn() const;
2232  V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const;
2233 
2234  /**
2235  * Passes on the value set by the embedder when it fed the script from which
2236  * this Message was generated to V8.
2237  */
2238  bool IsSharedCrossOrigin() const;
2239  bool IsOpaque() const;
2240 
2241  // TODO(1245381): Print to a string instead of on a FILE.
2242  static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
2243 
2244  static const int kNoLineNumberInfo = 0;
2245  static const int kNoColumnInfo = 0;
2246  static const int kNoScriptIdInfo = 0;
2247  static const int kNoWasmFunctionIndexInfo = -1;
2248 };
2249 
2250 
2251 /**
2252  * Representation of a JavaScript stack trace. The information collected is a
2253  * snapshot of the execution stack and the information remains valid after
2254  * execution continues.
2255  */
2257  public:
2258  /**
2259  * Flags that determine what information is placed captured for each
2260  * StackFrame when grabbing the current stack trace.
2261  * Note: these options are deprecated and we always collect all available
2262  * information (kDetailed).
2263  */
2267  kScriptName = 1 << 2,
2268  kFunctionName = 1 << 3,
2269  kIsEval = 1 << 4,
2270  kIsConstructor = 1 << 5,
2272  kScriptId = 1 << 7,
2276  };
2277 
2278  /**
2279  * Returns a StackFrame at a particular index.
2280  */
2281  Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
2282 
2283  /**
2284  * Returns the number of StackFrames.
2285  */
2286  int GetFrameCount() const;
2287 
2288  /**
2289  * Grab a snapshot of the current JavaScript execution stack.
2290  *
2291  * \param frame_limit The maximum number of stack frames we want to capture.
2292  * \param options Enumerates the set of things we will capture for each
2293  * StackFrame.
2294  */
2296  Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed);
2297 };
2298 
2299 
2300 /**
2301  * A single JavaScript stack frame.
2302  */
2304  public:
2305  /**
2306  * Returns the number, 1-based, of the line for the associate function call.
2307  * This method will return Message::kNoLineNumberInfo if it is unable to
2308  * retrieve the line number, or if kLineNumber was not passed as an option
2309  * when capturing the StackTrace.
2310  */
2311  int GetLineNumber() const;
2312 
2313  /**
2314  * Returns the 1-based column offset on the line for the associated function
2315  * call.
2316  * This method will return Message::kNoColumnInfo if it is unable to retrieve
2317  * the column number, or if kColumnOffset was not passed as an option when
2318  * capturing the StackTrace.
2319  */
2320  int GetColumn() const;
2321 
2322  /**
2323  * Returns the id of the script for the function for this StackFrame.
2324  * This method will return Message::kNoScriptIdInfo if it is unable to
2325  * retrieve the script id, or if kScriptId was not passed as an option when
2326  * capturing the StackTrace.
2327  */
2328  int GetScriptId() const;
2329 
2330  /**
2331  * Returns the name of the resource that contains the script for the
2332  * function for this StackFrame.
2333  */
2334  Local<String> GetScriptName() const;
2335 
2336  /**
2337  * Returns the name of the resource that contains the script for the
2338  * function for this StackFrame or sourceURL value if the script name
2339  * is undefined and its source ends with //# sourceURL=... string or
2340  * deprecated //@ sourceURL=... string.
2341  */
2343 
2344  /**
2345  * Returns the name of the function associated with this stack frame.
2346  */
2347  Local<String> GetFunctionName() const;
2348 
2349  /**
2350  * Returns whether or not the associated function is compiled via a call to
2351  * eval().
2352  */
2353  bool IsEval() const;
2354 
2355  /**
2356  * Returns whether or not the associated function is called as a
2357  * constructor via "new".
2358  */
2359  bool IsConstructor() const;
2360 
2361  /**
2362  * Returns whether or not the associated functions is defined in wasm.
2363  */
2364  bool IsWasm() const;
2365 
2366  /**
2367  * Returns whether or not the associated function is defined by the user.
2368  */
2369  bool IsUserJavaScript() const;
2370 };
2371 
2372 
2373 // A StateTag represents a possible state of the VM.
2374 enum StateTag {
2384 };
2385 
2386 // Holds the callee saved registers needed for the stack unwinder. It is the
2387 // empty struct if no registers are required. Implemented in
2388 // include/v8-unwinder-state.h.
2389 struct CalleeSavedRegisters;
2390 
2391 // A RegisterState represents the current state of registers used
2392 // by the sampling profiler API.
2394  RegisterState();
2395  ~RegisterState();
2396  RegisterState(const RegisterState& other);
2397  RegisterState& operator=(const RegisterState& other);
2398 
2399  void* pc; // Instruction pointer.
2400  void* sp; // Stack pointer.
2401  void* fp; // Frame pointer.
2402  void* lr; // Link register (or nullptr on platforms without a link register).
2403  // Callee saved registers (or null if no callee saved registers were stored)
2404  std::unique_ptr<CalleeSavedRegisters> callee_saved;
2405 };
2406 
2407 // The output structure filled up by GetStackSample API function.
2408 struct SampleInfo {
2409  size_t frames_count; // Number of frames collected.
2410  StateTag vm_state; // Current VM state.
2411  void* external_callback_entry; // External callback address if VM is
2412  // executing an external callback.
2413  void* top_context; // Incumbent native context address.
2414 };
2415 
2416 struct MemoryRange {
2417  const void* start = nullptr;
2418  size_t length_in_bytes = 0;
2419 };
2420 
2421 struct JSEntryStub {
2423 };
2424 
2429 };
2430 
2431 /**
2432  * A JSON Parser and Stringifier.
2433  */
2435  public:
2436  /**
2437  * Tries to parse the string |json_string| and returns it as value if
2438  * successful.
2439  *
2440  * \param the context in which to parse and create the value.
2441  * \param json_string The string to parse.
2442  * \return The corresponding value if successfully parsed.
2443  */
2445  Local<Context> context, Local<String> json_string);
2446 
2447  /**
2448  * Tries to stringify the JSON-serializable object |json_object| and returns
2449  * it as string if successful.
2450  *
2451  * \param json_object The JSON-serializable object to stringify.
2452  * \return The corresponding string if successfully stringified.
2453  */
2455  Local<Context> context, Local<Value> json_object,
2456  Local<String> gap = Local<String>());
2457 };
2458 
2459 /**
2460  * Value serialization compatible with the HTML structured clone algorithm.
2461  * The format is backward-compatible (i.e. safe to store to disk).
2462  */
2464  public:
2466  public:
2467  virtual ~Delegate() = default;
2468 
2469  /**
2470  * Handles the case where a DataCloneError would be thrown in the structured
2471  * clone spec. Other V8 embedders may throw some other appropriate exception
2472  * type.
2473  */
2474  virtual void ThrowDataCloneError(Local<String> message) = 0;
2475 
2476  /**
2477  * The embedder overrides this method to write some kind of host object, if
2478  * possible. If not, a suitable exception should be thrown and
2479  * Nothing<bool>() returned.
2480  */
2481  virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object);
2482 
2483  /**
2484  * Called when the ValueSerializer is going to serialize a
2485  * SharedArrayBuffer object. The embedder must return an ID for the
2486  * object, using the same ID if this SharedArrayBuffer has already been
2487  * serialized in this buffer. When deserializing, this ID will be passed to
2488  * ValueDeserializer::GetSharedArrayBufferFromId as |clone_id|.
2489  *
2490  * If the object cannot be serialized, an
2491  * exception should be thrown and Nothing<uint32_t>() returned.
2492  */
2493  virtual Maybe<uint32_t> GetSharedArrayBufferId(
2494  Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
2495 
2496  virtual Maybe<uint32_t> GetWasmModuleTransferId(
2497  Isolate* isolate, Local<WasmModuleObject> module);
2498  /**
2499  * Allocates memory for the buffer of at least the size provided. The actual
2500  * size (which may be greater or equal) is written to |actual_size|. If no
2501  * buffer has been allocated yet, nullptr will be provided.
2502  *
2503  * If the memory cannot be allocated, nullptr should be returned.
2504  * |actual_size| will be ignored. It is assumed that |old_buffer| is still
2505  * valid in this case and has not been modified.
2506  *
2507  * The default implementation uses the stdlib's `realloc()` function.
2508  */
2509  virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
2510  size_t* actual_size);
2511 
2512  /**
2513  * Frees a buffer allocated with |ReallocateBufferMemory|.
2514  *
2515  * The default implementation uses the stdlib's `free()` function.
2516  */
2517  virtual void FreeBufferMemory(void* buffer);
2518  };
2519 
2520  explicit ValueSerializer(Isolate* isolate);
2521  ValueSerializer(Isolate* isolate, Delegate* delegate);
2522  ~ValueSerializer();
2523 
2524  /**
2525  * Writes out a header, which includes the format version.
2526  */
2527  void WriteHeader();
2528 
2529  /**
2530  * Serializes a JavaScript value into the buffer.
2531  */
2533  Local<Value> value);
2534 
2535  /**
2536  * Returns the stored data (allocated using the delegate's
2537  * ReallocateBufferMemory) and its size. This serializer should not be used
2538  * once the buffer is released. The contents are undefined if a previous write
2539  * has failed. Ownership of the buffer is transferred to the caller.
2540  */
2541  V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
2542 
2543  /**
2544  * Marks an ArrayBuffer as havings its contents transferred out of band.
2545  * Pass the corresponding ArrayBuffer in the deserializing context to
2546  * ValueDeserializer::TransferArrayBuffer.
2547  */
2548  void TransferArrayBuffer(uint32_t transfer_id,
2549  Local<ArrayBuffer> array_buffer);
2550 
2551 
2552  /**
2553  * Indicate whether to treat ArrayBufferView objects as host objects,
2554  * i.e. pass them to Delegate::WriteHostObject. This should not be
2555  * called when no Delegate was passed.
2556  *
2557  * The default is not to treat ArrayBufferViews as host objects.
2558  */
2559  void SetTreatArrayBufferViewsAsHostObjects(bool mode);
2560 
2561  /**
2562  * Write raw data in various common formats to the buffer.
2563  * Note that integer types are written in base-128 varint format, not with a
2564  * binary copy. For use during an override of Delegate::WriteHostObject.
2565  */
2566  void WriteUint32(uint32_t value);
2567  void WriteUint64(uint64_t value);
2568  void WriteDouble(double value);
2569  void WriteRawBytes(const void* source, size_t length);
2570 
2571  ValueSerializer(const ValueSerializer&) = delete;
2572  void operator=(const ValueSerializer&) = delete;
2573 
2574  private:
2575  struct PrivateData;
2576  PrivateData* private_;
2577 };
2578 
2579 /**
2580  * Deserializes values from data written with ValueSerializer, or a compatible
2581  * implementation.
2582  */
2584  public:
2586  public:
2587  virtual ~Delegate() = default;
2588 
2589  /**
2590  * The embedder overrides this method to read some kind of host object, if
2591  * possible. If not, a suitable exception should be thrown and
2592  * MaybeLocal<Object>() returned.
2593  */
2594  virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);
2595 
2596  /**
2597  * Get a WasmModuleObject given a transfer_id previously provided
2598  * by ValueSerializer::GetWasmModuleTransferId
2599  */
2601  Isolate* isolate, uint32_t transfer_id);
2602 
2603  /**
2604  * Get a SharedArrayBuffer given a clone_id previously provided
2605  * by ValueSerializer::GetSharedArrayBufferId
2606  */
2608  Isolate* isolate, uint32_t clone_id);
2609  };
2610 
2611  ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
2612  ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size,
2613  Delegate* delegate);
2614  ~ValueDeserializer();
2615 
2616  /**
2617  * Reads and validates a header (including the format version).
2618  * May, for example, reject an invalid or unsupported wire format.
2619  */
2621 
2622  /**
2623  * Deserializes a JavaScript value from the buffer.
2624  */
2626 
2627  /**
2628  * Accepts the array buffer corresponding to the one passed previously to
2629  * ValueSerializer::TransferArrayBuffer.
2630  */
2631  void TransferArrayBuffer(uint32_t transfer_id,
2632  Local<ArrayBuffer> array_buffer);
2633 
2634  /**
2635  * Similar to TransferArrayBuffer, but for SharedArrayBuffer.
2636  * The id is not necessarily in the same namespace as unshared ArrayBuffer
2637  * objects.
2638  */
2639  void TransferSharedArrayBuffer(uint32_t id,
2640  Local<SharedArrayBuffer> shared_array_buffer);
2641 
2642  /**
2643  * Must be called before ReadHeader to enable support for reading the legacy
2644  * wire format (i.e., which predates this being shipped).
2645  *
2646  * Don't use this unless you need to read data written by previous versions of
2647  * blink::ScriptValueSerializer.
2648  */
2649  void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
2650 
2651  /**
2652  * Reads the underlying wire format version. Likely mostly to be useful to
2653  * legacy code reading old wire format versions. Must be called after
2654  * ReadHeader.
2655  */
2656  uint32_t GetWireFormatVersion() const;
2657 
2658  /**
2659  * Reads raw data in various common formats to the buffer.
2660  * Note that integer types are read in base-128 varint format, not with a
2661  * binary copy. For use during an override of Delegate::ReadHostObject.
2662  */
2663  V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t* value);
2664  V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t* value);
2665  V8_WARN_UNUSED_RESULT bool ReadDouble(double* value);
2666  V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data);
2667 
2668  ValueDeserializer(const ValueDeserializer&) = delete;
2669  void operator=(const ValueDeserializer&) = delete;
2670 
2671  private:
2672  struct PrivateData;
2673  PrivateData* private_;
2674 };
2675 
2676 
2677 // --- Value ---
2678 
2679 
2680 /**
2681  * The superclass of all JavaScript values and objects.
2682  */
2683 class V8_EXPORT Value : public Data {
2684  public:
2685  /**
2686  * Returns true if this value is the undefined value. See ECMA-262
2687  * 4.3.10.
2688  *
2689  * This is equivalent to `value === undefined` in JS.
2690  */
2691  V8_INLINE bool IsUndefined() const;
2692 
2693  /**
2694  * Returns true if this value is the null value. See ECMA-262
2695  * 4.3.11.
2696  *
2697  * This is equivalent to `value === null` in JS.
2698  */
2699  V8_INLINE bool IsNull() const;
2700 
2701  /**
2702  * Returns true if this value is either the null or the undefined value.
2703  * See ECMA-262
2704  * 4.3.11. and 4.3.12
2705  *
2706  * This is equivalent to `value == null` in JS.
2707  */
2708  V8_INLINE bool IsNullOrUndefined() const;
2709 
2710  /**
2711  * Returns true if this value is true.
2712  *
2713  * This is not the same as `BooleanValue()`. The latter performs a
2714  * conversion to boolean, i.e. the result of `Boolean(value)` in JS, whereas
2715  * this checks `value === true`.
2716  */
2717  bool IsTrue() const;
2718 
2719  /**
2720  * Returns true if this value is false.
2721  *
2722  * This is not the same as `!BooleanValue()`. The latter performs a
2723  * conversion to boolean, i.e. the result of `!Boolean(value)` in JS, whereas
2724  * this checks `value === false`.
2725  */
2726  bool IsFalse() const;
2727 
2728  /**
2729  * Returns true if this value is a symbol or a string.
2730  *
2731  * This is equivalent to
2732  * `typeof value === 'string' || typeof value === 'symbol'` in JS.
2733  */
2734  bool IsName() const;
2735 
2736  /**
2737  * Returns true if this value is an instance of the String type.
2738  * See ECMA-262 8.4.
2739  *
2740  * This is equivalent to `typeof value === 'string'` in JS.
2741  */
2742  V8_INLINE bool IsString() const;
2743 
2744  /**
2745  * Returns true if this value is a symbol.
2746  *
2747  * This is equivalent to `typeof value === 'symbol'` in JS.
2748  */
2749  bool IsSymbol() const;
2750 
2751  /**
2752  * Returns true if this value is a function.
2753  *
2754  * This is equivalent to `typeof value === 'function'` in JS.
2755  */
2756  bool IsFunction() const;
2757 
2758  /**
2759  * Returns true if this value is an array. Note that it will return false for
2760  * an Proxy for an array.
2761  */
2762  bool IsArray() const;
2763 
2764  /**
2765  * Returns true if this value is an object.
2766  */
2767  bool IsObject() const;
2768 
2769  /**
2770  * Returns true if this value is a bigint.
2771  *
2772  * This is equivalent to `typeof value === 'bigint'` in JS.
2773  */
2774  bool IsBigInt() const;
2775 
2776  /**
2777  * Returns true if this value is boolean.
2778  *
2779  * This is equivalent to `typeof value === 'boolean'` in JS.
2780  */
2781  bool IsBoolean() const;
2782 
2783  /**
2784  * Returns true if this value is a number.
2785  *
2786  * This is equivalent to `typeof value === 'number'` in JS.
2787  */
2788  bool IsNumber() const;
2789 
2790  /**
2791  * Returns true if this value is an `External` object.
2792  */
2793  bool IsExternal() const;
2794 
2795  /**
2796  * Returns true if this value is a 32-bit signed integer.
2797  */
2798  bool IsInt32() const;
2799 
2800  /**
2801  * Returns true if this value is a 32-bit unsigned integer.
2802  */
2803  bool IsUint32() const;
2804 
2805  /**
2806  * Returns true if this value is a Date.
2807  */
2808  bool IsDate() const;
2809 
2810  /**
2811  * Returns true if this value is an Arguments object.
2812  */
2813  bool IsArgumentsObject() const;
2814 
2815  /**
2816  * Returns true if this value is a BigInt object.
2817  */
2818  bool IsBigIntObject() const;
2819 
2820  /**
2821  * Returns true if this value is a Boolean object.
2822  */
2823  bool IsBooleanObject() const;
2824 
2825  /**
2826  * Returns true if this value is a Number object.
2827  */
2828  bool IsNumberObject() const;
2829 
2830  /**
2831  * Returns true if this value is a String object.
2832  */
2833  bool IsStringObject() const;
2834 
2835  /**
2836  * Returns true if this value is a Symbol object.
2837  */
2838  bool IsSymbolObject() const;
2839 
2840  /**
2841  * Returns true if this value is a NativeError.
2842  */
2843  bool IsNativeError() const;
2844 
2845  /**
2846  * Returns true if this value is a RegExp.
2847  */
2848  bool IsRegExp() const;
2849 
2850  /**
2851  * Returns true if this value is an async function.
2852  */
2853  bool IsAsyncFunction() const;
2854 
2855  /**
2856  * Returns true if this value is a Generator function.
2857  */
2858  bool IsGeneratorFunction() const;
2859 
2860  /**
2861  * Returns true if this value is a Generator object (iterator).
2862  */
2863  bool IsGeneratorObject() const;
2864 
2865  /**
2866  * Returns true if this value is a Promise.
2867  */
2868  bool IsPromise() const;
2869 
2870  /**
2871  * Returns true if this value is a Map.
2872  */
2873  bool IsMap() const;
2874 
2875  /**
2876  * Returns true if this value is a Set.
2877  */
2878  bool IsSet() const;
2879 
2880  /**
2881  * Returns true if this value is a Map Iterator.
2882  */
2883  bool IsMapIterator() const;
2884 
2885  /**
2886  * Returns true if this value is a Set Iterator.
2887  */
2888  bool IsSetIterator() const;
2889 
2890  /**
2891  * Returns true if this value is a WeakMap.
2892  */
2893  bool IsWeakMap() const;
2894 
2895  /**
2896  * Returns true if this value is a WeakSet.
2897  */
2898  bool IsWeakSet() const;
2899 
2900  /**
2901  * Returns true if this value is an ArrayBuffer.
2902  */
2903  bool IsArrayBuffer() const;
2904 
2905  /**
2906  * Returns true if this value is an ArrayBufferView.
2907  */
2908  bool IsArrayBufferView() const;
2909 
2910  /**
2911  * Returns true if this value is one of TypedArrays.
2912  */
2913  bool IsTypedArray() const;
2914 
2915  /**
2916  * Returns true if this value is an Uint8Array.
2917  */
2918  bool IsUint8Array() const;
2919 
2920  /**
2921  * Returns true if this value is an Uint8ClampedArray.
2922  */
2923  bool IsUint8ClampedArray() const;
2924 
2925  /**
2926  * Returns true if this value is an Int8Array.
2927  */
2928  bool IsInt8Array() const;
2929 
2930  /**
2931  * Returns true if this value is an Uint16Array.
2932  */
2933  bool IsUint16Array() const;
2934 
2935  /**
2936  * Returns true if this value is an Int16Array.
2937  */
2938  bool IsInt16Array() const;
2939 
2940  /**
2941  * Returns true if this value is an Uint32Array.
2942  */
2943  bool IsUint32Array() const;
2944 
2945  /**
2946  * Returns true if this value is an Int32Array.
2947  */
2948  bool IsInt32Array() const;
2949 
2950  /**
2951  * Returns true if this value is a Float32Array.
2952  */
2953  bool IsFloat32Array() const;
2954 
2955  /**
2956  * Returns true if this value is a Float64Array.
2957  */
2958  bool IsFloat64Array() const;
2959 
2960  /**
2961  * Returns true if this value is a BigInt64Array.
2962  */
2963  bool IsBigInt64Array() const;
2964 
2965  /**
2966  * Returns true if this value is a BigUint64Array.
2967  */
2968  bool IsBigUint64Array() const;
2969 
2970  /**
2971  * Returns true if this value is a DataView.
2972  */
2973  bool IsDataView() const;
2974 
2975  /**
2976  * Returns true if this value is a SharedArrayBuffer.
2977  */
2978  bool IsSharedArrayBuffer() const;
2979 
2980  /**
2981  * Returns true if this value is a JavaScript Proxy.
2982  */
2983  bool IsProxy() const;
2984 
2985  /**
2986  * Returns true if this value is a WasmMemoryObject.
2987  */
2988  bool IsWasmMemoryObject() const;
2989 
2990  /**
2991  * Returns true if this value is a WasmModuleObject.
2992  */
2993  bool IsWasmModuleObject() const;
2994 
2995  /**
2996  * Returns true if the value is a Module Namespace Object.
2997  */
2998  bool IsModuleNamespaceObject() const;
2999 
3000  /**
3001  * Perform the equivalent of `BigInt(value)` in JS.
3002  */
3004  Local<Context> context) const;
3005  /**
3006  * Perform the equivalent of `Number(value)` in JS.
3007  */
3009  Local<Context> context) const;
3010  /**
3011  * Perform the equivalent of `String(value)` in JS.
3012  */
3014  Local<Context> context) const;
3015  /**
3016  * Provide a string representation of this value usable for debugging.
3017  * This operation has no observable side effects and will succeed
3018  * unless e.g. execution is being terminated.
3019  */
3021  Local<Context> context) const;
3022  /**
3023  * Perform the equivalent of `Object(value)` in JS.
3024  */
3026  Local<Context> context) const;
3027  /**
3028  * Perform the equivalent of `Number(value)` in JS and convert the result
3029  * to an integer. Negative values are rounded up, positive values are rounded
3030  * down. NaN is converted to 0. Infinite values yield undefined results.
3031  */
3033  Local<Context> context) const;
3034  /**
3035  * Perform the equivalent of `Number(value)` in JS and convert the result
3036  * to an unsigned 32-bit integer by performing the steps in
3037  * https://tc39.es/ecma262/#sec-touint32.
3038  */
3040  Local<Context> context) const;
3041  /**
3042  * Perform the equivalent of `Number(value)` in JS and convert the result
3043  * to a signed 32-bit integer by performing the steps in
3044  * https://tc39.es/ecma262/#sec-toint32.
3045  */
3047 
3048  /**
3049  * Perform the equivalent of `Boolean(value)` in JS. This can never fail.
3050  */
3051  Local<Boolean> ToBoolean(Isolate* isolate) const;
3052 
3053  /**
3054  * Attempts to convert a string to an array index.
3055  * Returns an empty handle if the conversion fails.
3056  */
3058  Local<Context> context) const;
3059 
3060  /** Returns the equivalent of `ToBoolean()->Value()`. */
3061  bool BooleanValue(Isolate* isolate) const;
3062 
3063  /** Returns the equivalent of `ToNumber()->Value()`. */
3064  V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const;
3065  /** Returns the equivalent of `ToInteger()->Value()`. */
3067  Local<Context> context) const;
3068  /** Returns the equivalent of `ToUint32()->Value()`. */
3070  Local<Context> context) const;
3071  /** Returns the equivalent of `ToInt32()->Value()`. */
3072  V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const;
3073 
3074  /** JS == */
3076  Local<Value> that) const;
3077  bool StrictEquals(Local<Value> that) const;
3078  bool SameValue(Local<Value> that) const;
3079 
3080  template <class T> V8_INLINE static Value* Cast(T* value);
3081 
3083 
3084  Maybe<bool> InstanceOf(Local<Context> context, Local<Object> object);
3085 
3086  private:
3087  V8_INLINE bool QuickIsUndefined() const;
3088  V8_INLINE bool QuickIsNull() const;
3089  V8_INLINE bool QuickIsNullOrUndefined() const;
3090  V8_INLINE bool QuickIsString() const;
3091  bool FullIsUndefined() const;
3092  bool FullIsNull() const;
3093  bool FullIsString() const;
3094 
3095  static void CheckCast(Data* that);
3096 };
3097 
3098 
3099 /**
3100  * The superclass of primitive values. See ECMA-262 4.3.2.
3101  */
3102 class V8_EXPORT Primitive : public Value { };
3103 
3104 
3105 /**
3106  * A primitive boolean value (ECMA-262, 4.3.14). Either the true
3107  * or false value.
3108  */
3109 class V8_EXPORT Boolean : public Primitive {
3110  public:
3111  bool Value() const;
3112  V8_INLINE static Boolean* Cast(v8::Data* data);
3113  V8_INLINE static Local<Boolean> New(Isolate* isolate, bool value);
3114 
3115  private:
3116  static void CheckCast(v8::Data* that);
3117 };
3118 
3119 
3120 /**
3121  * A superclass for symbols and strings.
3122  */
3123 class V8_EXPORT Name : public Primitive {
3124  public:
3125  /**
3126  * Returns the identity hash for this object. The current implementation
3127  * uses an inline property on the object to store the identity hash.
3128  *
3129  * The return value will never be 0. Also, it is not guaranteed to be
3130  * unique.
3131  */
3132  int GetIdentityHash();
3133 
3134  V8_INLINE static Name* Cast(Data* data);
3135 
3136  private:
3137  static void CheckCast(Data* that);
3138 };
3139 
3140 /**
3141  * A flag describing different modes of string creation.
3142  *
3143  * Aside from performance implications there are no differences between the two
3144  * creation modes.
3145  */
3146 enum class NewStringType {
3147  /**
3148  * Create a new string, always allocating new storage memory.
3149  */
3150  kNormal,
3151 
3152  /**
3153  * Acts as a hint that the string should be created in the
3154  * old generation heap space and be deduplicated if an identical string
3155  * already exists.
3156  */
3158 };
3159 
3160 /**
3161  * A JavaScript string value (ECMA-262, 4.3.17).
3162  */
3163 class V8_EXPORT String : public Name {
3164  public:
3165  static constexpr int kMaxLength =
3166  internal::kApiSystemPointerSize == 4 ? (1 << 28) - 16 : (1 << 29) - 24;
3167 
3168  enum Encoding {
3172  };
3173  /**
3174  * Returns the number of characters (UTF-16 code units) in this string.
3175  */
3176  int Length() const;
3177 
3178  /**
3179  * Returns the number of bytes in the UTF-8 encoded
3180  * representation of this string.
3181  */
3182  int Utf8Length(Isolate* isolate) const;
3183 
3184  /**
3185  * Returns whether this string is known to contain only one byte data,
3186  * i.e. ISO-8859-1 code points.
3187  * Does not read the string.
3188  * False negatives are possible.
3189  */
3190  bool IsOneByte() const;
3191 
3192  /**
3193  * Returns whether this string contain only one byte data,
3194  * i.e. ISO-8859-1 code points.
3195  * Will read the entire string in some cases.
3196  */
3197  bool ContainsOnlyOneByte() const;
3198 
3199  /**
3200  * Write the contents of the string to an external buffer.
3201  * If no arguments are given, expects the buffer to be large
3202  * enough to hold the entire string and NULL terminator. Copies
3203  * the contents of the string and the NULL terminator into the
3204  * buffer.
3205  *
3206  * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop
3207  * before the end of the buffer.
3208  *
3209  * Copies up to length characters into the output buffer.
3210  * Only null-terminates if there is enough space in the buffer.
3211  *
3212  * \param buffer The buffer into which the string will be copied.
3213  * \param start The starting position within the string at which
3214  * copying begins.
3215  * \param length The number of characters to copy from the string. For
3216  * WriteUtf8 the number of bytes in the buffer.
3217  * \param nchars_ref The number of characters written, can be NULL.
3218  * \param options Various options that might affect performance of this or
3219  * subsequent operations.
3220  * \return The number of characters copied to the buffer excluding the null
3221  * terminator. For WriteUtf8: The number of bytes copied to the buffer
3222  * including the null terminator (if written).
3223  */
3229  // Used by WriteUtf8 to replace orphan surrogate code units with the
3230  // unicode replacement character. Needs to be set to guarantee valid UTF-8
3231  // output.
3233  };
3234 
3235  // 16-bit character codes.
3236  int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
3237  int options = NO_OPTIONS) const;
3238  // One byte characters.
3239  int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
3240  int length = -1, int options = NO_OPTIONS) const;
3241  // UTF-8 encoded characters.
3242  int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
3243  int* nchars_ref = nullptr, int options = NO_OPTIONS) const;
3244 
3245  /**
3246  * A zero length string.
3247  */
3248  V8_INLINE static Local<String> Empty(Isolate* isolate);
3249 
3250  /**
3251  * Returns true if the string is both external and two-byte.
3252  */
3253  bool IsExternalTwoByte() const;
3254 
3255  /**
3256  * Returns true if the string is both external and one-byte.
3257  */
3258  bool IsExternalOneByte() const;
3259 
3261  public:
3262  virtual ~ExternalStringResourceBase() = default;
3263 
3264  /**
3265  * If a string is cacheable, the value returned by
3266  * ExternalStringResource::data() may be cached, otherwise it is not
3267  * expected to be stable beyond the current top-level task.
3268  */
3269  virtual bool IsCacheable() const { return true; }
3270 
3271  // Disallow copying and assigning.
3273  void operator=(const ExternalStringResourceBase&) = delete;
3274 
3275  protected:
3276  ExternalStringResourceBase() = default;
3277 
3278  /**
3279  * Internally V8 will call this Dispose method when the external string
3280  * resource is no longer needed. The default implementation will use the
3281  * delete operator. This method can be overridden in subclasses to
3282  * control how allocated external string resources are disposed.
3283  */
3284  virtual void Dispose() { delete this; }
3285 
3286  /**
3287  * For a non-cacheable string, the value returned by
3288  * |ExternalStringResource::data()| has to be stable between |Lock()| and
3289  * |Unlock()|, that is the string must behave as is |IsCacheable()| returned
3290  * true.
3291  *
3292  * These two functions must be thread-safe, and can be called from anywhere.
3293  * They also must handle lock depth, in the sense that each can be called
3294  * several times, from different threads, and unlocking should only happen
3295  * when the balance of Lock() and Unlock() calls is 0.
3296  */
3297  virtual void Lock() const {}
3298 
3299  /**
3300  * Unlocks the string.
3301  */
3302  virtual void Unlock() const {}
3303 
3304  private:
3305  friend class internal::ExternalString;
3306  friend class v8::String;
3307  friend class internal::ScopedExternalStringLock;
3308  };
3309 
3310  /**
3311  * An ExternalStringResource is a wrapper around a two-byte string
3312  * buffer that resides outside V8's heap. Implement an
3313  * ExternalStringResource to manage the life cycle of the underlying
3314  * buffer. Note that the string data must be immutable.
3315  */
3317  : public ExternalStringResourceBase {
3318  public:
3319  /**
3320  * Override the destructor to manage the life cycle of the underlying
3321  * buffer.
3322  */
3323  ~ExternalStringResource() override = default;
3324 
3325  /**
3326  * The string data from the underlying buffer. If the resource is cacheable
3327  * then data() must return the same value for all invocations.
3328  */
3329  virtual const uint16_t* data() const = 0;
3330 
3331  /**
3332  * The length of the string. That is, the number of two-byte characters.
3333  */
3334  virtual size_t length() const = 0;
3335 
3336  /**
3337  * Returns the cached data from the underlying buffer. This method can be
3338  * called only for cacheable resources (i.e. IsCacheable() == true) and only
3339  * after UpdateDataCache() was called.
3340  */
3341  const uint16_t* cached_data() const {
3342  CheckCachedDataInvariants();
3343  return cached_data_;
3344  }
3345 
3346  /**
3347  * Update {cached_data_} with the data from the underlying buffer. This can
3348  * be called only for cacheable resources.
3349  */
3350  void UpdateDataCache();
3351 
3352  protected:
3353  ExternalStringResource() = default;
3354 
3355  private:
3356  void CheckCachedDataInvariants() const;
3357 
3358  const uint16_t* cached_data_ = nullptr;
3359  };
3360 
3361  /**
3362  * An ExternalOneByteStringResource is a wrapper around an one-byte
3363  * string buffer that resides outside V8's heap. Implement an
3364  * ExternalOneByteStringResource to manage the life cycle of the
3365  * underlying buffer. Note that the string data must be immutable
3366  * and that the data must be Latin-1 and not UTF-8, which would require
3367  * special treatment internally in the engine and do not allow efficient
3368  * indexing. Use String::New or convert to 16 bit data for non-Latin1.
3369  */
3370 
3372  : public ExternalStringResourceBase {
3373  public:
3374  /**
3375  * Override the destructor to manage the life cycle of the underlying
3376  * buffer.
3377  */
3378  ~ExternalOneByteStringResource() override = default;
3379 
3380  /**
3381  * The string data from the underlying buffer. If the resource is cacheable
3382  * then data() must return the same value for all invocations.
3383  */
3384  virtual const char* data() const = 0;
3385 
3386  /** The number of Latin-1 characters in the string.*/
3387  virtual size_t length() const = 0;
3388 
3389  /**
3390  * Returns the cached data from the underlying buffer. If the resource is
3391  * uncacheable or if UpdateDataCache() was not called before, it has
3392  * undefined behaviour.
3393  */
3394  const char* cached_data() const {
3395  CheckCachedDataInvariants();
3396  return cached_data_;
3397  }
3398 
3399  /**
3400  * Update {cached_data_} with the data from the underlying buffer. This can
3401  * be called only for cacheable resources.
3402  */
3403  void UpdateDataCache();
3404 
3405  protected:
3406  ExternalOneByteStringResource() = default;
3407 
3408  private:
3409  void CheckCachedDataInvariants() const;
3410 
3411  const char* cached_data_ = nullptr;
3412  };
3413 
3414  /**
3415  * If the string is an external string, return the ExternalStringResourceBase
3416  * regardless of the encoding, otherwise return NULL. The encoding of the
3417  * string is returned in encoding_out.
3418  */
3420  Encoding* encoding_out) const;
3421 
3422  /**
3423  * Get the ExternalStringResource for an external string. Returns
3424  * NULL if IsExternal() doesn't return true.
3425  */
3427 
3428  /**
3429  * Get the ExternalOneByteStringResource for an external one-byte string.
3430  * Returns NULL if IsExternalOneByte() doesn't return true.
3431  */
3433 
3434  V8_INLINE static String* Cast(v8::Data* data);
3435 
3436  /**
3437  * Allocates a new string from a UTF-8 literal. This is equivalent to calling
3438  * String::NewFromUtf(isolate, "...").ToLocalChecked(), but without the check
3439  * overhead.
3440  *
3441  * When called on a string literal containing '\0', the inferred length is the
3442  * length of the input array minus 1 (for the final '\0') and not the value
3443  * returned by strlen.
3444  **/
3445  template <int N>
3447  Isolate* isolate, const char (&literal)[N],
3449  static_assert(N <= kMaxLength, "String is too long");
3450  return NewFromUtf8Literal(isolate, literal, type, N - 1);
3451  }
3452 
3453  /** Allocates a new string from UTF-8 data. Only returns an empty value when
3454  * length > kMaxLength. **/
3456  Isolate* isolate, const char* data,
3457  NewStringType type = NewStringType::kNormal, int length = -1);
3458 
3459  /** Allocates a new string from Latin-1 data. Only returns an empty value
3460  * when length > kMaxLength. **/
3462  Isolate* isolate, const uint8_t* data,
3463  NewStringType type = NewStringType::kNormal, int length = -1);
3464 
3465  /** Allocates a new string from UTF-16 data. Only returns an empty value when
3466  * length > kMaxLength. **/
3468  Isolate* isolate, const uint16_t* data,
3469  NewStringType type = NewStringType::kNormal, int length = -1);
3470 
3471  /**
3472  * Creates a new string by concatenating the left and the right strings
3473  * passed in as parameters.
3474  */
3475  static Local<String> Concat(Isolate* isolate, Local<String> left,
3476  Local<String> right);
3477 
3478  /**
3479  * Creates a new external string using the data defined in the given
3480  * resource. When the external string is no longer live on V8's heap the
3481  * resource will be disposed by calling its Dispose method. The caller of
3482  * this function should not otherwise delete or modify the resource. Neither
3483  * should the underlying buffer be deallocated or modified except through the
3484  * destructor of the external string resource.
3485  */
3487  Isolate* isolate, ExternalStringResource* resource);
3488 
3489  /**
3490  * Associate an external string resource with this string by transforming it
3491  * in place so that existing references to this string in the JavaScript heap
3492  * will use the external string resource. The external string resource's
3493  * character contents need to be equivalent to this string.
3494  * Returns true if the string has been changed to be an external string.
3495  * The string is not modified if the operation fails. See NewExternal for
3496  * information on the lifetime of the resource.
3497  */
3498  bool MakeExternal(ExternalStringResource* resource);
3499 
3500  /**
3501  * Creates a new external string using the one-byte data defined in the given
3502  * resource. When the external string is no longer live on V8's heap the
3503  * resource will be disposed by calling its Dispose method. The caller of
3504  * this function should not otherwise delete or modify the resource. Neither
3505  * should the underlying buffer be deallocated or modified except through the
3506  * destructor of the external string resource.
3507  */
3509  Isolate* isolate, ExternalOneByteStringResource* resource);
3510 
3511  /**
3512  * Associate an external string resource with this string by transforming it
3513  * in place so that existing references to this string in the JavaScript heap
3514  * will use the external string resource. The external string resource's
3515  * character contents need to be equivalent to this string.
3516  * Returns true if the string has been changed to be an external string.
3517  * The string is not modified if the operation fails. See NewExternal for
3518  * information on the lifetime of the resource.
3519  */
3521 
3522  /**
3523  * Returns true if this string can be made external.
3524  */
3525  bool CanMakeExternal();
3526 
3527  /**
3528  * Returns true if the strings values are equal. Same as JS ==/===.
3529  */
3530  bool StringEquals(Local<String> str);
3531 
3532  /**
3533  * Converts an object to a UTF-8-encoded character array. Useful if
3534  * you want to print the object. If conversion to a string fails
3535  * (e.g. due to an exception in the toString() method of the object)
3536  * then the length() method returns 0 and the * operator returns
3537  * NULL.
3538  */
3540  public:
3541  Utf8Value(Isolate* isolate, Local<v8::Value> obj);
3542  ~Utf8Value();
3543  char* operator*() { return str_; }
3544  const char* operator*() const { return str_; }
3545  int length() const { return length_; }
3546 
3547  // Disallow copying and assigning.
3548  Utf8Value(const Utf8Value&) = delete;
3549  void operator=(const Utf8Value&) = delete;
3550 
3551  private:
3552  char* str_;
3553  int length_;
3554  };
3555 
3556  /**
3557  * Converts an object to a two-byte (UTF-16-encoded) string.
3558  * If conversion to a string fails (eg. due to an exception in the toString()
3559  * method of the object) then the length() method returns 0 and the * operator
3560  * returns NULL.
3561  */
3563  public:
3564  Value(Isolate* isolate, Local<v8::Value> obj);
3565  ~Value();
3566  uint16_t* operator*() { return str_; }
3567  const uint16_t* operator*() const { return str_; }
3568  int length() const { return length_; }
3569 
3570  // Disallow copying and assigning.
3571  Value(const Value&) = delete;
3572  void operator=(const Value&) = delete;
3573 
3574  private:
3575  uint16_t* str_;
3576  int length_;
3577  };
3578 
3579  private:
3580  void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
3581  Encoding encoding) const;
3582  void VerifyExternalStringResource(ExternalStringResource* val) const;
3583  ExternalStringResource* GetExternalStringResourceSlow() const;
3584  ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
3585  String::Encoding* encoding_out) const;
3586 
3587  static Local<v8::String> NewFromUtf8Literal(Isolate* isolate,
3588  const char* literal,
3589  NewStringType type, int length);
3590 
3591  static void CheckCast(v8::Data* that);
3592 };
3593 
3594 // Zero-length string specialization (templated string size includes
3595 // terminator).
3596 template <>
3598  Isolate* isolate, const char (&literal)[1], NewStringType type) {
3599  return String::Empty(isolate);
3600 }
3601 
3602 /**
3603  * A JavaScript symbol (ECMA-262 edition 6)
3604  */
3605 class V8_EXPORT Symbol : public Name {
3606  public:
3607  /**
3608  * Returns the description string of the symbol, or undefined if none.
3609  */
3610  Local<Value> Description() const;
3611 
3612  V8_DEPRECATED("Use Symbol::Description()")
3613  Local<Value> Name() const { return Description(); }
3614 
3615  /**
3616  * Create a symbol. If description is not empty, it will be used as the
3617  * description.
3618  */
3619  static Local<Symbol> New(Isolate* isolate,
3620  Local<String> description = Local<String>());
3621 
3622  /**
3623  * Access global symbol registry.
3624  * Note that symbols created this way are never collected, so
3625  * they should only be used for statically fixed properties.
3626  * Also, there is only one global name space for the descriptions used as
3627  * keys.
3628  * To minimize the potential for clashes, use qualified names as keys.
3629  */
3630  static Local<Symbol> For(Isolate* isolate, Local<String> description);
3631 
3632  /**
3633  * Retrieve a global symbol. Similar to |For|, but using a separate
3634  * registry that is not accessible by (and cannot clash with) JavaScript code.
3635  */
3636  static Local<Symbol> ForApi(Isolate* isolate, Local<String> description);
3637 
3638  // Well-known symbols
3639  static Local<Symbol> GetAsyncIterator(Isolate* isolate);
3640  static Local<Symbol> GetHasInstance(Isolate* isolate);
3641  static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
3642  static Local<Symbol> GetIterator(Isolate* isolate);
3643  static Local<Symbol> GetMatch(Isolate* isolate);
3644  static Local<Symbol> GetReplace(Isolate* isolate);
3645  static Local<Symbol> GetSearch(Isolate* isolate);
3646  static Local<Symbol> GetSplit(Isolate* isolate);
3647  static Local<Symbol> GetToPrimitive(Isolate* isolate);
3648  static Local<Symbol> GetToStringTag(Isolate* isolate);
3649  static Local<Symbol> GetUnscopables(Isolate* isolate);
3650 
3651  V8_INLINE static Symbol* Cast(Data* data);
3652 
3653  private:
3654  Symbol();
3655  static void CheckCast(Data* that);
3656 };
3657 
3658 
3659 /**
3660  * A private symbol
3661  *
3662  * This is an experimental feature. Use at your own risk.
3663  */
3664 class V8_EXPORT Private : public Data {
3665  public:
3666  /**
3667  * Returns the print name string of the private symbol, or undefined if none.
3668  */
3669  Local<Value> Name() const;
3670 
3671  /**
3672  * Create a private symbol. If name is not empty, it will be the description.
3673  */
3674  static Local<Private> New(Isolate* isolate,
3675  Local<String> name = Local<String>());
3676 
3677  /**
3678  * Retrieve a global private symbol. If a symbol with this name has not
3679  * been retrieved in the same isolate before, it is created.
3680  * Note that private symbols created this way are never collected, so
3681  * they should only be used for statically fixed properties.
3682  * Also, there is only one global name space for the names used as keys.
3683  * To minimize the potential for clashes, use qualified names as keys,
3684  * e.g., "Class#property".
3685  */
3686  static Local<Private> ForApi(Isolate* isolate, Local<String> name);
3687 
3688  V8_INLINE static Private* Cast(Data* data);
3689 
3690  private:
3691  Private();
3692 
3693  static void CheckCast(Data* that);
3694 };
3695 
3696 
3697 /**
3698  * A JavaScript number value (ECMA-262, 4.3.20)
3699  */
3700 class V8_EXPORT Number : public Primitive {
3701  public:
3702  double Value() const;
3703  static Local<Number> New(Isolate* isolate, double value);
3704  V8_INLINE static Number* Cast(v8::Data* data);
3705 
3706  private:
3707  Number();
3708  static void CheckCast(v8::Data* that);
3709 };
3710 
3711 
3712 /**
3713  * A JavaScript value representing a signed integer.
3714  */
3715 class V8_EXPORT Integer : public Number {
3716  public:
3717  static Local<Integer> New(Isolate* isolate, int32_t value);
3718  static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
3719  int64_t Value() const;
3720  V8_INLINE static Integer* Cast(v8::Data* data);
3721 
3722  private:
3723  Integer();
3724  static void CheckCast(v8::Data* that);
3725 };
3726 
3727 
3728 /**
3729  * A JavaScript value representing a 32-bit signed integer.
3730  */
3731 class V8_EXPORT Int32 : public Integer {
3732  public:
3733  int32_t Value() const;
3734  V8_INLINE static Int32* Cast(v8::Data* data);
3735 
3736  private:
3737  Int32();
3738  static void CheckCast(v8::Data* that);
3739 };
3740 
3741 
3742 /**
3743  * A JavaScript value representing a 32-bit unsigned integer.
3744  */
3745 class V8_EXPORT Uint32 : public Integer {
3746  public:
3747  uint32_t Value() const;
3748  V8_INLINE static Uint32* Cast(v8::Data* data);
3749 
3750  private:
3751  Uint32();
3752  static void CheckCast(v8::Data* that);
3753 };
3754 
3755 /**
3756  * A JavaScript BigInt value (https://tc39.github.io/proposal-bigint)
3757  */
3758 class V8_EXPORT BigInt : public Primitive {
3759  public:
3760  static Local<BigInt> New(Isolate* isolate, int64_t value);
3761  static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
3762  /**
3763  * Creates a new BigInt object using a specified sign bit and a
3764  * specified list of digits/words.
3765  * The resulting number is calculated as:
3766  *
3767  * (-1)^sign_bit * (words[0] * (2^64)^0 + words[1] * (2^64)^1 + ...)
3768  */
3769  static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
3770  int word_count, const uint64_t* words);
3771 
3772  /**
3773  * Returns the value of this BigInt as an unsigned 64-bit integer.
3774  * If `lossless` is provided, it will reflect whether the return value was
3775  * truncated or wrapped around. In particular, it is set to `false` if this
3776  * BigInt is negative.
3777  */
3778  uint64_t Uint64Value(bool* lossless = nullptr) const;
3779 
3780  /**
3781  * Returns the value of this BigInt as a signed 64-bit integer.
3782  * If `lossless` is provided, it will reflect whether this BigInt was
3783  * truncated or not.
3784  */
3785  int64_t Int64Value(bool* lossless = nullptr) const;
3786 
3787  /**
3788  * Returns the number of 64-bit words needed to store the result of
3789  * ToWordsArray().
3790  */
3791  int WordCount() const;
3792 
3793  /**
3794  * Writes the contents of this BigInt to a specified memory location.
3795  * `sign_bit` must be provided and will be set to 1 if this BigInt is
3796  * negative.
3797  * `*word_count` has to be initialized to the length of the `words` array.
3798  * Upon return, it will be set to the actual number of words that would
3799  * be needed to store this BigInt (i.e. the return value of `WordCount()`).
3800  */
3801  void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
3802 
3803  V8_INLINE static BigInt* Cast(v8::Data* data);
3804 
3805  private:
3806  BigInt();
3807  static void CheckCast(v8::Data* that);
3808 };
3809 
3810 /**
3811  * PropertyAttribute.
3812  */
3814  /** None. **/
3815  None = 0,
3816  /** ReadOnly, i.e., not writable. **/
3817  ReadOnly = 1 << 0,
3818  /** DontEnum, i.e., not enumerable. **/
3819  DontEnum = 1 << 1,
3820  /** DontDelete, i.e., not configurable. **/
3821  DontDelete = 1 << 2
3822 };
3823 
3824 /**
3825  * Accessor[Getter|Setter] are used as callback functions when
3826  * setting|getting a particular property. See Object and ObjectTemplate's
3827  * method SetAccessor.
3828  */
3829 using AccessorGetterCallback =
3830  void (*)(Local<String> property, const PropertyCallbackInfo<Value>& info);
3831 using AccessorNameGetterCallback =
3832  void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
3833 
3834 using AccessorSetterCallback = void (*)(Local<String> property,
3835  Local<Value> value,
3836  const PropertyCallbackInfo<void>& info);
3837 using AccessorNameSetterCallback =
3838  void (*)(Local<Name> property, Local<Value> value,
3839  const PropertyCallbackInfo<void>& info);
3840 
3841 /**
3842  * Access control specifications.
3843  *
3844  * Some accessors should be accessible across contexts. These
3845  * accessors have an explicit access control parameter which specifies
3846  * the kind of cross-context access that should be allowed.
3847  *
3848  * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused.
3849  */
3851  DEFAULT = 0,
3853  ALL_CAN_WRITE = 1 << 1,
3855 };
3856 
3857 /**
3858  * Property filter bits. They can be or'ed to build a composite filter.
3859  */
3867 };
3868 
3869 /**
3870  * Options for marking whether callbacks may trigger JS-observable side effects.
3871  * Side-effect-free callbacks are allowlisted during debug evaluation with
3872  * throwOnSideEffect. It applies when calling a Function, FunctionTemplate,
3873  * or an Accessor callback. For Interceptors, please see
3874  * PropertyHandlerFlags's kHasNoSideEffect.
3875  * Callbacks that only cause side effects to the receiver are allowlisted if
3876  * invoked on receiver objects that are created within the same debug-evaluate
3877  * call, as these objects are temporary and the side effect does not escape.
3878  */
3879 enum class SideEffectType {
3883 };
3884 
3885 /**
3886  * Keys/Properties filter enums:
3887  *
3888  * KeyCollectionMode limits the range of collected properties. kOwnOnly limits
3889  * the collected properties to the given Object only. kIncludesPrototypes will
3890  * include all keys of the objects's prototype chain as well.
3891  */
3893 
3894 /**
3895  * kIncludesIndices allows for integer indices to be collected, while
3896  * kSkipIndices will exclude integer indices from being collected.
3897  */
3899 
3900 /**
3901  * kConvertToString will convert integer indices to strings.
3902  * kKeepNumbers will return numbers for integer indices.
3903  */
3905 
3906 /**
3907  * Integrity level for objects.
3908  */
3910 
3911 /**
3912  * A JavaScript object (ECMA-262, 4.3.3)
3913  */
3914 class V8_EXPORT Object : public Value {
3915  public:
3916  /**
3917  * Set only return Just(true) or Empty(), so if it should never fail, use
3918  * result.Check().
3919  */
3920  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
3921  Local<Value> key, Local<Value> value);
3922 
3923  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
3924  Local<Value> value);
3925 
3926  // Implements CreateDataProperty (ECMA-262, 7.3.4).
3927  //
3928  // Defines a configurable, writable, enumerable property with the given value
3929  // on the object unless the property already exists and is not configurable
3930  // or the object is not extensible.
3931  //
3932  // Returns true on success.
3934  Local<Name> key,
3935  Local<Value> value);
3937  uint32_t index,
3938  Local<Value> value);
3939 
3940  // Implements DefineOwnProperty.
3941  //
3942  // In general, CreateDataProperty will be faster, however, does not allow
3943  // for specifying attributes.
3944  //
3945  // Returns true on success.
3947  Local<Context> context, Local<Name> key, Local<Value> value,
3948  PropertyAttribute attributes = None);
3949 
3950  // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4.
3951  //
3952  // The defineProperty function is used to add an own property or
3953  // update the attributes of an existing own property of an object.
3954  //
3955  // Both data and accessor descriptors can be used.
3956  //
3957  // In general, CreateDataProperty is faster, however, does not allow
3958  // for specifying attributes or an accessor descriptor.
3959  //
3960  // The PropertyDescriptor can change when redefining a property.
3961  //
3962  // Returns true on success.
3964  Local<Context> context, Local<Name> key,
3965  PropertyDescriptor& descriptor); // NOLINT(runtime/references)
3966 
3968  Local<Value> key);
3969 
3971  uint32_t index);
3972 
3973  /**
3974  * Gets the property attributes of a property which can be None or
3975  * any combination of ReadOnly, DontEnum and DontDelete. Returns
3976  * None when the property doesn't exist.
3977  */
3979  Local<Context> context, Local<Value> key);
3980 
3981  /**
3982  * Returns Object.getOwnPropertyDescriptor as per ES2016 section 19.1.2.6.
3983  */
3985  Local<Context> context, Local<Name> key);
3986 
3987  /**
3988  * Object::Has() calls the abstract operation HasProperty(O, P) described
3989  * in ECMA-262, 7.3.10. Has() returns
3990  * true, if the object has the property, either own or on the prototype chain.
3991  * Interceptors, i.e., PropertyQueryCallbacks, are called if present.
3992  *
3993  * Has() has the same side effects as JavaScript's `variable in object`.
3994  * For example, calling Has() on a revoked proxy will throw an exception.
3995  *
3996  * \note Has() converts the key to a name, which possibly calls back into
3997  * JavaScript.
3998  *
3999  * See also v8::Object::HasOwnProperty() and
4000  * v8::Object::HasRealNamedProperty().
4001  */
4002  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
4003  Local<Value> key);
4004 
4006  Local<Value> key);
4007 
4008  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, uint32_t index);
4009 
4011  uint32_t index);
4012 
4013  /**
4014  * Note: SideEffectType affects the getter only, not the setter.
4015  */
4017  Local<Context> context, Local<Name> name,
4018  AccessorNameGetterCallback getter,
4019  AccessorNameSetterCallback setter = nullptr,
4021  AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
4022  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
4023  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
4024 
4025  void SetAccessorProperty(Local<Name> name, Local<Function> getter,
4026  Local<Function> setter = Local<Function>(),
4027  PropertyAttribute attribute = None,
4028  AccessControl settings = DEFAULT);
4029 
4030  /**
4031  * Sets a native data property like Template::SetNativeDataProperty, but
4032  * this method sets on this object directly.
4033  */
4035  Local<Context> context, Local<Name> name,
4036  AccessorNameGetterCallback getter,
4037  AccessorNameSetterCallback setter = nullptr,
4038  Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
4039  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
4040  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
4041 
4042  /**
4043  * Attempts to create a property with the given name which behaves like a data
4044  * property, except that the provided getter is invoked (and provided with the
4045  * data value) to supply its value the first time it is read. After the
4046  * property is accessed once, it is replaced with an ordinary data property.
4047  *
4048  * Analogous to Template::SetLazyDataProperty.
4049  */
4051  Local<Context> context, Local<Name> name,
4052  AccessorNameGetterCallback getter, Local<Value> data = Local<Value>(),
4053  PropertyAttribute attributes = None,
4054  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
4055  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
4056 
4057  /**
4058  * Functionality for private properties.
4059  * This is an experimental feature, use at your own risk.
4060  * Note: Private properties are not inherited. Do not rely on this, since it
4061  * may change.
4062  */
4063  Maybe<bool> HasPrivate(Local<Context> context, Local<Private> key);
4064  Maybe<bool> SetPrivate(Local<Context> context, Local<Private> key,
4065  Local<Value> value);
4066  Maybe<bool> DeletePrivate(Local<Context> context, Local<Private> key);
4068 
4069  /**
4070  * Returns an array containing the names of the enumerable properties
4071  * of this object, including properties from prototype objects. The
4072  * array returned by this method contains the same values as would
4073  * be enumerated by a for-in statement over this object.
4074  */
4076  Local<Context> context);
4078  Local<Context> context, KeyCollectionMode mode,
4079  PropertyFilter property_filter, IndexFilter index_filter,
4081 
4082  /**
4083  * This function has the same functionality as GetPropertyNames but
4084  * the returned array doesn't contain the names of properties from
4085  * prototype objects.
4086  */
4088  Local<Context> context);
4089 
4090  /**
4091  * Returns an array containing the names of the filtered properties
4092  * of this object, including properties from prototype objects. The
4093  * array returned by this method contains the same values as would
4094  * be enumerated by a for-in statement over this object.
4095  */
4097  Local<Context> context, PropertyFilter filter,
4099 
4100  /**
4101  * Get the prototype object. This does not skip objects marked to
4102  * be skipped by __proto__ and it does not consult the security
4103  * handler.
4104  */
4106 
4107  /**
4108  * Set the prototype object. This does not skip objects marked to
4109  * be skipped by __proto__ and it does not consult the security
4110  * handler.
4111  */
4113  Local<Value> prototype);
4114 
4115  /**
4116  * Finds an instance of the given function template in the prototype
4117  * chain.
4118  */
4120 
4121  /**
4122  * Call builtin Object.prototype.toString on this object.
4123  * This is different from Value::ToString() that may call
4124  * user-defined toString function. This one does not.
4125  */
4127  Local<Context> context);
4128 
4129  /**
4130  * Returns the name of the function invoked as a constructor for this object.
4131  */
4133 
4134  /**
4135  * Sets the integrity level of the object.
4136  */
4137  Maybe<bool> SetIntegrityLevel(Local<Context> context, IntegrityLevel level);
4138 
4139  /** Gets the number of internal fields for this Object. */
4140  int InternalFieldCount();
4141 
4142  /** Same as above, but works for PersistentBase. */
4144  const PersistentBase<Object>& object) {
4145  return object.val_->InternalFieldCount();
4146  }
4147 
4148  /** Same as above, but works for BasicTracedReference. */
4150  const BasicTracedReference<Object>& object) {
4151  return object->InternalFieldCount();
4152  }
4153 
4154  /** Gets the value from an internal field. */
4155  V8_INLINE Local<Value> GetInternalField(int index);
4156 
4157  /** Sets the value in an internal field. */
4158  void SetInternalField(int index, Local<Value> value);
4159 
4160  /**
4161  * Gets a 2-byte-aligned native pointer from an internal field. This field
4162  * must have been set by SetAlignedPointerInInternalField, everything else
4163  * leads to undefined behavior.
4164  */
4166 
4167  /** Same as above, but works for PersistentBase. */
4169  const PersistentBase<Object>& object, int index) {
4170  return object.val_->GetAlignedPointerFromInternalField(index);
4171  }
4172 
4173  /** Same as above, but works for TracedGlobal. */
4175  const BasicTracedReference<Object>& object, int index) {
4176  return object->GetAlignedPointerFromInternalField(index);
4177  }
4178 
4179  /**
4180  * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
4181  * a field, GetAlignedPointerFromInternalField must be used, everything else
4182  * leads to undefined behavior.
4183  */
4184  void SetAlignedPointerInInternalField(int index, void* value);
4185  void SetAlignedPointerInInternalFields(int argc, int indices[],
4186  void* values[]);
4187 
4188  /**
4189  * HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty().
4190  *
4191  * See also v8::Object::Has() and v8::Object::HasRealNamedProperty().
4192  */
4194  Local<Name> key);
4196  uint32_t index);
4197  /**
4198  * Use HasRealNamedProperty() if you want to check if an object has an own
4199  * property without causing side effects, i.e., without calling interceptors.
4200  *
4201  * This function is similar to v8::Object::HasOwnProperty(), but it does not
4202  * call interceptors.
4203  *
4204  * \note Consider using non-masking interceptors, i.e., the interceptors are
4205  * not called if the receiver has the real named property. See
4206  * `v8::PropertyHandlerFlags::kNonMasking`.
4207  *
4208  * See also v8::Object::Has().
4209  */
4211  Local<Name> key);
4213  Local<Context> context, uint32_t index);
4215  Local<Context> context, Local<Name> key);
4216 
4217  /**
4218  * If result.IsEmpty() no real property was located in the prototype chain.
4219  * This means interceptors in the prototype chain are not called.
4220  */
4222  Local<Context> context, Local<Name> key);
4223 
4224  /**
4225  * Gets the property attributes of a real property in the prototype chain,
4226  * which can be None or any combination of ReadOnly, DontEnum and DontDelete.
4227  * Interceptors in the prototype chain are not called.
4228  */
4231  Local<Name> key);
4232 
4233  /**
4234  * If result.IsEmpty() no real property was located on the object or
4235  * in the prototype chain.
4236  * This means interceptors in the prototype chain are not called.
4237  */
4239  Local<Context> context, Local<Name> key);
4240 
4241  /**
4242  * Gets the property attributes of a real property which can be
4243  * None or any combination of ReadOnly, DontEnum and DontDelete.
4244  * Interceptors in the prototype chain are not called.
4245  */
4247  Local<Context> context, Local<Name> key);
4248 
4249  /** Tests for a named lookup interceptor.*/
4251 
4252  /** Tests for an index lookup interceptor.*/
4254 
4255  /**
4256  * Returns the identity hash for this object. The current implementation
4257  * uses a hidden property on the object to store the identity hash.
4258  *
4259  * The return value will never be 0. Also, it is not guaranteed to be
4260  * unique.
4261  */
4262  int GetIdentityHash();
4263 
4264  /**
4265  * Clone this object with a fast but shallow copy. Values will point
4266  * to the same values as the original object.
4267  */
4268  // TODO(dcarney): take an isolate and optionally bail out?
4269  Local<Object> Clone();
4270 
4271  /**
4272  * Returns the context in which the object was created.
4273  */
4274  V8_DEPRECATE_SOON("Use MaybeLocal<Context> GetCreationContext()")
4277 
4278  /** Same as above, but works for Persistents */
4280  "Use MaybeLocal<Context> GetCreationContext(const "
4281  "PersistentBase<Object>& object)")
4282  static Local<Context> CreationContext(const PersistentBase<Object>& object);
4284  const PersistentBase<Object>& object) {
4285  return object.val_->GetCreationContext();
4286  }
4287 
4288  /**
4289  * Checks whether a callback is set by the
4290  * ObjectTemplate::SetCallAsFunctionHandler method.
4291  * When an Object is callable this method returns true.
4292  */
4293  bool IsCallable();
4294 
4295  /**
4296  * True if this object is a constructor.
4297  */
4298  bool IsConstructor();
4299 
4300  /**
4301  * True if this object can carry information relevant to the embedder in its
4302  * embedder fields, false otherwise. This is generally true for objects
4303  * constructed through function templates but also holds for other types where
4304  * V8 automatically adds internal fields at compile time, such as e.g.
4305  * v8::ArrayBuffer.
4306  */
4307  bool IsApiWrapper();
4308 
4309  /**
4310  * True if this object was created from an object template which was marked
4311  * as undetectable. See v8::ObjectTemplate::MarkAsUndetectable for more
4312  * information.
4313  */
4314  bool IsUndetectable();
4315 
4316  /**
4317  * Call an Object as a function if a callback is set by the
4318  * ObjectTemplate::SetCallAsFunctionHandler method.
4319  */
4321  Local<Value> recv,
4322  int argc,
4323  Local<Value> argv[]);
4324 
4325  /**
4326  * Call an Object as a constructor if a callback is set by the
4327  * ObjectTemplate::SetCallAsFunctionHandler method.
4328  * Note: This method behaves like the Function::NewInstance method.
4329  */
4331  Local<Context> context, int argc, Local<Value> argv[]);
4332 
4333  /**
4334  * Return the isolate to which the Object belongs to.
4335  */
4336  Isolate* GetIsolate();
4337 
4338  /**
4339  * If this object is a Set, Map, WeakSet or WeakMap, this returns a
4340  * representation of the elements of this object as an array.
4341  * If this object is a SetIterator or MapIterator, this returns all
4342  * elements of the underlying collection, starting at the iterator's current
4343  * position.
4344  * For other types, this will return an empty MaybeLocal<Array> (without
4345  * scheduling an exception).
4346  */
4347  MaybeLocal<Array> PreviewEntries(bool* is_key_value);
4348 
4349  static Local<Object> New(Isolate* isolate);
4350 
4351  /**
4352  * Creates a JavaScript object with the given properties, and
4353  * a the given prototype_or_null (which can be any JavaScript
4354  * value, and if it's null, the newly created object won't have
4355  * a prototype at all). This is similar to Object.create().
4356  * All properties will be created as enumerable, configurable
4357  * and writable properties.
4358  */
4359  static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
4360  Local<Name>* names, Local<Value>* values,
4361  size_t length);
4362 
4363  V8_INLINE static Object* Cast(Value* obj);
4364 
4365  /**
4366  * Support for TC39 "dynamic code brand checks" proposal.
4367  *
4368  * This API allows to query whether an object was constructed from a
4369  * "code like" ObjectTemplate.
4370  *
4371  * See also: v8::ObjectTemplate::SetCodeLike
4372  */
4373  bool IsCodeLike(Isolate* isolate);
4374 
4375  private:
4376  Object();
4377  static void CheckCast(Value* obj);
4378  Local<Value> SlowGetInternalField(int index);
4379  void* SlowGetAlignedPointerFromInternalField(int index);
4380 };
4381 
4382 
4383 /**
4384  * An instance of the built-in array constructor (ECMA-262, 15.4.2).
4385  */
4386 class V8_EXPORT Array : public Object {
4387  public:
4388  uint32_t Length() const;
4389 
4390  /**
4391  * Creates a JavaScript array with the given length. If the length
4392  * is negative the returned array will have length 0.
4393  */
4394  static Local<Array> New(Isolate* isolate, int length = 0);
4395 
4396  /**
4397  * Creates a JavaScript array out of a Local<Value> array in C++
4398  * with a known length.
4399  */
4400  static Local<Array> New(Isolate* isolate, Local<Value>* elements,
4401  size_t length);
4402  V8_INLINE static Array* Cast(Value* obj);
4403  private:
4404  Array();
4405  static void CheckCast(Value* obj);
4406 };
4407 
4408 
4409 /**
4410  * An instance of the built-in Map constructor (ECMA-262, 6th Edition, 23.1.1).
4411  */
4412 class V8_EXPORT Map : public Object {
4413  public:
4414  size_t Size() const;
4415  void Clear();
4417  Local<Value> key);
4419  Local<Value> key,
4420  Local<Value> value);
4421  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
4422  Local<Value> key);
4424  Local<Value> key);
4425 
4426  /**
4427  * Returns an array of length Size() * 2, where index N is the Nth key and
4428  * index N + 1 is the Nth value.
4429  */
4430  Local<Array> AsArray() const;
4431 
4432  /**
4433  * Creates a new empty Map.
4434  */
4435  static Local<Map> New(Isolate* isolate);
4436 
4437  V8_INLINE static Map* Cast(Value* obj);
4438 
4439  private:
4440  Map();
4441  static void CheckCast(Value* obj);
4442 };
4443 
4444 
4445 /**
4446  * An instance of the built-in Set constructor (ECMA-262, 6th Edition, 23.2.1).
4447  */
4448 class V8_EXPORT Set : public Object {
4449  public:
4450  size_t Size() const;
4451  void Clear();
4453  Local<Value> key);
4454  V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context,
4455  Local<Value> key);
4457  Local<Value> key);
4458 
4459  /**
4460  * Returns an array of the keys in this Set.
4461  */
4462  Local<Array> AsArray() const;
4463 
4464  /**
4465  * Creates a new empty Set.
4466  */
4467  static Local<Set> New(Isolate* isolate);
4468 
4469  V8_INLINE static Set* Cast(Value* obj);
4470 
4471  private:
4472  Set();
4473  static void CheckCast(Value* obj);
4474 };
4475 
4476 
4477 template<typename T>
4478 class ReturnValue {
4479  public:
4480  template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
4481  : value_(that.value_) {
4482  static_assert(std::is_base_of<T, S>::value, "type check");
4483  }
4484  // Local setters
4485  template <typename S>
4486  V8_INLINE void Set(const Global<S>& handle);
4487  template <typename S>
4488  V8_INLINE void Set(const BasicTracedReference<S>& handle);
4489  template <typename S>
4490  V8_INLINE void Set(const Local<S> handle);
4491  // Fast primitive setters
4492  V8_INLINE void Set(bool value);
4493  V8_INLINE void Set(double i);
4494  V8_INLINE void Set(int32_t i);
4495  V8_INLINE void Set(uint32_t i);
4496  // Fast JS primitive setters
4497  V8_INLINE void SetNull();
4498  V8_INLINE void SetUndefined();
4499  V8_INLINE void SetEmptyString();
4500  // Convenience getter for Isolate
4501  V8_INLINE Isolate* GetIsolate() const;
4502 
4503  // Pointer setter: Uncompilable to prevent inadvertent misuse.
4504  template <typename S>
4505  V8_INLINE void Set(S* whatever);
4506 
4507  // Getter. Creates a new Local<> so it comes with a certain performance
4508  // hit. If the ReturnValue was not yet set, this will return the undefined
4509  // value.
4510  V8_INLINE Local<Value> Get() const;
4511 
4512  private:
4513  template<class F> friend class ReturnValue;
4514  template<class F> friend class FunctionCallbackInfo;
4515  template<class F> friend class PropertyCallbackInfo;
4516  template <class F, class G, class H>
4518  V8_INLINE void SetInternal(internal::Address value) { *value_ = value; }
4519  V8_INLINE internal::Address GetDefaultValue();
4520  V8_INLINE explicit ReturnValue(internal::Address* slot);
4521  internal::Address* value_;
4522 };
4523 
4524 
4525 /**
4526  * The argument information given to function call callbacks. This
4527  * class provides access to information about the context of the call,
4528  * including the receiver, the number and values of arguments, and
4529  * the holder of the function.
4530  */
4531 template<typename T>
4532 class FunctionCallbackInfo {
4533  public:
4534  /** The number of available arguments. */
4535  V8_INLINE int Length() const;
4536  /**
4537  * Accessor for the available arguments. Returns `undefined` if the index
4538  * is out of bounds.
4539  */
4540  V8_INLINE Local<Value> operator[](int i) const;
4541  /** Returns the receiver. This corresponds to the "this" value. */
4542  V8_INLINE Local<Object> This() const;
4543  /**
4544  * If the callback was created without a Signature, this is the same
4545  * value as This(). If there is a signature, and the signature didn't match
4546  * This() but one of its hidden prototypes, this will be the respective
4547  * hidden prototype.
4548  *
4549  * Note that this is not the prototype of This() on which the accessor
4550  * referencing this callback was found (which in V8 internally is often
4551  * referred to as holder [sic]).
4552  */
4553  V8_INLINE Local<Object> Holder() const;
4554  /** For construct calls, this returns the "new.target" value. */
4555  V8_INLINE Local<Value> NewTarget() const;
4556  /** Indicates whether this is a regular call or a construct call. */
4557  V8_INLINE bool IsConstructCall() const;
4558  /** The data argument specified when creating the callback. */
4559  V8_INLINE Local<Value> Data() const;
4560  /** The current Isolate. */
4561  V8_INLINE Isolate* GetIsolate() const;
4562  /** The ReturnValue for the call. */
4564  // This shouldn't be public, but the arm compiler needs it.
4565  static const int kArgsLength = 6;
4566 
4567  protected:
4568  friend class internal::FunctionCallbackArguments;
4570  friend class debug::ConsoleCallArguments;
4571  static const int kHolderIndex = 0;
4572  static const int kIsolateIndex = 1;
4573  static const int kReturnValueDefaultValueIndex = 2;
4574  static const int kReturnValueIndex = 3;
4575  static const int kDataIndex = 4;
4576  static const int kNewTargetIndex = 5;
4577 
4579  internal::Address* values, int length);
4582  int length_;
4583 };
4584 
4585 
4586 /**
4587  * The information passed to a property callback about the context
4588  * of the property access.
4589  */
4590 template<typename T>
4591 class PropertyCallbackInfo {
4592  public:
4593  /**
4594  * \return The isolate of the property access.
4595  */
4596  V8_INLINE Isolate* GetIsolate() const;
4597 
4598  /**
4599  * \return The data set in the configuration, i.e., in
4600  * `NamedPropertyHandlerConfiguration` or
4601  * `IndexedPropertyHandlerConfiguration.`
4602  */
4603  V8_INLINE Local<Value> Data() const;
4604 
4605  /**
4606  * \return The receiver. In many cases, this is the object on which the
4607  * property access was intercepted. When using
4608  * `Reflect.get`, `Function.prototype.call`, or similar functions, it is the
4609  * object passed in as receiver or thisArg.
4610  *
4611  * \code
4612  * void GetterCallback(Local<Name> name,
4613  * const v8::PropertyCallbackInfo<v8::Value>& info) {
4614  * auto context = info.GetIsolate()->GetCurrentContext();
4615  *
4616  * v8::Local<v8::Value> a_this =
4617  * info.This()
4618  * ->GetRealNamedProperty(context, v8_str("a"))
4619  * .ToLocalChecked();
4620  * v8::Local<v8::Value> a_holder =
4621  * info.Holder()
4622  * ->GetRealNamedProperty(context, v8_str("a"))
4623  * .ToLocalChecked();
4624  *
4625  * CHECK(v8_str("r")->Equals(context, a_this).FromJust());
4626  * CHECK(v8_str("obj")->Equals(context, a_holder).FromJust());
4627  *
4628  * info.GetReturnValue().Set(name);
4629  * }
4630  *
4631  * v8::Local<v8::FunctionTemplate> templ =
4632  * v8::FunctionTemplate::New(isolate);
4633  * templ->InstanceTemplate()->SetHandler(
4634  * v8::NamedPropertyHandlerConfiguration(GetterCallback));
4635  * LocalContext env;
4636  * env->Global()
4637  * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
4638  * .ToLocalChecked()
4639  * ->NewInstance(env.local())
4640  * .ToLocalChecked())
4641  * .FromJust();
4642  *
4643  * CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)");
4644  * \endcode
4645  */
4646  V8_INLINE Local<Object> This() const;
4647 
4648  /**
4649  * \return The object in the prototype chain of the receiver that has the
4650  * interceptor. Suppose you have `x` and its prototype is `y`, and `y`
4651  * has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`.
4652  * The Holder() could be a hidden object (the global object, rather
4653  * than the global proxy).
4654  *
4655  * \note For security reasons, do not pass the object back into the runtime.
4656  */
4657  V8_INLINE Local<Object> Holder() const;
4658 
4659  /**
4660  * \return The return value of the callback.
4661  * Can be changed by calling Set().
4662  * \code
4663  * info.GetReturnValue().Set(...)
4664  * \endcode
4665  *
4666  */
4668 
4669  /**
4670  * \return True if the intercepted function should throw if an error occurs.
4671  * Usually, `true` corresponds to `'use strict'`.
4672  *
4673  * \note Always `false` when intercepting `Reflect.set()`
4674  * independent of the language mode.
4675  */
4676  V8_INLINE bool ShouldThrowOnError() const;
4677 
4678  // This shouldn't be public, but the arm compiler needs it.
4679  static const int kArgsLength = 7;
4680 
4681  protected:
4682  friend class MacroAssembler;
4683  friend class internal::PropertyCallbackArguments;
4685  static const int kShouldThrowOnErrorIndex = 0;
4686  static const int kHolderIndex = 1;
4687  static const int kIsolateIndex = 2;
4688  static const int kReturnValueDefaultValueIndex = 3;
4689  static const int kReturnValueIndex = 4;
4690  static const int kDataIndex = 5;
4691  static const int kThisIndex = 6;
4692 
4695 };
4696 
4697 using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
4698 
4700 
4701 /**
4702  * A JavaScript function object (ECMA-262, 15.3).
4703  */
4704 class V8_EXPORT Function : public Object {
4705  public:
4706  /**
4707  * Create a function in the current execution context
4708  * for a given FunctionCallback.
4709  */
4710  static MaybeLocal<Function> New(
4711  Local<Context> context, FunctionCallback callback,
4712  Local<Value> data = Local<Value>(), int length = 0,
4714  SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
4715 
4717  Local<Context> context, int argc, Local<Value> argv[]) const;
4718 
4720  Local<Context> context) const {
4721  return NewInstance(context, 0, nullptr);
4722  }
4723 
4724  /**
4725  * When side effect checks are enabled, passing kHasNoSideEffect allows the
4726  * constructor to be invoked without throwing. Calls made within the
4727  * constructor are still checked.
4728  */
4730  Local<Context> context, int argc, Local<Value> argv[],
4731  SideEffectType side_effect_type = SideEffectType::kHasSideEffect) const;
4732 
4734  Local<Value> recv, int argc,
4735  Local<Value> argv[]);
4736 
4737  void SetName(Local<String> name);
4738  Local<Value> GetName() const;
4739 
4740  /**
4741  * Name inferred from variable or property assignment of this function.
4742  * Used to facilitate debugging and profiling of JavaScript code written
4743  * in an OO style, where many functions are anonymous but are assigned
4744  * to object properties.
4745  */
4746  Local<Value> GetInferredName() const;
4747 
4748  /**
4749  * displayName if it is set, otherwise name if it is configured, otherwise
4750  * function name, otherwise inferred name.
4751  */
4752  Local<Value> GetDebugName() const;
4753 
4754  /**
4755  * User-defined name assigned to the "displayName" property of this function.
4756  * Used to facilitate debugging and profiling of JavaScript code.
4757  */
4758  V8_DEPRECATED(
4759  "Use v8::Object::Get() instead to look up \"displayName\". "
4760  "V8 and DevTools no longer use \"displayName\" in stack "
4761  "traces, but the standard \"name\" property. "
4762  "See http://crbug.com/1177685.")
4763  Local<Value> GetDisplayName() const;
4764 
4765  /**
4766  * Returns zero based line number of function body and
4767  * kLineOffsetNotFound if no information available.
4768  */
4769  int GetScriptLineNumber() const;
4770  /**
4771  * Returns zero based column number of function body and
4772  * kLineOffsetNotFound if no information available.
4773  */
4774  int GetScriptColumnNumber() const;
4775 
4776  /**
4777  * Returns scriptId.
4778  */
4779  int ScriptId() const;
4780 
4781  /**
4782  * Returns the original function if this function is bound, else returns
4783  * v8::Undefined.
4784  */
4785  Local<Value> GetBoundFunction() const;
4786 
4787  /**
4788  * Calls builtin Function.prototype.toString on this function.
4789  * This is different from Value::ToString() that may call a user-defined
4790  * toString() function, and different than Object::ObjectProtoToString() which
4791  * always serializes "[object Function]".
4792  */
4794  Local<Context> context);
4795 
4796  ScriptOrigin GetScriptOrigin() const;
4797  V8_INLINE static Function* Cast(Value* obj);
4798  static const int kLineOffsetNotFound;
4799 
4800  private:
4801  Function();
4802  static void CheckCast(Value* obj);
4803 };
4804 
4805 #ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
4806 // The number of required internal fields can be defined by embedder.
4807 #define V8_PROMISE_INTERNAL_FIELD_COUNT 0
4808 #endif
4809 
4810 /**
4811  * An instance of the built-in Promise constructor (ES6 draft).
4812  */
4813 class V8_EXPORT Promise : public Object {
4814  public:
4815  /**
4816  * State of the promise. Each value corresponds to one of the possible values
4817  * of the [[PromiseState]] field.
4818  */
4820 
4821  class V8_EXPORT Resolver : public Object {
4822  public:
4823  /**
4824  * Create a new resolver, along with an associated promise in pending state.
4825  */
4827  Local<Context> context);
4828 
4829  /**
4830  * Extract the associated promise.
4831  */
4833 
4834  /**
4835  * Resolve/reject the associated promise with a given value.
4836  * Ignored if the promise is no longer pending.
4837  */
4839  Local<Value> value);
4840 
4842  Local<Value> value);
4843 
4844  V8_INLINE static Resolver* Cast(Value* obj);
4845 
4846  private:
4847  Resolver();
4848  static void CheckCast(Value* obj);
4849  };
4850 
4851  /**
4852  * Register a resolution/rejection handler with a promise.
4853  * The handler is given the respective resolution/rejection value as
4854  * an argument. If the promise is already resolved/rejected, the handler is
4855  * invoked at the end of turn.
4856  */
4858  Local<Function> handler);
4859 
4861  Local<Function> handler);
4862 
4864  Local<Function> on_fulfilled,
4865  Local<Function> on_rejected);
4866 
4867  /**
4868  * Returns true if the promise has at least one derived promise, and
4869  * therefore resolve/reject handlers (including default handler).
4870  */
4871  bool HasHandler();
4872 
4873  /**
4874  * Returns the content of the [[PromiseResult]] field. The Promise must not
4875  * be pending.
4876  */
4877  Local<Value> Result();
4878 
4879  /**
4880  * Returns the value of the [[PromiseState]] field.
4881  */
4882  PromiseState State();
4883 
4884  /**
4885  * Marks this promise as handled to avoid reporting unhandled rejections.
4886  */
4887  void MarkAsHandled();
4888 
4889  V8_INLINE static Promise* Cast(Value* obj);
4890 
4892 
4893  private:
4894  Promise();
4895  static void CheckCast(Value* obj);
4896 };
4897 
4898 /**
4899  * An instance of a Property Descriptor, see Ecma-262 6.2.4.
4900  *
4901  * Properties in a descriptor are present or absent. If you do not set
4902  * `enumerable`, `configurable`, and `writable`, they are absent. If `value`,
4903  * `get`, or `set` are absent, but you must specify them in the constructor, use
4904  * empty handles.
4905  *
4906  * Accessors `get` and `set` must be callable or undefined if they are present.
4907  *
4908  * \note Only query properties if they are present, i.e., call `x()` only if
4909  * `has_x()` returns true.
4910  *
4911  * \code
4912  * // var desc = {writable: false}
4913  * v8::PropertyDescriptor d(Local<Value>()), false);
4914  * d.value(); // error, value not set
4915  * if (d.has_writable()) {
4916  * d.writable(); // false
4917  * }
4918  *
4919  * // var desc = {value: undefined}
4920  * v8::PropertyDescriptor d(v8::Undefined(isolate));
4921  *
4922  * // var desc = {get: undefined}
4923  * v8::PropertyDescriptor d(v8::Undefined(isolate), Local<Value>()));
4924  * \endcode
4925  */
4927  public:
4928  // GenericDescriptor
4930 
4931  // DataDescriptor
4932  explicit PropertyDescriptor(Local<Value> value);
4933 
4934  // DataDescriptor with writable property
4935  PropertyDescriptor(Local<Value> value, bool writable);
4936 
4937  // AccessorDescriptor
4939 
4940  ~PropertyDescriptor();
4941 
4942  Local<Value> value() const;
4943  bool has_value() const;
4944 
4945  Local<Value> get() const;
4946  bool has_get() const;
4947  Local<Value> set() const;
4948  bool has_set() const;
4949 
4950  void set_enumerable(bool enumerable);
4951  bool enumerable() const;
4952  bool has_enumerable() const;
4953 
4954  void set_configurable(bool configurable);
4955  bool configurable() const;
4956  bool has_configurable() const;
4957 
4958  bool writable() const;
4959  bool has_writable() const;
4960 
4961  struct PrivateData;
4962  PrivateData* get_private() const { return private_; }
4963 
4964  PropertyDescriptor(const PropertyDescriptor&) = delete;
4965  void operator=(const PropertyDescriptor&) = delete;
4966 
4967  private:
4968  PrivateData* private_;
4969 };
4970 
4971 /**
4972  * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
4973  * 26.2.1).
4974  */
4975 class V8_EXPORT Proxy : public Object {
4976  public:
4977  Local<Value> GetTarget();
4978  Local<Value> GetHandler();
4979  bool IsRevoked();
4980  void Revoke();
4981 
4982  /**
4983  * Creates a new Proxy for the target object.
4984  */
4985  static MaybeLocal<Proxy> New(Local<Context> context,
4986  Local<Object> local_target,
4987  Local<Object> local_handler);
4988 
4989  V8_INLINE static Proxy* Cast(Value* obj);
4990 
4991  private:
4992  Proxy();
4993  static void CheckCast(Value* obj);
4994 };
4995 
4996 /**
4997  * Points to an unowned continous buffer holding a known number of elements.
4998  *
4999  * This is similar to std::span (under consideration for C++20), but does not
5000  * require advanced C++ support. In the (far) future, this may be replaced with
5001  * or aliased to std::span.
5002  *
5003  * To facilitate future migration, this class exposes a subset of the interface
5004  * implemented by std::span.
5005  */
5006 template <typename T>
5008  public:
5009  /** The default constructor creates an empty span. */
5010  constexpr MemorySpan() = default;
5011 
5012  constexpr MemorySpan(T* data, size_t size) : data_(data), size_(size) {}
5013 
5014  /** Returns a pointer to the beginning of the buffer. */
5015  constexpr T* data() const { return data_; }
5016  /** Returns the number of elements that the buffer holds. */
5017  constexpr size_t size() const { return size_; }
5018 
5019  private:
5020  T* data_ = nullptr;
5021  size_t size_ = 0;
5022 };
5023 
5024 /**
5025  * An owned byte buffer with associated size.
5026  */
5027 struct OwnedBuffer {
5028  std::unique_ptr<const uint8_t[]> buffer;
5029  size_t size = 0;
5030  OwnedBuffer(std::unique_ptr<const uint8_t[]> buffer, size_t size)
5031  : buffer(std::move(buffer)), size(size) {}
5032  OwnedBuffer() = default;
5033 };
5034 
5035 // Wrapper around a compiled WebAssembly module, which is potentially shared by
5036 // different WasmModuleObjects.
5038  public:
5039  /**
5040  * Serialize the compiled module. The serialized data does not include the
5041  * wire bytes.
5042  */
5044 
5045  /**
5046  * Get the (wasm-encoded) wire bytes that were used to compile this module.
5047  */
5048  MemorySpan<const uint8_t> GetWireBytesRef();
5049 
5050  const std::string& source_url() const { return source_url_; }
5051 
5052  private:
5053  friend class WasmModuleObject;
5054  friend class WasmStreaming;
5055 
5056  explicit CompiledWasmModule(std::shared_ptr<internal::wasm::NativeModule>,
5057  const char* source_url, size_t url_length);
5058 
5059  const std::shared_ptr<internal::wasm::NativeModule> native_module_;
5060  const std::string source_url_;
5061 };
5062 
5063 // An instance of WebAssembly.Memory.
5065  public:
5066  WasmMemoryObject() = delete;
5067 
5068  /**
5069  * Returns underlying ArrayBuffer.
5070  */
5072 
5073  V8_INLINE static WasmMemoryObject* Cast(Value* obj);
5074 
5075  private:
5076  static void CheckCast(Value* object);
5077 };
5078 
5079 // An instance of WebAssembly.Module.
5081  public:
5082  WasmModuleObject() = delete;
5083 
5084  /**
5085  * Efficiently re-create a WasmModuleObject, without recompiling, from
5086  * a CompiledWasmModule.
5087  */
5089  Isolate* isolate, const CompiledWasmModule&);
5090 
5091  /**
5092  * Get the compiled module for this module object. The compiled module can be
5093  * shared by several module objects.
5094  */
5096 
5097  V8_INLINE static WasmModuleObject* Cast(Value* obj);
5098 
5099  private:
5100  static void CheckCast(Value* obj);
5101 };
5102 
5103 /**
5104  * The V8 interface for WebAssembly streaming compilation. When streaming
5105  * compilation is initiated, V8 passes a {WasmStreaming} object to the embedder
5106  * such that the embedder can pass the input bytes for streaming compilation to
5107  * V8.
5108  */
5109 class V8_EXPORT WasmStreaming final {
5110  public:
5111  class WasmStreamingImpl;
5112 
5113  /**
5114  * Client to receive streaming event notifications.
5115  */
5116  class Client {
5117  public:
5118  virtual ~Client() = default;
5119  /**
5120  * Passes the fully compiled module to the client. This can be used to
5121  * implement code caching.
5122  */
5123  virtual void OnModuleCompiled(CompiledWasmModule compiled_module) = 0;
5124  };
5125 
5126  explicit WasmStreaming(std::unique_ptr<WasmStreamingImpl> impl);
5127 
5128  ~WasmStreaming();
5129 
5130  /**
5131  * Pass a new chunk of bytes to WebAssembly streaming compilation.
5132  * The buffer passed into {OnBytesReceived} is owned by the caller.
5133  */
5134  void OnBytesReceived(const uint8_t* bytes, size_t size);
5135 
5136  /**
5137  * {Finish} should be called after all received bytes where passed to
5138  * {OnBytesReceived} to tell V8 that there will be no more bytes. {Finish}
5139  * does not have to be called after {Abort} has been called already.
5140  */
5141  void Finish();
5142 
5143  /**
5144  * Abort streaming compilation. If {exception} has a value, then the promise
5145  * associated with streaming compilation is rejected with that value. If
5146  * {exception} does not have value, the promise does not get rejected.
5147  */
5148  void Abort(MaybeLocal<Value> exception);
5149 
5150  /**
5151  * Passes previously compiled module bytes. This must be called before
5152  * {OnBytesReceived}, {Finish}, or {Abort}. Returns true if the module bytes
5153  * can be used, false otherwise. The buffer passed via {bytes} and {size}
5154  * is owned by the caller. If {SetCompiledModuleBytes} returns true, the
5155  * buffer must remain valid until either {Finish} or {Abort} completes.
5156  */
5157  bool SetCompiledModuleBytes(const uint8_t* bytes, size_t size);
5158 
5159  /**
5160  * Sets the client object that will receive streaming event notifications.
5161  * This must be called before {OnBytesReceived}, {Finish}, or {Abort}.
5162  */
5163  void SetClient(std::shared_ptr<Client> client);
5164 
5165  /*
5166  * Sets the UTF-8 encoded source URL for the {Script} object. This must be
5167  * called before {Finish}.
5168  */
5169  void SetUrl(const char* url, size_t length);
5170 
5171  /**
5172  * Unpacks a {WasmStreaming} object wrapped in a {Managed} for the embedder.
5173  * Since the embedder is on the other side of the API, it cannot unpack the
5174  * {Managed} itself.
5175  */
5176  static std::shared_ptr<WasmStreaming> Unpack(Isolate* isolate,
5177  Local<Value> value);
5178 
5179  private:
5180  std::unique_ptr<WasmStreamingImpl> impl_;
5181 };
5182 
5183 // TODO(mtrofin): when streaming compilation is done, we can rename this
5184 // to simply WasmModuleObjectBuilder
5185 class V8_EXPORT WasmModuleObjectBuilderStreaming final {
5186  public:
5187  explicit WasmModuleObjectBuilderStreaming(Isolate* isolate);
5188  /**
5189  * The buffer passed into OnBytesReceived is owned by the caller.
5190  */
5191  void OnBytesReceived(const uint8_t*, size_t size);
5192  void Finish();
5193  /**
5194  * Abort streaming compilation. If {exception} has a value, then the promise
5195  * associated with streaming compilation is rejected with that value. If
5196  * {exception} does not have value, the promise does not get rejected.
5197  */
5198  void Abort(MaybeLocal<Value> exception);
5200 
5201  ~WasmModuleObjectBuilderStreaming() = default;
5202 
5203  private:
5204  WasmModuleObjectBuilderStreaming(const WasmModuleObjectBuilderStreaming&) =
5205  delete;
5206  WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) =
5207  default;
5208  WasmModuleObjectBuilderStreaming& operator=(
5209  const WasmModuleObjectBuilderStreaming&) = delete;
5210  WasmModuleObjectBuilderStreaming& operator=(
5211  WasmModuleObjectBuilderStreaming&&) = default;
5212  Isolate* isolate_ = nullptr;
5213 
5214 #if V8_CC_MSVC
5215  /**
5216  * We don't need the static Copy API, so the default
5217  * NonCopyablePersistentTraits would be sufficient, however,
5218  * MSVC eagerly instantiates the Copy.
5219  * We ensure we don't use Copy, however, by compiling with the
5220  * defaults everywhere else.
5221  */
5222  Persistent<Promise, CopyablePersistentTraits<Promise>> promise_;
5223 #else
5224  Persistent<Promise> promise_;
5225 #endif
5226  std::shared_ptr<internal::wasm::StreamingDecoder> streaming_decoder_;
5227 };
5228 
5229 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
5230 // The number of required internal fields can be defined by embedder.
5231 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
5232 #endif
5233 
5234 
5236 
5237 /**
5238  * A wrapper around the backing store (i.e. the raw memory) of an array buffer.
5239  * See a document linked in http://crbug.com/v8/9908 for more information.
5240  *
5241  * The allocation and destruction of backing stores is generally managed by
5242  * V8. Clients should always use standard C++ memory ownership types (i.e.
5243  * std::unique_ptr and std::shared_ptr) to manage lifetimes of backing stores
5244  * properly, since V8 internal objects may alias backing stores.
5245  *
5246  * This object does not keep the underlying |ArrayBuffer::Allocator| alive by
5247  * default. Use Isolate::CreateParams::array_buffer_allocator_shared when
5248  * creating the Isolate to make it hold a reference to the allocator itself.
5249  */
5251  public:
5252  ~BackingStore();
5253 
5254  /**
5255  * Return a pointer to the beginning of the memory block for this backing
5256  * store. The pointer is only valid as long as this backing store object
5257  * lives.
5258  */
5259  void* Data() const;
5260 
5261  /**
5262  * The length (in bytes) of this backing store.
5263  */
5264  size_t ByteLength() const;
5265 
5266  /**
5267  * Indicates whether the backing store was created for an ArrayBuffer or
5268  * a SharedArrayBuffer.
5269  */
5270  bool IsShared() const;
5271 
5272  /**
5273  * Prevent implicit instantiation of operator delete with size_t argument.
5274  * The size_t argument would be incorrect because ptr points to the
5275  * internal BackingStore object.
5276  */
5277  void operator delete(void* ptr) { ::operator delete(ptr); }
5278 
5279  /**
5280  * Wrapper around ArrayBuffer::Allocator::Reallocate that preserves IsShared.
5281  * Assumes that the backing_store was allocated by the ArrayBuffer allocator
5282  * of the given isolate.
5283  */
5284  static std::unique_ptr<BackingStore> Reallocate(
5285  v8::Isolate* isolate, std::unique_ptr<BackingStore> backing_store,
5286  size_t byte_length);
5287 
5288  /**
5289  * This callback is used only if the memory block for a BackingStore cannot be
5290  * allocated with an ArrayBuffer::Allocator. In such cases the destructor of
5291  * the BackingStore invokes the callback to free the memory block.
5292  */
5293  using DeleterCallback = void (*)(void* data, size_t length,
5294  void* deleter_data);
5295 
5296  /**
5297  * If the memory block of a BackingStore is static or is managed manually,
5298  * then this empty deleter along with nullptr deleter_data can be passed to
5299  * ArrayBuffer::NewBackingStore to indicate that.
5300  *
5301  * The manually managed case should be used with caution and only when it
5302  * is guaranteed that the memory block freeing happens after detaching its
5303  * ArrayBuffer.
5304  */
5305  static void EmptyDeleter(void* data, size_t length, void* deleter_data);
5306 
5307  private:
5308  /**
5309  * See [Shared]ArrayBuffer::GetBackingStore and
5310  * [Shared]ArrayBuffer::NewBackingStore.
5311  */
5312  BackingStore();
5313 };
5314 
5315 #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
5316 // Use v8::BackingStore::DeleterCallback instead.
5317 using BackingStoreDeleterCallback = void (*)(void* data, size_t length,
5318  void* deleter_data);
5319 
5320 #endif
5321 
5322 /**
5323  * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
5324  */
5325 class V8_EXPORT ArrayBuffer : public Object {
5326  public:
5327  /**
5328  * A thread-safe allocator that V8 uses to allocate |ArrayBuffer|'s memory.
5329  * The allocator is a global V8 setting. It has to be set via
5330  * Isolate::CreateParams.
5331  *
5332  * Memory allocated through this allocator by V8 is accounted for as external
5333  * memory by V8. Note that V8 keeps track of the memory for all internalized
5334  * |ArrayBuffer|s. Responsibility for tracking external memory (using
5335  * Isolate::AdjustAmountOfExternalAllocatedMemory) is handed over to the
5336  * embedder upon externalization and taken over upon internalization (creating
5337  * an internalized buffer from an existing buffer).
5338  *
5339  * Note that it is unsafe to call back into V8 from any of the allocator
5340  * functions.
5341  */
5342  class V8_EXPORT Allocator { // NOLINT
5343  public:
5344  virtual ~Allocator() = default;
5345 
5346  /**
5347  * Allocate |length| bytes. Return nullptr if allocation is not successful.
5348  * Memory should be initialized to zeroes.
5349  */
5350  virtual void* Allocate(size_t length) = 0;
5351 
5352  /**
5353  * Allocate |length| bytes. Return nullptr if allocation is not successful.
5354  * Memory does not have to be initialized.
5355  */
5356  virtual void* AllocateUninitialized(size_t length) = 0;
5357 
5358  /**
5359  * Free the memory block of size |length|, pointed to by |data|.
5360  * That memory is guaranteed to be previously allocated by |Allocate|.
5361  */
5362  virtual void Free(void* data, size_t length) = 0;
5363 
5364  /**
5365  * Reallocate the memory block of size |old_length| to a memory block of
5366  * size |new_length| by expanding, contracting, or copying the existing
5367  * memory block. If |new_length| > |old_length|, then the new part of
5368  * the memory must be initialized to zeros. Return nullptr if reallocation
5369  * is not successful.
5370  *
5371  * The caller guarantees that the memory block was previously allocated
5372  * using Allocate or AllocateUninitialized.
5373  *
5374  * The default implementation allocates a new block and copies data.
5375  */
5376  virtual void* Reallocate(void* data, size_t old_length, size_t new_length);
5377 
5378  /**
5379  * ArrayBuffer allocation mode. kNormal is a malloc/free style allocation,
5380  * while kReservation is for larger allocations with the ability to set
5381  * access permissions.
5382  */
5384 
5385  /**
5386  * malloc/free based convenience allocator.
5387  *
5388  * Caller takes ownership, i.e. the returned object needs to be freed using
5389  * |delete allocator| once it is no longer in use.
5390  */
5391  static Allocator* NewDefaultAllocator();
5392  };
5393 
5394  /**
5395  * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer|
5396  * returns an instance of this class, populated, with a pointer to data
5397  * and byte length.
5398  *
5399  * The Data pointer of ArrayBuffer::Contents must be freed using the provided
5400  * deleter, which will call ArrayBuffer::Allocator::Free if the buffer
5401  * was allocated with ArraryBuffer::Allocator::Allocate.
5402  */
5403  class V8_EXPORT Contents { // NOLINT
5404  public:
5405  using DeleterCallback = void (*)(void* buffer, size_t length, void* info);
5406 
5408  : data_(nullptr),
5409  byte_length_(0),
5410  allocation_base_(nullptr),
5411  allocation_length_(0),
5412  allocation_mode_(Allocator::AllocationMode::kNormal),
5413  deleter_(nullptr),
5414  deleter_data_(nullptr) {}
5415 
5416  void* AllocationBase() const { return allocation_base_; }
5417  size_t AllocationLength() const { return allocation_length_; }
5418  Allocator::AllocationMode AllocationMode() const {
5419  return allocation_mode_;
5420  }
5421 
5422  void* Data() const { return data_; }
5423  size_t ByteLength() const { return byte_length_; }
5424  DeleterCallback Deleter() const { return deleter_; }
5425  void* DeleterData() const { return deleter_data_; }
5426 
5427  private:
5428  Contents(void* data, size_t byte_length, void* allocation_base,
5429  size_t allocation_length,
5430  Allocator::AllocationMode allocation_mode, DeleterCallback deleter,
5431  void* deleter_data);
5432 
5433  void* data_;
5434  size_t byte_length_;
5435  void* allocation_base_;
5436  size_t allocation_length_;
5437  Allocator::AllocationMode allocation_mode_;
5438  DeleterCallback deleter_;
5439  void* deleter_data_;
5440 
5441  friend class ArrayBuffer;
5442  };
5443 
5444 
5445  /**
5446  * Data length in bytes.
5447  */
5448  size_t ByteLength() const;
5449 
5450  /**
5451  * Create a new ArrayBuffer. Allocate |byte_length| bytes.
5452  * Allocated memory will be owned by a created ArrayBuffer and
5453  * will be deallocated when it is garbage-collected,
5454  * unless the object is externalized.
5455  */
5456  static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
5457 
5458  /**
5459  * Create a new ArrayBuffer over an existing memory block.
5460  * The created array buffer is by default immediately in externalized state.
5461  * In externalized state, the memory block will not be reclaimed when a
5462  * created ArrayBuffer is garbage-collected.
5463  * In internalized state, the memory block will be released using
5464  * |Allocator::Free| once all ArrayBuffers referencing it are collected by
5465  * the garbage collector.
5466  */
5467  V8_DEPRECATED(
5468  "Use the version that takes a BackingStore. "
5469  "See http://crbug.com/v8/9908.")
5470  static Local<ArrayBuffer> New(
5471  Isolate* isolate, void* data, size_t byte_length,
5473 
5474  /**
5475  * Create a new ArrayBuffer with an existing backing store.
5476  * The created array keeps a reference to the backing store until the array
5477  * is garbage collected. Note that the IsExternal bit does not affect this
5478  * reference from the array to the backing store.
5479  *
5480  * In future IsExternal bit will be removed. Until then the bit is set as
5481  * follows. If the backing store does not own the underlying buffer, then
5482  * the array is created in externalized state. Otherwise, the array is created
5483  * in internalized state. In the latter case the array can be transitioned
5484  * to the externalized state using Externalize(backing_store).
5485  */
5486  static Local<ArrayBuffer> New(Isolate* isolate,
5487  std::shared_ptr<BackingStore> backing_store);
5488 
5489  /**
5490  * Returns a new standalone BackingStore that is allocated using the array
5491  * buffer allocator of the isolate. The result can be later passed to
5492  * ArrayBuffer::New.
5493  *
5494  * If the allocator returns nullptr, then the function may cause GCs in the
5495  * given isolate and re-try the allocation. If GCs do not help, then the
5496  * function will crash with an out-of-memory error.
5497  */
5498  static std::unique_ptr<BackingStore> NewBackingStore(Isolate* isolate,
5499  size_t byte_length);
5500  /**
5501  * Returns a new standalone BackingStore that takes over the ownership of
5502  * the given buffer. The destructor of the BackingStore invokes the given
5503  * deleter callback.
5504  *
5505  * The result can be later passed to ArrayBuffer::New. The raw pointer
5506  * to the buffer must not be passed again to any V8 API function.
5507  */
5508  static std::unique_ptr<BackingStore> NewBackingStore(
5509  void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter,
5510  void* deleter_data);
5511 
5512  /**
5513  * Returns true if ArrayBuffer is externalized, that is, does not
5514  * own its memory block.
5515  */
5516  V8_DEPRECATED(
5517  "With v8::BackingStore externalized ArrayBuffers are "
5518  "the same as ordinary ArrayBuffers. See http://crbug.com/v8/9908.")
5519  bool IsExternal() const;
5520 
5521  /**
5522  * Returns true if this ArrayBuffer may be detached.
5523  */
5524  bool IsDetachable() const;
5525 
5526  /**
5527  * Detaches this ArrayBuffer and all its views (typed arrays).
5528  * Detaching sets the byte length of the buffer and all typed arrays to zero,
5529  * preventing JavaScript from ever accessing underlying backing store.
5530  * ArrayBuffer should have been externalized and must be detachable.
5531  */
5532  void Detach();
5533 
5534  /**
5535  * Make this ArrayBuffer external. The pointer to underlying memory block
5536  * and byte length are returned as |Contents| structure. After ArrayBuffer
5537  * had been externalized, it does no longer own the memory block. The caller
5538  * should take steps to free memory when it is no longer needed.
5539  *
5540  * The Data pointer of ArrayBuffer::Contents must be freed using the provided
5541  * deleter, which will call ArrayBuffer::Allocator::Free if the buffer
5542  * was allocated with ArrayBuffer::Allocator::Allocate.
5543  */
5544  V8_DEPRECATED("Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
5546 
5547  /**
5548  * Marks this ArrayBuffer external given a witness that the embedder
5549  * has fetched the backing store using the new GetBackingStore() function.
5550  *
5551  * With the new lifetime management of backing stores there is no need for
5552  * externalizing, so this function exists only to make the transition easier.
5553  */
5554  V8_DEPRECATED("This will be removed together with IsExternal.")
5555  void Externalize(const std::shared_ptr<BackingStore>& backing_store);
5556 
5557  /**
5558  * Get a pointer to the ArrayBuffer's underlying memory block without
5559  * externalizing it. If the ArrayBuffer is not externalized, this pointer
5560  * will become invalid as soon as the ArrayBuffer gets garbage collected.
5561  *
5562  * The embedder should make sure to hold a strong reference to the
5563  * ArrayBuffer while accessing this pointer.
5564  */
5565  V8_DEPRECATED("Use GetBackingStore. See http://crbug.com/v8/9908.")
5567 
5568  /**
5569  * Get a shared pointer to the backing store of this array buffer. This
5570  * pointer coordinates the lifetime management of the internal storage
5571  * with any live ArrayBuffers on the heap, even across isolates. The embedder
5572  * should not attempt to manage lifetime of the storage through other means.
5573  *
5574  * This function replaces both Externalize() and GetContents().
5575  */
5576  std::shared_ptr<BackingStore> GetBackingStore();
5577 
5578  V8_INLINE static ArrayBuffer* Cast(Value* obj);
5579 
5582 
5583  private:
5584  ArrayBuffer();
5585  static void CheckCast(Value* obj);
5586  Contents GetContents(bool externalize);
5587 };
5588 
5589 
5590 #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
5591 // The number of required internal fields can be defined by embedder.
5592 #define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
5593 #endif
5594 
5595 
5596 /**
5597  * A base class for an instance of one of "views" over ArrayBuffer,
5598  * including TypedArrays and DataView (ES6 draft 15.13).
5599  */
5601  public:
5602  /**
5603  * Returns underlying ArrayBuffer.
5604  */
5606  /**
5607  * Byte offset in |Buffer|.
5608  */
5609  size_t ByteOffset();
5610  /**
5611  * Size of a view in bytes.
5612  */
5613  size_t ByteLength();
5614 
5615  /**
5616  * Copy the contents of the ArrayBufferView's buffer to an embedder defined
5617  * memory without additional overhead that calling ArrayBufferView::Buffer
5618  * might incur.
5619  *
5620  * Will write at most min(|byte_length|, ByteLength) bytes starting at
5621  * ByteOffset of the underlying buffer to the memory starting at |dest|.
5622  * Returns the number of bytes actually written.
5623  */
5624  size_t CopyContents(void* dest, size_t byte_length);
5625 
5626  /**
5627  * Returns true if ArrayBufferView's backing ArrayBuffer has already been
5628  * allocated.
5629  */
5630  bool HasBuffer() const;
5631 
5632  V8_INLINE static ArrayBufferView* Cast(Value* obj);
5633 
5634  static const int kInternalFieldCount =
5636  static const int kEmbedderFieldCount =
5638 
5639  private:
5640  ArrayBufferView();
5641  static void CheckCast(Value* obj);
5642 };
5643 
5644 
5645 /**
5646  * A base class for an instance of TypedArray series of constructors
5647  * (ES6 draft 15.13.6).
5648  */
5650  public:
5651  /*
5652  * The largest typed array size that can be constructed using New.
5653  */
5654  static constexpr size_t kMaxLength =
5657  : static_cast<size_t>(uint64_t{1} << 32);
5658 
5659  /**
5660  * Number of elements in this typed array
5661  * (e.g. for Int16Array, |ByteLength|/2).
5662  */
5663  size_t Length();
5664 
5665  V8_INLINE static TypedArray* Cast(Value* obj);
5666 
5667  private:
5668  TypedArray();
5669  static void CheckCast(Value* obj);
5670 };
5671 
5672 
5673 /**
5674  * An instance of Uint8Array constructor (ES6 draft 15.13.6).
5675  */
5677  public:
5678  static Local<Uint8Array> New(Local<ArrayBuffer> array_buffer,
5679  size_t byte_offset, size_t length);
5680  static Local<Uint8Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5681  size_t byte_offset, size_t length);
5682  V8_INLINE static Uint8Array* Cast(Value* obj);
5683 
5684  private:
5685  Uint8Array();
5686  static void CheckCast(Value* obj);
5687 };
5688 
5689 
5690 /**
5691  * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6).
5692  */
5694  public:
5695  static Local<Uint8ClampedArray> New(Local<ArrayBuffer> array_buffer,
5696  size_t byte_offset, size_t length);
5697  static Local<Uint8ClampedArray> New(
5698  Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset,
5699  size_t length);
5700  V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
5701 
5702  private:
5703  Uint8ClampedArray();
5704  static void CheckCast(Value* obj);
5705 };
5706 
5707 /**
5708  * An instance of Int8Array constructor (ES6 draft 15.13.6).
5709  */
5711  public:
5712  static Local<Int8Array> New(Local<ArrayBuffer> array_buffer,
5713  size_t byte_offset, size_t length);
5714  static Local<Int8Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5715  size_t byte_offset, size_t length);
5716  V8_INLINE static Int8Array* Cast(Value* obj);
5717 
5718  private:
5719  Int8Array();
5720  static void CheckCast(Value* obj);
5721 };
5722 
5723 
5724 /**
5725  * An instance of Uint16Array constructor (ES6 draft 15.13.6).
5726  */
5728  public:
5729  static Local<Uint16Array> New(Local<ArrayBuffer> array_buffer,
5730  size_t byte_offset, size_t length);
5731  static Local<Uint16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5732  size_t byte_offset, size_t length);
5733  V8_INLINE static Uint16Array* Cast(Value* obj);
5734 
5735  private:
5736  Uint16Array();
5737  static void CheckCast(Value* obj);
5738 };
5739 
5740 
5741 /**
5742  * An instance of Int16Array constructor (ES6 draft 15.13.6).
5743  */
5745  public:
5746  static Local<Int16Array> New(Local<ArrayBuffer> array_buffer,
5747  size_t byte_offset, size_t length);
5748  static Local<Int16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5749  size_t byte_offset, size_t length);
5750  V8_INLINE static Int16Array* Cast(Value* obj);
5751 
5752  private:
5753  Int16Array();
5754  static void CheckCast(Value* obj);
5755 };
5756 
5757 
5758 /**
5759  * An instance of Uint32Array constructor (ES6 draft 15.13.6).
5760  */
5762  public:
5763  static Local<Uint32Array> New(Local<ArrayBuffer> array_buffer,
5764  size_t byte_offset, size_t length);
5765  static Local<Uint32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5766  size_t byte_offset, size_t length);
5767  V8_INLINE static Uint32Array* Cast(Value* obj);
5768 
5769  private:
5770  Uint32Array();
5771  static void CheckCast(Value* obj);
5772 };
5773 
5774 
5775 /**
5776  * An instance of Int32Array constructor (ES6 draft 15.13.6).
5777  */
5779  public:
5780  static Local<Int32Array> New(Local<ArrayBuffer> array_buffer,
5781  size_t byte_offset, size_t length);
5782  static Local<Int32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5783  size_t byte_offset, size_t length);
5784  V8_INLINE static Int32Array* Cast(Value* obj);
5785 
5786  private:
5787  Int32Array();
5788  static void CheckCast(Value* obj);
5789 };
5790 
5791 
5792 /**
5793  * An instance of Float32Array constructor (ES6 draft 15.13.6).
5794  */
5796  public:
5797  static Local<Float32Array> New(Local<ArrayBuffer> array_buffer,
5798  size_t byte_offset, size_t length);
5799  static Local<Float32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5800  size_t byte_offset, size_t length);
5801  V8_INLINE static Float32Array* Cast(Value* obj);
5802 
5803  private:
5804  Float32Array();
5805  static void CheckCast(Value* obj);
5806 };
5807 
5808 
5809 /**
5810  * An instance of Float64Array constructor (ES6 draft 15.13.6).
5811  */
5813  public:
5814  static Local<Float64Array> New(Local<ArrayBuffer> array_buffer,
5815  size_t byte_offset, size_t length);
5816  static Local<Float64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5817  size_t byte_offset, size_t length);
5818  V8_INLINE static Float64Array* Cast(Value* obj);
5819 
5820  private:
5821  Float64Array();
5822  static void CheckCast(Value* obj);
5823 };
5824 
5825 /**
5826  * An instance of BigInt64Array constructor.
5827  */
5829  public:
5830  static Local<BigInt64Array> New(Local<ArrayBuffer> array_buffer,
5831  size_t byte_offset, size_t length);
5832  static Local<BigInt64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5833  size_t byte_offset, size_t length);
5834  V8_INLINE static BigInt64Array* Cast(Value* obj);
5835 
5836  private:
5837  BigInt64Array();
5838  static void CheckCast(Value* obj);
5839 };
5840 
5841 /**
5842  * An instance of BigUint64Array constructor.
5843  */
5845  public:
5846  static Local<BigUint64Array> New(Local<ArrayBuffer> array_buffer,
5847  size_t byte_offset, size_t length);
5848  static Local<BigUint64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
5849  size_t byte_offset, size_t length);
5850  V8_INLINE static BigUint64Array* Cast(Value* obj);
5851 
5852  private:
5853  BigUint64Array();
5854  static void CheckCast(Value* obj);
5855 };
5856 
5857 /**
5858  * An instance of DataView constructor (ES6 draft 15.13.7).
5859  */
5861  public:
5862  static Local<DataView> New(Local<ArrayBuffer> array_buffer,
5863  size_t byte_offset, size_t length);
5864  static Local<DataView> New(Local<SharedArrayBuffer> shared_array_buffer,
5865  size_t byte_offset, size_t length);
5866  V8_INLINE static DataView* Cast(Value* obj);
5867 
5868  private:
5869  DataView();
5870  static void CheckCast(Value* obj);
5871 };
5872 
5873 
5874 /**
5875  * An instance of the built-in SharedArrayBuffer constructor.
5876  */
5878  public:
5879  /**
5880  * The contents of an |SharedArrayBuffer|. Externalization of
5881  * |SharedArrayBuffer| returns an instance of this class, populated, with a
5882  * pointer to data and byte length.
5883  *
5884  * The Data pointer of ArrayBuffer::Contents must be freed using the provided
5885  * deleter, which will call ArrayBuffer::Allocator::Free if the buffer
5886  * was allocated with ArraryBuffer::Allocator::Allocate.
5887  */
5888  class V8_EXPORT Contents { // NOLINT
5889  public:
5890  using Allocator = v8::ArrayBuffer::Allocator;
5891  using DeleterCallback = void (*)(void* buffer, size_t length, void* info);
5892 
5894  : data_(nullptr),
5895  byte_length_(0),
5896  allocation_base_(nullptr),
5897  allocation_length_(0),
5898  allocation_mode_(Allocator::AllocationMode::kNormal),
5899  deleter_(nullptr),
5900  deleter_data_(nullptr) {}
5901 
5902  void* AllocationBase() const { return allocation_base_; }
5903  size_t AllocationLength() const { return allocation_length_; }
5904  Allocator::AllocationMode AllocationMode() const {
5905  return allocation_mode_;
5906  }
5907 
5908  void* Data() const { return data_; }
5909  size_t ByteLength() const { return byte_length_; }
5910  DeleterCallback Deleter() const { return deleter_; }
5911  void* DeleterData() const { return deleter_data_; }
5912 
5913  private:
5914  Contents(void* data, size_t byte_length, void* allocation_base,
5915  size_t allocation_length,
5916  Allocator::AllocationMode allocation_mode, DeleterCallback deleter,
5917  void* deleter_data);
5918 
5919  void* data_;
5920  size_t byte_length_;
5921  void* allocation_base_;
5922  size_t allocation_length_;
5923  Allocator::AllocationMode allocation_mode_;
5924  DeleterCallback deleter_;
5925  void* deleter_data_;
5926 
5927  friend class SharedArrayBuffer;
5928  };
5929 
5930  /**
5931  * Data length in bytes.
5932  */
5933  size_t ByteLength() const;
5934 
5935  /**
5936  * Create a new SharedArrayBuffer. Allocate |byte_length| bytes.
5937  * Allocated memory will be owned by a created SharedArrayBuffer and
5938  * will be deallocated when it is garbage-collected,
5939  * unless the object is externalized.
5940  */
5941  static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length);
5942 
5943  /**
5944  * Create a new SharedArrayBuffer over an existing memory block. The created
5945  * array buffer is immediately in externalized state unless otherwise
5946  * specified. The memory block will not be reclaimed when a created
5947  * SharedArrayBuffer is garbage-collected.
5948  */
5949  V8_DEPRECATED(
5950  "Use the version that takes a BackingStore. "
5951  "See http://crbug.com/v8/9908.")
5952  static Local<SharedArrayBuffer> New(
5953  Isolate* isolate, void* data, size_t byte_length,
5955 
5956  /**
5957  * Create a new SharedArrayBuffer with an existing backing store.
5958  * The created array keeps a reference to the backing store until the array
5959  * is garbage collected. Note that the IsExternal bit does not affect this
5960  * reference from the array to the backing store.
5961  *
5962  * In future IsExternal bit will be removed. Until then the bit is set as
5963  * follows. If the backing store does not own the underlying buffer, then
5964  * the array is created in externalized state. Otherwise, the array is created
5965  * in internalized state. In the latter case the array can be transitioned
5966  * to the externalized state using Externalize(backing_store).
5967  */
5968  static Local<SharedArrayBuffer> New(
5969  Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
5970 
5971  /**
5972  * Returns a new standalone BackingStore that is allocated using the array
5973  * buffer allocator of the isolate. The result can be later passed to
5974  * SharedArrayBuffer::New.
5975  *
5976  * If the allocator returns nullptr, then the function may cause GCs in the
5977  * given isolate and re-try the allocation. If GCs do not help, then the
5978  * function will crash with an out-of-memory error.
5979  */
5980  static std::unique_ptr<BackingStore> NewBackingStore(Isolate* isolate,
5981  size_t byte_length);
5982  /**
5983  * Returns a new standalone BackingStore that takes over the ownership of
5984  * the given buffer. The destructor of the BackingStore invokes the given
5985  * deleter callback.
5986  *
5987  * The result can be later passed to SharedArrayBuffer::New. The raw pointer
5988  * to the buffer must not be passed again to any V8 functions.
5989  */
5990  static std::unique_ptr<BackingStore> NewBackingStore(
5991  void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter,
5992  void* deleter_data);
5993 
5994  /**
5995  * Create a new SharedArrayBuffer over an existing memory block. Propagate
5996  * flags to indicate whether the underlying buffer can be grown.
5997  */
5998  V8_DEPRECATED(
5999  "Use the version that takes a BackingStore. "
6000  "See http://crbug.com/v8/9908.")
6001  static Local<SharedArrayBuffer> New(
6002  Isolate* isolate, const SharedArrayBuffer::Contents&,
6004 
6005  /**
6006  * Returns true if SharedArrayBuffer is externalized, that is, does not
6007  * own its memory block.
6008  */
6009  V8_DEPRECATED(
6010  "With v8::BackingStore externalized SharedArrayBuffers are the same "
6011  "as ordinary SharedArrayBuffers. See http://crbug.com/v8/9908.")
6012  bool IsExternal() const;
6013 
6014  /**
6015  * Make this SharedArrayBuffer external. The pointer to underlying memory
6016  * block and byte length are returned as |Contents| structure. After
6017  * SharedArrayBuffer had been externalized, it does no longer own the memory
6018  * block. The caller should take steps to free memory when it is no longer
6019  * needed.
6020  *
6021  * The memory block is guaranteed to be allocated with |Allocator::Allocate|
6022  * by the allocator specified in
6023  * v8::Isolate::CreateParams::array_buffer_allocator.
6024  *
6025  */
6026  V8_DEPRECATED("Use GetBackingStore or Detach. See http://crbug.com/v8/9908.")
6028 
6029  /**
6030  * Marks this SharedArrayBuffer external given a witness that the embedder
6031  * has fetched the backing store using the new GetBackingStore() function.
6032  *
6033  * With the new lifetime management of backing stores there is no need for
6034  * externalizing, so this function exists only to make the transition easier.
6035  */
6036  V8_DEPRECATED("This will be removed together with IsExternal.")
6037  void Externalize(const std::shared_ptr<BackingStore>& backing_store);
6038 
6039  /**
6040  * Get a pointer to the ArrayBuffer's underlying memory block without
6041  * externalizing it. If the ArrayBuffer is not externalized, this pointer
6042  * will become invalid as soon as the ArrayBuffer became garbage collected.
6043  *
6044  * The embedder should make sure to hold a strong reference to the
6045  * ArrayBuffer while accessing this pointer.
6046  *
6047  * The memory block is guaranteed to be allocated with |Allocator::Allocate|
6048  * by the allocator specified in
6049  * v8::Isolate::CreateParams::array_buffer_allocator.
6050  */
6051  V8_DEPRECATED("Use GetBackingStore. See http://crbug.com/v8/9908.")
6053 
6054  /**
6055  * Get a shared pointer to the backing store of this array buffer. This
6056  * pointer coordinates the lifetime management of the internal storage
6057  * with any live ArrayBuffers on the heap, even across isolates. The embedder
6058  * should not attempt to manage lifetime of the storage through other means.
6059  *
6060  * This function replaces both Externalize() and GetContents().
6061  */
6062  std::shared_ptr<BackingStore> GetBackingStore();
6063 
6064  V8_INLINE static SharedArrayBuffer* Cast(Value* obj);
6065 
6067 
6068  private:
6069  SharedArrayBuffer();
6070  static void CheckCast(Value* obj);
6071  Contents GetContents(bool externalize);
6072 };
6073 
6074 
6075 /**
6076  * An instance of the built-in Date constructor (ECMA-262, 15.9).
6077  */
6078 class V8_EXPORT Date : public Object {
6079  public:
6081  double time);
6082 
6083  /**
6084  * A specialization of Value::NumberValue that is more efficient
6085  * because we know the structure of this object.
6086  */
6087  double ValueOf() const;
6088 
6089  V8_INLINE static Date* Cast(Value* obj);
6090 
6091  private:
6092  static void CheckCast(Value* obj);
6093 };
6094 
6095 
6096 /**
6097  * A Number object (ECMA-262, 4.3.21).
6098  */
6100  public:
6101  static Local<Value> New(Isolate* isolate, double value);
6102 
6103  double ValueOf() const;
6104 
6105  V8_INLINE static NumberObject* Cast(Value* obj);
6106 
6107  private:
6108  static void CheckCast(Value* obj);
6109 };
6110 
6111 /**
6112  * A BigInt object (https://tc39.github.io/proposal-bigint)
6113  */
6115  public:
6116  static Local<Value> New(Isolate* isolate, int64_t value);
6117 
6118  Local<BigInt> ValueOf() const;
6119 
6120  V8_INLINE static BigIntObject* Cast(Value* obj);
6121 
6122  private:
6123  static void CheckCast(Value* obj);
6124 };
6125 
6126 /**
6127  * A Boolean object (ECMA-262, 4.3.15).
6128  */
6130  public:
6131  static Local<Value> New(Isolate* isolate, bool value);
6132 
6133  bool ValueOf() const;
6134 
6135  V8_INLINE static BooleanObject* Cast(Value* obj);
6136 
6137  private:
6138  static void CheckCast(Value* obj);
6139 };
6140 
6141 
6142 /**
6143  * A String object (ECMA-262, 4.3.18).
6144  */
6146  public:
6147  static Local<Value> New(Isolate* isolate, Local<String> value);
6148 
6149  Local<String> ValueOf() const;
6150 
6151  V8_INLINE static StringObject* Cast(Value* obj);
6152 
6153  private:
6154  static void CheckCast(Value* obj);
6155 };
6156 
6157 
6158 /**
6159  * A Symbol object (ECMA-262 edition 6).
6160  */
6162  public:
6163  static Local<Value> New(Isolate* isolate, Local<Symbol> value);
6164 
6165  Local<Symbol> ValueOf() const;
6166 
6167  V8_INLINE static SymbolObject* Cast(Value* obj);
6168 
6169  private:
6170  static void CheckCast(Value* obj);
6171 };
6172 
6173 
6174 /**
6175  * An instance of the built-in RegExp constructor (ECMA-262, 15.10).
6176  */
6177 class V8_EXPORT RegExp : public Object {
6178  public:
6179  /**
6180  * Regular expression flag bits. They can be or'ed to enable a set
6181  * of flags.
6182  * The kLinear value ('l') is experimental and can only be used with
6183  * --enable-experimental-regexp-engine. RegExps with kLinear flag are
6184  * guaranteed to be executed in asymptotic linear time wrt. the length of
6185  * the subject string.
6186  */
6187  enum Flags {
6188  kNone = 0,
6189  kGlobal = 1 << 0,
6190  kIgnoreCase = 1 << 1,
6191  kMultiline = 1 << 2,
6192  kSticky = 1 << 3,
6193  kUnicode = 1 << 4,
6194  kDotAll = 1 << 5,
6195  kLinear = 1 << 6,
6196  kHasIndices = 1 << 7,
6197  };
6198 
6199  static constexpr int kFlagCount = 8;
6200 
6201  /**
6202  * Creates a regular expression from the given pattern string and
6203  * the flags bit field. May throw a JavaScript exception as
6204  * described in ECMA-262, 15.10.4.1.
6205  *
6206  * For example,
6207  * RegExp::New(v8::String::New("foo"),
6208  * static_cast<RegExp::Flags>(kGlobal | kMultiline))
6209  * is equivalent to evaluating "/foo/gm".
6210  */
6212  Local<String> pattern,
6213  Flags flags);
6214 
6215  /**
6216  * Like New, but additionally specifies a backtrack limit. If the number of
6217  * backtracks done in one Exec call hits the limit, a match failure is
6218  * immediately returned.
6219  */
6221  Local<Context> context, Local<String> pattern, Flags flags,
6222  uint32_t backtrack_limit);
6223 
6224  /**
6225  * Executes the current RegExp instance on the given subject string.
6226  * Equivalent to RegExp.prototype.exec as described in
6227  *
6228  * https://tc39.es/ecma262/#sec-regexp.prototype.exec
6229  *
6230  * On success, an Array containing the matched strings is returned. On
6231  * failure, returns Null.
6232  *
6233  * Note: modifies global context state, accessible e.g. through RegExp.input.
6234  */
6236  Local<String> subject);
6237 
6238  /**
6239  * Returns the value of the source property: a string representing
6240  * the regular expression.
6241  */
6242  Local<String> GetSource() const;
6243 
6244  /**
6245  * Returns the flags bit field.
6246  */
6247  Flags GetFlags() const;
6248 
6249  V8_INLINE static RegExp* Cast(Value* obj);
6250 
6251  private:
6252  static void CheckCast(Value* obj);
6253 };
6254 
6255 /**
6256  * A JavaScript value that wraps a C++ void*. This type of value is mainly used
6257  * to associate C++ data structures with JavaScript objects.
6258  */
6259 class V8_EXPORT External : public Value {
6260  public:
6261  static Local<External> New(Isolate* isolate, void* value);
6262  V8_INLINE static External* Cast(Value* obj);
6263  void* Value() const;
6264  private:
6265  static void CheckCast(v8::Value* obj);
6266 };
6267 
6268 #define V8_INTRINSICS_LIST(F)
6269  F(ArrayProto_entries, array_entries_iterator)
6270  F(ArrayProto_forEach, array_for_each_iterator)
6271  F(ArrayProto_keys, array_keys_iterator)
6272  F(ArrayProto_values, array_values_iterator)
6273  F(AsyncIteratorPrototype, initial_async_iterator_prototype)
6274  F(ErrorPrototype, initial_error_prototype)
6275  F(IteratorPrototype, initial_iterator_prototype)
6276  F(ObjProto_valueOf, object_value_of_function)
6277 
6279 #define V8_DECL_INTRINSIC(name, iname) k##name,
6281 #undef V8_DECL_INTRINSIC
6282 };
6283 
6284 
6285 // --- Templates ---
6286 
6287 
6288 /**
6289  * The superclass of object and function templates.
6290  */
6291 class V8_EXPORT Template : public Data {
6292  public:
6293  /**
6294  * Adds a property to each instance created by this template.
6295  *
6296  * The property must be defined either as a primitive value, or a template.
6297  */
6298  void Set(Local<Name> name, Local<Data> value,
6299  PropertyAttribute attributes = None);
6300  void SetPrivate(Local<Private> name, Local<Data> value,
6301  PropertyAttribute attributes = None);
6302  V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value);
6303 
6304  void SetAccessorProperty(
6305  Local<Name> name,
6308  PropertyAttribute attribute = None,
6309  AccessControl settings = DEFAULT);
6310 
6311  /**
6312  * Whenever the property with the given name is accessed on objects
6313  * created from this Template the getter and setter callbacks
6314  * are called instead of getting and setting the property directly
6315  * on the JavaScript object.
6316  *
6317  * \param name The name of the property for which an accessor is added.
6318  * \param getter The callback to invoke when getting the property.
6319  * \param setter The callback to invoke when setting the property.
6320  * \param data A piece of data that will be passed to the getter and setter
6321  * callbacks whenever they are invoked.
6322  * \param settings Access control settings for the accessor. This is a bit
6323  * field consisting of one of more of
6324  * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
6325  * The default is to not allow cross-context access.
6326  * ALL_CAN_READ means that all cross-context reads are allowed.
6327  * ALL_CAN_WRITE means that all cross-context writes are allowed.
6328  * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
6329  * cross-context access.
6330  * \param attribute The attributes of the property for which an accessor
6331  * is added.
6332  * \param signature The signature describes valid receivers for the accessor
6333  * and is used to perform implicit instance checks against them. If the
6334  * receiver is incompatible (i.e. is not an instance of the constructor as
6335  * defined by FunctionTemplate::HasInstance()), an implicit TypeError is
6336  * thrown and no callback is invoked.
6337  */
6338  void SetNativeDataProperty(
6339  Local<String> name, AccessorGetterCallback getter,
6340  AccessorSetterCallback setter = nullptr,
6341  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
6343  AccessControl settings = DEFAULT,
6344  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
6345  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
6346  void SetNativeDataProperty(
6347  Local<Name> name, AccessorNameGetterCallback getter,
6348  AccessorNameSetterCallback setter = nullptr,
6349  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
6351  AccessControl settings = DEFAULT,
6352  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
6353  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
6354 
6355  /**
6356  * Like SetNativeDataProperty, but V8 will replace the native data property
6357  * with a real data property on first access.
6358  */
6359  void SetLazyDataProperty(
6360  Local<Name> name, AccessorNameGetterCallback getter,
6361  Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
6362  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
6363  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
6364 
6365  /**
6366  * During template instantiation, sets the value with the intrinsic property
6367  * from the correct context.
6368  */
6369  void SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
6370  PropertyAttribute attribute = None);
6371 
6372  private:
6373  Template();
6374 
6375  friend class ObjectTemplate;
6376  friend class FunctionTemplate;
6377 };
6378 
6379 // TODO(dcarney): Replace GenericNamedPropertyFooCallback with just
6380 // NamedPropertyFooCallback.
6381 
6382 /**
6383  * Interceptor for get requests on an object.
6384  *
6385  * Use `info.GetReturnValue().Set()` to set the return value of the
6386  * intercepted get request.
6387  *
6388  * \param property The name of the property for which the request was
6389  * intercepted.
6390  * \param info Information about the intercepted request, such as
6391  * isolate, receiver, return value, or whether running in `'use strict`' mode.
6392  * See `PropertyCallbackInfo`.
6393  *
6394  * \code
6395  * void GetterCallback(
6396  * Local<Name> name,
6397  * const v8::PropertyCallbackInfo<v8::Value>& info) {
6398  * info.GetReturnValue().Set(v8_num(42));
6399  * }
6400  *
6401  * v8::Local<v8::FunctionTemplate> templ =
6402  * v8::FunctionTemplate::New(isolate);
6403  * templ->InstanceTemplate()->SetHandler(
6404  * v8::NamedPropertyHandlerConfiguration(GetterCallback));
6405  * LocalContext env;
6406  * env->Global()
6407  * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
6408  * .ToLocalChecked()
6409  * ->NewInstance(env.local())
6410  * .ToLocalChecked())
6411  * .FromJust();
6412  * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a");
6413  * CHECK(v8_num(42)->Equals(env.local(), result).FromJust());
6414  * \endcode
6415  *
6416  * See also `ObjectTemplate::SetHandler`.
6417  */
6418 using GenericNamedPropertyGetterCallback =
6419  void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
6420 
6421 /**
6422  * Interceptor for set requests on an object.
6423  *
6424  * Use `info.GetReturnValue()` to indicate whether the request was intercepted
6425  * or not. If the setter successfully intercepts the request, i.e., if the
6426  * request should not be further executed, call
6427  * `info.GetReturnValue().Set(value)`. If the setter
6428  * did not intercept the request, i.e., if the request should be handled as
6429  * if no interceptor is present, do not not call `Set()`.
6430  *
6431  * \param property The name of the property for which the request was
6432  * intercepted.
6433  * \param value The value which the property will have if the request
6434  * is not intercepted.
6435  * \param info Information about the intercepted request, such as
6436  * isolate, receiver, return value, or whether running in `'use strict'` mode.
6437  * See `PropertyCallbackInfo`.
6438  *
6439  * See also
6440  * `ObjectTemplate::SetHandler.`
6441  */
6442 using GenericNamedPropertySetterCallback =
6443  void (*)(Local<Name> property, Local<Value> value,
6445 
6446 /**
6447  * Intercepts all requests that query the attributes of the
6448  * property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and
6449  * defineProperty().
6450  *
6451  * Use `info.GetReturnValue().Set(value)` to set the property attributes. The
6452  * value is an integer encoding a `v8::PropertyAttribute`.
6453  *
6454  * \param property The name of the property for which the request was
6455  * intercepted.
6456  * \param info Information about the intercepted request, such as
6457  * isolate, receiver, return value, or whether running in `'use strict'` mode.
6458  * See `PropertyCallbackInfo`.
6459  *
6460  * \note Some functions query the property attributes internally, even though
6461  * they do not return the attributes. For example, `hasOwnProperty()` can
6462  * trigger this interceptor depending on the state of the object.
6463  *
6464  * See also
6465  * `ObjectTemplate::SetHandler.`
6466  */
6467 using GenericNamedPropertyQueryCallback =
6468  void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
6469 
6470 /**
6471  * Interceptor for delete requests on an object.
6472  *
6473  * Use `info.GetReturnValue()` to indicate whether the request was intercepted
6474  * or not. If the deleter successfully intercepts the request, i.e., if the
6475  * request should not be further executed, call
6476  * `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is
6477  * used as the return value of `delete`.
6478  *
6479  * \param property The name of the property for which the request was
6480  * intercepted.
6481  * \param info Information about the intercepted request, such as
6482  * isolate, receiver, return value, or whether running in `'use strict'` mode.
6483  * See `PropertyCallbackInfo`.
6484  *
6485  * \note If you need to mimic the behavior of `delete`, i.e., throw in strict
6486  * mode instead of returning false, use `info.ShouldThrowOnError()` to determine
6487  * if you are in strict mode.
6488  *
6489  * See also `ObjectTemplate::SetHandler.`
6490  */
6491 using GenericNamedPropertyDeleterCallback =
6492  void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
6493 
6494 /**
6495  * Returns an array containing the names of the properties the named
6496  * property getter intercepts.
6497  *
6498  * Note: The values in the array must be of type v8::Name.
6499  */
6500 using GenericNamedPropertyEnumeratorCallback =
6501  void (*)(const PropertyCallbackInfo<Array>& info);
6502 
6503 /**
6504  * Interceptor for defineProperty requests on an object.
6505  *
6506  * Use `info.GetReturnValue()` to indicate whether the request was intercepted
6507  * or not. If the definer successfully intercepts the request, i.e., if the
6508  * request should not be further executed, call
6509  * `info.GetReturnValue().Set(value)`. If the definer
6510  * did not intercept the request, i.e., if the request should be handled as
6511  * if no interceptor is present, do not not call `Set()`.
6512  *
6513  * \param property The name of the property for which the request was
6514  * intercepted.
6515  * \param desc The property descriptor which is used to define the
6516  * property if the request is not intercepted.
6517  * \param info Information about the intercepted request, such as
6518  * isolate, receiver, return value, or whether running in `'use strict'` mode.
6519  * See `PropertyCallbackInfo`.
6520  *
6521  * See also `ObjectTemplate::SetHandler`.
6522  */
6523 using GenericNamedPropertyDefinerCallback =
6524  void (*)(Local<Name> property, const PropertyDescriptor& desc,
6526 
6527 /**
6528  * Interceptor for getOwnPropertyDescriptor requests on an object.
6529  *
6530  * Use `info.GetReturnValue().Set()` to set the return value of the
6531  * intercepted request. The return value must be an object that
6532  * can be converted to a PropertyDescriptor, e.g., a `v8::value` returned from
6533  * `v8::Object::getOwnPropertyDescriptor`.
6534  *
6535  * \param property The name of the property for which the request was
6536  * intercepted.
6537  * \info Information about the intercepted request, such as
6538  * isolate, receiver, return value, or whether running in `'use strict'` mode.
6539  * See `PropertyCallbackInfo`.
6540  *
6541  * \note If GetOwnPropertyDescriptor is intercepted, it will
6542  * always return true, i.e., indicate that the property was found.
6543  *
6544  * See also `ObjectTemplate::SetHandler`.
6545  */
6546 using GenericNamedPropertyDescriptorCallback =
6547  void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
6548 
6549 /**
6550  * See `v8::GenericNamedPropertyGetterCallback`.
6551  */
6552 using IndexedPropertyGetterCallback =
6553  void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
6554 
6555 /**
6556  * See `v8::GenericNamedPropertySetterCallback`.
6557  */
6558 using IndexedPropertySetterCallback =
6559  void (*)(uint32_t index, Local<Value> value,
6561 
6562 /**
6563  * See `v8::GenericNamedPropertyQueryCallback`.
6564  */
6565 using IndexedPropertyQueryCallback =
6566  void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
6567 
6568 /**
6569  * See `v8::GenericNamedPropertyDeleterCallback`.
6570  */
6571 using IndexedPropertyDeleterCallback =
6572  void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
6573 
6574 /**
6575  * Returns an array containing the indices of the properties the indexed
6576  * property getter intercepts.
6577  *
6578  * Note: The values in the array must be uint32_t.
6579  */
6580 using IndexedPropertyEnumeratorCallback =
6581  void (*)(const PropertyCallbackInfo<Array>& info);
6582 
6583 /**
6584  * See `v8::GenericNamedPropertyDefinerCallback`.
6585  */
6586 using IndexedPropertyDefinerCallback =
6587  void (*)(uint32_t index, const PropertyDescriptor& desc,
6589 
6590 /**
6591  * See `v8::GenericNamedPropertyDescriptorCallback`.
6592  */
6593 using IndexedPropertyDescriptorCallback =
6594  void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
6595 
6596 /**
6597  * Access type specification.
6598  */
6605 };
6606 
6607 
6608 /**
6609  * Returns true if the given context should be allowed to access the given
6610  * object.
6611  */
6612 using AccessCheckCallback = bool (*)(Local<Context> accessing_context,
6613  Local<Object> accessed_object,
6614  Local<Value> data);
6615 
6616 /**
6617  * A FunctionTemplate is used to create functions at runtime. There
6618  * can only be one function created from a FunctionTemplate in a
6619  * context. The lifetime of the created function is equal to the
6620  * lifetime of the context. So in case the embedder needs to create
6621  * temporary functions that can be collected using Scripts is
6622  * preferred.
6623  *
6624  * Any modification of a FunctionTemplate after first instantiation will trigger
6625  * a crash.
6626  *
6627  * A FunctionTemplate can have properties, these properties are added to the
6628  * function object when it is created.
6629  *
6630  * A FunctionTemplate has a corresponding instance template which is
6631  * used to create object instances when the function is used as a
6632  * constructor. Properties added to the instance template are added to
6633  * each object instance.
6634  *
6635  * A FunctionTemplate can have a prototype template. The prototype template
6636  * is used to create the prototype object of the function.
6637  *
6638  * The following example shows how to use a FunctionTemplate:
6639  *
6640  * \code
6641  * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
6642  * t->Set(isolate, "func_property", v8::Number::New(isolate, 1));
6643  *
6644  * v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
6645  * proto_t->Set(isolate,
6646  * "proto_method",
6647  * v8::FunctionTemplate::New(isolate, InvokeCallback));
6648  * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2));
6649  *
6650  * v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
6651  * instance_t->SetAccessor(
6652  String::NewFromUtf8Literal(isolate, "instance_accessor"),
6653  * InstanceAccessorCallback);
6654  * instance_t->SetHandler(
6655  * NamedPropertyHandlerConfiguration(PropertyHandlerCallback));
6656  * instance_t->Set(String::NewFromUtf8Literal(isolate, "instance_property"),
6657  * Number::New(isolate, 3));
6658  *
6659  * v8::Local<v8::Function> function = t->GetFunction();
6660  * v8::Local<v8::Object> instance = function->NewInstance();
6661  * \endcode
6662  *
6663  * Let's use "function" as the JS variable name of the function object
6664  * and "instance" for the instance object created above. The function
6665  * and the instance will have the following properties:
6666  *
6667  * \code
6668  * func_property in function == true;
6669  * function.func_property == 1;
6670  *
6671  * function.prototype.proto_method() invokes 'InvokeCallback'
6672  * function.prototype.proto_const == 2;
6673  *
6674  * instance instanceof function == true;
6675  * instance.instance_accessor calls 'InstanceAccessorCallback'
6676  * instance.instance_property == 3;
6677  * \endcode
6678  *
6679  * A FunctionTemplate can inherit from another one by calling the
6680  * FunctionTemplate::Inherit method. The following graph illustrates
6681  * the semantics of inheritance:
6682  *
6683  * \code
6684  * FunctionTemplate Parent -> Parent() . prototype -> { }
6685  * ^ ^
6686  * | Inherit(Parent) | .__proto__
6687  * | |
6688  * FunctionTemplate Child -> Child() . prototype -> { }
6689  * \endcode
6690  *
6691  * A FunctionTemplate 'Child' inherits from 'Parent', the prototype
6692  * object of the Child() function has __proto__ pointing to the
6693  * Parent() function's prototype object. An instance of the Child
6694  * function has all properties on Parent's instance templates.
6695  *
6696  * Let Parent be the FunctionTemplate initialized in the previous
6697  * section and create a Child FunctionTemplate by:
6698  *
6699  * \code
6700  * Local<FunctionTemplate> parent = t;
6701  * Local<FunctionTemplate> child = FunctionTemplate::New();
6702  * child->Inherit(parent);
6703  *
6704  * Local<Function> child_function = child->GetFunction();
6705  * Local<Object> child_instance = child_function->NewInstance();
6706  * \endcode
6707  *
6708  * The Child function and Child instance will have the following
6709  * properties:
6710  *
6711  * \code
6712  * child_func.prototype.__proto__ == function.prototype;
6713  * child_instance.instance_accessor calls 'InstanceAccessorCallback'
6714  * child_instance.instance_property == 3;
6715  * \endcode
6716  *
6717  * The additional 'c_function' parameter refers to a fast API call, which
6718  * must not trigger GC or JavaScript execution, or call into V8 in other
6719  * ways. For more information how to define them, see
6720  * include/v8-fast-api-calls.h. Please note that this feature is still
6721  * experimental.
6722  */
6724  public:
6725  /** Creates a function template.*/
6726  static Local<FunctionTemplate> New(
6727  Isolate* isolate, FunctionCallback callback = nullptr,
6728  Local<Value> data = Local<Value>(),
6729  Local<Signature> signature = Local<Signature>(), int length = 0,
6732  const CFunction* c_function = nullptr);
6733 
6734  /**
6735  * Creates a function template backed/cached by a private property.
6736  */
6738  Isolate* isolate, FunctionCallback callback,
6739  Local<Private> cache_property, Local<Value> data = Local<Value>(),
6740  Local<Signature> signature = Local<Signature>(), int length = 0,
6741  SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
6742 
6743  /** Returns the unique function instance in the current execution context.*/
6745  Local<Context> context);
6746 
6747  /**
6748  * Similar to Context::NewRemoteContext, this creates an instance that
6749  * isn't backed by an actual object.
6750  *
6751  * The InstanceTemplate of this FunctionTemplate must have access checks with
6752  * handlers installed.
6753  */
6755 
6756  /**
6757  * Set the call-handler callback for a FunctionTemplate. This
6758  * callback is called whenever the function created from this
6759  * FunctionTemplate is called. The 'c_function' represents a fast
6760  * API call, see the comment above the class declaration.
6761  */
6762  void SetCallHandler(
6763  FunctionCallback callback, Local<Value> data = Local<Value>(),
6765  const CFunction* c_function = nullptr);
6766 
6767  /** Set the predefined length property for the FunctionTemplate. */
6768  void SetLength(int length);
6769 
6770  /** Get the InstanceTemplate. */
6772 
6773  /**
6774  * Causes the function template to inherit from a parent function template.
6775  * This means the function's prototype.__proto__ is set to the parent
6776  * function's prototype.
6777  **/
6778  void Inherit(Local<FunctionTemplate> parent);
6779 
6780  /**
6781  * A PrototypeTemplate is the template used to create the prototype object
6782  * of the function created by this template.
6783  */
6785 
6786  /**
6787  * A PrototypeProviderTemplate is another function template whose prototype
6788  * property is used for this template. This is mutually exclusive with setting
6789  * a prototype template indirectly by calling PrototypeTemplate() or using
6790  * Inherit().
6791  **/
6792  void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
6793 
6794  /**
6795  * Set the class name of the FunctionTemplate. This is used for
6796  * printing objects created with the function created from the
6797  * FunctionTemplate as its constructor.
6798  */
6799  void SetClassName(Local<String> name);
6800 
6801 
6802  /**
6803  * When set to true, no access check will be performed on the receiver of a
6804  * function call. Currently defaults to true, but this is subject to change.
6805  */
6806  void SetAcceptAnyReceiver(bool value);
6807 
6808  /**
6809  * Sets the ReadOnly flag in the attributes of the 'prototype' property
6810  * of functions created from this FunctionTemplate to true.
6811  */
6812  void ReadOnlyPrototype();
6813 
6814  /**
6815  * Removes the prototype property from functions created from this
6816  * FunctionTemplate.
6817  */
6818  void RemovePrototype();
6819 
6820  /**
6821  * Returns true if the given object is an instance of this function
6822  * template.
6823  */
6824  bool HasInstance(Local<Value> object);
6825 
6826  V8_INLINE static FunctionTemplate* Cast(Data* data);
6827 
6828  private:
6829  FunctionTemplate();
6830 
6831  static void CheckCast(Data* that);
6832  friend class Context;
6833  friend class ObjectTemplate;
6834 };
6835 
6836 /**
6837  * Configuration flags for v8::NamedPropertyHandlerConfiguration or
6838  * v8::IndexedPropertyHandlerConfiguration.
6839  */
6841  /**
6842  * None.
6843  */
6844  kNone = 0,
6845 
6846  /**
6847  * See ALL_CAN_READ above.
6848  */
6849  kAllCanRead = 1,
6850 
6851  /** Will not call into interceptor for properties on the receiver or prototype
6852  * chain, i.e., only call into interceptor for properties that do not exist.
6853  * Currently only valid for named interceptors.
6854  */
6855  kNonMasking = 1 << 1,
6856 
6857  /**
6858  * Will not call into interceptor for symbol lookup. Only meaningful for
6859  * named interceptors.
6860  */
6861  kOnlyInterceptStrings = 1 << 2,
6862 
6863  /**
6864  * The getter, query, enumerator callbacks do not produce side effects.
6865  */
6866  kHasNoSideEffect = 1 << 3,
6867 };
6868 
6871  GenericNamedPropertyGetterCallback getter,
6872  GenericNamedPropertySetterCallback setter,
6873  GenericNamedPropertyQueryCallback query,
6874  GenericNamedPropertyDeleterCallback deleter,
6875  GenericNamedPropertyEnumeratorCallback enumerator,
6876  GenericNamedPropertyDefinerCallback definer,
6877  GenericNamedPropertyDescriptorCallback descriptor,
6878  Local<Value> data = Local<Value>(),
6880  : getter(getter),
6881  setter(setter),
6882  query(query),
6883  deleter(deleter),
6884  enumerator(enumerator),
6885  definer(definer),
6886  descriptor(descriptor),
6887  data(data),
6888  flags(flags) {}
6889 
6891  /** Note: getter is required */
6892  GenericNamedPropertyGetterCallback getter = nullptr,
6893  GenericNamedPropertySetterCallback setter = nullptr,
6894  GenericNamedPropertyQueryCallback query = nullptr,
6895  GenericNamedPropertyDeleterCallback deleter = nullptr,
6896  GenericNamedPropertyEnumeratorCallback enumerator = nullptr,
6897  Local<Value> data = Local<Value>(),
6899  : getter(getter),
6900  setter(setter),
6901  query(query),
6902  deleter(deleter),
6903  enumerator(enumerator),
6904  definer(nullptr),
6905  descriptor(nullptr),
6906  data(data),
6907  flags(flags) {}
6908 
6910  GenericNamedPropertyGetterCallback getter,
6911  GenericNamedPropertySetterCallback setter,
6912  GenericNamedPropertyDescriptorCallback descriptor,
6913  GenericNamedPropertyDeleterCallback deleter,
6914  GenericNamedPropertyEnumeratorCallback enumerator,
6915  GenericNamedPropertyDefinerCallback definer,
6916  Local<Value> data = Local<Value>(),
6918  : getter(getter),
6919  setter(setter),
6920  query(nullptr),
6921  deleter(deleter),
6922  enumerator(enumerator),
6923  definer(definer),
6924  descriptor(descriptor),
6925  data(data),
6926  flags(flags) {}
6927 
6928  GenericNamedPropertyGetterCallback getter;
6929  GenericNamedPropertySetterCallback setter;
6930  GenericNamedPropertyQueryCallback query;
6931  GenericNamedPropertyDeleterCallback deleter;
6932  GenericNamedPropertyEnumeratorCallback enumerator;
6933  GenericNamedPropertyDefinerCallback definer;
6934  GenericNamedPropertyDescriptorCallback descriptor;
6937 };
6938 
6939 
6942  IndexedPropertyGetterCallback getter,
6943  IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query,
6944  IndexedPropertyDeleterCallback deleter,
6945  IndexedPropertyEnumeratorCallback enumerator,
6946  IndexedPropertyDefinerCallback definer,
6947  IndexedPropertyDescriptorCallback descriptor,
6948  Local<Value> data = Local<Value>(),
6950  : getter(getter),
6951  setter(setter),
6952  query(query),
6953  deleter(deleter),
6954  enumerator(enumerator),
6955  definer(definer),
6956  descriptor(descriptor),
6957  data(data),
6958  flags(flags) {}
6959 
6961  /** Note: getter is required */
6962  IndexedPropertyGetterCallback getter = nullptr,
6963  IndexedPropertySetterCallback setter = nullptr,
6964  IndexedPropertyQueryCallback query = nullptr,
6965  IndexedPropertyDeleterCallback deleter = nullptr,
6966  IndexedPropertyEnumeratorCallback enumerator = nullptr,
6967  Local<Value> data = Local<Value>(),
6969  : getter(getter),
6970  setter(setter),
6971  query(query),
6972  deleter(deleter),
6973  enumerator(enumerator),
6974  definer(nullptr),
6975  descriptor(nullptr),
6976  data(data),
6977  flags(flags) {}
6978 
6980  IndexedPropertyGetterCallback getter,
6981  IndexedPropertySetterCallback setter,
6982  IndexedPropertyDescriptorCallback descriptor,
6983  IndexedPropertyDeleterCallback deleter,
6984  IndexedPropertyEnumeratorCallback enumerator,
6985  IndexedPropertyDefinerCallback definer,
6986  Local<Value> data = Local<Value>(),
6988  : getter(getter),
6989  setter(setter),
6990  query(nullptr),
6991  deleter(deleter),
6992  enumerator(enumerator),
6993  definer(definer),
6994  descriptor(descriptor),
6995  data(data),
6996  flags(flags) {}
6997 
6998  IndexedPropertyGetterCallback getter;
6999  IndexedPropertySetterCallback setter;
7000  IndexedPropertyQueryCallback query;
7001  IndexedPropertyDeleterCallback deleter;
7002  IndexedPropertyEnumeratorCallback enumerator;
7003  IndexedPropertyDefinerCallback definer;
7004  IndexedPropertyDescriptorCallback descriptor;
7007 };
7008 
7009 
7010 /**
7011  * An ObjectTemplate is used to create objects at runtime.
7012  *
7013  * Properties added to an ObjectTemplate are added to each object
7014  * created from the ObjectTemplate.
7015  */
7017  public:
7018  /** Creates an ObjectTemplate. */
7019  static Local<ObjectTemplate> New(
7020  Isolate* isolate,
7022 
7023  /** Creates a new instance of this template.*/
7025 
7026  /**
7027  * Sets an accessor on the object template.
7028  *
7029  * Whenever the property with the given name is accessed on objects
7030  * created from this ObjectTemplate the getter and setter callbacks
7031  * are called instead of getting and setting the property directly
7032  * on the JavaScript object.
7033  *
7034  * \param name The name of the property for which an accessor is added.
7035  * \param getter The callback to invoke when getting the property.
7036  * \param setter The callback to invoke when setting the property.
7037  * \param data A piece of data that will be passed to the getter and setter
7038  * callbacks whenever they are invoked.
7039  * \param settings Access control settings for the accessor. This is a bit
7040  * field consisting of one of more of
7041  * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
7042  * The default is to not allow cross-context access.
7043  * ALL_CAN_READ means that all cross-context reads are allowed.
7044  * ALL_CAN_WRITE means that all cross-context writes are allowed.
7045  * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
7046  * cross-context access.
7047  * \param attribute The attributes of the property for which an accessor
7048  * is added.
7049  * \param signature The signature describes valid receivers for the accessor
7050  * and is used to perform implicit instance checks against them. If the
7051  * receiver is incompatible (i.e. is not an instance of the constructor as
7052  * defined by FunctionTemplate::HasInstance()), an implicit TypeError is
7053  * thrown and no callback is invoked.
7054  */
7055  void SetAccessor(
7056  Local<String> name, AccessorGetterCallback getter,
7057  AccessorSetterCallback setter = nullptr,
7058  Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
7059  PropertyAttribute attribute = None,
7061  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
7062  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
7063  void SetAccessor(
7064  Local<Name> name, AccessorNameGetterCallback getter,
7065  AccessorNameSetterCallback setter = nullptr,
7066  Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
7067  PropertyAttribute attribute = None,
7069  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
7070  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
7071 
7072  /**
7073  * Sets a named property handler on the object template.
7074  *
7075  * Whenever a property whose name is a string or a symbol is accessed on
7076  * objects created from this object template, the provided callback is
7077  * invoked instead of accessing the property directly on the JavaScript
7078  * object.
7079  *
7080  * @param configuration The NamedPropertyHandlerConfiguration that defines the
7081  * callbacks to invoke when accessing a property.
7082  */
7083  void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
7084 
7085  /**
7086  * Sets an indexed property handler on the object template.
7087  *
7088  * Whenever an indexed property is accessed on objects created from
7089  * this object template, the provided callback is invoked instead of
7090  * accessing the property directly on the JavaScript object.
7091  *
7092  * \param getter The callback to invoke when getting a property.
7093  * \param setter The callback to invoke when setting a property.
7094  * \param query The callback to invoke to check if an object has a property.
7095  * \param deleter The callback to invoke when deleting a property.
7096  * \param enumerator The callback to invoke to enumerate all the indexed
7097  * properties of an object.
7098  * \param data A piece of data that will be passed to the callbacks
7099  * whenever they are invoked.
7100  */
7101  // TODO(dcarney): deprecate
7103  IndexedPropertyGetterCallback getter,
7104  IndexedPropertySetterCallback setter = nullptr,
7105  IndexedPropertyQueryCallback query = nullptr,
7106  IndexedPropertyDeleterCallback deleter = nullptr,
7107  IndexedPropertyEnumeratorCallback enumerator = nullptr,
7108  Local<Value> data = Local<Value>()) {
7110  deleter, enumerator, data));
7111  }
7112 
7113  /**
7114  * Sets an indexed property handler on the object template.
7115  *
7116  * Whenever an indexed property is accessed on objects created from
7117  * this object template, the provided callback is invoked instead of
7118  * accessing the property directly on the JavaScript object.
7119  *
7120  * @param configuration The IndexedPropertyHandlerConfiguration that defines
7121  * the callbacks to invoke when accessing a property.
7122  */
7123  void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
7124 
7125  /**
7126  * Sets the callback to be used when calling instances created from
7127  * this template as a function. If no callback is set, instances
7128  * behave like normal JavaScript objects that cannot be called as a
7129  * function.
7130  */
7131  void SetCallAsFunctionHandler(FunctionCallback callback,
7132  Local<Value> data = Local<Value>());
7133 
7134  /**
7135  * Mark object instances of the template as undetectable.
7136  *
7137  * In many ways, undetectable objects behave as though they are not
7138  * there. They behave like 'undefined' in conditionals and when
7139  * printed. However, properties can be accessed and called as on
7140  * normal objects.
7141  */
7142  void MarkAsUndetectable();
7143 
7144  /**
7145  * Sets access check callback on the object template and enables access
7146  * checks.
7147  *
7148  * When accessing properties on instances of this object template,
7149  * the access check callback will be called to determine whether or
7150  * not to allow cross-context access to the properties.
7151  */
7152  void SetAccessCheckCallback(AccessCheckCallback callback,
7153  Local<Value> data = Local<Value>());
7154 
7155  /**
7156  * Like SetAccessCheckCallback but invokes an interceptor on failed access
7157  * checks instead of looking up all-can-read properties. You can only use
7158  * either this method or SetAccessCheckCallback, but not both at the same
7159  * time.
7160  */
7162  AccessCheckCallback callback,
7163  const NamedPropertyHandlerConfiguration& named_handler,
7164  const IndexedPropertyHandlerConfiguration& indexed_handler,
7165  Local<Value> data = Local<Value>());
7166 
7167  /**
7168  * Gets the number of internal fields for objects generated from
7169  * this template.
7170  */
7171  int InternalFieldCount();
7172 
7173  /**
7174  * Sets the number of internal fields for objects generated from
7175  * this template.
7176  */
7177  void SetInternalFieldCount(int value);
7178 
7179  /**
7180  * Returns true if the object will be an immutable prototype exotic object.
7181  */
7182  bool IsImmutableProto();
7183 
7184  /**
7185  * Makes the ObjectTemplate for an immutable prototype exotic object, with an
7186  * immutable __proto__.
7187  */
7188  void SetImmutableProto();
7189 
7190  /**
7191  * Support for TC39 "dynamic code brand checks" proposal.
7192  *
7193  * This API allows to mark (& query) objects as "code like", which causes
7194  * them to be treated like Strings in the context of eval and function
7195  * constructor.
7196  *
7197  * Reference: https://github.com/tc39/proposal-dynamic-code-brand-checks
7198  */
7199  void SetCodeLike();
7200  bool IsCodeLike();
7201 
7202  V8_INLINE static ObjectTemplate* Cast(Data* data);
7203 
7204  private:
7205  ObjectTemplate();
7206  static Local<ObjectTemplate> New(internal::Isolate* isolate,
7207  Local<FunctionTemplate> constructor);
7208  static void CheckCast(Data* that);
7209  friend class FunctionTemplate;
7210 };
7211 
7212 /**
7213  * A Signature specifies which receiver is valid for a function.
7214  *
7215  * A receiver matches a given signature if the receiver (or any of its
7216  * hidden prototypes) was created from the signature's FunctionTemplate, or
7217  * from a FunctionTemplate that inherits directly or indirectly from the
7218  * signature's FunctionTemplate.
7219  */
7220 class V8_EXPORT Signature : public Data {
7221  public:
7222  static Local<Signature> New(
7223  Isolate* isolate,
7225 
7226  V8_INLINE static Signature* Cast(Data* data);
7227 
7228  private:
7229  Signature();
7230 
7231  static void CheckCast(Data* that);
7232 };
7233 
7234 
7235 /**
7236  * An AccessorSignature specifies which receivers are valid parameters
7237  * to an accessor callback.
7238  */
7240  public:
7241  static Local<AccessorSignature> New(
7242  Isolate* isolate,
7244 
7245  V8_INLINE static AccessorSignature* Cast(Data* data);
7246 
7247  private:
7248  AccessorSignature();
7249 
7250  static void CheckCast(Data* that);
7251 };
7252 
7253 
7254 // --- Extensions ---
7255 
7256 /**
7257  * Ignore
7258  */
7259 class V8_EXPORT Extension { // NOLINT
7260  public:
7261  // Note that the strings passed into this constructor must live as long
7262  // as the Extension itself.
7263  Extension(const char* name, const char* source = nullptr, int dep_count = 0,
7264  const char** deps = nullptr, int source_length = -1);
7265  virtual ~Extension() { delete source_; }
7267  Isolate* isolate, Local<String> name) {
7269  }
7270 
7271  const char* name() const { return name_; }
7272  size_t source_length() const { return source_length_; }
7274  return source_;
7275  }
7276  int dependency_count() const { return dep_count_; }
7277  const char** dependencies() const { return deps_; }
7278  void set_auto_enable(bool value) { auto_enable_ = value; }
7279  bool auto_enable() { return auto_enable_; }
7280 
7281  // Disallow copying and assigning.
7282  Extension(const Extension&) = delete;
7283  void operator=(const Extension&) = delete;
7284 
7285  private:
7286  const char* name_;
7287  size_t source_length_; // expected to initialize before source_
7289  int dep_count_;
7290  const char** deps_;
7291  bool auto_enable_;
7292 };
7293 
7294 void V8_EXPORT RegisterExtension(std::unique_ptr<Extension>);
7295 
7296 // --- Statics ---
7297 
7299 V8_INLINE Local<Primitive> Null(Isolate* isolate);
7300 V8_INLINE Local<Boolean> True(Isolate* isolate);
7301 V8_INLINE Local<Boolean> False(Isolate* isolate);
7302 
7303 /**
7304  * A set of constraints that specifies the limits of the runtime's memory use.
7305  * You must set the heap size before initializing the VM - the size cannot be
7306  * adjusted after the VM is initialized.
7307  *
7308  * If you are using threads then you should hold the V8::Locker lock while
7309  * setting the stack limit and you must set a non-default stack limit separately
7310  * for each thread.
7311  *
7312  * The arguments for set_max_semi_space_size, set_max_old_space_size,
7313  * set_max_executable_size, set_code_range_size specify limits in MB.
7314  *
7315  * The argument for set_max_semi_space_size_in_kb is in KB.
7316  */
7318  public:
7319  /**
7320  * Configures the constraints with reasonable default values based on the
7321  * provided heap size limit. The heap size includes both the young and
7322  * the old generation.
7323  *
7324  * \param initial_heap_size_in_bytes The initial heap size or zero.
7325  * By default V8 starts with a small heap and dynamically grows it to
7326  * match the set of live objects. This may lead to ineffective
7327  * garbage collections at startup if the live set is large.
7328  * Setting the initial heap size avoids such garbage collections.
7329  * Note that this does not affect young generation garbage collections.
7330  *
7331  * \param maximum_heap_size_in_bytes The hard limit for the heap size.
7332  * When the heap size approaches this limit, V8 will perform series of
7333  * garbage collections and invoke the NearHeapLimitCallback. If the garbage
7334  * collections do not help and the callback does not increase the limit,
7335  * then V8 will crash with V8::FatalProcessOutOfMemory.
7336  */
7337  void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes,
7338  size_t maximum_heap_size_in_bytes);
7339 
7340  /**
7341  * Configures the constraints with reasonable default values based on the
7342  * capabilities of the current device the VM is running on.
7343  *
7344  * \param physical_memory The total amount of physical memory on the current
7345  * device, in bytes.
7346  * \param virtual_memory_limit The amount of virtual memory on the current
7347  * device, in bytes, or zero, if there is no limit.
7348  */
7349  void ConfigureDefaults(uint64_t physical_memory,
7350  uint64_t virtual_memory_limit);
7351 
7352  /**
7353  * The address beyond which the VM's stack may not grow.
7354  */
7355  uint32_t* stack_limit() const { return stack_limit_; }
7356  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
7357 
7358  /**
7359  * The amount of virtual memory reserved for generated code. This is relevant
7360  * for 64-bit architectures that rely on code range for calls in code.
7361  */
7362  size_t code_range_size_in_bytes() const { return code_range_size_; }
7363  void set_code_range_size_in_bytes(size_t limit) { code_range_size_ = limit; }
7364 
7365  /**
7366  * The maximum size of the old generation.
7367  * When the old generation approaches this limit, V8 will perform series of
7368  * garbage collections and invoke the NearHeapLimitCallback.
7369  * If the garbage collections do not help and the callback does not
7370  * increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory.
7371  */
7373  return max_old_generation_size_;
7374  }
7376  max_old_generation_size_ = limit;
7377  }
7378 
7379  /**
7380  * The maximum size of the young generation, which consists of two semi-spaces
7381  * and a large object space. This affects frequency of Scavenge garbage
7382  * collections and should be typically much smaller that the old generation.
7383  */
7385  return max_young_generation_size_;
7386  }
7388  max_young_generation_size_ = limit;
7389  }
7390 
7392  return initial_old_generation_size_;
7393  }
7394  void set_initial_old_generation_size_in_bytes(size_t initial_size) {
7395  initial_old_generation_size_ = initial_size;
7396  }
7397 
7399  return initial_young_generation_size_;
7400  }
7402  initial_young_generation_size_ = initial_size;
7403  }
7404 
7405  private:
7406  static constexpr size_t kMB = 1048576u;
7407  size_t code_range_size_ = 0;
7408  size_t max_old_generation_size_ = 0;
7409  size_t max_young_generation_size_ = 0;
7410  size_t initial_old_generation_size_ = 0;
7411  size_t initial_young_generation_size_ = 0;
7412  uint32_t* stack_limit_ = nullptr;
7413 };
7414 
7415 
7416 // --- Exceptions ---
7417 
7418 using FatalErrorCallback = void (*)(const char* location, const char* message);
7419 
7420 using OOMErrorCallback = void (*)(const char* location, bool is_heap_oom);
7421 
7422 using DcheckErrorCallback = void (*)(const char* file, int line,
7423  const char* message);
7424 
7425 using MessageCallback = void (*)(Local<Message> message, Local<Value> data);
7426 
7427 // --- Tracing ---
7428 
7429 using LogEventCallback = void (*)(const char* name, int event);
7430 
7431 /**
7432  * Create new error objects by calling the corresponding error object
7433  * constructor with the message.
7434  */
7436  public:
7437  static Local<Value> RangeError(Local<String> message);
7438  static Local<Value> ReferenceError(Local<String> message);
7439  static Local<Value> SyntaxError(Local<String> message);
7440  static Local<Value> TypeError(Local<String> message);
7441  static Local<Value> WasmCompileError(Local<String> message);
7442  static Local<Value> WasmLinkError(Local<String> message);
7443  static Local<Value> WasmRuntimeError(Local<String> message);
7444  static Local<Value> Error(Local<String> message);
7445 
7446  /**
7447  * Creates an error message for the given exception.
7448  * Will try to reconstruct the original stack trace from the exception value,
7449  * or capture the current stack trace if not available.
7450  */
7451  static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
7452 
7453  /**
7454  * Returns the original stack trace that was captured at the creation time
7455  * of a given exception, or an empty handle if not available.
7456  */
7457  static Local<StackTrace> GetStackTrace(Local<Value> exception);
7458 };
7459 
7460 
7461 // --- Counters Callbacks ---
7462 
7463 using CounterLookupCallback = int* (*)(const char* name);
7464 
7465 using CreateHistogramCallback = void* (*)(const char* name, int min, int max,
7466  size_t buckets);
7467 
7468 using AddHistogramSampleCallback = void (*)(void* histogram, int sample);
7469 
7470 // --- Crashkeys Callback ---
7471 enum class CrashKeyId {
7476  kDumpType,
7477 };
7478 
7479 using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value);
7480 
7481 // --- Enter/Leave Script Callback ---
7482 using BeforeCallEnteredCallback = void (*)(Isolate*);
7483 using CallCompletedCallback = void (*)(Isolate*);
7484 
7485 /**
7486  * HostImportModuleDynamicallyCallback is called when we require the
7487  * embedder to load a module. This is used as part of the dynamic
7488  * import syntax.
7489  *
7490  * The referrer contains metadata about the script/module that calls
7491  * import.
7492  *
7493  * The specifier is the name of the module that should be imported.
7494  *
7495  * The embedder must compile, instantiate, evaluate the Module, and
7496  * obtain its namespace object.
7497  *
7498  * The Promise returned from this function is forwarded to userland
7499  * JavaScript. The embedder must resolve this promise with the module
7500  * namespace object. In case of an exception, the embedder must reject
7501  * this promise with the exception. If the promise creation itself
7502  * fails (e.g. due to stack overflow), the embedder must propagate
7503  * that exception by returning an empty MaybeLocal.
7504  */
7505 using HostImportModuleDynamicallyCallback V8_DEPRECATE_SOON(
7506  "Use HostImportModuleDynamicallyWithImportAssertionsCallback instead") =
7507  MaybeLocal<Promise> (*)(Local<Context> context,
7508  Local<ScriptOrModule> referrer,
7509  Local<String> specifier);
7510 
7511 /**
7512  * HostImportModuleDynamicallyWithImportAssertionsCallback is called when we
7513  * require the embedder to load a module. This is used as part of the dynamic
7514  * import syntax.
7515  *
7516  * The referrer contains metadata about the script/module that calls
7517  * import.
7518  *
7519  * The specifier is the name of the module that should be imported.
7520  *
7521  * The import_assertions are import assertions for this request in the form:
7522  * [key1, value1, key2, value2, ...] where the keys and values are of type
7523  * v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
7524  * returned from ModuleRequest::GetImportAssertions(), this array does not
7525  * contain the source Locations of the assertions.
7526  *
7527  * The embedder must compile, instantiate, evaluate the Module, and
7528  * obtain its namespace object.
7529  *
7530  * The Promise returned from this function is forwarded to userland
7531  * JavaScript. The embedder must resolve this promise with the module
7532  * namespace object. In case of an exception, the embedder must reject
7533  * this promise with the exception. If the promise creation itself
7534  * fails (e.g. due to stack overflow), the embedder must propagate
7535  * that exception by returning an empty MaybeLocal.
7536  */
7537 using HostImportModuleDynamicallyWithImportAssertionsCallback =
7538  MaybeLocal<Promise> (*)(Local<Context> context,
7539  Local<ScriptOrModule> referrer,
7540  Local<String> specifier,
7541  Local<FixedArray> import_assertions);
7542 
7543 /**
7544  * HostInitializeImportMetaObjectCallback is called the first time import.meta
7545  * is accessed for a module. Subsequent access will reuse the same value.
7546  *
7547  * The method combines two implementation-defined abstract operations into one:
7548  * HostGetImportMetaProperties and HostFinalizeImportMeta.
7549  *
7550  * The embedder should use v8::Object::CreateDataProperty to add properties on
7551  * the meta object.
7552  */
7553 using HostInitializeImportMetaObjectCallback = void (*)(Local<Context> context,
7554  Local<Module> module,
7555  Local<Object> meta);
7556 
7557 /**
7558  * PrepareStackTraceCallback is called when the stack property of an error is
7559  * first accessed. The return value will be used as the stack value. If this
7560  * callback is registed, the |Error.prepareStackTrace| API will be disabled.
7561  * |sites| is an array of call sites, specified in
7562  * https://v8.dev/docs/stack-trace-api
7563  */
7564 using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
7565  Local<Value> error,
7566  Local<Array> sites);
7567 
7568 /**
7569  * PromiseHook with type kInit is called when a new promise is
7570  * created. When a new promise is created as part of the chain in the
7571  * case of Promise.then or in the intermediate promises created by
7572  * Promise.{race, all}/AsyncFunctionAwait, we pass the parent promise
7573  * otherwise we pass undefined.
7574  *
7575  * PromiseHook with type kResolve is called at the beginning of
7576  * resolve or reject function defined by CreateResolvingFunctions.
7577  *
7578  * PromiseHook with type kBefore is called at the beginning of the
7579  * PromiseReactionJob.
7580  *
7581  * PromiseHook with type kAfter is called right at the end of the
7582  * PromiseReactionJob.
7583  */
7585 
7586 using PromiseHook = void (*)(PromiseHookType type, Local<Promise> promise,
7587  Local<Value> parent);
7588 
7589 // --- Promise Reject Callback ---
7595 };
7596 
7598  public:
7600  Local<Value> value)
7601  : promise_(promise), event_(event), value_(value) {}
7602 
7603  V8_INLINE Local<Promise> GetPromise() const { return promise_; }
7604  V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
7605  V8_INLINE Local<Value> GetValue() const { return value_; }
7606 
7607  private:
7608  Local<Promise> promise_;
7609  PromiseRejectEvent event_;
7610  Local<Value> value_;
7611 };
7612 
7613 using PromiseRejectCallback = void (*)(PromiseRejectMessage message);
7614 
7615 // --- Microtasks Callbacks ---
7616 using MicrotasksCompletedCallbackWithData = void (*)(Isolate*, void*);
7617 using MicrotaskCallback = void (*)(void* data);
7618 
7619 /**
7620  * Policy for running microtasks:
7621  * - explicit: microtasks are invoked with the
7622  * Isolate::PerformMicrotaskCheckpoint() method;
7623  * - scoped: microtasks invocation is controlled by MicrotasksScope objects;
7624  * - auto: microtasks are invoked when the script call depth decrements
7625  * to zero.
7626  */
7628 
7629 /**
7630  * Represents the microtask queue, where microtasks are stored and processed.
7631  * https://html.spec.whatwg.org/multipage/webappapis.html#microtask-queue
7632  * https://html.spec.whatwg.org/multipage/webappapis.html#enqueuejob(queuename,-job,-arguments)
7633  * https://html.spec.whatwg.org/multipage/webappapis.html#perform-a-microtask-checkpoint
7634  *
7635  * A MicrotaskQueue instance may be associated to multiple Contexts by passing
7636  * it to Context::New(), and they can be detached by Context::DetachGlobal().
7637  * The embedder must keep the MicrotaskQueue instance alive until all associated
7638  * Contexts are gone or detached.
7639  *
7640  * Use the same instance of MicrotaskQueue for all Contexts that may access each
7641  * other synchronously. E.g. for Web embedding, use the same instance for all
7642  * origins that share the same URL scheme and eTLD+1.
7643  */
7645  public:
7646  /**
7647  * Creates an empty MicrotaskQueue instance.
7648  */
7649  static std::unique_ptr<MicrotaskQueue> New(
7650  Isolate* isolate, MicrotasksPolicy policy = MicrotasksPolicy::kAuto);
7651 
7652  virtual ~MicrotaskQueue() = default;
7653 
7654  /**
7655  * Enqueues the callback to the queue.
7656  */
7657  virtual void EnqueueMicrotask(Isolate* isolate,
7658  Local<Function> microtask) = 0;
7659 
7660  /**
7661  * Enqueues the callback to the queue.
7662  */
7663  virtual void EnqueueMicrotask(v8::Isolate* isolate,
7664  MicrotaskCallback callback,
7665  void* data = nullptr) = 0;
7666 
7667  /**
7668  * Adds a callback to notify the embedder after microtasks were run. The
7669  * callback is triggered by explicit RunMicrotasks call or automatic
7670  * microtasks execution (see Isolate::SetMicrotasksPolicy).
7671  *
7672  * Callback will trigger even if microtasks were attempted to run,
7673  * but the microtasks queue was empty and no single microtask was actually
7674  * executed.
7675  *
7676  * Executing scripts inside the callback will not re-trigger microtasks and
7677  * the callback.
7678  */
7679  virtual void AddMicrotasksCompletedCallback(
7680  MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
7681 
7682  /**
7683  * Removes callback that was installed by AddMicrotasksCompletedCallback.
7684  */
7685  virtual void RemoveMicrotasksCompletedCallback(
7686  MicrotasksCompletedCallbackWithData callback, void* data = nullptr) = 0;
7687 
7688  /**
7689  * Runs microtasks if no microtask is running on this MicrotaskQueue instance.
7690  */
7691  virtual void PerformCheckpoint(Isolate* isolate) = 0;
7692 
7693  /**
7694  * Returns true if a microtask is running on this MicrotaskQueue instance.
7695  */
7696  virtual bool IsRunningMicrotasks() const = 0;
7697 
7698  /**
7699  * Returns the current depth of nested MicrotasksScope that has
7700  * kRunMicrotasks.
7701  */
7702  virtual int GetMicrotasksScopeDepth() const = 0;
7703 
7704  MicrotaskQueue(const MicrotaskQueue&) = delete;
7705  MicrotaskQueue& operator=(const MicrotaskQueue&) = delete;
7706 
7707  private:
7708  friend class internal::MicrotaskQueue;
7709  MicrotaskQueue() = default;
7710 };
7711 
7712 /**
7713  * This scope is used to control microtasks when MicrotasksPolicy::kScoped
7714  * is used on Isolate. In this mode every non-primitive call to V8 should be
7715  * done inside some MicrotasksScope.
7716  * Microtasks are executed when topmost MicrotasksScope marked as kRunMicrotasks
7717  * exits.
7718  * kDoNotRunMicrotasks should be used to annotate calls not intended to trigger
7719  * microtasks.
7720  */
7722  public:
7724 
7725  MicrotasksScope(Isolate* isolate, Type type);
7726  MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
7727  ~MicrotasksScope();
7728 
7729  /**
7730  * Runs microtasks if no kRunMicrotasks scope is currently active.
7731  */
7732  static void PerformCheckpoint(Isolate* isolate);
7733 
7734  /**
7735  * Returns current depth of nested kRunMicrotasks scopes.
7736  */
7737  static int GetCurrentDepth(Isolate* isolate);
7738 
7739  /**
7740  * Returns true while microtasks are being executed.
7741  */
7742  static bool IsRunningMicrotasks(Isolate* isolate);
7743 
7744  // Prevent copying.
7745  MicrotasksScope(const MicrotasksScope&) = delete;
7746  MicrotasksScope& operator=(const MicrotasksScope&) = delete;
7747 
7748  private:
7749  internal::Isolate* const isolate_;
7750  internal::MicrotaskQueue* const microtask_queue_;
7751  bool run_;
7752 };
7753 
7754 // --- Failed Access Check Callback ---
7755 using FailedAccessCheckCallback = void (*)(Local<Object> target,
7756  AccessType type, Local<Value> data);
7757 
7758 // --- AllowCodeGenerationFromStrings callbacks ---
7759 
7760 /**
7761  * Callback to check if code generation from strings is allowed. See
7762  * Context::AllowCodeGenerationFromStrings.
7763  */
7764 using AllowCodeGenerationFromStringsCallback = bool (*)(Local<Context> context,
7765  Local<String> source);
7766 
7768  // If true, proceed with the codegen algorithm. Otherwise, block it.
7769  bool codegen_allowed = false;
7770  // Overwrite the original source with this string, if present.
7771  // Use the original source if empty.
7772  // This field is considered only if codegen_allowed is true.
7774 };
7775 
7776 /**
7777  * Callback to check if codegen is allowed from a source object, and convert
7778  * the source to string if necessary. See: ModifyCodeGenerationFromStrings.
7779  */
7780 using ModifyCodeGenerationFromStringsCallback =
7782  Local<Value> source);
7783 using ModifyCodeGenerationFromStringsCallback2 =
7785  Local<Value> source,
7786  bool is_code_like);
7787 
7788 // --- WebAssembly compilation callbacks ---
7789 using ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&);
7790 
7791 using AllowWasmCodeGenerationCallback = bool (*)(Local<Context> context,
7792  Local<String> source);
7793 
7794 // --- Callback for APIs defined on v8-supported objects, but implemented
7795 // by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
7796 using ApiImplementationCallback = void (*)(const FunctionCallbackInfo<Value>&);
7797 
7798 // --- Callback for WebAssembly.compileStreaming ---
7799 using WasmStreamingCallback = void (*)(const FunctionCallbackInfo<Value>&);
7800 
7801 // --- Callback for loading source map file for Wasm profiling support
7802 using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
7803  const char* name);
7804 
7805 // --- Callback for checking if WebAssembly Simd is enabled ---
7806 using WasmSimdEnabledCallback = bool (*)(Local<Context> context);
7807 
7808 // --- Callback for checking if WebAssembly exceptions are enabled ---
7809 using WasmExceptionsEnabledCallback = bool (*)(Local<Context> context);
7810 
7811 // --- Garbage Collection Callbacks ---
7812 
7813 /**
7814  * Applications can register callback functions which will be called before and
7815  * after certain garbage collection operations. Allocations are not allowed in
7816  * the callback functions, you therefore cannot manipulate objects (set or
7817  * delete properties for example) since it is possible such operations will
7818  * result in the allocation of objects.
7819  */
7820 enum GCType {
7827 };
7828 
7829 /**
7830  * GCCallbackFlags is used to notify additional information about the GC
7831  * callback.
7832  * - kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for
7833  * constructing retained object infos.
7834  * - kGCCallbackFlagForced: The GC callback is for a forced GC for testing.
7835  * - kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback
7836  * is called synchronously without getting posted to an idle task.
7837  * - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called
7838  * in a phase where V8 is trying to collect all available garbage
7839  * (e.g., handling a low memory notification).
7840  * - kGCCallbackScheduleIdleGarbageCollection: The GC callback is called to
7841  * trigger an idle garbage collection.
7842  */
7851 };
7852 
7853 using GCCallback = void (*)(GCType type, GCCallbackFlags flags);
7854 
7855 using InterruptCallback = void (*)(Isolate* isolate, void* data);
7856 
7857 /**
7858  * This callback is invoked when the heap size is close to the heap limit and
7859  * V8 is likely to abort with out-of-memory error.
7860  * The callback can extend the heap limit by returning a value that is greater
7861  * than the current_heap_limit. The initial heap limit is the limit that was
7862  * set after heap setup.
7863  */
7864 using NearHeapLimitCallback = size_t (*)(void* data, size_t current_heap_limit,
7865  size_t initial_heap_limit);
7866 
7867 /**
7868  * Collection of shared per-process V8 memory information.
7869  *
7870  * Instances of this class can be passed to
7871  * v8::V8::GetSharedMemoryStatistics to get shared memory statistics from V8.
7872  */
7874  public:
7876  size_t read_only_space_size() { return read_only_space_size_; }
7877  size_t read_only_space_used_size() { return read_only_space_used_size_; }
7879  return read_only_space_physical_size_;
7880  }
7881 
7882  private:
7883  size_t read_only_space_size_;
7884  size_t read_only_space_used_size_;
7885  size_t read_only_space_physical_size_;
7886 
7887  friend class V8;
7888  friend class internal::ReadOnlyHeap;
7889 };
7890 
7891 /**
7892  * Collection of V8 heap information.
7893  *
7894  * Instances of this class can be passed to v8::Isolate::GetHeapStatistics to
7895  * get heap statistics from V8.
7896  */
7898  public:
7899  HeapStatistics();
7900  size_t total_heap_size() { return total_heap_size_; }
7901  size_t total_heap_size_executable() { return total_heap_size_executable_; }
7902  size_t total_physical_size() { return total_physical_size_; }
7903  size_t total_available_size() { return total_available_size_; }
7904  size_t total_global_handles_size() { return total_global_handles_size_; }
7905  size_t used_global_handles_size() { return used_global_handles_size_; }
7906  size_t used_heap_size() { return used_heap_size_; }
7907  size_t heap_size_limit() { return heap_size_limit_; }
7908  size_t malloced_memory() { return malloced_memory_; }
7909  size_t external_memory() { return external_memory_; }
7910  size_t peak_malloced_memory() { return peak_malloced_memory_; }
7911  size_t number_of_native_contexts() { return number_of_native_contexts_; }
7912  size_t number_of_detached_contexts() { return number_of_detached_contexts_; }
7913 
7914  /**
7915  * Returns a 0/1 boolean, which signifies whether the V8 overwrite heap
7916  * garbage with a bit pattern.
7917  */
7918  size_t does_zap_garbage() { return does_zap_garbage_; }
7919 
7920  private:
7921  size_t total_heap_size_;
7922  size_t total_heap_size_executable_;
7923  size_t total_physical_size_;
7924  size_t total_available_size_;
7925  size_t used_heap_size_;
7926  size_t heap_size_limit_;
7927  size_t malloced_memory_;
7928  size_t external_memory_;
7929  size_t peak_malloced_memory_;
7930  bool does_zap_garbage_;
7931  size_t number_of_native_contexts_;
7932  size_t number_of_detached_contexts_;
7933  size_t total_global_handles_size_;
7934  size_t used_global_handles_size_;
7935 
7936  friend class V8;
7937  friend class Isolate;
7938 };
7939 
7940 
7942  public:
7944  const char* space_name() { return space_name_; }
7945  size_t space_size() { return space_size_; }
7946  size_t space_used_size() { return space_used_size_; }
7947  size_t space_available_size() { return space_available_size_; }
7948  size_t physical_space_size() { return physical_space_size_; }
7949 
7950  private:
7951  const char* space_name_;
7952  size_t space_size_;
7953  size_t space_used_size_;
7954  size_t space_available_size_;
7955  size_t physical_space_size_;
7956 
7957  friend class Isolate;
7958 };
7959 
7960 
7962  public:
7964  const char* object_type() { return object_type_; }
7965  const char* object_sub_type() { return object_sub_type_; }
7966  size_t object_count() { return object_count_; }
7967  size_t object_size() { return object_size_; }
7968 
7969  private:
7970  const char* object_type_;
7971  const char* object_sub_type_;
7972  size_t object_count_;
7973  size_t object_size_;
7974 
7975  friend class Isolate;
7976 };
7977 
7979  public:
7981  size_t code_and_metadata_size() { return code_and_metadata_size_; }
7982  size_t bytecode_and_metadata_size() { return bytecode_and_metadata_size_; }
7983  size_t external_script_source_size() { return external_script_source_size_; }
7984 
7985  private:
7986  size_t code_and_metadata_size_;
7987  size_t bytecode_and_metadata_size_;
7988  size_t external_script_source_size_;
7989 
7990  friend class Isolate;
7991 };
7992 
7993 /**
7994  * A JIT code event is issued each time code is added, moved or removed.
7995  *
7996  * \note removal events are not currently issued.
7997  */
7999  enum EventType {
8006  };
8007  // Definition of the code position type. The "POSITION" type means the place
8008  // in the source code which are of interest when making stack traces to
8009  // pin-point the source location of a stack frame as close as possible.
8010  // The "STATEMENT_POSITION" means the place at the beginning of each
8011  // statement, and is used to indicate possible break locations.
8013 
8014  // There are two different kinds of JitCodeEvents, one for JIT code generated
8015  // by the optimizing compiler, and one for byte code generated for the
8016  // interpreter. For JIT_CODE events, the |code_start| member of the event
8017  // points to the beginning of jitted assembly code, while for BYTE_CODE
8018  // events, |code_start| points to the first bytecode of the interpreted
8019  // function.
8021 
8022  // Type of event.
8025  // Start of the instructions.
8026  void* code_start;
8027  // Size of the instructions.
8028  size_t code_len;
8029  // Script info for CODE_ADDED event.
8031  // User-defined data for *_LINE_INFO_* event. It's used to hold the source
8032  // code line information which is returned from the
8033  // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
8034  // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
8035  void* user_data;
8036 
8037  struct name_t {
8038  // Name of the object associated with the code, note that the string is not
8039  // zero-terminated.
8040  const char* str;
8041  // Number of chars in str.
8042  size_t len;
8043  };
8044 
8045  struct line_info_t {
8046  // PC offset
8047  size_t offset;
8048  // Code position
8049  size_t pos;
8050  // The position type.
8052  };
8053 
8055  // Source file name.
8056  const char* filename;
8057  // Length of filename.
8059  // Line number table, which maps offsets of JITted code to line numbers of
8060  // source file.
8062  // Number of entries in the line number table.
8064  };
8065 
8067 
8068  union {
8069  // Only valid for CODE_ADDED.
8070  struct name_t name;
8071 
8072  // Only valid for CODE_ADD_LINE_POS_INFO
8073  struct line_info_t line_info;
8074 
8075  // New location of instructions. Only valid for CODE_MOVED.
8076  void* new_code_start;
8077  };
8078 
8080 };
8081 
8082 /**
8083  * Option flags passed to the SetRAILMode function.
8084  * See documentation https://developers.google.com/web/tools/chrome-devtools/
8085  * profile/evaluate-performance/rail
8086  */
8087 enum RAILMode : unsigned {
8088  // Response performance mode: In this mode very low virtual machine latency
8089  // is provided. V8 will try to avoid JavaScript execution interruptions.
8090  // Throughput may be throttled.
8092  // Animation performance mode: In this mode low virtual machine latency is
8093  // provided. V8 will try to avoid as many JavaScript execution interruptions
8094  // as possible. Throughput may be throttled. This is the default mode.
8096  // Idle performance mode: The embedder is idle. V8 can complete deferred work
8097  // in this mode.
8099  // Load performance mode: In this mode high throughput is provided. V8 may
8100  // turn off latency optimizations.
8102 };
8103 
8104 /**
8105  * Option flags passed to the SetJitCodeEventHandler function.
8106  */
8109  // Generate callbacks for already existent code.
8111 };
8112 
8113 
8114 /**
8115  * Callback function passed to SetJitCodeEventHandler.
8116  *
8117  * \param event code add, move or removal event.
8118  */
8119 using JitCodeEventHandler = void (*)(const JitCodeEvent* event);
8120 
8121 /**
8122  * Callback function passed to SetUnhandledExceptionCallback.
8123  */
8124 #if defined(V8_OS_WIN)
8127 #endif
8128 
8129 /**
8130  * Interface for iterating through all external resources in the heap.
8131  */
8133  public:
8134  virtual ~ExternalResourceVisitor() = default;
8135  virtual void VisitExternalString(Local<String> string) {}
8136 };
8137 
8138 
8139 /**
8140  * Interface for iterating through all the persistent handles in the heap.
8141  */
8143  public:
8144  virtual ~PersistentHandleVisitor() = default;
8146  uint16_t class_id) {}
8147 };
8148 
8149 /**
8150  * Memory pressure level for the MemoryPressureNotification.
8151  * kNone hints V8 that there is no memory pressure.
8152  * kModerate hints V8 to speed up incremental garbage collection at the cost of
8153  * of higher latency due to garbage collection pauses.
8154  * kCritical hints V8 to free memory as soon as possible. Garbage collection
8155  * pauses at this level will be large.
8156  */
8158 
8159 /**
8160  * Interface for tracing through the embedder heap. During a V8 garbage
8161  * collection, V8 collects hidden fields of all potential wrappers, and at the
8162  * end of its marking phase iterates the collection and asks the embedder to
8163  * trace through its heap and use reporter to report each JavaScript object
8164  * reachable from any of the given wrappers.
8165  */
8167  public:
8168  using EmbedderStackState = cppgc::EmbedderStackState;
8169 
8172  kReduceMemory = 1 << 0,
8173  kForced = 1 << 2,
8174  };
8175 
8176  /**
8177  * Interface for iterating through TracedGlobal handles.
8178  */
8180  public:
8181  virtual ~TracedGlobalHandleVisitor() = default;
8182  virtual void VisitTracedGlobalHandle(const TracedGlobal<Value>& handle) {}
8183  virtual void VisitTracedReference(const TracedReference<Value>& handle) {}
8184  };
8185 
8186  /**
8187  * Summary of a garbage collection cycle. See |TraceEpilogue| on how the
8188  * summary is reported.
8189  */
8190  struct TraceSummary {
8191  /**
8192  * Time spent managing the retained memory in milliseconds. This can e.g.
8193  * include the time tracing through objects in the embedder.
8194  */
8195  double time = 0.0;
8196 
8197  /**
8198  * Memory retained by the embedder through the |EmbedderHeapTracer|
8199  * mechanism in bytes.
8200  */
8201  size_t allocated_size = 0;
8202  };
8203 
8204  virtual ~EmbedderHeapTracer() = default;
8205 
8206  /**
8207  * Iterates all TracedGlobal handles created for the v8::Isolate the tracer is
8208  * attached to.
8209  */
8211 
8212  /**
8213  * Called by the embedder to set the start of the stack which is e.g. used by
8214  * V8 to determine whether handles are used from stack or heap.
8215  */
8216  void SetStackStart(void* stack_start);
8217 
8218  /**
8219  * Called by the embedder to notify V8 of an empty execution stack.
8220  */
8221  void NotifyEmptyEmbedderStack();
8222 
8223  /**
8224  * Called by v8 to register internal fields of found wrappers.
8225  *
8226  * The embedder is expected to store them somewhere and trace reachable
8227  * wrappers from them when called through |AdvanceTracing|.
8228  */
8229  virtual void RegisterV8References(
8230  const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
8231 
8233 
8234  /**
8235  * Called at the beginning of a GC cycle.
8236  */
8237  virtual void TracePrologue(TraceFlags flags) {}
8238 
8239  /**
8240  * Called to advance tracing in the embedder.
8241  *
8242  * The embedder is expected to trace its heap starting from wrappers reported
8243  * by RegisterV8References method, and report back all reachable wrappers.
8244  * Furthermore, the embedder is expected to stop tracing by the given
8245  * deadline. A deadline of infinity means that tracing should be finished.
8246  *
8247  * Returns |true| if tracing is done, and false otherwise.
8248  */
8249  virtual bool AdvanceTracing(double deadline_in_ms) = 0;
8250 
8251  /*
8252  * Returns true if there no more tracing work to be done (see AdvanceTracing)
8253  * and false otherwise.
8254  */
8255  virtual bool IsTracingDone() = 0;
8256 
8257  /**
8258  * Called at the end of a GC cycle.
8259  *
8260  * Note that allocation is *not* allowed within |TraceEpilogue|. Can be
8261  * overriden to fill a |TraceSummary| that is used by V8 to schedule future
8262  * garbage collections.
8263  */
8264  virtual void TraceEpilogue(TraceSummary* trace_summary) {}
8265 
8266  /**
8267  * Called upon entering the final marking pause. No more incremental marking
8268  * steps will follow this call.
8269  */
8270  virtual void EnterFinalPause(EmbedderStackState stack_state) = 0;
8271 
8272  /*
8273  * Called by the embedder to request immediate finalization of the currently
8274  * running tracing phase that has been started with TracePrologue and not
8275  * yet finished with TraceEpilogue.
8276  *
8277  * Will be a noop when currently not in tracing.
8278  *
8279  * This is an experimental feature.
8280  */
8281  void FinalizeTracing();
8282 
8283  /**
8284  * Returns true if the TracedGlobal handle should be considered as root for
8285  * the currently running non-tracing garbage collection and false otherwise.
8286  * The default implementation will keep all TracedGlobal references as roots.
8287  *
8288  * If this returns false, then V8 may decide that the object referred to by
8289  * such a handle is reclaimed. In that case:
8290  * - No action is required if handles are used with destructors, i.e., by just
8291  * using |TracedGlobal|.
8292  * - When run without destructors, i.e., by using
8293  * |TracedReference|, V8 calls |ResetHandleInNonTracingGC|.
8294  *
8295  * Note that the |handle| is different from the handle that the embedder holds
8296  * for retaining the object. The embedder may use |WrapperClassId()| to
8297  * distinguish cases where it wants handles to be treated as roots from not
8298  * being treated as roots.
8299  */
8300  virtual bool IsRootForNonTracingGC(
8301  const v8::TracedReference<v8::Value>& handle);
8302  virtual bool IsRootForNonTracingGC(const v8::TracedGlobal<v8::Value>& handle);
8303 
8304  /**
8305  * Used in combination with |IsRootForNonTracingGC|. Called by V8 when an
8306  * object that is backed by a handle is reclaimed by a non-tracing garbage
8307  * collection. It is up to the embedder to reset the original handle.
8308  *
8309  * Note that the |handle| is different from the handle that the embedder holds
8310  * for retaining the object. It is up to the embedder to find the original
8311  * handle via the object or class id.
8312  */
8313  virtual void ResetHandleInNonTracingGC(
8314  const v8::TracedReference<v8::Value>& handle);
8315 
8316  /*
8317  * Called by the embedder to immediately perform a full garbage collection.
8318  *
8319  * Should only be used in testing code.
8320  */
8321  void GarbageCollectionForTesting(EmbedderStackState stack_state);
8322 
8323  /*
8324  * Called by the embedder to signal newly allocated or freed memory. Not bound
8325  * to tracing phases. Embedders should trade off when increments are reported
8326  * as V8 may consult global heuristics on whether to trigger garbage
8327  * collection on this change.
8328  */
8329  void IncreaseAllocatedSize(size_t bytes);
8330  void DecreaseAllocatedSize(size_t bytes);
8331 
8332  /*
8333  * Returns the v8::Isolate this tracer is attached too and |nullptr| if it
8334  * is not attached to any v8::Isolate.
8335  */
8336  v8::Isolate* isolate() const { return isolate_; }
8337 
8338  protected:
8339  v8::Isolate* isolate_ = nullptr;
8340 
8341  friend class internal::LocalEmbedderHeapTracer;
8342 };
8343 
8344 /**
8345  * Callback and supporting data used in SnapshotCreator to implement embedder
8346  * logic to serialize internal fields.
8347  * Internal fields that directly reference V8 objects are serialized without
8348  * calling this callback. Internal fields that contain aligned pointers are
8349  * serialized by this callback if it returns non-zero result. Otherwise it is
8350  * serialized verbatim.
8351  */
8353  using CallbackFunction = StartupData (*)(Local<Object> holder, int index,
8354  void* data);
8355  SerializeInternalFieldsCallback(CallbackFunction function = nullptr,
8356  void* data_arg = nullptr)
8357  : callback(function), data(data_arg) {}
8358  CallbackFunction callback;
8359  void* data;
8360 };
8361 // Note that these fields are called "internal fields" in the API and called
8362 // "embedder fields" within V8.
8363 using SerializeEmbedderFieldsCallback = SerializeInternalFieldsCallback;
8364 
8365 /**
8366  * Callback and supporting data used to implement embedder logic to deserialize
8367  * internal fields.
8368  */
8370  using CallbackFunction = void (*)(Local<Object> holder, int index,
8371  StartupData payload, void* data);
8372  DeserializeInternalFieldsCallback(CallbackFunction function = nullptr,
8373  void* data_arg = nullptr)
8374  : callback(function), data(data_arg) {}
8375  void (*callback)(Local<Object> holder, int index, StartupData payload,
8376  void* data);
8377  void* data;
8378 };
8379 using DeserializeEmbedderFieldsCallback = DeserializeInternalFieldsCallback;
8380 
8381 /**
8382  * Controls how the default MeasureMemoryDelegate reports the result of
8383  * the memory measurement to JS. With kSummary only the total size is reported.
8384  * With kDetailed the result includes the size of each native context.
8385  */
8387 
8388 /**
8389  * Controls how promptly a memory measurement request is executed.
8390  * By default the measurement is folded with the next scheduled GC which may
8391  * happen after a while and is forced after some timeout.
8392  * The kEager mode starts incremental GC right away and is useful for testing.
8393  * The kLazy mode does not force GC.
8394  */
8396 
8397 /**
8398  * The delegate is used in Isolate::MeasureMemory API.
8399  *
8400  * It specifies the contexts that need to be measured and gets called when
8401  * the measurement is completed to report the results.
8402  */
8404  public:
8405  virtual ~MeasureMemoryDelegate() = default;
8406 
8407  /**
8408  * Returns true if the size of the given context needs to be measured.
8409  */
8410  virtual bool ShouldMeasure(Local<Context> context) = 0;
8411 
8412  /**
8413  * This function is called when memory measurement finishes.
8414  *
8415  * \param context_sizes_in_bytes a vector of (context, size) pairs that
8416  * includes each context for which ShouldMeasure returned true and that
8417  * was not garbage collected while the memory measurement was in progress.
8418  *
8419  * \param unattributed_size_in_bytes total size of objects that were not
8420  * attributed to any context (i.e. are likely shared objects).
8421  */
8422  virtual void MeasurementComplete(
8423  const std::vector<std::pair<Local<Context>, size_t>>&
8424  context_sizes_in_bytes,
8425  size_t unattributed_size_in_bytes) = 0;
8426 
8427  /**
8428  * Returns a default delegate that resolves the given promise when
8429  * the memory measurement completes.
8430  *
8431  * \param isolate the current isolate
8432  * \param context the current context
8433  * \param promise_resolver the promise resolver that is given the
8434  * result of the memory measurement.
8435  * \param mode the detail level of the result.
8436  */
8437  static std::unique_ptr<MeasureMemoryDelegate> Default(
8438  Isolate* isolate, Local<Context> context,
8439  Local<Promise::Resolver> promise_resolver, MeasureMemoryMode mode);
8440 };
8441 
8442 /**
8443  * Isolate represents an isolated instance of the V8 engine. V8 isolates have
8444  * completely separate states. Objects from one isolate must not be used in
8445  * other isolates. The embedder can create multiple isolates and use them in
8446  * parallel in multiple threads. An isolate can be entered by at most one
8447  * thread at any given time. The Locker/Unlocker API must be used to
8448  * synchronize.
8449  */
8451  public:
8452  /**
8453  * Initial configuration parameters for a new Isolate.
8454  */
8456  CreateParams();
8457  ~CreateParams();
8458 
8459  /**
8460  * Allows the host application to provide the address of a function that is
8461  * notified each time code is added, moved or removed.
8462  */
8463  JitCodeEventHandler code_event_handler = nullptr;
8464 
8465  /**
8466  * ResourceConstraints to use for the new Isolate.
8467  */
8469 
8470  /**
8471  * Explicitly specify a startup snapshot blob. The embedder owns the blob.
8472  */
8474 
8475  /**
8476  * Enables the host application to provide a mechanism for recording
8477  * statistics counters.
8478  */
8479  CounterLookupCallback counter_lookup_callback = nullptr;
8480 
8481  /**
8482  * Enables the host application to provide a mechanism for recording
8483  * histograms. The CreateHistogram function returns a
8484  * histogram which will later be passed to the AddHistogramSample
8485  * function.
8486  */
8487  CreateHistogramCallback create_histogram_callback = nullptr;
8488  AddHistogramSampleCallback add_histogram_sample_callback = nullptr;
8489 
8490  /**
8491  * The ArrayBuffer::Allocator to use for allocating and freeing the backing
8492  * store of ArrayBuffers.
8493  *
8494  * If the shared_ptr version is used, the Isolate instance and every
8495  * |BackingStore| allocated using this allocator hold a std::shared_ptr
8496  * to the allocator, in order to facilitate lifetime
8497  * management for the allocator instance.
8498  */
8501 
8502  /**
8503  * Specifies an optional nullptr-terminated array of raw addresses in the
8504  * embedder that V8 can match against during serialization and use for
8505  * deserialization. This array and its content must stay valid for the
8506  * entire lifetime of the isolate.
8507  */
8508  const intptr_t* external_references = nullptr;
8509 
8510  /**
8511  * Whether calling Atomics.wait (a function that may block) is allowed in
8512  * this isolate. This can also be configured via SetAllowAtomicsWait.
8513  */
8514  bool allow_atomics_wait = true;
8515 
8516  /**
8517  * Termination is postponed when there is no active SafeForTerminationScope.
8518  */
8520 
8521  /**
8522  * The following parameters describe the offsets for addressing type info
8523  * for wrapped API objects and are used by the fast C API
8524  * (for details see v8-fast-api-calls.h).
8525  */
8528 
8529  V8_DEPRECATED(
8530  "Setting this has no effect. Embedders should ignore import assertions "
8531  "that they do not use.")
8532  std::vector<std::string> supported_import_assertions;
8533  };
8534 
8535  /**
8536  * Stack-allocated class which sets the isolate for all operations
8537  * executed within a local scope.
8538  */
8540  public:
8541  explicit Scope(Isolate* isolate) : isolate_(isolate) {
8542  isolate->Enter();
8543  }
8544 
8545  ~Scope() { isolate_->Exit(); }
8546 
8547  // Prevent copying of Scope objects.
8548  Scope(const Scope&) = delete;
8549  Scope& operator=(const Scope&) = delete;
8550 
8551  private:
8552  Isolate* const isolate_;
8553  };
8554 
8555  /**
8556  * Assert that no Javascript code is invoked.
8557  */
8559  public:
8561 
8562  DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure);
8564 
8565  // Prevent copying of Scope objects.
8567  delete;
8569  const DisallowJavascriptExecutionScope&) = delete;
8570 
8571  private:
8572  OnFailure on_failure_;
8573  Isolate* isolate_;
8574 
8575  bool was_execution_allowed_assert_;
8576  bool was_execution_allowed_throws_;
8577  bool was_execution_allowed_dump_;
8578  };
8579 
8580  /**
8581  * Introduce exception to DisallowJavascriptExecutionScope.
8582  */
8584  public:
8585  explicit AllowJavascriptExecutionScope(Isolate* isolate);
8587 
8588  // Prevent copying of Scope objects.
8590  delete;
8592  const AllowJavascriptExecutionScope&) = delete;
8593 
8594  private:
8595  Isolate* isolate_;
8596  bool was_execution_allowed_assert_;
8597  bool was_execution_allowed_throws_;
8598  bool was_execution_allowed_dump_;
8599  };
8600 
8601  /**
8602  * Do not run microtasks while this scope is active, even if microtasks are
8603  * automatically executed otherwise.
8604  */
8606  public:
8608  Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
8610 
8611  // Prevent copying of Scope objects.
8613  delete;
8615  const SuppressMicrotaskExecutionScope&) = delete;
8616 
8617  private:
8618  internal::Isolate* const isolate_;
8619  internal::MicrotaskQueue* const microtask_queue_;
8620  internal::Address previous_stack_height_;
8621 
8622  friend class internal::ThreadLocalTop;
8623  };
8624 
8625  /**
8626  * This scope allows terminations inside direct V8 API calls and forbid them
8627  * inside any recursive API calls without explicit SafeForTerminationScope.
8628  */
8630  public:
8631  explicit SafeForTerminationScope(v8::Isolate* isolate);
8633 
8634  // Prevent copying of Scope objects.
8637 
8638  private:
8639  internal::Isolate* isolate_;
8640  bool prev_value_;
8641  };
8642 
8643  /**
8644  * Types of garbage collections that can be requested via
8645  * RequestGarbageCollectionForTesting.
8646  */
8650  };
8651 
8652  /**
8653  * Features reported via the SetUseCounterCallback callback. Do not change
8654  * assigned numbers of existing items; add new features to the end of this
8655  * list.
8656  */
8658  kUseAsm = 0,
8710  kAtomicsNotify = 52, // Unused.
8711  kAtomicsWake = 53, // Unused.
8717  kLocale = 59,
8732  kDateGetTimezoneOffset = 74, // Unused.
8767  kWasmBulkMemory = 109, // Unused.
8770 
8771  // If you add new values here, you'll also need to update Chromium's:
8772  // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
8773  // this list need to be landed first, then changes on the Chromium side.
8774  kUseCounterFeatureCount // This enum value must be last.
8775  };
8776 
8778  kMessageLog = (1 << 0),
8779  kMessageDebug = (1 << 1),
8780  kMessageInfo = (1 << 2),
8781  kMessageError = (1 << 3),
8782  kMessageWarning = (1 << 4),
8785  };
8786 
8787  using UseCounterCallback = void (*)(Isolate* isolate,
8789 
8790  /**
8791  * Allocates a new isolate but does not initialize it. Does not change the
8792  * currently entered isolate.
8793  *
8794  * Only Isolate::GetData() and Isolate::SetData(), which access the
8795  * embedder-controlled parts of the isolate, are allowed to be called on the
8796  * uninitialized isolate. To initialize the isolate, call
8797  * Isolate::Initialize().
8798  *
8799  * When an isolate is no longer used its resources should be freed
8800  * by calling Dispose(). Using the delete operator is not allowed.
8801  *
8802  * V8::Initialize() must have run prior to this.
8803  */
8804  static Isolate* Allocate();
8805 
8806  /**
8807  * Initialize an Isolate previously allocated by Isolate::Allocate().
8808  */
8809  static void Initialize(Isolate* isolate, const CreateParams& params);
8810 
8811  /**
8812  * Creates a new isolate. Does not change the currently entered
8813  * isolate.
8814  *
8815  * When an isolate is no longer used its resources should be freed
8816  * by calling Dispose(). Using the delete operator is not allowed.
8817  *
8818  * V8::Initialize() must have run prior to this.
8819  */
8820  static Isolate* New(const CreateParams& params);
8821 
8822  /**
8823  * Returns the entered isolate for the current thread or NULL in
8824  * case there is no current isolate.
8825  *
8826  * This method must not be invoked before V8::Initialize() was invoked.
8827  */
8828  static Isolate* GetCurrent();
8829 
8830  /**
8831  * Clears the set of objects held strongly by the heap. This set of
8832  * objects are originally built when a WeakRef is created or
8833  * successfully dereferenced.
8834  *
8835  * This is invoked automatically after microtasks are run. See
8836  * MicrotasksPolicy for when microtasks are run.
8837  *
8838  * This needs to be manually invoked only if the embedder is manually running
8839  * microtasks via a custom MicrotaskQueue class's PerformCheckpoint. In that
8840  * case, it is the embedder's responsibility to make this call at a time which
8841  * does not interrupt synchronous ECMAScript code execution.
8842  */
8843  void ClearKeptObjects();
8844 
8845  /**
8846  * Custom callback used by embedders to help V8 determine if it should abort
8847  * when it throws and no internal handler is predicted to catch the
8848  * exception. If --abort-on-uncaught-exception is used on the command line,
8849  * then V8 will abort if either:
8850  * - no custom callback is set.
8851  * - the custom callback set returns true.
8852  * Otherwise, the custom callback will not be called and V8 will not abort.
8853  */
8854  using AbortOnUncaughtExceptionCallback = bool (*)(Isolate*);
8856  AbortOnUncaughtExceptionCallback callback);
8857 
8858  /**
8859  * This specifies the callback called by the upcoming dynamic
8860  * import() language feature to load modules.
8861  */
8863  "Use the version of SetHostImportModuleDynamicallyCallback that takes a "
8864  "HostImportModuleDynamicallyWithImportAssertionsCallback instead")
8865  void SetHostImportModuleDynamicallyCallback(
8866  HostImportModuleDynamicallyCallback callback);
8867 
8868  /**
8869  * This specifies the callback called by the upcoming dynamic
8870  * import() language feature to load modules.
8871  */
8873  HostImportModuleDynamicallyWithImportAssertionsCallback callback);
8874 
8875  /**
8876  * This specifies the callback called by the upcoming import.meta
8877  * language feature to retrieve host-defined meta data for a module.
8878  */
8880  HostInitializeImportMetaObjectCallback callback);
8881 
8882  /**
8883  * This specifies the callback called when the stack property of Error
8884  * is accessed.
8885  */
8886  void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback);
8887 
8888  /**
8889  * Optional notification that the system is running low on memory.
8890  * V8 uses these notifications to guide heuristics.
8891  * It is allowed to call this function from another thread while
8892  * the isolate is executing long running JavaScript code.
8893  */
8895 
8896  /**
8897  * Methods below this point require holding a lock (using Locker) in
8898  * a multi-threaded environment.
8899  */
8900 
8901  /**
8902  * Sets this isolate as the entered one for the current thread.
8903  * Saves the previously entered one (if any), so that it can be
8904  * restored when exiting. Re-entering an isolate is allowed.
8905  */
8906  void Enter();
8907 
8908  /**
8909  * Exits this isolate by restoring the previously entered one in the
8910  * current thread. The isolate may still stay the same, if it was
8911  * entered more than once.
8912  *
8913  * Requires: this == Isolate::GetCurrent().
8914  */
8915  void Exit();
8916 
8917  /**
8918  * Disposes the isolate. The isolate must not be entered by any
8919  * thread to be disposable.
8920  */
8921  void Dispose();
8922 
8923  /**
8924  * Dumps activated low-level V8 internal stats. This can be used instead
8925  * of performing a full isolate disposal.
8926  */
8927  void DumpAndResetStats();
8928 
8929  /**
8930  * Discards all V8 thread-specific data for the Isolate. Should be used
8931  * if a thread is terminating and it has used an Isolate that will outlive
8932  * the thread -- all thread-specific data for an Isolate is discarded when
8933  * an Isolate is disposed so this call is pointless if an Isolate is about
8934  * to be Disposed.
8935  */
8937 
8938  /**
8939  * Associate embedder-specific data with the isolate. |slot| has to be
8940  * between 0 and GetNumberOfDataSlots() - 1.
8941  */
8942  V8_INLINE void SetData(uint32_t slot, void* data);
8943 
8944  /**
8945  * Retrieve embedder-specific data from the isolate.
8946  * Returns NULL if SetData has never been called for the given |slot|.
8947  */
8948  V8_INLINE void* GetData(uint32_t slot);
8949 
8950  /**
8951  * Returns the maximum number of available embedder data slots. Valid slots
8952  * are in the range of 0 - GetNumberOfDataSlots() - 1.
8953  */
8954  V8_INLINE static uint32_t GetNumberOfDataSlots();
8955 
8956  /**
8957  * Return data that was previously attached to the isolate snapshot via
8958  * SnapshotCreator, and removes the reference to it.
8959  * Repeated call with the same index returns an empty MaybeLocal.
8960  */
8961  template <class T>
8962  V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
8963 
8964  /**
8965  * Get statistics about the heap memory usage.
8966  */
8967  void GetHeapStatistics(HeapStatistics* heap_statistics);
8968 
8969  /**
8970  * Returns the number of spaces in the heap.
8971  */
8972  size_t NumberOfHeapSpaces();
8973 
8974  /**
8975  * Get the memory usage of a space in the heap.
8976  *
8977  * \param space_statistics The HeapSpaceStatistics object to fill in
8978  * statistics.
8979  * \param index The index of the space to get statistics from, which ranges
8980  * from 0 to NumberOfHeapSpaces() - 1.
8981  * \returns true on success.
8982  */
8983  bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
8984  size_t index);
8985 
8986  /**
8987  * Returns the number of types of objects tracked in the heap at GC.
8988  */
8990 
8991  /**
8992  * Get statistics about objects in the heap.
8993  *
8994  * \param object_statistics The HeapObjectStatistics object to fill in
8995  * statistics of objects of given type, which were live in the previous GC.
8996  * \param type_index The index of the type of object to fill details about,
8997  * which ranges from 0 to NumberOfTrackedHeapObjectTypes() - 1.
8998  * \returns true on success.
8999  */
9000  bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
9001  size_t type_index);
9002 
9003  /**
9004  * Get statistics about code and its metadata in the heap.
9005  *
9006  * \param object_statistics The HeapCodeStatistics object to fill in
9007  * statistics of code, bytecode and their metadata.
9008  * \returns true on success.
9009  */
9010  bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
9011 
9012  /**
9013  * This API is experimental and may change significantly.
9014  *
9015  * Enqueues a memory measurement request and invokes the delegate with the
9016  * results.
9017  *
9018  * \param delegate the delegate that defines which contexts to measure and
9019  * reports the results.
9020  *
9021  * \param execution promptness executing the memory measurement.
9022  * The kEager value is expected to be used only in tests.
9023  */
9024  bool MeasureMemory(
9025  std::unique_ptr<MeasureMemoryDelegate> delegate,
9027 
9028  V8_DEPRECATED("Use the version with a delegate")
9030  MeasureMemoryMode mode);
9031 
9032  /**
9033  * Get a call stack sample from the isolate.
9034  * \param state Execution state.
9035  * \param frames Caller allocated buffer to store stack frames.
9036  * \param frames_limit Maximum number of frames to capture. The buffer must
9037  * be large enough to hold the number of frames.
9038  * \param sample_info The sample info is filled up by the function
9039  * provides number of actual captured stack frames and
9040  * the current VM state.
9041  * \note GetStackSample should only be called when the JS thread is paused or
9042  * interrupted. Otherwise the behavior is undefined.
9043  */
9044  void GetStackSample(const RegisterState& state, void** frames,
9045  size_t frames_limit, SampleInfo* sample_info);
9046 
9047  /**
9048  * Adjusts the amount of registered external memory. Used to give V8 an
9049  * indication of the amount of externally allocated memory that is kept alive
9050  * by JavaScript objects. V8 uses this to decide when to perform global
9051  * garbage collections. Registering externally allocated memory will trigger
9052  * global garbage collections more often than it would otherwise in an attempt
9053  * to garbage collect the JavaScript objects that keep the externally
9054  * allocated memory alive.
9055  *
9056  * \param change_in_bytes the change in externally allocated memory that is
9057  * kept alive by JavaScript objects.
9058  * \returns the adjusted value.
9059  */
9060  int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
9061 
9062  /**
9063  * Returns the number of phantom handles without callbacks that were reset
9064  * by the garbage collector since the last call to this function.
9065  */
9067 
9068  /**
9069  * Returns heap profiler for this isolate. Will return NULL until the isolate
9070  * is initialized.
9071  */
9073 
9074  /**
9075  * Tells the VM whether the embedder is idle or not.
9076  */
9077  void SetIdle(bool is_idle);
9078 
9079  /** Returns the ArrayBuffer::Allocator used in this isolate. */
9081 
9082  /** Returns true if this isolate has a current context. */
9083  bool InContext();
9084 
9085  /**
9086  * Returns the context of the currently running JavaScript, or the context
9087  * on the top of the stack if no JavaScript is running.
9088  */
9090 
9091  /**
9092  * Returns either the last context entered through V8's C++ API, or the
9093  * context of the currently running microtask while processing microtasks.
9094  * If a context is entered while executing a microtask, that context is
9095  * returned.
9096  */
9098 
9099  /**
9100  * Returns the Context that corresponds to the Incumbent realm in HTML spec.
9101  * https://html.spec.whatwg.org/multipage/webappapis.html#incumbent
9102  */
9104 
9105  /**
9106  * Schedules an exception to be thrown when returning to JavaScript. When an
9107  * exception has been scheduled it is illegal to invoke any JavaScript
9108  * operation; the caller must return immediately and only after the exception
9109  * has been handled does it become legal to invoke JavaScript operations.
9110  */
9111  Local<Value> ThrowException(Local<Value> exception);
9112 
9113  using GCCallback = void (*)(Isolate* isolate, GCType type,
9115  using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
9116  GCCallbackFlags flags, void* data);
9117 
9118  /**
9119  * Enables the host application to receive a notification before a
9120  * garbage collection. Allocations are allowed in the callback function,
9121  * but the callback is not re-entrant: if the allocation inside it will
9122  * trigger the garbage collection, the callback won't be called again.
9123  * It is possible to specify the GCType filter for your callback. But it is
9124  * not possible to register the same callback function two times with
9125  * different GCType filters.
9126  */
9127  void AddGCPrologueCallback(GCCallbackWithData callback, void* data = nullptr,
9128  GCType gc_type_filter = kGCTypeAll);
9129  void AddGCPrologueCallback(GCCallback callback,
9130  GCType gc_type_filter = kGCTypeAll);
9131 
9132  /**
9133  * This function removes callback which was installed by
9134  * AddGCPrologueCallback function.
9135  */
9136  void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
9137  void RemoveGCPrologueCallback(GCCallback callback);
9138 
9139  /**
9140  * Sets the embedder heap tracer for the isolate.
9141  */
9143 
9144  /*
9145  * Gets the currently active heap tracer for the isolate.
9146  */
9148 
9149  /**
9150  * Attaches a managed C++ heap as an extension to the JavaScript heap. The
9151  * embedder maintains ownership of the CppHeap. At most one C++ heap can be
9152  * attached to V8.
9153  *
9154  * This is an experimental feature and may still change significantly.
9155  */
9156  void AttachCppHeap(CppHeap*);
9157 
9158  /**
9159  * Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
9160  *
9161  * This is an experimental feature and may still change significantly.
9162  */
9163  void DetachCppHeap();
9164 
9165  /**
9166  * This is an experimental feature and may still change significantly.
9167 
9168  * \returns the C++ heap managed by V8. Only available if such a heap has been
9169  * attached using `AttachCppHeap()`.
9170  */
9171  CppHeap* GetCppHeap() const;
9172 
9173  /**
9174  * Use for |AtomicsWaitCallback| to indicate the type of event it receives.
9175  */
9176  enum class AtomicsWaitEvent {
9177  /** Indicates that this call is happening before waiting. */
9178  kStartWait,
9179  /** `Atomics.wait()` finished because of an `Atomics.wake()` call. */
9180  kWokenUp,
9181  /** `Atomics.wait()` finished because it timed out. */
9182  kTimedOut,
9183  /** `Atomics.wait()` was interrupted through |TerminateExecution()|. */
9185  /** `Atomics.wait()` was stopped through |AtomicsWaitWakeHandle|. */
9186  kAPIStopped,
9187  /** `Atomics.wait()` did not wait, as the initial condition was not met. */
9188  kNotEqual
9189  };
9190 
9191  /**
9192  * Passed to |AtomicsWaitCallback| as a means of stopping an ongoing
9193  * `Atomics.wait` call.
9194  */
9196  public:
9197  /**
9198  * Stop this `Atomics.wait()` call and call the |AtomicsWaitCallback|
9199  * with |kAPIStopped|.
9200  *
9201  * This function may be called from another thread. The caller has to ensure
9202  * through proper synchronization that it is not called after
9203  * the finishing |AtomicsWaitCallback|.
9204  *
9205  * Note that the ECMAScript specification does not plan for the possibility
9206  * of wakeups that are neither coming from a timeout or an `Atomics.wake()`
9207  * call, so this may invalidate assumptions made by existing code.
9208  * The embedder may accordingly wish to schedule an exception in the
9209  * finishing |AtomicsWaitCallback|.
9210  */
9211  void Wake();
9212  };
9213 
9214  /**
9215  * Embedder callback for `Atomics.wait()` that can be added through
9216  * |SetAtomicsWaitCallback|.
9217  *
9218  * This will be called just before starting to wait with the |event| value
9219  * |kStartWait| and after finishing waiting with one of the other
9220  * values of |AtomicsWaitEvent| inside of an `Atomics.wait()` call.
9221  *
9222  * |array_buffer| will refer to the underlying SharedArrayBuffer,
9223  * |offset_in_bytes| to the location of the waited-on memory address inside
9224  * the SharedArrayBuffer.
9225  *
9226  * |value| and |timeout_in_ms| will be the values passed to
9227  * the `Atomics.wait()` call. If no timeout was used, |timeout_in_ms|
9228  * will be `INFINITY`.
9229  *
9230  * In the |kStartWait| callback, |stop_handle| will be an object that
9231  * is only valid until the corresponding finishing callback and that
9232  * can be used to stop the wait process while it is happening.
9233  *
9234  * This callback may schedule exceptions, *unless* |event| is equal to
9235  * |kTerminatedExecution|.
9236  */
9237  using AtomicsWaitCallback = void (*)(AtomicsWaitEvent event,
9238  Local<SharedArrayBuffer> array_buffer,
9239  size_t offset_in_bytes, int64_t value,
9240  double timeout_in_ms,
9241  AtomicsWaitWakeHandle* stop_handle,
9242  void* data);
9243 
9244  /**
9245  * Set a new |AtomicsWaitCallback|. This overrides an earlier
9246  * |AtomicsWaitCallback|, if there was any. If |callback| is nullptr,
9247  * this unsets the callback. |data| will be passed to the callback
9248  * as its last parameter.
9249  */
9250  void SetAtomicsWaitCallback(AtomicsWaitCallback callback, void* data);
9251 
9252  /**
9253  * Enables the host application to receive a notification after a
9254  * garbage collection. Allocations are allowed in the callback function,
9255  * but the callback is not re-entrant: if the allocation inside it will
9256  * trigger the garbage collection, the callback won't be called again.
9257  * It is possible to specify the GCType filter for your callback. But it is
9258  * not possible to register the same callback function two times with
9259  * different GCType filters.
9260  */
9261  void AddGCEpilogueCallback(GCCallbackWithData callback, void* data = nullptr,
9262  GCType gc_type_filter = kGCTypeAll);
9263  void AddGCEpilogueCallback(GCCallback callback,
9264  GCType gc_type_filter = kGCTypeAll);
9265 
9266  /**
9267  * This function removes callback which was installed by
9268  * AddGCEpilogueCallback function.
9269  */
9270  void RemoveGCEpilogueCallback(GCCallbackWithData callback,
9271  void* data = nullptr);
9272  void RemoveGCEpilogueCallback(GCCallback callback);
9273 
9274  using GetExternallyAllocatedMemoryInBytesCallback = size_t (*)();
9275 
9276  /**
9277  * Set the callback that tells V8 how much memory is currently allocated
9278  * externally of the V8 heap. Ideally this memory is somehow connected to V8
9279  * objects and may get freed-up when the corresponding V8 objects get
9280  * collected by a V8 garbage collection.
9281  */
9283  GetExternallyAllocatedMemoryInBytesCallback callback);
9284 
9285  /**
9286  * Forcefully terminate the current thread of JavaScript execution
9287  * in the given isolate.
9288  *
9289  * This method can be used by any thread even if that thread has not
9290  * acquired the V8 lock with a Locker object.
9291  */
9292  void TerminateExecution();
9293 
9294  /**
9295  * Is V8 terminating JavaScript execution.
9296  *
9297  * Returns true if JavaScript execution is currently terminating
9298  * because of a call to TerminateExecution. In that case there are
9299  * still JavaScript frames on the stack and the termination
9300  * exception is still active.
9301  */
9302  bool IsExecutionTerminating();
9303 
9304  /**
9305  * Resume execution capability in the given isolate, whose execution
9306  * was previously forcefully terminated using TerminateExecution().
9307  *
9308  * When execution is forcefully terminated using TerminateExecution(),
9309  * the isolate can not resume execution until all JavaScript frames
9310  * have propagated the uncatchable exception which is generated. This
9311  * method allows the program embedding the engine to handle the
9312  * termination event and resume execution capability, even if
9313  * JavaScript frames remain on the stack.
9314  *
9315  * This method can be used by any thread even if that thread has not
9316  * acquired the V8 lock with a Locker object.
9317  */
9318  void CancelTerminateExecution();
9319 
9320  /**
9321  * Request V8 to interrupt long running JavaScript code and invoke
9322  * the given |callback| passing the given |data| to it. After |callback|
9323  * returns control will be returned to the JavaScript code.
9324  * There may be a number of interrupt requests in flight.
9325  * Can be called from another thread without acquiring a |Locker|.
9326  * Registered |callback| must not reenter interrupted Isolate.
9327  */
9328  void RequestInterrupt(InterruptCallback callback, void* data);
9329 
9330  /**
9331  * Returns true if there is ongoing background work within V8 that will
9332  * eventually post a foreground task, like asynchronous WebAssembly
9333  * compilation.
9334  */
9336 
9337  /**
9338  * Request garbage collection in this Isolate. It is only valid to call this
9339  * function if --expose_gc was specified.
9340  *
9341  * This should only be used for testing purposes and not to enforce a garbage
9342  * collection schedule. It has strong negative impact on the garbage
9343  * collection performance. Use IdleNotificationDeadline() or
9344  * LowMemoryNotification() instead to influence the garbage collection
9345  * schedule.
9346  */
9348 
9349  /**
9350  * Set the callback to invoke for logging event.
9351  */
9352  void SetEventLogger(LogEventCallback that);
9353 
9354  /**
9355  * Adds a callback to notify the host application right before a script
9356  * is about to run. If a script re-enters the runtime during executing, the
9357  * BeforeCallEnteredCallback is invoked for each re-entrance.
9358  * Executing scripts inside the callback will re-trigger the callback.
9359  */
9360  void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
9361 
9362  /**
9363  * Removes callback that was installed by AddBeforeCallEnteredCallback.
9364  */
9365  void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
9366 
9367  /**
9368  * Adds a callback to notify the host application when a script finished
9369  * running. If a script re-enters the runtime during executing, the
9370  * CallCompletedCallback is only invoked when the outer-most script
9371  * execution ends. Executing scripts inside the callback do not trigger
9372  * further callbacks.
9373  */
9374  void AddCallCompletedCallback(CallCompletedCallback callback);
9375 
9376  /**
9377  * Removes callback that was installed by AddCallCompletedCallback.
9378  */
9379  void RemoveCallCompletedCallback(CallCompletedCallback callback);
9380 
9381  /**
9382  * Set the PromiseHook callback for various promise lifecycle
9383  * events.
9384  */
9385  void SetPromiseHook(PromiseHook hook);
9386 
9387  /**
9388  * Set callback to notify about promise reject with no handler, or
9389  * revocation of such a previous notification once the handler is added.
9390  */
9391  void SetPromiseRejectCallback(PromiseRejectCallback callback);
9392 
9393  /**
9394  * Runs the default MicrotaskQueue until it gets empty and perform other
9395  * microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that
9396  * the MicrotasksPolicy is not kScoped. Any exceptions thrown by microtask
9397  * callbacks are swallowed.
9398  */
9400 
9401  /**
9402  * Enqueues the callback to the default MicrotaskQueue
9403  */
9404  void EnqueueMicrotask(Local<Function> microtask);
9405 
9406  /**
9407  * Enqueues the callback to the default MicrotaskQueue
9408  */
9409  void EnqueueMicrotask(MicrotaskCallback callback, void* data = nullptr);
9410 
9411  /**
9412  * Controls how Microtasks are invoked. See MicrotasksPolicy for details.
9413  */
9415 
9416  /**
9417  * Returns the policy controlling how Microtasks are invoked.
9418  */
9420 
9421  /**
9422  * Adds a callback to notify the host application after
9423  * microtasks were run on the default MicrotaskQueue. The callback is
9424  * triggered by explicit RunMicrotasks call or automatic microtasks execution
9425  * (see SetMicrotaskPolicy).
9426  *
9427  * Callback will trigger even if microtasks were attempted to run,
9428  * but the microtasks queue was empty and no single microtask was actually
9429  * executed.
9430  *
9431  * Executing scripts inside the callback will not re-trigger microtasks and
9432  * the callback.
9433  */
9435  MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
9436 
9437  /**
9438  * Removes callback that was installed by AddMicrotasksCompletedCallback.
9439  */
9441  MicrotasksCompletedCallbackWithData callback, void* data = nullptr);
9442 
9443  /**
9444  * Sets a callback for counting the number of times a feature of V8 is used.
9445  */
9446  void SetUseCounterCallback(UseCounterCallback callback);
9447 
9448  /**
9449  * Enables the host application to provide a mechanism for recording
9450  * statistics counters.
9451  */
9452  void SetCounterFunction(CounterLookupCallback);
9453 
9454  /**
9455  * Enables the host application to provide a mechanism for recording
9456  * histograms. The CreateHistogram function returns a
9457  * histogram which will later be passed to the AddHistogramSample
9458  * function.
9459  */
9460  void SetCreateHistogramFunction(CreateHistogramCallback);
9461  void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
9462 
9463  /**
9464  * Enables the host application to provide a mechanism for recording
9465  * event based metrics. In order to use this interface
9466  * include/v8-metrics.h
9467  * needs to be included and the recorder needs to be derived from the
9468  * Recorder base class defined there.
9469  * This method can only be called once per isolate and must happen during
9470  * isolate initialization before background threads are spawned.
9471  */
9472  void SetMetricsRecorder(
9473  const std::shared_ptr<metrics::Recorder>& metrics_recorder);
9474 
9475  /**
9476  * Enables the host application to provide a mechanism for recording a
9477  * predefined set of data as crash keys to be used in postmortem debugging in
9478  * case of a crash.
9479  */
9480  void SetAddCrashKeyCallback(AddCrashKeyCallback);
9481 
9482  /**
9483  * Optional notification that the embedder is idle.
9484  * V8 uses the notification to perform garbage collection.
9485  * This call can be used repeatedly if the embedder remains idle.
9486  * Returns true if the embedder should stop calling IdleNotificationDeadline
9487  * until real work has been done. This indicates that V8 has done
9488  * as much cleanup as it will be able to do.
9489  *
9490  * The deadline_in_seconds argument specifies the deadline V8 has to finish
9491  * garbage collection work. deadline_in_seconds is compared with
9492  * MonotonicallyIncreasingTime() and should be based on the same timebase as
9493  * that function. There is no guarantee that the actual work will be done
9494  * within the time limit.
9495  */
9496  bool IdleNotificationDeadline(double deadline_in_seconds);
9497 
9498  /**
9499  * Optional notification that the system is running low on memory.
9500  * V8 uses these notifications to attempt to free memory.
9501  */
9502  void LowMemoryNotification();
9503 
9504  /**
9505  * Optional notification that a context has been disposed. V8 uses these
9506  * notifications to guide the GC heuristic and cancel FinalizationRegistry
9507  * cleanup tasks. Returns the number of context disposals - including this one
9508  * - since the last time V8 had a chance to clean up.
9509  *
9510  * The optional parameter |dependant_context| specifies whether the disposed
9511  * context was depending on state from other contexts or not.
9512  */
9513  int ContextDisposedNotification(bool dependant_context = true);
9514 
9515  /**
9516  * Optional notification that the isolate switched to the foreground.
9517  * V8 uses these notifications to guide heuristics.
9518  */
9520 
9521  /**
9522  * Optional notification that the isolate switched to the background.
9523  * V8 uses these notifications to guide heuristics.
9524  */
9526 
9527  /**
9528  * Optional notification which will enable the memory savings mode.
9529  * V8 uses this notification to guide heuristics which may result in a
9530  * smaller memory footprint at the cost of reduced runtime performance.
9531  */
9532  void EnableMemorySavingsMode();
9533 
9534  /**
9535  * Optional notification which will disable the memory savings mode.
9536  */
9537  void DisableMemorySavingsMode();
9538 
9539  /**
9540  * Optional notification to tell V8 the current performance requirements
9541  * of the embedder based on RAIL.
9542  * V8 uses these notifications to guide heuristics.
9543  * This is an unfinished experimental feature. Semantics and implementation
9544  * may change frequently.
9545  */
9546  void SetRAILMode(RAILMode rail_mode);
9547 
9548  /**
9549  * Optional notification to tell V8 the current isolate is used for debugging
9550  * and requires higher heap limit.
9551  */
9553 
9554  /**
9555  * Restores the original heap limit after IncreaseHeapLimitForDebugging().
9556  */
9557  void RestoreOriginalHeapLimit();
9558 
9559  /**
9560  * Returns true if the heap limit was increased for debugging and the
9561  * original heap limit was not restored yet.
9562  */
9564 
9565  /**
9566  * Allows the host application to provide the address of a function that is
9567  * notified each time code is added, moved or removed.
9568  *
9569  * \param options options for the JIT code event handler.
9570  * \param event_handler the JIT code event handler, which will be invoked
9571  * each time code is added, moved or removed.
9572  * \note \p event_handler won't get notified of existent code.
9573  * \note since code removal notifications are not currently issued, the
9574  * \p event_handler may get notifications of code that overlaps earlier
9575  * code notifications. This happens when code areas are reused, and the
9576  * earlier overlapping code areas should therefore be discarded.
9577  * \note the events passed to \p event_handler and the strings they point to
9578  * are not guaranteed to live past each call. The \p event_handler must
9579  * copy strings and other parameters it needs to keep around.
9580  * \note the set of events declared in JitCodeEvent::EventType is expected to
9581  * grow over time, and the JitCodeEvent structure is expected to accrue
9582  * new members. The \p event_handler function must ignore event codes
9583  * it does not recognize to maintain future compatibility.
9584  * \note Use Isolate::CreateParams to get events for code executed during
9585  * Isolate setup.
9586  */
9588  JitCodeEventHandler event_handler);
9589 
9590  /**
9591  * Modifies the stack limit for this Isolate.
9592  *
9593  * \param stack_limit An address beyond which the Vm's stack may not grow.
9594  *
9595  * \note If you are using threads then you should hold the V8::Locker lock
9596  * while setting the stack limit and you must set a non-default stack
9597  * limit separately for each thread.
9598  */
9599  void SetStackLimit(uintptr_t stack_limit);
9600 
9601  /**
9602  * Returns a memory range that can potentially contain jitted code. Code for
9603  * V8's 'builtins' will not be in this range if embedded builtins is enabled.
9604  *
9605  * On Win64, embedders are advised to install function table callbacks for
9606  * these ranges, as default SEH won't be able to unwind through jitted code.
9607  * The first page of the code range is reserved for the embedder and is
9608  * committed, writable, and executable, to be used to store unwind data, as
9609  * documented in
9610  * https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64.
9611  *
9612  * Might be empty on other platforms.
9613  *
9614  * https://code.google.com/p/v8/issues/detail?id=3598
9615  */
9616  void GetCodeRange(void** start, size_t* length_in_bytes);
9617 
9618  /**
9619  * As GetCodeRange, but for embedded builtins (these live in a distinct
9620  * memory region from other V8 Code objects).
9621  */
9622  void GetEmbeddedCodeRange(const void** start, size_t* length_in_bytes);
9623 
9624  /**
9625  * Returns the JSEntryStubs necessary for use with the Unwinder API.
9626  */
9628 
9629  static constexpr size_t kMinCodePagesBufferSize = 32;
9630 
9631  /**
9632  * Copies the code heap pages currently in use by V8 into |code_pages_out|.
9633  * |code_pages_out| must have at least kMinCodePagesBufferSize capacity and
9634  * must be empty.
9635  *
9636  * Signal-safe, does not allocate, does not access the V8 heap.
9637  * No code on the stack can rely on pages that might be missing.
9638  *
9639  * Returns the number of pages available to be copied, which might be greater
9640  * than |capacity|. In this case, only |capacity| pages will be copied into
9641  * |code_pages_out|. The caller should provide a bigger buffer on the next
9642  * call in order to get all available code pages, but this is not required.
9643  */
9644  size_t CopyCodePages(size_t capacity, MemoryRange* code_pages_out);
9645 
9646  /** Set the callback to invoke in case of fatal errors. */
9647  void SetFatalErrorHandler(FatalErrorCallback that);
9648 
9649  /** Set the callback to invoke in case of OOM errors. */
9650  void SetOOMErrorHandler(OOMErrorCallback that);
9651 
9652  /**
9653  * Add a callback to invoke in case the heap size is close to the heap limit.
9654  * If multiple callbacks are added, only the most recently added callback is
9655  * invoked.
9656  */
9657  void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void* data);
9658 
9659  /**
9660  * Remove the given callback and restore the heap limit to the
9661  * given limit. If the given limit is zero, then it is ignored.
9662  * If the current heap size is greater than the given limit,
9663  * then the heap limit is restored to the minimal limit that
9664  * is possible for the current heap size.
9665  */
9666  void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback,
9667  size_t heap_limit);
9668 
9669  /**
9670  * If the heap limit was changed by the NearHeapLimitCallback, then the
9671  * initial heap limit will be restored once the heap size falls below the
9672  * given threshold percentage of the initial heap limit.
9673  * The threshold percentage is a number in (0.0, 1.0) range.
9674  */
9675  void AutomaticallyRestoreInitialHeapLimit(double threshold_percent = 0.5);
9676 
9677  /**
9678  * Set the callback to invoke to check if code generation from
9679  * strings should be allowed.
9680  */
9681  V8_DEPRECATED(
9682  "Use Isolate::SetModifyCodeGenerationFromStringsCallback with "
9683  "ModifyCodeGenerationFromStringsCallback2 instead. See "
9684  "http://crbug.com/1096017 and TC39 Dynamic Code Brand Checks proposal "
9685  "at https://github.com/tc39/proposal-dynamic-code-brand-checks.")
9686  void SetModifyCodeGenerationFromStringsCallback(
9687  ModifyCodeGenerationFromStringsCallback callback);
9689  ModifyCodeGenerationFromStringsCallback2 callback);
9690 
9691  /**
9692  * Set the callback to invoke to check if wasm code generation should
9693  * be allowed.
9694  */
9696  AllowWasmCodeGenerationCallback callback);
9697 
9698  /**
9699  * Embedder over{ride|load} injection points for wasm APIs. The expectation
9700  * is that the embedder sets them at most once.
9701  */
9702  void SetWasmModuleCallback(ExtensionCallback callback);
9703  void SetWasmInstanceCallback(ExtensionCallback callback);
9704 
9705  void SetWasmStreamingCallback(WasmStreamingCallback callback);
9706 
9707  void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
9708 
9709  void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
9710 
9711  void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback);
9712 
9713  /**
9714  * Check if V8 is dead and therefore unusable. This is the case after
9715  * fatal errors such as out-of-memory situations.
9716  */
9717  bool IsDead();
9718 
9719  /**
9720  * Adds a message listener (errors only).
9721  *
9722  * The same message listener can be added more than once and in that
9723  * case it will be called more than once for each message.
9724  *
9725  * If data is specified, it will be passed to the callback when it is called.
9726  * Otherwise, the exception object will be passed to the callback instead.
9727  */
9728  bool AddMessageListener(MessageCallback that,
9729  Local<Value> data = Local<Value>());
9730 
9731  /**
9732  * Adds a message listener.
9733  *
9734  * The same message listener can be added more than once and in that
9735  * case it will be called more than once for each message.
9736  *
9737  * If data is specified, it will be passed to the callback when it is called.
9738  * Otherwise, the exception object will be passed to the callback instead.
9739  *
9740  * A listener can listen for particular error levels by providing a mask.
9741  */
9742  bool AddMessageListenerWithErrorLevel(MessageCallback that,
9743  int message_levels,
9744  Local<Value> data = Local<Value>());
9745 
9746  /**
9747  * Remove all message listeners from the specified callback function.
9748  */
9749  void RemoveMessageListeners(MessageCallback that);
9750 
9751  /** Callback function for reporting failed access checks.*/
9752  void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
9753 
9754  /**
9755  * Tells V8 to capture current stack trace when uncaught exception occurs
9756  * and report it to the message listeners. The option is off by default.
9757  */
9759  bool capture, int frame_limit = 10,
9761 
9762  /**
9763  * Iterates through all external resources referenced from current isolate
9764  * heap. GC is not invoked prior to iterating, therefore there is no
9765  * guarantee that visited objects are still alive.
9766  */
9768 
9769  /**
9770  * Iterates through all the persistent handles in the current isolate's heap
9771  * that have class_ids.
9772  */
9774 
9775  /**
9776  * Iterates through all the persistent handles in the current isolate's heap
9777  * that have class_ids and are weak to be marked as inactive if there is no
9778  * pending activity for the handle.
9779  */
9781 
9782  /**
9783  * Check if this isolate is in use.
9784  * True if at least one thread Enter'ed this isolate.
9785  */
9786  bool IsInUse();
9787 
9788  /**
9789  * Set whether calling Atomics.wait (a function that may block) is allowed in
9790  * this isolate. This can also be configured via
9791  * CreateParams::allow_atomics_wait.
9792  */
9793  void SetAllowAtomicsWait(bool allow);
9794 
9795  /**
9796  * Time zone redetection indicator for
9797  * DateTimeConfigurationChangeNotification.
9798  *
9799  * kSkip indicates V8 that the notification should not trigger redetecting
9800  * host time zone. kRedetect indicates V8 that host time zone should be
9801  * redetected, and used to set the default time zone.
9802  *
9803  * The host time zone detection may require file system access or similar
9804  * operations unlikely to be available inside a sandbox. If v8 is run inside a
9805  * sandbox, the host time zone has to be detected outside the sandbox before
9806  * calling DateTimeConfigurationChangeNotification function.
9807  */
9809 
9810  /**
9811  * Notification that the embedder has changed the time zone, daylight savings
9812  * time or other date / time configuration parameters. V8 keeps a cache of
9813  * various values used for date / time computation. This notification will
9814  * reset those cached values for the current context so that date / time
9815  * configuration changes would be reflected.
9816  *
9817  * This API should not be called more than needed as it will negatively impact
9818  * the performance of date operations.
9819  */
9821  TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip);
9822 
9823  /**
9824  * Notification that the embedder has changed the locale. V8 keeps a cache of
9825  * various values used for locale computation. This notification will reset
9826  * those cached values for the current context so that locale configuration
9827  * changes would be reflected.
9828  *
9829  * This API should not be called more than needed as it will negatively impact
9830  * the performance of locale operations.
9831  */
9833 
9834  Isolate() = delete;
9835  ~Isolate() = delete;
9836  Isolate(const Isolate&) = delete;
9837  Isolate& operator=(const Isolate&) = delete;
9838  // Deleting operator new and delete here is allowed as ctor and dtor is also
9839  // deleted.
9840  void* operator new(size_t size) = delete;
9841  void* operator new[](size_t size) = delete;
9842  void operator delete(void*, size_t) = delete;
9843  void operator delete[](void*, size_t) = delete;
9844 
9845  private:
9846  template <class K, class V, class Traits>
9848 
9849  internal::Address* GetDataFromSnapshotOnce(size_t index);
9850  void ReportExternalAllocationLimitReached();
9851 };
9852 
9854  public:
9855  /**
9856  * Whether the data created can be rehashed and and the hash seed can be
9857  * recomputed when deserialized.
9858  * Only valid for StartupData returned by SnapshotCreator::CreateBlob().
9859  */
9860  bool CanBeRehashed() const;
9861  /**
9862  * Allows embedders to verify whether the data is valid for the current
9863  * V8 instance.
9864  */
9865  bool IsValid() const;
9866 
9867  const char* data;
9869 };
9870 
9871 /**
9872  * EntropySource is used as a callback function when v8 needs a source
9873  * of entropy.
9874  */
9875 using EntropySource = bool (*)(unsigned char* buffer, size_t length);
9876 
9877 /**
9878  * ReturnAddressLocationResolver is used as a callback function when v8 is
9879  * resolving the location of a return address on the stack. Profilers that
9880  * change the return address on the stack can use this to resolve the stack
9881  * location to wherever the profiler stashed the original return address.
9882  *
9883  * \param return_addr_location A location on stack where a machine
9884  * return address resides.
9885  * \returns Either return_addr_location, or else a pointer to the profiler's
9886  * copy of the original return address.
9887  *
9888  * \note The resolver function must not cause garbage collection.
9889  */
9890 using ReturnAddressLocationResolver =
9891  uintptr_t (*)(uintptr_t return_addr_location);
9892 
9893 /**
9894  * Container class for static utility functions.
9895  */
9896 class V8_EXPORT V8 {
9897  public:
9898  /**
9899  * Hand startup data to V8, in case the embedder has chosen to build
9900  * V8 with external startup data.
9901  *
9902  * Note:
9903  * - By default the startup data is linked into the V8 library, in which
9904  * case this function is not meaningful.
9905  * - If this needs to be called, it needs to be called before V8
9906  * tries to make use of its built-ins.
9907  * - To avoid unnecessary copies of data, V8 will point directly into the
9908  * given data blob, so pretty please keep it around until V8 exit.
9909  * - Compression of the startup blob might be useful, but needs to
9910  * handled entirely on the embedders' side.
9911  * - The call will abort if the data is invalid.
9912  */
9913  static void SetSnapshotDataBlob(StartupData* startup_blob);
9914 
9915  /** Set the callback to invoke in case of Dcheck failures. */
9916  static void SetDcheckErrorHandler(DcheckErrorCallback that);
9917 
9918 
9919  /**
9920  * Sets V8 flags from a string.
9921  */
9922  static void SetFlagsFromString(const char* str);
9923  static void SetFlagsFromString(const char* str, size_t length);
9924 
9925  /**
9926  * Sets V8 flags from the command line.
9927  */
9928  static void SetFlagsFromCommandLine(int* argc,
9929  char** argv,
9930  bool remove_flags);
9931 
9932  /** Get the version string. */
9933  static const char* GetVersion();
9934 
9935  /**
9936  * Initializes V8. This function needs to be called before the first Isolate
9937  * is created. It always returns true.
9938  */
9939  V8_INLINE static bool Initialize() {
9940  const int kBuildConfiguration =
9941  (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) |
9942  (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) |
9943  (internal::HeapSandboxIsEnabled() ? kHeapSandbox : 0);
9944  return Initialize(kBuildConfiguration);
9945  }
9946 
9947  /**
9948  * Allows the host application to provide a callback which can be used
9949  * as a source of entropy for random number generators.
9950  */
9951  static void SetEntropySource(EntropySource source);
9952 
9953  /**
9954  * Allows the host application to provide a callback that allows v8 to
9955  * cooperate with a profiler that rewrites return addresses on stack.
9956  */
9958  ReturnAddressLocationResolver return_address_resolver);
9959 
9960  /**
9961  * Releases any resources used by v8 and stops any utility threads
9962  * that may be running. Note that disposing v8 is permanent, it
9963  * cannot be reinitialized.
9964  *
9965  * It should generally not be necessary to dispose v8 before exiting
9966  * a process, this should happen automatically. It is only necessary
9967  * to use if the process needs the resources taken up by v8.
9968  */
9969  static bool Dispose();
9970 
9971  /**
9972  * Initialize the ICU library bundled with V8. The embedder should only
9973  * invoke this method when using the bundled ICU. Returns true on success.
9974  *
9975  * If V8 was compiled with the ICU data in an external file, the location
9976  * of the data file has to be provided.
9977  */
9978  static bool InitializeICU(const char* icu_data_file = nullptr);
9979 
9980  /**
9981  * Initialize the ICU library bundled with V8. The embedder should only
9982  * invoke this method when using the bundled ICU. If V8 was compiled with
9983  * the ICU data in an external file and when the default location of that
9984  * file should be used, a path to the executable must be provided.
9985  * Returns true on success.
9986  *
9987  * The default is a file called icudtl.dat side-by-side with the executable.
9988  *
9989  * Optionally, the location of the data file can be provided to override the
9990  * default.
9991  */
9992  static bool InitializeICUDefaultLocation(const char* exec_path,
9993  const char* icu_data_file = nullptr);
9994 
9995  /**
9996  * Initialize the external startup data. The embedder only needs to
9997  * invoke this method when external startup data was enabled in a build.
9998  *
9999  * If V8 was compiled with the startup data in an external file, then
10000  * V8 needs to be given those external files during startup. There are
10001  * three ways to do this:
10002  * - InitializeExternalStartupData(const char*)
10003  * This will look in the given directory for the file "snapshot_blob.bin".
10004  * - InitializeExternalStartupDataFromFile(const char*)
10005  * As above, but will directly use the given file name.
10006  * - Call SetSnapshotDataBlob.
10007  * This will read the blobs from the given data structure and will
10008  * not perform any file IO.
10009  */
10010  static void InitializeExternalStartupData(const char* directory_path);
10011  static void InitializeExternalStartupDataFromFile(const char* snapshot_blob);
10012 
10013  /**
10014  * Sets the v8::Platform to use. This should be invoked before V8 is
10015  * initialized.
10016  */
10017  static void InitializePlatform(Platform* platform);
10018 
10019  /**
10020  * Clears all references to the v8::Platform. This should be invoked after
10021  * V8 was disposed.
10022  */
10023  static void ShutdownPlatform();
10024 
10025 #if V8_OS_POSIX
10026  /**
10027  * Give the V8 signal handler a chance to handle a fault.
10028  *
10029  * This function determines whether a memory access violation can be recovered
10030  * by V8. If so, it will return true and modify context to return to a code
10031  * fragment that can recover from the fault. Otherwise, TryHandleSignal will
10032  * return false.
10033  *
10034  * The parameters to this function correspond to those passed to a Linux
10035  * signal handler.
10036  *
10037  * \param signal_number The signal number.
10038  *
10039  * \param info A pointer to the siginfo_t structure provided to the signal
10040  * handler.
10041  *
10042  * \param context The third argument passed to the Linux signal handler, which
10043  * points to a ucontext_t structure.
10044  */
10045  V8_DEPRECATED("Use TryHandleWebAssemblyTrapPosix")
10046  static bool TryHandleSignal(int signal_number, void* info, void* context);
10047 #endif // V8_OS_POSIX
10048 
10049  /**
10050  * Activate trap-based bounds checking for WebAssembly.
10051  *
10052  * \param use_v8_signal_handler Whether V8 should install its own signal
10053  * handler or rely on the embedder's.
10054  */
10055  static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler);
10056 
10057 #if defined(V8_OS_WIN)
10058  /**
10059  * On Win64, by default V8 does not emit unwinding data for jitted code,
10060  * which means the OS cannot walk the stack frames and the system Structured
10061  * Exception Handling (SEH) cannot unwind through V8-generated code:
10062  * https://code.google.com/p/v8/issues/detail?id=3598.
10063  *
10064  * This function allows embedders to register a custom exception handler for
10065  * exceptions in V8-generated code.
10066  */
10067  static void SetUnhandledExceptionCallback(
10069 #endif
10070 
10071  /**
10072  * Get statistics about the shared memory usage.
10073  */
10074  static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
10075 
10076  /**
10077  * Notifies V8 that the process is cross-origin-isolated, which enables
10078  * defining the SharedArrayBuffer function on the global object of Contexts.
10079  */
10080  static void SetIsCrossOriginIsolated();
10081 
10082  private:
10083  V8();
10084 
10085  enum BuildConfigurationFeatures {
10086  kPointerCompression = 1 << 0,
10087  k31BitSmis = 1 << 1,
10088  kHeapSandbox = 1 << 2,
10089  };
10090 
10091  /**
10092  * Checks that the embedder build configuration is compatible with
10093  * the V8 binary and if so initializes V8.
10094  */
10095  static bool Initialize(int build_config);
10096 
10097  static internal::Address* GlobalizeReference(internal::Isolate* isolate,
10098  internal::Address* handle);
10099  static internal::Address* GlobalizeTracedReference(internal::Isolate* isolate,
10100  internal::Address* handle,
10101  internal::Address* slot,
10102  bool has_destructor);
10103  static void MoveGlobalReference(internal::Address** from,
10104  internal::Address** to);
10105  static void MoveTracedGlobalReference(internal::Address** from,
10106  internal::Address** to);
10107  static void CopyTracedGlobalReference(const internal::Address* const* from,
10108  internal::Address** to);
10109  static internal::Address* CopyGlobalReference(internal::Address* from);
10110  static void DisposeGlobal(internal::Address* global_handle);
10111  static void DisposeTracedGlobal(internal::Address* global_handle);
10112  static void MakeWeak(internal::Address* location, void* data,
10113  WeakCallbackInfo<void>::Callback weak_callback,
10114  WeakCallbackType type);
10115  static void MakeWeak(internal::Address** location_addr);
10116  static void* ClearWeak(internal::Address* location);
10117  static void SetFinalizationCallbackTraced(
10118  internal::Address* location, void* parameter,
10119  WeakCallbackInfo<void>::Callback callback);
10120  static void AnnotateStrongRetainer(internal::Address* location,
10121  const char* label);
10122  static Value* Eternalize(Isolate* isolate, Value* handle);
10123 
10124  template <class K, class V, class T>
10126 
10127  static void FromJustIsNothing();
10128  static void ToLocalEmpty();
10129  static void InternalFieldOutOfBounds(int index);
10130  template <class T>
10131  friend class BasicTracedReference;
10132  template <class T>
10133  friend class Global;
10134  template <class T> friend class Local;
10135  template <class T>
10136  friend class MaybeLocal;
10137  template <class T>
10138  friend class Maybe;
10139  template <class T>
10140  friend class TracedGlobal;
10141  friend class TracedReferenceBase;
10142  template <class T>
10143  friend class TracedReference;
10144  template <class T>
10145  friend class WeakCallbackInfo;
10146  template <class T> friend class Eternal;
10147  template <class T> friend class PersistentBase;
10148  template <class T, class M> friend class Persistent;
10149  friend class Context;
10150 };
10151 
10152 /**
10153  * Helper class to create a snapshot data blob.
10154  *
10155  * The Isolate used by a SnapshotCreator is owned by it, and will be entered
10156  * and exited by the constructor and destructor, respectively; The destructor
10157  * will also destroy the Isolate. Experimental language features, including
10158  * those available by default, are not available while creating a snapshot.
10159  */
10161  public:
10163 
10164  /**
10165  * Initialize and enter an isolate, and set it up for serialization.
10166  * The isolate is either created from scratch or from an existing snapshot.
10167  * The caller keeps ownership of the argument snapshot.
10168  * \param existing_blob existing snapshot from which to create this one.
10169  * \param external_references a null-terminated array of external references
10170  * that must be equivalent to CreateParams::external_references.
10171  */
10172  SnapshotCreator(Isolate* isolate,
10173  const intptr_t* external_references = nullptr,
10174  StartupData* existing_blob = nullptr);
10175 
10176  /**
10177  * Create and enter an isolate, and set it up for serialization.
10178  * The isolate is either created from scratch or from an existing snapshot.
10179  * The caller keeps ownership of the argument snapshot.
10180  * \param existing_blob existing snapshot from which to create this one.
10181  * \param external_references a null-terminated array of external references
10182  * that must be equivalent to CreateParams::external_references.
10183  */
10184  SnapshotCreator(const intptr_t* external_references = nullptr,
10185  StartupData* existing_blob = nullptr);
10186 
10187  /**
10188  * Destroy the snapshot creator, and exit and dispose of the Isolate
10189  * associated with it.
10190  */
10191  ~SnapshotCreator();
10192 
10193  /**
10194  * \returns the isolate prepared by the snapshot creator.
10195  */
10196  Isolate* GetIsolate();
10197 
10198  /**
10199  * Set the default context to be included in the snapshot blob.
10200  * The snapshot will not contain the global proxy, and we expect one or a
10201  * global object template to create one, to be provided upon deserialization.
10202  *
10203  * \param callback optional callback to serialize internal fields.
10204  */
10205  void SetDefaultContext(Local<Context> context,
10208 
10209  /**
10210  * Add additional context to be included in the snapshot blob.
10211  * The snapshot will include the global proxy.
10212  *
10213  * \param callback optional callback to serialize internal fields.
10214  *
10215  * \returns the index of the context in the snapshot blob.
10216  */
10217  size_t AddContext(Local<Context> context,
10220 
10221  /**
10222  * Attach arbitrary V8::Data to the context snapshot, which can be retrieved
10223  * via Context::GetDataFromSnapshot after deserialization. This data does not
10224  * survive when a new snapshot is created from an existing snapshot.
10225  * \returns the index for retrieval.
10226  */
10227  template <class T>
10228  V8_INLINE size_t AddData(Local<Context> context, Local<T> object);
10229 
10230  /**
10231  * Attach arbitrary V8::Data to the isolate snapshot, which can be retrieved
10232  * via Isolate::GetDataFromSnapshot after deserialization. This data does not
10233  * survive when a new snapshot is created from an existing snapshot.
10234  * \returns the index for retrieval.
10235  */
10236  template <class T>
10237  V8_INLINE size_t AddData(Local<T> object);
10238 
10239  /**
10240  * Created a snapshot data blob.
10241  * This must not be called from within a handle scope.
10242  * \param function_code_handling whether to include compiled function code
10243  * in the snapshot.
10244  * \returns { nullptr, 0 } on failure, and a startup snapshot on success. The
10245  * caller acquires ownership of the data array in the return value.
10246  */
10247  StartupData CreateBlob(FunctionCodeHandling function_code_handling);
10248 
10249  // Disallow copying and assigning.
10250  SnapshotCreator(const SnapshotCreator&) = delete;
10251  void operator=(const SnapshotCreator&) = delete;
10252 
10253  private:
10254  size_t AddData(Local<Context> context, internal::Address object);
10255  size_t AddData(internal::Address object);
10256 
10257  void* data_;
10258 };
10259 
10260 /**
10261  * A simple Maybe type, representing an object which may or may not have a
10262  * value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
10263  *
10264  * If an API method returns a Maybe<>, the API method can potentially fail
10265  * either because an exception is thrown, or because an exception is pending,
10266  * e.g. because a previous API call threw an exception that hasn't been caught
10267  * yet, or because a TerminateExecution exception was thrown. In that case, a
10268  * "Nothing" value is returned.
10269  */
10270 template <class T>
10271 class Maybe {
10272  public:
10273  V8_INLINE bool IsNothing() const { return !has_value_; }
10274  V8_INLINE bool IsJust() const { return has_value_; }
10275 
10276  /**
10277  * An alias for |FromJust|. Will crash if the Maybe<> is nothing.
10278  */
10279  V8_INLINE T ToChecked() const { return FromJust(); }
10280 
10281  /**
10282  * Short-hand for ToChecked(), which doesn't return a value. To be used, where
10283  * the actual value of the Maybe is not needed like Object::Set.
10284  */
10285  V8_INLINE void Check() const {
10286  if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
10287  }
10288 
10289  /**
10290  * Converts this Maybe<> to a value of type T. If this Maybe<> is
10291  * nothing (empty), |false| is returned and |out| is left untouched.
10292  */
10293  V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const {
10294  if (V8_LIKELY(IsJust())) *out = value_;
10295  return IsJust();
10296  }
10297 
10298  /**
10299  * Converts this Maybe<> to a value of type T. If this Maybe<> is
10300  * nothing (empty), V8 will crash the process.
10301  */
10302  V8_INLINE T FromJust() const {
10303  if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
10304  return value_;
10305  }
10306 
10307  /**
10308  * Converts this Maybe<> to a value of type T, using a default value if this
10309  * Maybe<> is nothing (empty).
10310  */
10311  V8_INLINE T FromMaybe(const T& default_value) const {
10312  return has_value_ ? value_ : default_value;
10313  }
10314 
10315  V8_INLINE bool operator==(const Maybe& other) const {
10316  return (IsJust() == other.IsJust()) &&
10317  (!IsJust() || FromJust() == other.FromJust());
10318  }
10319 
10320  V8_INLINE bool operator!=(const Maybe& other) const {
10321  return !operator==(other);
10322  }
10323 
10324  private:
10325  Maybe() : has_value_(false) {}
10326  explicit Maybe(const T& t) : has_value_(true), value_(t) {}
10327 
10328  bool has_value_;
10329  T value_;
10330 
10331  template <class U>
10332  friend Maybe<U> Nothing();
10333  template <class U>
10334  friend Maybe<U> Just(const U& u);
10335 };
10336 
10337 template <class T>
10338 inline Maybe<T> Nothing() {
10339  return Maybe<T>();
10340 }
10341 
10342 template <class T>
10343 inline Maybe<T> Just(const T& t) {
10344  return Maybe<T>(t);
10345 }
10346 
10347 // A template specialization of Maybe<T> for the case of T = void.
10348 template <>
10349 class Maybe<void> {
10350  public:
10351  V8_INLINE bool IsNothing() const { return !is_valid_; }
10352  V8_INLINE bool IsJust() const { return is_valid_; }
10353 
10354  V8_INLINE bool operator==(const Maybe& other) const {
10355  return IsJust() == other.IsJust();
10356  }
10357 
10358  V8_INLINE bool operator!=(const Maybe& other) const {
10359  return !operator==(other);
10360  }
10361 
10362  private:
10363  struct JustTag {};
10364 
10365  Maybe() : is_valid_(false) {}
10366  explicit Maybe(JustTag) : is_valid_(true) {}
10367 
10368  bool is_valid_;
10369 
10370  template <class U>
10371  friend Maybe<U> Nothing();
10372  friend Maybe<void> JustVoid();
10373 };
10374 
10375 inline Maybe<void> JustVoid() { return Maybe<void>(Maybe<void>::JustTag()); }
10376 
10377 /**
10378  * An external exception handler.
10379  */
10381  public:
10382  /**
10383  * Creates a new try/catch block and registers it with v8. Note that
10384  * all TryCatch blocks should be stack allocated because the memory
10385  * location itself is compared against JavaScript try/catch blocks.
10386  */
10387  explicit TryCatch(Isolate* isolate);
10388 
10389  /**
10390  * Unregisters and deletes this try/catch block.
10391  */
10392  ~TryCatch();
10393 
10394  /**
10395  * Returns true if an exception has been caught by this try/catch block.
10396  */
10397  bool HasCaught() const;
10398 
10399  /**
10400  * For certain types of exceptions, it makes no sense to continue execution.
10401  *
10402  * If CanContinue returns false, the correct action is to perform any C++
10403  * cleanup needed and then return. If CanContinue returns false and
10404  * HasTerminated returns true, it is possible to call
10405  * CancelTerminateExecution in order to continue calling into the engine.
10406  */
10407  bool CanContinue() const;
10408 
10409  /**
10410  * Returns true if an exception has been caught due to script execution
10411  * being terminated.
10412  *
10413  * There is no JavaScript representation of an execution termination
10414  * exception. Such exceptions are thrown when the TerminateExecution
10415  * methods are called to terminate a long-running script.
10416  *
10417  * If such an exception has been thrown, HasTerminated will return true,
10418  * indicating that it is possible to call CancelTerminateExecution in order
10419  * to continue calling into the engine.
10420  */
10421  bool HasTerminated() const;
10422 
10423  /**
10424  * Throws the exception caught by this TryCatch in a way that avoids
10425  * it being caught again by this same TryCatch. As with ThrowException
10426  * it is illegal to execute any JavaScript operations after calling
10427  * ReThrow; the caller must return immediately to where the exception
10428  * is caught.
10429  */
10430  Local<Value> ReThrow();
10431 
10432  /**
10433  * Returns the exception caught by this try/catch block. If no exception has
10434  * been caught an empty handle is returned.
10435  */
10436  Local<Value> Exception() const;
10437 
10438  /**
10439  * Returns the .stack property of an object. If no .stack
10440  * property is present an empty handle is returned.
10441  */
10443  Local<Context> context, Local<Value> exception);
10444 
10445  /**
10446  * Returns the .stack property of the thrown object. If no .stack property is
10447  * present or if this try/catch block has not caught an exception, an empty
10448  * handle is returned.
10449  */
10451  Local<Context> context) const;
10452 
10453  /**
10454  * Returns the message associated with this exception. If there is
10455  * no message associated an empty handle is returned.
10456  */
10457  Local<v8::Message> Message() const;
10458 
10459  /**
10460  * Clears any exceptions that may have been caught by this try/catch block.
10461  * After this method has been called, HasCaught() will return false. Cancels
10462  * the scheduled exception if it is caught and ReThrow() is not called before.
10463  *
10464  * It is not necessary to clear a try/catch block before using it again; if
10465  * another exception is thrown the previously caught exception will just be
10466  * overwritten. However, it is often a good idea since it makes it easier
10467  * to determine which operation threw a given exception.
10468  */
10469  void Reset();
10470 
10471  /**
10472  * Set verbosity of the external exception handler.
10473  *
10474  * By default, exceptions that are caught by an external exception
10475  * handler are not reported. Call SetVerbose with true on an
10476  * external exception handler to have exceptions caught by the
10477  * handler reported as if they were not caught.
10478  */
10479  void SetVerbose(bool value);
10480 
10481  /**
10482  * Returns true if verbosity is enabled.
10483  */
10484  bool IsVerbose() const;
10485 
10486  /**
10487  * Set whether or not this TryCatch should capture a Message object
10488  * which holds source information about where the exception
10489  * occurred. True by default.
10490  */
10491  void SetCaptureMessage(bool value);
10492 
10493  /**
10494  * There are cases when the raw address of C++ TryCatch object cannot be
10495  * used for comparisons with addresses into the JS stack. The cases are:
10496  * 1) ARM, ARM64 and MIPS simulators which have separate JS stack.
10497  * 2) Address sanitizer allocates local C++ object in the heap when
10498  * UseAfterReturn mode is enabled.
10499  * This method returns address that can be used for comparisons with
10500  * addresses into the JS stack. When neither simulator nor ASAN's
10501  * UseAfterReturn is enabled, then the address returned will be the address
10502  * of the C++ try catch handler itself.
10503  */
10504  static void* JSStackComparableAddress(TryCatch* handler) {
10505  if (handler == nullptr) return nullptr;
10506  return handler->js_stack_comparable_address_;
10507  }
10508 
10509  TryCatch(const TryCatch&) = delete;
10510  void operator=(const TryCatch&) = delete;
10511 
10512  private:
10513  // Declaring operator new and delete as deleted is not spec compliant.
10514  // Therefore declare them private instead to disable dynamic alloc
10515  void* operator new(size_t size);
10516  void* operator new[](size_t size);
10517  void operator delete(void*, size_t);
10518  void operator delete[](void*, size_t);
10519 
10520  void ResetInternal();
10521 
10522  internal::Isolate* isolate_;
10523  TryCatch* next_;
10524  void* exception_;
10525  void* message_obj_;
10526  void* js_stack_comparable_address_;
10527  bool is_verbose_ : 1;
10528  bool can_continue_ : 1;
10529  bool capture_message_ : 1;
10530  bool rethrow_ : 1;
10531  bool has_terminated_ : 1;
10532 
10533  friend class internal::Isolate;
10534 };
10535 
10536 
10537 // --- Context ---
10538 
10539 
10540 /**
10541  * A container for extension names.
10542  */
10544  public:
10545  ExtensionConfiguration() : name_count_(0), names_(nullptr) {}
10546  ExtensionConfiguration(int name_count, const char* names[])
10547  : name_count_(name_count), names_(names) { }
10548 
10549  const char** begin() const { return &names_[0]; }
10550  const char** end() const { return &names_[name_count_]; }
10551 
10552  private:
10553  const int name_count_;
10554  const char** names_;
10555 };
10556 
10557 /**
10558  * A sandboxed execution context with its own set of built-in objects
10559  * and functions.
10560  */
10561 class V8_EXPORT Context : public Data {
10562  public:
10563  /**
10564  * Returns the global proxy object.
10565  *
10566  * Global proxy object is a thin wrapper whose prototype points to actual
10567  * context's global object with the properties like Object, etc. This is done
10568  * that way for security reasons (for more details see
10569  * https://wiki.mozilla.org/Gecko:SplitWindow).
10570  *
10571  * Please note that changes to global proxy object prototype most probably
10572  * would break VM---v8 expects only global object as a prototype of global
10573  * proxy object.
10574  */
10575  Local<Object> Global();
10576 
10577  /**
10578  * Detaches the global object from its context before
10579  * the global object can be reused to create a new context.
10580  */
10581  void DetachGlobal();
10582 
10583  /**
10584  * Creates a new context and returns a handle to the newly allocated
10585  * context.
10586  *
10587  * \param isolate The isolate in which to create the context.
10588  *
10589  * \param extensions An optional extension configuration containing
10590  * the extensions to be installed in the newly created context.
10591  *
10592  * \param global_template An optional object template from which the
10593  * global object for the newly created context will be created.
10594  *
10595  * \param global_object An optional global object to be reused for
10596  * the newly created context. This global object must have been
10597  * created by a previous call to Context::New with the same global
10598  * template. The state of the global object will be completely reset
10599  * and only object identify will remain.
10600  */
10601  static Local<Context> New(
10602  Isolate* isolate, ExtensionConfiguration* extensions = nullptr,
10604  MaybeLocal<Value> global_object = MaybeLocal<Value>(),
10605  DeserializeInternalFieldsCallback internal_fields_deserializer =
10607  MicrotaskQueue* microtask_queue = nullptr);
10608 
10609  /**
10610  * Create a new context from a (non-default) context snapshot. There
10611  * is no way to provide a global object template since we do not create
10612  * a new global object from template, but we can reuse a global object.
10613  *
10614  * \param isolate See v8::Context::New.
10615  *
10616  * \param context_snapshot_index The index of the context snapshot to
10617  * deserialize from. Use v8::Context::New for the default snapshot.
10618  *
10619  * \param embedder_fields_deserializer Optional callback to deserialize
10620  * internal fields. It should match the SerializeInternalFieldCallback used
10621  * to serialize.
10622  *
10623  * \param extensions See v8::Context::New.
10624  *
10625  * \param global_object See v8::Context::New.
10626  */
10628  Isolate* isolate, size_t context_snapshot_index,
10629  DeserializeInternalFieldsCallback embedder_fields_deserializer =
10631  ExtensionConfiguration* extensions = nullptr,
10632  MaybeLocal<Value> global_object = MaybeLocal<Value>(),
10633  MicrotaskQueue* microtask_queue = nullptr);
10634 
10635  /**
10636  * Returns an global object that isn't backed by an actual context.
10637  *
10638  * The global template needs to have access checks with handlers installed.
10639  * If an existing global object is passed in, the global object is detached
10640  * from its context.
10641  *
10642  * Note that this is different from a detached context where all accesses to
10643  * the global proxy will fail. Instead, the access check handlers are invoked.
10644  *
10645  * It is also not possible to detach an object returned by this method.
10646  * Instead, the access check handlers need to return nothing to achieve the
10647  * same effect.
10648  *
10649  * It is possible, however, to create a new context from the global object
10650  * returned by this method.
10651  */
10653  Isolate* isolate, Local<ObjectTemplate> global_template,
10654  MaybeLocal<Value> global_object = MaybeLocal<Value>());
10655 
10656  /**
10657  * Sets the security token for the context. To access an object in
10658  * another context, the security tokens must match.
10659  */
10660  void SetSecurityToken(Local<Value> token);
10661 
10662  /** Restores the security token to the default value. */
10663  void UseDefaultSecurityToken();
10664 
10665  /** Returns the security token of this context.*/
10667 
10668  /**
10669  * Enter this context. After entering a context, all code compiled
10670  * and run is compiled and run in this context. If another context
10671  * is already entered, this old context is saved so it can be
10672  * restored when the new context is exited.
10673  */
10674  void Enter();
10675 
10676  /**
10677  * Exit this context. Exiting the current context restores the
10678  * context that was in place when entering the current context.
10679  */
10680  void Exit();
10681 
10682  /** Returns the isolate associated with a current context. */
10683  Isolate* GetIsolate();
10684 
10685  /** Returns the microtask queue associated with a current context. */
10687 
10688  /**
10689  * The field at kDebugIdIndex used to be reserved for the inspector.
10690  * It now serves no purpose.
10691  */
10693 
10694  /**
10695  * Return the number of fields allocated for embedder data.
10696  */
10697  uint32_t GetNumberOfEmbedderDataFields();
10698 
10699  /**
10700  * Gets the embedder data with the given index, which must have been set by a
10701  * previous call to SetEmbedderData with the same index.
10702  */
10703  V8_INLINE Local<Value> GetEmbedderData(int index);
10704 
10705  /**
10706  * Gets the binding object used by V8 extras. Extra natives get a reference
10707  * to this object and can use it to "export" functionality by adding
10708  * properties. Extra natives can also "import" functionality by accessing
10709  * properties added by the embedder using the V8 API.
10710  */
10712 
10713  /**
10714  * Sets the embedder data with the given index, growing the data as
10715  * needed. Note that index 0 currently has a special meaning for Chrome's
10716  * debugger.
10717  */
10718  void SetEmbedderData(int index, Local<Value> value);
10719 
10720  /**
10721  * Gets a 2-byte-aligned native pointer from the embedder data with the given
10722  * index, which must have been set by a previous call to
10723  * SetAlignedPointerInEmbedderData with the same index. Note that index 0
10724  * currently has a special meaning for Chrome's debugger.
10725  */
10727 
10728  /**
10729  * Sets a 2-byte-aligned native pointer in the embedder data with the given
10730  * index, growing the data as needed. Note that index 0 currently has a
10731  * special meaning for Chrome's debugger.
10732  */
10733  void SetAlignedPointerInEmbedderData(int index, void* value);
10734 
10735  /**
10736  * Control whether code generation from strings is allowed. Calling
10737  * this method with false will disable 'eval' and the 'Function'
10738  * constructor for code running in this context. If 'eval' or the
10739  * 'Function' constructor are used an exception will be thrown.
10740  *
10741  * If code generation from strings is not allowed the
10742  * V8::AllowCodeGenerationFromStrings callback will be invoked if
10743  * set before blocking the call to 'eval' or the 'Function'
10744  * constructor. If that callback returns true, the call will be
10745  * allowed, otherwise an exception will be thrown. If no callback is
10746  * set an exception will be thrown.
10747  */
10748  void AllowCodeGenerationFromStrings(bool allow);
10749 
10750  /**
10751  * Returns true if code generation from strings is allowed for the context.
10752  * For more details see AllowCodeGenerationFromStrings(bool) documentation.
10753  */
10755 
10756  /**
10757  * Sets the error description for the exception that is thrown when
10758  * code generation from strings is not allowed and 'eval' or the 'Function'
10759  * constructor are called.
10760  */
10762 
10763  /**
10764  * Return data that was previously attached to the context snapshot via
10765  * SnapshotCreator, and removes the reference to it.
10766  * Repeated call with the same index returns an empty MaybeLocal.
10767  */
10768  template <class T>
10769  V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
10770 
10771  /**
10772  * If callback is set, abort any attempt to execute JavaScript in this
10773  * context, call the specified callback, and throw an exception.
10774  * To unset abort, pass nullptr as callback.
10775  */
10776  using AbortScriptExecutionCallback = void (*)(Isolate* isolate,
10777  Local<Context> context);
10778  void SetAbortScriptExecution(AbortScriptExecutionCallback callback);
10779 
10780  /**
10781  * Returns the value that was set or restored by
10782  * SetContinuationPreservedEmbedderData(), if any.
10783  */
10785 
10786  /**
10787  * Sets a value that will be stored on continuations and reset while the
10788  * continuation runs.
10789  */
10791 
10792  /**
10793  * Stack-allocated class which sets the execution context for all
10794  * operations executed within a local scope.
10795  */
10797  public:
10798  explicit V8_INLINE Scope(Local<Context> context) : context_(context) {
10799  context_->Enter();
10800  }
10801  V8_INLINE ~Scope() { context_->Exit(); }
10802 
10803  private:
10804  Local<Context> context_;
10805  };
10806 
10807  /**
10808  * Stack-allocated class to support the backup incumbent settings object
10809  * stack.
10810  * https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack
10811  */
10812  class V8_EXPORT V8_NODISCARD BackupIncumbentScope final {
10813  public:
10814  /**
10815  * |backup_incumbent_context| is pushed onto the backup incumbent settings
10816  * object stack.
10817  */
10818  explicit BackupIncumbentScope(Local<Context> backup_incumbent_context);
10820 
10821  /**
10822  * Returns address that is comparable with JS stack address. Note that JS
10823  * stack may be allocated separately from the native stack. See also
10824  * |TryCatch::JSStackComparableAddress| for details.
10825  */
10826  uintptr_t JSStackComparableAddress() const {
10827  return js_stack_comparable_address_;
10828  }
10829 
10830  private:
10831  friend class internal::Isolate;
10832 
10833  Local<Context> backup_incumbent_context_;
10834  uintptr_t js_stack_comparable_address_ = 0;
10835  const BackupIncumbentScope* prev_ = nullptr;
10836  };
10837 
10838  V8_INLINE static Context* Cast(Data* data);
10839 
10840  private:
10841  friend class Value;
10842  friend class Script;
10843  friend class Object;
10844  friend class Function;
10845 
10846  static void CheckCast(Data* obj);
10847 
10848  internal::Address* GetDataFromSnapshotOnce(size_t index);
10849  Local<Value> SlowGetEmbedderData(int index);
10850  void* SlowGetAlignedPointerFromEmbedderData(int index);
10851 };
10852 
10853 /**
10854  * Multiple threads in V8 are allowed, but only one thread at a time is allowed
10855  * to use any given V8 isolate, see the comments in the Isolate class. The
10856  * definition of 'using a V8 isolate' includes accessing handles or holding onto
10857  * object pointers obtained from V8 handles while in the particular V8 isolate.
10858  * It is up to the user of V8 to ensure, perhaps with locking, that this
10859  * constraint is not violated. In addition to any other synchronization
10860  * mechanism that may be used, the v8::Locker and v8::Unlocker classes must be
10861  * used to signal thread switches to V8.
10862  *
10863  * v8::Locker is a scoped lock object. While it's active, i.e. between its
10864  * construction and destruction, the current thread is allowed to use the locked
10865  * isolate. V8 guarantees that an isolate can be locked by at most one thread at
10866  * any time. In other words, the scope of a v8::Locker is a critical section.
10867  *
10868  * Sample usage:
10869 * \code
10870  * ...
10871  * {
10872  * v8::Locker locker(isolate);
10873  * v8::Isolate::Scope isolate_scope(isolate);
10874  * ...
10875  * // Code using V8 and isolate goes here.
10876  * ...
10877  * } // Destructor called here
10878  * \endcode
10879  *
10880  * If you wish to stop using V8 in a thread A you can do this either by
10881  * destroying the v8::Locker object as above or by constructing a v8::Unlocker
10882  * object:
10883  *
10884  * \code
10885  * {
10886  * isolate->Exit();
10887  * v8::Unlocker unlocker(isolate);
10888  * ...
10889  * // Code not using V8 goes here while V8 can run in another thread.
10890  * ...
10891  * } // Destructor called here.
10892  * isolate->Enter();
10893  * \endcode
10894  *
10895  * The Unlocker object is intended for use in a long-running callback from V8,
10896  * where you want to release the V8 lock for other threads to use.
10897  *
10898  * The v8::Locker is a recursive lock, i.e. you can lock more than once in a
10899  * given thread. This can be useful if you have code that can be called either
10900  * from code that holds the lock or from code that does not. The Unlocker is
10901  * not recursive so you can not have several Unlockers on the stack at once, and
10902  * you can not use an Unlocker in a thread that is not inside a Locker's scope.
10903  *
10904  * An unlocker will unlock several lockers if it has to and reinstate the
10905  * correct depth of locking on its destruction, e.g.:
10906  *
10907  * \code
10908  * // V8 not locked.
10909  * {
10910  * v8::Locker locker(isolate);
10911  * Isolate::Scope isolate_scope(isolate);
10912  * // V8 locked.
10913  * {
10914  * v8::Locker another_locker(isolate);
10915  * // V8 still locked (2 levels).
10916  * {
10917  * isolate->Exit();
10918  * v8::Unlocker unlocker(isolate);
10919  * // V8 not locked.
10920  * }
10921  * isolate->Enter();
10922  * // V8 locked again (2 levels).
10923  * }
10924  * // V8 still locked (1 level).
10925  * }
10926  * // V8 Now no longer locked.
10927  * \endcode
10928  */
10930  public:
10931  /**
10932  * Initialize Unlocker for a given Isolate.
10933  */
10934  V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
10935 
10936  ~Unlocker();
10937  private:
10938  void Initialize(Isolate* isolate);
10939 
10940  internal::Isolate* isolate_;
10941 };
10942 
10943 
10945  public:
10946  /**
10947  * Initialize Locker for a given Isolate.
10948  */
10949  V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
10950 
10951  ~Locker();
10952 
10953  /**
10954  * Returns whether or not the locker for a given isolate, is locked by the
10955  * current thread.
10956  */
10957  static bool IsLocked(Isolate* isolate);
10958 
10959  /**
10960  * Returns whether v8::Locker is being used by this V8 instance.
10961  */
10962  static bool IsActive();
10963 
10964  // Disallow copying and assigning.
10965  Locker(const Locker&) = delete;
10966  void operator=(const Locker&) = delete;
10967 
10968  private:
10969  void Initialize(Isolate* isolate);
10970 
10971  bool has_lock_;
10972  bool top_level_;
10973  internal::Isolate* isolate_;
10974 };
10975 
10976 /**
10977  * Various helpers for skipping over V8 frames in a given stack.
10978  *
10979  * The unwinder API is only supported on the x64, ARM64 and ARM32 architectures.
10980  */
10982  public:
10983  /**
10984  * Attempt to unwind the stack to the most recent C++ frame. This function is
10985  * signal-safe and does not access any V8 state and thus doesn't require an
10986  * Isolate.
10987  *
10988  * The unwinder needs to know the location of the JS Entry Stub (a piece of
10989  * code that is run when C++ code calls into generated JS code). This is used
10990  * for edge cases where the current frame is being constructed or torn down
10991  * when the stack sample occurs.
10992  *
10993  * The unwinder also needs the virtual memory range of all possible V8 code
10994  * objects. There are two ranges required - the heap code range and the range
10995  * for code embedded in the binary.
10996  *
10997  * Available on x64, ARM64 and ARM32.
10998  *
10999  * \param code_pages A list of all of the ranges in which V8 has allocated
11000  * executable code. The caller should obtain this list by calling
11001  * Isolate::CopyCodePages() during the same interrupt/thread suspension that
11002  * captures the stack.
11003  * \param register_state The current registers. This is an in-out param that
11004  * will be overwritten with the register values after unwinding, on success.
11005  * \param stack_base The resulting stack pointer and frame pointer values are
11006  * bounds-checked against the stack_base and the original stack pointer value
11007  * to ensure that they are valid locations in the given stack. If these values
11008  * or any intermediate frame pointer values used during unwinding are ever out
11009  * of these bounds, unwinding will fail.
11010  *
11011  * \return True on success.
11012  */
11013  static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
11014  size_t code_pages_length,
11015  const MemoryRange* code_pages,
11016  RegisterState* register_state,
11017  const void* stack_base);
11018 
11019  /**
11020  * Whether the PC is within the V8 code range represented by code_pages.
11021  *
11022  * If this returns false, then calling UnwindV8Frames() with the same PC
11023  * and unwind_state will always fail. If it returns true, then unwinding may
11024  * (but not necessarily) be successful.
11025  *
11026  * Available on x64, ARM64 and ARM32
11027  */
11028  static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
11029  void* pc);
11030 };
11031 
11032 // --- Implementation ---
11033 
11034 template <class T>
11035 Local<T> Local<T>::New(Isolate* isolate, Local<T> that) {
11036  return New(isolate, that.val_);
11037 }
11038 
11039 template <class T>
11040 Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
11041  return New(isolate, that.val_);
11042 }
11043 
11044 template <class T>
11045 Local<T> Local<T>::New(Isolate* isolate, const BasicTracedReference<T>& that) {
11046  return New(isolate, *that);
11047 }
11048 
11049 template <class T>
11050 Local<T> Local<T>::New(Isolate* isolate, T* that) {
11051  if (that == nullptr) return Local<T>();
11052  T* that_ptr = that;
11053  internal::Address* p = reinterpret_cast<internal::Address*>(that_ptr);
11054  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
11055  reinterpret_cast<internal::Isolate*>(isolate), *p)));
11056 }
11057 
11058 
11059 template<class T>
11060 template<class S>
11061 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
11062  static_assert(std::is_base_of<T, S>::value, "type check");
11063  val_ = reinterpret_cast<T*>(
11064  V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle)));
11065 }
11066 
11067 template <class T>
11068 Local<T> Eternal<T>::Get(Isolate* isolate) const {
11069  // The eternal handle will never go away, so as with the roots, we don't even
11070  // need to open a handle.
11071  return Local<T>(val_);
11072 }
11073 
11074 
11075 template <class T>
11077  if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
11078  return Local<T>(val_);
11079 }
11080 
11081 
11082 template <class T>
11083 void* WeakCallbackInfo<T>::GetInternalField(int index) const {
11084 #ifdef V8_ENABLE_CHECKS
11085  if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
11086  V8::InternalFieldOutOfBounds(index);
11087  }
11088 #endif
11089  return embedder_fields_[index];
11090 }
11091 
11092 
11093 template <class T>
11094 T* PersistentBase<T>::New(Isolate* isolate, T* that) {
11095  if (that == nullptr) return nullptr;
11096  internal::Address* p = reinterpret_cast<internal::Address*>(that);
11097  return reinterpret_cast<T*>(
11098  V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
11099  p));
11100 }
11101 
11102 
11103 template <class T, class M>
11104 template <class S, class M2>
11105 void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
11106  static_assert(std::is_base_of<T, S>::value, "type check");
11107  this->Reset();
11108  if (that.IsEmpty()) return;
11109  internal::Address* p = reinterpret_cast<internal::Address*>(that.val_);
11110  this->val_ = reinterpret_cast<T*>(V8::CopyGlobalReference(p));
11111  M::Copy(that, this);
11112 }
11113 
11114 template <class T>
11115 bool PersistentBase<T>::IsWeak() const {
11116  using I = internal::Internals;
11117  if (this->IsEmpty()) return false;
11118  return I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_)) ==
11120 }
11121 
11122 
11123 template <class T>
11124 void PersistentBase<T>::Reset() {
11125  if (this->IsEmpty()) return;
11126  V8::DisposeGlobal(reinterpret_cast<internal::Address*>(this->val_));
11127  val_ = nullptr;
11128 }
11129 
11130 
11131 template <class T>
11132 template <class S>
11133 void PersistentBase<T>::Reset(Isolate* isolate, const Local<S>& other) {
11134  static_assert(std::is_base_of<T, S>::value, "type check");
11135  Reset();
11136  if (other.IsEmpty()) return;
11137  this->val_ = New(isolate, other.val_);
11138 }
11139 
11140 
11141 template <class T>
11142 template <class S>
11143 void PersistentBase<T>::Reset(Isolate* isolate,
11144  const PersistentBase<S>& other) {
11145  static_assert(std::is_base_of<T, S>::value, "type check");
11146  Reset();
11147  if (other.IsEmpty()) return;
11148  this->val_ = New(isolate, other.val_);
11149 }
11150 
11151 
11152 template <class T>
11153 template <typename P>
11155  P* parameter, typename WeakCallbackInfo<P>::Callback callback,
11156  WeakCallbackType type) {
11157  using Callback = WeakCallbackInfo<void>::Callback;
11158 #if (__GNUC__ >= 8) && !defined(__clang__)
11159 #pragma GCC diagnostic push
11160 #pragma GCC diagnostic ignored "-Wcast-function-type"
11161 #endif
11162  V8::MakeWeak(reinterpret_cast<internal::Address*>(this->val_), parameter,
11163  reinterpret_cast<Callback>(callback), type);
11164 #if (__GNUC__ >= 8) && !defined(__clang__)
11165 #pragma GCC diagnostic pop
11166 #endif
11167 }
11168 
11169 template <class T>
11171  V8::MakeWeak(reinterpret_cast<internal::Address**>(&this->val_));
11172 }
11173 
11174 template <class T>
11175 template <typename P>
11176 P* PersistentBase<T>::ClearWeak() {
11177  return reinterpret_cast<P*>(
11178  V8::ClearWeak(reinterpret_cast<internal::Address*>(this->val_)));
11179 }
11180 
11181 template <class T>
11182 void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
11183  V8::AnnotateStrongRetainer(reinterpret_cast<internal::Address*>(this->val_),
11184  label);
11185 }
11186 
11187 template <class T>
11188 void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
11189  using I = internal::Internals;
11190  if (this->IsEmpty()) return;
11191  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
11192  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
11193  *reinterpret_cast<uint16_t*>(addr) = class_id;
11194 }
11195 
11196 
11197 template <class T>
11198 uint16_t PersistentBase<T>::WrapperClassId() const {
11199  using I = internal::Internals;
11200  if (this->IsEmpty()) return 0;
11201  internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
11202  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
11203  return *reinterpret_cast<uint16_t*>(addr);
11204 }
11205 
11206 template <class T>
11207 Global<T>::Global(Global&& other) : PersistentBase<T>(other.val_) {
11208  if (other.val_ != nullptr) {
11209  V8::MoveGlobalReference(reinterpret_cast<internal::Address**>(&other.val_),
11210  reinterpret_cast<internal::Address**>(&this->val_));
11211  other.val_ = nullptr;
11212  }
11213 }
11214 
11215 template <class T>
11216 template <class S>
11217 Global<T>& Global<T>::operator=(Global<S>&& rhs) {
11218  static_assert(std::is_base_of<T, S>::value, "type check");
11219  if (this != &rhs) {
11220  this->Reset();
11221  if (rhs.val_ != nullptr) {
11222  this->val_ = rhs.val_;
11223  V8::MoveGlobalReference(
11224  reinterpret_cast<internal::Address**>(&rhs.val_),
11225  reinterpret_cast<internal::Address**>(&this->val_));
11226  rhs.val_ = nullptr;
11227  }
11228  }
11229  return *this;
11230 }
11231 
11232 template <class T>
11234  Isolate* isolate, T* that, void* slot, DestructionMode destruction_mode) {
11235  if (that == nullptr) return nullptr;
11236  internal::Address* p = reinterpret_cast<internal::Address*>(that);
11237  return V8::GlobalizeTracedReference(
11238  reinterpret_cast<internal::Isolate*>(isolate), p,
11239  reinterpret_cast<internal::Address*>(slot),
11240  destruction_mode == kWithDestructor);
11241 }
11242 
11244  if (IsEmpty()) return;
11245  V8::DisposeTracedGlobal(reinterpret_cast<internal::Address*>(val_));
11246  SetSlotThreadSafe(nullptr);
11247 }
11248 
11250  if (IsEmpty()) return Local<Value>();
11251  return Local<Value>::New(isolate, reinterpret_cast<Value*>(val_));
11252 }
11253 
11255  const TracedReferenceBase& rhs) {
11256  v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
11257  v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(rhs.val_);
11258  if (a == nullptr) return b == nullptr;
11259  if (b == nullptr) return false;
11260  return *a == *b;
11261 }
11262 
11263 template <typename U>
11265  const v8::Local<U>& rhs) {
11266  v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
11267  v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(*rhs);
11268  if (a == nullptr) return b == nullptr;
11269  if (b == nullptr) return false;
11270  return *a == *b;
11271 }
11272 
11273 template <typename U>
11274 V8_INLINE bool operator==(const v8::Local<U>& lhs,
11275  const TracedReferenceBase& rhs) {
11276  return rhs == lhs;
11277 }
11278 
11280  const TracedReferenceBase& rhs) {
11281  return !(lhs == rhs);
11282 }
11283 
11284 template <typename U>
11286  const v8::Local<U>& rhs) {
11287  return !(lhs == rhs);
11288 }
11289 
11290 template <typename U>
11291 V8_INLINE bool operator!=(const v8::Local<U>& lhs,
11292  const TracedReferenceBase& rhs) {
11293  return !(rhs == lhs);
11294 }
11295 
11296 template <class T>
11297 template <class S>
11298 void TracedGlobal<T>::Reset(Isolate* isolate, const Local<S>& other) {
11299  static_assert(std::is_base_of<T, S>::value, "type check");
11300  Reset();
11301  if (other.IsEmpty()) return;
11302  this->val_ = this->New(isolate, other.val_, &this->val_,
11303  BasicTracedReference<T>::kWithDestructor);
11304 }
11305 
11306 template <class T>
11307 template <class S>
11309  static_assert(std::is_base_of<T, S>::value, "type check");
11310  *this = std::move(rhs.template As<T>());
11311  return *this;
11312 }
11313 
11314 template <class T>
11315 template <class S>
11317  static_assert(std::is_base_of<T, S>::value, "type check");
11318  *this = rhs.template As<T>();
11319  return *this;
11320 }
11321 
11322 template <class T>
11324  if (this != &rhs) {
11325  V8::MoveTracedGlobalReference(
11326  reinterpret_cast<internal::Address**>(&rhs.val_),
11327  reinterpret_cast<internal::Address**>(&this->val_));
11328  }
11329  return *this;
11330 }
11331 
11332 template <class T>
11334  if (this != &rhs) {
11335  this->Reset();
11336  if (rhs.val_ != nullptr) {
11337  V8::CopyTracedGlobalReference(
11338  reinterpret_cast<const internal::Address* const*>(&rhs.val_),
11339  reinterpret_cast<internal::Address**>(&this->val_));
11340  }
11341  }
11342  return *this;
11343 }
11344 
11345 template <class T>
11346 template <class S>
11347 void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other) {
11348  static_assert(std::is_base_of<T, S>::value, "type check");
11349  this->Reset();
11350  if (other.IsEmpty()) return;
11351  this->SetSlotThreadSafe(
11352  this->New(isolate, other.val_, &this->val_,
11353  BasicTracedReference<T>::kWithoutDestructor));
11354 }
11355 
11356 template <class T>
11357 template <class S>
11359  static_assert(std::is_base_of<T, S>::value, "type check");
11360  *this = std::move(rhs.template As<T>());
11361  return *this;
11362 }
11363 
11364 template <class T>
11365 template <class S>
11367  const TracedReference<S>& rhs) {
11368  static_assert(std::is_base_of<T, S>::value, "type check");
11369  *this = rhs.template As<T>();
11370  return *this;
11371 }
11372 
11373 template <class T>
11375  if (this != &rhs) {
11376  V8::MoveTracedGlobalReference(
11377  reinterpret_cast<internal::Address**>(&rhs.val_),
11378  reinterpret_cast<internal::Address**>(&this->val_));
11379  }
11380  return *this;
11381 }
11382 
11383 template <class T>
11385  if (this != &rhs) {
11386  this->Reset();
11387  if (rhs.val_ != nullptr) {
11388  V8::CopyTracedGlobalReference(
11389  reinterpret_cast<const internal::Address* const*>(&rhs.val_),
11390  reinterpret_cast<internal::Address**>(&this->val_));
11391  }
11392  }
11393  return *this;
11394 }
11395 
11396 void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
11397  using I = internal::Internals;
11398  if (IsEmpty()) return;
11399  internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
11400  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
11401  *reinterpret_cast<uint16_t*>(addr) = class_id;
11402 }
11403 
11405  using I = internal::Internals;
11406  if (IsEmpty()) return 0;
11407  internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
11408  uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
11409  return *reinterpret_cast<uint16_t*>(addr);
11410 }
11411 
11412 template <class T>
11414  void* parameter, typename WeakCallbackInfo<void>::Callback callback) {
11415  V8::SetFinalizationCallbackTraced(
11416  reinterpret_cast<internal::Address*>(this->val_), parameter, callback);
11417 }
11418 
11419 template <typename T>
11420 ReturnValue<T>::ReturnValue(internal::Address* slot) : value_(slot) {}
11421 
11422 template <typename T>
11423 template <typename S>
11424 void ReturnValue<T>::Set(const Global<S>& handle) {
11425  static_assert(std::is_base_of<T, S>::value, "type check");
11426  if (V8_UNLIKELY(handle.IsEmpty())) {
11427  *value_ = GetDefaultValue();
11428  } else {
11429  *value_ = *reinterpret_cast<internal::Address*>(*handle);
11430  }
11431 }
11432 
11433 template <typename T>
11434 template <typename S>
11435 void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
11436  static_assert(std::is_base_of<T, S>::value, "type check");
11437  if (V8_UNLIKELY(handle.IsEmpty())) {
11438  *value_ = GetDefaultValue();
11439  } else {
11440  *value_ = *reinterpret_cast<internal::Address*>(handle.val_);
11441  }
11442 }
11443 
11444 template <typename T>
11445 template <typename S>
11446 void ReturnValue<T>::Set(const Local<S> handle) {
11447  static_assert(std::is_void<T>::value || std::is_base_of<T, S>::value,
11448  "type check");
11449  if (V8_UNLIKELY(handle.IsEmpty())) {
11450  *value_ = GetDefaultValue();
11451  } else {
11452  *value_ = *reinterpret_cast<internal::Address*>(*handle);
11453  }
11454 }
11455 
11456 template<typename T>
11457 void ReturnValue<T>::Set(double i) {
11458  static_assert(std::is_base_of<T, Number>::value, "type check");
11460 }
11461 
11462 template<typename T>
11463 void ReturnValue<T>::Set(int32_t i) {
11464  static_assert(std::is_base_of<T, Integer>::value, "type check");
11465  using I = internal::Internals;
11466  if (V8_LIKELY(I::IsValidSmi(i))) {
11467  *value_ = I::IntToSmi(i);
11468  return;
11469  }
11471 }
11472 
11473 template<typename T>
11474 void ReturnValue<T>::Set(uint32_t i) {
11475  static_assert(std::is_base_of<T, Integer>::value, "type check");
11476  // Can't simply use INT32_MAX here for whatever reason.
11477  bool fits_into_int32_t = (i & (1U << 31)) == 0;
11478  if (V8_LIKELY(fits_into_int32_t)) {
11479  Set(static_cast<int32_t>(i));
11480  return;
11481  }
11483 }
11484 
11485 template<typename T>
11486 void ReturnValue<T>::Set(bool value) {
11487  static_assert(std::is_base_of<T, Boolean>::value, "type check");
11488  using I = internal::Internals;
11489  int root_index;
11490  if (value) {
11491  root_index = I::kTrueValueRootIndex;
11492  } else {
11493  root_index = I::kFalseValueRootIndex;
11494  }
11495  *value_ = *I::GetRoot(GetIsolate(), root_index);
11496 }
11497 
11498 template<typename T>
11499 void ReturnValue<T>::SetNull() {
11500  static_assert(std::is_base_of<T, Primitive>::value, "type check");
11501  using I = internal::Internals;
11503 }
11504 
11505 template<typename T>
11507  static_assert(std::is_base_of<T, Primitive>::value, "type check");
11508  using I = internal::Internals;
11510 }
11511 
11512 template<typename T>
11514  static_assert(std::is_base_of<T, String>::value, "type check");
11515  using I = internal::Internals;
11517 }
11518 
11519 template <typename T>
11521  // Isolate is always the pointer below the default value on the stack.
11522  return *reinterpret_cast<Isolate**>(&value_[-2]);
11523 }
11524 
11525 template <typename T>
11526 Local<Value> ReturnValue<T>::Get() const {
11527  using I = internal::Internals;
11529  return Local<Value>(*Undefined(GetIsolate()));
11530  return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
11531 }
11532 
11533 template <typename T>
11534 template <typename S>
11535 void ReturnValue<T>::Set(S* whatever) {
11536  static_assert(sizeof(S) < 0, "incompilable to prevent inadvertent misuse");
11537 }
11538 
11539 template <typename T>
11540 internal::Address ReturnValue<T>::GetDefaultValue() {
11541  // Default value is always the pointer below value_ on the stack.
11542  return value_[-1];
11543 }
11544 
11545 template <typename T>
11547  internal::Address* values,
11548  int length)
11549  : implicit_args_(implicit_args), values_(values), length_(length) {}
11550 
11551 template<typename T>
11553  // values_ points to the first argument (not the receiver).
11554  if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
11555  return Local<Value>(reinterpret_cast<Value*>(values_ + i));
11556 }
11557 
11558 
11559 template<typename T>
11561  // values_ points to the first argument (not the receiver).
11562  return Local<Object>(reinterpret_cast<Object*>(values_ - 1));
11563 }
11564 
11565 
11566 template<typename T>
11568  return Local<Object>(reinterpret_cast<Object*>(
11570 }
11571 
11572 template <typename T>
11574  return Local<Value>(
11575  reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex]));
11576 }
11577 
11578 template <typename T>
11580  return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
11581 }
11582 
11583 
11584 template<typename T>
11586  return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
11587 }
11588 
11589 
11590 template<typename T>
11593 }
11594 
11595 
11596 template<typename T>
11598  return !NewTarget()->IsUndefined();
11599 }
11600 
11601 
11602 template<typename T>
11603 int FunctionCallbackInfo<T>::Length() const {
11604  return length_;
11605 }
11606 
11608  Local<Value> resource_name, Local<Integer> line_offset,
11609  Local<Integer> column_offset, Local<Boolean> is_shared_cross_origin,
11610  Local<Integer> script_id, Local<Value> source_map_url,
11611  Local<Boolean> is_opaque, Local<Boolean> is_wasm, Local<Boolean> is_module,
11612  Local<PrimitiveArray> host_defined_options)
11613  : ScriptOrigin(
11614  Isolate::GetCurrent(), resource_name,
11615  line_offset.IsEmpty() ? 0 : static_cast<int>(line_offset->Value()),
11616  column_offset.IsEmpty() ? 0
11617  : static_cast<int>(column_offset->Value()),
11618  !is_shared_cross_origin.IsEmpty() && is_shared_cross_origin->IsTrue(),
11619  static_cast<int>(script_id.IsEmpty() ? -1 : script_id->Value()),
11620  source_map_url, !is_opaque.IsEmpty() && is_opaque->IsTrue(),
11621  !is_wasm.IsEmpty() && is_wasm->IsTrue(),
11622  !is_module.IsEmpty() && is_module->IsTrue(), host_defined_options) {}
11623 
11624 ScriptOrigin::ScriptOrigin(Local<Value> resource_name, int line_offset,
11625  int column_offset, bool is_shared_cross_origin,
11626  int script_id, Local<Value> source_map_url,
11627  bool is_opaque, bool is_wasm, bool is_module,
11628  Local<PrimitiveArray> host_defined_options)
11629  : isolate_(Isolate::GetCurrent()),
11630  resource_name_(resource_name),
11631  resource_line_offset_(line_offset),
11632  resource_column_offset_(column_offset),
11633  options_(is_shared_cross_origin, is_opaque, is_wasm, is_module),
11634  script_id_(script_id),
11635  source_map_url_(source_map_url),
11636  host_defined_options_(host_defined_options) {}
11637 
11638 ScriptOrigin::ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
11639  int line_offset, int column_offset,
11640  bool is_shared_cross_origin, int script_id,
11641  Local<Value> source_map_url, bool is_opaque,
11642  bool is_wasm, bool is_module,
11643  Local<PrimitiveArray> host_defined_options)
11644  : isolate_(isolate),
11645  resource_name_(resource_name),
11646  resource_line_offset_(line_offset),
11647  resource_column_offset_(column_offset),
11648  options_(is_shared_cross_origin, is_opaque, is_wasm, is_module),
11649  script_id_(script_id),
11650  source_map_url_(source_map_url),
11651  host_defined_options_(host_defined_options) {}
11652 
11653 Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
11654 
11656  return host_defined_options_;
11657 }
11658 
11660  return v8::Integer::New(isolate_, resource_line_offset_);
11661 }
11662 
11664  return v8::Integer::New(isolate_, resource_column_offset_);
11665 }
11666 
11668  return v8::Integer::New(isolate_, script_id_);
11669 }
11670 
11671 int ScriptOrigin::LineOffset() const { return resource_line_offset_; }
11672 
11673 int ScriptOrigin::ColumnOffset() const { return resource_column_offset_; }
11674 
11675 int ScriptOrigin::ScriptId() const { return script_id_; }
11676 
11677 Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
11678 
11680  CachedData* data)
11681  : source_string(string),
11682  resource_name(origin.ResourceName()),
11683  resource_line_offset(origin.LineOffset()),
11684  resource_column_offset(origin.ColumnOffset()),
11685  resource_options(origin.Options()),
11686  source_map_url(origin.SourceMapUrl()),
11687  host_defined_options(origin.HostDefinedOptions()),
11688  cached_data(data) {}
11689 
11691  CachedData* data)
11692  : source_string(string), cached_data(data) {}
11693 
11694 
11696  delete cached_data;
11697 }
11698 
11699 
11701  const {
11702  return cached_data;
11703 }
11704 
11706  return resource_options;
11707 }
11708 
11709 Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
11710  return value ? True(isolate) : False(isolate);
11711 }
11712 
11713 void Template::Set(Isolate* isolate, const char* name, Local<Data> value) {
11716  value);
11717 }
11718 
11720 #ifdef V8_ENABLE_CHECKS
11721  CheckCast(data);
11722 #endif
11723  return reinterpret_cast<FunctionTemplate*>(data);
11724 }
11725 
11727 #ifdef V8_ENABLE_CHECKS
11728  CheckCast(data);
11729 #endif
11730  return reinterpret_cast<ObjectTemplate*>(data);
11731 }
11732 
11734 #ifdef V8_ENABLE_CHECKS
11735  CheckCast(data);
11736 #endif
11737  return reinterpret_cast<Signature*>(data);
11738 }
11739 
11741 #ifdef V8_ENABLE_CHECKS
11742  CheckCast(data);
11743 #endif
11744  return reinterpret_cast<AccessorSignature*>(data);
11745 }
11746 
11748 #ifndef V8_ENABLE_CHECKS
11749  using A = internal::Address;
11750  using I = internal::Internals;
11751  A obj = *reinterpret_cast<A*>(this);
11752  // Fast path: If the object is a plain JSObject, which is the common case, we
11753  // know where to find the internal fields and can return the value directly.
11754  auto instance_type = I::GetInstanceType(obj);
11755  if (instance_type == I::kJSObjectType ||
11756  instance_type == I::kJSApiObjectType ||
11757  instance_type == I::kJSSpecialApiObjectType) {
11758  int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
11759  A value = I::ReadRawField<A>(obj, offset);
11760 #ifdef V8_COMPRESS_POINTERS
11761  // We read the full pointer value and then decompress it in order to avoid
11762  // dealing with potential endiannes issues.
11763  value = I::DecompressTaggedAnyField(obj, static_cast<uint32_t>(value));
11764 #endif
11765  internal::Isolate* isolate =
11767  A* result = HandleScope::CreateHandle(isolate, value);
11768  return Local<Value>(reinterpret_cast<Value*>(result));
11769  }
11770 #endif
11771  return SlowGetInternalField(index);
11772 }
11773 
11774 
11776 #ifndef V8_ENABLE_CHECKS
11777  using A = internal::Address;
11778  using I = internal::Internals;
11779  A obj = *reinterpret_cast<A*>(this);
11780  // Fast path: If the object is a plain JSObject, which is the common case, we
11781  // know where to find the internal fields and can return the value directly.
11782  auto instance_type = I::GetInstanceType(obj);
11783  if (V8_LIKELY(instance_type == I::kJSObjectType ||
11784  instance_type == I::kJSApiObjectType ||
11785  instance_type == I::kJSSpecialApiObjectType)) {
11786  int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
11787 #ifdef V8_HEAP_SANDBOX
11788  offset += I::kEmbedderDataSlotRawPayloadOffset;
11789 #endif
11790  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
11791  A value = I::ReadExternalPointerField(
11792  isolate, obj, offset, internal::kEmbedderDataSlotPayloadTag);
11793  return reinterpret_cast<void*>(value);
11794  }
11795 #endif
11796  return SlowGetAlignedPointerFromInternalField(index);
11797 }
11798 
11799 String* String::Cast(v8::Data* data) {
11800 #ifdef V8_ENABLE_CHECKS
11801  CheckCast(data);
11802 #endif
11803  return static_cast<String*>(data);
11804 }
11805 
11807  using S = internal::Address;
11808  using I = internal::Internals;
11809  I::CheckInitialized(isolate);
11810  S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
11811  return Local<String>(reinterpret_cast<String*>(slot));
11812 }
11813 
11814 
11816  using A = internal::Address;
11817  using I = internal::Internals;
11818  A obj = *reinterpret_cast<const A*>(this);
11819 
11820  ExternalStringResource* result;
11822  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
11823  A value =
11826  result = reinterpret_cast<String::ExternalStringResource*>(value);
11827  } else {
11828  result = GetExternalStringResourceSlow();
11829  }
11830 #ifdef V8_ENABLE_CHECKS
11831  VerifyExternalStringResource(result);
11832 #endif
11833  return result;
11834 }
11835 
11836 
11838  String::Encoding* encoding_out) const {
11839  using A = internal::Address;
11840  using I = internal::Internals;
11841  A obj = *reinterpret_cast<const A*>(this);
11843  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
11844  ExternalStringResourceBase* resource;
11845  if (type == I::kExternalOneByteRepresentationTag ||
11847  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(obj);
11848  A value =
11851  resource = reinterpret_cast<ExternalStringResourceBase*>(value);
11852  } else {
11853  resource = GetExternalStringResourceBaseSlow(encoding_out);
11854  }
11855 #ifdef V8_ENABLE_CHECKS
11856  VerifyExternalStringResourceBase(resource, *encoding_out);
11857 #endif
11858  return resource;
11859 }
11860 
11861 
11862 bool Value::IsUndefined() const {
11863 #ifdef V8_ENABLE_CHECKS
11864  return FullIsUndefined();
11865 #else
11866  return QuickIsUndefined();
11867 #endif
11868 }
11869 
11870 bool Value::QuickIsUndefined() const {
11871  using A = internal::Address;
11872  using I = internal::Internals;
11873  A obj = *reinterpret_cast<const A*>(this);
11874  if (!I::HasHeapObjectTag(obj)) return false;
11875  if (I::GetInstanceType(obj) != I::kOddballType) return false;
11877 }
11878 
11879 
11880 bool Value::IsNull() const {
11881 #ifdef V8_ENABLE_CHECKS
11882  return FullIsNull();
11883 #else
11884  return QuickIsNull();
11885 #endif
11886 }
11887 
11888 bool Value::QuickIsNull() const {
11889  using A = internal::Address;
11890  using I = internal::Internals;
11891  A obj = *reinterpret_cast<const A*>(this);
11892  if (!I::HasHeapObjectTag(obj)) return false;
11893  if (I::GetInstanceType(obj) != I::kOddballType) return false;
11894  return (I::GetOddballKind(obj) == I::kNullOddballKind);
11895 }
11896 
11897 bool Value::IsNullOrUndefined() const {
11898 #ifdef V8_ENABLE_CHECKS
11899  return FullIsNull() || FullIsUndefined();
11900 #else
11901  return QuickIsNullOrUndefined();
11902 #endif
11903 }
11904 
11905 bool Value::QuickIsNullOrUndefined() const {
11906  using A = internal::Address;
11907  using I = internal::Internals;
11908  A obj = *reinterpret_cast<const A*>(this);
11909  if (!I::HasHeapObjectTag(obj)) return false;
11910  if (I::GetInstanceType(obj) != I::kOddballType) return false;
11911  int kind = I::GetOddballKind(obj);
11912  return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind;
11913 }
11914 
11915 bool Value::IsString() const {
11916 #ifdef V8_ENABLE_CHECKS
11917  return FullIsString();
11918 #else
11919  return QuickIsString();
11920 #endif
11921 }
11922 
11923 bool Value::QuickIsString() const {
11924  using A = internal::Address;
11925  using I = internal::Internals;
11926  A obj = *reinterpret_cast<const A*>(this);
11927  if (!I::HasHeapObjectTag(obj)) return false;
11929 }
11930 
11931 
11932 template <class T> Value* Value::Cast(T* value) {
11933  return static_cast<Value*>(value);
11934 }
11935 
11936 template <>
11938 #ifdef V8_ENABLE_CHECKS
11939  CheckCast(value);
11940 #endif
11941  return static_cast<Value*>(value);
11942 }
11943 
11945 #ifdef V8_ENABLE_CHECKS
11946  CheckCast(data);
11947 #endif
11948  return static_cast<Boolean*>(data);
11949 }
11950 
11951 Name* Name::Cast(v8::Data* data) {
11952 #ifdef V8_ENABLE_CHECKS
11953  CheckCast(data);
11954 #endif
11955  return static_cast<Name*>(data);
11956 }
11957 
11958 Symbol* Symbol::Cast(v8::Data* data) {
11959 #ifdef V8_ENABLE_CHECKS
11960  CheckCast(data);
11961 #endif
11962  return static_cast<Symbol*>(data);
11963 }
11964 
11966 #ifdef V8_ENABLE_CHECKS
11967  CheckCast(data);
11968 #endif
11969  return reinterpret_cast<Private*>(data);
11970 }
11971 
11973 #ifdef V8_ENABLE_CHECKS
11974  CheckCast(data);
11975 #endif
11976  return reinterpret_cast<ModuleRequest*>(data);
11977 }
11978 
11980 #ifdef V8_ENABLE_CHECKS
11981  CheckCast(data);
11982 #endif
11983  return reinterpret_cast<Module*>(data);
11984 }
11985 
11986 Number* Number::Cast(v8::Data* data) {
11987 #ifdef V8_ENABLE_CHECKS
11988  CheckCast(data);
11989 #endif
11990  return static_cast<Number*>(data);
11991 }
11992 
11994 #ifdef V8_ENABLE_CHECKS
11995  CheckCast(data);
11996 #endif
11997  return static_cast<Integer*>(data);
11998 }
11999 
12000 Int32* Int32::Cast(v8::Data* data) {
12001 #ifdef V8_ENABLE_CHECKS
12002  CheckCast(data);
12003 #endif
12004  return static_cast<Int32*>(data);
12005 }
12006 
12007 Uint32* Uint32::Cast(v8::Data* data) {
12008 #ifdef V8_ENABLE_CHECKS
12009  CheckCast(data);
12010 #endif
12011  return static_cast<Uint32*>(data);
12012 }
12013 
12014 BigInt* BigInt::Cast(v8::Data* data) {
12015 #ifdef V8_ENABLE_CHECKS
12016  CheckCast(data);
12017 #endif
12018  return static_cast<BigInt*>(data);
12019 }
12020 
12022 #ifdef V8_ENABLE_CHECKS
12023  CheckCast(data);
12024 #endif
12025  return static_cast<Context*>(data);
12026 }
12027 
12028 Date* Date::Cast(v8::Value* value) {
12029 #ifdef V8_ENABLE_CHECKS
12030  CheckCast(value);
12031 #endif
12032  return static_cast<Date*>(value);
12033 }
12034 
12035 
12037 #ifdef V8_ENABLE_CHECKS
12038  CheckCast(value);
12039 #endif
12040  return static_cast<StringObject*>(value);
12041 }
12042 
12043 
12045 #ifdef V8_ENABLE_CHECKS
12046  CheckCast(value);
12047 #endif
12048  return static_cast<SymbolObject*>(value);
12049 }
12050 
12051 
12053 #ifdef V8_ENABLE_CHECKS
12054  CheckCast(value);
12055 #endif
12056  return static_cast<NumberObject*>(value);
12057 }
12058 
12060 #ifdef V8_ENABLE_CHECKS
12061  CheckCast(value);
12062 #endif
12063  return static_cast<BigIntObject*>(value);
12064 }
12065 
12067 #ifdef V8_ENABLE_CHECKS
12068  CheckCast(value);
12069 #endif
12070  return static_cast<BooleanObject*>(value);
12071 }
12072 
12073 
12074 RegExp* RegExp::Cast(v8::Value* value) {
12075 #ifdef V8_ENABLE_CHECKS
12076  CheckCast(value);
12077 #endif
12078  return static_cast<RegExp*>(value);
12079 }
12080 
12081 
12082 Object* Object::Cast(v8::Value* value) {
12083 #ifdef V8_ENABLE_CHECKS
12084  CheckCast(value);
12085 #endif
12086  return static_cast<Object*>(value);
12087 }
12088 
12089 
12090 Array* Array::Cast(v8::Value* value) {
12091 #ifdef V8_ENABLE_CHECKS
12092  CheckCast(value);
12093 #endif
12094  return static_cast<Array*>(value);
12095 }
12096 
12097 
12098 Map* Map::Cast(v8::Value* value) {
12099 #ifdef V8_ENABLE_CHECKS
12100  CheckCast(value);
12101 #endif
12102  return static_cast<Map*>(value);
12103 }
12104 
12105 
12106 Set* Set::Cast(v8::Value* value) {
12107 #ifdef V8_ENABLE_CHECKS
12108  CheckCast(value);
12109 #endif
12110  return static_cast<Set*>(value);
12111 }
12112 
12113 
12115 #ifdef V8_ENABLE_CHECKS
12116  CheckCast(value);
12117 #endif
12118  return static_cast<Promise*>(value);
12119 }
12120 
12121 
12122 Proxy* Proxy::Cast(v8::Value* value) {
12123 #ifdef V8_ENABLE_CHECKS
12124  CheckCast(value);
12125 #endif
12126  return static_cast<Proxy*>(value);
12127 }
12128 
12130 #ifdef V8_ENABLE_CHECKS
12131  CheckCast(value);
12132 #endif
12133  return static_cast<WasmMemoryObject*>(value);
12134 }
12135 
12137 #ifdef V8_ENABLE_CHECKS
12138  CheckCast(value);
12139 #endif
12140  return static_cast<WasmModuleObject*>(value);
12141 }
12142 
12144 #ifdef V8_ENABLE_CHECKS
12145  CheckCast(value);
12146 #endif
12147  return static_cast<Promise::Resolver*>(value);
12148 }
12149 
12150 
12152 #ifdef V8_ENABLE_CHECKS
12153  CheckCast(value);
12154 #endif
12155  return static_cast<ArrayBuffer*>(value);
12156 }
12157 
12158 
12160 #ifdef V8_ENABLE_CHECKS
12161  CheckCast(value);
12162 #endif
12163  return static_cast<ArrayBufferView*>(value);
12164 }
12165 
12166 
12168 #ifdef V8_ENABLE_CHECKS
12169  CheckCast(value);
12170 #endif
12171  return static_cast<TypedArray*>(value);
12172 }
12173 
12174 
12176 #ifdef V8_ENABLE_CHECKS
12177  CheckCast(value);
12178 #endif
12179  return static_cast<Uint8Array*>(value);
12180 }
12181 
12182 
12184 #ifdef V8_ENABLE_CHECKS
12185  CheckCast(value);
12186 #endif
12187  return static_cast<Int8Array*>(value);
12188 }
12189 
12190 
12192 #ifdef V8_ENABLE_CHECKS
12193  CheckCast(value);
12194 #endif
12195  return static_cast<Uint16Array*>(value);
12196 }
12197 
12198 
12200 #ifdef V8_ENABLE_CHECKS
12201  CheckCast(value);
12202 #endif
12203  return static_cast<Int16Array*>(value);
12204 }
12205 
12206 
12208 #ifdef V8_ENABLE_CHECKS
12209  CheckCast(value);
12210 #endif
12211  return static_cast<Uint32Array*>(value);
12212 }
12213 
12214 
12216 #ifdef V8_ENABLE_CHECKS
12217  CheckCast(value);
12218 #endif
12219  return static_cast<Int32Array*>(value);
12220 }
12221 
12222 
12224 #ifdef V8_ENABLE_CHECKS
12225  CheckCast(value);
12226 #endif
12227  return static_cast<Float32Array*>(value);
12228 }
12229 
12230 
12232 #ifdef V8_ENABLE_CHECKS
12233  CheckCast(value);
12234 #endif
12235  return static_cast<Float64Array*>(value);
12236 }
12237 
12239 #ifdef V8_ENABLE_CHECKS
12240  CheckCast(value);
12241 #endif
12242  return static_cast<BigInt64Array*>(value);
12243 }
12244 
12246 #ifdef V8_ENABLE_CHECKS
12247  CheckCast(value);
12248 #endif
12249  return static_cast<BigUint64Array*>(value);
12250 }
12251 
12253 #ifdef V8_ENABLE_CHECKS
12254  CheckCast(value);
12255 #endif
12256  return static_cast<Uint8ClampedArray*>(value);
12257 }
12258 
12259 
12261 #ifdef V8_ENABLE_CHECKS
12262  CheckCast(value);
12263 #endif
12264  return static_cast<DataView*>(value);
12265 }
12266 
12267 
12269 #ifdef V8_ENABLE_CHECKS
12270  CheckCast(value);
12271 #endif
12272  return static_cast<SharedArrayBuffer*>(value);
12273 }
12274 
12275 
12277 #ifdef V8_ENABLE_CHECKS
12278  CheckCast(value);
12279 #endif
12280  return static_cast<Function*>(value);
12281 }
12282 
12283 
12285 #ifdef V8_ENABLE_CHECKS
12286  CheckCast(value);
12287 #endif
12288  return static_cast<External*>(value);
12289 }
12290 
12291 
12292 template<typename T>
12294  return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
12295 }
12296 
12297 
12298 template<typename T>
12300  return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
12301 }
12302 
12303 
12304 template<typename T>
12306  return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
12307 }
12308 
12309 
12310 template<typename T>
12312  return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
12313 }
12314 
12315 
12316 template<typename T>
12318  return ReturnValue<T>(&args_[kReturnValueIndex]);
12319 }
12320 
12321 template <typename T>
12323  using I = internal::Internals;
12327  }
12329  reinterpret_cast<v8::internal::Isolate*>(GetIsolate()));
12330 }
12331 
12333  using S = internal::Address;
12334  using I = internal::Internals;
12335  I::CheckInitialized(isolate);
12336  S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
12337  return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
12338 }
12339 
12340 
12342  using S = internal::Address;
12343  using I = internal::Internals;
12344  I::CheckInitialized(isolate);
12345  S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
12346  return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
12347 }
12348 
12349 
12351  using S = internal::Address;
12352  using I = internal::Internals;
12353  I::CheckInitialized(isolate);
12354  S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
12355  return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
12356 }
12357 
12358 
12360  using S = internal::Address;
12361  using I = internal::Internals;
12362  I::CheckInitialized(isolate);
12363  S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
12364  return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
12365 }
12366 
12367 
12368 void Isolate::SetData(uint32_t slot, void* data) {
12369  using I = internal::Internals;
12370  I::SetEmbedderData(this, slot, data);
12371 }
12372 
12373 
12374 void* Isolate::GetData(uint32_t slot) {
12375  using I = internal::Internals;
12376  return I::GetEmbedderData(this, slot);
12377 }
12378 
12379 
12381  using I = internal::Internals;
12382  return I::kNumIsolateDataSlots;
12383 }
12384 
12385 template <class T>
12387  T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
12388  if (data) internal::PerformCastCheck(data);
12389  return Local<T>(data);
12390 }
12391 
12393 #ifndef V8_ENABLE_CHECKS
12394  using A = internal::Address;
12395  using I = internal::Internals;
12396  A ctx = *reinterpret_cast<const A*>(this);
12397  A embedder_data =
12399  int value_offset =
12401  A value = I::ReadRawField<A>(embedder_data, value_offset);
12402 #ifdef V8_COMPRESS_POINTERS
12403  // We read the full pointer value and then decompress it in order to avoid
12404  // dealing with potential endiannes issues.
12405  value =
12406  I::DecompressTaggedAnyField(embedder_data, static_cast<uint32_t>(value));
12407 #endif
12409  *reinterpret_cast<A*>(this));
12410  A* result = HandleScope::CreateHandle(isolate, value);
12411  return Local<Value>(reinterpret_cast<Value*>(result));
12412 #else
12413  return SlowGetEmbedderData(index);
12414 #endif
12415 }
12416 
12417 
12419 #ifndef V8_ENABLE_CHECKS
12420  using A = internal::Address;
12421  using I = internal::Internals;
12422  A ctx = *reinterpret_cast<const A*>(this);
12423  A embedder_data =
12425  int value_offset =
12427 #ifdef V8_HEAP_SANDBOX
12428  value_offset += I::kEmbedderDataSlotRawPayloadOffset;
12429 #endif
12430  internal::Isolate* isolate = I::GetIsolateForHeapSandbox(ctx);
12431  return reinterpret_cast<void*>(
12432  I::ReadExternalPointerField(isolate, embedder_data, value_offset,
12434 #else
12435  return SlowGetAlignedPointerFromEmbedderData(index);
12436 #endif
12437 }
12438 
12439 template <class T>
12441  T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
12442  if (data) internal::PerformCastCheck(data);
12443  return Local<T>(data);
12444 }
12445 
12446 template <class T>
12447 size_t SnapshotCreator::AddData(Local<Context> context, Local<T> object) {
12448  T* object_ptr = *object;
12449  internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
12450  return AddData(context, *p);
12451 }
12452 
12453 template <class T>
12454 size_t SnapshotCreator::AddData(Local<T> object) {
12455  T* object_ptr = *object;
12456  internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
12457  return AddData(*p);
12458 }
12459 
12460 /**
12461  * \example shell.cc
12462  * A simple shell that takes a list of expressions on the
12463  * command-line and executes them.
12464  */
12465 
12466 
12467 /**
12468  * \example process.cc
12469  */
12470 
12471 
12472 } // namespace v8
12473 
12474 #endif // INCLUDE_V8_H_
v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO
@ CODE_ADD_LINE_POS_INFO
Definition: v8.h:8003
v8::Isolate::Scope::Scope
Scope(const Scope &)=delete
v8::ArrayBuffer::NewBackingStore
static std::unique_ptr< BackingStore > NewBackingStore(Isolate *isolate, size_t byte_length)
v8::Isolate::kWasmThreadOpcodes
@ kWasmThreadOpcodes
Definition: v8.h:8709
v8::Message::kNoColumnInfo
static const int kNoColumnInfo
Definition: v8.h:2245
v8::PropertyDescriptor::operator=
void operator=(const PropertyDescriptor &)=delete
v8::SideEffectType::kHasSideEffect
@ kHasSideEffect
v8::MemoryRange::start
const void * start
Definition: v8.h:2417
v8::ArrayBuffer::Allocator::NewDefaultAllocator
static Allocator * NewDefaultAllocator()
v8::Array::Cast
static V8_INLINE Array * Cast(Value *obj)
Definition: v8.h:12090
v8::JitCodeEvent::type
EventType type
Definition: v8.h:8023
v8::PropertyCallbackInfo::kIsolateIndex
static const int kIsolateIndex
Definition: v8.h:4687
v8::Isolate::kStringLocaleCompare
@ kStringLocaleCompare
Definition: v8.h:8720
v8::Module::CreateSyntheticModule
static Local< Module > CreateSyntheticModule(Isolate *isolate, Local< String > module_name, const std::vector< Local< String >> &export_names, SyntheticModuleEvaluationSteps evaluation_steps)
v8::Uint8ClampedArray::New
static Local< Uint8ClampedArray > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::EmbedderHeapTracer::RegisterEmbedderReference
void RegisterEmbedderReference(const BasicTracedReference< v8::Data > &ref)
v8::Isolate::RemoveNearHeapLimitCallback
void RemoveNearHeapLimitCallback(NearHeapLimitCallback callback, size_t heap_limit)
v8::Eternal::Get
V8_INLINE Local< T > Get(Isolate *isolate) const
Definition: v8.h:11068
v8::ArrayBufferCreationMode::kExternalized
@ kExternalized
v8::Promise::Catch
V8_WARN_UNUSED_RESULT MaybeLocal< Promise > Catch(Local< Context > context, Local< Function > handler)
v8::KeyConversionMode::kConvertToString
@ kConvertToString
V8_DEPRECATE_SOON
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:425
v8::internal::Internals::kFullStringRepresentationMask
static const int kFullStringRepresentationMask
Definition: v8-internal.h:197
v8::SnapshotCreator::GetIsolate
Isolate * GetIsolate()
v8::StackFrame::GetColumn
int GetColumn() const
v8::Isolate::Isolate
Isolate()=delete
v8::Map::AsArray
Local< Array > AsArray() const
v8::Persistent::As
V8_INLINE Persistent< S > & As() const
Definition: v8.h:737
v8::SharedArrayBuffer
Definition: v8.h:5877
v8::Object::GetPropertyAttributes
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetPropertyAttributes(Local< Context > context, Local< Value > key)
v8::Isolate::AllowJavascriptExecutionScope::operator=
AllowJavascriptExecutionScope & operator=(const AllowJavascriptExecutionScope &)=delete
v8::Isolate::kMessageAll
@ kMessageAll
Definition: v8.h:8783
v8::UnboundScript::BindToCurrentContext
Local< Script > BindToCurrentContext()
v8::HandleScope
Definition: v8.h:1200
v8::Isolate::AddGCPrologueCallback
void AddGCPrologueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
v8::External::Cast
static V8_INLINE External * Cast(Value *obj)
Definition: v8.h:12284
v8::Location::GetLineNumber
int GetLineNumber()
Definition: v8.h:1527
v8::GCType
GCType
Definition: v8.h:7820
v8::Isolate::GetJSEntryStubs
JSEntryStubs GetJSEntryStubs()
v8::Object::GetPropertyNames
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetPropertyNames(Local< Context > context, KeyCollectionMode mode, PropertyFilter property_filter, IndexFilter index_filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
v8::Value::ToObject
V8_WARN_UNUSED_RESULT MaybeLocal< Object > ToObject(Local< Context > context) const
V8_UNLIKELY
#define V8_UNLIKELY(condition)
Definition: v8config.h:443
v8::SerializeInternalFieldsCallback::callback
CallbackFunction callback
Definition: v8.h:8358
v8::Symbol::GetIterator
static Local< Symbol > GetIterator(Isolate *isolate)
v8::COMPILER
@ COMPILER
Definition: v8.h:2379
v8::internal::Internals::kFalseValueRootIndex
static const int kFalseValueRootIndex
Definition: v8-internal.h:227
v8::BasicTracedReference::operator->
T * operator->() const
Definition: v8.h:929
v8::ResourceConstraints::set_code_range_size_in_bytes
void set_code_range_size_in_bytes(size_t limit)
Definition: v8.h:7363
v8::Isolate::kArraySpeciesModified
@ kArraySpeciesModified
Definition: v8.h:8683
v8::Global::operator=
void operator=(const Global &)=delete
v8::Extension::GetNativeFunctionTemplate
virtual Local< FunctionTemplate > GetNativeFunctionTemplate(Isolate *isolate, Local< String > name)
Definition: v8.h:7266
v8::MeasureMemoryMode::kDetailed
@ kDetailed
v8::ValueDeserializer::operator=
void operator=(const ValueDeserializer &)=delete
v8::ValueSerializer::WriteUint32
void WriteUint32(uint32_t value)
v8::ValueDeserializer::ReadHeader
V8_WARN_UNUSED_RESULT Maybe< bool > ReadHeader(Local< Context > context)
v8::WeakCallbackInfo::GetInternalField
V8_INLINE void * GetInternalField(int index) const
Definition: v8.h:11083
v8::Symbol::New
static Local< Symbol > New(Isolate *isolate, Local< String > description=Local< String >())
v8::TracedGlobal::~TracedGlobal
~TracedGlobal()
Definition: v8.h:969
v8::String::ExternalOneByteStringResource
Definition: v8.h:3371
v8::ScriptCompiler::StreamedSource::UTF8
@ UTF8
Definition: v8.h:1939
v8::ScriptCompiler::Source
Definition: v8.h:1843
v8::MicrotaskQueue::RemoveMicrotasksCompletedCallback
virtual void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)=0
v8::Isolate::Scope::Scope
Scope(Isolate *isolate)
Definition: v8.h:8541
v8::WasmModuleObjectBuilderStreaming::WasmModuleObjectBuilderStreaming
WasmModuleObjectBuilderStreaming(Isolate *isolate)
v8::TracedGlobal::operator=
V8_INLINE TracedGlobal & operator=(TracedGlobal &&rhs)
Definition: v8.h:11323
v8::StringObject::New
static Local< Value > New(Isolate *isolate, Local< String > value)
v8::ReturnValue::Set
void Set(S *whatever)
Definition: v8.h:11535
v8::ScriptCompiler::kNoCacheBecauseStreamingSource
@ kNoCacheBecauseStreamingSource
Definition: v8.h:1991
v8::Name
Definition: v8.h:3123
v8::EmbedderHeapTracer::~EmbedderHeapTracer
virtual ~EmbedderHeapTracer()=default
v8::Global::Global
V8_INLINE Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8.h:785
v8::internal::Internals::ReadRawField
static V8_INLINE T ReadRawField(internal::Address heap_object_ptr, int offset)
Definition: v8-internal.h:340
v8::HandleScope::Initialize
void Initialize(Isolate *isolate)
v8::Context::kDebugIdIndex
@ kDebugIdIndex
Definition: v8.h:10692
v8::Symbol::Cast
static V8_INLINE Symbol * Cast(Data *data)
Definition: v8.h:11958
v8::ArrayBuffer::Contents::AllocationLength
size_t AllocationLength() const
Definition: v8.h:5417
v8::Context::GetExtrasBindingObject
Local< Object > GetExtrasBindingObject()
v8::ScriptOrigin::ResourceColumnOffset
V8_INLINE Local< Integer > ResourceColumnOffset() const
Definition: v8.h:11663
v8::Isolate::Scope::operator=
Scope & operator=(const Scope &)=delete
v8::Object::GetOwnPropertyDescriptor
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetOwnPropertyDescriptor(Local< Context > context, Local< Name > key)
v8::Isolate::kMinorGarbageCollection
@ kMinorGarbageCollection
Definition: v8.h:8649
v8::MicrotasksScope::operator=
MicrotasksScope & operator=(const MicrotasksScope &)=delete
v8::ScriptCompiler::StreamedSource::Encoding
Encoding
Definition: v8.h:1939
v8::ArrayBuffer::Allocator::AllocationMode
AllocationMode
Definition: v8.h:5383
v8::SnapshotCreator::SnapshotCreator
SnapshotCreator(const intptr_t *external_references=nullptr, StartupData *existing_blob=nullptr)
v8::String::ExternalStringResource::UpdateDataCache
void UpdateDataCache()
v8::CrashKeyId
CrashKeyId
Definition: v8.h:7471
v8::Isolate::kDecimalWithLeadingZeroInStrictMode
@ kDecimalWithLeadingZeroInStrictMode
Definition: v8.h:8690
v8::SnapshotCreator::CreateBlob
StartupData CreateBlob(FunctionCodeHandling function_code_handling)
v8::ArrayBufferView::ByteOffset
size_t ByteOffset()
v8::TryCatch::CanContinue
bool CanContinue() const
v8::Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope
~SuppressMicrotaskExecutionScope()
v8::Number
Definition: v8.h:3700
v8::Array::New
static Local< Array > New(Isolate *isolate, Local< Value > *elements, size_t length)
v8::TracedReferenceBase::WrapperClassId
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:11404
v8::ScriptOriginOptions::ScriptOriginOptions
V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin=false, bool is_opaque=false, bool is_wasm=false, bool is_module=false)
Definition: v8.h:1396
v8::Function::Call
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Call(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
v8::Isolate::kDateTimeFormat
@ kDateTimeFormat
Definition: v8.h:8714
v8::Object::Delete
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, uint32_t index)
v8::MicrotasksPolicy
MicrotasksPolicy
Definition: v8.h:7627
v8::V8::Initialize
static V8_INLINE bool Initialize()
Definition: v8.h:9939
v8::Promise::Result
Local< Value > Result()
v8::String::ExternalOneByteStringResource::UpdateDataCache
void UpdateDataCache()
v8::Value::IsFunction
bool IsFunction() const
v8::MeasureMemoryDelegate::Default
static std::unique_ptr< MeasureMemoryDelegate > Default(Isolate *isolate, Local< Context > context, Local< Promise::Resolver > promise_resolver, MeasureMemoryMode mode)
v8::NumberObject
Definition: v8.h:6099
v8::ObjectTemplate::IsImmutableProto
bool IsImmutableProto()
v8::ObjectTemplate::SetHandler
void SetHandler(const IndexedPropertyHandlerConfiguration &configuration)
v8::ValueDeserializer::~ValueDeserializer
~ValueDeserializer()
v8::FunctionCallbackInfo::IsConstructCall
V8_INLINE bool IsConstructCall() const
Definition: v8.h:11597
v8::Extension::Extension
Extension(const Extension &)=delete
v8::Value::IsUint16Array
bool IsUint16Array() const
v8::internal::wasm
Definition: v8.h:150
v8::internal::Internals::kNativeContextEmbedderDataOffset
static const int kNativeContextEmbedderDataOffset
Definition: v8-internal.h:196
v8::TracedGlobal::TracedGlobal
V8_INLINE TracedGlobal(TracedGlobal &&other)
Definition: v8.h:992
v8::JitCodeEvent::EventType
EventType
Definition: v8.h:7999
v8::ArrayBuffer::Allocator::AllocationMode::kReservation
@ kReservation
v8::ScriptCompiler::kNoCacheBecauseResourceWithNoCacheHandler
@ kNoCacheBecauseResourceWithNoCacheHandler
Definition: v8.h:1999
v8::Isolate::SetWasmExceptionsEnabledCallback
void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback)
v8::String::Encoding
Encoding
Definition: v8.h:3168
v8::StackTrace::kScriptId
@ kScriptId
Definition: v8.h:2272
v8::Eternal::Eternal
V8_INLINE Eternal()
Definition: v8.h:417
v8::internal::Internals::kJSObjectHeaderSize
static const int kJSObjectHeaderSize
Definition: v8-internal.h:189
v8::FunctionCallbackInfo::Length
V8_INLINE int Length() const
Definition: v8.h:11603
v8::V8::EnableWebAssemblyTrapHandler
static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler)
v8::Set::Size
size_t Size() const
v8::PrimitiveArray::New
static Local< PrimitiveArray > New(Isolate *isolate, int length)
v8::RegExp::kMultiline
@ kMultiline
Definition: v8.h:6191
v8::V8::SetFlagsFromString
static void SetFlagsFromString(const char *str)
v8::RegExp::kLinear
@ kLinear
Definition: v8.h:6195
v8::Isolate::SetPromiseHook
void SetPromiseHook(PromiseHook hook)
v8::MeasureMemoryExecution::kEager
@ kEager
v8::Isolate::SetFatalErrorHandler
void SetFatalErrorHandler(FatalErrorCallback that)
v8::Promise::kPending
@ kPending
Definition: v8.h:4819
v8::MicrotasksScope
Definition: v8.h:7721
v8::Isolate::kWasmBulkMemory
@ kWasmBulkMemory
Definition: v8.h:8767
v8::ResourceConstraints::max_young_generation_size_in_bytes
size_t max_young_generation_size_in_bytes() const
Definition: v8.h:7384
v8::Data
Definition: v8.h:1318
v8::Message::PrintCurrentStackTrace
static void PrintCurrentStackTrace(Isolate *isolate, FILE *out)
v8::ValueDeserializer::ValueDeserializer
ValueDeserializer(const ValueDeserializer &)=delete
v8::Isolate::kSegmenter
@ kSegmenter
Definition: v8.h:8719
v8::Object::IsUndetectable
bool IsUndetectable()
v8::Isolate::SetAtomicsWaitCallback
void SetAtomicsWaitCallback(AtomicsWaitCallback callback, void *data)
v8::Isolate::SetWasmInstanceCallback
void SetWasmInstanceCallback(ExtensionCallback callback)
v8::DataView::Cast
static V8_INLINE DataView * Cast(Value *obj)
Definition: v8.h:12260
v8::Promise::State
PromiseState State()
v8::Value::IsUint32Array
bool IsUint32Array() const
v8::FunctionCallbackInfo::kNewTargetIndex
static const int kNewTargetIndex
Definition: v8.h:4576
v8::PropertyDescriptor::PropertyDescriptor
PropertyDescriptor(const PropertyDescriptor &)=delete
v8::Map::Get
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy
@ kAssigmentExpressionLHSIsCallInSloppy
Definition: v8.h:8694
v8::Local::Local
V8_INLINE Local(Local< S > that)
Definition: v8.h:203
v8::internal::Internals::GetInstanceType
static V8_INLINE int GetInstanceType(const internal::Address obj)
Definition: v8-internal.h:279
v8::Location::GetColumnNumber
int GetColumnNumber()
Definition: v8.h:1528
v8::SealHandleScope::SealHandleScope
SealHandleScope(const SealHandleScope &)=delete
v8::Isolate::AtomicsWaitEvent::kWokenUp
@ kWokenUp
v8::Isolate::kIndexAccessor
@ kIndexAccessor
Definition: v8.h:8700
v8::StartupData::data
const char * data
Definition: v8.h:9867
v8::Value::IsPromise
bool IsPromise() const
v8::SnapshotCreator::FunctionCodeHandling
FunctionCodeHandling
Definition: v8.h:10162
v8::NamedPropertyHandlerConfiguration::descriptor
GenericNamedPropertyDescriptorCallback descriptor
Definition: v8.h:6934
v8::PrimitiveArray::Length
int Length() const
v8::Object::Has
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, Local< Value > key)
v8::Isolate::SetAddCrashKeyCallback
void SetAddCrashKeyCallback(AddCrashKeyCallback)
v8::Proxy::IsRevoked
bool IsRevoked()
v8::WasmModuleObjectBuilderStreaming::OnBytesReceived
void OnBytesReceived(const uint8_t *, size_t size)
v8::UnboundScript
Definition: v8.h:1487
v8::Private::ForApi
static Local< Private > ForApi(Isolate *isolate, Local< String > name)
v8::Name::GetIdentityHash
int GetIdentityHash()
v8::ArrayBuffer::GetBackingStore
std::shared_ptr< BackingStore > GetBackingStore()
v8::WasmModuleObject::FromCompiledModule
static MaybeLocal< WasmModuleObject > FromCompiledModule(Isolate *isolate, const CompiledWasmModule &)
v8::PropertyDescriptor::has_writable
bool has_writable() const
v8::Isolate::CreateParams::snapshot_blob
StartupData * snapshot_blob
Definition: v8.h:8473
v8::String::ExternalStringResourceBase
Definition: v8.h:3260
v8::Isolate::operator delete[]
void operator delete[](void *, size_t)=delete
v8::EmbedderHeapTracer::SetStackStart
void SetStackStart(void *stack_start)
v8::Global::Global
V8_INLINE Global(Global &&other)
Definition: v8.h:11207
v8::ScriptCompiler::kNoCacheBecauseModule
@ kNoCacheBecauseModule
Definition: v8.h:1990
v8::NamedPropertyHandlerConfiguration
Definition: v8.h:6869
v8::EmbedderHeapTracer::kReduceMemory
@ kReduceMemory
Definition: v8.h:8172
v8::PromiseHookType::kBefore
@ kBefore
v8::PersistentBase::Empty
V8_INLINE void Empty()
Definition: v8.h:511
v8::BigUint64Array::Cast
static V8_INLINE BigUint64Array * Cast(Value *obj)
Definition: v8.h:12245
v8::GlobalValueMap
Definition: v8-util.h:424
v8::Int16Array
Definition: v8.h:5744
v8::ScriptCompiler::kNoCacheBecauseV8Extension
@ kNoCacheBecauseV8Extension
Definition: v8.h:1995
v8::V8::ShutdownPlatform
static void ShutdownPlatform()
v8::ValueDeserializer::TransferArrayBuffer
void TransferArrayBuffer(uint32_t transfer_id, Local< ArrayBuffer > array_buffer)
v8::internal::Address
uintptr_t Address
Definition: v8-internal.h:24
v8::Isolate::kLegacyConst
@ kLegacyConst
Definition: v8.h:8660
v8::Object::GetIdentityHash
int GetIdentityHash()
v8::Location::Location
Location(int line_number, int column_number)
Definition: v8.h:1530
v8::BigUint64Array::New
static Local< BigUint64Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::ReturnValue::FunctionCallbackInfo
friend class FunctionCallbackInfo
Definition: v8.h:4514
v8::StackFrame::IsUserJavaScript
bool IsUserJavaScript() const
v8::Template::SetNativeDataProperty
void SetNativeDataProperty(Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::Isolate::CreateParams::embedder_wrapper_type_index
int embedder_wrapper_type_index
Definition: v8.h:8526
v8::CompiledWasmModule::source_url
const std::string & source_url() const
Definition: v8.h:5050
v8::TracedGlobal::TracedGlobal
V8_INLINE TracedGlobal(const TracedGlobal< S > &other)
Definition: v8.h:1018
v8::PropertyCallbackInfo::GetIsolate
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:12293
v8::MicrotaskQueue::~MicrotaskQueue
virtual ~MicrotaskQueue()=default
v8::SharedArrayBuffer::New
static Local< SharedArrayBuffer > New(Isolate *isolate, std::shared_ptr< BackingStore > backing_store)
v8::kGCTypeScavenge
@ kGCTypeScavenge
Definition: v8.h:7821
v8::Object::IsApiWrapper
bool IsApiWrapper()
v8::ScriptCompiler::kNoCacheBecauseInspector
@ kNoCacheBecauseInspector
Definition: v8.h:1992
v8::DeserializeInternalFieldsCallback::callback
void(* callback)(Local< Object > holder, int index, StartupData payload, void *data)
Definition: v8.h:8375
v8::Promise::Resolver::Resolve
V8_WARN_UNUSED_RESULT Maybe< bool > Resolve(Local< Context > context, Local< Value > value)
v8::Module::Cast
static V8_INLINE Module * Cast(Data *data)
Definition: v8.h:11979
v8::Symbol::GetToStringTag
static Local< Symbol > GetToStringTag(Isolate *isolate)
v8::Isolate::kStoreBufferOverflow
@ kStoreBufferOverflow
Definition: v8.h:8662
v8::BigUint64Array::New
static Local< BigUint64Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::Isolate::kObjectObserve
@ kObjectObserve
Definition: v8.h:8664
v8::Isolate::New
static Isolate * New(const CreateParams &params)
v8::Promise::Resolver::Cast
static V8_INLINE Resolver * Cast(Value *obj)
Definition: v8.h:12143
v8::PropertyAttribute
PropertyAttribute
Definition: v8.h:3813
v8::Isolate::SetOOMErrorHandler
void SetOOMErrorHandler(OOMErrorCallback that)
v8::UnboundModuleScript
Definition: v8.h:1518
v8::Value::IsUint8ClampedArray
bool IsUint8ClampedArray() const
v8::MaybeLocal::FromMaybe
V8_INLINE Local< S > FromMaybe(Local< S > default_value) const
Definition: v8.h:403
v8::Module::Status
Status
Definition: v8.h:1594
v8::PersistentBase::IsWeak
V8_INLINE bool IsWeak() const
Definition: v8.h:11115
v8::V8::Dispose
static bool Dispose()
v8::ScriptCompiler::kNoCacheBecauseCachingDisabled
@ kNoCacheBecauseCachingDisabled
Definition: v8.h:1987
v8::MemorySpan::size
constexpr size_t size() const
Definition: v8.h:5017
v8::NamedPropertyHandlerConfiguration::getter
GenericNamedPropertyGetterCallback getter
Definition: v8.h:6928
v8::String::UNKNOWN_ENCODING
@ UNKNOWN_ENCODING
Definition: v8.h:3169
v8::RegisterState::sp
void * sp
Definition: v8.h:2400
v8::StackFrame::GetScriptId
int GetScriptId() const
v8::IndexedPropertyHandlerConfiguration::data
Local< Value > data
Definition: v8.h:7005
v8::Context::UseDefaultSecurityToken
void UseDefaultSecurityToken()
v8::String::GetExternalStringResource
V8_INLINE ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:11815
v8::Uint8Array::Cast
static V8_INLINE Uint8Array * Cast(Value *obj)
Definition: v8.h:12175
v8::TracedReference::operator=
V8_INLINE TracedReference & operator=(TracedReference &&rhs)
Definition: v8.h:11374
v8::Object::HasRealNamedProperty
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealNamedProperty(Local< Context > context, Local< Name > key)
v8::Object::Has
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, uint32_t index)
v8::ArrayBuffer::Allocator::Allocate
virtual void * Allocate(size_t length)=0
v8::ReturnValue::Set
void Set(const Global< S > &handle)
Definition: v8.h:11424
v8::Eternal::Set
void Set(Isolate *isolate, Local< S > handle)
Definition: v8.h:11061
v8::ScriptCompiler::Compile
static V8_WARN_UNUSED_RESULT MaybeLocal< Script > Compile(Local< Context > context, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
v8::V8::GetVersion
static const char * GetVersion()
v8::Symbol::GetUnscopables
static Local< Symbol > GetUnscopables(Isolate *isolate)
v8::Message::GetEndColumn
int GetEndColumn() const
v8::MemoryPressureLevel
MemoryPressureLevel
Definition: v8.h:8157
v8::String::ExternalStringResource::~ExternalStringResource
~ExternalStringResource() override=default
v8::Template::Set
V8_INLINE void Set(Isolate *isolate, const char *name, Local< Data > value)
Definition: v8.h:11713
v8::Isolate::AddMessageListenerWithErrorLevel
bool AddMessageListenerWithErrorLevel(MessageCallback that, int message_levels, Local< Value > data=Local< Value >())
v8::FunctionCallbackInfo::Data
V8_INLINE Local< Value > Data() const
Definition: v8.h:11579
v8::PropertyCallbackInfo::Data
V8_INLINE Local< Value > Data() const
Definition: v8.h:12299
v8::NonCopyablePersistentTraits::Copy
static V8_INLINE void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
Definition: v8.h:635
v8::JitCodeEvent::POSITION
@ POSITION
Definition: v8.h:8012
v8::internal::Internals::SetEmbedderData
static V8_INLINE void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
Definition: v8-internal.h:316
v8::Extension::~Extension
virtual ~Extension()
Definition: v8.h:7265
v8::Global::operator=
Global< T > & operator=(Global< S > &&rhs)
Definition: v8.h:11217
v8::PERFORMANCE_ANIMATION
@ PERFORMANCE_ANIMATION
Definition: v8.h:8095
v8::Maybe::Check
V8_INLINE void Check() const
Definition: v8.h:10285
v8::internal::Internals::HasHeapObjectTag
static V8_INLINE bool HasHeapObjectTag(const internal::Address value)
Definition: v8-internal.h:263
v8::Map::Size
size_t Size() const
v8::Message::kNoWasmFunctionIndexInfo
static const int kNoWasmFunctionIndexInfo
Definition: v8.h:2247
v8::Isolate::kArrayPrototypeSortJSArrayModifiedPrototype
@ kArrayPrototypeSortJSArrayModifiedPrototype
Definition: v8.h:8706
v8::WasmModuleObject
Definition: v8.h:5080
v8::Isolate::GetCppHeap
CppHeap * GetCppHeap() const
v8::FunctionTemplate::SetClassName
void SetClassName(Local< String > name)
v8::Isolate::NumberOfTrackedHeapObjectTypes
size_t NumberOfTrackedHeapObjectTypes()
v8::internal::Internals::ReadExternalPointerField
static V8_INLINE internal::Address ReadExternalPointerField(internal::Isolate *isolate, internal::Address heap_object_ptr, int offset, ExternalPointerTag tag)
Definition: v8-internal.h:398
v8::Object::SetNativeDataProperty
V8_WARN_UNUSED_RESULT Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::MaybeLocal::ToLocal
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local< S > *out) const
Definition: v8.h:387
v8::Object::SetAccessor
V8_WARN_UNUSED_RESULT Maybe< bool > SetAccessor(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, MaybeLocal< Value > data=MaybeLocal< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::BooleanObject
Definition: v8.h:6129
v8::Context::EmbedderDataFields
EmbedderDataFields
Definition: v8.h:10692
v8::ObjectTemplate::SetAccessor
void SetAccessor(Local< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::ValueDeserializer::SetSupportsLegacyWireFormat
void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format)
v8::PropertyCallbackInfo::kArgsLength
static const int kArgsLength
Definition: v8.h:4679
v8::JitCodeEventOptions
JitCodeEventOptions
Definition: v8.h:8107
v8::Value::IsBooleanObject
bool IsBooleanObject() const
V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
Definition: v8.h:5231
v8::Value::IsModuleNamespaceObject
bool IsModuleNamespaceObject() const
v8::Data::IsValue
bool IsValue() const
v8::RegisterState::pc
void * pc
Definition: v8.h:2399
v8::String::IsExternalTwoByte
bool IsExternalTwoByte() const
v8::Value::ToString
V8_WARN_UNUSED_RESULT MaybeLocal< String > ToString(Local< Context > context) const
v8::StackFrame::IsConstructor
bool IsConstructor() const
v8::Isolate::TimeZoneDetection
TimeZoneDetection
Definition: v8.h:9808
v8::PersistentHandleVisitor::VisitPersistentHandle
virtual void VisitPersistentHandle(Persistent< Value > *value, uint16_t class_id)
Definition: v8.h:8145
v8::Undefined
V8_INLINE Local< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:12332
v8::ValueDeserializer::TransferSharedArrayBuffer
void TransferSharedArrayBuffer(uint32_t id, Local< SharedArrayBuffer > shared_array_buffer)
v8::ScriptCompiler::CompileOptions
CompileOptions
Definition: v8.h:1976
v8::Promise::Then
V8_WARN_UNUSED_RESULT MaybeLocal< Promise > Then(Local< Context > context, Local< Function > on_fulfilled, Local< Function > on_rejected)
v8::IndexFilter::kSkipIndices
@ kSkipIndices
v8::Isolate::kFunctionConstructorReturnedUndefined
@ kFunctionConstructorReturnedUndefined
Definition: v8.h:8693
v8::Isolate::kLabeledExpressionStatement
@ kLabeledExpressionStatement
Definition: v8.h:8698
v8::Module::SourceOffsetToLocation
Location SourceOffsetToLocation(int offset) const
v8::Isolate::CreateParams::create_histogram_callback
CreateHistogramCallback create_histogram_callback
Definition: v8.h:8487
v8::ONLY_ENUMERABLE
@ ONLY_ENUMERABLE
Definition: v8.h:3863
v8::TracedReference::operator=
TracedReference< T > & operator=(TracedReference< S > &&rhs)
Definition: v8.h:11358
v8::Maybe::FromJust
V8_INLINE T FromJust() const
Definition: v8.h:10302
v8::IndexedPropertyHandlerConfiguration::setter
IndexedPropertySetterCallback setter
Definition: v8.h:6999
v8::JitCodeEvent::wasm_source_info_t
Definition: v8.h:8054
v8::MicrotasksScope::PerformCheckpoint
static void PerformCheckpoint(Isolate *isolate)
v8::SharedArrayBuffer::Contents::DeleterData
void * DeleterData() const
Definition: v8.h:5911
v8::EscapableHandleScope::Escape
V8_INLINE Local< T > Escape(Local< T > value)
Definition: v8.h:1261
v8::Isolate::SetAbortOnUncaughtExceptionCallback
void SetAbortOnUncaughtExceptionCallback(AbortOnUncaughtExceptionCallback callback)
v8::ValueDeserializer::Delegate
Definition: v8.h:2585
v8::RegExp::kFlagCount
static constexpr int kFlagCount
Definition: v8.h:6199
v8::internal::Internals::kDontThrow
static const int kDontThrow
Definition: v8-internal.h:249
v8::Object::SetInternalField
void SetInternalField(int index, Local< Value > value)
v8::internal::Internals::IsExternalTwoByteString
static V8_INLINE bool IsExternalTwoByteString(int instance_type)
Definition: v8-internal.h:289
v8::Function::GetScriptOrigin
ScriptOrigin GetScriptOrigin() const
v8::TryCatch::Reset
void Reset()
v8::Isolate::Scope::~Scope
~Scope()
Definition: v8.h:8545
v8::MicrotasksPolicy::kAuto
@ kAuto
v8::KeyConversionMode
KeyConversionMode
Definition: v8.h:3904
v8::Private::New
static Local< Private > New(Isolate *isolate, Local< String > name=Local< String >())
v8::ScriptCompiler::CreateCodeCacheForFunction
static CachedData * CreateCodeCacheForFunction(Local< Function > function)
v8::String::ExternalStringResourceBase::Lock
virtual void Lock() const
Definition: v8.h:3297
v8::Promise::kRejected
@ kRejected
Definition: v8.h:4819
v8::ArrayBuffer::New
static Local< ArrayBuffer > New(Isolate *isolate, std::shared_ptr< BackingStore > backing_store)
v8::SymbolObject
Definition: v8.h:6161
v8::FunctionCallbackInfo::operator[]
V8_INLINE Local< Value > operator[](int i) const
Definition: v8.h:11552
v8::Array::New
static Local< Array > New(Isolate *isolate, int length=0)
v8::MicrotasksScope::MicrotasksScope
MicrotasksScope(Isolate *isolate, MicrotaskQueue *microtask_queue, Type type)
v8::ValueSerializer::Release
V8_WARN_UNUSED_RESULT std::pair< uint8_t *, size_t > Release()
v8::MaybeLocal::IsEmpty
V8_INLINE bool IsEmpty() const
Definition: v8.h:380
v8::StackTrace::kOverview
@ kOverview
Definition: v8.h:2274
v8::Value::IsMap
bool IsMap() const
v8::Extension::source
const String::ExternalOneByteStringResource * source() const
Definition: v8.h:7273
v8::ScriptCompiler::CachedData::CachedData
CachedData(const uint8_t *data, int length, BufferPolicy buffer_policy=BufferNotOwned)
v8::ScriptOrigin::ScriptId
V8_INLINE int ScriptId() const
Definition: v8.h:11675
v8::WasmStreaming::OnBytesReceived
void OnBytesReceived(const uint8_t *bytes, size_t size)
v8::PersistentHandleVisitor::~PersistentHandleVisitor
virtual ~PersistentHandleVisitor()=default
v8::String::ExternalStringResource::cached_data
const uint16_t * cached_data() const
Definition: v8.h:3341
v8::ScriptOriginOptions::IsOpaque
bool IsOpaque() const
Definition: v8.h:1409
v8::Data::IsPrivate
bool IsPrivate() const
v8::V8::Persistent
friend class Persistent
Definition: v8.h:10148
v8::Value::IsFloat32Array
bool IsFloat32Array() const
v8::SerializeInternalFieldsCallback
Definition: v8.h:8352
v8::BigInt::Int64Value
int64_t Int64Value(bool *lossless=nullptr) const
v8::ScriptCompiler::CachedData::rejected
bool rejected
Definition: v8.h:1832
v8::ScriptCompiler::kNoCompileOptions
@ kNoCompileOptions
Definition: v8.h:1977
v8::HeapSpaceStatistics::space_available_size
size_t space_available_size()
Definition: v8.h:7947
v8::MeasureMemoryDelegate::ShouldMeasure
virtual bool ShouldMeasure(Local< Context > context)=0
v8::TracedGlobal::TracedGlobal
TracedGlobal()
Definition: v8.h:974
v8::PropertyCallbackInfo::kReturnValueIndex
static const int kReturnValueIndex
Definition: v8.h:4689
v8::WasmStreaming::Finish
void Finish()
v8::Message::IsSharedCrossOrigin
bool IsSharedCrossOrigin() const
v8::FunctionCallbackInfo::kReturnValueIndex
static const int kReturnValueIndex
Definition: v8.h:4574
v8::MicrotaskQueue
Definition: v8.h:7644
v8::Maybe< void >::Nothing
friend Maybe< U > Nothing()
Definition: v8.h:10338
v8::Isolate::CreateParams::allow_atomics_wait
bool allow_atomics_wait
Definition: v8.h:8514
v8::Value::IsInt32Array
bool IsInt32Array() const
v8::String::Utf8Length
int Utf8Length(Isolate *isolate) const
v8::Uint8ClampedArray
Definition: v8.h:5693
v8::HeapCodeStatistics::HeapCodeStatistics
HeapCodeStatistics()
v8::StartupData
Definition: v8.h:9853
v8::Module::InstantiateModule
V8_WARN_UNUSED_RESULT Maybe< bool > InstantiateModule(Local< Context > context, ResolveModuleCallback callback)
v8::Template::SetIntrinsicDataProperty
void SetIntrinsicDataProperty(Local< Name > name, Intrinsic intrinsic, PropertyAttribute attribute=None)
v8::Message::GetStartPosition
int GetStartPosition() const
v8::ValueDeserializer::ReadUint32
V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t *value)
v8::Maybe::Just
friend Maybe< U > Just(const U &u)
v8::FunctionTemplate
Definition: v8.h:6723
v8::kGCCallbackFlagCollectAllExternalMemory
@ kGCCallbackFlagCollectAllExternalMemory
Definition: v8.h:7849
v8::TypedArray::kMaxLength
static constexpr size_t kMaxLength
Definition: v8.h:5654
v8::Unwinder::TryUnwindV8Frames
static bool TryUnwindV8Frames(const JSEntryStubs &entry_stubs, size_t code_pages_length, const MemoryRange *code_pages, RegisterState *register_state, const void *stack_base)
v8::PropertyDescriptor
Definition: v8.h:4926
v8::SnapshotCreator
Definition: v8.h:10160
v8::SharedArrayBuffer::NewBackingStore
static std::unique_ptr< BackingStore > NewBackingStore(void *data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void *deleter_data)
v8::PersistentBase::Reset
V8_INLINE void Reset()
Definition: v8.h:11124
V8_INLINE
#define V8_INLINE
Definition: v8config.h:380
v8::Local::Local
V8_INLINE Local()
Definition: v8.h:201
v8::Value::IsNumberObject
bool IsNumberObject() const
v8::Value::IsSetIterator
bool IsSetIterator() const
v8::WasmStreaming::SetCompiledModuleBytes
bool SetCompiledModuleBytes(const uint8_t *bytes, size_t size)
v8::ValueSerializer::WriteValue
V8_WARN_UNUSED_RESULT Maybe< bool > WriteValue(Local< Context > context, Local< Value > value)
v8::TracedReference::TracedReference
TracedReference()
Definition: v8.h:1097
v8::Isolate::SuppressMicrotaskExecutionScope::operator=
SuppressMicrotaskExecutionScope & operator=(const SuppressMicrotaskExecutionScope &)=delete
v8::kJitCodeEventEnumExisting
@ kJitCodeEventEnumExisting
Definition: v8.h:8110
v8::ValueSerializer::Delegate
Definition: v8.h:2465
v8::NewStringType::kInternalized
@ kInternalized
v8::Isolate::SetPrepareStackTraceCallback
void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback)
v8::MemorySpan::MemorySpan
constexpr MemorySpan()=default
v8::Isolate::kInvalidatedArrayIteratorLookupChainProtector
@ kInvalidatedArrayIteratorLookupChainProtector
Definition: v8.h:8750
v8::RegExp::kNone
@ kNone
Definition: v8.h:6188
v8::ScriptCompiler::CachedData::buffer_policy
BufferPolicy buffer_policy
Definition: v8.h:1833
v8::Value::ToUint32
V8_WARN_UNUSED_RESULT MaybeLocal< Uint32 > ToUint32(Local< Context > context) const
v8::Isolate::IsHeapLimitIncreasedForDebugging
bool IsHeapLimitIncreasedForDebugging()
v8::internal::ShouldThrowOnError
V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate *isolate)
v8::ScriptCompiler::Source::~Source
V8_INLINE ~Source()
Definition: v8.h:11695
v8::EmbedderHeapTracer::NotifyEmptyEmbedderStack
void NotifyEmptyEmbedderStack()
v8::GCCallbackFlags
GCCallbackFlags
Definition: v8.h:7843
v8::Isolate::kDisplayNames
@ kDisplayNames
Definition: v8.h:8739
v8::ObjectTemplate::IsCodeLike
bool IsCodeLike()
v8::PropertyDescriptor::has_set
bool has_set() const
v8::SerializeInternalFieldsCallback::SerializeInternalFieldsCallback
SerializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition: v8.h:8355
v8::kGCTypeIncrementalMarking
@ kGCTypeIncrementalMarking
Definition: v8.h:7823
v8::IndexedPropertyHandlerConfiguration::IndexedPropertyHandlerConfiguration
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query, IndexedPropertyDeleterCallback deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallback definer, IndexedPropertyDescriptorCallback descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6941
v8::internal::kApiSystemPointerSize
const int kApiSystemPointerSize
Definition: v8-internal.h:32
v8::Value::IsNativeError
bool IsNativeError() const
v8::Local::Clear
V8_INLINE void Clear()
Definition: v8.h:221
v8::HeapSpaceStatistics::space_name
const char * space_name()
Definition: v8.h:7944
v8::StartupData::IsValid
bool IsValid() const
v8::internal::Internals::IntToSmi
static constexpr V8_INLINE internal::Address IntToSmi(int value)
Definition: v8-internal.h:271
v8::Isolate::IsolateInForegroundNotification
void IsolateInForegroundNotification()
v8::V8::Eternal
friend class Eternal
Definition: v8.h:10146
v8::Function::FunctionProtoToString
V8_WARN_UNUSED_RESULT MaybeLocal< String > FunctionProtoToString(Local< Context > context)
v8::NumberObject::ValueOf
double ValueOf() const
v8::Isolate::operator delete
void operator delete(void *, size_t)=delete
v8::HeapStatistics::total_global_handles_size
size_t total_global_handles_size()
Definition: v8.h:7904
v8::Value::IsNullOrUndefined
V8_INLINE bool IsNullOrUndefined() const
Definition: v8.h:11897
v8::PropertyCallbackInfo::This
V8_INLINE Local< Object > This() const
Definition: v8.h:12305
v8::MicrotasksPolicy::kScoped
@ kScoped
v8::ArrayBuffer::Allocator::AllocateUninitialized
virtual void * AllocateUninitialized(size_t length)=0
v8::ValueSerializer::WriteUint64
void WriteUint64(uint64_t value)
v8::Context::GetDataFromSnapshotOnce
MaybeLocal< T > GetDataFromSnapshotOnce(size_t index)
Definition: v8.h:12440
v8::PropertyDescriptor::set
Local< Value > set() const
v8::CopyablePersistentTraits
Definition: v8.h:648
v8::EmbedderHeapTracer::IterateTracedGlobalHandles
void IterateTracedGlobalHandles(TracedGlobalHandleVisitor *visitor)
v8::Object::HasPrivate
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
v8::Local::Cast
static V8_INLINE Local< T > Cast(Local< S > that)
Definition: v8.h:280
v8::Isolate::kAtomicsNotify
@ kAtomicsNotify
Definition: v8.h:8710
v8::ReturnValue::SetUndefined
V8_INLINE void SetUndefined()
Definition: v8.h:11506
v8::Value::Equals
V8_WARN_UNUSED_RESULT Maybe< bool > Equals(Local< Context > context, Local< Value > that) const
v8::PropertyHandlerFlags::kHasNoSideEffect
@ kHasNoSideEffect
v8::ValueSerializer::Delegate::FreeBufferMemory
virtual void FreeBufferMemory(void *buffer)
v8::FunctionTemplate::PrototypeTemplate
Local< ObjectTemplate > PrototypeTemplate()
v8::ModuleRequest::GetSpecifier
Local< String > GetSpecifier() const
v8::Isolate::AddMicrotasksCompletedCallback
void AddMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
v8::Isolate::kSlotsBufferOverflow
@ kSlotsBufferOverflow
Definition: v8.h:8663
v8::Isolate::kDateTimeFormatDateTimeStyle
@ kDateTimeFormatDateTimeStyle
Definition: v8.h:8745
v8::Isolate::kRegExpPrototypeUnicodeGetter
@ kRegExpPrototypeUnicodeGetter
Definition: v8.h:8671
v8::Extension::dependencies
const char ** dependencies() const
Definition: v8.h:7277
v8::WeakCallbackInfo::GetParameter
V8_INLINE T * GetParameter() const
Definition: v8.h:450
v8::SharedArrayBuffer::ByteLength
size_t ByteLength() const
v8::MemoryRange
Definition: v8.h:2416
v8::TracedReferenceBase::SetSlotThreadSafe
void SetSlotThreadSafe(void *new_val)
Definition: v8.h:875
v8::SnapshotCreator::AddContext
size_t AddContext(Local< Context > context, SerializeInternalFieldsCallback callback=SerializeInternalFieldsCallback())
v8::ResourceConstraints::set_initial_old_generation_size_in_bytes
void set_initial_old_generation_size_in_bytes(size_t initial_size)
Definition: v8.h:7394
v8::FunctionTemplate::GetFunction
V8_WARN_UNUSED_RESULT MaybeLocal< Function > GetFunction(Local< Context > context)
v8::Signature::Cast
static V8_INLINE Signature * Cast(Data *data)
Definition: v8.h:11733
v8::IntegrityLevel::kSealed
@ kSealed
v8::ReturnValue::ReturnValue
friend class ReturnValue
Definition: v8.h:4513
v8::ScriptCompiler::CachedData::length
int length
Definition: v8.h:1831
v8::SymbolObject::New
static Local< Value > New(Isolate *isolate, Local< Symbol > value)
v8::BigUint64Array
Definition: v8.h:5844
v8::Context::Cast
static V8_INLINE Context * Cast(Data *data)
Definition: v8.h:12021
v8::ValueSerializer::WriteRawBytes
void WriteRawBytes(const void *source, size_t length)
v8::Object::GetPrivate
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
v8::Object::GetRealNamedPropertyInPrototypeChain
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
v8::Value::IsProxy
bool IsProxy() const
v8::Isolate::kDateToLocaleString
@ kDateToLocaleString
Definition: v8.h:8724
v8::internal::SmiValuesAre31Bits
constexpr bool SmiValuesAre31Bits()
Definition: v8-internal.h:152
v8::String::NewFromOneByte
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromOneByte(Isolate *isolate, const uint8_t *data, NewStringType type=NewStringType::kNormal, int length=-1)
v8::Isolate::GetEmbedderHeapTracer
EmbedderHeapTracer * GetEmbedderHeapTracer()
v8::TracedReferenceBase::SetWrapperClassId
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:11396
v8::StackTrace::GetFrameCount
int GetFrameCount() const
v8::CrashKeyId::kDumpType
@ kDumpType
v8::MeasureMemoryDelegate
Definition: v8.h:8403
v8::Extension::source_length
size_t source_length() const
Definition: v8.h:7272
v8::Set::New
static Local< Set > New(Isolate *isolate)
v8::ScriptCompiler::NoCacheReason
NoCacheReason
Definition: v8.h:1985
v8::Isolate::kWebAssemblyInstantiation
@ kWebAssemblyInstantiation
Definition: v8.h:8704
v8::Value::BooleanValue
bool BooleanValue(Isolate *isolate) const
v8::WasmModuleObject::Cast
static V8_INLINE WasmModuleObject * Cast(Value *obj)
Definition: v8.h:12136
v8::Function::NewInstance
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance(Local< Context > context) const
Definition: v8.h:4719
v8::Isolate::kStringToLocaleLowerCase
@ kStringToLocaleLowerCase
Definition: v8.h:8722
v8::Extension::set_auto_enable
void set_auto_enable(bool value)
Definition: v8.h:7278
v8::String::WriteUtf8
int WriteUtf8(Isolate *isolate, char *buffer, int length=-1, int *nchars_ref=nullptr, int options=NO_OPTIONS) const
v8::Set::Clear
void Clear()
v8::JSEntryStubs::js_entry_stub
JSEntryStub js_entry_stub
Definition: v8.h:2426
v8::SnapshotCreator::~SnapshotCreator
~SnapshotCreator()
v8::RegExp::kGlobal
@ kGlobal
Definition: v8.h:6189
v8::FunctionTemplate::SetAcceptAnyReceiver
void SetAcceptAnyReceiver(bool value)
v8::Data::IsContext
bool IsContext() const
v8::ValueSerializer::Delegate::~Delegate
virtual ~Delegate()=default
v8::MaybeLocal::ToLocalChecked
V8_INLINE Local< T > ToLocalChecked()
Definition: v8.h:11076
v8::PersistentBase::ClearWeak
V8_INLINE void ClearWeak()
Definition: v8.h:575
v8::PropertyCallbackInfo::PropertyCallbackInfo
V8_INLINE PropertyCallbackInfo(internal::Address *args)
Definition: v8.h:4693
v8::ValueDeserializer::Delegate::GetWasmModuleFromId
virtual MaybeLocal< WasmModuleObject > GetWasmModuleFromId(Isolate *isolate, uint32_t transfer_id)
v8::Isolate::SetIdle
void SetIdle(bool is_idle)
v8::RegisterState::fp
void * fp
Definition: v8.h:2401
v8::Array::Length
uint32_t Length() const
v8::Function::SetName
void SetName(Local< String > name)
v8::Isolate::kArrayInstanceConstructorModified
@ kArrayInstanceConstructorModified
Definition: v8.h:8686
v8::FunctionCallbackInfo::kReturnValueDefaultValueIndex
static const int kReturnValueDefaultValueIndex
Definition: v8.h:4573
v8::Function::NewInstance
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance(Local< Context > context, int argc, Local< Value > argv[]) const
v8::SnapshotCreator::FunctionCodeHandling::kKeep
@ kKeep
v8::Context::Enter
void Enter()
v8::Proxy::GetTarget
Local< Value > GetTarget()
v8::ResourceConstraints::stack_limit
uint32_t * stack_limit() const
Definition: v8.h:7355
v8::Object
Definition: v8.h:3914
v8::Isolate::SetCaptureStackTraceForUncaughtExceptions
void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
v8::Template::SetPrivate
void SetPrivate(Local< Private > name, Local< Data > value, PropertyAttribute attributes=None)
v8::PropertyHandlerFlags::kNone
@ kNone
v8::Module::export_value
Local< Value > export_value
Definition: v8.h:1761
v8::ResourceConstraints::set_initial_young_generation_size_in_bytes
void set_initial_young_generation_size_in_bytes(size_t initial_size)
Definition: v8.h:7401
v8::Exception::SyntaxError
static Local< Value > SyntaxError(Local< String > message)
v8::ObjectTemplate::SetImmutableProto
void SetImmutableProto()
v8::Value::Uint32Value
V8_WARN_UNUSED_RESULT Maybe< uint32_t > Uint32Value(Local< Context > context) const
v8::Value::Int32Value
V8_WARN_UNUSED_RESULT Maybe< int32_t > Int32Value(Local< Context > context) const
v8::Isolate::kInvalidatedIsConcatSpreadableLookupChainProtector
@ kInvalidatedIsConcatSpreadableLookupChainProtector
Definition: v8.h:8752
v8::TryCatch::TryCatch
TryCatch(Isolate *isolate)
v8::ArrayBuffer::kEmbedderFieldCount
static const int kEmbedderFieldCount
Definition: v8.h:5581
v8::Int8Array::New
static Local< Int8Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::StackTrace
Definition: v8.h:2256
v8::Value::ToNumber
V8_WARN_UNUSED_RESULT MaybeLocal< Number > ToNumber(Local< Context > context) const
v8::internal::Internals::kNodeClassIdOffset
static const int kNodeClassIdOffset
Definition: v8-internal.h:230
v8::ArrayBufferView::kInternalFieldCount
static const int kInternalFieldCount
Definition: v8.h:5634
v8::kNoGCCallbackFlags
@ kNoGCCallbackFlags
Definition: v8.h:7844
v8::Value::IsArrayBufferView
bool IsArrayBufferView() const
v8::Context::GetIsolate
Isolate * GetIsolate()
v8::Value::IsBigInt
bool IsBigInt() const
v8::Float64Array::New
static Local< Float64Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::Isolate::CreateParams::constraints
ResourceConstraints constraints
Definition: v8.h:8468
v8::Isolate::SetData
V8_INLINE void SetData(uint32_t slot, void *data)
Definition: v8.h:12368
v8::PERFORMANCE_IDLE
@ PERFORMANCE_IDLE
Definition: v8.h:8098
v8::V8::PersistentValueMapBase
friend class PersistentValueMapBase
Definition: v8.h:10125
v8::Function::GetName
Local< Value > GetName() const
v8::Isolate::kAtomicsWake
@ kAtomicsWake
Definition: v8.h:8711
v8::Isolate::PerformMicrotaskCheckpoint
void PerformMicrotaskCheckpoint()
v8::Context::SetEmbedderData
void SetEmbedderData(int index, Local< Value > value)
v8::JitCodeEvent::line_info_t
Definition: v8.h:8045
v8::HandleScope::NumberOfHandles
static int NumberOfHandles(Isolate *isolate)
v8::String::Utf8Value::~Utf8Value
~Utf8Value()
v8::ValueDeserializer::ValueDeserializer
ValueDeserializer(Isolate *isolate, const uint8_t *data, size_t size)
v8::String::NewExternalOneByte
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewExternalOneByte(Isolate *isolate, ExternalOneByteStringResource *resource)
v8::Uint16Array::New
static Local< Uint16Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::Int32Array::New
static Local< Int32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::SKIP_SYMBOLS
@ SKIP_SYMBOLS
Definition: v8.h:3866
v8::Symbol::ForApi
static Local< Symbol > ForApi(Isolate *isolate, Local< String > description)
v8::MicrotaskQueue::IsRunningMicrotasks
virtual bool IsRunningMicrotasks() const =0
v8::BigInt::ToWordsArray
void ToWordsArray(int *sign_bit, int *word_count, uint64_t *words) const
v8::NumberObject::Cast
static V8_INLINE NumberObject * Cast(Value *obj)
Definition: v8.h:12052
v8::Local::operator->
V8_INLINE T * operator->() const
Definition: v8.h:223
v8::String::Utf8Value::operator=
void operator=(const Utf8Value &)=delete
v8::Isolate::AddCallCompletedCallback
void AddCallCompletedCallback(CallCompletedCallback callback)
v8::FunctionTemplate::HasInstance
bool HasInstance(Local< Value > object)
v8::Isolate::kIntlPattern
@ kIntlPattern
Definition: v8.h:8673
v8::Data::IsObjectTemplate
bool IsObjectTemplate() const
v8::Exception::WasmCompileError
static Local< Value > WasmCompileError(Local< String > message)
v8::Isolate::kAssigmentExpressionLHSIsCallInStrict
@ kAssigmentExpressionLHSIsCallInStrict
Definition: v8.h:8695
v8::MicrotaskQueue::GetMicrotasksScopeDepth
virtual int GetMicrotasksScopeDepth() const =0
v8::HandleScope::operator=
void operator=(const HandleScope &)=delete
v8::Context::NewRemoteContext
static MaybeLocal< Object > NewRemoteContext(Isolate *isolate, Local< ObjectTemplate > global_template, MaybeLocal< Value > global_object=MaybeLocal< Value >())
v8::DeserializeInternalFieldsCallback
Definition: v8.h:8369
v8::ScriptCompiler::ExternalSourceStream::~ExternalSourceStream
virtual ~ExternalSourceStream()=default
v8::ScriptCompiler::CachedData::operator=
CachedData & operator=(const CachedData &)=delete
v8::FixedArray::Length
int Length() const
v8::FunctionTemplate::Cast
static V8_INLINE FunctionTemplate * Cast(Data *data)
Definition: v8.h:11719
v8::Object::DeletePrivate
Maybe< bool > DeletePrivate(Local< Context > context, Local< Private > key)
v8::Isolate::DumpAndResetStats
void DumpAndResetStats()
v8::Maybe::IsJust
V8_INLINE bool IsJust() const
Definition: v8.h:10274
v8::Isolate::kIntlV8Parse
@ kIntlV8Parse
Definition: v8.h:8672
v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING
@ CODE_END_LINE_INFO_RECORDING
Definition: v8.h:8005
v8::ModifyCodeGenerationFromStringsResult::codegen_allowed
bool codegen_allowed
Definition: v8.h:7769
v8::StackTrace::StackTraceOptions
StackTraceOptions
Definition: v8.h:2264
v8::SampleInfo::frames_count
size_t frames_count
Definition: v8.h:2409
v8::KeyCollectionMode::kOwnOnly
@ kOwnOnly
v8::SharedArrayBuffer::Contents
Definition: v8.h:5888
v8::String::ExternalOneByteStringResource::ExternalOneByteStringResource
ExternalOneByteStringResource()=default
v8::CompiledWasmModule::GetWireBytesRef
MemorySpan< const uint8_t > GetWireBytesRef()
v8::Proxy::New
static MaybeLocal< Proxy > New(Local< Context > context, Local< Object > local_target, Local< Object > local_handler)
v8::ScriptOrigin::ScriptID
V8_INLINE Local< Integer > ScriptID() const
Definition: v8.h:11667
v8::SnapshotCreator::AddData
size_t AddData(Local< Context > context, Local< T > object)
Definition: v8.h:12447
v8::Isolate::AdjustAmountOfExternalAllocatedMemory
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
v8::PromiseRejectMessage::GetEvent
V8_INLINE PromiseRejectEvent GetEvent() const
Definition: v8.h:7604
v8::Private::Name
Local< Value > Name() const
v8::ScriptCompiler::ScriptStreamingTask::Run
void Run()
v8::DeserializeInternalFieldsCallback::DeserializeInternalFieldsCallback
DeserializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition: v8.h:8372
v8::Global::Global
Global(const Global &)=delete
v8::Isolate::CreateParams::array_buffer_allocator
ArrayBuffer::Allocator * array_buffer_allocator
Definition: v8.h:8499
v8::JitCodeEvent::script
Local< UnboundScript > script
Definition: v8.h:8030
v8::String::NO_NULL_TERMINATION
@ NO_NULL_TERMINATION
Definition: v8.h:3227
v8::ResourceConstraints::ConfigureDefaults
void ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit)
v8::Isolate::VisitExternalResources
void VisitExternalResources(ExternalResourceVisitor *visitor)
v8::Persistent::Persistent
V8_INLINE Persistent(const Persistent< S, M2 > &that)
Definition: v8.h:703
v8::Isolate::AddGCEpilogueCallback
void AddGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
v8::ValueSerializer::~ValueSerializer
~ValueSerializer()
v8::FunctionCallbackInfo::length_
int length_
Definition: v8.h:4582
v8::FunctionCallbackInfo::kArgsLength
static const int kArgsLength
Definition: v8.h:4565
v8::Proxy::GetHandler
Local< Value > GetHandler()
v8::SharedArrayBuffer::Contents::ByteLength
size_t ByteLength() const
Definition: v8.h:5909
v8::JSON
Definition: v8.h:2434
v8::Isolate::kRelativeTimeFormat
@ kRelativeTimeFormat
Definition: v8.h:8716
v8::EmbedderHeapTracer::kNoFlags
@ kNoFlags
Definition: v8.h:8171
v8::TracedReference::As
V8_INLINE TracedReference< S > & As() const
Definition: v8.h:1180
v8::HeapObjectStatistics::object_sub_type
const char * object_sub_type()
Definition: v8.h:7965
v8::ReturnValue::Set
V8_INLINE void Set(uint32_t i)
Definition: v8.h:11474
v8::Persistent::~Persistent
V8_INLINE ~Persistent()
Definition: v8.h:720
v8::ArrayBuffer
Definition: v8.h:5325
v8::internal::kEmbedderDataSlotPayloadTag
@ kEmbedderDataSlotPayloadTag
Definition: v8-internal.h:137
v8::ArrayBuffer::NewBackingStore
static std::unique_ptr< BackingStore > NewBackingStore(void *data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void *deleter_data)
v8::Isolate::SetAllowWasmCodeGenerationCallback
void SetAllowWasmCodeGenerationCallback(AllowWasmCodeGenerationCallback callback)
v8::Data::IsModule
bool IsModule() const
v8::Object::ObjectProtoToString
V8_WARN_UNUSED_RESULT MaybeLocal< String > ObjectProtoToString(Local< Context > context)
v8::ScriptOriginOptions::Flags
int Flags() const
Definition: v8.h:1413
v8::ScriptOrigin::ScriptOrigin
V8_INLINE ScriptOrigin(Local< Value > resource_name, Local< Integer > resource_line_offset, Local< Integer > resource_column_offset, Local< Boolean > resource_is_shared_cross_origin=Local< Boolean >(), Local< Integer > script_id=Local< Integer >(), Local< Value > source_map_url=Local< Value >(), Local< Boolean > resource_is_opaque=Local< Boolean >(), Local< Boolean > is_wasm=Local< Boolean >(), Local< Boolean > is_module=Local< Boolean >(), Local< PrimitiveArray > host_defined_options=Local< PrimitiveArray >())
Definition: v8.h:11607
v8::Isolate::kDeoptimizerDisableSpeculation
@ kDeoptimizerDisableSpeculation
Definition: v8.h:8705
v8::IndexedPropertyHandlerConfiguration::getter
IndexedPropertyGetterCallback getter
Definition: v8.h:6998
v8::IndexFilter
IndexFilter
Definition: v8.h:3898
v8::ScriptOrigin::SourceMapUrl
V8_INLINE Local< Value > SourceMapUrl() const
Definition: v8.h:11677
v8::JitCodeEvent::wasm_source_info_t::filename
const char * filename
Definition: v8.h:8056
v8::TryCatch::IsVerbose
bool IsVerbose() const
v8::Isolate::kRegExpMatchIsFalseishOnJSRegExp
@ kRegExpMatchIsFalseishOnJSRegExp
Definition: v8.h:8731
v8::PromiseHookType::kResolve
@ kResolve
v8::TracedReferenceBase::Reset
V8_INLINE void Reset()
Definition: v8.h:11243
v8::Value::IsUint32
bool IsUint32() const
v8::kGCTypeProcessWeakCallbacks
@ kGCTypeProcessWeakCallbacks
Definition: v8.h:7824
v8::ArrayBuffer::mode
void size_t ArrayBufferCreationMode mode
Definition: v8.h:5472
v8::EmbedderHeapTracer::DecreaseAllocatedSize
void DecreaseAllocatedSize(size_t bytes)
v8::Isolate::kMessageDebug
@ kMessageDebug
Definition: v8.h:8779
v8::Context::AllowCodeGenerationFromStrings
void AllowCodeGenerationFromStrings(bool allow)
v8::EscapableHandleScope::EscapableHandleScope
EscapableHandleScope(Isolate *isolate)
v8::Local::Traced
friend class Traced
Definition: v8.h:339
v8::Isolate::AtomicsWaitEvent::kAPIStopped
@ kAPIStopped
v8::ACCESS_KEYS
@ ACCESS_KEYS
Definition: v8.h:6604
v8::JSEntryStubs::js_run_microtasks_entry_stub
JSEntryStub js_run_microtasks_entry_stub
Definition: v8.h:2428
v8::Object::IsCallable
bool IsCallable()
v8::Isolate::SafeForTerminationScope::~SafeForTerminationScope
~SafeForTerminationScope()
v8::ScriptOriginOptions::ScriptOriginOptions
V8_INLINE ScriptOriginOptions(int flags)
Definition: v8.h:1402
v8::ValueSerializer::operator=
void operator=(const ValueSerializer &)=delete
v8::Value::IsArrayBuffer
bool IsArrayBuffer() const
v8::internal::Internals::kJSSpecialApiObjectType
static const int kJSSpecialApiObjectType
Definition: v8-internal.h:239
v8::Persistent::operator=
V8_INLINE Persistent & operator=(const Persistent &that)
Definition: v8.h:706
v8::JitCodeEvent::name_t
Definition: v8.h:8037
v8::WasmMemoryObject::WasmMemoryObject
WasmMemoryObject()=delete
v8::Float64Array::New
static Local< Float64Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::Number::Value
double Value() const
v8::Uint32Array::Cast
static V8_INLINE Uint32Array * Cast(Value *obj)
Definition: v8.h:12207
v8::Context::SetSecurityToken
void SetSecurityToken(Local< Value > token)
v8::Object::GetPrototype
Local< Value > GetPrototype()
v8::RegExp::GetSource
Local< String > GetSource() const
v8::SKIP_STRINGS
@ SKIP_STRINGS
Definition: v8.h:3865
v8::Symbol::Description
Local< Value > Description() const
v8::EscapableHandleScope
Definition: v8.h:1251
v8::V8::SetEntropySource
static void SetEntropySource(EntropySource source)
v8::StartupData::CanBeRehashed
bool CanBeRehashed() const
v8::Isolate::Isolate
Isolate(const Isolate &)=delete
v8::JitCodeEvent::JIT_CODE
@ JIT_CODE
Definition: v8.h:8020
v8::ScriptCompiler::CachedDataVersionTag
static uint32_t CachedDataVersionTag()
v8::MicrotasksScope::kRunMicrotasks
@ kRunMicrotasks
Definition: v8.h:7723
v8::PropertyDescriptor::enumerable
bool enumerable() const
v8::Isolate::AllowJavascriptExecutionScope::AllowJavascriptExecutionScope
AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope &)=delete
v8::NamedPropertyHandlerConfiguration::setter
GenericNamedPropertySetterCallback setter
Definition: v8.h:6929
v8::FunctionCallbackInfo::kHolderIndex
static const int kHolderIndex
Definition: v8.h:4571
v8::MaybeLocal::MaybeLocal
V8_INLINE MaybeLocal()
Definition: v8.h:373
v8::Object::InternalFieldCount
int InternalFieldCount()
v8::Isolate::kBreakIterator
@ kBreakIterator
Definition: v8.h:8659
v8::ValueDeserializer::GetWireFormatVersion
uint32_t GetWireFormatVersion() const
v8::StackFrame::IsEval
bool IsEval() const
v8::WasmModuleObjectBuilderStreaming::Abort
void Abort(MaybeLocal< Value > exception)
v8::TracedReferenceBase::Get
V8_INLINE v8::Local< v8::Value > Get(v8::Isolate *isolate) const
Definition: v8.h:11249
v8::Symbol::GetHasInstance
static Local< Symbol > GetHasInstance(Isolate *isolate)
v8::Module::kErrored
@ kErrored
Definition: v8.h:1600
v8::ArrayBuffer::Allocator::~Allocator
virtual ~Allocator()=default
v8::Int8Array
Definition: v8.h:5710
v8::MicrotasksScope::MicrotasksScope
MicrotasksScope(const MicrotasksScope &)=delete
v8::BackingStore::EmptyDeleter
static void EmptyDeleter(void *data, size_t length, void *deleter_data)
v8::EmbedderHeapTracer::IsRootForNonTracingGC
virtual bool IsRootForNonTracingGC(const v8::TracedGlobal< v8::Value > &handle)
v8::Isolate::GetCurrent
static Isolate * GetCurrent()
v8::Value::IsInt16Array
bool IsInt16Array() const
v8::BackingStore::Data
void * Data() const
v8::internal::Internals::kJSApiObjectType
static const int kJSApiObjectType
Definition: v8-internal.h:240
v8::String::ExternalOneByteStringResource::cached_data
const char * cached_data() const
Definition: v8.h:3394
v8::EmbedderHeapTracer::TracedGlobalHandleVisitor::VisitTracedReference
virtual void VisitTracedReference(const TracedReference< Value > &handle)
Definition: v8.h:8183
v8::EmbedderHeapTracer::TraceSummary
Definition: v8.h:8190
v8::ScriptCompiler::CreateCodeCache
static CachedData * CreateCodeCache(Local< UnboundScript > unbound_script)
v8::ATOMICS_WAIT
@ ATOMICS_WAIT
Definition: v8.h:2382
v8::MicrotasksScope::~MicrotasksScope
~MicrotasksScope()
v8::internal::Internals::kExternalOneByteRepresentationTag
static const int kExternalOneByteRepresentationTag
Definition: v8-internal.h:200
v8::Data::IsFunctionTemplate
bool IsFunctionTemplate() const
v8::String::NewFromUtf8
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=NewStringType::kNormal, int length=-1)
v8::ArrayBuffer::Contents::ByteLength
size_t ByteLength() const
Definition: v8.h:5423
v8::Isolate::CreateParams::counter_lookup_callback
CounterLookupCallback counter_lookup_callback
Definition: v8.h:8479
v8::IntegrityLevel
IntegrityLevel
Definition: v8.h:3909
v8::ScriptCompiler
Definition: v8.h:1800
v8::Maybe::operator==
V8_INLINE bool operator==(const Maybe &other) const
Definition: v8.h:10315
v8::HeapStatistics::total_available_size
size_t total_available_size()
Definition: v8.h:7903
v8::Message::ErrorLevel
int ErrorLevel() const
v8::Message::GetScriptOrigin
ScriptOrigin GetScriptOrigin() const
v8::SharedArrayBuffer::GetBackingStore
std::shared_ptr< BackingStore > GetBackingStore()
v8::Isolate::IsExecutionTerminating
bool IsExecutionTerminating()
v8::PersistentBase::operator!=
V8_INLINE bool operator!=(const PersistentBase< S > &that) const
Definition: v8.h:536
v8::UnboundScript::GetScriptName
Local< Value > GetScriptName()
v8::BigInt::WordCount
int WordCount() const
v8::EscapableHandleScope::EscapeMaybe
V8_INLINE MaybeLocal< T > EscapeMaybe(MaybeLocal< T > value)
Definition: v8.h:1268
v8::Module::IsSyntheticModule
bool IsSyntheticModule() const
v8::JitCodeEvent::wasm_source_info_t::line_number_table
const line_info_t * line_number_table
Definition: v8.h:8061
v8::Isolate::CancelTerminateExecution
void CancelTerminateExecution()
v8::KeyConversionMode::kNoNumbers
@ kNoNumbers
v8::TryCatch::HasTerminated
bool HasTerminated() const
v8::Maybe::operator!=
V8_INLINE bool operator!=(const Maybe &other) const
Definition: v8.h:10320
v8::JitCodeEvent::code_type
CodeType code_type
Definition: v8.h:8024
v8::Module::GetModuleRequests
Local< FixedArray > GetModuleRequests() const
v8::internal::Internals::GetRoot
static V8_INLINE internal::Address * GetRoot(v8::Isolate *isolate, int index)
Definition: v8-internal.h:332
v8::JitCodeEvent::STATEMENT_POSITION
@ STATEMENT_POSITION
Definition: v8.h:8012
v8::Value::IsTrue
bool IsTrue() const
v8::internal::Internals
Definition: v8-internal.h:179
v8::Isolate::EnqueueMicrotask
void EnqueueMicrotask(Local< Function > microtask)
v8::ReturnValue::Set
V8_INLINE void Set(int32_t i)
Definition: v8.h:11463
v8::Locker::IsActive
static bool IsActive()
v8::internal::Internals::kJSObjectType
static const int kJSObjectType
Definition: v8-internal.h:241
v8::Int16Array::Cast
static V8_INLINE Int16Array * Cast(Value *obj)
Definition: v8.h:12199
v8::EmbedderHeapTracer::TraceFlags
TraceFlags
Definition: v8.h:8170
v8::Isolate::kLocale
@ kLocale
Definition: v8.h:8717
v8::PersistentBase::Reset
void Reset(Isolate *isolate, const Local< S > &other)
Definition: v8.h:11133
v8::ResourceConstraints::set_max_old_generation_size_in_bytes
void set_max_old_generation_size_in_bytes(size_t limit)
Definition: v8.h:7375
v8::ScriptCompiler::CachedData
Definition: v8.h:1809
v8::Context::GetEmbedderData
V8_INLINE Local< Value > GetEmbedderData(int index)
Definition: v8.h:12392
v8::IndexedPropertyHandlerConfiguration::definer
IndexedPropertyDefinerCallback definer
Definition: v8.h:7003
v8::Function::ScriptId
int ScriptId() const
v8::Context::DetachGlobal
void DetachGlobal()
v8::String::MakeExternal
bool MakeExternal(ExternalOneByteStringResource *resource)
v8::String::Value::Value
Value(Isolate *isolate, Local< v8::Value > obj)
v8::String::ExternalStringResourceBase::operator=
void operator=(const ExternalStringResourceBase &)=delete
v8::ScriptCompiler::Source::operator=
Source & operator=(const Source &)=delete
v8::ArrayBuffer::Contents::DeleterData
void * DeleterData() const
Definition: v8.h:5425
v8::PropertyDescriptor::PropertyDescriptor
PropertyDescriptor()
v8::ScriptCompiler::StartStreaming
static ScriptStreamingTask * StartStreaming(Isolate *isolate, StreamedSource *source, ScriptType type=ScriptType::kClassic)
v8::Symbol::GetReplace
static Local< Symbol > GetReplace(Isolate *isolate)
v8::Uint32Array
Definition: v8.h:5761
v8::MicrotaskQueue::EnqueueMicrotask
virtual void EnqueueMicrotask(v8::Isolate *isolate, MicrotaskCallback callback, void *data=nullptr)=0
v8::Isolate::kLegacyDateParser
@ kLegacyDateParser
Definition: v8.h:8691
v8::Isolate::CreateParams::code_event_handler
JitCodeEventHandler code_event_handler
Definition: v8.h:8463
v8::ScriptCompiler::CachedData::data
const uint8_t * data
Definition: v8.h:1830
v8::SharedArrayBuffer::New
static Local< SharedArrayBuffer > New(Isolate *isolate, size_t byte_length)
v8::Message::GetStartColumn
V8_WARN_UNUSED_RESULT Maybe< int > GetStartColumn(Local< Context > context) const
v8::MemorySpan::MemorySpan
constexpr MemorySpan(T *data, size_t size)
Definition: v8.h:5012
v8::Exception::Error
static Local< Value > Error(Local< String > message)
v8::MicrotaskQueue::AddMicrotasksCompletedCallback
virtual void AddMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)=0
v8::Value::IsWasmMemoryObject
bool IsWasmMemoryObject() const
v8::Value::IsGeneratorFunction
bool IsGeneratorFunction() const
v8::StackTrace::kLineNumber
@ kLineNumber
Definition: v8.h:2265
v8::Boolean::Cast
static V8_INLINE Boolean * Cast(v8::Data *data)
Definition: v8.h:11944
v8::Value::Cast
Value * Cast(T *value)
Definition: v8.h:11932
v8::Symbol::GetToPrimitive
static Local< Symbol > GetToPrimitive(Isolate *isolate)
v8::BasicTracedReference::Get
Local< T > Get(Isolate *isolate) const
Definition: v8.h:921
v8::Isolate::DateTimeConfigurationChangeNotification
void DateTimeConfigurationChangeNotification(TimeZoneDetection time_zone_detection=TimeZoneDetection::kSkip)
v8::Value::IsBigUint64Array
bool IsBigUint64Array() const
v8::SerializeInternalFieldsCallback::data
void * data
Definition: v8.h:8359
v8::Isolate::SetHostImportModuleDynamicallyCallback
void SetHostImportModuleDynamicallyCallback(HostImportModuleDynamicallyWithImportAssertionsCallback callback)
v8::ScriptOrigin::Options
V8_INLINE ScriptOriginOptions Options() const
Definition: v8.h:1471
v8::Isolate::DisallowJavascriptExecutionScope::OnFailure
OnFailure
Definition: v8.h:8560
v8::Template::Set
void Set(Local< Name > name, Local< Data > value, PropertyAttribute attributes=None)
v8::V8::InitializePlatform
static void InitializePlatform(Platform *platform)
v8::ScriptCompiler::StreamedSource::StreamedSource
StreamedSource(std::unique_ptr< ExternalSourceStream > source_stream, Encoding encoding)
v8::Symbol::GetSearch
static Local< Symbol > GetSearch(Isolate *isolate)
v8::Set::Add
V8_WARN_UNUSED_RESULT MaybeLocal< Set > Add(Local< Context > context, Local< Value > key)
v8::Isolate::kPromiseAccept
@ kPromiseAccept
Definition: v8.h:8676
v8::Exception
Definition: v8.h:7435
v8::Object::HasOwnProperty
V8_WARN_UNUSED_RESULT Maybe< bool > HasOwnProperty(Local< Context > context, Local< Name > key)
v8::ResourceConstraints::initial_old_generation_size_in_bytes
size_t initial_old_generation_size_in_bytes() const
Definition: v8.h:7391
v8::Int32::Cast
static V8_INLINE Int32 * Cast(v8::Data *data)
Definition: v8.h:12000
v8::PropertyHandlerFlags::kNonMasking
@ kNonMasking
v8::SharedArrayBuffer::Contents::Contents
Contents()
Definition: v8.h:5893
v8::WeakCallbackInfo::GetIsolate
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:449
v8::TracedGlobal::Reset
void Reset(Isolate *isolate, const Local< S > &other)
Definition: v8.h:11298
v8::HeapSpaceStatistics::space_used_size
size_t space_used_size()
Definition: v8.h:7946
v8::Context::GetContinuationPreservedEmbedderData
Local< Value > GetContinuationPreservedEmbedderData() const
v8::Uint32::Cast
static V8_INLINE Uint32 * Cast(v8::Data *data)
Definition: v8.h:12007
v8::Isolate::IdleNotificationDeadline
bool IdleNotificationDeadline(double deadline_in_seconds)
v8::Isolate::EnqueueMicrotask
void EnqueueMicrotask(MicrotaskCallback callback, void *data=nullptr)
v8::StringObject::Cast
static V8_INLINE StringObject * Cast(Value *obj)
Definition: v8.h:12036
v8::internal::Internals::kStringEncodingMask
static const int kStringEncodingMask
Definition: v8-internal.h:198
v8::Object::GetCreationContext
MaybeLocal< Context > GetCreationContext()
v8::Isolate::RemoveGCPrologueCallback
void RemoveGCPrologueCallback(GCCallbackWithData, void *data=nullptr)
v8::String::REPLACE_INVALID_UTF8
@ REPLACE_INVALID_UTF8
Definition: v8.h:3232
v8::ValueSerializer
Definition: v8.h:2463
v8::Isolate::SuppressMicrotaskExecutionScope::SuppressMicrotaskExecutionScope
SuppressMicrotaskExecutionScope(Isolate *isolate, MicrotaskQueue *microtask_queue=nullptr)
v8::Locker
Definition: v8.h:10944
v8::StackTrace::GetFrame
Local< StackFrame > GetFrame(Isolate *isolate, uint32_t index) const
v8::EmbedderHeapTracer::TracedGlobalHandleVisitor::~TracedGlobalHandleVisitor
virtual ~TracedGlobalHandleVisitor()=default
v8::OwnedBuffer::size
size_t size
Definition: v8.h:5029
v8::Uint8Array
Definition: v8.h:5676
v8::internal::Internals::kNullOddballKind
static const int kNullOddballKind
Definition: v8-internal.h:244
v8::ScriptOriginOptions::IsModule
bool IsModule() const
Definition: v8.h:1411
v8::String::NewFromTwoByte
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewFromTwoByte(Isolate *isolate, const uint16_t *data, NewStringType type=NewStringType::kNormal, int length=-1)
v8::SharedArrayBuffer::Contents::AllocationLength
size_t AllocationLength() const
Definition: v8.h:5903
v8::FunctionCallbackInfo::kIsolateIndex
static const int kIsolateIndex
Definition: v8.h:4572
v8::Module::kEvaluated
@ kEvaluated
Definition: v8.h:1599
cppgc
Definition: allocation.h:17
v8::ScriptOrigin::ScriptOrigin
V8_INLINE ScriptOrigin(Local< Value > resource_name, int resource_line_offset=0, int resource_column_offset=0, bool resource_is_shared_cross_origin=false, int script_id=-1, Local< Value > source_map_url=Local< Value >(), bool resource_is_opaque=false, bool is_wasm=false, bool is_module=false, Local< PrimitiveArray > host_defined_options=Local< PrimitiveArray >())
Definition: v8.h:11624
v8::Isolate::kRegExpPrototypeStickyGetter
@ kRegExpPrototypeStickyGetter
Definition: v8.h:8669
v8::Isolate::RemoveGCPrologueCallback
void RemoveGCPrologueCallback(GCCallback callback)
v8::Maybe< void >::operator==
V8_INLINE bool operator==(const Maybe &other) const
Definition: v8.h:10354
v8::Uint32
Definition: v8.h:3745
v8::V8::MaybeLocal
friend class MaybeLocal
Definition: v8.h:10136
v8::Isolate::kForcedGC
@ kForcedGC
Definition: v8.h:8665
v8::Int32Array::New
static Local< Int32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::JitCodeEvent::CODE_ADDED
@ CODE_ADDED
Definition: v8.h:8000
v8::ModuleRequest::GetImportAssertions
Local< FixedArray > GetImportAssertions() const
v8::Object::CallAsConstructor
V8_WARN_UNUSED_RESULT MaybeLocal< Value > CallAsConstructor(Local< Context > context, int argc, Local< Value > argv[])
v8::Message::GetEndColumn
V8_WARN_UNUSED_RESULT Maybe< int > GetEndColumn(Local< Context > context) const
v8::CrashKeyId::kReadonlySpaceFirstPageAddress
@ kReadonlySpaceFirstPageAddress
v8::SharedArrayBuffer::kInternalFieldCount
static const int kInternalFieldCount
Definition: v8.h:6066
v8::ArrayBufferView::CopyContents
size_t CopyContents(void *dest, size_t byte_length)
v8::MicrotasksPolicy::kExplicit
@ kExplicit
v8::Object::SetAlignedPointerInInternalField
void SetAlignedPointerInInternalField(int index, void *value)
v8::ACCESS_SET
@ ACCESS_SET
Definition: v8.h:6601
v8::MeasureMemoryDelegate::MeasurementComplete
virtual void MeasurementComplete(const std::vector< std::pair< Local< Context >, size_t >> &context_sizes_in_bytes, size_t unattributed_size_in_bytes)=0
v8::ExtensionConfiguration
Definition: v8.h:10543
v8::Value::IsWeakSet
bool IsWeakSet() const
v8::RegExp::New
static V8_WARN_UNUSED_RESULT MaybeLocal< RegExp > New(Local< Context > context, Local< String > pattern, Flags flags)
v8::ValueSerializer::Delegate::ThrowDataCloneError
virtual void ThrowDataCloneError(Local< String > message)=0
v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING
@ CODE_START_LINE_INFO_RECORDING
Definition: v8.h:8004
v8::ValueSerializer::Delegate::GetWasmModuleTransferId
virtual Maybe< uint32_t > GetWasmModuleTransferId(Isolate *isolate, Local< WasmModuleObject > module)
v8::Isolate::kStrongMode
@ kStrongMode
Definition: v8.h:8668
v8::Value::ToInt32
V8_WARN_UNUSED_RESULT MaybeLocal< Int32 > ToInt32(Local< Context > context) const
v8::TryCatch::~TryCatch
~TryCatch()
v8::Symbol::GetIsConcatSpreadable
static Local< Symbol > GetIsConcatSpreadable(Isolate *isolate)
v8::ScriptCompiler::kNoCacheBecauseInlineScript
@ kNoCacheBecauseInlineScript
Definition: v8.h:1989
v8::Isolate::kObjectPrototypeHasElements
@ kObjectPrototypeHasElements
Definition: v8.h:8742
v8::String::IsExternalOneByte
bool IsExternalOneByte() const
v8::Isolate::SafeForTerminationScope
Definition: v8.h:8629
v8::JitCodeEvent::code_len
size_t code_len
Definition: v8.h:8028
v8::FunctionTemplate::RemovePrototype
void RemovePrototype()
v8::TracedGlobal::TracedGlobal
V8_INLINE TracedGlobal(TracedGlobal< S > &&other)
Definition: v8.h:1001
v8::ScriptCompiler::kNoCacheBecauseCacheTooCold
@ kNoCacheBecauseCacheTooCold
Definition: v8.h:1994
v8::SharedArrayBuffer::NewBackingStore
static std::unique_ptr< BackingStore > NewBackingStore(Isolate *isolate, size_t byte_length)
v8::IndexedPropertyHandlerConfiguration::deleter
IndexedPropertyDeleterCallback deleter
Definition: v8.h:7001
v8::String::ExternalStringResourceBase::Dispose
virtual void Dispose()
Definition: v8.h:3284
v8::Isolate::GetHeapObjectStatisticsAtLastGC
bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics *object_statistics, size_t type_index)
v8::Message::kNoLineNumberInfo
static const int kNoLineNumberInfo
Definition: v8.h:2244
v8::Value::IsSharedArrayBuffer
bool IsSharedArrayBuffer() const
v8::JSEntryStub::code
MemoryRange code
Definition: v8.h:2422
v8::EmbedderHeapTracer::isolate_
v8::Isolate * isolate_
Definition: v8.h:8339
v8::Isolate::~Isolate
~Isolate()=delete
v8::Function
Definition: v8.h:4704
v8::StackTrace::kScriptName
@ kScriptName
Definition: v8.h:2267
v8::Symbol::GetMatch
static Local< Symbol > GetMatch(Isolate *isolate)
v8::HeapStatistics::total_heap_size_executable
size_t total_heap_size_executable()
Definition: v8.h:7901
v8::ArrayBuffer::GetContents
Contents GetContents()
v8::NamedPropertyHandlerConfiguration::flags
PropertyHandlerFlags flags
Definition: v8.h:6936
v8::ValueSerializer::WriteHeader
void WriteHeader()
v8::ScriptCompiler::CachedData::BufferOwned
@ BufferOwned
Definition: v8.h:1812
v8::Isolate::AllowJavascriptExecutionScope::~AllowJavascriptExecutionScope
~AllowJavascriptExecutionScope()
v8::Local::New
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8.h:11035
v8::ObjectTemplate::MarkAsUndetectable
void MarkAsUndetectable()
v8::RegExp::kHasIndices
@ kHasIndices
Definition: v8.h:6196
v8::Context::Scope
Definition: v8.h:10796
v8::Isolate::SetWasmLoadSourceMapCallback
void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback)
v8::JitCodeEvent::PositionType
PositionType
Definition: v8.h:8012
v8::TracedGlobal::operator=
V8_INLINE TracedGlobal & operator=(const TracedGlobal &rhs)
Definition: v8.h:11333
v8::V8::SetReturnAddressLocationResolver
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver return_address_resolver)
v8::kPromiseRejectWithNoHandler
@ kPromiseRejectWithNoHandler
Definition: v8.h:7591
v8::Object::Clone
Local< Object > Clone()
v8::ReturnValue::GetIsolate
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:11520
v8::Global::Global
V8_INLINE Global()
Definition: v8.h:766
v8::TracedReferenceBase::val_
internal::Address * val_
Definition: v8.h:889
v8::Isolate::kDateGetTimezoneOffset
@ kDateGetTimezoneOffset
Definition: v8.h:8732
v8::PersistentBase::SetWeak
V8_INLINE void SetWeak()
Definition: v8.h:11170
v8::String::ExternalOneByteStringResource::length
virtual size_t length() const =0
v8::NonCopyablePersistentTraits::kResetInDestructor
static const bool kResetInDestructor
Definition: v8.h:633
v8::MicrotasksScope::MicrotasksScope
MicrotasksScope(Isolate *isolate, Type type)
v8::Isolate::kAttemptOverrideReadOnlyOnPrototypeStrict
@ kAttemptOverrideReadOnlyOnPrototypeStrict
Definition: v8.h:8728
v8::Object::SetAccessorProperty
void SetAccessorProperty(Local< Name > name, Local< Function > getter, Local< Function > setter=Local< Function >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
v8::Value::IsInt32
bool IsInt32() const
v8::SnapshotCreator::operator=
void operator=(const SnapshotCreator &)=delete
v8::NamedPropertyHandlerConfiguration::definer
GenericNamedPropertyDefinerCallback definer
Definition: v8.h:6933
v8::EmbedderHeapTracer::TraceSummary::allocated_size
size_t allocated_size
Definition: v8.h:8201
v8::JitCodeEvent::isolate
Isolate * isolate
Definition: v8.h:8079
v8::Module::GetStatus
Status GetStatus() const
v8::WasmStreaming::Unpack
static std::shared_ptr< WasmStreaming > Unpack(Isolate *isolate, Local< Value > value)
v8::Maybe::To
V8_WARN_UNUSED_RESULT V8_INLINE bool To(T *out) const
Definition: v8.h:10293
v8::ConstructorBehavior::kThrow
@ kThrow
v8::Map::Set
V8_WARN_UNUSED_RESULT MaybeLocal< Map > Set(Local< Context > context, Local< Value > key, Local< Value > value)
v8::ArrayBuffer::Contents::Data
void * Data() const
Definition: v8.h:5422
v8::TracedGlobal::TracedGlobal
TracedGlobal(Isolate *isolate, Local< S > that)
Definition: v8.h:983
v8::Isolate::GetStackSample
void GetStackSample(const RegisterState &state, void **frames, size_t frames_limit, SampleInfo *sample_info)
v8::Object::DefineOwnProperty
V8_WARN_UNUSED_RESULT Maybe< bool > DefineOwnProperty(Local< Context > context, Local< Name > key, Local< Value > value, PropertyAttribute attributes=None)
v8::kGCCallbackFlagCollectAllAvailableGarbage
@ kGCCallbackFlagCollectAllAvailableGarbage
Definition: v8.h:7848
v8::Object::GetAlignedPointerFromInternalField
static V8_INLINE void * GetAlignedPointerFromInternalField(const BasicTracedReference< Object > &object, int index)
Definition: v8.h:4174
v8::Isolate::kBreakIteratorTypeWord
@ kBreakIteratorTypeWord
Definition: v8.h:8746
v8::PropertyDescriptor::PropertyDescriptor
PropertyDescriptor(Local< Value > get, Local< Value > set)
v8::MeasureMemoryExecution::kLazy
@ kLazy
v8::Isolate::IsolateInBackgroundNotification
void IsolateInBackgroundNotification()
v8::IntegrityLevel::kFrozen
@ kFrozen
v8::NamedPropertyHandlerConfiguration::query
GenericNamedPropertyQueryCallback query
Definition: v8.h:6930
v8::ScriptCompiler::CachedData::BufferNotOwned
@ BufferNotOwned
Definition: v8.h:1811
v8::Isolate::AttachCppHeap
void AttachCppHeap(CppHeap *)
v8::Isolate::kArrayProtectorDirtied
@ kArrayProtectorDirtied
Definition: v8.h:8682
v8::Exception::TypeError
static Local< Value > TypeError(Local< String > message)
v8::Object::Delete
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, Local< Value > key)
v8::Local::New
static V8_INLINE Local< T > New(Isolate *isolate, const PersistentBase< T > &that)
Definition: v8.h:11040
v8::Isolate::DetachCppHeap
void DetachCppHeap()
v8::Isolate::GetMicrotasksPolicy
MicrotasksPolicy GetMicrotasksPolicy() const
v8::TracedReference::TracedReference
TracedReference(Isolate *isolate, Local< S > that)
Definition: v8.h:1106
v8::Isolate::kPromiseDefer
@ kPromiseDefer
Definition: v8.h:8677
v8::RegExp::GetFlags
Flags GetFlags() const
v8::BigInt::Cast
static V8_INLINE BigInt * Cast(v8::Data *data)
Definition: v8.h:12014
v8::Value::IntegerValue
V8_WARN_UNUSED_RESULT Maybe< int64_t > IntegerValue(Local< Context > context) const
v8::Message::GetScriptResourceName
Local< Value > GetScriptResourceName() const
v8::Isolate::VisitWeakHandles
void VisitWeakHandles(PersistentHandleVisitor *visitor)
v8::Message::GetStackTrace
Local< StackTrace > GetStackTrace() const
v8::StackTrace::CurrentStackTrace
static Local< StackTrace > CurrentStackTrace(Isolate *isolate, int frame_limit, StackTraceOptions options=kDetailed)
v8::Isolate::kPromiseChain
@ kPromiseChain
Definition: v8.h:8675
v8::ExtensionConfiguration::end
const char ** end() const
Definition: v8.h:10550
v8::String::Length
int Length() const
v8::ScriptCompiler::Compile
static V8_WARN_UNUSED_RESULT MaybeLocal< Script > Compile(Local< Context > context, StreamedSource *source, Local< String > full_source_string, const ScriptOrigin &origin)
v8::Isolate::GetHeapProfiler
HeapProfiler * GetHeapProfiler()
v8::Value::IsSet
bool IsSet() const
v8::internal::Internals::IsValidSmi
static constexpr V8_INLINE bool IsValidSmi(intptr_t value)
Definition: v8-internal.h:275
v8::Primitive
Definition: v8.h:3102
V8_PROMISE_INTERNAL_FIELD_COUNT
#define V8_PROMISE_INTERNAL_FIELD_COUNT
Definition: v8.h:4807
V8_NODISCARD
#define V8_NODISCARD
Definition: v8config.h:468
v8::Local::operator!=
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:266
v8::ScriptCompiler::Source::GetCachedData
const V8_INLINE CachedData * GetCachedData() const
Definition: v8.h:11700
v8::Persistent::Persistent
V8_INLINE Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8.h:689
v8::Module::Evaluate
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Evaluate(Local< Context > context)
v8::PrimitiveArray
Definition: v8.h:1383
v8::Value::IsDataView
bool IsDataView() const
v8::internal::Internals::kUndefinedOddballKind
static const int kUndefinedOddballKind
Definition: v8-internal.h:243
v8::Exception::ReferenceError
static Local< Value > ReferenceError(Local< String > message)
v8::Uint32Array::New
static Local< Uint32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::Promise::Resolver
Definition: v8.h:4821
V8_EXPORT
#define V8_EXPORT
Definition: v8config.h:512
v8::WasmModuleObjectBuilderStreaming::Finish
void Finish()
v8::String::StringEquals
bool StringEquals(Local< String > str)
v8::JSEntryStubs
Definition: v8.h:2425
v8::Isolate::kUseCounterFeatureCount
@ kUseCounterFeatureCount
Definition: v8.h:8774
v8::SideEffectType
SideEffectType
Definition: v8.h:3879
v8::OwnedBuffer::buffer
std::unique_ptr< const uint8_t[]> buffer
Definition: v8.h:5028
v8::Isolate::kNumberToLocaleString
@ kNumberToLocaleString
Definition: v8.h:8723
v8::PropertyHandlerFlags
PropertyHandlerFlags
Definition: v8.h:6840
v8::NumberObject::New
static Local< Value > New(Isolate *isolate, double value)
v8::MemoryPressureLevel::kCritical
@ kCritical
v8::JitCodeEvent::code_start
void * code_start
Definition: v8.h:8026
v8::WasmMemoryObject::Buffer
Local< ArrayBuffer > Buffer()
v8::EmbedderHeapTracer::kForced
@ kForced
Definition: v8.h:8173
v8::Module::GetModuleNamespace
Local< Value > GetModuleNamespace()
v8::ArrayBuffer::Cast
static V8_INLINE ArrayBuffer * Cast(Value *obj)
Definition: v8.h:12151
v8::RegExp::kUnicode
@ kUnicode
Definition: v8.h:6193
v8::Isolate::GetCodeRange
void GetCodeRange(void **start, size_t *length_in_bytes)
v8::ScriptType
ScriptType
Definition: v8.h:1795
v8::Date::Cast
static V8_INLINE Date * Cast(Value *obj)
Definition: v8.h:12028
v8::RegExp::kDotAll
@ kDotAll
Definition: v8.h:6194
v8::Object::Set
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, uint32_t index, Local< Value > value)
v8::Isolate::IsInUse
bool IsInUse()
v8::EmbedderHeapTracer::GarbageCollectionForTesting
void GarbageCollectionForTesting(EmbedderStackState stack_state)
v8::String::Value::operator*
const uint16_t * operator*() const
Definition: v8.h:3567
v8::ArrayBuffer::Contents
Definition: v8.h:5403
v8::ArrayBufferView::kEmbedderFieldCount
static const int kEmbedderFieldCount
Definition: v8.h:5636
v8::ObjectTemplate::SetHandler
void SetHandler(const NamedPropertyHandlerConfiguration &configuration)
v8::Int8Array::New
static Local< Int8Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::HandleScope::HandleScope
HandleScope(const HandleScope &)=delete
v8::Isolate::kWasmSimdOpcodes
@ kWasmSimdOpcodes
Definition: v8.h:8764
v8::UnboundScript::kNoScriptId
static const int kNoScriptId
Definition: v8.h:1512
v8::Isolate::SetAllowAtomicsWait
void SetAllowAtomicsWait(bool allow)
v8::Isolate::kInvalidatedArrayBufferDetachingProtector
@ kInvalidatedArrayBufferDetachingProtector
Definition: v8.h:8748
v8::ALL_CAN_READ
@ ALL_CAN_READ
Definition: v8.h:3852
v8::Isolate::SetCreateHistogramFunction
void SetCreateHistogramFunction(CreateHistogramCallback)
v8::Template::SetAccessorProperty
void SetAccessorProperty(Local< Name > name, Local< FunctionTemplate > getter=Local< FunctionTemplate >(), Local< FunctionTemplate > setter=Local< FunctionTemplate >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
v8::Value::IsSymbol
bool IsSymbol() const
v8::RAILMode
RAILMode
Definition: v8.h:8087
v8::Context::SetErrorMessageForCodeGenerationFromStrings
void SetErrorMessageForCodeGenerationFromStrings(Local< String > message)
v8::Script
Definition: v8.h:1773
v8::Message
Definition: v8.h:2161
v8::Object::HasRealNamedCallbackProperty
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealNamedCallbackProperty(Local< Context > context, Local< Name > key)
v8::ScriptOriginOptions::IsWasm
bool IsWasm() const
Definition: v8.h:1410
v8::ValueSerializer::SetTreatArrayBufferViewsAsHostObjects
void SetTreatArrayBufferViewsAsHostObjects(bool mode)
v8::ModuleRequest::GetSourceOffset
int GetSourceOffset() const
v8::Local::CustomArguments
friend class internal::CustomArguments
Definition: v8.h:326
v8::kJitCodeEventDefault
@ kJitCodeEventDefault
Definition: v8.h:8108
v8::TracedReference::operator=
TracedReference< T > & operator=(const TracedReference< S > &rhs)
Definition: v8.h:11366
v8::PersistentBase::WrapperClassId
V8_INLINE uint16_t WrapperClassId() const
Definition: v8.h:11198
v8::ArrayBuffer::IsDetachable
bool IsDetachable() const
v8::Isolate::kSloppyMode
@ kSloppyMode
Definition: v8.h:8666
v8::PropertyDescriptor::configurable
bool configurable() const
v8::CrashKeyId::kCodeSpaceFirstPageAddress
@ kCodeSpaceFirstPageAddress
v8::TypedArray::Length
size_t Length()
v8::Integer::Cast
static V8_INLINE Integer * Cast(v8::Data *data)
Definition: v8.h:11993
v8::Value::IsFalse
bool IsFalse() const
v8::V8::WeakCallbackInfo
friend class WeakCallbackInfo
Definition: v8.h:10145
v8::Module::ScriptId
int ScriptId()
v8::internal::IsolateFromNeverReadOnlySpaceObject
V8_EXPORT internal::Isolate * IsolateFromNeverReadOnlySpaceObject(Address obj)
v8::BackingStore::Reallocate
static std::unique_ptr< BackingStore > Reallocate(v8::Isolate *isolate, std::unique_ptr< BackingStore > backing_store, size_t byte_length)
v8::FunctionCallbackInfo::Holder
V8_INLINE Local< Object > Holder() const
Definition: v8.h:11567
v8::ArrayBufferView::Buffer
Local< ArrayBuffer > Buffer()
v8::Isolate::RemoveMicrotasksCompletedCallback
void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallbackWithData callback, void *data=nullptr)
v8::Isolate::kInvalidatedSetIteratorLookupChainProtector
@ kInvalidatedSetIteratorLookupChainProtector
Definition: v8.h:8760
v8::Module::kInstantiating
@ kInstantiating
Definition: v8.h:1596
v8::Extension::operator=
void operator=(const Extension &)=delete
v8::ExtensionConfiguration::ExtensionConfiguration
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8.h:10546
v8::ModifyCodeGenerationFromStringsResult::modified_source
MaybeLocal< String > modified_source
Definition: v8.h:7773
v8::Unlocker::Unlocker
V8_INLINE Unlocker(Isolate *isolate)
Definition: v8.h:10934
v8::Context::GetNumberOfEmbedderDataFields
uint32_t GetNumberOfEmbedderDataFields()
v8::StackTrace::kIsConstructor
@ kIsConstructor
Definition: v8.h:2270
v8::ONLY_CONFIGURABLE
@ ONLY_CONFIGURABLE
Definition: v8.h:3864
v8::String::MakeExternal
bool MakeExternal(ExternalStringResource *resource)
v8::SnapshotCreator::SnapshotCreator
SnapshotCreator(Isolate *isolate, const intptr_t *external_references=nullptr, StartupData *existing_blob=nullptr)
v8::ModifyCodeGenerationFromStringsResult
Definition: v8.h:7767
v8::PropertyDescriptor::has_get
bool has_get() const
v8::String::Value::length
int length() const
Definition: v8.h:3568
v8::ValueSerializer::TransferArrayBuffer
void TransferArrayBuffer(uint32_t transfer_id, Local< ArrayBuffer > array_buffer)
v8::WasmStreaming::Client::OnModuleCompiled
virtual void OnModuleCompiled(CompiledWasmModule compiled_module)=0
v8::Value::ToBoolean
Local< Boolean > ToBoolean(Isolate *isolate) const
v8::Isolate::SafeForTerminationScope::SafeForTerminationScope
SafeForTerminationScope(const SafeForTerminationScope &)=delete
v8::Context::Global
Local< Object > Global()
v8::Object::HasOwnProperty
V8_WARN_UNUSED_RESULT Maybe< bool > HasOwnProperty(Local< Context > context, uint32_t index)
v8::Isolate::kDateToLocaleTimeString
@ kDateToLocaleTimeString
Definition: v8.h:8726
v8::KeyConversionMode::kKeepNumbers
@ kKeepNumbers
v8::IndexedPropertyHandlerConfiguration::IndexedPropertyHandlerConfiguration
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, IndexedPropertyDescriptorCallback descriptor, IndexedPropertyDeleterCallback deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallback definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6979
v8::String::ExternalStringResource::length
virtual size_t length() const =0
v8::JSON::Stringify
static V8_WARN_UNUSED_RESULT MaybeLocal< String > Stringify(Local< Context > context, Local< Value > json_object, Local< String > gap=Local< String >())
v8::JitCodeEvent::wasm_source_info
wasm_source_info_t * wasm_source_info
Definition: v8.h:8066
v8::ACCESS_DELETE
@ ACCESS_DELETE
Definition: v8.h:6603
v8::TracedReferenceBase::IsEmptyThreadSafe
bool IsEmptyThreadSafe() const
Definition: v8.h:856
v8::internal::Internals::kFirstNonstringType
static const int kFirstNonstringType
Definition: v8-internal.h:236
v8::ObjectTemplate::SetAccessor
void SetAccessor(Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::ScriptOrigin::ScriptOrigin
V8_INLINE ScriptOrigin(Isolate *isolate, Local< Value > resource_name, int resource_line_offset=0, int resource_column_offset=0, bool resource_is_shared_cross_origin=false, int script_id=-1, Local< Value > source_map_url=Local< Value >(), bool resource_is_opaque=false, bool is_wasm=false, bool is_module=false, Local< PrimitiveArray > host_defined_options=Local< PrimitiveArray >())
Definition: v8.h:11638
v8::StringObject
Definition: v8.h:6145
v8::MemorySpan
Definition: v8.h:5007
v8::Date::New
static V8_WARN_UNUSED_RESULT MaybeLocal< Value > New(Local< Context > context, double time)
v8::BackingStore::~BackingStore
~BackingStore()
v8::BackingStore
Definition: v8.h:5250
v8::Value::IsRegExp
bool IsRegExp() const
v8::Isolate::SetMetricsRecorder
void SetMetricsRecorder(const std::shared_ptr< metrics::Recorder > &metrics_recorder)
v8::internal
Definition: v8-cppgc.h:26
v8::Isolate::RequestGarbageCollectionForTesting
void RequestGarbageCollectionForTesting(GarbageCollectionType type)
v8::Isolate::AddBeforeCallEnteredCallback
void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
v8::internal::Internals::kExternalTwoByteRepresentationTag
static const int kExternalTwoByteRepresentationTag
Definition: v8-internal.h:199
v8::ObjectTemplate::New
static Local< ObjectTemplate > New(Isolate *isolate, Local< FunctionTemplate > constructor=Local< FunctionTemplate >())
v8::kGCCallbackFlagForced
@ kGCCallbackFlagForced
Definition: v8.h:7846
v8::Isolate::SafeForTerminationScope::SafeForTerminationScope
SafeForTerminationScope(v8::Isolate *isolate)
v8::Isolate::kIntlResolved
@ kIntlResolved
Definition: v8.h:8674
v8::JSON::Parse
static V8_WARN_UNUSED_RESULT MaybeLocal< Value > Parse(Local< Context > context, Local< String > json_string)
v8::PropertyFilter
PropertyFilter
Definition: v8.h:3860
v8::MemoryPressureLevel::kNone
@ kNone
v8::SampleInfo
Definition: v8.h:2408
v8::internal::Internals::kEmbedderDataSlotSize
static const int kEmbedderDataSlotSize
Definition: v8-internal.h:192
v8::Promise::Resolver::GetPromise
Local< Promise > GetPromise()
v8::JitCodeEvent::BYTE_CODE
@ BYTE_CODE
Definition: v8.h:8020
v8::ArrayBuffer::Contents::AllocationBase
void * AllocationBase() const
Definition: v8.h:5416
v8::PropertyCallbackInfo::args_
internal::Address * args_
Definition: v8.h:4694
v8::Isolate::DisallowJavascriptExecutionScope::~DisallowJavascriptExecutionScope
~DisallowJavascriptExecutionScope()
v8::JitCodeEvent::name_t::len
size_t len
Definition: v8.h:8042
v8::Object::GetInternalField
V8_INLINE Local< Value > GetInternalField(int index)
Definition: v8.h:11747
v8::Locker::Locker
Locker(const Locker &)=delete
v8::internal::Internals::kTrueValueRootIndex
static const int kTrueValueRootIndex
Definition: v8-internal.h:226
v8::String::Value
Definition: v8.h:3562
v8::BigInt64Array::New
static Local< BigInt64Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::ScriptCompiler::kNoCacheBecauseNoResource
@ kNoCacheBecauseNoResource
Definition: v8.h:1988
v8::Context::GetAlignedPointerFromEmbedderData
V8_INLINE void * GetAlignedPointerFromEmbedderData(int index)
Definition: v8.h:12418
v8::TryCatch::Exception
Local< Value > Exception() const
v8::Boolean::Value
bool Value() const
v8::ExternalResourceVisitor
Definition: v8.h:8132
v8::JSEntryStub
Definition: v8.h:2421
v8::WasmMemoryObject
Definition: v8.h:5064
v8::NamedPropertyHandlerConfiguration::NamedPropertyHandlerConfiguration
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, GenericNamedPropertyDescriptorCallback descriptor, GenericNamedPropertyDeleterCallback deleter, GenericNamedPropertyEnumeratorCallback enumerator, GenericNamedPropertyDefinerCallback definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6909
v8::EmbedderHeapTracer::TracedGlobalHandleVisitor::VisitTracedGlobalHandle
virtual void VisitTracedGlobalHandle(const TracedGlobal< Value > &handle)
Definition: v8.h:8182
v8::CopyablePersistentTraits::kResetInDestructor
static const bool kResetInDestructor
Definition: v8.h:650
v8::Isolate::kFunctionTokenOffsetTooLongForToString
@ kFunctionTokenOffsetTooLongForToString
Definition: v8.h:8707
v8::Symbol::GetAsyncIterator
static Local< Symbol > GetAsyncIterator(Isolate *isolate)
v8::V8::Maybe
friend class Maybe
Definition: v8.h:10138
v8::Maybe::FromMaybe
V8_INLINE T FromMaybe(const T &default_value) const
Definition: v8.h:10311
v8::String::ONE_BYTE_ENCODING
@ ONE_BYTE_ENCODING
Definition: v8.h:3171
v8::Value::IsGeneratorObject
bool IsGeneratorObject() const
v8::ArrayBuffer::Contents::Deleter
DeleterCallback Deleter() const
Definition: v8.h:5424
v8::CompiledWasmModule::Serialize
OwnedBuffer Serialize()
v8::ModuleRequest
Definition: v8.h:1547
v8::EmbedderHeapTracer::FinalizeTracing
void FinalizeTracing()
v8::IndexedPropertyHandlerConfiguration
Definition: v8.h:6940
v8::HeapCodeStatistics::code_and_metadata_size
size_t code_and_metadata_size()
Definition: v8.h:7981
v8::String::HINT_MANY_WRITES_EXPECTED
@ HINT_MANY_WRITES_EXPECTED
Definition: v8.h:3226
v8::MeasureMemoryExecution::kDefault
@ kDefault
v8::StackTrace::kDetailed
@ kDetailed
Definition: v8.h:2275
v8::Isolate::kListFormat
@ kListFormat
Definition: v8.h:8718
v8::HeapStatistics::total_heap_size
size_t total_heap_size()
Definition: v8.h:7900
v8::internal::Internals::GetIsolateForHeapSandbox
static V8_INLINE internal::Isolate * GetIsolateForHeapSandbox(internal::Address obj)
Definition: v8-internal.h:378
v8::Isolate::RemoveGCEpilogueCallback
void RemoveGCEpilogueCallback(GCCallbackWithData callback, void *data=nullptr)
v8::Module::kUninstantiated
@ kUninstantiated
Definition: v8.h:1595
v8::Context
Definition: v8.h:10561
v8::ScriptCompiler::StreamedSource::TWO_BYTE
@ TWO_BYTE
Definition: v8.h:1939
v8::Isolate::kInvalidatedMapIteratorLookupChainProtector
@ kInvalidatedMapIteratorLookupChainProtector
Definition: v8.h:8753
v8::Isolate::kRegExpExecCalledOnSlowRegExp
@ kRegExpExecCalledOnSlowRegExp
Definition: v8.h:8737
v8::Isolate::AtomicsWaitEvent::kStartWait
@ kStartWait
v8::Isolate::RemoveCallCompletedCallback
void RemoveCallCompletedCallback(CallCompletedCallback callback)
v8::Promise::Resolver::Reject
V8_WARN_UNUSED_RESULT Maybe< bool > Reject(Local< Context > context, Local< Value > value)
v8::kPromiseHandlerAddedAfterReject
@ kPromiseHandlerAddedAfterReject
Definition: v8.h:7592
v8::ObjectTemplate::SetAccessCheckCallbackAndHandler
void SetAccessCheckCallbackAndHandler(AccessCheckCallback callback, const NamedPropertyHandlerConfiguration &named_handler, const IndexedPropertyHandlerConfiguration &indexed_handler, Local< Value > data=Local< Value >())
v8::Isolate::kStringToLocaleUpperCase
@ kStringToLocaleUpperCase
Definition: v8.h:8721
v8::OwnedBuffer::OwnedBuffer
OwnedBuffer()=default
v8::TryCatch::StackTrace
static V8_WARN_UNUSED_RESULT MaybeLocal< Value > StackTrace(Local< Context > context, Local< Value > exception)
v8::Isolate
Definition: v8.h:8450
v8::Isolate::kInvalidatedStringIteratorLookupChainProtector
@ kInvalidatedStringIteratorLookupChainProtector
Definition: v8.h:8761
v8::HeapObjectStatistics
Definition: v8.h:7961
v8::Isolate::SetFailedAccessCheckCallbackFunction
void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)
v8::FunctionCallbackInfo::kDataIndex
static const int kDataIndex
Definition: v8.h:4575
v8::Isolate::kMessageWarning
@ kMessageWarning
Definition: v8.h:8782
v8::Isolate::MemoryPressureNotification
void MemoryPressureNotification(MemoryPressureLevel level)
v8::V8::SetSnapshotDataBlob
static void SetSnapshotDataBlob(StartupData *startup_blob)
v8::MicrotaskQueue::EnqueueMicrotask
virtual void EnqueueMicrotask(Isolate *isolate, Local< Function > microtask)=0
v8::TracedGlobal::operator=
TracedGlobal< T > & operator=(TracedGlobal< S > &&rhs)
Definition: v8.h:11308
v8::Isolate::ContextDisposedNotification
int ContextDisposedNotification(bool dependant_context=true)
v8::PropertyDescriptor::set_enumerable
void set_enumerable(bool enumerable)
v8::SnapshotCreator::FunctionCodeHandling::kClear
@ kClear
v8::Set::Cast
static V8_INLINE Set * Cast(Value *obj)
Definition: v8.h:12106
v8::KeyCollectionMode::kIncludePrototypes
@ kIncludePrototypes
v8::Unlocker::~Unlocker
~Unlocker()
v8::HandleScope::HandleScope
HandleScope(Isolate *isolate)
v8::PropertyCallbackInfo::ShouldThrowOnError
V8_INLINE bool ShouldThrowOnError() const
Definition: v8.h:12322
v8::ScriptCompiler::kNoCacheNoReason
@ kNoCacheNoReason
Definition: v8.h:1986
v8::PropertyCallbackInfo::GetReturnValue
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:12317
v8::ScriptCompiler::Source::Source
V8_INLINE Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=nullptr)
Definition: v8.h:11679
v8::Function::kLineOffsetNotFound
static const int kLineOffsetNotFound
Definition: v8.h:4798
v8::Intrinsic
Intrinsic
Definition: v8.h:6278
v8::MicrotaskQueue::operator=
MicrotaskQueue & operator=(const MicrotaskQueue &)=delete
v8::None
@ None
Definition: v8.h:3815
v8::operator!=
V8_INLINE bool operator!=(const TracedReferenceBase &lhs, const v8::Local< U > &rhs)
Definition: v8.h:11285
v8::Maybe< void >::IsJust
V8_INLINE bool IsJust() const
Definition: v8.h:10352
v8::ReturnValue::SetNull
V8_INLINE void SetNull()
Definition: v8.h:11499
v8::V8::TracedGlobal
friend class TracedGlobal
Definition: v8.h:10140
v8::Name::Cast
static V8_INLINE Name * Cast(Data *data)
Definition: v8.h:11951
v8::V8::SetIsCrossOriginIsolated
static void SetIsCrossOriginIsolated()
v8::PersistentBase::Reset
void Reset(Isolate *isolate, const PersistentBase< S > &other)
Definition: v8.h:11143
v8::Float32Array::New
static Local< Float32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::Object::CreationContext
Local< Context > CreationContext()
v8::TryCatch::TryCatch
TryCatch(const TryCatch &)=delete
v8::Number::Cast
static V8_INLINE Number * Cast(v8::Data *data)
Definition: v8.h:11986
v8::Eternal::Eternal
V8_INLINE Eternal(Isolate *isolate, Local< S > handle)
Definition: v8.h:419
v8::CopyablePersistentTraits::Copy
static V8_INLINE void Copy(const Persistent< S, M > &source, CopyablePersistent *dest)
Definition: v8.h:652
v8::ValueSerializer::Delegate::WriteHostObject
virtual Maybe< bool > WriteHostObject(Isolate *isolate, Local< Object > object)
v8::Object::CreateDataProperty
V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Local< Context > context, Local< Name > key, Local< Value > value)
v8::Locker::operator=
void operator=(const Locker &)=delete
v8::Promise::PromiseState
PromiseState
Definition: v8.h:4819
v8::Object::HasIndexedLookupInterceptor
bool HasIndexedLookupInterceptor()
v8::StartupData::raw_size
int raw_size
Definition: v8.h:9868
v8::ReturnValue::Set
V8_INLINE void Set(double i)
Definition: v8.h:11457
v8::ReturnValue::ReturnValue
V8_INLINE ReturnValue(const ReturnValue< S > &that)
Definition: v8.h:4480
v8::GC
@ GC
Definition: v8.h:2376
v8::TryCatch
Definition: v8.h:10380
v8::ExternalResourceVisitor::VisitExternalString
virtual void VisitExternalString(Local< String > string)
Definition: v8.h:8135
v8::Value::IsNumber
bool IsNumber() const
v8::Just
Maybe< T > Just(const T &t)
Definition: v8.h:10343
v8::String::Value::Value
Value(const Value &)=delete
v8::FunctionCallbackInfo::implicit_args_
internal::Address * implicit_args_
Definition: v8.h:4580
v8::String::IsOneByte
bool IsOneByte() const
v8::ScriptCompiler::StreamedSource
Definition: v8.h:1937
v8::Script::GetUnboundScript
Local< UnboundScript > GetUnboundScript()
v8::Module::SetSyntheticModuleExport
V8_WARN_UNUSED_RESULT Maybe< bool > SetSyntheticModuleExport(Isolate *isolate, Local< String > export_name, Local< Value > export_value)
v8::Persistent::Persistent
V8_INLINE Persistent()
Definition: v8.h:672
v8::JitCodeEvent::user_data
void * user_data
Definition: v8.h:8035
v8::Isolate::Exit
void Exit()
v8::String::Utf8Value
Definition: v8.h:3539
v8::Script::Run
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Run(Local< Context > context)
v8::BigInt64Array::Cast
static V8_INLINE BigInt64Array * Cast(Value *obj)
Definition: v8.h:12238
v8::Value::IsWeakMap
bool IsWeakMap() const
v8::String::ExternalStringResource
Definition: v8.h:3316
v8::EscapableHandleScope::operator=
void operator=(const EscapableHandleScope &)=delete
v8::Value::IsName
bool IsName() const
v8::Isolate::CreateParams::add_histogram_sample_callback
AddHistogramSampleCallback add_histogram_sample_callback
Definition: v8.h:8488
v8::WasmStreaming::Client
Definition: v8.h:5116
v8::String::Write
int Write(Isolate *isolate, uint16_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
V8_LIKELY
#define V8_LIKELY(condition)
Definition: v8config.h:444
v8::Symbol::Name
Local< Value > Name() const
Definition: v8.h:3613
v8::Isolate::Allocate
static Isolate * Allocate()
v8::PersistentBase::operator!=
V8_INLINE bool operator!=(const Local< S > &that) const
Definition: v8.h:541
v8::String::NO_OPTIONS
@ NO_OPTIONS
Definition: v8.h:3225
v8::PropertyDescriptor::~PropertyDescriptor
~PropertyDescriptor()
v8::String::GetExternalOneByteStringResource
const ExternalOneByteStringResource * GetExternalOneByteStringResource() const
v8::Isolate::GarbageCollectionType
GarbageCollectionType
Definition: v8.h:8647
v8::UnboundScript::GetLineNumber
int GetLineNumber(int code_pos)
v8::PropertyDescriptor::writable
bool writable() const
v8::Isolate::TimeZoneDetection::kRedetect
@ kRedetect
v8::HeapStatistics::does_zap_garbage
size_t does_zap_garbage()
Definition: v8.h:7918
v8::Int32Array::Cast
static V8_INLINE Int32Array * Cast(Value *obj)
Definition: v8.h:12215
v8::Isolate::kMarkDequeOverflow
@ kMarkDequeOverflow
Definition: v8.h:8661
v8::Isolate::ThrowException
Local< Value > ThrowException(Local< Value > exception)
v8::StringObject::ValueOf
Local< String > ValueOf() const
v8::ScriptCompiler::CreateCodeCache
static CachedData * CreateCodeCache(Local< UnboundModuleScript > unbound_module_script)
v8::Context::SetAlignedPointerInEmbedderData
void SetAlignedPointerInEmbedderData(int index, void *value)
v8::Isolate::kWasmRefTypes
@ kWasmRefTypes
Definition: v8.h:8766
v8::Module::IsSourceTextModule
bool IsSourceTextModule() const
v8::FunctionCallbackInfo::This
V8_INLINE Local< Object > This() const
Definition: v8.h:11560
v8::Isolate::AddGCPrologueCallback
void AddGCPrologueCallback(GCCallbackWithData callback, void *data=nullptr, GCType gc_type_filter=kGCTypeAll)
v8::HandleScope::GetIsolate
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:1211
v8::FunctionTemplate::SetLength
void SetLength(int length)
v8::Value::IsExternal
bool IsExternal() const
v8::WasmStreaming::~WasmStreaming
~WasmStreaming()
v8::Int32::Value
int32_t Value() const
v8::EscapableHandleScope::~EscapableHandleScope
V8_INLINE ~EscapableHandleScope()=default
v8::Isolate::AtomicsWaitEvent
AtomicsWaitEvent
Definition: v8.h:9176
v8::HeapCodeStatistics::external_script_source_size
size_t external_script_source_size()
Definition: v8.h:7983
v8::HeapStatistics::number_of_native_contexts
size_t number_of_native_contexts()
Definition: v8.h:7911
v8::Private::Cast
static V8_INLINE Private * Cast(Data *data)
Definition: v8.h:11965
v8::Isolate::GetArrayBufferAllocator
ArrayBuffer::Allocator * GetArrayBufferAllocator()
v8::Context::GetMicrotaskQueue
MicrotaskQueue * GetMicrotaskQueue()
v8
Definition: libplatform.h:15
v8::Isolate::kWasmMultiValue
@ kWasmMultiValue
Definition: v8.h:8768
v8::Value::IsBigInt64Array
bool IsBigInt64Array() const
v8::MicrotasksScope::kDoNotRunMicrotasks
@ kDoNotRunMicrotasks
Definition: v8.h:7723
v8::PropertyDescriptor::has_enumerable
bool has_enumerable() const
v8::UnboundScript::GetId
int GetId()
v8::ArrayBuffer::ByteLength
size_t ByteLength() const
v8::SharedMemoryStatistics::read_only_space_physical_size
size_t read_only_space_physical_size()
Definition: v8.h:7878
v8::ReturnValue::Set
V8_INLINE void Set(bool value)
Definition: v8.h:11486
v8::JitCodeEvent::CodeType
CodeType
Definition: v8.h:8020
v8::Isolate::kPluralRules
@ kPluralRules
Definition: v8.h:8715
v8::Extension::dependency_count
int dependency_count() const
Definition: v8.h:7276
v8::Uint16Array::Cast
static V8_INLINE Uint16Array * Cast(Value *obj)
Definition: v8.h:12191
v8::RegisterState::callee_saved
std::unique_ptr< CalleeSavedRegisters > callee_saved
Definition: v8.h:2404
v8::String::ExternalStringResource::ExternalStringResource
ExternalStringResource()=default
v8::Module::kEvaluating
@ kEvaluating
Definition: v8.h:1598
v8::PersistentBase::SetWrapperClassId
V8_INLINE void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:11188
v8::Proxy::Revoke
void Revoke()
v8::ArrayBuffer::Externalize
Contents Externalize()
v8::Value::IsBoolean
bool IsBoolean() const
v8::ResourceConstraints::set_max_young_generation_size_in_bytes
void set_max_young_generation_size_in_bytes(size_t limit)
Definition: v8.h:7387
v8::Value::ToBigInt
V8_WARN_UNUSED_RESULT MaybeLocal< BigInt > ToBigInt(Local< Context > context) const
v8::OTHER
@ OTHER
Definition: v8.h:2380
v8::ScriptOriginOptions
Definition: v8.h:1394
v8::Module::GetUnboundModuleScript
Local< UnboundModuleScript > GetUnboundModuleScript()
v8::ConstructorBehavior
ConstructorBehavior
Definition: v8.h:4699
v8::DontEnum
@ DontEnum
Definition: v8.h:3819
v8::WasmModuleObject::GetCompiledModule
CompiledWasmModule GetCompiledModule()
v8::Isolate::kInvalidatedPromiseSpeciesLookupChainProtector
@ kInvalidatedPromiseSpeciesLookupChainProtector
Definition: v8.h:8757
v8::ScriptCompiler::Source::GetResourceOptions
const V8_INLINE ScriptOriginOptions & GetResourceOptions() const
Definition: v8.h:11705
v8::Unwinder
Definition: v8.h:10981
v8::ArrayBuffer::Allocator::Reallocate
virtual void * Reallocate(void *data, size_t old_length, size_t new_length)
v8::RegisterExtension
void V8_EXPORT RegisterExtension(std::unique_ptr< Extension >)
v8::Isolate::kMessageError
@ kMessageError
Definition: v8.h:8781
v8::ScriptOrigin
Definition: v8.h:1428
v8::String::ExternalOneByteStringResource::~ExternalOneByteStringResource
~ExternalOneByteStringResource() override=default
v8::Uint8Array::New
static Local< Uint8Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::StateTag
StateTag
Definition: v8.h:2374
v8::RegisterState::~RegisterState
~RegisterState()
v8::SideEffectType::kHasNoSideEffect
@ kHasNoSideEffect
v8::Context::GetSecurityToken
Local< Value > GetSecurityToken()
v8::Isolate::kErrorCaptureStackTrace
@ kErrorCaptureStackTrace
Definition: v8.h:8701
v8::operator==
V8_INLINE bool operator==(const TracedReferenceBase &lhs, const v8::Local< U > &rhs)
Definition: v8.h:11264
v8::MicrotasksScope::IsRunningMicrotasks
static bool IsRunningMicrotasks(Isolate *isolate)
v8::Isolate::Initialize
static void Initialize(Isolate *isolate, const CreateParams &params)
v8::Isolate::kInvalidatedNoElementsProtector
@ kInvalidatedNoElementsProtector
Definition: v8.h:8754
v8::String::PRESERVE_ONE_BYTE_NULL
@ PRESERVE_ONE_BYTE_NULL
Definition: v8.h:3228
v8::TryCatch::JSStackComparableAddress
static void * JSStackComparableAddress(TryCatch *handler)
Definition: v8.h:10504
v8::CrashKeyId::kMapSpaceFirstPageAddress
@ kMapSpaceFirstPageAddress
v8::internal::HeapSandboxIsEnabled
constexpr bool HeapSandboxIsEnabled()
Definition: v8-internal.h:113
v8::Date::ValueOf
double ValueOf() const
v8::Isolate::kCallSiteAPIGetFunctionSloppyCall
@ kCallSiteAPIGetFunctionSloppyCall
Definition: v8.h:8734
v8::kPromiseResolveAfterResolved
@ kPromiseResolveAfterResolved
Definition: v8.h:7594
v8::SymbolObject::Cast
static V8_INLINE SymbolObject * Cast(Value *obj)
Definition: v8.h:12044
v8::ReturnValue::Get
V8_INLINE Local< Value > Get() const
Definition: v8.h:11526
v8::HeapStatistics::heap_size_limit
size_t heap_size_limit()
Definition: v8.h:7907
v8::Template::SetLazyDataProperty
void SetLazyDataProperty(Local< Name > name, AccessorNameGetterCallback getter, Local< Value > data=Local< Value >(), PropertyAttribute attribute=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::V8::SetDcheckErrorHandler
static void SetDcheckErrorHandler(DcheckErrorCallback that)
v8::ScriptCompiler::CachedData::~CachedData
~CachedData()
v8::Isolate::DisallowJavascriptExecutionScope::DUMP_ON_FAILURE
@ DUMP_ON_FAILURE
Definition: v8.h:8560
v8::String::Utf8Value::Utf8Value
Utf8Value(Isolate *isolate, Local< v8::Value > obj)
v8::Object::PreviewEntries
MaybeLocal< Array > PreviewEntries(bool *is_key_value)
v8::JitCodeEvent::CODE_REMOVED
@ CODE_REMOVED
Definition: v8.h:8002
v8::SharedMemoryStatistics::read_only_space_size
size_t read_only_space_size()
Definition: v8.h:7876
v8::internal::Internals::kNullValueRootIndex
static const int kNullValueRootIndex
Definition: v8-internal.h:225
v8::ArrayBuffer::kInternalFieldCount
static const int kInternalFieldCount
Definition: v8.h:5580
v8::ScriptCompiler::kNoCacheBecausePacScript
@ kNoCacheBecausePacScript
Definition: v8.h:1997
v8::JitCodeEvent::line_info_t::pos
size_t pos
Definition: v8.h:8049
v8::SampleInfo::top_context
void * top_context
Definition: v8.h:2413
v8::internal::Internals::GetNodeState
static V8_INLINE uint8_t GetNodeState(internal::Address *obj)
Definition: v8-internal.h:306
v8::FixedArray::Get
Local< Data > Get(Local< Context > context, int i) const
v8::internal::BackingStoreBase
Definition: v8-internal.h:457
v8::Value::StrictEquals
bool StrictEquals(Local< Value > that) const
v8::ScriptCompiler::ExternalSourceStream
Definition: v8.h:1886
v8::DataView::New
static Local< DataView > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::PromiseHookType
PromiseHookType
Definition: v8.h:7584
v8::Template::SetNativeDataProperty
void SetNativeDataProperty(Local< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attribute=None, Local< AccessorSignature > signature=Local< AccessorSignature >(), AccessControl settings=DEFAULT, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::Isolate::HasPendingBackgroundTasks
bool HasPendingBackgroundTasks()
v8::WeakCallbackInfo::SetSecondPassCallback
void SetSecondPassCallback(Callback callback) const
Definition: v8.h:459
v8::Exception::WasmLinkError
static Local< Value > WasmLinkError(Local< String > message)
v8::Isolate::DisallowJavascriptExecutionScope::DisallowJavascriptExecutionScope
DisallowJavascriptExecutionScope(Isolate *isolate, OnFailure on_failure)
v8::Object::IsCodeLike
bool IsCodeLike(Isolate *isolate)
v8::JSEntryStubs::js_construct_entry_stub
JSEntryStub js_construct_entry_stub
Definition: v8.h:2427
v8::Value::IsNull
V8_INLINE bool IsNull() const
Definition: v8.h:11880
v8::Message::Get
Local< String > Get() const
v8::PropertyCallbackInfo::kThisIndex
static const int kThisIndex
Definition: v8.h:4691
v8::Isolate::kRegExpReplaceCalledOnSlowRegExp
@ kRegExpReplaceCalledOnSlowRegExp
Definition: v8.h:8738
v8::WasmStreaming::Client::~Client
virtual ~Client()=default
v8::Isolate::SetAddHistogramSampleFunction
void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
v8::ReturnValue::Set
void Set(const BasicTracedReference< S > &handle)
Definition: v8.h:11435
v8::Value::IsBigIntObject
bool IsBigIntObject() const
v8::Isolate::RemoveMessageListeners
void RemoveMessageListeners(MessageCallback that)
v8::String::NewFromUtf8Literal
static V8_WARN_UNUSED_RESULT Local< String > NewFromUtf8Literal(Isolate *isolate, const char(&literal)[N], NewStringType type=NewStringType::kNormal)
Definition: v8.h:3446
v8::FunctionTemplate::New
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=nullptr, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const CFunction *c_function=nullptr)
V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
Definition: v8.h:5592
v8::Locker::IsLocked
static bool IsLocked(Isolate *isolate)
v8::Isolate::DisallowJavascriptExecutionScope::CRASH_ON_FAILURE
@ CRASH_ON_FAILURE
Definition: v8.h:8560
v8::SnapshotCreator::AddData
size_t AddData(Local< T > object)
Definition: v8.h:12454
v8::Isolate::SetStackLimit
void SetStackLimit(uintptr_t stack_limit)
v8::V8::GetSharedMemoryStatistics
static void GetSharedMemoryStatistics(SharedMemoryStatistics *statistics)
v8::Array
Definition: v8.h:4386
v8::EmbedderHeapTracer::IsRootForNonTracingGC
virtual bool IsRootForNonTracingGC(const v8::TracedReference< v8::Value > &handle)
v8::SharedArrayBuffer::mode
const SharedArrayBuffer::Contents ArrayBufferCreationMode mode
Definition: v8.h:6003
v8::Isolate::SetJitCodeEventHandler
void SetJitCodeEventHandler(JitCodeEventOptions options, JitCodeEventHandler event_handler)
v8::String::ContainsOnlyOneByte
bool ContainsOnlyOneByte() const
v8::Isolate::CreateParams::array_buffer_allocator_shared
std::shared_ptr< ArrayBuffer::Allocator > array_buffer_allocator_shared
Definition: v8.h:8500
v8::PromiseHookType::kInit
@ kInit
v8::Value::NumberValue
V8_WARN_UNUSED_RESULT Maybe< double > NumberValue(Local< Context > context) const
v8::WeakCallbackType::kInternalFields
@ kInternalFields
v8::Isolate::DisallowJavascriptExecutionScope
Definition: v8.h:8558
v8::Isolate::DiscardThreadSpecificMetadata
void DiscardThreadSpecificMetadata()
v8::Unwinder::PCIsInV8
static bool PCIsInV8(size_t code_pages_length, const MemoryRange *code_pages, void *pc)
v8::Value::ToInteger
V8_WARN_UNUSED_RESULT MaybeLocal< Integer > ToInteger(Local< Context > context) const
v8::internal::kSmiMaxValue
const int kSmiMaxValue
Definition: v8-internal.h:151
v8::ArrayBufferCreationMode
ArrayBufferCreationMode
Definition: v8.h:5235
v8::Function::GetBoundFunction
Local< Value > GetBoundFunction() const
v8::BigInt::NewFromUnsigned
static Local< BigInt > NewFromUnsigned(Isolate *isolate, uint64_t value)
v8::String::ExternalOneByteStringResource::data
virtual const char * data() const =0
v8::SideEffectType::kHasSideEffectToReceiver
@ kHasSideEffectToReceiver
v8::NamedPropertyHandlerConfiguration::NamedPropertyHandlerConfiguration
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter=nullptr, GenericNamedPropertySetterCallback setter=nullptr, GenericNamedPropertyQueryCallback query=nullptr, GenericNamedPropertyDeleterCallback deleter=nullptr, GenericNamedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6890
v8::ResourceConstraints::max_old_generation_size_in_bytes
size_t max_old_generation_size_in_bytes() const
Definition: v8.h:7372
v8::ValueSerializer::WriteDouble
void WriteDouble(double value)
v8::Message::IsOpaque
bool IsOpaque() const
v8::Module::IsGraphAsync
bool IsGraphAsync() const
v8::String::Utf8Value::Utf8Value
Utf8Value(const Utf8Value &)=delete
v8::StackTrace::kExposeFramesAcrossSecurityOrigins
@ kExposeFramesAcrossSecurityOrigins
Definition: v8.h:2273
v8::BigIntObject
Definition: v8.h:6114
v8::Extension::name
const char * name() const
Definition: v8.h:7271
v8::StackFrame::GetScriptNameOrSourceURL
Local< String > GetScriptNameOrSourceURL() const
v8::Value::IsSymbolObject
bool IsSymbolObject() const
v8::ValueDeserializer::ReadRawBytes
V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void **data)
v8::Number::New
static Local< Number > New(Isolate *isolate, double value)
v8::Isolate::kLineOrParagraphSeparatorAsLineTerminator
@ kLineOrParagraphSeparatorAsLineTerminator
Definition: v8.h:8699
v8::Isolate::kForInInitializer
@ kForInInitializer
Definition: v8.h:8681
v8::Isolate::kSharedArrayBufferConstructed
@ kSharedArrayBufferConstructed
Definition: v8.h:8740
v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE
@ THROW_ON_FAILURE
Definition: v8.h:8560
v8::ArrayBuffer::Detach
void Detach()
v8::BigInt::NewFromWords
static MaybeLocal< BigInt > NewFromWords(Local< Context > context, int sign_bit, int word_count, const uint64_t *words)
v8::Context::IsCodeGenerationFromStringsAllowed
bool IsCodeGenerationFromStringsAllowed()
v8::HeapStatistics::peak_malloced_memory
size_t peak_malloced_memory()
Definition: v8.h:7910
v8::UnboundScript::GetSourceURL
Local< Value > GetSourceURL()
v8::PersistentBase::Get
V8_INLINE Local< T > Get(Isolate *isolate) const
Definition: v8.h:513
v8::HandleScope::CreateHandle
static internal::Address * CreateHandle(internal::Isolate *isolate, internal::Address value)
v8::ArrayBufferView::ByteLength
size_t ByteLength()
v8::Value::IsDate
bool IsDate() const
v8::MeasureMemoryDelegate::~MeasureMemoryDelegate
virtual ~MeasureMemoryDelegate()=default
v8::PropertyDescriptor::PropertyDescriptor
PropertyDescriptor(Local< Value > value)
v8::Isolate::kCollator
@ kCollator
Definition: v8.h:8712
v8::MaybeLocal::MaybeLocal
V8_INLINE MaybeLocal(Local< S > that)
Definition: v8.h:375
v8::TracedReferenceBase::GetSlotThreadSafe
const void * GetSlotThreadSafe() const
Definition: v8.h:883
v8::Date
Definition: v8.h:6078
v8::ModuleRequest::Cast
static V8_INLINE ModuleRequest * Cast(Data *data)
Definition: v8.h:11972
v8::Persistent::Persistent
V8_INLINE Persistent(Isolate *isolate, Local< S > that)
Definition: v8.h:679
v8::ScriptCompiler::kNoCacheBecauseScriptTooSmall
@ kNoCacheBecauseScriptTooSmall
Definition: v8.h:1993
v8::BigInt64Array::New
static Local< BigInt64Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::Null
V8_INLINE Local< Primitive > Null(Isolate *isolate)
Definition: v8.h:12341
v8::kGCCallbackScheduleIdleGarbageCollection
@ kGCCallbackScheduleIdleGarbageCollection
Definition: v8.h:7850
v8::Template
Definition: v8.h:6291
v8::operator==
V8_INLINE bool operator==(const v8::Local< U > &lhs, const TracedReferenceBase &rhs)
Definition: v8.h:11274
v8::ValueDeserializer::ReadDouble
V8_WARN_UNUSED_RESULT bool ReadDouble(double *value)
v8::ScriptCompiler::CompileUnboundScript
static V8_WARN_UNUSED_RESULT MaybeLocal< UnboundScript > CompileUnboundScript(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
v8::HeapSpaceStatistics::physical_space_size
size_t physical_space_size()
Definition: v8.h:7948
v8::SampleInfo::vm_state
StateTag vm_state
Definition: v8.h:2410
v8::BooleanObject::New
static Local< Value > New(Isolate *isolate, bool value)
v8::Promise
Definition: v8.h:4813
V8_DEPRECATED
#define V8_DEPRECATED(message)
Definition: v8config.h:417
v8::RegisterState::RegisterState
RegisterState()
v8::Isolate::kHtmlCommentInExternalScript
@ kHtmlCommentInExternalScript
Definition: v8.h:8678
v8::PrimitiveArray::Set
void Set(Isolate *isolate, int index, Local< Primitive > item)
v8::PropertyCallbackInfo::kHolderIndex
static const int kHolderIndex
Definition: v8.h:4686
v8::RegExp::kSticky
@ kSticky
Definition: v8.h:6192
v8::ScriptOrModule::GetHostDefinedOptions
Local< PrimitiveArray > GetHostDefinedOptions()
v8::Isolate::AtomicsWaitEvent::kTimedOut
@ kTimedOut
v8::FunctionTemplate::InstanceTemplate
Local< ObjectTemplate > InstanceTemplate()
v8::Isolate::kDefineGetterOrSetterWouldThrow
@ kDefineGetterOrSetterWouldThrow
Definition: v8.h:8692
v8::JitCodeEvent::line_info_t::position_type
PositionType position_type
Definition: v8.h:8051
v8::Isolate::SafeForTerminationScope::operator=
SafeForTerminationScope & operator=(const SafeForTerminationScope &)=delete
v8::EmbedderHeapTracer::IsTracingDone
virtual bool IsTracingDone()=0
v8::AccessorSignature::New
static Local< AccessorSignature > New(Isolate *isolate, Local< FunctionTemplate > receiver=Local< FunctionTemplate >())
v8::Maybe::IsNothing
V8_INLINE bool IsNothing() const
Definition: v8.h:10273
v8::Symbol
Definition: v8.h:3605
v8::Uint8ClampedArray::Cast
static V8_INLINE Uint8ClampedArray * Cast(Value *obj)
Definition: v8.h:12252
v8::String::TWO_BYTE_ENCODING
@ TWO_BYTE_ENCODING
Definition: v8.h:3170
v8::AccessorSignature::Cast
static V8_INLINE AccessorSignature * Cast(Data *data)
Definition: v8.h:11740
v8::Function::GetScriptLineNumber
int GetScriptLineNumber() const
v8::Map::Delete
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, Local< Value > key)
v8::String::ExternalStringResourceBase::Unlock
virtual void Unlock() const
Definition: v8.h:3302
v8::Float32Array::New
static Local< Float32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::PropertyCallbackInfo::Holder
V8_INLINE Local< Object > Holder() const
Definition: v8.h:12311
v8::Message::GetWasmFunctionIndex
int GetWasmFunctionIndex() const
v8::Isolate::operator new
void * operator new(size_t size)=delete
v8::String::Utf8Value::length
int length() const
Definition: v8.h:3545
v8::ResourceConstraints::initial_young_generation_size_in_bytes
size_t initial_young_generation_size_in_bytes() const
Definition: v8.h:7398
v8::ObjectTemplate::Cast
static V8_INLINE ObjectTemplate * Cast(Data *data)
Definition: v8.h:11726
v8::Isolate::kRegExpPrototypeToString
@ kRegExpPrototypeToString
Definition: v8.h:8670
v8::Platform
Definition: v8-platform.h:522
v8::Exception::WasmRuntimeError
static Local< Value > WasmRuntimeError(Local< String > message)
v8::HeapStatistics::external_memory
size_t external_memory()
Definition: v8.h:7909
v8::ScriptOrigin::HostDefinedOptions
V8_INLINE Local< PrimitiveArray > HostDefinedOptions() const
Definition: v8.h:11655
v8::Isolate::kStrictMode
@ kStrictMode
Definition: v8.h:8667
v8::Integer::NewFromUnsigned
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
v8::operator!=
V8_INLINE bool operator!=(const TracedReferenceBase &lhs, const TracedReferenceBase &rhs)
Definition: v8.h:11279
v8::internal::Internals::CheckInitialized
static V8_INLINE void CheckInitialized(v8::Isolate *isolate)
Definition: v8-internal.h:257
v8::Local::operator==
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:238
v8::Isolate::kErrorPrepareStackTrace
@ kErrorPrepareStackTrace
Definition: v8.h:8702
v8::Value::IsUndefined
V8_INLINE bool IsUndefined() const
Definition: v8.h:11862
v8::StackFrame
Definition: v8.h:2303
v8::PERFORMANCE_LOAD
@ PERFORMANCE_LOAD
Definition: v8.h:8101
v8::SnapshotCreator::SnapshotCreator
SnapshotCreator(const SnapshotCreator &)=delete
v8::Isolate::Dispose
void Dispose()
v8::Function::New
static MaybeLocal< Function > New(Local< Context > context, FunctionCallback callback, Local< Value > data=Local< Value >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect)
v8::BackingStore::IsShared
bool IsShared() const
v8::ScriptCompiler::kEagerCompile
@ kEagerCompile
Definition: v8.h:1979
v8::TracedReference::operator=
V8_INLINE TracedReference & operator=(const TracedReference &rhs)
Definition: v8.h:11384
v8::Isolate::SuppressMicrotaskExecutionScope
Definition: v8.h:8605
v8::BooleanObject::Cast
static V8_INLINE BooleanObject * Cast(Value *obj)
Definition: v8.h:12066
v8::Isolate::AllowJavascriptExecutionScope
Definition: v8.h:8583
v8::PropertyDescriptor::get
Local< Value > get() const
v8::Set::AsArray
Local< Array > AsArray() const
v8::Extension::auto_enable
bool auto_enable()
Definition: v8.h:7279
v8::Function::GetDebugName
Local< Value > GetDebugName() const
v8::SharedArrayBuffer::Contents::Deleter
DeleterCallback Deleter() const
Definition: v8.h:5910
v8::MicrotaskQueue::MicrotaskQueue
MicrotaskQueue(const MicrotaskQueue &)=delete
v8::IndexedPropertyHandlerConfiguration::query
IndexedPropertyQueryCallback query
Definition: v8.h:7000
v8::SharedMemoryStatistics
Definition: v8.h:7873
v8::HeapSpaceStatistics
Definition: v8.h:7941
v8::Float64Array
Definition: v8.h:5812
v8::internal::kExternalStringResourceTag
@ kExternalStringResourceTag
Definition: v8-internal.h:131
v8::PromiseRejectMessage
Definition: v8.h:7597
v8::TracedGlobalTrait
Definition: v8.h:831
v8::Isolate::ClearKeptObjects
void ClearKeptObjects()
v8::Isolate::AllowJavascriptExecutionScope::AllowJavascriptExecutionScope
AllowJavascriptExecutionScope(Isolate *isolate)
v8::TracedGlobal::operator=
TracedGlobal< T > & operator=(const TracedGlobal< S > &rhs)
Definition: v8.h:11316
v8::Isolate::IncreaseHeapLimitForDebugging
void IncreaseHeapLimitForDebugging()
v8::Promise::HasHandler
bool HasHandler()
v8::Persistent::Persistent
V8_INLINE Persistent(const Persistent &that)
Definition: v8.h:699
v8::PropertyCallbackInfo::kReturnValueDefaultValueIndex
static const int kReturnValueDefaultValueIndex
Definition: v8.h:4688
v8::Value::IsStringObject
bool IsStringObject() const
v8::Isolate::GetEmbeddedCodeRange
void GetEmbeddedCodeRange(const void **start, size_t *length_in_bytes)
v8::Script::Compile
static V8_WARN_UNUSED_RESULT MaybeLocal< Script > Compile(Local< Context > context, Local< String > source, ScriptOrigin *origin=nullptr)
v8::AccessControl
AccessControl
Definition: v8.h:3850
v8::String::Utf8Value::operator*
char * operator*()
Definition: v8.h:3543
v8::MemoryRange::length_in_bytes
size_t length_in_bytes
Definition: v8.h:2418
v8::Isolate::UseCounterFeature
UseCounterFeature
Definition: v8.h:8657
v8::NewStringType
NewStringType
Definition: v8.h:3146
v8::Object::New
static Local< Object > New(Isolate *isolate, Local< Value > prototype_or_null, Local< Name > *names, Local< Value > *values, size_t length)
v8::TryCatch::StackTrace
V8_WARN_UNUSED_RESULT MaybeLocal< Value > StackTrace(Local< Context > context) const
v8::Isolate::TimeZoneDetection::kSkip
@ kSkip
v8::ObjectTemplate::SetCallAsFunctionHandler
void SetCallAsFunctionHandler(FunctionCallback callback, Local< Value > data=Local< Value >())
v8::AccessorSignature
Definition: v8.h:7239
v8::RegExp::Flags
Flags
Definition: v8.h:6187
v8::HeapStatistics::used_global_handles_size
size_t used_global_handles_size()
Definition: v8.h:7905
v8::Isolate::kStringNormalize
@ kStringNormalize
Definition: v8.h:8733
v8::EmbedderHeapTracer::RegisterV8References
virtual void RegisterV8References(const std::vector< std::pair< void *, void * > > &embedder_fields)=0
v8::PropertyDescriptor::has_configurable
bool has_configurable() const
v8::Value::ToDetailString
V8_WARN_UNUSED_RESULT MaybeLocal< String > ToDetailString(Local< Context > context) const
v8::ObjectTemplate::SetCodeLike
void SetCodeLike()
v8::SharedArrayBuffer::data
void * data
Definition: v8.h:5953
v8::Value::IsObject
bool IsObject() const
v8::BigInt
Definition: v8.h:3758
v8::Isolate::SetEmbedderHeapTracer
void SetEmbedderHeapTracer(EmbedderHeapTracer *tracer)
v8::WasmStreaming::SetClient
void SetClient(std::shared_ptr< Client > client)
v8::Object::SetLazyDataProperty
V8_WARN_UNUSED_RESULT Maybe< bool > SetLazyDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
v8::Maybe::ToChecked
V8_INLINE T ToChecked() const
Definition: v8.h:10279
v8::DataView
Definition: v8.h:5860
v8::Isolate::kDateToLocaleDateString
@ kDateToLocaleDateString
Definition: v8.h:8725
v8::NamedPropertyHandlerConfiguration::deleter
GenericNamedPropertyDeleterCallback deleter
Definition: v8.h:6931
v8::Context::New
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=nullptr, MaybeLocal< ObjectTemplate > global_template=MaybeLocal< ObjectTemplate >(), MaybeLocal< Value > global_object=MaybeLocal< Value >(), DeserializeInternalFieldsCallback internal_fields_deserializer=DeserializeInternalFieldsCallback(), MicrotaskQueue *microtask_queue=nullptr)
v8::HeapStatistics::total_physical_size
size_t total_physical_size()
Definition: v8.h:7902
v8::Promise::MarkAsHandled
void MarkAsHandled()
v8::Isolate::RestoreOriginalHeapLimit
void RestoreOriginalHeapLimit()
v8::ValueDeserializer::ReadUint64
V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t *value)
v8::Isolate::kInvalidatedPromiseHookProtector
@ kInvalidatedPromiseHookProtector
Definition: v8.h:8755
v8::DeserializeInternalFieldsCallback::data
void * data
Definition: v8.h:8377
v8::Isolate::GetCurrentContext
Local< Context > GetCurrentContext()
v8::FunctionTemplate::NewWithCache
static Local< FunctionTemplate > NewWithCache(Isolate *isolate, FunctionCallback callback, Local< Private > cache_property, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, SideEffectType side_effect_type=SideEffectType::kHasSideEffect)
v8::TypedArray::Cast
static V8_INLINE TypedArray * Cast(Value *obj)
Definition: v8.h:12167
v8::EmbedderHeapTracer::TraceEpilogue
virtual void TraceEpilogue(TraceSummary *trace_summary)
Definition: v8.h:8264
v8::Isolate::DisableMemorySavingsMode
void DisableMemorySavingsMode()
v8::Extension
Definition: v8.h:7259
v8::Map::Clear
void Clear()
v8::WasmModuleObjectBuilderStreaming::~WasmModuleObjectBuilderStreaming
~WasmModuleObjectBuilderStreaming()=default
v8::TypedArray
Definition: v8.h:5649
v8::SharedArrayBuffer::Externalize
Contents Externalize()
v8::SealHandleScope
Definition: v8.h:1292
v8::Isolate::SetGetExternallyAllocatedMemoryInBytesCallback
void SetGetExternallyAllocatedMemoryInBytesCallback(GetExternallyAllocatedMemoryInBytesCallback callback)
v8::ValueSerializer::ValueSerializer
ValueSerializer(const ValueSerializer &)=delete
v8::Float64Array::Cast
static V8_INLINE Float64Array * Cast(Value *obj)
Definition: v8.h:12231
v8::TracedReferenceBase
Definition: v8.h:833
v8::FunctionCallbackInfo::values_
internal::Address * values_
Definition: v8.h:4581
v8::Object::GetRealNamedPropertyAttributes
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetRealNamedPropertyAttributes(Local< Context > context, Local< Name > key)
v8::JitCodeEvent::wasm_source_info_t::filename_size
size_t filename_size
Definition: v8.h:8058
v8::DataView::New
static Local< DataView > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::Isolate::SetWasmStreamingCallback
void SetWasmStreamingCallback(WasmStreamingCallback callback)
v8::Isolate::GetHeapSpaceStatistics
bool GetHeapSpaceStatistics(HeapSpaceStatistics *space_statistics, size_t index)
v8::IndexedPropertyHandlerConfiguration::enumerator
IndexedPropertyEnumeratorCallback enumerator
Definition: v8.h:7002
v8::Integer
Definition: v8.h:3715
v8::ArrayBuffer::Allocator::AllocationMode::kNormal
@ kNormal
v8::Isolate::LowMemoryNotification
void LowMemoryNotification()
v8::Isolate::MessageErrorLevel
MessageErrorLevel
Definition: v8.h:8777
v8::FunctionCallbackInfo::FunctionCallbackInfo
V8_INLINE FunctionCallbackInfo(internal::Address *implicit_args, internal::Address *values, int length)
Definition: v8.h:11546
v8::CompiledWasmModule
Definition: v8.h:5037
v8::Isolate::kUseAsm
@ kUseAsm
Definition: v8.h:8658
v8::False
V8_INLINE Local< Boolean > False(Isolate *isolate)
Definition: v8.h:12359
v8::Isolate::kArrayPrototypeConstructorModified
@ kArrayPrototypeConstructorModified
Definition: v8.h:8684
v8::Context::Exit
void Exit()
v8::Value::IsString
V8_INLINE bool IsString() const
Definition: v8.h:11915
v8::Object::GetAlignedPointerFromInternalField
static V8_INLINE void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8.h:4168
v8::ScriptType::kModule
@ kModule
v8::ArrayBufferView::HasBuffer
bool HasBuffer() const
v8::WasmMemoryObject::Cast
static V8_INLINE WasmMemoryObject * Cast(Value *obj)
Definition: v8.h:12129
v8::ResourceConstraints
Definition: v8.h:7317
v8::PromiseRejectEvent
PromiseRejectEvent
Definition: v8.h:7590
v8::internal::Internals::kStringResourceOffset
static const int kStringResourceOffset
Definition: v8-internal.h:185
v8::Isolate::kInvalidatedRegExpSpeciesLookupChainProtector
@ kInvalidatedRegExpSpeciesLookupChainProtector
Definition: v8.h:8759
v8::FunctionTemplate::ReadOnlyPrototype
void ReadOnlyPrototype()
v8::BigInt::New
static Local< BigInt > New(Isolate *isolate, int64_t value)
v8::Isolate::CreateParams::external_references
const intptr_t * external_references
Definition: v8.h:8508
v8::RegisterState::RegisterState
RegisterState(const RegisterState &other)
v8::CppHeap
Definition: v8-cppgc.h:85
v8::Isolate::EnableMemorySavingsMode
void EnableMemorySavingsMode()
v8::Uint32Array::New
static Local< Uint32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::ArrayBuffer::Allocator
Definition: v8.h:5342
v8::Signature::New
static Local< Signature > New(Isolate *isolate, Local< FunctionTemplate > receiver=Local< FunctionTemplate >())
v8::ArrayBuffer::New
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
v8::Isolate::CopyCodePages
size_t CopyCodePages(size_t capacity, MemoryRange *code_pages_out)
v8::kGCTypeMarkSweepCompact
@ kGCTypeMarkSweepCompact
Definition: v8.h:7822
v8::kPromiseRejectAfterResolved
@ kPromiseRejectAfterResolved
Definition: v8.h:7593
v8::String::kMaxLength
static constexpr int kMaxLength
Definition: v8.h:3165
v8::PropertyDescriptor::get_private
PrivateData * get_private() const
Definition: v8.h:4962
v8::MeasureMemoryMode
MeasureMemoryMode
Definition: v8.h:8386
v8::Isolate::kAttemptOverrideReadOnlyOnPrototypeSloppy
@ kAttemptOverrideReadOnlyOnPrototypeSloppy
Definition: v8.h:8727
v8::String::Concat
static Local< String > Concat(Isolate *isolate, Local< String > left, Local< String > right)
v8::Isolate::SetPromiseRejectCallback
void SetPromiseRejectCallback(PromiseRejectCallback callback)
v8::Value::SameValue
bool SameValue(Local< Value > that) const
v8::ResourceConstraints::set_stack_limit
void set_stack_limit(uint32_t *value)
Definition: v8.h:7356
v8::String::Value::operator=
void operator=(const Value &)=delete
v8::KeyCollectionMode
KeyCollectionMode
Definition: v8.h:3892
v8::internal::Internals::kEmbedderDataArrayHeaderSize
static const int kEmbedderDataArrayHeaderSize
Definition: v8-internal.h:191
v8::RegExp::kIgnoreCase
@ kIgnoreCase
Definition: v8.h:6190
v8::String::NewExternalTwoByte
static V8_WARN_UNUSED_RESULT MaybeLocal< String > NewExternalTwoByte(Isolate *isolate, ExternalStringResource *resource)
v8::Value::IsArray
bool IsArray() const
v8::Object::InternalFieldCount
static V8_INLINE int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8.h:4143
v8::Message::GetLineNumber
V8_WARN_UNUSED_RESULT Maybe< int > GetLineNumber(Local< Context > context) const
v8::SharedMemoryStatistics::SharedMemoryStatistics
SharedMemoryStatistics()
v8::Isolate::kArrayInstanceProtoModified
@ kArrayInstanceProtoModified
Definition: v8.h:8685
v8::Isolate::TerminateExecution
void TerminateExecution()
v8::StackTrace::kColumnOffset
@ kColumnOffset
Definition: v8.h:2266
v8::Value::TypeOf
Local< String > TypeOf(Isolate *)
v8::ALL_PROPERTIES
@ ALL_PROPERTIES
Definition: v8.h:3861
v8::internal::Internals::kNumIsolateDataSlots
static const uint32_t kNumIsolateDataSlots
Definition: v8-internal.h:202
v8::V8::InitializeExternalStartupData
static void InitializeExternalStartupData(const char *directory_path)
v8::Object::GetOwnPropertyNames
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
v8::V8::Local
friend class Local
Definition: v8.h:10134
v8::Private
Definition: v8.h:3664
v8::Extension::Extension
Extension(const char *name, const char *source=nullptr, int dep_count=0, const char **deps=nullptr, int source_length=-1)
v8::True
V8_INLINE Local< Boolean > True(Isolate *isolate)
Definition: v8.h:12350
v8::Context::SetContinuationPreservedEmbedderData
void SetContinuationPreservedEmbedderData(Local< Value > context)
v8::Isolate::DisallowJavascriptExecutionScope::operator=
DisallowJavascriptExecutionScope & operator=(const DisallowJavascriptExecutionScope &)=delete
v8::Object::GetAlignedPointerFromInternalField
V8_INLINE void * GetAlignedPointerFromInternalField(int index)
Definition: v8.h:11775
v8::ResourceConstraints::code_range_size_in_bytes
size_t code_range_size_in_bytes() const
Definition: v8.h:7362
v8::Isolate::SetWasmSimdEnabledCallback
void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback)
v8::HandleScope::HandleScope
V8_INLINE HandleScope()=default
v8::Module::kInstantiated
@ kInstantiated
Definition: v8.h:1597
v8::Object::Set
V8_WARN_UNUSED_RESULT Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
v8::Isolate::CreateParams::CreateParams
CreateParams()
v8::FunctionTemplate::NewRemoteInstance
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewRemoteInstance()
v8::Isolate::CreateParams::embedder_wrapper_object_index
int embedder_wrapper_object_index
Definition: v8.h:8527
v8::Isolate::kInvalidatedPromiseResolveLookupChainProtector
@ kInvalidatedPromiseResolveLookupChainProtector
Definition: v8.h:8756
v8::FunctionCallbackInfo::NewTarget
V8_INLINE Local< Value > NewTarget() const
Definition: v8.h:11573
v8::ObjectTemplate::NewInstance
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance(Local< Context > context)
v8::ObjectTemplate::SetAccessCheckCallback
void SetAccessCheckCallback(AccessCheckCallback callback, Local< Value > data=Local< Value >())
v8::Value::IsInt8Array
bool IsInt8Array() const
v8::MeasureMemoryMode::kSummary
@ kSummary
v8::NamedPropertyHandlerConfiguration::enumerator
GenericNamedPropertyEnumeratorCallback enumerator
Definition: v8.h:6932
v8::RegExp::NewWithBacktrackLimit
static V8_WARN_UNUSED_RESULT MaybeLocal< RegExp > NewWithBacktrackLimit(Local< Context > context, Local< String > pattern, Flags flags, uint32_t backtrack_limit)
v8::Module::callback
ResolveCallback callback
Definition: v8.h:1670
v8::ArrayBuffer::Externalize
void Externalize(const std::shared_ptr< BackingStore > &backing_store)
v8::RegisterState::operator=
RegisterState & operator=(const RegisterState &other)
v8::Uint16Array
Definition: v8.h:5727
v8::Isolate::kWasmExceptionHandling
@ kWasmExceptionHandling
Definition: v8.h:8769
v8::HeapStatistics
Definition: v8.h:7897
v8::Int32Array
Definition: v8.h:5778
v8::TracedReference::TracedReference
V8_INLINE TracedReference(const TracedReference< S > &other)
Definition: v8.h:1145
v8::BigInt64Array
Definition: v8.h:5828
v8::PROHIBITS_OVERWRITING
@ PROHIBITS_OVERWRITING
Definition: v8.h:3854
v8::Object::GetConstructorName
Local< String > GetConstructorName()
v8::Boolean
Definition: v8.h:3109
v8::Isolate::GetDataFromSnapshotOnce
MaybeLocal< T > GetDataFromSnapshotOnce(size_t index)
Definition: v8.h:12386
v8::Isolate::kInvalidatedTypedArraySpeciesLookupChainProtector
@ kInvalidatedTypedArraySpeciesLookupChainProtector
Definition: v8.h:8763
v8::ScriptOrigin::ResourceName
V8_INLINE Local< Value > ResourceName() const
Definition: v8.h:11653
v8::Module::GetException
Local< Value > GetException() const
v8::IndexFilter::kIncludeIndices
@ kIncludeIndices
v8::V8::InitializeExternalStartupDataFromFile
static void InitializeExternalStartupDataFromFile(const char *snapshot_blob)
v8::NamedPropertyHandlerConfiguration::NamedPropertyHandlerConfiguration
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, GenericNamedPropertyQueryCallback query, GenericNamedPropertyDeleterCallback deleter, GenericNamedPropertyEnumeratorCallback enumerator, GenericNamedPropertyDefinerCallback definer, GenericNamedPropertyDescriptorCallback descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6870
v8::internal::Internals::ReadTaggedPointerField
static V8_INLINE internal::Address ReadTaggedPointerField(internal::Address heap_object_ptr, int offset)
Definition: v8-internal.h:357
v8::Object::GetRealNamedProperty
V8_WARN_UNUSED_RESULT MaybeLocal< Value > GetRealNamedProperty(Local< Context > context, Local< Name > key)
v8::OwnedBuffer::OwnedBuffer
OwnedBuffer(std::unique_ptr< const uint8_t[]> buffer, size_t size)
Definition: v8.h:5030
v8::Isolate::kLegacyFunctionDeclaration
@ kLegacyFunctionDeclaration
Definition: v8.h:8687
v8::Proxy
Definition: v8.h:4975
v8::Object::SetIntegrityLevel
Maybe< bool > SetIntegrityLevel(Local< Context > context, IntegrityLevel level)
v8::V8::PersistentBase
friend class PersistentBase
Definition: v8.h:10147
v8::Float32Array
Definition: v8.h:5795
v8::Int16Array::New
static Local< Int16Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
v8::BasicTracedReference::operator*
T * operator*() const
Definition: v8.h:930
v8::FunctionTemplate::SetCallHandler
void SetCallHandler(FunctionCallback callback, Local< Value > data=Local< Value >(), SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const CFunction *c_function=nullptr)
v8::Isolate::AddMessageListener
bool AddMessageListener(MessageCallback that, Local< Value > data=Local< Value >())
v8::Global::Pass
Global Pass()
Definition: v8.h:806
v8::Isolate::GetHeapCodeAndMetadataStatistics
bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics *object_statistics)
v8::DEFAULT
@ DEFAULT
Definition: v8.h:3851
v8::Isolate::InContext
bool InContext()
v8::Isolate::DisallowJavascriptExecutionScope::DisallowJavascriptExecutionScope
DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope &)=delete
v8::PropertyCallbackInfo::kDataIndex
static const int kDataIndex
Definition: v8.h:4690
v8::Isolate::kErrorStackTraceLimit
@ kErrorStackTraceLimit
Definition: v8.h:8703
v8::Uint32::Value
uint32_t Value() const
v8::NamedPropertyHandlerConfiguration::data
Local< Value > data
Definition: v8.h:6935
v8::Function::NewInstanceWithSideEffectType
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstanceWithSideEffectType(Local< Context > context, int argc, Local< Value > argv[], SideEffectType side_effect_type=SideEffectType::kHasSideEffect) const
v8::HeapCodeStatistics::bytecode_and_metadata_size
size_t bytecode_and_metadata_size()
Definition: v8.h:7982
v8::String::CanMakeExternal
bool CanMakeExternal()
v8::PropertyDescriptor::set_configurable
void set_configurable(bool configurable)
v8::ScriptCompiler::StreamedSource::operator=
StreamedSource & operator=(const StreamedSource &)=delete
v8::ScriptCompiler::StartStreamingScript
static ScriptStreamingTask * StartStreamingScript(Isolate *isolate, StreamedSource *source, CompileOptions options=kNoCompileOptions)
v8::ONLY_WRITABLE
@ ONLY_WRITABLE
Definition: v8.h:3862
v8::Promise::Cast
static V8_INLINE Promise * Cast(Value *obj)
Definition: v8.h:12114
v8::V8::BasicTracedReference
friend class BasicTracedReference
Definition: v8.h:10131
v8::Local::operator!=
V8_INLINE bool operator!=(const Persistent< S > &that) const
Definition: v8.h:270
v8::Signature
Definition: v8.h:7220
v8::ScriptCompiler::StreamedSource::~StreamedSource
~StreamedSource()
v8::SharedArrayBuffer::Contents::Data
void * Data() const
Definition: v8.h:5908
v8::ALL_CAN_WRITE
@ ALL_CAN_WRITE
Definition: v8.h:3853
v8::metrics::Recorder
Definition: v8-metrics.h:141
v8::Maybe< void >::IsNothing
V8_INLINE bool IsNothing() const
Definition: v8.h:10351
v8::Int16Array::New
static Local< Int16Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::Isolate::SetCounterFunction
void SetCounterFunction(CounterLookupCallback)
v8::Object::CreateDataProperty
V8_WARN_UNUSED_RESULT Maybe< bool > CreateDataProperty(Local< Context > context, uint32_t index, Local< Value > value)
v8::RegisterState::lr
void * lr
Definition: v8.h:2402
v8::Location
Definition: v8.h:1525
v8::FunctionTemplate::Inherit
void Inherit(Local< FunctionTemplate > parent)
v8::V8::Global
friend class Global
Definition: v8.h:10133
v8::Isolate::Enter
void Enter()
v8::Value::IsArgumentsObject
bool IsArgumentsObject() const
v8::Isolate::GetIncumbentContext
Local< Context > GetIncumbentContext()
v8::Map::New
static Local< Map > New(Isolate *isolate)
v8::IndexedPropertyHandlerConfiguration::descriptor
IndexedPropertyDescriptorCallback descriptor
Definition: v8.h:7004
v8::Set::Has
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, Local< Value > key)
v8::Locker::Locker
V8_INLINE Locker(Isolate *isolate)
Definition: v8.h:10949
v8::Object::CallAsFunction
V8_WARN_UNUSED_RESULT MaybeLocal< Value > CallAsFunction(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
v8::Message::GetEndPosition
int GetEndPosition() const
v8::SealHandleScope::operator=
void operator=(const SealHandleScope &)=delete
v8::Isolate::MeasureMemory
MaybeLocal< Promise > MeasureMemory(Local< Context > context, MeasureMemoryMode mode)
v8::Object::SetPrivate
Maybe< bool > SetPrivate(Local< Context > context, Local< Private > key, Local< Value > value)
v8::ScriptCompiler::CachedData::BufferPolicy
BufferPolicy
Definition: v8.h:1810
v8::Function::GetScriptColumnNumber
int GetScriptColumnNumber() const
v8::Object::HasRealIndexedProperty
V8_WARN_UNUSED_RESULT Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
v8::Global::Global
V8_INLINE Global(Isolate *isolate, Local< S > that)
Definition: v8.h:774
v8::DontDelete
@ DontDelete
Definition: v8.h:3821
v8::SymbolObject::ValueOf
Local< Symbol > ValueOf() const
v8::Context::SetAbortScriptExecution
void SetAbortScriptExecution(AbortScriptExecutionCallback callback)
v8::Context::Scope::Scope
V8_INLINE Scope(Local< Context > context)
Definition: v8.h:10798
v8::HeapStatistics::used_heap_size
size_t used_heap_size()
Definition: v8.h:7906
v8::Isolate::NumberOfPhantomHandleResetsSinceLastCall
size_t NumberOfPhantomHandleResetsSinceLastCall()
v8::WeakCallbackType::kParameter
@ kParameter
v8::AccessType
AccessType
Definition: v8.h:6599
v8::TryCatch::ReThrow
Local< Value > ReThrow()
v8::MicrotaskQueue::PerformCheckpoint
virtual void PerformCheckpoint(Isolate *isolate)=0
v8::internal::Internals::kOddballType
static const int kOddballType
Definition: v8-internal.h:237
v8::ScriptCompiler::kNoCacheBecauseExtensionModule
@ kNoCacheBecauseExtensionModule
Definition: v8.h:1996
v8::ScriptCompiler::CompileModule
static V8_WARN_UNUSED_RESULT MaybeLocal< Module > CompileModule(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason)
v8::ObjectTemplate
Definition: v8.h:7016
v8::MemorySpan::data
constexpr T * data() const
Definition: v8.h:5015
v8::PromiseRejectMessage::PromiseRejectMessage
PromiseRejectMessage(Local< Promise > promise, PromiseRejectEvent event, Local< Value > value)
Definition: v8.h:7599
v8::ValueSerializer::Delegate::GetSharedArrayBufferId
virtual Maybe< uint32_t > GetSharedArrayBufferId(Isolate *isolate, Local< SharedArrayBuffer > shared_array_buffer)
v8::Value::IsUint8Array
bool IsUint8Array() const
v8::internal::PointerCompressionIsEnabled
constexpr bool PointerCompressionIsEnabled()
Definition: v8-internal.h:109
v8::ScriptOrigin::ResourceLineOffset
V8_INLINE Local< Integer > ResourceLineOffset() const
Definition: v8.h:11659
v8::ScriptCompiler::CachedData::CachedData
CachedData()
Definition: v8.h:1815
v8::SnapshotCreator::SetDefaultContext
void SetDefaultContext(Local< Context > context, SerializeInternalFieldsCallback callback=SerializeInternalFieldsCallback())
v8::Maybe< void >::operator!=
V8_INLINE bool operator!=(const Maybe &other) const
Definition: v8.h:10358
v8::Exception::RangeError
static Local< Value > RangeError(Local< String > message)
v8::Map::Cast
static V8_INLINE Map * Cast(Value *obj)
Definition: v8.h:12098
v8::Isolate::RemoveGCEpilogueCallback
void RemoveGCEpilogueCallback(GCCallback callback)
v8::String::Value::operator*
uint16_t * operator*()
Definition: v8.h:3566
v8::Float32Array::Cast
static V8_INLINE Float32Array * Cast(Value *obj)
Definition: v8.h:12223
v8::WeakCallbackType::kFinalizer
@ kFinalizer
v8::Value::IsWasmModuleObject
bool IsWasmModuleObject() const
V8_INTRINSICS_LIST
#define V8_INTRINSICS_LIST(F)
Definition: v8.h:6268
v8::ScriptCompiler::StreamedSource::encoding
Encoding encoding
Definition: v8.h:1944
v8::EmbedderHeapTracer::TraceSummary::time
double time
Definition: v8.h:8195
v8::PersistentBase::PersistentBase
PersistentBase(const PersistentBase &other)=delete
v8::MicrotasksScope::Type
Type
Definition: v8.h:7723
v8::ScriptCompiler::CachedData::CachedData
CachedData(const CachedData &)=delete
v8::SampleInfo::external_callback_entry
void * external_callback_entry
Definition: v8.h:2411
v8::ExtensionConfiguration::ExtensionConfiguration
ExtensionConfiguration()
Definition: v8.h:10545
v8::Global::~Global
V8_INLINE ~Global()
Definition: v8.h:795
v8::FunctionTemplate::SetPrototypeProviderTemplate
void SetPrototypeProviderTemplate(Local< FunctionTemplate > prototype_provider)
v8::PropertyDescriptor::PropertyDescriptor
PropertyDescriptor(Local< Value > value, bool writable)
v8::Int32
Definition: v8.h:3731
v8::Isolate::AtomicsWaitWakeHandle
Definition: v8.h:9195
v8::External::Value
void * Value() const
v8::Isolate::kVarRedeclaredCatchBinding
@ kVarRedeclaredCatchBinding
Definition: v8.h:8765
v8::Message::GetIsolate
Isolate * GetIsolate() const
v8::UnboundScript::GetSourceMappingURL
Local< Value > GetSourceMappingURL()
v8::JitCodeEvent::line_info_t::offset
size_t offset
Definition: v8.h:8047
v8::Object::GetIsolate
Isolate * GetIsolate()
v8::Isolate::kMinCodePagesBufferSize
static constexpr size_t kMinCodePagesBufferSize
Definition: v8.h:9629
v8::WasmStreaming::Abort
void Abort(MaybeLocal< Value > exception)
v8::Module
Definition: v8.h:1585
v8::TracedReference::TracedReference
V8_INLINE TracedReference(const TracedReference &other)
Definition: v8.h:1135
v8::HeapObjectStatistics::object_size
size_t object_size()
Definition: v8.h:7967
v8::Local::operator==
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:246
v8::TryCatch::operator=
void operator=(const TryCatch &)=delete
v8::IDLE
@ IDLE
Definition: v8.h:2383
v8::HeapObjectStatistics::HeapObjectStatistics
HeapObjectStatistics()
v8::HeapSpaceStatistics::HeapSpaceStatistics
HeapSpaceStatistics()
v8::Object::InternalFieldCount
static V8_INLINE int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8.h:4149
v8::String::ExternalStringResource::data
virtual const uint16_t * data() const =0
v8::ValueDeserializer
Definition: v8.h:2583
v8::Value::IsFloat64Array
bool IsFloat64Array() const
v8::Exception::CreateMessage
static Local< Message > CreateMessage(Isolate *isolate, Local< Value > exception)
v8::RegExp::Cast
static V8_INLINE RegExp * Cast(Value *obj)
Definition: v8.h:12074
v8::String::WriteOneByte
int WriteOneByte(Isolate *isolate, uint8_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
v8::Isolate::CreateParams::~CreateParams
~CreateParams()
v8::WasmStreaming::SetUrl
void SetUrl(const char *url, size_t length)
v8::Symbol::GetSplit
static Local< Symbol > GetSplit(Isolate *isolate)
v8::Isolate::GetHeapStatistics
void GetHeapStatistics(HeapStatistics *heap_statistics)
v8::EmbedderHeapTracer::AdvanceTracing
virtual bool AdvanceTracing(double deadline_in_ms)=0
v8::Object::SetPrototype
V8_WARN_UNUSED_RESULT Maybe< bool > SetPrototype(Local< Context > context, Local< Value > prototype)
v8::External
Definition: v8.h:6259
v8::Isolate::SetUseCounterCallback
void SetUseCounterCallback(UseCounterCallback callback)
v8::Isolate::AtomicsWaitEvent::kNotEqual
@ kNotEqual
v8::Isolate::kHtmlComment
@ kHtmlComment
Definition: v8.h:8679
v8::Value::IsTypedArray
bool IsTypedArray() const
v8::ArrayBufferView
Definition: v8.h:5600
V8_WARN_UNUSED_RESULT
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:454
v8::Unlocker
Definition: v8.h:10929
v8::ScriptCompiler::kConsumeCodeCache
@ kConsumeCodeCache
Definition: v8.h:1978
v8::Isolate::kMessageLog
@ kMessageLog
Definition: v8.h:8778
v8::Isolate::kRegExpMatchAllWithNonGlobalRegExp
@ kRegExpMatchAllWithNonGlobalRegExp
Definition: v8.h:8736
v8::PromiseRejectMessage::GetPromise
V8_INLINE Local< Promise > GetPromise() const
Definition: v8.h:7603
v8::EmbedderHeapTracer::EnterFinalPause
virtual void EnterFinalPause(EmbedderStackState stack_state)=0
v8::Isolate::AutomaticallyRestoreInitialHeapLimit
void AutomaticallyRestoreInitialHeapLimit(double threshold_percent=0.5)
v8::HeapStatistics::HeapStatistics
HeapStatistics()
v8::Isolate::RequestInterrupt
void RequestInterrupt(InterruptCallback callback, void *data)
v8::TracedReferenceBase::IsEmpty
bool IsEmpty() const
Definition: v8.h:839
v8::Isolate::kInvalidatedStringLengthOverflowLookupChainProtector
@ kInvalidatedStringLengthOverflowLookupChainProtector
Definition: v8.h:8762
v8::Context::Scope::~Scope
V8_INLINE ~Scope()
Definition: v8.h:10801
v8::PersistentBase::PersistentValueVector
friend class PersistentValueVector
Definition: v8.h:613
v8::String::Empty
static V8_INLINE Local< String > Empty(Isolate *isolate)
Definition: v8.h:11806
v8::ArrayBuffer::byte_length
void size_t byte_length
Definition: v8.h:5471
v8::PropertyHandlerFlags::kAllCanRead
@ kAllCanRead
v8::JustVoid
Maybe< void > JustVoid()
Definition: v8.h:10375
v8::TracedGlobal::As
V8_INLINE TracedGlobal< S > & As() const
Definition: v8.h:1059
v8::Promise::kEmbedderFieldCount
static const int kEmbedderFieldCount
Definition: v8.h:4891
v8::MicrotasksScope::GetCurrentDepth
static int GetCurrentDepth(Isolate *isolate)
v8::metrics
Definition: v8-metrics.h:11
v8::ScriptCompiler::StreamedSource::StreamedSource
StreamedSource(const StreamedSource &)=delete
v8::Message::GetStartColumn
int GetStartColumn() const
v8::TryCatch::SetCaptureMessage
void SetCaptureMessage(bool value)
v8::Isolate::kWasmSharedMemory
@ kWasmSharedMemory
Definition: v8.h:8708
v8::ReadOnly
@ ReadOnly
Definition: v8.h:3817
v8::StackFrame::GetFunctionName
Local< String > GetFunctionName() const
v8::EmbedderHeapTracer::isolate
v8::Isolate * isolate() const
Definition: v8.h:8336
v8::MicrotaskQueue::New
static std::unique_ptr< MicrotaskQueue > New(Isolate *isolate, MicrotasksPolicy policy=MicrotasksPolicy::kAuto)
v8::StackFrame::GetLineNumber
int GetLineNumber() const
v8::PersistentValueMap
Definition: v8-util.h:348
v8::ScriptOrigin::ColumnOffset
V8_INLINE int ColumnOffset() const
Definition: v8.h:11673
v8::PropertyCallbackInfo::kShouldThrowOnErrorIndex
static const int kShouldThrowOnErrorIndex
Definition: v8.h:4685
v8::ScriptCompiler::CompileModule
static V8_WARN_UNUSED_RESULT MaybeLocal< Module > CompileModule(Local< Context > context, StreamedSource *v8_source, Local< String > full_source_string, const ScriptOrigin &origin)
v8::RegExp::Exec
V8_WARN_UNUSED_RESULT MaybeLocal< Object > Exec(Local< Context > context, Local< String > subject)
v8::BigInt::Uint64Value
uint64_t Uint64Value(bool *lossless=nullptr) const
v8::ExternalResourceVisitor::~ExternalResourceVisitor
virtual ~ExternalResourceVisitor()=default
v8::ScriptOrigin::LineOffset
V8_INLINE int LineOffset() const
Definition: v8.h:11671
v8::Isolate::kArrayPrototypeHasElements
@ kArrayPrototypeHasElements
Definition: v8.h:8741
v8::ExtensionConfiguration::begin
const char ** begin() const
Definition: v8.h:10549
v8::IndexedPropertyHandlerConfiguration::IndexedPropertyHandlerConfiguration
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter=nullptr, IndexedPropertySetterCallback setter=nullptr, IndexedPropertyQueryCallback query=nullptr, IndexedPropertyDeleterCallback deleter=nullptr, IndexedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
Definition: v8.h:6960
v8::BooleanObject::ValueOf
bool ValueOf() const
v8::Promise::Resolver::New
static V8_WARN_UNUSED_RESULT MaybeLocal< Resolver > New(Local< Context > context)
v8::HandleScope::~HandleScope
~HandleScope()
v8::EmbedderHeapTracer::TracedGlobalHandleVisitor
Definition: v8.h:8179
v8::Set::Delete
V8_WARN_UNUSED_RESULT Maybe< bool > Delete(Local< Context > context, Local< Value > key)
v8::PersistentBase::ClearWeak
V8_INLINE P * ClearWeak()
v8::Context::FromSnapshot
static MaybeLocal< Context > FromSnapshot(Isolate *isolate, size_t context_snapshot_index, DeserializeInternalFieldsCallback embedder_fields_deserializer=DeserializeInternalFieldsCallback(), ExtensionConfiguration *extensions=nullptr, MaybeLocal< Value > global_object=MaybeLocal< Value >(), MicrotaskQueue *microtask_queue=nullptr)
v8::BasicTracedReference::As
V8_INLINE BasicTracedReference< S > & As() const
Definition: v8.h:924
v8::Integer::New
static Local< Integer > New(Isolate *isolate, int32_t value)
v8::Promise::kFulfilled
@ kFulfilled
Definition: v8.h:4819
v8::ValueDeserializer::Delegate::GetSharedArrayBufferFromId
virtual MaybeLocal< SharedArrayBuffer > GetSharedArrayBufferFromId(Isolate *isolate, uint32_t clone_id)
v8::ScriptCompiler::kNoCacheBecauseDeferredProduceCodeCache
@ kNoCacheBecauseDeferredProduceCodeCache
Definition: v8.h:2000
v8::Isolate::operator new[]
void * operator new[](size_t size)=delete
v8::Object::Get
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, uint32_t index)
v8::Isolate::kBreakIteratorTypeLine
@ kBreakIteratorTypeLine
Definition: v8.h:8747
v8::Isolate::kPromiseConstructorReturnedUndefined
@ kPromiseConstructorReturnedUndefined
Definition: v8.h:8696
v8::Isolate::LocaleConfigurationChangeNotification
void LocaleConfigurationChangeNotification()
v8::FunctionCallbackInfo::GetIsolate
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:11585
v8::Map::Has
V8_WARN_UNUSED_RESULT Maybe< bool > Has(Local< Context > context, Local< Value > key)
v8::Isolate::SetModifyCodeGenerationFromStringsCallback
void SetModifyCodeGenerationFromStringsCallback(ModifyCodeGenerationFromStringsCallback2 callback)
v8::Local::operator*
V8_INLINE T * operator*() const
Definition: v8.h:225
v8::PrimitiveArray::Get
Local< Primitive > Get(Isolate *isolate, int index)
v8::TracedReference::TracedReference
V8_INLINE TracedReference(TracedReference &&other)
Definition: v8.h:1116
v8::TryCatch::HasCaught
bool HasCaught() const
v8::BYTECODE_COMPILER
@ BYTECODE_COMPILER
Definition: v8.h:2378
v8::Function::GetInferredName
Local< Value > GetInferredName() const
v8::ACCESS_HAS
@ ACCESS_HAS
Definition: v8.h:6602
v8::Isolate::CreateParams::only_terminate_in_safe_scope
bool only_terminate_in_safe_scope
Definition: v8.h:8519
v8::Value::IsAsyncFunction
bool IsAsyncFunction() const
v8::ValueSerializer::ValueSerializer
ValueSerializer(Isolate *isolate, Delegate *delegate)
v8::String::WriteOptions
WriteOptions
Definition: v8.h:3224
v8::Isolate::SetHostInitializeImportMetaObjectCallback
void SetHostInitializeImportMetaObjectCallback(HostInitializeImportMetaObjectCallback callback)
v8::EmbedderHeapTracer::IncreaseAllocatedSize
void IncreaseAllocatedSize(size_t bytes)
v8::ScriptCompiler::ExternalSourceStream::GetMoreData
virtual size_t GetMoreData(const uint8_t **src)=0
v8::Exception::GetStackTrace
static Local< StackTrace > GetStackTrace(Local< Value > exception)
v8::Boolean::New
static V8_INLINE Local< Boolean > New(Isolate *isolate, bool value)
Definition: v8.h:11709
v8::internal::Internals::GetEmbedderData
static V8_INLINE void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
Definition: v8-internal.h:324
v8::Context::BackupIncumbentScope::~BackupIncumbentScope
~BackupIncumbentScope()
v8::ResourceConstraints::ConfigureDefaultsFromHeapSize
void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes, size_t maximum_heap_size_in_bytes)
v8::Local::As
V8_INLINE Local< S > As() const
Definition: v8.h:295
v8::Object::New
static Local< Object > New(Isolate *isolate)
v8::Promise::Then
V8_WARN_UNUSED_RESULT MaybeLocal< Promise > Then(Local< Context > context, Local< Function > handler)
v8::HeapSpaceStatistics::space_size
size_t space_size()
Definition: v8.h:7945
v8::Isolate::Scope
Definition: v8.h:8539
v8::WeakCallbackType
WeakCallbackType
Definition: v8.h:474
v8::Object::HasNamedLookupInterceptor
bool HasNamedLookupInterceptor()
v8::V8::InitializeICU
static bool InitializeICU(const char *icu_data_file=nullptr)
v8::Int8Array::Cast
static V8_INLINE Int8Array * Cast(Value *obj)
Definition: v8.h:12183
v8::internal::Internals::kUndefinedValueRootIndex
static const int kUndefinedValueRootIndex
Definition: v8-internal.h:223
v8::ScriptOrModule::GetResourceName
Local< Value > GetResourceName()
v8::BackingStore::operator delete
void operator delete(void *ptr)
Definition: v8.h:5277
v8::EmbedderHeapTracer
Definition: v8.h:8166
v8::internal::Internals::GetOddballKind
static V8_INLINE int GetOddballKind(const internal::Address obj)
Definition: v8-internal.h:285
v8::Object::GetCreationContext
static V8_INLINE MaybeLocal< Context > GetCreationContext(const PersistentBase< Object > &object)
Definition: v8.h:4283
v8::ReturnValue::PropertyCallbackInfo
friend class PropertyCallbackInfo
Definition: v8.h:4515
v8::StackFrame::GetScriptName
Local< String > GetScriptName() const
v8::PropertyHandlerFlags::kOnlyInterceptStrings
@ kOnlyInterceptStrings
v8::Object::SetAlignedPointerInInternalFields
void SetAlignedPointerInInternalFields(int argc, int indices[], void *values[])
v8::String::Value::~Value
~Value()
v8::Locker::~Locker
~Locker()
v8::Value::IsMapIterator
bool IsMapIterator() const
v8::Object::Get
V8_WARN_UNUSED_RESULT MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
v8::Isolate::kDateTimeFormatRange
@ kDateTimeFormatRange
Definition: v8.h:8744
v8::HeapStatistics::malloced_memory
size_t malloced_memory()
Definition: v8.h:7908
v8::TracedReference::Reset
void Reset(Isolate *isolate, const Local< S > &other)
Definition: v8.h:11347
v8::ScriptType::kClassic
@ kClassic
v8::Isolate::NumberOfHeapSpaces
size_t NumberOfHeapSpaces()
v8::Integer::Value
int64_t Value() const
v8::PersistentBase::SetWeak
V8_INLINE void SetWeak(P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
Definition: v8.h:11154
v8::kGCCallbackFlagConstructRetainedObjectInfos
@ kGCCallbackFlagConstructRetainedObjectInfos
Definition: v8.h:7845
v8::StackTrace::kScriptNameOrSourceURL
@ kScriptNameOrSourceURL
Definition: v8.h:2271
v8::ValueSerializer::Delegate::ReallocateBufferMemory
virtual void * ReallocateBufferMemory(void *old_buffer, size_t size, size_t *actual_size)
v8::kGCTypeAll
@ kGCTypeAll
Definition: v8.h:7825
v8::SealHandleScope::SealHandleScope
SealHandleScope(Isolate *isolate)
v8::ACCESS_GET
@ ACCESS_GET
Definition: v8.h:6600
v8::Value::InstanceOf
Maybe< bool > InstanceOf(Local< Context > context, Local< Object > object)
v8::Isolate::SetRAILMode
void SetRAILMode(RAILMode rail_mode)
v8::WeakCallbackInfo::WeakCallbackInfo
WeakCallbackInfo(Isolate *isolate, T *parameter, void *embedder_fields[kEmbedderFieldsInWeakCallback], Callback *callback)
Definition: v8.h:440
v8::Set
Definition: v8.h:4448
v8::PersistentBase::AnnotateStrongRetainer
V8_INLINE void AnnotateStrongRetainer(const char *label)
Definition: v8.h:11182
v8::WasmModuleObject::WasmModuleObject
WasmModuleObject()=delete
v8::EXTERNAL
@ EXTERNAL
Definition: v8.h:2381
v8::debug
Definition: v8.h:161
v8::Isolate::AddGCEpilogueCallback
void AddGCEpilogueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
v8::EscapableHandleScope::EscapableHandleScope
EscapableHandleScope(const EscapableHandleScope &)=delete
v8::Persistent::operator=
V8_INLINE Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8.h:711
v8::IndexedPropertyHandlerConfiguration::flags
PropertyHandlerFlags flags
Definition: v8.h:7006
v8::ArrayBufferCreationMode::kInternalized
@ kInternalized
v8::internal::Internals::kNodeStateIsWeakValue
static const int kNodeStateIsWeakValue
Definition: v8-internal.h:233
v8::kGCCallbackFlagSynchronousPhantomCallbackProcessing
@ kGCCallbackFlagSynchronousPhantomCallbackProcessing
Definition: v8.h:7847
v8::Isolate::kOptimizedFunctionWithOneShotBytecode
@ kOptimizedFunctionWithOneShotBytecode
Definition: v8.h:8729
v8::BigIntObject::ValueOf
Local< BigInt > ValueOf() const
v8::ScriptCompiler::kNoCacheBecauseInDocumentWrite
@ kNoCacheBecauseInDocumentWrite
Definition: v8.h:1998
v8::Isolate::operator=
Isolate & operator=(const Isolate &)=delete
v8::SharedArrayBuffer::byte_length
void size_t byte_length
Definition: v8.h:5953
v8::V8::TracedReference
friend class TracedReference
Definition: v8.h:10143
v8::PersistentBase::IsEmpty
V8_INLINE bool IsEmpty() const
Definition: v8.h:510
v8::JitCodeEvent::name_t::str
const char * str
Definition: v8.h:8040
v8::String::ExternalStringResourceBase::ExternalStringResourceBase
ExternalStringResourceBase(const ExternalStringResourceBase &)=delete
v8::Isolate::SetEventLogger
void SetEventLogger(LogEventCallback that)
v8::Isolate::GetNumberOfDataSlots
static V8_INLINE uint32_t GetNumberOfDataSlots()
Definition: v8.h:12380
v8::Isolate::kMessageInfo
@ kMessageInfo
Definition: v8.h:8780
v8::ValueDeserializer::Delegate::ReadHostObject
virtual MaybeLocal< Object > ReadHostObject(Isolate *isolate)
cppgc::EmbedderStackState
EmbedderStackState
Definition: common.h:16
v8::SharedArrayBuffer::Externalize
void Externalize(const std::shared_ptr< BackingStore > &backing_store)
v8::String::ExternalStringResourceBase::~ExternalStringResourceBase
virtual ~ExternalStringResourceBase()=default
v8::WasmStreaming::WasmStreaming
WasmStreaming(std::unique_ptr< WasmStreamingImpl > impl)
v8::ValueDeserializer::Delegate::~Delegate
virtual ~Delegate()=default
v8::Object::DefineProperty
V8_WARN_UNUSED_RESULT Maybe< bool > DefineProperty(Local< Context > context, Local< Name > key, PropertyDescriptor &descriptor)
v8::Isolate::SetMicrotasksPolicy
void SetMicrotasksPolicy(MicrotasksPolicy policy)
v8::ArrayBuffer::Contents::Contents
Contents()
Definition: v8.h:5407
v8::EmbedderHeapTracer::TracePrologue
virtual void TracePrologue(TraceFlags flags)
Definition: v8.h:8237
v8::TracedGlobal::SetFinalizationCallback
V8_INLINE void SetFinalizationCallback(void *parameter, WeakCallbackInfo< void >::Callback callback)
Definition: v8.h:11413
v8::Isolate::SuppressMicrotaskExecutionScope::SuppressMicrotaskExecutionScope
SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope &)=delete
v8::Persistent::Cast
static V8_INLINE Persistent< T > & Cast(const Persistent< S > &that)
Definition: v8.h:726
v8::TracedReference::TracedReference
V8_INLINE TracedReference(TracedReference< S > &&other)
Definition: v8.h:1126
v8::Isolate::kConstructorNonUndefinedPrimitiveReturn
@ kConstructorNonUndefinedPrimitiveReturn
Definition: v8.h:8697
v8::Object::GetOwnPropertyNames
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context, PropertyFilter filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
v8::ArrayBuffer::Allocator::Free
virtual void Free(void *data, size_t length)=0
v8::PARSER
@ PARSER
Definition: v8.h:2377
v8::Isolate::kSloppyModeBlockScopedFunctionRedefinition
@ kSloppyModeBlockScopedFunctionRedefinition
Definition: v8.h:8680
v8::Maybe::Nothing
friend Maybe< U > Nothing()
Definition: v8.h:10338
v8::WasmModuleObjectBuilderStreaming::GetPromise
Local< Promise > GetPromise()
v8::Message::kNoScriptIdInfo
static const int kNoScriptIdInfo
Definition: v8.h:2246
v8::V8::SetFlagsFromCommandLine
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
v8::ObjectTemplate::SetInternalFieldCount
void SetInternalFieldCount(int value)
v8::RegExp
Definition: v8.h:6177
v8::PersistentHandleVisitor
Definition: v8.h:8142
v8::internal::Internals::kInferShouldThrowMode
static const int kInferShouldThrowMode
Definition: v8-internal.h:250
v8::V8::SetFlagsFromString
static void SetFlagsFromString(const char *str, size_t length)
v8::CFunction
Definition: v8-fast-api-calls.h:358
v8::CrashKeyId::kIsolateAddress
@ kIsolateAddress
v8::MeasureMemoryExecution
MeasureMemoryExecution
Definition: v8.h:8395
v8::Isolate::AtomicsWaitEvent::kTerminatedExecution
@ kTerminatedExecution
v8::External::New
static Local< External > New(Isolate *isolate, void *value)
v8::Object::GetRealNamedPropertyAttributesInPrototypeChain
V8_WARN_UNUSED_RESULT Maybe< PropertyAttribute > GetRealNamedPropertyAttributesInPrototypeChain(Local< Context > context, Local< Name > key)
v8::Isolate::IsDead
bool IsDead()
v8::Local::IsEmpty
V8_INLINE bool IsEmpty() const
Definition: v8.h:216
v8::String::ExternalStringResourceBase::IsCacheable
virtual bool IsCacheable() const
Definition: v8.h:3269
v8::Isolate::kFullGarbageCollection
@ kFullGarbageCollection
Definition: v8.h:8648
v8::String::Utf8Value::operator*
const char * operator*() const
Definition: v8.h:3544
v8::Value::ToArrayIndex
V8_WARN_UNUSED_RESULT MaybeLocal< Uint32 > ToArrayIndex(Local< Context > context) const
v8::Isolate::RemoveBeforeCallEnteredCallback
void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback)
v8::ArrayBuffer::data
void * data
Definition: v8.h:5471
v8::Local::New
static V8_INLINE Local< T > New(Isolate *isolate, const BasicTracedReference< T > &that)
Definition: v8.h:11045
v8::PromiseHookType::kAfter
@ kAfter
v8::ObjectTemplate::SetIndexedPropertyHandler
void SetIndexedPropertyHandler(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=nullptr, IndexedPropertyQueryCallback query=nullptr, IndexedPropertyDeleterCallback deleter=nullptr, IndexedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >())
Definition: v8.h:7102
v8::ScriptCompiler::ExternalSourceStream::ResetToBookmark
virtual void ResetToBookmark()
v8::Context::BackupIncumbentScope::JSStackComparableAddress
uintptr_t JSStackComparableAddress() const
Definition: v8.h:10826
v8::ScriptCompiler::Source::Source
Source(const Source &)=delete
v8::TryCatch::SetVerbose
void SetVerbose(bool value)
v8::V8
Definition: v8.h:9896
v8::BigIntObject::New
static Local< Value > New(Isolate *isolate, int64_t value)
v8::Value
Definition: v8.h:2683
v8::Isolate::kRegExpPrototypeSourceGetter
@ kRegExpPrototypeSourceGetter
Definition: v8.h:8688
v8::Symbol::For
static Local< Symbol > For(Isolate *isolate, Local< String > description)
v8::Message::GetSourceLine
V8_WARN_UNUSED_RESULT MaybeLocal< String > GetSourceLine(Local< Context > context) const
v8::ValueDeserializer::ReadValue
V8_WARN_UNUSED_RESULT MaybeLocal< Value > ReadValue(Local< Context > context)
v8::Uint16Array::New
static Local< Uint16Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::ScriptCompiler::ExternalSourceStream::SetBookmark
virtual bool SetBookmark()
v8::Isolate::kRegExpMatchIsTrueishOnNonJSRegExp
@ kRegExpMatchIsTrueishOnNonJSRegExp
Definition: v8.h:8730
v8::TracedGlobal::TracedGlobal
V8_INLINE TracedGlobal(const TracedGlobal &other)
Definition: v8.h:1009
v8::SharedArrayBuffer::mode
void size_t ArrayBufferCreationMode mode
Definition: v8.h:5954
v8::ScriptOrModule
Definition: v8.h:1360
v8::Isolate::CreateParams
Definition: v8.h:8455
v8::Proxy::Cast
static V8_INLINE Proxy * Cast(Value *obj)
Definition: v8.h:12122
v8::Isolate::SetWasmModuleCallback
void SetWasmModuleCallback(ExtensionCallback callback)
v8::Isolate::kCallSiteAPIGetThisSloppyCall
@ kCallSiteAPIGetThisSloppyCall
Definition: v8.h:8735
v8::BigIntObject::Cast
static V8_INLINE BigIntObject * Cast(Value *obj)
Definition: v8.h:12059
v8::Context::BackupIncumbentScope::BackupIncumbentScope
BackupIncumbentScope(Local< Context > backup_incumbent_context)
v8::PropertyDescriptor::value
Local< Value > value() const
v8::PERFORMANCE_RESPONSE
@ PERFORMANCE_RESPONSE
Definition: v8.h:8091
v8::PersistentBase::operator=
void operator=(const PersistentBase &)=delete
v8::JitCodeEvent::CODE_MOVED
@ CODE_MOVED
Definition: v8.h:8001
v8::HeapObjectStatistics::object_type
const char * object_type()
Definition: v8.h:7964
v8::SealHandleScope::~SealHandleScope
~SealHandleScope()
v8::Uint8ClampedArray::New
static Local< Uint8ClampedArray > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::Isolate::AtomicsWaitWakeHandle::Wake
void Wake()
v8::Eternal::IsEmpty
V8_INLINE bool IsEmpty() const
Definition: v8.h:424
v8::HeapCodeStatistics
Definition: v8.h:7978
v8::Isolate::VisitHandlesWithClassIds
void VisitHandlesWithClassIds(PersistentHandleVisitor *visitor)
v8::ValueDeserializer::ValueDeserializer
ValueDeserializer(Isolate *isolate, const uint8_t *data, size_t size, Delegate *delegate)
v8::ValueSerializer::ValueSerializer
ValueSerializer(Isolate *isolate)
v8::Isolate::kInvalidatedArrayConstructorProtector
@ kInvalidatedArrayConstructorProtector
Definition: v8.h:8749
v8::ReturnValue::Set
void Set(const Local< S > handle)
Definition: v8.h:11446
v8::SharedArrayBuffer::Contents::AllocationBase
void * AllocationBase() const
Definition: v8.h:5902
v8::StackTrace::kIsEval
@ kIsEval
Definition: v8.h:2269
v8::String::ExternalStringResourceBase::ExternalStringResourceBase
ExternalStringResourceBase()=default
v8::JitCodeEvent::wasm_source_info_t::line_number_table_size
size_t line_number_table_size
Definition: v8.h:8063
v8::RegisterState
Definition: v8.h:2393
v8::SharedArrayBuffer::Cast
static V8_INLINE SharedArrayBuffer * Cast(Value *obj)
Definition: v8.h:12268
v8::ObjectTemplate::InternalFieldCount
int InternalFieldCount()
v8::Persistent::Copy
void Copy(const Persistent< S, M2 > &that)
Definition: v8.h:11105
v8::JitCodeEvent
Definition: v8.h:7998
v8::String::Cast
static V8_INLINE String * Cast(v8::Data *data)
Definition: v8.h:11799
v8::V8::InitializeICUDefaultLocation
static bool InitializeICUDefaultLocation(const char *exec_path, const char *icu_data_file=nullptr)
v8::ReturnValue::SetEmptyString
V8_INLINE void SetEmptyString()
Definition: v8.h:11513
v8::internal::Internals::kTheHoleValueRootIndex
static const int kTheHoleValueRootIndex
Definition: v8-internal.h:224
v8::ArrayBufferView::Cast
static V8_INLINE ArrayBufferView * Cast(Value *obj)
Definition: v8.h:12159
v8::Object::GetPropertyNames
V8_WARN_UNUSED_RESULT MaybeLocal< Array > GetPropertyNames(Local< Context > context)
v8::Isolate::MeasureMemory
bool MeasureMemory(std::unique_ptr< MeasureMemoryDelegate > delegate, MeasureMemoryExecution execution=MeasureMemoryExecution::kDefault)
v8::Object::Cast
static V8_INLINE Object * Cast(Value *obj)
Definition: v8.h:12082
v8::ScriptCompiler::CompileFunctionInContext
static V8_WARN_UNUSED_RESULT MaybeLocal< Function > CompileFunctionInContext(Local< Context > context, Source *source, size_t arguments_count, Local< String > arguments[], size_t context_extension_count, Local< Object > context_extensions[], CompileOptions options=kNoCompileOptions, NoCacheReason no_cache_reason=kNoCacheNoReason, Local< ScriptOrModule > *script_or_module_out=nullptr)
v8::Isolate::kNumberFormatStyleUnit
@ kNumberFormatStyleUnit
Definition: v8.h:8743
v8::ConstructorBehavior::kAllow
@ kAllow
v8::Map
Definition: v8.h:4412
v8::ScriptOriginOptions::IsSharedCrossOrigin
bool IsSharedCrossOrigin() const
Definition: v8.h:1406
v8::PersistentBase::operator==
V8_INLINE bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:518
v8::Isolate::kInvalidatedArraySpeciesLookupChainProtector
@ kInvalidatedArraySpeciesLookupChainProtector
Definition: v8.h:8751
v8::operator!=
V8_INLINE bool operator!=(const v8::Local< U > &lhs, const TracedReferenceBase &rhs)
Definition: v8.h:11291
v8::String::GetExternalStringResourceBase
V8_INLINE ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:11837
v8::FixedArray
Definition: v8.h:1541
v8::Isolate::GetData
V8_INLINE void * GetData(uint32_t slot)
Definition: v8.h:12374
v8::StackFrame::IsWasm
bool IsWasm() const
v8::ScriptCompiler::StreamedSource::ONE_BYTE
@ ONE_BYTE
Definition: v8.h:1939
v8::HeapProfiler
Definition: v8-profiler.h:815
v8::PropertyDescriptor::has_value
bool has_value() const
v8::Isolate::kNumberFormat
@ kNumberFormat
Definition: v8.h:8713
v8::JS
@ JS
Definition: v8.h:2375
v8::StackTrace::kFunctionName
@ kFunctionName
Definition: v8.h:2268
v8::BackingStore::ByteLength
size_t ByteLength() const
v8::HeapStatistics::number_of_detached_contexts
size_t number_of_detached_contexts()
Definition: v8.h:7912
v8::Object::FindInstanceInPrototypeChain
Local< Object > FindInstanceInPrototypeChain(Local< FunctionTemplate > tmpl)
v8::operator==
V8_INLINE bool operator==(const TracedReferenceBase &lhs, const TracedReferenceBase &rhs)
Definition: v8.h:11254
v8::ScriptCompiler::Source::Source
V8_INLINE Source(Local< String > source_string, CachedData *cached_data=nullptr)
Definition: v8.h:11690
v8::Isolate::kInvalidatedPromiseThenLookupChainProtector
@ kInvalidatedPromiseThenLookupChainProtector
Definition: v8.h:8758
v8::SharedArrayBuffer::GetContents
Contents GetContents()
v8::SharedMemoryStatistics::read_only_space_used_size
size_t read_only_space_used_size()
Definition: v8.h:7877
v8::EmbedderHeapTracer::ResetHandleInNonTracingGC
virtual void ResetHandleInNonTracingGC(const v8::TracedReference< v8::Value > &handle)
v8::internal::Internals::kEmptyStringRootIndex
static const int kEmptyStringRootIndex
Definition: v8-internal.h:228
v8::OwnedBuffer
Definition: v8.h:5027
v8::Uint8Array::New
static Local< Uint8Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
v8::Isolate::kRegExpPrototypeOldFlagGetter
@ kRegExpPrototypeOldFlagGetter
Definition: v8.h:8689
v8::Function::Cast
static V8_INLINE Function * Cast(Value *obj)
Definition: v8.h:12276
v8::PersistentBase::operator==
V8_INLINE bool operator==(const Local< S > &that) const
Definition: v8.h:527
v8::Isolate::AddNearHeapLimitCallback
void AddNearHeapLimitCallback(NearHeapLimitCallback callback, void *data)
v8::HeapObjectStatistics::object_count
size_t object_count()
Definition: v8.h:7966
v8::FunctionCallbackInfo::GetReturnValue
V8_INLINE ReturnValue< T > GetReturnValue() const
Definition: v8.h:11591
v8::Module::GetIdentityHash
int GetIdentityHash() const
v8::Object::IsConstructor
bool IsConstructor()
v8::Isolate::GetEnteredOrMicrotaskContext
Local< Context > GetEnteredOrMicrotaskContext()
v8::ScriptCompiler::StreamedSource::impl
internal::ScriptStreamingData * impl() const
Definition: v8.h:1949
v8::String
Definition: v8.h:3163
v8::MemoryPressureLevel::kModerate
@ kModerate
v8::PromiseRejectMessage::GetValue
V8_INLINE Local< Value > GetValue() const
Definition: v8.h:7605
v8::NewStringType::kNormal
@ kNormal