Loading...
Searching...
No Matches
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
15#ifndef INCLUDE_V8_H_
16#define INCLUDE_V8_H_
17
18#include <stddef.h>
19#include <stdint.h>
20#include <stdio.h>
21#include <memory>
22#include <utility>
23#include <vector>
24
25#include "v8-version.h" // NOLINT(build/include)
26#include "v8config.h" // NOLINT(build/include)
27
28// We reserve the V8_* prefix for macros defined in V8 public API and
29// assume there are no name conflicts with the embedder's code.
30
31#ifdef V8_OS_WIN
32
33// Setup for Windows DLL export/import. When building the V8 DLL the
34// BUILDING_V8_SHARED needs to be defined. When building a program which uses
35// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
36// static library or building a program which uses the V8 static library neither
37// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
38#ifdef BUILDING_V8_SHARED
39# define V8_EXPORT __declspec(dllexport)
40#elif USING_V8_SHARED
41# define V8_EXPORT __declspec(dllimport)
42#else
43# define V8_EXPORT
44#endif // BUILDING_V8_SHARED
45
46#else // V8_OS_WIN
47
48// Setup for Linux shared library export.
49#if V8_HAS_ATTRIBUTE_VISIBILITY
50# ifdef BUILDING_V8_SHARED
51# define V8_EXPORT __attribute__ ((visibility("default")))
52# else
53# define V8_EXPORT
54# endif
55#else
56# define V8_EXPORT
57#endif
58
59#endif // V8_OS_WIN
60
64namespace v8 {
65
66class AccessorSignature;
67class Array;
68class ArrayBuffer;
69class Boolean;
70class BooleanObject;
71class Context;
72class CpuProfiler;
73class Data;
74class Date;
75class External;
76class Function;
77class FunctionTemplate;
78class HeapProfiler;
79class ImplementationUtilities;
80class Int32;
81class Integer;
82class Isolate;
83template <class T>
84class Maybe;
85class Name;
86class Number;
87class NumberObject;
88class Object;
89class ObjectOperationDescriptor;
90class ObjectTemplate;
91class Platform;
92class Primitive;
93class Promise;
94class PropertyDescriptor;
95class Proxy;
96class RawOperationDescriptor;
97class Script;
98class SharedArrayBuffer;
99class Signature;
100class StartupData;
101class StackFrame;
102class StackTrace;
103class String;
104class StringObject;
105class Symbol;
106class SymbolObject;
107class Private;
108class Uint32;
109class Utils;
110class Value;
111class WasmCompiledModule;
112template <class T> class Local;
113template <class T>
114class MaybeLocal;
115template <class T> class Eternal;
116template<class T> class NonCopyablePersistentTraits;
117template<class T> class PersistentBase;
118template <class T, class M = NonCopyablePersistentTraits<T> >
119class Persistent;
120template <class T>
121class Global;
122template<class K, class V, class T> class PersistentValueMap;
123template <class K, class V, class T>
124class PersistentValueMapBase;
125template <class K, class V, class T>
126class GlobalValueMap;
127template<class V, class T> class PersistentValueVector;
128template<class T, class P> class WeakCallbackObject;
129class FunctionTemplate;
130class ObjectTemplate;
131template<typename T> class FunctionCallbackInfo;
132template<typename T> class PropertyCallbackInfo;
133class StackTrace;
134class StackFrame;
135class Isolate;
136class CallHandlerHelper;
138template<typename T> class ReturnValue;
139
140namespace internal {
141class Arguments;
142class DeferredHandles;
143class Heap;
144class HeapObject;
145class Isolate;
146class Object;
147struct StreamedSource;
148template<typename T> class CustomArguments;
149class PropertyCallbackArguments;
150class FunctionCallbackArguments;
151class GlobalHandles;
152} // namespace internal
153
154namespace debug {
155class ConsoleCallArguments;
156} // namespace debug
157
158// --- Handles ---
159
160#define TYPE_CHECK(T, S) \
161 while (false) { \
162 *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
163 }
164
196template <class T>
197class Local {
198 public:
199 V8_INLINE Local() : val_(0) {}
200 template <class S>
202 : val_(reinterpret_cast<T*>(*that)) {
208 TYPE_CHECK(T, S);
209 }
210
214 V8_INLINE bool IsEmpty() const { return val_ == 0; }
215
219 V8_INLINE void Clear() { val_ = 0; }
220
221 V8_INLINE T* operator->() const { return val_; }
222
223 V8_INLINE T* operator*() const { return val_; }
224
231 template <class S>
232 V8_INLINE bool operator==(const Local<S>& that) const {
233 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
234 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
235 if (a == 0) return b == 0;
236 if (b == 0) return false;
237 return *a == *b;
238 }
239
240 template <class S> V8_INLINE bool operator==(
241 const PersistentBase<S>& that) const {
242 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
243 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
244 if (a == 0) return b == 0;
245 if (b == 0) return false;
246 return *a == *b;
247 }
248
255 template <class S>
256 V8_INLINE bool operator!=(const Local<S>& that) const {
257 return !operator==(that);
258 }
259
260 template <class S> V8_INLINE bool operator!=(
261 const Persistent<S>& that) const {
262 return !operator==(that);
263 }
264
270 template <class S> V8_INLINE static Local<T> Cast(Local<S> that) {
271#ifdef V8_ENABLE_CHECKS
272 // If we're going to perform the type check then we have to check
273 // that the handle isn't empty before doing the checked cast.
274 if (that.IsEmpty()) return Local<T>();
275#endif
276 return Local<T>(T::Cast(*that));
277 }
278
284 template <class S>
286 return Local<S>::Cast(*this);
287 }
288
294 V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that);
295 V8_INLINE static Local<T> New(Isolate* isolate,
296 const PersistentBase<T>& that);
297
298 private:
299 friend class Utils;
300 template<class F> friend class Eternal;
301 template<class F> friend class PersistentBase;
302 template<class F, class M> friend class Persistent;
303 template<class F> friend class Local;
304 template <class F>
305 friend class MaybeLocal;
306 template<class F> friend class FunctionCallbackInfo;
307 template<class F> friend class PropertyCallbackInfo;
308 friend class String;
309 friend class Object;
310 friend class Context;
311 friend class Private;
312 template<class F> friend class internal::CustomArguments;
314 friend Local<Primitive> Null(Isolate* isolate);
315 friend Local<Boolean> True(Isolate* isolate);
316 friend Local<Boolean> False(Isolate* isolate);
317 friend class HandleScope;
319 template <class F1, class F2, class F3>
321 template<class F1, class F2> friend class PersistentValueVector;
322 template <class F>
323 friend class ReturnValue;
324
325 explicit V8_INLINE Local(T* that) : val_(that) {}
326 V8_INLINE static Local<T> New(Isolate* isolate, T* that);
327 T* val_;
328};
329
330
331#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
332// Handle is an alias for Local for historical reasons.
333template <class T>
335#endif
336
337
348template <class T>
350 public:
351 V8_INLINE MaybeLocal() : val_(nullptr) {}
352 template <class S>
354 : val_(reinterpret_cast<T*>(*that)) {
355 TYPE_CHECK(T, S);
356 }
357
358 V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
359
364 template <class S>
366 out->val_ = IsEmpty() ? nullptr : this->val_;
367 return !IsEmpty();
368 }
369
375
380 template <class S>
381 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
382 return IsEmpty() ? default_value : Local<S>(val_);
383 }
384
385 private:
386 T* val_;
387};
388
393template <class T> class Eternal {
394 public:
395 V8_INLINE Eternal() : val_(nullptr) {}
396 template <class S>
397 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : val_(nullptr) {
398 Set(isolate, handle);
399 }
400 // Can only be safely called if already set.
401 V8_INLINE Local<T> Get(Isolate* isolate) const;
402 V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
403 template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
404
405 private:
406 T* val_;
407};
408
409
410static const int kInternalFieldsInWeakCallback = 2;
411static const int kEmbedderFieldsInWeakCallback = 2;
412
413template <typename T>
415 public:
416 typedef void (*Callback)(const WeakCallbackInfo<T>& data);
417
418 WeakCallbackInfo(Isolate* isolate, T* parameter,
419 void* embedder_fields[kEmbedderFieldsInWeakCallback],
420 Callback* callback)
421 : isolate_(isolate), parameter_(parameter), callback_(callback) {
422 for (int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
423 embedder_fields_[i] = embedder_fields[i];
424 }
425 }
426
427 V8_INLINE Isolate* GetIsolate() const { return isolate_; }
428 V8_INLINE T* GetParameter() const { return parameter_; }
429 V8_INLINE void* GetInternalField(int index) const;
430
431 V8_INLINE V8_DEPRECATED("use indexed version",
432 void* GetInternalField1() const) {
433 return embedder_fields_[0];
434 }
435 V8_INLINE V8_DEPRECATED("use indexed version",
436 void* GetInternalField2() const) {
437 return embedder_fields_[1];
438 }
439
440 V8_DEPRECATED("Not realiable once SetSecondPassCallback() was used.",
441 bool IsFirstPass() const) {
442 return callback_ != nullptr;
443 }
444
445 // When first called, the embedder MUST Reset() the Global which triggered the
446 // callback. The Global itself is unusable for anything else. No v8 other api
447 // calls may be called in the first callback. Should additional work be
448 // required, the embedder must set a second pass callback, which will be
449 // called after all the initial callbacks are processed.
450 // Calling SetSecondPassCallback on the second pass will immediately crash.
451 void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
452
453 private:
454 Isolate* isolate_;
455 T* parameter_;
456 Callback* callback_;
457 void* embedder_fields_[kEmbedderFieldsInWeakCallback];
458};
459
460
461// kParameter will pass a void* parameter back to the callback, kInternalFields
462// will pass the first two internal fields back to the callback, kFinalizer
463// will pass a void* parameter back, but is invoked before the object is
464// actually collected, so it can be resurrected. In the last case, it is not
465// possible to request a second pass callback.
467
481template <class T> class PersistentBase {
482 public:
492 template <class S>
493 V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
494
499 template <class S>
500 V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other);
501
502 V8_INLINE bool IsEmpty() const { return val_ == NULL; }
503 V8_INLINE void Empty() { val_ = 0; }
504
505 V8_INLINE Local<T> Get(Isolate* isolate) const {
506 return Local<T>::New(isolate, *this);
507 }
508
509 template <class S>
510 V8_INLINE bool operator==(const PersistentBase<S>& that) const {
511 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
512 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
513 if (a == NULL) return b == NULL;
514 if (b == NULL) return false;
515 return *a == *b;
516 }
517
518 template <class S>
519 V8_INLINE bool operator==(const Local<S>& that) const {
520 internal::Object** a = reinterpret_cast<internal::Object**>(this->val_);
521 internal::Object** b = reinterpret_cast<internal::Object**>(that.val_);
522 if (a == NULL) return b == NULL;
523 if (b == NULL) return false;
524 return *a == *b;
525 }
526
527 template <class S>
528 V8_INLINE bool operator!=(const PersistentBase<S>& that) const {
529 return !operator==(that);
530 }
531
532 template <class S>
533 V8_INLINE bool operator!=(const Local<S>& that) const {
534 return !operator==(that);
535 }
536
544 template <typename P>
545 V8_INLINE void SetWeak(P* parameter,
546 typename WeakCallbackInfo<P>::Callback callback,
547 WeakCallbackType type);
548
557
558 template<typename P>
560
561 // TODO(dcarney): remove this.
562 V8_INLINE void ClearWeak() { ClearWeak<void>(); }
563
570
578
585
587
589 V8_INLINE bool IsNearDeath() const;
590
592 V8_INLINE bool IsWeak() const;
593
598 V8_INLINE void SetWrapperClassId(uint16_t class_id);
599
604 V8_INLINE uint16_t WrapperClassId() const;
605
606 PersistentBase(const PersistentBase& other) = delete; // NOLINT
607 void operator=(const PersistentBase&) = delete;
608
609 private:
610 friend class Isolate;
611 friend class Utils;
612 template<class F> friend class Local;
613 template<class F1, class F2> friend class Persistent;
614 template <class F>
615 friend class Global;
616 template<class F> friend class PersistentBase;
617 template<class F> friend class ReturnValue;
618 template <class F1, class F2, class F3>
620 template<class F1, class F2> friend class PersistentValueVector;
621 friend class Object;
622
623 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
624 V8_INLINE static T* New(Isolate* isolate, T* that);
625
626 T* val_;
627};
628
629
636template<class T>
638 public:
640 static const bool kResetInDestructor = false;
641 template<class S, class M>
642 V8_INLINE static void Copy(const Persistent<S, M>& source,
643 NonCopyablePersistent* dest) {
644 Uncompilable<Object>();
645 }
646 // TODO(dcarney): come up with a good compile error here.
647 template<class O> V8_INLINE static void Uncompilable() {
649 }
650};
651
652
657template<class T>
660 static const bool kResetInDestructor = true;
661 template<class S, class M>
662 static V8_INLINE void Copy(const Persistent<S, M>& source,
663 CopyablePersistent* dest) {
664 // do nothing, just allow copy
665 }
666};
667
668
677template <class T, class M> class Persistent : public PersistentBase<T> {
678 public:
688 template <class S>
690 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
691 TYPE_CHECK(T, S);
692 }
698 template <class S, class M2>
700 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
701 TYPE_CHECK(T, S);
702 }
710 Copy(that);
711 }
712 template <class S, class M2>
714 Copy(that);
715 }
716 V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT
717 Copy(that);
718 return *this;
719 }
720 template <class S, class M2>
722 Copy(that);
723 return *this;
724 }
731 if (M::kResetInDestructor) this->Reset();
732 }
733
734 // TODO(dcarney): this is pretty useless, fix or remove
735 template <class S>
736 V8_INLINE static Persistent<T>& Cast(const Persistent<S>& that) { // NOLINT
737#ifdef V8_ENABLE_CHECKS
738 // If we're going to perform the type check then we have to check
739 // that the handle isn't empty before doing the checked cast.
740 if (!that.IsEmpty()) T::Cast(*that);
741#endif
742 return reinterpret_cast<Persistent<T>&>(const_cast<Persistent<S>&>(that));
743 }
744
745 // TODO(dcarney): this is pretty useless, fix or remove
746 template <class S>
747 V8_INLINE Persistent<S>& As() const { // NOLINT
748 return Persistent<S>::Cast(*this);
749 }
750
751 private:
752 friend class Isolate;
753 friend class Utils;
754 template<class F> friend class Local;
755 template<class F1, class F2> friend class Persistent;
756 template<class F> friend class ReturnValue;
757
758 explicit V8_INLINE Persistent(T* that) : PersistentBase<T>(that) {}
759 V8_INLINE T* operator*() const { return this->val_; }
760 template<class S, class M2>
761 V8_INLINE void Copy(const Persistent<S, M2>& that);
762};
763
764
770template <class T>
771class Global : public PersistentBase<T> {
772 public:
776 V8_INLINE Global() : PersistentBase<T>(nullptr) {}
782 template <class S>
784 : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) {
785 TYPE_CHECK(T, S);
786 }
792 template <class S>
794 : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) {
795 TYPE_CHECK(T, S);
796 }
800 V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) { // NOLINT
801 other.val_ = nullptr;
802 }
803 V8_INLINE ~Global() { this->Reset(); }
807 template <class S>
809 TYPE_CHECK(T, S);
810 if (this != &rhs) {
811 this->Reset();
812 this->val_ = rhs.val_;
813 rhs.val_ = nullptr;
814 }
815 return *this;
816 }
820 Global Pass() { return static_cast<Global&&>(*this); } // NOLINT
821
822 /*
823 * For compatibility with Chromium's base::Bind (base::Passed).
824 */
826
827 Global(const Global&) = delete;
828 void operator=(const Global&) = delete;
829
830 private:
831 template <class F>
832 friend class ReturnValue;
833 V8_INLINE T* operator*() const { return this->val_; }
834};
835
836
837// UniquePersistent is an alias for Global for historical reason.
838template <class T>
840
841
857 public:
858 explicit HandleScope(Isolate* isolate);
859
861
865 static int NumberOfHandles(Isolate* isolate);
866
868 return reinterpret_cast<Isolate*>(isolate_);
869 }
870
871 HandleScope(const HandleScope&) = delete;
872 void operator=(const HandleScope&) = delete;
873
874 protected:
876
877 void Initialize(Isolate* isolate);
878
879 static internal::Object** CreateHandle(internal::Isolate* isolate,
880 internal::Object* value);
881
882 private:
883 // Declaring operator new and delete as deleted is not spec compliant.
884 // Therefore declare them private instead to disable dynamic alloc
885 void* operator new(size_t size);
886 void* operator new[](size_t size);
887 void operator delete(void*, size_t);
888 void operator delete[](void*, size_t);
889
890 // Uses heap_object to obtain the current Isolate.
891 static internal::Object** CreateHandle(internal::HeapObject* heap_object,
892 internal::Object* value);
893
894 internal::Isolate* isolate_;
895 internal::Object** prev_next_;
896 internal::Object** prev_limit_;
897
898 // Local::New uses CreateHandle with an Isolate* parameter.
899 template<class F> friend class Local;
900
901 // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
902 // a HeapObject* in their shortcuts.
903 friend class Object;
904 friend class Context;
905};
906
907
913 public:
914 explicit EscapableHandleScope(Isolate* isolate);
916
921 template <class T>
923 internal::Object** slot =
924 Escape(reinterpret_cast<internal::Object**>(*value));
925 return Local<T>(reinterpret_cast<T*>(slot));
926 }
927
929 void operator=(const EscapableHandleScope&) = delete;
930
931 private:
932 // Declaring operator new and delete as deleted is not spec compliant.
933 // Therefore declare them private instead to disable dynamic alloc
934 void* operator new(size_t size);
935 void* operator new[](size_t size);
936 void operator delete(void*, size_t);
937 void operator delete[](void*, size_t);
938
939 internal::Object** Escape(internal::Object** escape_value);
940 internal::Object** escape_slot_;
941};
942
949 public:
952
954 void operator=(const SealHandleScope&) = delete;
955
956 private:
957 // Declaring operator new and delete as deleted is not spec compliant.
958 // Therefore declare them private instead to disable dynamic alloc
959 void* operator new(size_t size);
960 void* operator new[](size_t size);
961 void operator delete(void*, size_t);
962 void operator delete[](void*, size_t);
963
964 internal::Isolate* const isolate_;
965 internal::Object** prev_limit_;
966 int prev_sealed_level_;
967};
968
969
970// --- Special objects ---
971
972
977 private:
978 Data();
979};
980
981
986 public:
987 V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
988 bool is_opaque = false, bool is_wasm = false,
989 bool is_module = false)
990 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
991 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
992 (is_module ? kIsModule : 0)) {}
994 : flags_(flags &
995 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
996
997 bool IsSharedCrossOrigin() const {
998 return (flags_ & kIsSharedCrossOrigin) != 0;
999 }
1000 bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
1001 bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
1002 bool IsModule() const { return (flags_ & kIsModule) != 0; }
1003
1004 int Flags() const { return flags_; }
1005
1006 private:
1007 enum {
1008 kIsSharedCrossOrigin = 1,
1009 kIsOpaque = 1 << 1,
1010 kIsWasm = 1 << 2,
1011 kIsModule = 1 << 3
1012 };
1013 const int flags_;
1014};
1015
1020 public:
1022 Local<Value> resource_name,
1023 Local<Integer> resource_line_offset = Local<Integer>(),
1024 Local<Integer> resource_column_offset = Local<Integer>(),
1025 Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(),
1026 Local<Integer> script_id = Local<Integer>(),
1027 Local<Value> source_map_url = Local<Value>(),
1028 Local<Boolean> resource_is_opaque = Local<Boolean>(),
1029 Local<Boolean> is_wasm = Local<Boolean>(),
1030 Local<Boolean> is_module = Local<Boolean>());
1031
1037 V8_INLINE ScriptOriginOptions Options() const { return options_; }
1038
1039 private:
1040 Local<Value> resource_name_;
1041 Local<Integer> resource_line_offset_;
1042 Local<Integer> resource_column_offset_;
1043 ScriptOriginOptions options_;
1044 Local<Integer> script_id_;
1045 Local<Value> source_map_url_;
1046};
1047
1052 public:
1057
1058 int GetId();
1060
1069
1074 int GetLineNumber(int code_pos);
1075
1076 static const int kNoScriptId = 0;
1077};
1078
1083 public:
1084 int GetLineNumber() { return line_number_; }
1085 int GetColumnNumber() { return column_number_; }
1086
1087 Location(int line_number, int column_number)
1088 : line_number_(line_number), column_number_(column_number) {}
1089
1090 private:
1091 int line_number_;
1092 int column_number_;
1093};
1094
1102 public:
1106 enum Status {
1112 kErrored
1114
1119
1124
1129
1135
1141
1145 int GetIdentityHash() const;
1146
1147 typedef MaybeLocal<Module> (*ResolveCallback)(Local<Context> context,
1148 Local<String> specifier,
1149 Local<Module> referrer);
1150
1158 V8_DEPRECATED("Use Maybe<bool> version",
1159 bool Instantiate(Local<Context> context,
1160 ResolveCallback callback));
1162 ResolveCallback callback);
1163
1171
1177};
1178
1184 public:
1188 static V8_DEPRECATE_SOON(
1189 "Use maybe version",
1190 Local<Script> Compile(Local<String> source,
1191 ScriptOrigin* origin = nullptr));
1193 Local<Context> context, Local<String> source,
1194 ScriptOrigin* origin = nullptr);
1195
1196 static Local<Script> V8_DEPRECATE_SOON("Use maybe version",
1197 Compile(Local<String> source,
1198 Local<String> file_name));
1199
1205 V8_DEPRECATE_SOON("Use maybe version", Local<Value> Run());
1207
1212};
1213
1214
1219 public:
1230 BufferOwned
1232
1234 : data(NULL),
1235 length(0),
1236 rejected(false),
1237 buffer_policy(BufferNotOwned) {}
1238
1239 // If buffer_policy is BufferNotOwned, the caller keeps the ownership of
1240 // data and guarantees that it stays alive until the CachedData object is
1241 // destroyed. If the policy is BufferOwned, the given data will be deleted
1242 // (with delete[]) when the CachedData object is destroyed.
1243 CachedData(const uint8_t* data, int length,
1244 BufferPolicy buffer_policy = BufferNotOwned);
1246 // TODO(marja): Async compilation; add constructors which take a callback
1247 // which will be called when V8 no longer needs the data.
1248 const uint8_t* data;
1252
1253 // Prevent copying.
1254 CachedData(const CachedData&) = delete;
1256 };
1257
1261 class Source {
1262 public:
1263 // Source takes ownership of CachedData.
1264 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
1265 CachedData* cached_data = NULL);
1266 V8_INLINE Source(Local<String> source_string,
1267 CachedData* cached_data = NULL);
1269
1270 // Ownership of the CachedData or its buffers is *not* transferred to the
1271 // caller. The CachedData object is alive as long as the Source object is
1272 // alive.
1273 V8_INLINE const CachedData* GetCachedData() const;
1274
1275 V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
1276
1277 // Prevent copying.
1278 Source(const Source&) = delete;
1279 Source& operator=(const Source&) = delete;
1280
1281 private:
1282 friend class ScriptCompiler;
1283
1284 Local<String> source_string;
1285
1286 // Origin information
1287 Local<Value> resource_name;
1288 Local<Integer> resource_line_offset;
1289 Local<Integer> resource_column_offset;
1290 ScriptOriginOptions resource_options;
1291 Local<Value> source_map_url;
1292
1293 // Cached data from previous compilation (if a kConsume*Cache flag is
1294 // set), or hold newly generated cache data (kProduce*Cache flags) are
1295 // set when calling a compile method.
1296 CachedData* cached_data;
1297 };
1298
1304 public:
1306
1324 virtual size_t GetMoreData(const uint8_t** src) = 0;
1325
1336 virtual bool SetBookmark();
1337
1341 virtual void ResetToBookmark();
1342 };
1343
1344
1352 public:
1353 enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
1354
1357
1358 // Ownership of the CachedData or its buffers is *not* transferred to the
1359 // caller. The CachedData object is alive as long as the StreamedSource
1360 // object is alive.
1362
1363 internal::StreamedSource* impl() const { return impl_; }
1364
1365 // Prevent copying.
1368
1369 private:
1370 internal::StreamedSource* impl_;
1371 };
1372
1378 public:
1380 virtual void Run() = 0;
1381 };
1382
1384 kNoCompileOptions = 0,
1388 kConsumeCodeCache
1390
1404 static V8_DEPRECATED("Use maybe version",
1405 Local<UnboundScript> CompileUnbound(
1406 Isolate* isolate, Source* source,
1407 CompileOptions options = kNoCompileOptions));
1409 Isolate* isolate, Source* source,
1410 CompileOptions options = kNoCompileOptions);
1411
1423 static V8_DEPRECATED(
1424 "Use maybe version",
1425 Local<Script> Compile(Isolate* isolate, Source* source,
1426 CompileOptions options = kNoCompileOptions));
1428 Local<Context> context, Source* source,
1429 CompileOptions options = kNoCompileOptions);
1430
1443 Isolate* isolate, StreamedSource* source,
1444 CompileOptions options = kNoCompileOptions);
1445
1453 static V8_DEPRECATED("Use maybe version",
1454 Local<Script> Compile(Isolate* isolate,
1455 StreamedSource* source,
1456 Local<String> full_source_string,
1457 const ScriptOrigin& origin));
1459 Local<Context> context, StreamedSource* source,
1460 Local<String> full_source_string, const ScriptOrigin& origin);
1461
1480 static uint32_t CachedDataVersionTag();
1481
1493 Isolate* isolate, Source* source);
1494
1505 static V8_DEPRECATE_SOON("Use maybe version",
1506 Local<Function> CompileFunctionInContext(
1507 Isolate* isolate, Source* source,
1508 Local<Context> context, size_t arguments_count,
1509 Local<String> arguments[],
1510 size_t context_extension_count,
1511 Local<Object> context_extensions[]));
1513 Local<Context> context, Source* source, size_t arguments_count,
1514 Local<String> arguments[], size_t context_extension_count,
1515 Local<Object> context_extensions[]);
1516
1517 private:
1518 static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
1519 Isolate* isolate, Source* source, CompileOptions options);
1520};
1521
1522
1527 public:
1529
1530 V8_DEPRECATE_SOON("Use maybe version", Local<String> GetSourceLine() const);
1532 Local<Context> context) const;
1533
1539
1545
1552
1556 V8_DEPRECATE_SOON("Use maybe version", int GetLineNumber() const);
1558
1563 int GetStartPosition() const;
1564
1569 int GetEndPosition() const;
1570
1574 int ErrorLevel() const;
1575
1580 V8_DEPRECATE_SOON("Use maybe version", int GetStartColumn() const);
1582
1587 V8_DEPRECATED("Use maybe version", int GetEndColumn() const);
1589
1595 bool IsOpaque() const;
1596
1597 // TODO(1245381): Print to a string instead of on a FILE.
1598 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
1599
1600 static const int kNoLineNumberInfo = 0;
1601 static const int kNoColumnInfo = 0;
1602 static const int kNoScriptIdInfo = 0;
1603};
1604
1605
1612 public:
1620 kLineNumber = 1,
1621 kColumnOffset = 1 << 1 | kLineNumber,
1622 kScriptName = 1 << 2,
1623 kFunctionName = 1 << 3,
1624 kIsEval = 1 << 4,
1625 kIsConstructor = 1 << 5,
1626 kScriptNameOrSourceURL = 1 << 6,
1627 kScriptId = 1 << 7,
1628 kExposeFramesAcrossSecurityOrigins = 1 << 8,
1629 kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
1630 kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
1632
1636 Local<StackFrame> GetFrame(uint32_t index) const;
1637
1641 int GetFrameCount() const;
1642
1646 V8_DEPRECATED("Use native API instead", Local<Array> AsArray());
1647
1656 Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed);
1657};
1658
1659
1664 public:
1671 int GetLineNumber() const;
1672
1680 int GetColumn() const;
1681
1688 int GetScriptId() const;
1689
1695
1703
1708
1713 bool IsEval() const;
1714
1719 bool IsConstructor() const;
1720
1724 bool IsWasm() const;
1725};
1726
1727
1728// A StateTag represents a possible state of the VM.
1737 IDLE
1739
1740// A RegisterState represents the current state of registers used
1741// by the sampling profiler API.
1743 RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {}
1744 void* pc; // Instruction pointer.
1745 void* sp; // Stack pointer.
1746 void* fp; // Frame pointer.
1747};
1748
1749// The output structure filled up by GetStackSample API function.
1751 size_t frames_count; // Number of frames collected.
1752 StateTag vm_state; // Current VM state.
1753 void* external_callback_entry; // External callback address if VM is
1754 // executing an external callback.
1755};
1756
1761 public:
1769 static V8_DEPRECATED("Use the maybe version taking context",
1771 static V8_DEPRECATE_SOON("Use the maybe version taking context",
1772 MaybeLocal<Value> Parse(Isolate* isolate,
1773 Local<String> json_string));
1775 Local<Context> context, Local<String> json_string);
1776
1785 Local<Context> context, Local<Object> json_object,
1787};
1788
1798 public:
1800 public:
1801 virtual ~Delegate() {}
1802
1808 virtual void ThrowDataCloneError(Local<String> message) = 0;
1809
1816
1828 Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
1829
1831 Isolate* isolate, Local<WasmCompiledModule> module);
1841 virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
1842 size_t* actual_size);
1843
1847 virtual void FreeBufferMemory(void* buffer);
1848 };
1849
1850 explicit ValueSerializer(Isolate* isolate);
1851 ValueSerializer(Isolate* isolate, Delegate* delegate);
1853
1858
1863 Local<Value> value);
1864
1869 V8_DEPRECATE_SOON("Use Release()", std::vector<uint8_t> ReleaseBuffer());
1870
1877 V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
1878
1884 void TransferArrayBuffer(uint32_t transfer_id,
1885 Local<ArrayBuffer> array_buffer);
1886
1890 V8_DEPRECATE_SOON("Use Delegate::GetSharedArrayBufferId",
1891 void TransferSharedArrayBuffer(
1892 uint32_t transfer_id,
1893 Local<SharedArrayBuffer> shared_array_buffer));
1894
1903
1909 void WriteUint32(uint32_t value);
1910 void WriteUint64(uint64_t value);
1911 void WriteDouble(double value);
1912 void WriteRawBytes(const void* source, size_t length);
1913
1914 private:
1915 ValueSerializer(const ValueSerializer&) = delete;
1916 void operator=(const ValueSerializer&) = delete;
1917
1918 struct PrivateData;
1919 PrivateData* private_;
1920};
1921
1931 public:
1933 public:
1934 virtual ~Delegate() {}
1935
1942
1948 Isolate* isolate, uint32_t transfer_id);
1949 };
1950
1951 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
1952 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size,
1953 Delegate* delegate);
1955
1961
1966
1971 void TransferArrayBuffer(uint32_t transfer_id,
1972 Local<ArrayBuffer> array_buffer);
1973
1980 Local<SharedArrayBuffer> shared_array_buffer);
1981
1989 void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
1990
1994 void SetExpectInlineWasm(bool allow_inline_wasm);
1995
2001 uint32_t GetWireFormatVersion() const;
2002
2008 V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t* value);
2009 V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t* value);
2011 V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data);
2012
2013 private:
2014 ValueDeserializer(const ValueDeserializer&) = delete;
2015 void operator=(const ValueDeserializer&) = delete;
2016
2017 struct PrivateData;
2018 PrivateData* private_;
2019};
2020
2027 public:
2033};
2034
2035
2036// --- Value ---
2037
2038
2042class V8_EXPORT Value : public Data {
2043 public:
2048 V8_INLINE bool IsUndefined() const;
2049
2054 V8_INLINE bool IsNull() const;
2055
2061 V8_INLINE bool IsNullOrUndefined() const;
2062
2066 bool IsTrue() const;
2067
2071 bool IsFalse() const;
2072
2076 bool IsName() const;
2077
2082 V8_INLINE bool IsString() const;
2083
2087 bool IsSymbol() const;
2088
2092 bool IsFunction() const;
2093
2098 bool IsArray() const;
2099
2103 bool IsObject() const;
2104
2108 bool IsBoolean() const;
2109
2113 bool IsNumber() const;
2114
2118 bool IsExternal() const;
2119
2123 bool IsInt32() const;
2124
2128 bool IsUint32() const;
2129
2133 bool IsDate() const;
2134
2138 bool IsArgumentsObject() const;
2139
2143 bool IsBooleanObject() const;
2144
2148 bool IsNumberObject() const;
2149
2153 bool IsStringObject() const;
2154
2158 bool IsSymbolObject() const;
2159
2163 bool IsNativeError() const;
2164
2168 bool IsRegExp() const;
2169
2173 bool IsAsyncFunction() const;
2174
2179
2183 bool IsGeneratorObject() const;
2184
2188 bool IsPromise() const;
2189
2193 bool IsMap() const;
2194
2198 bool IsSet() const;
2199
2203 bool IsMapIterator() const;
2204
2208 bool IsSetIterator() const;
2209
2213 bool IsWeakMap() const;
2214
2218 bool IsWeakSet() const;
2219
2223 bool IsArrayBuffer() const;
2224
2228 bool IsArrayBufferView() const;
2229
2233 bool IsTypedArray() const;
2234
2238 bool IsUint8Array() const;
2239
2244
2248 bool IsInt8Array() const;
2249
2253 bool IsUint16Array() const;
2254
2258 bool IsInt16Array() const;
2259
2263 bool IsUint32Array() const;
2264
2268 bool IsInt32Array() const;
2269
2273 bool IsFloat32Array() const;
2274
2278 bool IsFloat64Array() const;
2279
2283 bool IsDataView() const;
2284
2290
2294 bool IsProxy() const;
2295
2297
2299 Local<Context> context) const;
2301 Local<Context> context) const;
2303 Local<Context> context) const;
2305 Local<Context> context) const;
2307 Local<Context> context) const;
2309 Local<Context> context) const;
2311 Local<Context> context) const;
2313
2314 V8_DEPRECATE_SOON("Use maybe version",
2316 V8_DEPRECATE_SOON("Use maybe version",
2318 V8_DEPRECATE_SOON("Use maybe version",
2320 V8_DEPRECATED("Use maybe version",
2322 V8_DEPRECATE_SOON("Use maybe version",
2324 V8_DEPRECATE_SOON("Use maybe version",
2326 V8_DEPRECATED("Use maybe version",
2328 V8_DEPRECATE_SOON("Use maybe version",
2329 Local<Int32> ToInt32(Isolate* isolate) const);
2330
2331 inline V8_DEPRECATE_SOON("Use maybe version",
2332 Local<Boolean> ToBoolean() const);
2333 inline V8_DEPRECATED("Use maybe version", Local<Number> ToNumber() const);
2334 inline V8_DEPRECATE_SOON("Use maybe version", Local<String> ToString() const);
2335 inline V8_DEPRECATED("Use maybe version",
2336 Local<String> ToDetailString() const);
2337 inline V8_DEPRECATE_SOON("Use maybe version", Local<Object> ToObject() const);
2338 inline V8_DEPRECATE_SOON("Use maybe version",
2339 Local<Integer> ToInteger() const);
2340 inline V8_DEPRECATED("Use maybe version", Local<Uint32> ToUint32() const);
2341 inline V8_DEPRECATED("Use maybe version", Local<Int32> ToInt32() const);
2342
2347 V8_DEPRECATED("Use maybe version", Local<Uint32> ToArrayIndex() const);
2349 Local<Context> context) const;
2350
2354 Local<Context> context) const;
2356 Local<Context> context) const;
2358
2359 V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue() const);
2360 V8_DEPRECATE_SOON("Use maybe version", double NumberValue() const);
2361 V8_DEPRECATE_SOON("Use maybe version", int64_t IntegerValue() const);
2362 V8_DEPRECATE_SOON("Use maybe version", uint32_t Uint32Value() const);
2363 V8_DEPRECATE_SOON("Use maybe version", int32_t Int32Value() const);
2364
2366 V8_DEPRECATE_SOON("Use maybe version", bool Equals(Local<Value> that) const);
2368 Local<Value> that) const;
2369 bool StrictEquals(Local<Value> that) const;
2370 bool SameValue(Local<Value> that) const;
2371
2372 template <class T> V8_INLINE static Value* Cast(T* value);
2373
2375
2377
2378 private:
2379 V8_INLINE bool QuickIsUndefined() const;
2380 V8_INLINE bool QuickIsNull() const;
2381 V8_INLINE bool QuickIsNullOrUndefined() const;
2382 V8_INLINE bool QuickIsString() const;
2383 bool FullIsUndefined() const;
2384 bool FullIsNull() const;
2385 bool FullIsString() const;
2386};
2387
2388
2392class V8_EXPORT Primitive : public Value { };
2393
2394
2400 public:
2401 bool Value() const;
2402 V8_INLINE static Boolean* Cast(v8::Value* obj);
2403 V8_INLINE static Local<Boolean> New(Isolate* isolate, bool value);
2404
2405 private:
2406 static void CheckCast(v8::Value* obj);
2407};
2408
2409
2413class V8_EXPORT Name : public Primitive {
2414 public:
2423
2424 V8_INLINE static Name* Cast(Value* obj);
2425
2426 private:
2427 static void CheckCast(Value* obj);
2428};
2429
2436enum class NewStringType {
2440 kNormal,
2441
2448};
2449
2453class V8_EXPORT String : public Name {
2454 public:
2455 static constexpr int kMaxLength =
2456 sizeof(void*) == 4 ? (1 << 28) - 16 : (1 << 30) - 1 - 24;
2457
2459 UNKNOWN_ENCODING = 0x1,
2460 TWO_BYTE_ENCODING = 0x0,
2461 ONE_BYTE_ENCODING = 0x8
2466 int Length() const;
2467
2472 int Utf8Length() const;
2473
2480 bool IsOneByte() const;
2481
2488
2515 NO_OPTIONS = 0,
2516 HINT_MANY_WRITES_EXPECTED = 1,
2517 NO_NULL_TERMINATION = 2,
2518 PRESERVE_ONE_BYTE_NULL = 4,
2519 // Used by WriteUtf8 to replace orphan surrogate code units with the
2520 // unicode replacement character. Needs to be set to guarantee valid UTF-8
2521 // output.
2522 REPLACE_INVALID_UTF8 = 8
2524
2525 // 16-bit character codes.
2526 int Write(uint16_t* buffer,
2527 int start = 0,
2528 int length = -1,
2529 int options = NO_OPTIONS) const;
2530 // One byte characters.
2531 int WriteOneByte(uint8_t* buffer,
2532 int start = 0,
2533 int length = -1,
2534 int options = NO_OPTIONS) const;
2535 // UTF-8 encoded characters.
2536 int WriteUtf8(char* buffer,
2537 int length = -1,
2538 int* nchars_ref = NULL,
2539 int options = NO_OPTIONS) const;
2540
2544 V8_INLINE static Local<String> Empty(Isolate* isolate);
2545
2549 bool IsExternal() const;
2550
2554 bool IsExternalOneByte() const;
2555
2557 public:
2559
2560 virtual bool IsCompressible() const { return false; }
2561
2562 protected:
2564
2571 virtual void Dispose() { delete this; }
2572
2573 // Disallow copying and assigning.
2576
2577 private:
2578 friend class internal::Heap;
2579 friend class v8::String;
2580 };
2581
2590 public:
2596
2600 virtual const uint16_t* data() const = 0;
2601
2605 virtual size_t length() const = 0;
2606
2607 protected:
2609 };
2610
2623 public:
2630 virtual const char* data() const = 0;
2632 virtual size_t length() const = 0;
2633 protected:
2635 };
2636
2642 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
2643 Encoding* encoding_out) const;
2644
2649 V8_INLINE ExternalStringResource* GetExternalStringResource() const;
2650
2656
2657 V8_INLINE static String* Cast(v8::Value* obj);
2658
2659 // TODO(dcarney): remove with deprecation of New functions.
2661 kNormalString = static_cast<int>(v8::NewStringType::kNormal),
2662 kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
2664
2666 static V8_DEPRECATE_SOON(
2667 "Use maybe version",
2668 Local<String> NewFromUtf8(Isolate* isolate, const char* data,
2669 NewStringType type = kNormalString,
2670 int length = -1));
2671
2675 Isolate* isolate, const char* data, v8::NewStringType type,
2676 int length = -1);
2677
2679 static V8_DEPRECATED(
2680 "Use maybe version",
2681 Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data,
2682 NewStringType type = kNormalString,
2683 int length = -1));
2684
2688 Isolate* isolate, const uint8_t* data, v8::NewStringType type,
2689 int length = -1);
2690
2692 static V8_DEPRECATE_SOON(
2693 "Use maybe version",
2694 Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data,
2695 NewStringType type = kNormalString,
2696 int length = -1));
2697
2701 Isolate* isolate, const uint16_t* data, v8::NewStringType type,
2702 int length = -1);
2703
2709
2718 static V8_DEPRECATED("Use maybe version",
2719 Local<String> NewExternal(
2720 Isolate* isolate, ExternalStringResource* resource));
2722 Isolate* isolate, ExternalStringResource* resource);
2723
2734
2743 static V8_DEPRECATE_SOON(
2744 "Use maybe version",
2745 Local<String> NewExternal(Isolate* isolate,
2748 Isolate* isolate, ExternalOneByteStringResource* resource);
2749
2760
2765
2774 public:
2775 V8_DEPRECATE_SOON("Use Isolate version",
2779 char* operator*() { return str_; }
2780 const char* operator*() const { return str_; }
2781 int length() const { return length_; }
2782
2783 // Disallow copying and assigning.
2784 Utf8Value(const Utf8Value&) = delete;
2785 void operator=(const Utf8Value&) = delete;
2786
2787 private:
2788 char* str_;
2789 int length_;
2790 };
2791
2799 public:
2800 V8_DEPRECATE_SOON("Use Isolate version",
2801 explicit Value(Local<v8::Value> obj));
2804 uint16_t* operator*() { return str_; }
2805 const uint16_t* operator*() const { return str_; }
2806 int length() const { return length_; }
2807
2808 // Disallow copying and assigning.
2809 Value(const Value&) = delete;
2810 void operator=(const Value&) = delete;
2811
2812 private:
2813 uint16_t* str_;
2814 int length_;
2815 };
2816
2817 private:
2818 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
2819 Encoding encoding) const;
2820 void VerifyExternalStringResource(ExternalStringResource* val) const;
2821 static void CheckCast(v8::Value* obj);
2822};
2823
2824
2828class V8_EXPORT Symbol : public Name {
2829 public:
2834
2838 static Local<Symbol> New(Isolate* isolate,
2839 Local<String> name = Local<String>());
2840
2848 static Local<Symbol> For(Isolate *isolate, Local<String> name);
2849
2855
2856 // Well-known symbols
2867
2868 V8_INLINE static Symbol* Cast(Value* obj);
2869
2870 private:
2871 Symbol();
2872 static void CheckCast(Value* obj);
2873};
2874
2875
2881class V8_EXPORT Private : public Data {
2882 public:
2887
2891 static Local<Private> New(Isolate* isolate,
2892 Local<String> name = Local<String>());
2893
2904
2905 private:
2906 Private();
2907};
2908
2909
2914 public:
2915 double Value() const;
2916 static Local<Number> New(Isolate* isolate, double value);
2917 V8_INLINE static Number* Cast(v8::Value* obj);
2918 private:
2919 Number();
2920 static void CheckCast(v8::Value* obj);
2921};
2922
2923
2927class V8_EXPORT Integer : public Number {
2928 public:
2929 static Local<Integer> New(Isolate* isolate, int32_t value);
2930 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
2931 int64_t Value() const;
2932 V8_INLINE static Integer* Cast(v8::Value* obj);
2933 private:
2934 Integer();
2935 static void CheckCast(v8::Value* obj);
2936};
2937
2938
2942class V8_EXPORT Int32 : public Integer {
2943 public:
2944 int32_t Value() const;
2945 V8_INLINE static Int32* Cast(v8::Value* obj);
2946
2947 private:
2948 Int32();
2949 static void CheckCast(v8::Value* obj);
2950};
2951
2952
2956class V8_EXPORT Uint32 : public Integer {
2957 public:
2958 uint32_t Value() const;
2959 V8_INLINE static Uint32* Cast(v8::Value* obj);
2960
2961 private:
2962 Uint32();
2963 static void CheckCast(v8::Value* obj);
2964};
2965
2971 None = 0,
2973 ReadOnly = 1 << 0,
2975 DontEnum = 1 << 1,
2977 DontDelete = 1 << 2
2979
2986 Local<String> property,
2987 const PropertyCallbackInfo<Value>& info);
2989 Local<Name> property,
2990 const PropertyCallbackInfo<Value>& info);
2991
2992
2994 Local<String> property,
2995 Local<Value> value,
2996 const PropertyCallbackInfo<void>& info);
2998 Local<Name> property,
2999 Local<Value> value,
3000 const PropertyCallbackInfo<void>& info);
3001
3002
3016 PROHIBITS_OVERWRITING = 1 << 2
3018
3028 SKIP_SYMBOLS = 16
3030
3039
3045
3050
3054class V8_EXPORT Object : public Value {
3055 public:
3056 V8_DEPRECATE_SOON("Use maybe version",
3057 bool Set(Local<Value> key, Local<Value> value));
3059 Local<Value> key, Local<Value> value);
3060
3061 V8_DEPRECATE_SOON("Use maybe version",
3062 bool Set(uint32_t index, Local<Value> value));
3064 Local<Value> value);
3065
3066 // Implements CreateDataProperty (ECMA-262, 7.3.4).
3067 //
3068 // Defines a configurable, writable, enumerable property with the given value
3069 // on the object unless the property already exists and is not configurable
3070 // or the object is not extensible.
3071 //
3072 // Returns true on success.
3074 Local<Name> key,
3075 Local<Value> value);
3077 uint32_t index,
3078 Local<Value> value);
3079
3080 // Implements DefineOwnProperty.
3081 //
3082 // In general, CreateDataProperty will be faster, however, does not allow
3083 // for specifying attributes.
3084 //
3085 // Returns true on success.
3087 Local<Context> context, Local<Name> key, Local<Value> value,
3088 PropertyAttribute attributes = None);
3089
3090 // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4.
3091 //
3092 // The defineProperty function is used to add an own property or
3093 // update the attributes of an existing own property of an object.
3094 //
3095 // Both data and accessor descriptors can be used.
3096 //
3097 // In general, CreateDataProperty is faster, however, does not allow
3098 // for specifying attributes or an accessor descriptor.
3099 //
3100 // The PropertyDescriptor can change when redefining a property.
3101 //
3102 // Returns true on success.
3104 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
3105
3106 // Sets an own property on this object bypassing interceptors and
3107 // overriding accessors or read-only properties.
3108 //
3109 // Note that if the object has an interceptor the property will be set
3110 // locally, but since the interceptor takes precedence the local property
3111 // will only be returned if the interceptor doesn't return a value.
3112 //
3113 // Note also that this only works for named properties.
3114 V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty",
3115 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
3116 Local<Value> value,
3117 PropertyAttribute attribs = None));
3118
3121 Local<Value> key);
3122
3123 V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index));
3125 uint32_t index);
3126
3132 V8_DEPRECATED("Use maybe version",
3135 Local<Context> context, Local<Value> key);
3136
3140 V8_DEPRECATED("Use maybe version",
3143 Local<Context> context, Local<Name> key);
3144
3145 V8_DEPRECATE_SOON("Use maybe version", bool Has(Local<Value> key));
3162 Local<Value> key);
3163
3164 V8_DEPRECATE_SOON("Use maybe version", bool Delete(Local<Value> key));
3166 Local<Value> key);
3167
3168 V8_DEPRECATED("Use maybe version", bool Has(uint32_t index));
3170 uint32_t index);
3171
3172 V8_DEPRECATED("Use maybe version", bool Delete(uint32_t index));
3174 uint32_t index);
3175
3176 V8_DEPRECATED("Use maybe version",
3177 bool SetAccessor(Local<String> name,
3178 AccessorGetterCallback getter,
3179 AccessorSetterCallback setter = 0,
3180 Local<Value> data = Local<Value>(),
3181 AccessControl settings = DEFAULT,
3182 PropertyAttribute attribute = None));
3183 V8_DEPRECATED("Use maybe version",
3184 bool SetAccessor(Local<Name> name,
3185 AccessorNameGetterCallback getter,
3186 AccessorNameSetterCallback setter = 0,
3187 Local<Value> data = Local<Value>(),
3188 AccessControl settings = DEFAULT,
3189 PropertyAttribute attribute = None));
3191 Local<Name> name,
3192 AccessorNameGetterCallback getter,
3193 AccessorNameSetterCallback setter = 0,
3195 AccessControl settings = DEFAULT,
3196 PropertyAttribute attribute = None);
3197
3200 PropertyAttribute attribute = None,
3201 AccessControl settings = DEFAULT);
3202
3208 Local<Context> context, Local<Name> name,
3209 AccessorNameGetterCallback getter,
3210 AccessorNameSetterCallback setter = nullptr,
3211 Local<Value> data = Local<Value>(), PropertyAttribute attributes = None);
3212
3221 Local<Value> value);
3224
3233 Local<Context> context);
3235 Local<Context> context, KeyCollectionMode mode,
3236 PropertyFilter property_filter, IndexFilter index_filter);
3237
3245 Local<Context> context);
3246
3254 Local<Context> context, PropertyFilter filter);
3255
3262
3268 V8_DEPRECATED("Use maybe version", bool SetPrototype(Local<Value> prototype));
3270 Local<Value> prototype);
3271
3277
3285 Local<Context> context);
3286
3291
3296
3299
3302 const PersistentBase<Object>& object) {
3303 return object.val_->InternalFieldCount();
3304 }
3305
3307 V8_INLINE Local<Value> GetInternalField(int index);
3308
3310 void SetInternalField(int index, Local<Value> value);
3311
3317 V8_INLINE void* GetAlignedPointerFromInternalField(int index);
3318
3321 const PersistentBase<Object>& object, int index) {
3322 return object.val_->GetAlignedPointerFromInternalField(index);
3323 }
3324
3330 void SetAlignedPointerInInternalField(int index, void* value);
3331 void SetAlignedPointerInInternalFields(int argc, int indices[],
3332 void* values[]);
3333
3334 // Testers for local properties.
3335 V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key));
3336
3343 Local<Name> key);
3345 uint32_t index);
3346 V8_DEPRECATE_SOON("Use maybe version",
3362 Local<Name> key);
3363 V8_DEPRECATE_SOON("Use maybe version",
3364 bool HasRealIndexedProperty(uint32_t index));
3366 Local<Context> context, uint32_t index);
3367 V8_DEPRECATE_SOON("Use maybe version",
3370 Local<Context> context, Local<Name> key);
3371
3377 "Use maybe version",
3380 Local<Context> context, Local<Name> key);
3381
3388 "Use maybe version",
3389 Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
3393 Local<Name> key);
3394
3400 V8_DEPRECATED("Use maybe version",
3403 Local<Context> context, Local<Name> key);
3404
3410 V8_DEPRECATED("Use maybe version",
3411 Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
3414 Local<Context> context, Local<Name> key);
3415
3418
3421
3430
3435 // TODO(dcarney): take an isolate and optionally bail out?
3437
3442
3445 const PersistentBase<Object>& object) {
3446 return object.val_->CreationContext();
3447 }
3448
3455
3460
3465 V8_DEPRECATED("Use maybe version",
3466 Local<Value> CallAsFunction(Local<Value> recv, int argc,
3469 Local<Value> recv,
3470 int argc,
3471 Local<Value> argv[]);
3472
3478 V8_DEPRECATED("Use maybe version",
3481 Local<Context> context, int argc, Local<Value> argv[]);
3482
3486 V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate());
3487
3488 static Local<Object> New(Isolate* isolate);
3489
3490 V8_INLINE static Object* Cast(Value* obj);
3491
3492 private:
3493 Object();
3494 static void CheckCast(Value* obj);
3495 Local<Value> SlowGetInternalField(int index);
3496 void* SlowGetAlignedPointerFromInternalField(int index);
3497};
3498
3499
3503class V8_EXPORT Array : public Object {
3504 public:
3505 uint32_t Length() const;
3506
3511 V8_DEPRECATED("Cloning is not supported.",
3513 V8_DEPRECATED("Cloning is not supported.",
3514 MaybeLocal<Object> CloneElementAt(Local<Context> context,
3515 uint32_t index));
3516
3521 static Local<Array> New(Isolate* isolate, int length = 0);
3522
3523 V8_INLINE static Array* Cast(Value* obj);
3524 private:
3525 Array();
3526 static void CheckCast(Value* obj);
3527};
3528
3529
3533class V8_EXPORT Map : public Object {
3534 public:
3535 size_t Size() const;
3536 void Clear();
3538 Local<Value> key);
3540 Local<Value> key,
3541 Local<Value> value);
3543 Local<Value> key);
3545 Local<Value> key);
3546
3552
3556 static Local<Map> New(Isolate* isolate);
3557
3558 V8_INLINE static Map* Cast(Value* obj);
3559
3560 private:
3561 Map();
3562 static void CheckCast(Value* obj);
3563};
3564
3565
3569class V8_EXPORT Set : public Object {
3570 public:
3571 size_t Size() const;
3572 void Clear();
3574 Local<Value> key);
3576 Local<Value> key);
3578 Local<Value> key);
3579
3584
3588 static Local<Set> New(Isolate* isolate);
3589
3590 V8_INLINE static Set* Cast(Value* obj);
3591
3592 private:
3593 Set();
3594 static void CheckCast(Value* obj);
3595};
3596
3597
3598template<typename T>
3600 public:
3601 template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
3602 : value_(that.value_) {
3603 TYPE_CHECK(T, S);
3604 }
3605 // Local setters
3606 template <typename S>
3607 V8_INLINE V8_DEPRECATE_SOON("Use Global<> instead",
3608 void Set(const Persistent<S>& handle));
3609 template <typename S>
3610 V8_INLINE void Set(const Global<S>& handle);
3611 template <typename S>
3612 V8_INLINE void Set(const Local<S> handle);
3613 // Fast primitive setters
3614 V8_INLINE void Set(bool value);
3615 V8_INLINE void Set(double i);
3616 V8_INLINE void Set(int32_t i);
3617 V8_INLINE void Set(uint32_t i);
3618 // Fast JS primitive setters
3619 V8_INLINE void SetNull();
3620 V8_INLINE void SetUndefined();
3622 // Convenience getter for Isolate
3623 V8_INLINE Isolate* GetIsolate() const;
3624
3625 // Pointer setter: Uncompilable to prevent inadvertent misuse.
3626 template <typename S>
3627 V8_INLINE void Set(S* whatever);
3628
3629 // Getter. Creates a new Local<> so it comes with a certain performance
3630 // hit. If the ReturnValue was not yet set, this will return the undefined
3631 // value.
3632 V8_INLINE Local<Value> Get() const;
3633
3634 private:
3635 template<class F> friend class ReturnValue;
3636 template<class F> friend class FunctionCallbackInfo;
3637 template<class F> friend class PropertyCallbackInfo;
3638 template <class F, class G, class H>
3640 V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; }
3641 V8_INLINE internal::Object* GetDefaultValue();
3642 V8_INLINE explicit ReturnValue(internal::Object** slot);
3643 internal::Object** value_;
3644};
3645
3646
3653template<typename T>
3655 public:
3657 V8_INLINE int Length() const;
3659 V8_INLINE Local<Value> operator[](int i) const;
3660 V8_INLINE V8_DEPRECATED("Use Data() to explicitly pass Callee instead",
3661 Local<Function> Callee() const);
3678 V8_INLINE bool IsConstructCall() const;
3680 V8_INLINE Local<Value> Data() const;
3682 V8_INLINE Isolate* GetIsolate() const;
3685 // This shouldn't be public, but the arm compiler needs it.
3686 static const int kArgsLength = 8;
3687
3688 protected:
3692 static const int kHolderIndex = 0;
3693 static const int kIsolateIndex = 1;
3694 static const int kReturnValueDefaultValueIndex = 2;
3695 static const int kReturnValueIndex = 3;
3696 static const int kDataIndex = 4;
3697 static const int kCalleeIndex = 5;
3698 static const int kContextSaveIndex = 6;
3699 static const int kNewTargetIndex = 7;
3700
3701 V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
3702 internal::Object** values, int length);
3703 internal::Object** implicit_args_;
3704 internal::Object** values_;
3706};
3707
3708
3713template<typename T>
3715 public:
3720
3727
3770
3781
3791
3800
3801 // This shouldn't be public, but the arm compiler needs it.
3802 static const int kArgsLength = 7;
3803
3804 protected:
3805 friend class MacroAssembler;
3808 static const int kShouldThrowOnErrorIndex = 0;
3809 static const int kHolderIndex = 1;
3810 static const int kIsolateIndex = 2;
3811 static const int kReturnValueDefaultValueIndex = 3;
3812 static const int kReturnValueIndex = 4;
3813 static const int kDataIndex = 5;
3814 static const int kThisIndex = 6;
3815
3816 V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
3817 internal::Object** args_;
3818};
3819
3820
3822
3824
3828class V8_EXPORT Function : public Object {
3829 public:
3835 Local<Context> context, FunctionCallback callback,
3836 Local<Value> data = Local<Value>(), int length = 0,
3837 ConstructorBehavior behavior = ConstructorBehavior::kAllow);
3838 static V8_DEPRECATE_SOON(
3839 "Use maybe version",
3840 Local<Function> New(Isolate* isolate, FunctionCallback callback,
3841 Local<Value> data = Local<Value>(), int length = 0));
3842
3843 V8_DEPRECATED("Use maybe version",
3844 Local<Object> NewInstance(int argc, Local<Value> argv[]) const);
3846 Local<Context> context, int argc, Local<Value> argv[]) const;
3847
3848 V8_DEPRECATED("Use maybe version", Local<Object> NewInstance() const);
3850 Local<Context> context) const {
3851 return NewInstance(context, 0, nullptr);
3852 }
3853
3854 V8_DEPRECATE_SOON("Use maybe version",
3855 Local<Value> Call(Local<Value> recv, int argc,
3858 Local<Value> recv, int argc,
3859 Local<Value> argv[]);
3860
3863
3871
3877
3883
3894
3898 V8_DEPRECATED("this should no longer be used.", bool IsBuiltin() const);
3899
3903 int ScriptId() const;
3904
3910
3912 V8_INLINE static Function* Cast(Value* obj);
3913 static const int kLineOffsetNotFound;
3914
3915 private:
3916 Function();
3917 static void CheckCast(Value* obj);
3918};
3919
3920#ifndef V8_PROMISE_INTERNAL_FIELD_COUNT
3921// The number of required internal fields can be defined by embedder.
3922#define V8_PROMISE_INTERNAL_FIELD_COUNT 0
3923#endif
3924
3928class V8_EXPORT Promise : public Object {
3929 public:
3934 enum PromiseState { kPending, kFulfilled, kRejected };
3935
3936 class V8_EXPORT Resolver : public Object {
3937 public:
3941 static V8_DEPRECATE_SOON("Use maybe version",
3944 Local<Context> context);
3945
3950
3955 V8_DEPRECATE_SOON("Use maybe version", void Resolve(Local<Value> value));
3957 Local<Value> value);
3958
3959 V8_DEPRECATE_SOON("Use maybe version", void Reject(Local<Value> value));
3961 Local<Value> value);
3962
3963 V8_INLINE static Resolver* Cast(Value* obj);
3964
3965 private:
3966 Resolver();
3967 static void CheckCast(Value* obj);
3968 };
3969
3976 V8_DEPRECATED("Use maybe version",
3979 Local<Function> handler);
3980
3981 V8_DEPRECATED("Use maybe version",
3984 Local<Function> handler);
3985
3991
3997
4002
4003 V8_INLINE static Promise* Cast(Value* obj);
4004
4005 static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT;
4006
4007 private:
4008 Promise();
4009 static void CheckCast(Value* obj);
4010};
4011
4041 public:
4042 // GenericDescriptor
4044
4045 // DataDescriptor
4047
4048 // DataDescriptor with writable property
4049 PropertyDescriptor(Local<Value> value, bool writable);
4050
4051 // AccessorDescriptor
4053
4055
4057 bool has_value() const;
4058
4060 bool has_get() const;
4062 bool has_set() const;
4063
4064 void set_enumerable(bool enumerable);
4065 bool enumerable() const;
4066 bool has_enumerable() const;
4067
4068 void set_configurable(bool configurable);
4069 bool configurable() const;
4070 bool has_configurable() const;
4071
4072 bool writable() const;
4073 bool has_writable() const;
4074
4075 struct PrivateData;
4076 PrivateData* get_private() const { return private_; }
4077
4079 void operator=(const PropertyDescriptor&) = delete;
4080
4081 private:
4082 PrivateData* private_;
4083};
4084
4089class V8_EXPORT Proxy : public Object {
4090 public:
4094 void Revoke();
4095
4100 Local<Object> local_target,
4101 Local<Object> local_handler);
4102
4103 V8_INLINE static Proxy* Cast(Value* obj);
4104
4105 private:
4106 Proxy();
4107 static void CheckCast(Value* obj);
4108};
4109
4110// TODO(mtrofin): rename WasmCompiledModule to WasmModuleObject, for
4111// consistency with internal APIs.
4113 public:
4114 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule;
4115 // A buffer that is owned by the caller.
4116 typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer;
4117
4118 // An opaque, native heap object for transferring wasm modules. It
4119 // supports move semantics, and does not support copy semantics.
4121 public:
4124
4127
4128 private:
4129 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer;
4131 TransferrableModule(OwnedBuffer&& code, OwnedBuffer&& bytes)
4132 : compiled_code(std::move(code)), wire_bytes(std::move(bytes)) {}
4133
4134 OwnedBuffer compiled_code = {nullptr, 0};
4135 OwnedBuffer wire_bytes = {nullptr, 0};
4136 };
4137
4138 // Get an in-memory, non-persistable, and context-independent (meaning,
4139 // suitable for transfer to another Isolate and Context) representation
4140 // of this wasm compiled module.
4142
4143 // Efficiently re-create a WasmCompiledModule, without recompiling, from
4144 // a TransferrableModule.
4146 Isolate* isolate, const TransferrableModule&);
4147
4148 // Get the wasm-encoded bytes that were used to compile this module.
4150
4151 // Serialize the compiled module. The serialized data does not include the
4152 // uncompiled bytes.
4154
4155 // If possible, deserialize the module, otherwise compile it from the provided
4156 // uncompiled bytes.
4158 Isolate* isolate, const CallerOwnedBuffer& serialized_module,
4159 const CallerOwnedBuffer& wire_bytes);
4160 V8_INLINE static WasmCompiledModule* Cast(Value* obj);
4161
4162 private:
4163 // TODO(ahaas): please remove the friend once streamed compilation is
4164 // implemented
4166
4167 static MaybeLocal<WasmCompiledModule> Deserialize(
4168 Isolate* isolate, const CallerOwnedBuffer& serialized_module,
4169 const CallerOwnedBuffer& wire_bytes);
4170 static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate,
4171 const uint8_t* start,
4172 size_t length);
4173 static CallerOwnedBuffer AsCallerOwned(
4174 const TransferrableModule::OwnedBuffer& buff) {
4175 return {buff.first.get(), buff.second};
4176 }
4177
4178 WasmCompiledModule();
4179 static void CheckCast(Value* obj);
4180};
4181
4182// TODO(mtrofin): when streaming compilation is done, we can rename this
4183// to simply WasmModuleObjectBuilder
4185 public:
4187 // The buffer passed into OnBytesReceived is owned by the caller.
4188 void OnBytesReceived(const uint8_t*, size_t size);
4189 void Finish();
4190 void Abort(Local<Value> exception);
4192
4194
4195 private:
4196 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> Buffer;
4197
4199 delete;
4201 default;
4203 const WasmModuleObjectBuilderStreaming&) = delete;
4206 Isolate* isolate_ = nullptr;
4207
4208#if V8_CC_MSVC
4209 // We don't need the static Copy API, so the default
4210 // NonCopyablePersistentTraits would be sufficient, however,
4211 // MSVC eagerly instantiates the Copy.
4212 // We ensure we don't use Copy, however, by compiling with the
4213 // defaults everywhere else.
4215#else
4216 Persistent<Promise> promise_;
4217#endif
4218 std::vector<Buffer> received_buffers_;
4219 size_t total_size_ = 0;
4220};
4221
4223 public:
4224 WasmModuleObjectBuilder(Isolate* isolate) : isolate_(isolate) {}
4225 // The buffer passed into OnBytesReceived is owned by the caller.
4226 void OnBytesReceived(const uint8_t*, size_t size);
4228
4229 private:
4230 Isolate* isolate_ = nullptr;
4231 // TODO(ahaas): We probably need none of this below here once streamed
4232 // compilation is implemented.
4233 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> Buffer;
4234
4235 // Disable copy semantics *in this implementation*. We can choose to
4236 // relax this, albeit it's not clear why.
4239 WasmModuleObjectBuilder& operator=(const WasmModuleObjectBuilder&) = delete;
4240 WasmModuleObjectBuilder& operator=(WasmModuleObjectBuilder&&) = default;
4241
4242 std::vector<Buffer> received_buffers_;
4243 size_t total_size_ = 0;
4244};
4245
4246#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
4247// The number of required internal fields can be defined by embedder.
4248#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
4249#endif
4250
4251
4253
4254
4259 public:
4275 class V8_EXPORT Allocator { // NOLINT
4276 public:
4277 virtual ~Allocator() {}
4278
4283 virtual void* Allocate(size_t length) = 0;
4284
4289 virtual void* AllocateUninitialized(size_t length) = 0;
4290
4295 // TODO(eholk): make this pure virtual once blink implements this.
4296 virtual void* Reserve(size_t length);
4297
4302 virtual void Free(void* data, size_t length) = 0;
4303
4304 enum class AllocationMode { kNormal, kReservation };
4305
4311 // TODO(eholk): make this pure virtual once blink implements this.
4312 virtual void Free(void* data, size_t length, AllocationMode mode);
4313
4314 enum class Protection { kNoAccess, kReadWrite };
4315
4323 // TODO(eholk): make this pure virtual once blink implements this.
4324 virtual void SetProtection(void* data, size_t length,
4325 Protection protection);
4326
4334 };
4335
4344 class V8_EXPORT Contents { // NOLINT
4345 public:
4347 : data_(nullptr),
4348 byte_length_(0),
4349 allocation_base_(nullptr),
4350 allocation_length_(0),
4351 allocation_mode_(Allocator::AllocationMode::kNormal) {}
4352
4353 void* AllocationBase() const { return allocation_base_; }
4354 size_t AllocationLength() const { return allocation_length_; }
4356 return allocation_mode_;
4357 }
4358
4359 void* Data() const { return data_; }
4360 size_t ByteLength() const { return byte_length_; }
4361
4362 private:
4363 void* data_;
4364 size_t byte_length_;
4365 void* allocation_base_;
4366 size_t allocation_length_;
4367 Allocator::AllocationMode allocation_mode_;
4368
4369 friend class ArrayBuffer;
4370 };
4371
4372
4376 size_t ByteLength() const;
4377
4384 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length);
4385
4396 Isolate* isolate, void* data, size_t byte_length,
4397 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
4398
4403 bool IsExternal() const;
4404
4408 bool IsNeuterable() const;
4409
4416 void Neuter();
4417
4428
4440
4441 V8_INLINE static ArrayBuffer* Cast(Value* obj);
4442
4443 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
4444 static const int kEmbedderFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
4445
4446 private:
4447 ArrayBuffer();
4448 static void CheckCast(Value* obj);
4449};
4450
4451
4452#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
4453// The number of required internal fields can be defined by embedder.
4454#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2
4455#endif
4456
4457
4463 public:
4471 size_t ByteOffset();
4475 size_t ByteLength();
4476
4486 size_t CopyContents(void* dest, size_t byte_length);
4487
4492 bool HasBuffer() const;
4493
4494 V8_INLINE static ArrayBufferView* Cast(Value* obj);
4495
4496 static const int kInternalFieldCount =
4498 static const int kEmbedderFieldCount =
4500
4501 private:
4503 static void CheckCast(Value* obj);
4504};
4505
4506
4512 public:
4513 /*
4514 * The largest typed array size that can be constructed using New.
4515 */
4516 static constexpr size_t kMaxLength =
4517 sizeof(void*) == 4 ? (1u << 30) - 1 : (1u << 31) - 1;
4518
4523 size_t Length();
4524
4525 V8_INLINE static TypedArray* Cast(Value* obj);
4526
4527 private:
4528 TypedArray();
4529 static void CheckCast(Value* obj);
4530};
4531
4532
4537 public:
4539 size_t byte_offset, size_t length);
4541 size_t byte_offset, size_t length);
4542 V8_INLINE static Uint8Array* Cast(Value* obj);
4543
4544 private:
4545 Uint8Array();
4546 static void CheckCast(Value* obj);
4547};
4548
4549
4554 public:
4556 size_t byte_offset, size_t length);
4558 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset,
4559 size_t length);
4560 V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
4561
4562 private:
4564 static void CheckCast(Value* obj);
4565};
4566
4571 public:
4573 size_t byte_offset, size_t length);
4575 size_t byte_offset, size_t length);
4576 V8_INLINE static Int8Array* Cast(Value* obj);
4577
4578 private:
4579 Int8Array();
4580 static void CheckCast(Value* obj);
4581};
4582
4583
4588 public:
4590 size_t byte_offset, size_t length);
4592 size_t byte_offset, size_t length);
4593 V8_INLINE static Uint16Array* Cast(Value* obj);
4594
4595 private:
4596 Uint16Array();
4597 static void CheckCast(Value* obj);
4598};
4599
4600
4605 public:
4607 size_t byte_offset, size_t length);
4609 size_t byte_offset, size_t length);
4610 V8_INLINE static Int16Array* Cast(Value* obj);
4611
4612 private:
4613 Int16Array();
4614 static void CheckCast(Value* obj);
4615};
4616
4617
4622 public:
4624 size_t byte_offset, size_t length);
4626 size_t byte_offset, size_t length);
4627 V8_INLINE static Uint32Array* Cast(Value* obj);
4628
4629 private:
4630 Uint32Array();
4631 static void CheckCast(Value* obj);
4632};
4633
4634
4639 public:
4641 size_t byte_offset, size_t length);
4643 size_t byte_offset, size_t length);
4644 V8_INLINE static Int32Array* Cast(Value* obj);
4645
4646 private:
4647 Int32Array();
4648 static void CheckCast(Value* obj);
4649};
4650
4651
4656 public:
4658 size_t byte_offset, size_t length);
4660 size_t byte_offset, size_t length);
4661 V8_INLINE static Float32Array* Cast(Value* obj);
4662
4663 private:
4664 Float32Array();
4665 static void CheckCast(Value* obj);
4666};
4667
4668
4673 public:
4675 size_t byte_offset, size_t length);
4677 size_t byte_offset, size_t length);
4678 V8_INLINE static Float64Array* Cast(Value* obj);
4679
4680 private:
4681 Float64Array();
4682 static void CheckCast(Value* obj);
4683};
4684
4685
4690 public:
4692 size_t byte_offset, size_t length);
4694 size_t byte_offset, size_t length);
4695 V8_INLINE static DataView* Cast(Value* obj);
4696
4697 private:
4698 DataView();
4699 static void CheckCast(Value* obj);
4700};
4701
4702
4708 public:
4720 class V8_EXPORT Contents { // NOLINT
4721 public:
4723 : data_(nullptr),
4724 byte_length_(0),
4725 allocation_base_(nullptr),
4726 allocation_length_(0),
4727 allocation_mode_(ArrayBuffer::Allocator::AllocationMode::kNormal) {}
4728
4729 void* AllocationBase() const { return allocation_base_; }
4730 size_t AllocationLength() const { return allocation_length_; }
4732 return allocation_mode_;
4733 }
4734
4735 void* Data() const { return data_; }
4736 size_t ByteLength() const { return byte_length_; }
4737
4738 private:
4739 void* data_;
4740 size_t byte_length_;
4741 void* allocation_base_;
4742 size_t allocation_length_;
4744
4745 friend class SharedArrayBuffer;
4746 };
4747
4748
4752 size_t ByteLength() const;
4753
4760 static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length);
4761
4769 Isolate* isolate, void* data, size_t byte_length,
4770 ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
4771
4776 bool IsExternal() const;
4777
4791
4805
4806 V8_INLINE static SharedArrayBuffer* Cast(Value* obj);
4807
4808 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT;
4809
4810 private:
4812 static void CheckCast(Value* obj);
4813};
4814
4815
4819class V8_EXPORT Date : public Object {
4820 public:
4821 static V8_DEPRECATE_SOON("Use maybe version.",
4822 Local<Value> New(Isolate* isolate, double time));
4824 double time);
4825
4830 double ValueOf() const;
4831
4832 V8_INLINE static Date* Cast(Value* obj);
4833
4847
4848 private:
4849 static void CheckCast(Value* obj);
4850};
4851
4852
4857 public:
4858 static Local<Value> New(Isolate* isolate, double value);
4859
4860 double ValueOf() const;
4861
4862 V8_INLINE static NumberObject* Cast(Value* obj);
4863
4864 private:
4865 static void CheckCast(Value* obj);
4866};
4867
4868
4873 public:
4874 static Local<Value> New(Isolate* isolate, bool value);
4875 V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value));
4876
4877 bool ValueOf() const;
4878
4879 V8_INLINE static BooleanObject* Cast(Value* obj);
4880
4881 private:
4882 static void CheckCast(Value* obj);
4883};
4884
4885
4890 public:
4892
4894
4895 V8_INLINE static StringObject* Cast(Value* obj);
4896
4897 private:
4898 static void CheckCast(Value* obj);
4899};
4900
4901
4906 public:
4907 static Local<Value> New(Isolate* isolate, Local<Symbol> value);
4908
4910
4911 V8_INLINE static SymbolObject* Cast(Value* obj);
4912
4913 private:
4914 static void CheckCast(Value* obj);
4915};
4916
4917
4921class V8_EXPORT RegExp : public Object {
4922 public:
4927 enum Flags {
4929 kGlobal = 1 << 0,
4930 kIgnoreCase = 1 << 1,
4931 kMultiline = 1 << 2,
4932 kSticky = 1 << 3,
4933 kUnicode = 1 << 4,
4934 kDotAll = 1 << 5,
4935 };
4936
4947 static V8_DEPRECATE_SOON("Use maybe version",
4948 Local<RegExp> New(Local<String> pattern,
4949 Flags flags));
4951 Local<String> pattern,
4952 Flags flags);
4953
4959
4964
4965 V8_INLINE static RegExp* Cast(Value* obj);
4966
4967 private:
4968 static void CheckCast(Value* obj);
4969};
4970
4971
4976class V8_EXPORT External : public Value {
4977 public:
4978 static Local<External> New(Isolate* isolate, void* value);
4979 V8_INLINE static External* Cast(Value* obj);
4980 void* Value() const;
4981 private:
4982 static void CheckCast(v8::Value* obj);
4983};
4984
4985#define V8_INTRINSICS_LIST(F) \
4986 F(ArrayProto_entries, array_entries_iterator) \
4987 F(ArrayProto_forEach, array_for_each_iterator) \
4988 F(ArrayProto_keys, array_keys_iterator) \
4989 F(ArrayProto_values, array_values_iterator) \
4990 F(ErrorPrototype, initial_error_prototype) \
4991 F(IteratorPrototype, initial_iterator_prototype)
4992
4994#define V8_DECL_INTRINSIC(name, iname) k##name,
4996#undef V8_DECL_INTRINSIC
4997};
4998
4999
5000// --- Templates ---
5001
5002
5006class V8_EXPORT Template : public Data {
5007 public:
5013 void Set(Local<Name> name, Local<Data> value,
5014 PropertyAttribute attributes = None);
5015 void SetPrivate(Local<Private> name, Local<Data> value,
5016 PropertyAttribute attributes = None);
5017 V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value);
5019 void SetAccessorProperty(
5020 Local<Name> name,
5023 PropertyAttribute attribute = None,
5024 AccessControl settings = DEFAULT);
5025
5053 void SetNativeDataProperty(
5054 Local<String> name, AccessorGetterCallback getter,
5055 AccessorSetterCallback setter = 0,
5056 // TODO(dcarney): gcc can't handle Local below
5057 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
5059 AccessControl settings = DEFAULT);
5060 void SetNativeDataProperty(
5061 Local<Name> name, AccessorNameGetterCallback getter,
5062 AccessorNameSetterCallback setter = 0,
5063 // TODO(dcarney): gcc can't handle Local below
5064 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
5066 AccessControl settings = DEFAULT);
5067
5072 void SetLazyDataProperty(Local<Name> name, AccessorNameGetterCallback getter,
5073 Local<Value> data = Local<Value>(),
5074 PropertyAttribute attribute = None);
5075
5080 void SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
5081 PropertyAttribute attribute = None);
5082
5083 private:
5084 Template();
5086 friend class ObjectTemplate;
5087 friend class FunctionTemplate;
5088};
5089
5090
5095typedef void (*NamedPropertyGetterCallback)(
5096 Local<String> property,
5097 const PropertyCallbackInfo<Value>& info);
5098
5099
5104typedef void (*NamedPropertySetterCallback)(
5105 Local<String> property,
5106 Local<Value> value,
5107 const PropertyCallbackInfo<Value>& info);
5108
5109
5115typedef void (*NamedPropertyQueryCallback)(
5116 Local<String> property,
5117 const PropertyCallbackInfo<Integer>& info);
5118
5119
5125typedef void (*NamedPropertyDeleterCallback)(
5126 Local<String> property,
5127 const PropertyCallbackInfo<Boolean>& info);
5128
5133typedef void (*NamedPropertyEnumeratorCallback)(
5134 const PropertyCallbackInfo<Array>& info);
5135
5136
5137// TODO(dcarney): Deprecate and remove previous typedefs, and replace
5138// GenericNamedPropertyFooCallback with just NamedPropertyFooCallback.
5139
5177 Local<Name> property, const PropertyCallbackInfo<Value>& info);
5178
5201 Local<Name> property, Local<Value> value,
5202 const PropertyCallbackInfo<Value>& info);
5203
5225typedef void (*GenericNamedPropertyQueryCallback)(
5226 Local<Name> property, const PropertyCallbackInfo<Integer>& info);
5227
5250 Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
5251
5257 const PropertyCallbackInfo<Array>& info);
5258
5280 Local<Name> property, const PropertyDescriptor& desc,
5281 const PropertyCallbackInfo<Value>& info);
5282
5303 Local<Name> property, const PropertyCallbackInfo<Value>& info);
5304
5308typedef void (*IndexedPropertyGetterCallback)(
5309 uint32_t index,
5310 const PropertyCallbackInfo<Value>& info);
5311
5315typedef void (*IndexedPropertySetterCallback)(
5316 uint32_t index,
5317 Local<Value> value,
5318 const PropertyCallbackInfo<Value>& info);
5319
5323typedef void (*IndexedPropertyQueryCallback)(
5324 uint32_t index,
5325 const PropertyCallbackInfo<Integer>& info);
5326
5330typedef void (*IndexedPropertyDeleterCallback)(
5331 uint32_t index,
5332 const PropertyCallbackInfo<Boolean>& info);
5333
5337typedef void (*IndexedPropertyEnumeratorCallback)(
5338 const PropertyCallbackInfo<Array>& info);
5339
5343typedef void (*IndexedPropertyDefinerCallback)(
5344 uint32_t index, const PropertyDescriptor& desc,
5345 const PropertyCallbackInfo<Value>& info);
5346
5350typedef void (*IndexedPropertyDescriptorCallback)(
5351 uint32_t index, const PropertyCallbackInfo<Value>& info);
5352
5362};
5363
5364
5369typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
5370 Local<Object> accessed_object,
5371 Local<Value> data);
5372
5472class V8_EXPORT FunctionTemplate : public Template {
5473 public:
5475 static Local<FunctionTemplate> New(
5476 Isolate* isolate, FunctionCallback callback = 0,
5477 Local<Value> data = Local<Value>(),
5478 Local<Signature> signature = Local<Signature>(), int length = 0,
5479 ConstructorBehavior behavior = ConstructorBehavior::kAllow);
5480
5482 static MaybeLocal<FunctionTemplate> FromSnapshot(Isolate* isolate,
5483 size_t index);
5484
5488 static Local<FunctionTemplate> NewWithCache(
5489 Isolate* isolate, FunctionCallback callback,
5490 Local<Private> cache_property, Local<Value> data = Local<Value>(),
5491 Local<Signature> signature = Local<Signature>(), int length = 0);
5492
5496 Local<Context> context);
5497
5505 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewRemoteInstance();
5506
5512 void SetCallHandler(FunctionCallback callback,
5513 Local<Value> data = Local<Value>());
5514
5516 void SetLength(int length);
5517
5519 Local<ObjectTemplate> InstanceTemplate();
5520
5526 void Inherit(Local<FunctionTemplate> parent);
5527
5532 Local<ObjectTemplate> PrototypeTemplate();
5533
5540 void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
5541
5547 void SetClassName(Local<String> name);
5548
5549
5554 void SetAcceptAnyReceiver(bool value);
5555
5568 void SetHiddenPrototype(bool value);
5569
5574 void ReadOnlyPrototype();
5575
5580 void RemovePrototype();
5581
5586 bool HasInstance(Local<Value> object);
5587
5588 private:
5590 friend class Context;
5591 friend class ObjectTemplate;
5592};
5593
5598enum class PropertyHandlerFlags {
5602 kNone = 0,
5603
5607 kAllCanRead = 1,
5608
5613 kNonMasking = 1 << 1,
5614
5619 kOnlyInterceptStrings = 1 << 2,
5620};
5632 : getter(getter),
5633 setter(setter),
5634 query(query),
5637 definer(0),
5638 descriptor(0),
5639 data(data),
5640 flags(flags) {}
5651 : getter(getter),
5652 setter(setter),
5653 query(0),
5658 data(data),
5659 flags(flags) {}
5670};
5671
5683 : getter(getter),
5684 setter(setter),
5685 query(query),
5688 definer(0),
5689 descriptor(0),
5690 data(data),
5691 flags(flags) {}
5702 : getter(getter),
5703 setter(setter),
5704 query(0),
5709 data(data),
5710 flags(flags) {}
5721};
5722
5723
5730class V8_EXPORT ObjectTemplate : public Template {
5731 public:
5733 static Local<ObjectTemplate> New(
5734 Isolate* isolate,
5736 static V8_DEPRECATED("Use isolate version", Local<ObjectTemplate> New());
5737
5739 static MaybeLocal<ObjectTemplate> FromSnapshot(Isolate* isolate,
5740 size_t index);
5741
5745
5775 void SetAccessor(
5776 Local<String> name, AccessorGetterCallback getter,
5777 AccessorSetterCallback setter = 0, Local<Value> data = Local<Value>(),
5778 AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
5780 void SetAccessor(
5781 Local<Name> name, AccessorNameGetterCallback getter,
5782 AccessorNameSetterCallback setter = 0, Local<Value> data = Local<Value>(),
5783 AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
5785
5808 // TODO(dcarney): deprecate
5809 void SetNamedPropertyHandler(NamedPropertyGetterCallback getter,
5810 NamedPropertySetterCallback setter = 0,
5811 NamedPropertyQueryCallback query = 0,
5812 NamedPropertyDeleterCallback deleter = 0,
5813 NamedPropertyEnumeratorCallback enumerator = 0,
5814 Local<Value> data = Local<Value>());
5815
5827 void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
5828
5845 // TODO(dcarney): deprecate
5846 void SetIndexedPropertyHandler(
5847 IndexedPropertyGetterCallback getter,
5848 IndexedPropertySetterCallback setter = 0,
5849 IndexedPropertyQueryCallback query = 0,
5850 IndexedPropertyDeleterCallback deleter = 0,
5851 IndexedPropertyEnumeratorCallback enumerator = 0,
5852 Local<Value> data = Local<Value>()) {
5853 SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
5854 deleter, enumerator, data));
5855 }
5856
5867 void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
5868
5875 void SetCallAsFunctionHandler(FunctionCallback callback,
5876 Local<Value> data = Local<Value>());
5877
5886 void MarkAsUndetectable();
5887
5896 void SetAccessCheckCallback(AccessCheckCallback callback,
5897 Local<Value> data = Local<Value>());
5898
5905 void SetAccessCheckCallbackAndHandler(
5906 AccessCheckCallback callback,
5907 const NamedPropertyHandlerConfiguration& named_handler,
5908 const IndexedPropertyHandlerConfiguration& indexed_handler,
5909 Local<Value> data = Local<Value>());
5910
5915 int InternalFieldCount();
5916
5921 void SetInternalFieldCount(int value);
5922
5926 bool IsImmutableProto();
5927
5932 void SetImmutableProto();
5933
5934 private:
5936 static Local<ObjectTemplate> New(internal::Isolate* isolate,
5938 friend class FunctionTemplate;
5939};
5940
5949class V8_EXPORT Signature : public Data {
5950 public:
5951 static Local<Signature> New(
5952 Isolate* isolate,
5954
5955 private:
5956 Signature();
5957};
5958
5959
5964class V8_EXPORT AccessorSignature : public Data {
5965 public:
5966 static Local<AccessorSignature> New(
5967 Isolate* isolate,
5969
5970 private:
5972};
5973
5974
5975// --- Extensions ---
5979 public:
5980 ExternalOneByteStringResourceImpl() : data_(0), length_(0) {}
5981 ExternalOneByteStringResourceImpl(const char* data, size_t length)
5982 : data_(data), length_(length) {}
5983 const char* data() const { return data_; }
5984 size_t length() const { return length_; }
5985
5986 private:
5987 const char* data_;
5988 size_t length_;
5989};
5990
5994class V8_EXPORT Extension { // NOLINT
5995 public:
5996 // Note that the strings passed into this constructor must live as long
5997 // as the Extension itself.
5998 Extension(const char* name,
5999 const char* source = 0,
6000 int dep_count = 0,
6001 const char** deps = 0,
6002 int source_length = -1);
6003 virtual ~Extension() { }
6004 virtual Local<FunctionTemplate> GetNativeFunctionTemplate(
6005 Isolate* isolate, Local<String> name) {
6006 return Local<FunctionTemplate>();
6007 }
6009 const char* name() const { return name_; }
6010 size_t source_length() const { return source_length_; }
6011 const String::ExternalOneByteStringResource* source() const {
6012 return &source_; }
6013 int dependency_count() { return dep_count_; }
6014 const char** dependencies() { return deps_; }
6015 void set_auto_enable(bool value) { auto_enable_ = value; }
6016 bool auto_enable() { return auto_enable_; }
6017
6018 // Disallow copying and assigning.
6019 Extension(const Extension&) = delete;
6020 void operator=(const Extension&) = delete;
6021
6022 private:
6023 const char* name_;
6024 size_t source_length_; // expected to initialize before source_
6026 int dep_count_;
6027 const char** deps_;
6028 bool auto_enable_;
6029};
6030
6032void V8_EXPORT RegisterExtension(Extension* extension);
6033
6034
6035// --- Statics ---
6036
6041
6057 public:
6059
6069 void ConfigureDefaults(uint64_t physical_memory,
6070 uint64_t virtual_memory_limit);
6071
6072 // Returns the max semi-space size in MB.
6073 V8_DEPRECATE_SOON("Use max_semi_space_size_in_kb()",
6074 int max_semi_space_size()) {
6075 return static_cast<int>(max_semi_space_size_in_kb_ / 1024);
6076 }
6077
6078 // Sets the max semi-space size in MB.
6079 V8_DEPRECATE_SOON("Use set_max_semi_space_size_in_kb(size_t limit_in_kb)",
6080 void set_max_semi_space_size(int limit_in_mb)) {
6081 max_semi_space_size_in_kb_ = limit_in_mb * 1024;
6082 }
6083
6084 // Returns the max semi-space size in KB.
6085 size_t max_semi_space_size_in_kb() const {
6086 return max_semi_space_size_in_kb_;
6087 }
6088
6089 // Sets the max semi-space size in KB.
6090 void set_max_semi_space_size_in_kb(size_t limit_in_kb) {
6091 max_semi_space_size_in_kb_ = limit_in_kb;
6092 }
6094 int max_old_space_size() const { return max_old_space_size_; }
6095 void set_max_old_space_size(int limit_in_mb) {
6096 max_old_space_size_ = limit_in_mb;
6097 }
6098 V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_",
6099 int max_executable_size() const) {
6100 return max_executable_size_;
6101 }
6102 V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_",
6103 void set_max_executable_size(int limit_in_mb)) {
6104 max_executable_size_ = limit_in_mb;
6106 uint32_t* stack_limit() const { return stack_limit_; }
6107 // Sets an address beyond which the VM's stack may not grow.
6108 void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
6109 size_t code_range_size() const { return code_range_size_; }
6110 void set_code_range_size(size_t limit_in_mb) {
6111 code_range_size_ = limit_in_mb;
6113 size_t max_zone_pool_size() const { return max_zone_pool_size_; }
6114 void set_max_zone_pool_size(const size_t bytes) {
6115 max_zone_pool_size_ = bytes;
6116 }
6117
6118 private:
6119 // max_semi_space_size_ is in KB
6120 size_t max_semi_space_size_in_kb_;
6121
6122 // The remaining limits are in MB
6123 int max_old_space_size_;
6124 int max_executable_size_;
6125 uint32_t* stack_limit_;
6126 size_t code_range_size_;
6127 size_t max_zone_pool_size_;
6128};
6129
6130
6131// --- Exceptions ---
6132
6134typedef void (*FatalErrorCallback)(const char* location, const char* message);
6136typedef void (*OOMErrorCallback)(const char* location, bool is_heap_oom);
6138typedef void (*MessageCallback)(Local<Message> message, Local<Value> data);
6139
6140// --- Tracing ---
6142typedef void (*LogEventCallback)(const char* name, int event);
6143
6148class V8_EXPORT Exception {
6149 public:
6150 static Local<Value> RangeError(Local<String> message);
6151 static Local<Value> ReferenceError(Local<String> message);
6152 static Local<Value> SyntaxError(Local<String> message);
6153 static Local<Value> TypeError(Local<String> message);
6154 static Local<Value> Error(Local<String> message);
6155
6161 static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception);
6162 V8_DEPRECATED("Use version with an Isolate*",
6163 static Local<Message> CreateMessage(Local<Value> exception));
6164
6169 static Local<StackTrace> GetStackTrace(Local<Value> exception);
6170};
6171
6172
6173// --- Counters Callbacks ---
6175typedef int* (*CounterLookupCallback)(const char* name);
6177typedef void* (*CreateHistogramCallback)(const char* name,
6178 int min,
6179 int max,
6180 size_t buckets);
6182typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
6183
6184// --- Memory Allocation Callback ---
6190 kObjectSpaceLoSpace = 1 << 4,
6194};
6198 kAllocationActionFree = 1 << 1,
6200 };
6201
6202// --- Enter/Leave Script Callback ---
6205typedef void (*DeprecatedCallCompletedCallback)();
6206
6228 Local<Context> context, Local<String> referrer, Local<String> specifier);
6229
6246enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
6248typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise,
6249 Local<Value> parent);
6250
6251// --- Promise Reject Callback ---
6255};
6258 public:
6260 Local<Value> value, Local<StackTrace> stack_trace)
6261 : promise_(promise),
6262 event_(event),
6263 value_(value),
6264 stack_trace_(stack_trace) {}
6266 V8_INLINE Local<Promise> GetPromise() const { return promise_; }
6267 V8_INLINE PromiseRejectEvent GetEvent() const { return event_; }
6268 V8_INLINE Local<Value> GetValue() const { return value_; }
6269
6270 V8_DEPRECATED("Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()",
6272 return stack_trace_;
6273 }
6274
6275 private:
6276 Local<Promise> promise_;
6277 PromiseRejectEvent event_;
6278 Local<Value> value_;
6279 Local<StackTrace> stack_trace_;
6280};
6282typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
6283
6284// --- Microtasks Callbacks ---
6286typedef void (*MicrotaskCallback)(void* data);
6287
6288
6296enum class MicrotasksPolicy { kExplicit, kScoped, kAuto };
6297
6298
6308class V8_EXPORT MicrotasksScope {
6309 public:
6310 enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
6314
6318 static void PerformCheckpoint(Isolate* isolate);
6319
6323 static int GetCurrentDepth(Isolate* isolate);
6324
6328 static bool IsRunningMicrotasks(Isolate* isolate);
6329
6330 // Prevent copying.
6332 MicrotasksScope& operator=(const MicrotasksScope&) = delete;
6333
6334 private:
6335 internal::Isolate* const isolate_;
6336 bool run_;
6337};
6338
6339
6340// --- Failed Access Check Callback ---
6341typedef void (*FailedAccessCheckCallback)(Local<Object> target,
6342 AccessType type,
6343 Local<Value> data);
6344
6345// --- AllowCodeGenerationFromStrings callbacks ---
6346
6352 Local<String> source);
6353
6354// --- WebAssembly compilation callbacks ---
6355typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&);
6356
6357// --- Callback for APIs defined on v8-supported objects, but implemented
6358// by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
6360
6361// --- Garbage Collection Callbacks ---
6362
6377};
6378
6401};
6403typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
6405typedef void (*InterruptCallback)(Isolate* isolate, void* data);
6406
6407
6415 public:
6417 size_t total_heap_size() { return total_heap_size_; }
6418 size_t total_heap_size_executable() { return total_heap_size_executable_; }
6419 size_t total_physical_size() { return total_physical_size_; }
6420 size_t total_available_size() { return total_available_size_; }
6421 size_t used_heap_size() { return used_heap_size_; }
6422 size_t heap_size_limit() { return heap_size_limit_; }
6423 size_t malloced_memory() { return malloced_memory_; }
6424 size_t peak_malloced_memory() { return peak_malloced_memory_; }
6425
6430 size_t does_zap_garbage() { return does_zap_garbage_; }
6431
6432 private:
6433 size_t total_heap_size_;
6434 size_t total_heap_size_executable_;
6435 size_t total_physical_size_;
6436 size_t total_available_size_;
6437 size_t used_heap_size_;
6438 size_t heap_size_limit_;
6439 size_t malloced_memory_;
6440 size_t peak_malloced_memory_;
6441 bool does_zap_garbage_;
6443 friend class V8;
6444 friend class Isolate;
6445};
6446
6449 public:
6451 const char* space_name() { return space_name_; }
6452 size_t space_size() { return space_size_; }
6453 size_t space_used_size() { return space_used_size_; }
6454 size_t space_available_size() { return space_available_size_; }
6455 size_t physical_space_size() { return physical_space_size_; }
6456
6457 private:
6458 const char* space_name_;
6459 size_t space_size_;
6460 size_t space_used_size_;
6461 size_t space_available_size_;
6462 size_t physical_space_size_;
6464 friend class Isolate;
6465};
6466
6469 public:
6471 const char* object_type() { return object_type_; }
6472 const char* object_sub_type() { return object_sub_type_; }
6473 size_t object_count() { return object_count_; }
6474 size_t object_size() { return object_size_; }
6475
6476 private:
6477 const char* object_type_;
6478 const char* object_sub_type_;
6479 size_t object_count_;
6480 size_t object_size_;
6482 friend class Isolate;
6483};
6486 public:
6488 size_t code_and_metadata_size() { return code_and_metadata_size_; }
6489 size_t bytecode_and_metadata_size() { return bytecode_and_metadata_size_; }
6490
6491 private:
6492 size_t code_and_metadata_size_;
6493 size_t bytecode_and_metadata_size_;
6495 friend class Isolate;
6496};
6497
6498class RetainedObjectInfo;
6499
6500
6512typedef void (*FunctionEntryHook)(uintptr_t function,
6513 uintptr_t return_addr_location);
6514
6528 };
6529 // Definition of the code position type. The "POSITION" type means the place
6530 // in the source code which are of interest when making stack traces to
6531 // pin-point the source location of a stack frame as close as possible.
6532 // The "STATEMENT_POSITION" means the place at the beginning of each
6533 // statement, and is used to indicate possible break locations.
6535
6536 // Type of event.
6538 // Start of the instructions.
6539 void* code_start;
6540 // Size of the instructions.
6541 size_t code_len;
6542 // Script info for CODE_ADDED event.
6544 // User-defined data for *_LINE_INFO_* event. It's used to hold the source
6545 // code line information which is returned from the
6546 // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent
6547 // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events.
6548 void* user_data;
6550 struct name_t {
6551 // Name of the object associated with the code, note that the string is not
6552 // zero-terminated.
6553 const char* str;
6554 // Number of chars in str.
6555 size_t len;
6556 };
6558 struct line_info_t {
6559 // PC offset
6560 size_t offset;
6561 // Code position
6562 size_t pos;
6563 // The position type.
6565 };
6566
6567 union {
6568 // Only valid for CODE_ADDED.
6569 struct name_t name;
6570
6571 // Only valid for CODE_ADD_LINE_POS_INFO
6572 struct line_info_t line_info;
6573
6574 // New location of instructions. Only valid for CODE_MOVED.
6575 void* new_code_start;
6576 };
6577};
6578
6584enum RAILMode {
6585 // Response performance mode: In this mode very low virtual machine latency
6586 // is provided. V8 will try to avoid JavaScript execution interruptions.
6587 // Throughput may be throttled.
6589 // Animation performance mode: In this mode low virtual machine latency is
6590 // provided. V8 will try to avoid as many JavaScript execution interruptions
6591 // as possible. Throughput may be throttled. This is the default mode.
6593 // Idle performance mode: The embedder is idle. V8 can complete deferred work
6594 // in this mode.
6596 // Load performance mode: In this mode high throughput is provided. V8 may
6597 // turn off latency optimizations.
6599};
6600
6606 // Generate callbacks for already existent code.
6608};
6609
6610
6616typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
6617
6618
6622class V8_EXPORT ExternalResourceVisitor { // NOLINT
6623 public:
6625 virtual void VisitExternalString(Local<String> string) {}
6626};
6627
6628
6632class V8_EXPORT PersistentHandleVisitor { // NOLINT
6633 public:
6635 virtual void VisitPersistentHandle(Persistent<Value>* value,
6636 uint16_t class_id) {}
6637};
6638
6648
6660class V8_EXPORT EmbedderHeapTracer {
6661 public:
6662 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION };
6665 explicit AdvanceTracingActions(ForceCompletionAction force_completion_)
6666 : force_completion(force_completion_) {}
6668 ForceCompletionAction force_completion;
6669 };
6670
6677 virtual void RegisterV8References(
6678 const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
6679
6683 virtual void TracePrologue() = 0;
6684
6695 virtual bool AdvanceTracing(double deadline_in_ms,
6696 AdvanceTracingActions actions) = 0;
6697
6703 virtual void TraceEpilogue() = 0;
6704
6709 virtual void EnterFinalPause() = 0;
6710
6717 virtual void AbortTracing() = 0;
6718
6722 virtual size_t NumberOfWrappersToTrace() { return 0; }
6723
6724 protected:
6725 virtual ~EmbedderHeapTracer() = default;
6726};
6727
6733 typedef StartupData (*CallbackFunction)(Local<Object> holder, int index,
6734 void* data);
6736 void* data_arg = nullptr)
6737 : callback(function), data(data_arg) {}
6739 void* data;
6740};
6741// Note that these fields are called "internal fields" in the API and called
6742// "embedder fields" within V8.
6744
6750 typedef void (*CallbackFunction)(Local<Object> holder, int index,
6751 StartupData payload, void* data);
6753 void* data_arg = nullptr)
6754 : callback(function), data(data_arg) {}
6755 void (*callback)(Local<Object> holder, int index, StartupData payload,
6756 void* data);
6757 void* data;
6759typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback;
6760
6769class V8_EXPORT Isolate {
6770 public:
6775 CreateParams()
6776 : entry_hook(nullptr),
6777 code_event_handler(nullptr),
6778 snapshot_blob(nullptr),
6779 counter_lookup_callback(nullptr),
6780 create_histogram_callback(nullptr),
6781 add_histogram_sample_callback(nullptr),
6782 array_buffer_allocator(nullptr),
6783 external_references(nullptr),
6784 allow_atomics_wait(true) {}
6785
6794 FunctionEntryHook entry_hook;
6795
6800 JitCodeEventHandler code_event_handler;
6801
6805 ResourceConstraints constraints;
6806
6810 StartupData* snapshot_blob;
6811
6812
6817 CounterLookupCallback counter_lookup_callback;
6818
6825 CreateHistogramCallback create_histogram_callback;
6826 AddHistogramSampleCallback add_histogram_sample_callback;
6827
6832 ArrayBuffer::Allocator* array_buffer_allocator;
6833
6840 const intptr_t* external_references;
6841
6846 bool allow_atomics_wait;
6847 };
6848
6849
6854 class V8_EXPORT Scope {
6855 public:
6856 explicit Scope(Isolate* isolate) : isolate_(isolate) {
6857 isolate->Enter();
6858 }
6860 ~Scope() { isolate_->Exit(); }
6861
6862 // Prevent copying of Scope objects.
6863 Scope(const Scope&) = delete;
6864 Scope& operator=(const Scope&) = delete;
6865
6866 private:
6867 Isolate* const isolate_;
6868 };
6869
6870
6875 public:
6876 enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE };
6880
6881 // Prevent copying of Scope objects.
6883 delete;
6885 const DisallowJavascriptExecutionScope&) = delete;
6886
6887 private:
6888 bool on_failure_;
6889 void* internal_;
6890 };
6891
6892
6897 public:
6900
6901 // Prevent copying of Scope objects.
6903 delete;
6905 const AllowJavascriptExecutionScope&) = delete;
6906
6907 private:
6908 void* internal_throws_;
6909 void* internal_assert_;
6910 };
6911
6917 public:
6920
6921 // Prevent copying of Scope objects.
6923 delete;
6925 const SuppressMicrotaskExecutionScope&) = delete;
6926
6927 private:
6928 internal::Isolate* const isolate_;
6929 };
6930
6936 kFullGarbageCollection,
6937 kMinorGarbageCollection
6938 };
6939
6946 kUseAsm = 0,
6947 kBreakIterator = 1,
6948 kLegacyConst = 2,
6949 kMarkDequeOverflow = 3,
6950 kStoreBufferOverflow = 4,
6951 kSlotsBufferOverflow = 5,
6952 kObjectObserve = 6,
6953 kForcedGC = 7,
6954 kSloppyMode = 8,
6955 kStrictMode = 9,
6956 kStrongMode = 10,
6957 kRegExpPrototypeStickyGetter = 11,
6958 kRegExpPrototypeToString = 12,
6959 kRegExpPrototypeUnicodeGetter = 13,
6960 kIntlV8Parse = 14,
6961 kIntlPattern = 15,
6962 kIntlResolved = 16,
6963 kPromiseChain = 17,
6964 kPromiseAccept = 18,
6965 kPromiseDefer = 19,
6966 kHtmlCommentInExternalScript = 20,
6967 kHtmlComment = 21,
6968 kSloppyModeBlockScopedFunctionRedefinition = 22,
6969 kForInInitializer = 23,
6970 kArrayProtectorDirtied = 24,
6971 kArraySpeciesModified = 25,
6972 kArrayPrototypeConstructorModified = 26,
6973 kArrayInstanceProtoModified = 27,
6974 kArrayInstanceConstructorModified = 28,
6975 kLegacyFunctionDeclaration = 29,
6976 kRegExpPrototypeSourceGetter = 30,
6977 kRegExpPrototypeOldFlagGetter = 31,
6978 kDecimalWithLeadingZeroInStrictMode = 32,
6979 kLegacyDateParser = 33,
6980 kDefineGetterOrSetterWouldThrow = 34,
6981 kFunctionConstructorReturnedUndefined = 35,
6982 kAssigmentExpressionLHSIsCallInSloppy = 36,
6983 kAssigmentExpressionLHSIsCallInStrict = 37,
6984 kPromiseConstructorReturnedUndefined = 38,
6985 kConstructorNonUndefinedPrimitiveReturn = 39,
6986 kLabeledExpressionStatement = 40,
6987
6988 // If you add new values here, you'll also need to update Chromium's:
6989 // UseCounter.h, V8PerIsolateData.cpp, histograms.xml
6990 kUseCounterFeatureCount // This enum value must be last.
6991 };
6994 kMessageLog = (1 << 0),
6995 kMessageDebug = (1 << 1),
6996 kMessageInfo = (1 << 2),
6997 kMessageError = (1 << 3),
6998 kMessageWarning = (1 << 4),
6999 kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError |
7000 kMessageWarning,
7001 };
7003 typedef void (*UseCounterCallback)(Isolate* isolate,
7004 UseCounterFeature feature);
7005
7006
7016 static Isolate* New(const CreateParams& params);
7017
7024 static Isolate* GetCurrent();
7025
7035 typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*);
7036 void SetAbortOnUncaughtExceptionCallback(
7037 AbortOnUncaughtExceptionCallback callback);
7038
7046 void SetHostImportModuleDynamicallyCallback(
7047 HostImportModuleDynamicallyCallback callback);
7048
7055 void MemoryPressureNotification(MemoryPressureLevel level);
7056
7067 void Enter();
7068
7076 void Exit();
7077
7082 void Dispose();
7083
7088 void DumpAndResetStats();
7089
7097 void DiscardThreadSpecificMetadata();
7098
7103 V8_INLINE void SetData(uint32_t slot, void* data);
7104
7109 V8_INLINE void* GetData(uint32_t slot);
7110
7115 V8_INLINE static uint32_t GetNumberOfDataSlots();
7116
7120 void GetHeapStatistics(HeapStatistics* heap_statistics);
7121
7125 size_t NumberOfHeapSpaces();
7126
7136 bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
7137 size_t index);
7138
7142 size_t NumberOfTrackedHeapObjectTypes();
7143
7153 bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics,
7154 size_t type_index);
7155
7163 bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics);
7164
7177 void GetStackSample(const RegisterState& state, void** frames,
7178 size_t frames_limit, SampleInfo* sample_info);
7179
7193 V8_INLINE int64_t
7194 AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
7195
7200 size_t NumberOfPhantomHandleResetsSinceLastCall();
7201
7206 HeapProfiler* GetHeapProfiler();
7207
7213 V8_DEPRECATE_SOON("CpuProfiler should be created with CpuProfiler::New call.",
7214 CpuProfiler* GetCpuProfiler());
7215
7217 bool InContext();
7218
7223 Local<Context> GetCurrentContext();
7224
7231 "Calling context concept is not compatible with tail calls, and will be "
7232 "removed.",
7233 Local<Context> GetCallingContext());
7234
7236 Local<Context> GetEnteredContext();
7237
7244 Local<Context> GetEnteredOrMicrotaskContext();
7245
7250 Local<Context> GetIncumbentContext();
7251
7258 Local<Value> ThrowException(Local<Value> exception);
7260 typedef void (*GCCallback)(Isolate* isolate, GCType type,
7261 GCCallbackFlags flags);
7262
7272 void AddGCPrologueCallback(GCCallback callback,
7273 GCType gc_type_filter = kGCTypeAll);
7274
7279 void RemoveGCPrologueCallback(GCCallback callback);
7280
7284 void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
7285
7295 void AddGCEpilogueCallback(GCCallback callback,
7296 GCType gc_type_filter = kGCTypeAll);
7297
7302 void RemoveGCEpilogueCallback(GCCallback callback);
7304 typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
7305
7312 void SetGetExternallyAllocatedMemoryInBytesCallback(
7313 GetExternallyAllocatedMemoryInBytesCallback callback);
7314
7322 void TerminateExecution();
7323
7332 bool IsExecutionTerminating();
7333
7348 void CancelTerminateExecution();
7349
7358 void RequestInterrupt(InterruptCallback callback, void* data);
7359
7370 void RequestGarbageCollectionForTesting(GarbageCollectionType type);
7371
7375 void SetEventLogger(LogEventCallback that);
7376
7383 void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
7384
7388 void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback);
7389
7397 void AddCallCompletedCallback(CallCompletedCallback callback);
7399 "Use callback with parameter",
7400 void AddCallCompletedCallback(DeprecatedCallCompletedCallback callback));
7401
7405 void RemoveCallCompletedCallback(CallCompletedCallback callback);
7407 "Use callback with parameter",
7409 DeprecatedCallCompletedCallback callback));
7410
7415 void SetPromiseHook(PromiseHook hook);
7416
7421 void SetPromiseRejectCallback(PromiseRejectCallback callback);
7422
7427 void RunMicrotasks();
7428
7432 void EnqueueMicrotask(Local<Function> microtask);
7433
7437 void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
7438
7443 void SetMicrotasksPolicy(MicrotasksPolicy policy);
7444 V8_DEPRECATE_SOON("Use SetMicrotasksPolicy",
7445 void SetAutorunMicrotasks(bool autorun));
7446
7450 MicrotasksPolicy GetMicrotasksPolicy() const;
7451 V8_DEPRECATE_SOON("Use GetMicrotasksPolicy",
7452 bool WillAutorunMicrotasks() const);
7453
7466 void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
7467
7471 void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
7472
7476 void SetUseCounterCallback(UseCounterCallback callback);
7477
7482 void SetCounterFunction(CounterLookupCallback);
7483
7490 void SetCreateHistogramFunction(CreateHistogramCallback);
7491 void SetAddHistogramSampleFunction(AddHistogramSampleCallback);
7492
7507 bool IdleNotificationDeadline(double deadline_in_seconds);
7508
7509 V8_DEPRECATED("use IdleNotificationDeadline()",
7510 bool IdleNotification(int idle_time_in_ms));
7511
7516 void LowMemoryNotification();
7517
7527 int ContextDisposedNotification(bool dependant_context = true);
7528
7533 void IsolateInForegroundNotification();
7534
7539 void IsolateInBackgroundNotification();
7540
7548 void SetRAILMode(RAILMode rail_mode);
7549
7554 void IncreaseHeapLimitForDebugging();
7555
7559 void RestoreOriginalHeapLimit();
7560
7565 bool IsHeapLimitIncreasedForDebugging();
7566
7589 void SetJitCodeEventHandler(JitCodeEventOptions options,
7590 JitCodeEventHandler event_handler);
7591
7601 void SetStackLimit(uintptr_t stack_limit);
7602
7616 void GetCodeRange(void** start, size_t* length_in_bytes);
7617
7619 void SetFatalErrorHandler(FatalErrorCallback that);
7620
7622 void SetOOMErrorHandler(OOMErrorCallback that);
7623
7628 void SetAllowCodeGenerationFromStringsCallback(
7629 AllowCodeGenerationFromStringsCallback callback);
7630
7635 void SetWasmModuleCallback(ExtensionCallback callback);
7636 void SetWasmInstanceCallback(ExtensionCallback callback);
7638 void SetWasmCompileStreamingCallback(ApiImplementationCallback callback);
7639
7644 bool IsDead();
7645
7655 bool AddMessageListener(MessageCallback that,
7656 Local<Value> data = Local<Value>());
7657
7669 bool AddMessageListenerWithErrorLevel(MessageCallback that,
7670 int message_levels,
7671 Local<Value> data = Local<Value>());
7672
7676 void RemoveMessageListeners(MessageCallback that);
7677
7679 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);
7680
7685 void SetCaptureStackTraceForUncaughtExceptions(
7686 bool capture, int frame_limit = 10,
7687 StackTrace::StackTraceOptions options = StackTrace::kOverview);
7688
7694 void VisitExternalResources(ExternalResourceVisitor* visitor);
7695
7700 void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
7701
7709 void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor);
7710
7716 void VisitWeakHandles(PersistentHandleVisitor* visitor);
7717
7722 bool IsInUse();
7723
7729 void SetAllowAtomicsWait(bool allow);
7731 Isolate() = delete;
7732 ~Isolate() = delete;
7733 Isolate(const Isolate&) = delete;
7734 Isolate& operator=(const Isolate&) = delete;
7735 // Deleting operator new and delete here is allowed as ctor and dtor is also
7736 // deleted.
7737 void* operator new(size_t size) = delete;
7738 void* operator new[](size_t size) = delete;
7739 void operator delete(void*, size_t) = delete;
7740 void operator delete[](void*, size_t) = delete;
7741
7742 private:
7743 template <class K, class V, class Traits>
7744 friend class PersistentValueMapBase;
7745
7746 void ReportExternalAllocationLimitReached();
7747 void CheckMemoryPressure();
7748};
7750class V8_EXPORT StartupData {
7751 public:
7752 const char* data;
7753 int raw_size;
7754};
7755
7756
7761typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
7762
7776typedef uintptr_t (*ReturnAddressLocationResolver)(
7777 uintptr_t return_addr_location);
7778
7779
7783class V8_EXPORT V8 {
7784 public:
7786 V8_INLINE static V8_DEPRECATED(
7787 "Use isolate version",
7788 void SetFatalErrorHandler(FatalErrorCallback that));
7789
7794 V8_INLINE static V8_DEPRECATED("Use isolate version", bool IsDead());
7795
7811 static void SetNativesDataBlob(StartupData* startup_blob);
7812 static void SetSnapshotDataBlob(StartupData* startup_blob);
7813
7820 static StartupData CreateSnapshotDataBlob(const char* embedded_source = NULL);
7821
7830 static StartupData WarmUpSnapshotDataBlob(StartupData cold_startup_blob,
7831 const char* warmup_source);
7832
7842 V8_INLINE static V8_DEPRECATED(
7843 "Use isolate version",
7844 bool AddMessageListener(MessageCallback that,
7845 Local<Value> data = Local<Value>()));
7846
7850 V8_INLINE static V8_DEPRECATED(
7851 "Use isolate version", void RemoveMessageListeners(MessageCallback that));
7852
7857 V8_INLINE static V8_DEPRECATED(
7858 "Use isolate version",
7859 void SetCaptureStackTraceForUncaughtExceptions(
7860 bool capture, int frame_limit = 10,
7861 StackTrace::StackTraceOptions options = StackTrace::kOverview));
7862
7866 static void SetFlagsFromString(const char* str, int length);
7867
7871 static void SetFlagsFromCommandLine(int* argc,
7872 char** argv,
7873 bool remove_flags);
7874
7876 static const char* GetVersion();
7877
7879 V8_INLINE static V8_DEPRECATED(
7880 "Use isolate version",
7881 void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback));
7882
7893 static V8_DEPRECATED(
7894 "Use isolate version",
7895 void AddGCPrologueCallback(GCCallback callback,
7896 GCType gc_type_filter = kGCTypeAll));
7897
7902 V8_INLINE static V8_DEPRECATED(
7903 "Use isolate version",
7904 void RemoveGCPrologueCallback(GCCallback callback));
7905
7916 static V8_DEPRECATED(
7917 "Use isolate version",
7918 void AddGCEpilogueCallback(GCCallback callback,
7919 GCType gc_type_filter = kGCTypeAll));
7920
7925 V8_INLINE static V8_DEPRECATED(
7926 "Use isolate version",
7927 void RemoveGCEpilogueCallback(GCCallback callback));
7928
7933 static bool Initialize();
7934
7939 static void SetEntropySource(EntropySource source);
7940
7945 static void SetReturnAddressLocationResolver(
7946 ReturnAddressLocationResolver return_address_resolver);
7947
7957 V8_INLINE static V8_DEPRECATED("Use isolate version",
7958 void TerminateExecution(Isolate* isolate));
7959
7970 V8_INLINE static V8_DEPRECATED(
7971 "Use isolate version",
7972 bool IsExecutionTerminating(Isolate* isolate = NULL));
7973
7990 V8_INLINE static V8_DEPRECATED(
7991 "Use isolate version", void CancelTerminateExecution(Isolate* isolate));
7992
8002 static bool Dispose();
8003
8009 V8_INLINE static V8_DEPRECATED(
8010 "Use isolate version",
8011 void VisitExternalResources(ExternalResourceVisitor* visitor));
8012
8017 V8_INLINE static V8_DEPRECATED(
8018 "Use isolate version",
8019 void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor));
8020
8025 V8_INLINE static V8_DEPRECATED(
8026 "Use isolate version",
8027 void VisitHandlesWithClassIds(Isolate* isolate,
8028 PersistentHandleVisitor* visitor));
8029
8037 V8_INLINE static V8_DEPRECATED(
8038 "Use isolate version",
8039 void VisitHandlesForPartialDependence(Isolate* isolate,
8040 PersistentHandleVisitor* visitor));
8041
8050 "Use version with default location.",
8051 static bool InitializeICU(const char* icu_data_file = nullptr));
8052
8065 static bool InitializeICUDefaultLocation(const char* exec_path,
8066 const char* icu_data_file = nullptr);
8067
8084 static void InitializeExternalStartupData(const char* directory_path);
8085 static void InitializeExternalStartupData(const char* natives_blob,
8086 const char* snapshot_blob);
8091 static void InitializePlatform(Platform* platform);
8092
8097 static void ShutdownPlatform();
8098
8099#if V8_OS_POSIX
8119 static bool TryHandleSignal(int signal_number, void* info, void* context);
8120#endif // V8_OS_POSIX
8121
8126 static bool RegisterDefaultSignalHandler();
8127
8128 private:
8129 V8();
8130
8131 static internal::Object** GlobalizeReference(internal::Isolate* isolate,
8132 internal::Object** handle);
8133 static internal::Object** CopyPersistent(internal::Object** handle);
8134 static void DisposeGlobal(internal::Object** global_handle);
8135 static void MakeWeak(internal::Object** location, void* data,
8137 WeakCallbackType type);
8138 static void MakeWeak(internal::Object** location, void* data,
8139 // Must be 0 or -1.
8140 int internal_field_index1,
8141 // Must be 1 or -1.
8142 int internal_field_index2,
8143 WeakCallbackInfo<void>::Callback weak_callback);
8144 static void MakeWeak(internal::Object*** location_addr);
8145 static void* ClearWeak(internal::Object** location);
8146 static Value* Eternalize(Isolate* isolate, Value* handle);
8147
8148 static void RegisterExternallyReferencedObject(internal::Object** object,
8149 internal::Isolate* isolate);
8150
8151 template <class K, class V, class T>
8152 friend class PersistentValueMapBase;
8153
8154 static void FromJustIsNothing();
8155 static void ToLocalEmpty();
8156 static void InternalFieldOutOfBounds(int index);
8157 template <class T> friend class Local;
8158 template <class T>
8159 friend class MaybeLocal;
8160 template <class T>
8161 friend class Maybe;
8162 template <class T>
8163 friend class WeakCallbackInfo;
8164 template <class T> friend class Eternal;
8165 template <class T> friend class PersistentBase;
8166 template <class T, class M> friend class Persistent;
8167 friend class Context;
8168};
8169
8174 public:
8175 enum class FunctionCodeHandling { kClear, kKeep };
8176
8185 SnapshotCreator(const intptr_t* external_references = nullptr,
8186 StartupData* existing_blob = nullptr);
8189
8193 Isolate* GetIsolate();
8194
8202 void SetDefaultContext(Local<Context> context,
8205
8214 size_t AddContext(Local<Context> context,
8217
8222 size_t AddTemplate(Local<Template> template_obj);
8223
8232 StartupData CreateBlob(FunctionCodeHandling function_code_handling);
8233
8234 // Disallow copying and assigning.
8236 void operator=(const SnapshotCreator&) = delete;
8237
8238 private:
8239 void* data_;
8240};
8241
8252template <class T>
8253class Maybe {
8254 public:
8255 V8_INLINE bool IsNothing() const { return !has_value_; }
8256 V8_INLINE bool IsJust() const { return has_value_; }
8257
8261 V8_INLINE T ToChecked() const { return FromJust(); }
8262
8267 V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const {
8268 if (V8_LIKELY(IsJust())) *out = value_;
8269 return IsJust();
8270 }
8271
8276 V8_INLINE T FromJust() const {
8277 if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
8278 return value_;
8279 }
8280
8285 V8_INLINE T FromMaybe(const T& default_value) const {
8286 return has_value_ ? value_ : default_value;
8287 }
8289 V8_INLINE bool operator==(const Maybe& other) const {
8290 return (IsJust() == other.IsJust()) &&
8291 (!IsJust() || FromJust() == other.FromJust());
8292 }
8294 V8_INLINE bool operator!=(const Maybe& other) const {
8295 return !operator==(other);
8296 }
8297
8298 private:
8299 Maybe() : has_value_(false) {}
8300 explicit Maybe(const T& t) : has_value_(true), value_(t) {}
8301
8302 bool has_value_;
8303 T value_;
8304
8305 template <class U>
8306 friend Maybe<U> Nothing();
8307 template <class U>
8308 friend Maybe<U> Just(const U& u);
8309};
8310
8311
8312template <class T>
8313inline Maybe<T> Nothing() {
8314 return Maybe<T>();
8315}
8316
8317
8318template <class T>
8319inline Maybe<T> Just(const T& t) {
8320 return Maybe<T>(t);
8321}
8322
8323
8327class V8_EXPORT TryCatch {
8328 public:
8334 V8_DEPRECATED("Use isolate version", TryCatch());
8335
8341 TryCatch(Isolate* isolate);
8342
8346 ~TryCatch();
8347
8351 bool HasCaught() const;
8352
8361 bool CanContinue() const;
8362
8375 bool HasTerminated() const;
8376
8384 Local<Value> ReThrow();
8385
8392 Local<Value> Exception() const;
8393
8398 V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace() const);
8400 Local<Context> context) const;
8401
8410
8421 void Reset();
8422
8431 void SetVerbose(bool value);
8432
8436 bool IsVerbose() const;
8437
8443 void SetCaptureMessage(bool value);
8444
8456 static void* JSStackComparableAddress(TryCatch* handler) {
8457 if (handler == NULL) return NULL;
8458 return handler->js_stack_comparable_address_;
8459 }
8461 TryCatch(const TryCatch&) = delete;
8462 void operator=(const TryCatch&) = delete;
8463
8464 private:
8465 // Declaring operator new and delete as deleted is not spec compliant.
8466 // Therefore declare them private instead to disable dynamic alloc
8467 void* operator new(size_t size);
8468 void* operator new[](size_t size);
8469 void operator delete(void*, size_t);
8470 void operator delete[](void*, size_t);
8471
8472 void ResetInternal();
8473
8474 internal::Isolate* isolate_;
8475 TryCatch* next_;
8476 void* exception_;
8477 void* message_obj_;
8478 void* js_stack_comparable_address_;
8479 bool is_verbose_ : 1;
8480 bool can_continue_ : 1;
8481 bool capture_message_ : 1;
8482 bool rethrow_ : 1;
8483 bool has_terminated_ : 1;
8485 friend class internal::Isolate;
8486};
8487
8488
8489// --- Context ---
8490
8491
8496 public:
8497 ExtensionConfiguration() : name_count_(0), names_(NULL) { }
8498 ExtensionConfiguration(int name_count, const char* names[])
8499 : name_count_(name_count), names_(names) { }
8501 const char** begin() const { return &names_[0]; }
8502 const char** end() const { return &names_[name_count_]; }
8503
8504 private:
8505 const int name_count_;
8506 const char** names_;
8507};
8508
8513class V8_EXPORT Context {
8514 public:
8527 Local<Object> Global();
8528
8533 void DetachGlobal();
8534
8553 static Local<Context> New(
8554 Isolate* isolate, ExtensionConfiguration* extensions = NULL,
8555 MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
8556 MaybeLocal<Value> global_object = MaybeLocal<Value>(),
8557 DeserializeInternalFieldsCallback internal_fields_deserializer =
8558 DeserializeInternalFieldsCallback());
8559
8579 static MaybeLocal<Context> FromSnapshot(
8580 Isolate* isolate, size_t context_snapshot_index,
8581 DeserializeInternalFieldsCallback embedder_fields_deserializer =
8582 DeserializeInternalFieldsCallback(),
8583 ExtensionConfiguration* extensions = nullptr,
8584 MaybeLocal<Value> global_object = MaybeLocal<Value>());
8585
8603 static MaybeLocal<Object> NewRemoteContext(
8604 Isolate* isolate, Local<ObjectTemplate> global_template,
8605 MaybeLocal<Value> global_object = MaybeLocal<Value>());
8606
8611 void SetSecurityToken(Local<Value> token);
8612
8614 void UseDefaultSecurityToken();
8615
8617 Local<Value> GetSecurityToken();
8618
8625 void Enter();
8626
8631 void Exit();
8632
8634 Isolate* GetIsolate();
8635
8640 enum EmbedderDataFields { kDebugIdIndex = 0 };
8641
8646 V8_INLINE Local<Value> GetEmbedderData(int index);
8647
8654 Local<Object> GetExtrasBindingObject();
8655
8661 void SetEmbedderData(int index, Local<Value> value);
8662
8669 V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
8670
8676 void SetAlignedPointerInEmbedderData(int index, void* value);
8677
8691 void AllowCodeGenerationFromStrings(bool allow);
8692
8697 bool IsCodeGenerationFromStringsAllowed();
8698
8704 void SetErrorMessageForCodeGenerationFromStrings(Local<String> message);
8705
8709 V8_DEPRECATED("no longer supported", size_t EstimatedSize());
8710
8715 class Scope {
8716 public:
8717 explicit V8_INLINE Scope(Local<Context> context) : context_(context) {
8718 context_->Enter();
8720 V8_INLINE ~Scope() { context_->Exit(); }
8721
8722 private:
8723 Local<Context> context_;
8724 };
8725
8731 class BackupIncumbentScope {
8732 public:
8737 explicit BackupIncumbentScope(Local<Context> backup_incumbent_context);
8739
8740 private:
8741 friend class internal::Isolate;
8742
8743 Local<Context> backup_incumbent_context_;
8744 const BackupIncumbentScope* prev_ = nullptr;
8745 };
8746
8747 private:
8748 friend class Value;
8749 friend class Script;
8750 friend class Object;
8751 friend class Function;
8752
8753 Local<Value> SlowGetEmbedderData(int index);
8754 void* SlowGetAlignedPointerFromEmbedderData(int index);
8755};
8756
8757
8834class V8_EXPORT Unlocker {
8835 public:
8839 V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
8841 ~Unlocker();
8842 private:
8843 void Initialize(Isolate* isolate);
8844
8845 internal::Isolate* isolate_;
8846};
8847
8849class V8_EXPORT Locker {
8850 public:
8854 V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
8856 ~Locker();
8857
8862 static bool IsLocked(Isolate* isolate);
8863
8867 static bool IsActive();
8868
8869 // Disallow copying and assigning.
8870 Locker(const Locker&) = delete;
8871 void operator=(const Locker&) = delete;
8872
8873 private:
8874 void Initialize(Isolate* isolate);
8875
8876 bool has_lock_;
8877 bool top_level_;
8878 internal::Isolate* isolate_;
8879};
8880
8881
8882// --- Implementation ---
8883
8884
8885namespace internal {
8887const int kApiPointerSize = sizeof(void*); // NOLINT
8888const int kApiIntSize = sizeof(int); // NOLINT
8889const int kApiInt64Size = sizeof(int64_t); // NOLINT
8890
8891// Tag information for HeapObject.
8892const int kHeapObjectTag = 1;
8894const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
8895
8896// Tag information for Smi.
8897const int kSmiTag = 0;
8898const int kSmiTagSize = 1;
8899const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
8901template <size_t ptr_size> struct SmiTagging;
8902
8903template<int kSmiShiftSize>
8904V8_INLINE internal::Object* IntToSmi(int value) {
8905 int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
8906 uintptr_t tagged_value =
8907 (static_cast<uintptr_t>(value) << smi_shift_bits) | kSmiTag;
8908 return reinterpret_cast<internal::Object*>(tagged_value);
8909}
8910
8911// Smi constants for 32-bit systems.
8912template <> struct SmiTagging<4> {
8913 enum { kSmiShiftSize = 0, kSmiValueSize = 31 };
8914 static int SmiShiftSize() { return kSmiShiftSize; }
8915 static int SmiValueSize() { return kSmiValueSize; }
8916 V8_INLINE static int SmiToInt(const internal::Object* value) {
8917 int shift_bits = kSmiTagSize + kSmiShiftSize;
8918 // Throw away top 32 bits and shift down (requires >> to be sign extending).
8919 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits;
8921 V8_INLINE static internal::Object* IntToSmi(int value) {
8922 return internal::IntToSmi<kSmiShiftSize>(value);
8924 V8_INLINE static bool IsValidSmi(intptr_t value) {
8925 // To be representable as an tagged small integer, the two
8926 // most-significant bits of 'value' must be either 00 or 11 due to
8927 // sign-extension. To check this we add 01 to the two
8928 // most-significant bits, and check if the most-significant bit is 0
8929 //
8930 // CAUTION: The original code below:
8931 // bool result = ((value + 0x40000000) & 0x80000000) == 0;
8932 // may lead to incorrect results according to the C language spec, and
8933 // in fact doesn't work correctly with gcc4.1.1 in some cases: The
8934 // compiler may produce undefined results in case of signed integer
8935 // overflow. The computation must be done w/ unsigned ints.
8936 return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
8937 }
8938};
8939
8940// Smi constants for 64-bit systems.
8941template <> struct SmiTagging<8> {
8942 enum { kSmiShiftSize = 31, kSmiValueSize = 32 };
8943 static int SmiShiftSize() { return kSmiShiftSize; }
8944 static int SmiValueSize() { return kSmiValueSize; }
8945 V8_INLINE static int SmiToInt(const internal::Object* value) {
8946 int shift_bits = kSmiTagSize + kSmiShiftSize;
8947 // Shift down and throw away top 32 bits.
8948 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits);
8950 V8_INLINE static internal::Object* IntToSmi(int value) {
8951 return internal::IntToSmi<kSmiShiftSize>(value);
8953 V8_INLINE static bool IsValidSmi(intptr_t value) {
8954 // To be representable as a long smi, the value must be a 32-bit integer.
8955 return (value == static_cast<int32_t>(value));
8956 }
8957};
8960const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
8961const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
8962V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
8963V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
8964
8970class Internals {
8971 public:
8972 // These values match non-compiler-dependent values defined within
8973 // the implementation of v8.
8974 static const int kHeapObjectMapOffset = 0;
8975 static const int kMapInstanceTypeAndBitFieldOffset =
8977 static const int kStringResourceOffset = 3 * kApiPointerSize;
8979 static const int kOddballKindOffset = 4 * kApiPointerSize + sizeof(double);
8981 static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
8983 static const int kContextHeaderSize = 2 * kApiPointerSize;
8984 static const int kContextEmbedderDataIndex = 5;
8985 static const int kFullStringRepresentationMask = 0x0f;
8986 static const int kStringEncodingMask = 0x8;
8987 static const int kExternalTwoByteRepresentationTag = 0x02;
8988 static const int kExternalOneByteRepresentationTag = 0x0a;
8992 static const int kExternalMemoryLimitOffset =
8999 static const int kUndefinedValueRootIndex = 4;
9000 static const int kTheHoleValueRootIndex = 5;
9001 static const int kNullValueRootIndex = 6;
9002 static const int kTrueValueRootIndex = 7;
9003 static const int kFalseValueRootIndex = 8;
9004 static const int kEmptyStringRootIndex = 9;
9006 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
9007 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
9008 static const int kNodeStateMask = 0x7;
9009 static const int kNodeStateIsWeakValue = 2;
9010 static const int kNodeStateIsPendingValue = 3;
9011 static const int kNodeStateIsNearDeathValue = 4;
9012 static const int kNodeIsIndependentShift = 3;
9013 static const int kNodeIsActiveShift = 4;
9015 static const int kJSApiObjectType = 0xbd;
9016 static const int kJSObjectType = 0xbe;
9017 static const int kFirstNonstringType = 0x80;
9018 static const int kOddballType = 0x82;
9019 static const int kForeignType = 0x86;
9021 static const int kUndefinedOddballKind = 5;
9022 static const int kNullOddballKind = 3;
9024 static const uint32_t kNumIsolateDataSlots = 4;
9027 V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
9028#ifdef V8_ENABLE_CHECKS
9029 CheckInitializedImpl(isolate);
9030#endif
9031 }
9033 V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) {
9034 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
9036 }
9038 V8_INLINE static int SmiValue(const internal::Object* value) {
9039 return PlatformSmiTagging::SmiToInt(value);
9040 }
9042 V8_INLINE static internal::Object* IntToSmi(int value) {
9043 return PlatformSmiTagging::IntToSmi(value);
9044 }
9046 V8_INLINE static bool IsValidSmi(intptr_t value) {
9047 return PlatformSmiTagging::IsValidSmi(value);
9048 }
9050 V8_INLINE static int GetInstanceType(const internal::Object* obj) {
9051 typedef internal::Object O;
9052 O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
9053 // Map::InstanceType is defined so that it will always be loaded into
9054 // the LS 8 bits of one 16-bit word, regardless of endianess.
9055 return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff;
9056 }
9058 V8_INLINE static int GetOddballKind(const internal::Object* obj) {
9059 typedef internal::Object O;
9060 return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
9061 }
9063 V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
9064 int representation = (instance_type & kFullStringRepresentationMask);
9065 return representation == kExternalTwoByteRepresentationTag;
9066 }
9068 V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
9069 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9070 return *addr & static_cast<uint8_t>(1U << shift);
9071 }
9073 V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
9074 bool value, int shift) {
9075 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9076 uint8_t mask = static_cast<uint8_t>(1U << shift);
9077 *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
9078 }
9080 V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
9081 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9082 return *addr & kNodeStateMask;
9083 }
9085 V8_INLINE static void UpdateNodeState(internal::Object** obj,
9086 uint8_t value) {
9087 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
9088 *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
9089 }
9091 V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
9092 uint32_t slot,
9093 void* data) {
9094 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
9096 *reinterpret_cast<void**>(addr) = data;
9097 }
9099 V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
9100 uint32_t slot) {
9101 const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
9103 return *reinterpret_cast<void* const*>(addr);
9104 }
9106 V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
9107 int index) {
9108 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
9109 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
9110 }
9111
9112 template <typename T>
9113 V8_INLINE static T ReadField(const internal::Object* ptr, int offset) {
9114 const uint8_t* addr =
9115 reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
9116 return *reinterpret_cast<const T*>(addr);
9117 }
9118
9119 template <typename T>
9120 V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) {
9121 typedef internal::Object O;
9122 typedef internal::Internals I;
9123 O* ctx = *reinterpret_cast<O* const*>(context);
9124 int embedder_data_offset = I::kContextHeaderSize +
9125 (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
9126 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
9127 int value_offset =
9128 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
9129 return I::ReadField<T>(embedder_data, value_offset);
9130 }
9131};
9132
9133} // namespace internal
9134
9135
9136template <class T>
9137Local<T> Local<T>::New(Isolate* isolate, Local<T> that) {
9138 return New(isolate, that.val_);
9139}
9140
9141template <class T>
9142Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) {
9143 return New(isolate, that.val_);
9144}
9145
9146
9147template <class T>
9148Local<T> Local<T>::New(Isolate* isolate, T* that) {
9149 if (that == NULL) return Local<T>();
9150 T* that_ptr = that;
9151 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
9152 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
9153 reinterpret_cast<internal::Isolate*>(isolate), *p)));
9154}
9155
9156
9157template<class T>
9158template<class S>
9159void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
9160 TYPE_CHECK(T, S);
9161 val_ = reinterpret_cast<T*>(
9162 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle)));
9163}
9164
9165template <class T>
9166Local<T> Eternal<T>::Get(Isolate* isolate) const {
9167 // The eternal handle will never go away, so as with the roots, we don't even
9168 // need to open a handle.
9169 return Local<T>(val_);
9170}
9171
9172
9173template <class T>
9175 if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
9176 return Local<T>(val_);
9177}
9178
9179
9180template <class T>
9181void* WeakCallbackInfo<T>::GetInternalField(int index) const {
9182#ifdef V8_ENABLE_CHECKS
9183 if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
9184 V8::InternalFieldOutOfBounds(index);
9185 }
9186#endif
9187 return embedder_fields_[index];
9188}
9189
9190
9191template <class T>
9192T* PersistentBase<T>::New(Isolate* isolate, T* that) {
9193 if (that == NULL) return NULL;
9194 internal::Object** p = reinterpret_cast<internal::Object**>(that);
9195 return reinterpret_cast<T*>(
9196 V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
9197 p));
9198}
9199
9200
9201template <class T, class M>
9202template <class S, class M2>
9203void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
9204 TYPE_CHECK(T, S);
9205 this->Reset();
9206 if (that.IsEmpty()) return;
9207 internal::Object** p = reinterpret_cast<internal::Object**>(that.val_);
9208 this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p));
9209 M::Copy(that, this);
9210}
9211
9212
9213template <class T>
9215 typedef internal::Internals I;
9216 if (this->IsEmpty()) return false;
9217 return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
9218 I::kNodeIsIndependentShift);
9219}
9220
9221
9222template <class T>
9223bool PersistentBase<T>::IsNearDeath() const {
9224 typedef internal::Internals I;
9225 if (this->IsEmpty()) return false;
9226 uint8_t node_state =
9227 I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_));
9228 return node_state == I::kNodeStateIsNearDeathValue ||
9229 node_state == I::kNodeStateIsPendingValue;
9230}
9231
9232
9233template <class T>
9234bool PersistentBase<T>::IsWeak() const {
9235 typedef internal::Internals I;
9236 if (this->IsEmpty()) return false;
9237 return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
9238 I::kNodeStateIsWeakValue;
9239}
9240
9241
9242template <class T>
9244 if (this->IsEmpty()) return;
9245 V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_));
9246 val_ = 0;
9247}
9248
9249
9250template <class T>
9251template <class S>
9252void PersistentBase<T>::Reset(Isolate* isolate, const Local<S>& other) {
9253 TYPE_CHECK(T, S);
9254 Reset();
9255 if (other.IsEmpty()) return;
9256 this->val_ = New(isolate, other.val_);
9257}
9258
9259
9260template <class T>
9261template <class S>
9262void PersistentBase<T>::Reset(Isolate* isolate,
9263 const PersistentBase<S>& other) {
9264 TYPE_CHECK(T, S);
9265 Reset();
9266 if (other.IsEmpty()) return;
9267 this->val_ = New(isolate, other.val_);
9268}
9269
9270
9271template <class T>
9272template <typename P>
9274 P* parameter, typename WeakCallbackInfo<P>::Callback callback,
9275 WeakCallbackType type) {
9276 typedef typename WeakCallbackInfo<void>::Callback Callback;
9277 V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
9278 reinterpret_cast<Callback>(callback), type);
9279}
9280
9281template <class T>
9283 V8::MakeWeak(reinterpret_cast<internal::Object***>(&this->val_));
9284}
9285
9286template <class T>
9287template <typename P>
9289 return reinterpret_cast<P*>(
9290 V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
9291}
9292
9293template <class T>
9295 if (IsEmpty()) return;
9296 V8::RegisterExternallyReferencedObject(
9297 reinterpret_cast<internal::Object**>(this->val_),
9298 reinterpret_cast<internal::Isolate*>(isolate));
9299}
9300
9301template <class T>
9303 typedef internal::Internals I;
9304 if (this->IsEmpty()) return;
9305 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
9306 true,
9307 I::kNodeIsIndependentShift);
9308}
9309
9310template <class T>
9312 typedef internal::Internals I;
9313 if (this->IsEmpty()) return;
9314 I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), true,
9315 I::kNodeIsActiveShift);
9316}
9317
9318
9319template <class T>
9320void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
9321 typedef internal::Internals I;
9322 if (this->IsEmpty()) return;
9323 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
9324 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9325 *reinterpret_cast<uint16_t*>(addr) = class_id;
9326}
9327
9328
9329template <class T>
9330uint16_t PersistentBase<T>::WrapperClassId() const {
9331 typedef internal::Internals I;
9332 if (this->IsEmpty()) return 0;
9333 internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_);
9334 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
9335 return *reinterpret_cast<uint16_t*>(addr);
9336}
9337
9338
9339template<typename T>
9340ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
9341
9342template<typename T>
9343template<typename S>
9344void ReturnValue<T>::Set(const Persistent<S>& handle) {
9345 TYPE_CHECK(T, S);
9346 if (V8_UNLIKELY(handle.IsEmpty())) {
9347 *value_ = GetDefaultValue();
9348 } else {
9349 *value_ = *reinterpret_cast<internal::Object**>(*handle);
9350 }
9351}
9352
9353template <typename T>
9354template <typename S>
9355void ReturnValue<T>::Set(const Global<S>& handle) {
9356 TYPE_CHECK(T, S);
9357 if (V8_UNLIKELY(handle.IsEmpty())) {
9358 *value_ = GetDefaultValue();
9359 } else {
9360 *value_ = *reinterpret_cast<internal::Object**>(*handle);
9361 }
9362}
9363
9364template <typename T>
9365template <typename S>
9366void ReturnValue<T>::Set(const Local<S> handle) {
9367 TYPE_CHECK(T, S);
9368 if (V8_UNLIKELY(handle.IsEmpty())) {
9369 *value_ = GetDefaultValue();
9370 } else {
9371 *value_ = *reinterpret_cast<internal::Object**>(*handle);
9372 }
9373}
9374
9375template<typename T>
9376void ReturnValue<T>::Set(double i) {
9377 TYPE_CHECK(T, Number);
9378 Set(Number::New(GetIsolate(), i));
9379}
9380
9381template<typename T>
9382void ReturnValue<T>::Set(int32_t i) {
9383 TYPE_CHECK(T, Integer);
9384 typedef internal::Internals I;
9385 if (V8_LIKELY(I::IsValidSmi(i))) {
9386 *value_ = I::IntToSmi(i);
9387 return;
9388 }
9389 Set(Integer::New(GetIsolate(), i));
9390}
9391
9392template<typename T>
9393void ReturnValue<T>::Set(uint32_t i) {
9394 TYPE_CHECK(T, Integer);
9395 // Can't simply use INT32_MAX here for whatever reason.
9396 bool fits_into_int32_t = (i & (1U << 31)) == 0;
9397 if (V8_LIKELY(fits_into_int32_t)) {
9398 Set(static_cast<int32_t>(i));
9399 return;
9400 }
9401 Set(Integer::NewFromUnsigned(GetIsolate(), i));
9402}
9403
9404template<typename T>
9405void ReturnValue<T>::Set(bool value) {
9406 TYPE_CHECK(T, Boolean);
9407 typedef internal::Internals I;
9408 int root_index;
9409 if (value) {
9410 root_index = I::kTrueValueRootIndex;
9411 } else {
9412 root_index = I::kFalseValueRootIndex;
9413 }
9414 *value_ = *I::GetRoot(GetIsolate(), root_index);
9415}
9416
9417template<typename T>
9420 typedef internal::Internals I;
9421 *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
9422}
9423
9424template<typename T>
9427 typedef internal::Internals I;
9428 *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
9429}
9430
9431template<typename T>
9433 TYPE_CHECK(T, String);
9434 typedef internal::Internals I;
9435 *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
9436}
9437
9438template <typename T>
9440 // Isolate is always the pointer below the default value on the stack.
9441 return *reinterpret_cast<Isolate**>(&value_[-2]);
9442}
9443
9444template <typename T>
9446 typedef internal::Internals I;
9447 if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex))
9448 return Local<Value>(*Undefined(GetIsolate()));
9449 return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
9450}
9451
9452template <typename T>
9453template <typename S>
9454void ReturnValue<T>::Set(S* whatever) {
9455 // Uncompilable to prevent inadvertent misuse.
9456 TYPE_CHECK(S*, Primitive);
9457}
9458
9459template<typename T>
9460internal::Object* ReturnValue<T>::GetDefaultValue() {
9461 // Default value is always the pointer below value_ on the stack.
9462 return value_[-1];
9463}
9464
9465template <typename T>
9466FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args,
9467 internal::Object** values,
9468 int length)
9469 : implicit_args_(implicit_args), values_(values), length_(length) {}
9470
9471template<typename T>
9473 if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate()));
9474 return Local<Value>(reinterpret_cast<Value*>(values_ - i));
9475}
9476
9477
9478template<typename T>
9480 return Local<Function>(reinterpret_cast<Function*>(
9481 &implicit_args_[kCalleeIndex]));
9482}
9483
9484
9485template<typename T>
9487 return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
9488}
9489
9490
9491template<typename T>
9493 return Local<Object>(reinterpret_cast<Object*>(
9494 &implicit_args_[kHolderIndex]));
9495}
9496
9497template <typename T>
9499 return Local<Value>(
9500 reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex]));
9501}
9502
9503template <typename T>
9505 return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));
9506}
9507
9508
9509template<typename T>
9511 return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
9512}
9513
9514
9515template<typename T>
9517 return ReturnValue<T>(&implicit_args_[kReturnValueIndex]);
9518}
9519
9520
9521template<typename T>
9523 return !NewTarget()->IsUndefined();
9524}
9525
9526
9527template<typename T>
9529 return length_;
9530}
9533 Local<Integer> resource_line_offset,
9534 Local<Integer> resource_column_offset,
9535 Local<Boolean> resource_is_shared_cross_origin,
9536 Local<Integer> script_id,
9537 Local<Value> source_map_url,
9538 Local<Boolean> resource_is_opaque,
9539 Local<Boolean> is_wasm, Local<Boolean> is_module)
9540 : resource_name_(resource_name),
9541 resource_line_offset_(resource_line_offset),
9542 resource_column_offset_(resource_column_offset),
9543 options_(!resource_is_shared_cross_origin.IsEmpty() &&
9544 resource_is_shared_cross_origin->IsTrue(),
9545 !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
9546 !is_wasm.IsEmpty() && is_wasm->IsTrue(),
9547 !is_module.IsEmpty() && is_module->IsTrue()),
9548 script_id_(script_id),
9549 source_map_url_(source_map_url) {}
9551Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
9552
9555 return resource_line_offset_;
9556}
9557
9560 return resource_column_offset_;
9561}
9562
9564Local<Integer> ScriptOrigin::ScriptID() const { return script_id_; }
9565
9567Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
9568
9571 CachedData* data)
9572 : source_string(string),
9573 resource_name(origin.ResourceName()),
9574 resource_line_offset(origin.ResourceLineOffset()),
9575 resource_column_offset(origin.ResourceColumnOffset()),
9576 resource_options(origin.Options()),
9577 source_map_url(origin.SourceMapUrl()),
9578 cached_data(data) {}
9579
9582 CachedData* data)
9583 : source_string(string), cached_data(data) {}
9584
9587 delete cached_data;
9588}
9589
9592 const {
9593 return cached_data;
9594}
9597 return resource_options;
9598}
9600Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
9601 return value ? True(isolate) : False(isolate);
9602}
9604void Template::Set(Isolate* isolate, const char* name, Local<Data> value) {
9606 .ToLocalChecked(),
9607 value);
9608}
9609
9612#ifndef V8_ENABLE_CHECKS
9613 typedef internal::Object O;
9614 typedef internal::HeapObject HO;
9615 typedef internal::Internals I;
9616 O* obj = *reinterpret_cast<O**>(this);
9617 // Fast path: If the object is a plain JSObject, which is the common case, we
9618 // know where to find the internal fields and can return the value directly.
9619 auto instance_type = I::GetInstanceType(obj);
9620 if (instance_type == I::kJSObjectType ||
9621 instance_type == I::kJSApiObjectType) {
9622 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
9623 O* value = I::ReadField<O*>(obj, offset);
9624 O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
9625 return Local<Value>(reinterpret_cast<Value*>(result));
9626 }
9627#endif
9628 return SlowGetInternalField(index);
9629}
9630
9633#ifndef V8_ENABLE_CHECKS
9634 typedef internal::Object O;
9635 typedef internal::Internals I;
9636 O* obj = *reinterpret_cast<O**>(this);
9637 // Fast path: If the object is a plain JSObject, which is the common case, we
9638 // know where to find the internal fields and can return the value directly.
9639 auto instance_type = I::GetInstanceType(obj);
9640 if (V8_LIKELY(instance_type == I::kJSObjectType ||
9641 instance_type == I::kJSApiObjectType)) {
9642 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
9643 return I::ReadField<void*>(obj, offset);
9644 }
9645#endif
9646 return SlowGetAlignedPointerFromInternalField(index);
9647}
9649String* String::Cast(v8::Value* value) {
9650#ifdef V8_ENABLE_CHECKS
9651 CheckCast(value);
9652#endif
9653 return static_cast<String*>(value);
9654}
9655
9658 typedef internal::Object* S;
9659 typedef internal::Internals I;
9660 I::CheckInitialized(isolate);
9661 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
9662 return Local<String>(reinterpret_cast<String*>(slot));
9663}
9664
9667 typedef internal::Object O;
9668 typedef internal::Internals I;
9669 O* obj = *reinterpret_cast<O* const*>(this);
9671 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
9672 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
9673 result = reinterpret_cast<String::ExternalStringResource*>(value);
9674 } else {
9675 result = NULL;
9676 }
9677#ifdef V8_ENABLE_CHECKS
9678 VerifyExternalStringResource(result);
9679#endif
9680 return result;
9681}
9682
9685 String::Encoding* encoding_out) const {
9686 typedef internal::Object O;
9687 typedef internal::Internals I;
9688 O* obj = *reinterpret_cast<O* const*>(this);
9689 int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
9690 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
9691 ExternalStringResourceBase* resource = NULL;
9692 if (type == I::kExternalOneByteRepresentationTag ||
9693 type == I::kExternalTwoByteRepresentationTag) {
9694 void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
9695 resource = static_cast<ExternalStringResourceBase*>(value);
9696 }
9697#ifdef V8_ENABLE_CHECKS
9698 VerifyExternalStringResourceBase(resource, *encoding_out);
9699#endif
9700 return resource;
9701}
9702
9704bool Value::IsUndefined() const {
9705#ifdef V8_ENABLE_CHECKS
9706 return FullIsUndefined();
9707#else
9708 return QuickIsUndefined();
9709#endif
9710}
9711
9712bool Value::QuickIsUndefined() const {
9713 typedef internal::Object O;
9714 typedef internal::Internals I;
9715 O* obj = *reinterpret_cast<O* const*>(this);
9716 if (!I::HasHeapObjectTag(obj)) return false;
9717 if (I::GetInstanceType(obj) != I::kOddballType) return false;
9718 return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
9719}
9720
9722bool Value::IsNull() const {
9723#ifdef V8_ENABLE_CHECKS
9724 return FullIsNull();
9725#else
9726 return QuickIsNull();
9727#endif
9728}
9729
9730bool Value::QuickIsNull() const {
9731 typedef internal::Object O;
9732 typedef internal::Internals I;
9733 O* obj = *reinterpret_cast<O* const*>(this);
9734 if (!I::HasHeapObjectTag(obj)) return false;
9735 if (I::GetInstanceType(obj) != I::kOddballType) return false;
9736 return (I::GetOddballKind(obj) == I::kNullOddballKind);
9737}
9739bool Value::IsNullOrUndefined() const {
9740#ifdef V8_ENABLE_CHECKS
9741 return FullIsNull() || FullIsUndefined();
9742#else
9743 return QuickIsNullOrUndefined();
9744#endif
9745}
9746
9747bool Value::QuickIsNullOrUndefined() const {
9748 typedef internal::Object O;
9749 typedef internal::Internals I;
9750 O* obj = *reinterpret_cast<O* const*>(this);
9751 if (!I::HasHeapObjectTag(obj)) return false;
9752 if (I::GetInstanceType(obj) != I::kOddballType) return false;
9753 int kind = I::GetOddballKind(obj);
9754 return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind;
9755}
9757bool Value::IsString() const {
9758#ifdef V8_ENABLE_CHECKS
9759 return FullIsString();
9760#else
9761 return QuickIsString();
9762#endif
9763}
9764
9765bool Value::QuickIsString() const {
9766 typedef internal::Object O;
9767 typedef internal::Internals I;
9768 O* obj = *reinterpret_cast<O* const*>(this);
9769 if (!I::HasHeapObjectTag(obj)) return false;
9770 return (I::GetInstanceType(obj) < I::kFirstNonstringType);
9771}
9772
9774template <class T> Value* Value::Cast(T* value) {
9775 return static_cast<Value*>(value);
9776}
9777
9780 return ToBoolean(Isolate::GetCurrent()->GetCurrentContext())
9781 .FromMaybe(Local<Boolean>());
9782}
9783
9786 return ToNumber(Isolate::GetCurrent()->GetCurrentContext())
9787 .FromMaybe(Local<Number>());
9788}
9789
9792 return ToString(Isolate::GetCurrent()->GetCurrentContext())
9793 .FromMaybe(Local<String>());
9794}
9795
9798 return ToDetailString(Isolate::GetCurrent()->GetCurrentContext())
9799 .FromMaybe(Local<String>());
9800}
9801
9804 return ToObject(Isolate::GetCurrent()->GetCurrentContext())
9805 .FromMaybe(Local<Object>());
9806}
9807
9810 return ToInteger(Isolate::GetCurrent()->GetCurrentContext())
9811 .FromMaybe(Local<Integer>());
9812}
9813
9816 return ToUint32(Isolate::GetCurrent()->GetCurrentContext())
9817 .FromMaybe(Local<Uint32>());
9818}
9819
9822 return ToInt32(Isolate::GetCurrent()->GetCurrentContext())
9823 .FromMaybe(Local<Int32>());
9824}
9825
9828#ifdef V8_ENABLE_CHECKS
9829 CheckCast(value);
9830#endif
9831 return static_cast<Boolean*>(value);
9832}
9833
9835Name* Name::Cast(v8::Value* value) {
9836#ifdef V8_ENABLE_CHECKS
9837 CheckCast(value);
9838#endif
9839 return static_cast<Name*>(value);
9840}
9841
9843Symbol* Symbol::Cast(v8::Value* value) {
9844#ifdef V8_ENABLE_CHECKS
9845 CheckCast(value);
9846#endif
9847 return static_cast<Symbol*>(value);
9848}
9849
9851Number* Number::Cast(v8::Value* value) {
9852#ifdef V8_ENABLE_CHECKS
9853 CheckCast(value);
9854#endif
9855 return static_cast<Number*>(value);
9856}
9857
9860#ifdef V8_ENABLE_CHECKS
9861 CheckCast(value);
9862#endif
9863 return static_cast<Integer*>(value);
9864}
9865
9867Int32* Int32::Cast(v8::Value* value) {
9868#ifdef V8_ENABLE_CHECKS
9869 CheckCast(value);
9870#endif
9871 return static_cast<Int32*>(value);
9872}
9873
9875Uint32* Uint32::Cast(v8::Value* value) {
9876#ifdef V8_ENABLE_CHECKS
9877 CheckCast(value);
9878#endif
9879 return static_cast<Uint32*>(value);
9880}
9881
9883Date* Date::Cast(v8::Value* value) {
9884#ifdef V8_ENABLE_CHECKS
9885 CheckCast(value);
9886#endif
9887 return static_cast<Date*>(value);
9888}
9889
9892#ifdef V8_ENABLE_CHECKS
9893 CheckCast(value);
9894#endif
9895 return static_cast<StringObject*>(value);
9896}
9897
9900#ifdef V8_ENABLE_CHECKS
9901 CheckCast(value);
9902#endif
9903 return static_cast<SymbolObject*>(value);
9904}
9905
9908#ifdef V8_ENABLE_CHECKS
9909 CheckCast(value);
9910#endif
9911 return static_cast<NumberObject*>(value);
9912}
9913
9916#ifdef V8_ENABLE_CHECKS
9917 CheckCast(value);
9918#endif
9919 return static_cast<BooleanObject*>(value);
9920}
9921
9923RegExp* RegExp::Cast(v8::Value* value) {
9924#ifdef V8_ENABLE_CHECKS
9925 CheckCast(value);
9926#endif
9927 return static_cast<RegExp*>(value);
9928}
9929
9931Object* Object::Cast(v8::Value* value) {
9932#ifdef V8_ENABLE_CHECKS
9933 CheckCast(value);
9934#endif
9935 return static_cast<Object*>(value);
9936}
9937
9939Array* Array::Cast(v8::Value* value) {
9940#ifdef V8_ENABLE_CHECKS
9941 CheckCast(value);
9942#endif
9943 return static_cast<Array*>(value);
9944}
9945
9947Map* Map::Cast(v8::Value* value) {
9948#ifdef V8_ENABLE_CHECKS
9949 CheckCast(value);
9950#endif
9951 return static_cast<Map*>(value);
9952}
9953
9955Set* Set::Cast(v8::Value* value) {
9956#ifdef V8_ENABLE_CHECKS
9957 CheckCast(value);
9958#endif
9959 return static_cast<Set*>(value);
9960}
9961
9964#ifdef V8_ENABLE_CHECKS
9965 CheckCast(value);
9966#endif
9967 return static_cast<Promise*>(value);
9968}
9969
9971Proxy* Proxy::Cast(v8::Value* value) {
9972#ifdef V8_ENABLE_CHECKS
9973 CheckCast(value);
9974#endif
9975 return static_cast<Proxy*>(value);
9976}
9979#ifdef V8_ENABLE_CHECKS
9980 CheckCast(value);
9981#endif
9982 return static_cast<WasmCompiledModule*>(value);
9983}
9986#ifdef V8_ENABLE_CHECKS
9987 CheckCast(value);
9988#endif
9989 return static_cast<Promise::Resolver*>(value);
9990}
9991
9994#ifdef V8_ENABLE_CHECKS
9995 CheckCast(value);
9996#endif
9997 return static_cast<ArrayBuffer*>(value);
9998}
9999
10002#ifdef V8_ENABLE_CHECKS
10003 CheckCast(value);
10004#endif
10005 return static_cast<ArrayBufferView*>(value);
10006}
10007
10010#ifdef V8_ENABLE_CHECKS
10011 CheckCast(value);
10012#endif
10013 return static_cast<TypedArray*>(value);
10014}
10015
10018#ifdef V8_ENABLE_CHECKS
10019 CheckCast(value);
10020#endif
10021 return static_cast<Uint8Array*>(value);
10022}
10023
10026#ifdef V8_ENABLE_CHECKS
10027 CheckCast(value);
10028#endif
10029 return static_cast<Int8Array*>(value);
10030}
10031
10034#ifdef V8_ENABLE_CHECKS
10035 CheckCast(value);
10036#endif
10037 return static_cast<Uint16Array*>(value);
10038}
10039
10042#ifdef V8_ENABLE_CHECKS
10043 CheckCast(value);
10044#endif
10045 return static_cast<Int16Array*>(value);
10046}
10047
10050#ifdef V8_ENABLE_CHECKS
10051 CheckCast(value);
10052#endif
10053 return static_cast<Uint32Array*>(value);
10054}
10055
10058#ifdef V8_ENABLE_CHECKS
10059 CheckCast(value);
10060#endif
10061 return static_cast<Int32Array*>(value);
10062}
10063
10066#ifdef V8_ENABLE_CHECKS
10067 CheckCast(value);
10068#endif
10069 return static_cast<Float32Array*>(value);
10070}
10071
10074#ifdef V8_ENABLE_CHECKS
10075 CheckCast(value);
10076#endif
10077 return static_cast<Float64Array*>(value);
10078}
10079
10082#ifdef V8_ENABLE_CHECKS
10083 CheckCast(value);
10084#endif
10085 return static_cast<Uint8ClampedArray*>(value);
10086}
10087
10090#ifdef V8_ENABLE_CHECKS
10091 CheckCast(value);
10092#endif
10093 return static_cast<DataView*>(value);
10094}
10095
10098#ifdef V8_ENABLE_CHECKS
10099 CheckCast(value);
10100#endif
10101 return static_cast<SharedArrayBuffer*>(value);
10102}
10103
10106#ifdef V8_ENABLE_CHECKS
10107 CheckCast(value);
10108#endif
10109 return static_cast<Function*>(value);
10110}
10111
10114#ifdef V8_ENABLE_CHECKS
10115 CheckCast(value);
10116#endif
10117 return static_cast<External*>(value);
10118}
10119
10120
10121template<typename T>
10123 return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
10124}
10125
10126
10127template<typename T>
10129 return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
10130}
10131
10132
10133template<typename T>
10135 return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
10136}
10137
10138
10139template<typename T>
10141 return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
10142}
10143
10144
10145template<typename T>
10147 return ReturnValue<T>(&args_[kReturnValueIndex]);
10148}
10149
10150template <typename T>
10152 typedef internal::Internals I;
10153 return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(0);
10154}
10155
10158 typedef internal::Object* S;
10159 typedef internal::Internals I;
10160 I::CheckInitialized(isolate);
10161 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
10162 return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
10163}
10164
10166Local<Primitive> Null(Isolate* isolate) {
10167 typedef internal::Object* S;
10168 typedef internal::Internals I;
10169 I::CheckInitialized(isolate);
10170 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
10171 return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
10172}
10173
10175Local<Boolean> True(Isolate* isolate) {
10176 typedef internal::Object* S;
10177 typedef internal::Internals I;
10178 I::CheckInitialized(isolate);
10179 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
10180 return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
10181}
10182
10184Local<Boolean> False(Isolate* isolate) {
10185 typedef internal::Object* S;
10186 typedef internal::Internals I;
10187 I::CheckInitialized(isolate);
10188 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
10189 return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
10190}
10191
10193void Isolate::SetData(uint32_t slot, void* data) {
10194 typedef internal::Internals I;
10195 I::SetEmbedderData(this, slot, data);
10196}
10197
10199void* Isolate::GetData(uint32_t slot) {
10200 typedef internal::Internals I;
10201 return I::GetEmbedderData(this, slot);
10202}
10203
10206 typedef internal::Internals I;
10207 return I::kNumIsolateDataSlots;
10208}
10209
10212 int64_t change_in_bytes) {
10213 typedef internal::Internals I;
10214 const int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024;
10215 int64_t* external_memory = reinterpret_cast<int64_t*>(
10216 reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
10217 int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
10218 reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
10219 int64_t* external_memory_at_last_mc =
10220 reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
10221 I::kExternalMemoryAtLastMarkCompactOffset);
10222 const int64_t amount = *external_memory + change_in_bytes;
10223
10224 *external_memory = amount;
10225
10226 int64_t allocation_diff_since_last_mc =
10227 *external_memory_at_last_mc - *external_memory;
10228 allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
10229 ? -allocation_diff_since_last_mc
10230 : allocation_diff_since_last_mc;
10231 if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
10232 CheckMemoryPressure();
10233 }
10234
10235 if (change_in_bytes < 0) {
10236 *external_memory_limit += change_in_bytes;
10237 }
10238
10239 if (change_in_bytes > 0 && amount > *external_memory_limit) {
10240 ReportExternalAllocationLimitReached();
10241 }
10242 return *external_memory;
10243}
10246#ifndef V8_ENABLE_CHECKS
10247 typedef internal::Object O;
10248 typedef internal::HeapObject HO;
10249 typedef internal::Internals I;
10250 HO* context = *reinterpret_cast<HO**>(this);
10251 O** result =
10252 HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
10253 return Local<Value>(reinterpret_cast<Value*>(result));
10254#else
10255 return SlowGetEmbedderData(index);
10256#endif
10257}
10258
10261#ifndef V8_ENABLE_CHECKS
10262 typedef internal::Internals I;
10263 return I::ReadEmbedderData<void*>(this, index);
10264#else
10265 return SlowGetAlignedPointerFromEmbedderData(index);
10266#endif
10267}
10269bool V8::IsDead() {
10270 Isolate* isolate = Isolate::GetCurrent();
10271 return isolate->IsDead();
10272}
10273
10276 Isolate* isolate = Isolate::GetCurrent();
10277 return isolate->AddMessageListener(that, data);
10278}
10279
10282 Isolate* isolate = Isolate::GetCurrent();
10283 isolate->RemoveMessageListeners(that);
10284}
10285
10288 FailedAccessCheckCallback callback) {
10289 Isolate* isolate = Isolate::GetCurrent();
10290 isolate->SetFailedAccessCheckCallbackFunction(callback);
10291}
10292
10295 bool capture, int frame_limit, StackTrace::StackTraceOptions options) {
10296 Isolate* isolate = Isolate::GetCurrent();
10297 isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit,
10298 options);
10299}
10300
10303 Isolate* isolate = Isolate::GetCurrent();
10304 isolate->SetFatalErrorHandler(callback);
10305}
10308 Isolate* isolate = Isolate::GetCurrent();
10309 isolate->RemoveGCPrologueCallback(
10310 reinterpret_cast<Isolate::GCCallback>(callback));
10311}
10312
10315 Isolate* isolate = Isolate::GetCurrent();
10316 isolate->RemoveGCEpilogueCallback(
10317 reinterpret_cast<Isolate::GCCallback>(callback));
10318}
10320void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); }
10321
10323bool V8::IsExecutionTerminating(Isolate* isolate) {
10324 if (isolate == NULL) {
10325 isolate = Isolate::GetCurrent();
10326 }
10327 return isolate->IsExecutionTerminating();
10328}
10329
10332 isolate->CancelTerminateExecution();
10333}
10334
10337 Isolate* isolate = Isolate::GetCurrent();
10338 isolate->VisitExternalResources(visitor);
10339}
10340
10343 Isolate* isolate = Isolate::GetCurrent();
10344 isolate->VisitHandlesWithClassIds(visitor);
10345}
10346
10349 PersistentHandleVisitor* visitor) {
10350 isolate->VisitHandlesWithClassIds(visitor);
10351}
10352
10355 PersistentHandleVisitor* visitor) {
10356 isolate->VisitHandlesForPartialDependence(visitor);
10357}
10358
10371} // namespace v8
10372
10373
10374#undef TYPE_CHECK
10375
10376
10377#endif // INCLUDE_V8_H_
Definition: v8.h:5963
Definition: v8.h:4462
Local< ArrayBuffer > Buffer()
static ArrayBufferView * Cast(Value *obj)
Definition: v8.h:10000
size_t CopyContents(void *dest, size_t byte_length)
bool HasBuffer() const
Definition: v8.h:4275
virtual void Free(void *data, size_t length)=0
static Allocator * NewDefaultAllocator()
virtual void * AllocateUninitialized(size_t length)=0
virtual void SetProtection(void *data, size_t length, Protection protection)
AllocationMode
Definition: v8.h:4304
virtual void Free(void *data, size_t length, AllocationMode mode)
virtual void * Allocate(size_t length)=0
virtual void * Reserve(size_t length)
Protection
Definition: v8.h:4314
virtual ~Allocator()
Definition: v8.h:4277
Definition: v8.h:4344
void * Data() const
Definition: v8.h:4359
Contents()
Definition: v8.h:4346
Allocator::AllocationMode AllocationMode() const
Definition: v8.h:4355
size_t AllocationLength() const
Definition: v8.h:4354
size_t ByteLength() const
Definition: v8.h:4360
void * AllocationBase() const
Definition: v8.h:4353
Definition: v8.h:4258
bool IsExternal() const
static ArrayBuffer * Cast(Value *obj)
Definition: v8.h:9992
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
bool IsNeuterable() const
Contents Externalize()
static Local< ArrayBuffer > New(Isolate *isolate, void *data, size_t byte_length, ArrayBufferCreationMode mode=ArrayBufferCreationMode::kExternalized)
Contents GetContents()
size_t ByteLength() const
Definition: v8.h:3503
Local< Object > CloneElementAt(uint32_t index)
static Local< Array > New(Isolate *isolate, int length=0)
uint32_t Length() const
static Array * Cast(Value *obj)
Definition: v8.h:9938
Definition: v8.h:4872
static BooleanObject * Cast(Value *obj)
Definition: v8.h:9914
bool ValueOf() const
static Local< Value > New(Isolate *isolate, bool value)
static Local< Value > New(bool value)
Definition: v8.h:2399
bool Value() const
static Boolean * Cast(v8::Value *obj)
Definition: v8.h:9826
static Local< Boolean > New(Isolate *isolate, bool value)
Definition: v8.h:9599
Definition: v8.h:8714
Definition: v8.h:8512
Local< Value > GetEmbedderData(int index)
Definition: v8.h:10244
void * GetAlignedPointerFromEmbedderData(int index)
Definition: v8.h:10259
Definition: v8-profiler.h:280
Definition: v8.h:4689
static Local< DataView > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< DataView > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static DataView * Cast(Value *obj)
Definition: v8.h:10088
Definition: v8.h:976
Definition: v8.h:4819
static MaybeLocal< Value > New(Local< Context > context, double time)
static void DateTimeConfigurationChangeNotification(Isolate *isolate)
double ValueOf() const
static Local< Value > New(Isolate *isolate, double time)
static Date * Cast(Value *obj)
Definition: v8.h:9882
Definition: v8.h:6659
ForceCompletionAction
Definition: v8.h:6661
Definition: v8.h:912
EscapableHandleScope(const EscapableHandleScope &)=delete
Local< T > Escape(Local< T > value)
Definition: v8.h:922
void operator=(const EscapableHandleScope &)=delete
~EscapableHandleScope()
Definition: v8.h:915
EscapableHandleScope(Isolate *isolate)
Definition: v8.h:393
Local< T > Get(Isolate *isolate) const
Definition: v8.h:9165
void Set(Isolate *isolate, Local< S > handle)
Definition: v8.h:9158
Eternal()
Definition: v8.h:395
bool IsEmpty() const
Definition: v8.h:402
Eternal(Isolate *isolate, Local< S > handle)
Definition: v8.h:397
Definition: v8.h:6147
Definition: v8.h:8494
ExtensionConfiguration(int name_count, const char *names[])
Definition: v8.h:8497
Definition: v8.h:5993
ExternalOneByteStringResourceImpl(const char *data, size_t length)
Definition: v8.h:5980
Definition: v8.h:6621
Definition: v8.h:4976
void * Value() const
static External * Cast(Value *obj)
Definition: v8.h:10112
static Local< External > New(Isolate *isolate, void *value)
Definition: v8.h:4655
static Local< Float32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Float32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Float32Array * Cast(Value *obj)
Definition: v8.h:10064
Definition: v8.h:4672
static Local< Float64Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Float64Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Float64Array * Cast(Value *obj)
Definition: v8.h:10072
Definition: v8.h:3654
static const int kHolderIndex
Definition: v8.h:3692
static const int kCalleeIndex
Definition: v8.h:3697
static const int kReturnValueDefaultValueIndex
Definition: v8.h:3694
static const int kIsolateIndex
Definition: v8.h:3693
static const int kDataIndex
Definition: v8.h:3696
static const int kArgsLength
Definition: v8.h:3686
internal::Object ** values_
Definition: v8.h:3704
static const int kNewTargetIndex
Definition: v8.h:3699
ReturnValue< T > GetReturnValue() const
Definition: v8.h:9515
Local< Object > This() const
Definition: v8.h:9485
Local< Object > Holder() const
Definition: v8.h:9491
Local< Value > operator[](int i) const
Definition: v8.h:9471
Isolate * GetIsolate() const
Definition: v8.h:9509
static const int kContextSaveIndex
Definition: v8.h:3698
Local< Value > NewTarget() const
Definition: v8.h:9497
friend class debug::ConsoleCallArguments
Definition: v8.h:3691
friend class internal::FunctionCallbackArguments
Definition: v8.h:3689
Local< Value > Data() const
Definition: v8.h:9503
int length_
Definition: v8.h:3705
internal::Object ** implicit_args_
Definition: v8.h:3703
static const int kReturnValueIndex
Definition: v8.h:3695
bool IsConstructCall() const
Definition: v8.h:9521
FunctionCallbackInfo(internal::Object **implicit_args, internal::Object **values, int length)
Definition: v8.h:9465
Local< Function > Callee() const
Definition: v8.h:9478
int Length() const
Definition: v8.h:9527
Definition: v8.h:5471
MaybeLocal< Function > GetFunction(Local< Context > context)
Definition: v8.h:3828
MaybeLocal< Value > Call(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
bool IsBuiltin() const
Local< Value > GetName() const
Local< Value > GetInferredName() const
Local< Value > GetDisplayName() const
int ScriptId() const
int GetScriptLineNumber() const
MaybeLocal< Object > NewInstance(Local< Context > context) const
Definition: v8.h:3849
ScriptOrigin GetScriptOrigin() const
int GetScriptColumnNumber() const
static MaybeLocal< Function > New(Local< Context > context, FunctionCallback callback, Local< Value > data=Local< Value >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow)
Local< Object > NewInstance(int argc, Local< Value > argv[]) const
void SetName(Local< String > name)
static const int kLineOffsetNotFound
Definition: v8.h:3913
MaybeLocal< Object > NewInstance(Local< Context > context, int argc, Local< Value > argv[]) const
Local< Object > NewInstance() const
Local< Value > GetBoundFunction() const
static Function * Cast(Value *obj)
Definition: v8.h:10104
Local< Value > GetDebugName() const
Definition: v8.h:771
void MoveOnlyTypeForCPP03
Definition: v8.h:825
Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8.h:793
Global & operator=(Global< S > &&rhs)
Definition: v8.h:808
void operator=(const Global &)=delete
~Global()
Definition: v8.h:803
Global Pass()
Definition: v8.h:820
Global(Isolate *isolate, Local< S > that)
Definition: v8.h:783
Global(Global &&other)
Definition: v8.h:800
Global()
Definition: v8.h:776
Global(const Global &)=delete
Definition: v8.h:856
void operator=(const HandleScope &)=delete
static internal::Object ** CreateHandle(internal::Isolate *isolate, internal::Object *value)
HandleScope()
Definition: v8.h:875
void Initialize(Isolate *isolate)
HandleScope(const HandleScope &)=delete
Isolate * GetIsolate() const
Definition: v8.h:867
static int NumberOfHandles(Isolate *isolate)
HandleScope(Isolate *isolate)
Definition: v8.h:6484
Definition: v8.h:6467
Definition: v8-profiler.h:626
Definition: v8.h:6447
Definition: v8.h:6413
Definition: v8.h:4604
static Local< Int16Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Int16Array * Cast(Value *obj)
Definition: v8.h:10040
static Local< Int16Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
Definition: v8.h:4638
static Local< Int32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Int32Array * Cast(Value *obj)
Definition: v8.h:10056
static Local< Int32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
Definition: v8.h:2942
static Int32 * Cast(v8::Value *obj)
Definition: v8.h:9866
int32_t Value() const
Definition: v8.h:4570
static Int8Array * Cast(Value *obj)
Definition: v8.h:10024
static Local< Int8Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Int8Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
Definition: v8.h:2927
static Local< Integer > New(Isolate *isolate, int32_t value)
static Integer * Cast(v8::Value *obj)
Definition: v8.h:9858
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
int64_t Value() const
Definition: v8.h:6853
Definition: v8.h:6768
void RemoveMessageListeners(MessageCallback that)
void RemoveGCEpilogueCallback(GCCallback callback)
void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
void SetFatalErrorHandler(FatalErrorCallback that)
bool AddMessageListener(MessageCallback that, Local< Value > data=Local< Value >())
void SetData(uint32_t slot, void *data)
Definition: v8.h:10192
void VisitExternalResources(ExternalResourceVisitor *visitor)
static Isolate * GetCurrent()
GarbageCollectionType
Definition: v8.h:6934
bool IsDead()
static uint32_t GetNumberOfDataSlots()
Definition: v8.h:10204
void CancelTerminateExecution()
void RemoveGCPrologueCallback(GCCallback callback)
void RemoveCallCompletedCallback(DeprecatedCallCompletedCallback callback)
void VisitHandlesWithClassIds(PersistentHandleVisitor *visitor)
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
Definition: v8.h:10210
void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)
void(* GCCallback)(Isolate *isolate, GCType type, GCCallbackFlags flags)
Definition: v8.h:7259
void VisitHandlesForPartialDependence(PersistentHandleVisitor *visitor)
MessageErrorLevel
Definition: v8.h:6992
void TerminateExecution()
void Enter()
UseCounterFeature
Definition: v8.h:6944
void * GetData(uint32_t slot)
Definition: v8.h:10198
bool IsExecutionTerminating()
Definition: v8.h:1760
static Local< Value > Parse(Local< String > json_string)
static MaybeLocal< String > Stringify(Local< Context > context, Local< Object > json_object, Local< String > gap=Local< String >())
static MaybeLocal< Value > Parse(Local< Context > context, Local< String > json_string)
Definition: v8.h:197
friend Local< Primitive > Null(Isolate *isolate)
Definition: v8.h:10165
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8.h:9136
bool IsEmpty() const
Definition: v8.h:214
friend Local< Boolean > False(Isolate *isolate)
Definition: v8.h:10183
friend Local< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:10156
T * operator*() const
Definition: v8.h:223
static Local< T > Cast(Local< S > that)
Definition: v8.h:270
Local< S > As() const
Definition: v8.h:285
bool operator!=(const Local< S > &that) const
Definition: v8.h:256
bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:240
friend Local< Boolean > True(Isolate *isolate)
Definition: v8.h:10174
static Local< T > New(Isolate *isolate, const PersistentBase< T > &that)
Definition: v8.h:9141
void Clear()
Definition: v8.h:219
bool operator!=(const Persistent< S > &that) const
Definition: v8.h:260
friend class Utils
Definition: v8.h:299
Local()
Definition: v8.h:199
T * operator->() const
Definition: v8.h:221
bool operator==(const Local< S > &that) const
Definition: v8.h:232
Local(Local< S > that)
Definition: v8.h:201
friend class Local
Definition: v8.h:303
Definition: v8.h:1082
int GetLineNumber()
Definition: v8.h:1084
Location(int line_number, int column_number)
Definition: v8.h:1087
int GetColumnNumber()
Definition: v8.h:1085
Definition: v8.h:8848
Definition: v8.h:3533
void Clear()
Local< Array > AsArray() const
static Local< Map > New(Isolate *isolate)
Maybe< bool > Delete(Local< Context > context, Local< Value > key)
size_t Size() const
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
Maybe< bool > Has(Local< Context > context, Local< Value > key)
MaybeLocal< Map > Set(Local< Context > context, Local< Value > key, Local< Value > value)
static Map * Cast(Value *obj)
Definition: v8.h:9946
Definition: v8.h:349
bool ToLocal(Local< S > *out) const
Definition: v8.h:365
Local< T > ToLocalChecked()
Definition: v8.h:9173
Local< S > FromMaybe(Local< S > default_value) const
Definition: v8.h:381
MaybeLocal()
Definition: v8.h:351
bool IsEmpty() const
Definition: v8.h:358
MaybeLocal(Local< S > that)
Definition: v8.h:353
Definition: v8.h:8252
friend Maybe< U > Nothing()
Definition: v8.h:8312
T FromMaybe(const T &default_value) const
Definition: v8.h:8284
bool operator!=(const Maybe &other) const
Definition: v8.h:8293
bool IsNothing() const
Definition: v8.h:8254
T FromJust() const
Definition: v8.h:8275
bool To(T *out) const
Definition: v8.h:8266
friend Maybe< U > Just(const U &u)
bool IsJust() const
Definition: v8.h:8255
bool operator==(const Maybe &other) const
Definition: v8.h:8288
T ToChecked() const
Definition: v8.h:8260
Definition: v8.h:1526
Local< String > GetSourceLine() const
ScriptOrigin GetScriptOrigin() const
int GetStartColumn() const
MaybeLocal< String > GetSourceLine(Local< Context > context) const
Local< String > Get() const
bool IsSharedCrossOrigin() const
Local< StackTrace > GetStackTrace() const
int GetStartPosition() const
int ErrorLevel() const
int GetEndPosition() const
Maybe< int > GetLineNumber(Local< Context > context) const
Maybe< int > GetEndColumn(Local< Context > context) const
bool IsOpaque() const
int GetEndColumn() const
static void PrintCurrentStackTrace(Isolate *isolate, FILE *out)
int GetLineNumber() const
Maybe< int > GetStartColumn(Local< Context > context) const
Local< Value > GetScriptResourceName() const
Definition: v8.h:6307
Type
Definition: v8.h:6309
Definition: v8.h:1101
Maybe< bool > InstantiateModule(Local< Context > context, ResolveCallback callback)
MaybeLocal< Value > Evaluate(Local< Context > context)
Local< Value > GetModuleNamespace()
int GetModuleRequestsLength() const
Status GetStatus() const
Local< Value > GetException() const
Location GetModuleRequestLocation(int i) const
Status
Definition: v8.h:1106
@ kInstantiating
Definition: v8.h:1108
@ kInstantiated
Definition: v8.h:1109
@ kUninstantiated
Definition: v8.h:1107
@ kEvaluating
Definition: v8.h:1110
@ kEvaluated
Definition: v8.h:1111
int GetIdentityHash() const
Local< String > GetModuleRequest(int i) const
Definition: v8.h:2413
static Name * Cast(Value *obj)
Definition: v8.h:9834
int GetIdentityHash()
Definition: v8.h:2026
static Local< NativeWeakMap > New(Isolate *isolate)
bool Has(Local< Value > key)
Local< Value > Get(Local< Value > key) const
void Set(Local< Value > key, Local< Value > value)
bool Delete(Local< Value > key)
static void Uncompilable()
Definition: v8.h:647
static const bool kResetInDestructor
Definition: v8.h:640
static void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
Definition: v8.h:642
Persistent< T, NonCopyablePersistentTraits< T > > NonCopyablePersistent
Definition: v8.h:639
Definition: v8.h:4856
static NumberObject * Cast(Value *obj)
Definition: v8.h:9906
static Local< Value > New(Isolate *isolate, double value)
double ValueOf() const
Definition: v8.h:2913
static Number * Cast(v8::Value *obj)
Definition: v8.h:9850
static Local< Number > New(Isolate *isolate, double value)
double Value() const
Definition: v8.h:5729
MaybeLocal< Object > NewInstance(Local< Context > context)
Definition: v8.h:3054
Local< Value > Get(uint32_t index)
bool HasOwnProperty(Local< String > key)
Maybe< PropertyAttribute > GetRealNamedPropertyAttributesInPrototypeChain(Local< Context > context, Local< Name > key)
Maybe< PropertyAttribute > GetPropertyAttributes(Local< Context > context, Local< Value > key)
void SetAlignedPointerInInternalField(int index, void *value)
Maybe< bool > CreateDataProperty(Local< Context > context, uint32_t index, Local< Value > value)
Local< Context > CreationContext()
MaybeLocal< Value > GetOwnPropertyDescriptor(Local< Context > context, Local< Name > key)
bool HasNamedLookupInterceptor()
static Object * Cast(Value *obj)
Definition: v8.h:9930
Maybe< bool > SetPrivate(Local< Context > context, Local< Private > key, Local< Value > value)
bool IsCallable()
Maybe< bool > HasRealNamedProperty(Local< Context > context, Local< Name > key)
bool IsConstructor()
MaybeLocal< Array > GetPropertyNames(Local< Context > context)
bool HasIndexedLookupInterceptor()
Maybe< bool > Delete(Local< Context > context, uint32_t index)
void SetAccessorProperty(Local< Name > name, Local< Function > getter, Local< Function > setter=Local< Function >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
bool HasRealIndexedProperty(uint32_t index)
MaybeLocal< Value > GetRealNamedProperty(Local< Context > context, Local< Name > key)
Maybe< bool > DefineProperty(Local< Context > context, Local< Name > key, PropertyDescriptor &descriptor)
bool Has(Local< Value > key)
Maybe< bool > SetPrototype(Local< Context > context, Local< Value > prototype)
Maybe< bool > Delete(Local< Context > context, Local< Value > key)
MaybeLocal< Value > CallAsFunction(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
Local< Object > Clone()
Maybe< bool > DefineOwnProperty(Local< Context > context, Local< Name > key, Local< Value > value, PropertyAttribute attributes=None)
Local< Value > GetRealNamedPropertyInPrototypeChain(Local< String > key)
void * GetAlignedPointerFromInternalField(int index)
Definition: v8.h:9631
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8.h:3301
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
Maybe< bool > Has(Local< Context > context, Local< Value > key)
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
bool HasRealNamedCallbackProperty(Local< String > key)
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context, PropertyFilter filter)
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
bool Delete(uint32_t index)
MaybeLocal< Value > CallAsConstructor(Local< Context > context, int argc, Local< Value > argv[])
static void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index)
Definition: v8.h:3320
Local< Value > GetPrototype()
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None)
bool SetPrototype(Local< Value > prototype)
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
Local< Array > GetOwnPropertyNames()
MaybeLocal< Array > GetPropertyNames(Local< Context > context, KeyCollectionMode mode, PropertyFilter property_filter, IndexFilter index_filter)
Maybe< bool > CreateDataProperty(Local< Context > context, Local< Name > key, Local< Value > value)
Maybe< bool > SetAccessor(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=0, MaybeLocal< Value > data=MaybeLocal< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None)
Local< Value > Get(Local< Value > key)
bool HasRealNamedProperty(Local< String > key)
Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
Isolate * GetIsolate()
MaybeLocal< String > ObjectProtoToString(Local< Context > context)
Local< Value > GetOwnPropertyDescriptor(Local< Name > key)
Local< String > ObjectProtoToString()
MaybeLocal< Value > Get(Local< Context > context, uint32_t index)
Maybe< bool > SetIntegrityLevel(Local< Context > context, IntegrityLevel level)
Local< Value > GetInternalField(int index)
Definition: v8.h:9610
Maybe< PropertyAttribute > GetRealNamedPropertyAttributes(Local< Context > context, Local< Name > key)
int InternalFieldCount()
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
Local< Value > CallAsConstructor(int argc, Local< Value > argv[])
Local< Object > FindInstanceInPrototypeChain(Local< FunctionTemplate > tmpl)
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
static Local< Object > New(Isolate *isolate)
int GetIdentityHash()
bool Has(uint32_t index)
Maybe< bool > Set(Local< Context > context, uint32_t index, Local< Value > value)
Maybe< bool > HasOwnProperty(Local< Context > context, Local< Name > key)
bool Delete(Local< Value > key)
Maybe< bool > Has(Local< Context > context, uint32_t index)
Maybe< bool > DeletePrivate(Local< Context > context, Local< Private > key)
Local< String > GetConstructorName()
PropertyAttribute GetPropertyAttributes(Local< Value > key)
void SetInternalField(int index, Local< Value > value)
static Local< Context > CreationContext(const PersistentBase< Object > &object)
Definition: v8.h:3444
void SetAlignedPointerInInternalFields(int argc, int indices[], void *values[])
Maybe< bool > HasRealNamedCallbackProperty(Local< Context > context, Local< Name > key)
bool Set(uint32_t index, Local< Value > value)
Local< Value > GetRealNamedProperty(Local< String > key)
Local< Array > GetPropertyNames()
bool Set(Local< Value > key, Local< Value > value)
Maybe< bool > HasOwnProperty(Local< Context > context, uint32_t index)
Definition: v8.h:481
void SetWeak(P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
Definition: v8.h:9272
void SetWeak()
Definition: v8.h:9281
void Reset()
Definition: v8.h:9242
void ClearWeak()
Definition: v8.h:562
Local< T > Get(Isolate *isolate) const
Definition: v8.h:505
void RegisterExternalReference(Isolate *isolate) const
Definition: v8.h:9293
bool IsWeak() const
Definition: v8.h:9233
void Empty()
Definition: v8.h:503
bool IsIndependent() const
Definition: v8.h:9213
bool IsNearDeath() const
Definition: v8.h:9222
void Reset(Isolate *isolate, const PersistentBase< S > &other)
Definition: v8.h:9261
void MarkActive()
Definition: v8.h:9310
bool operator==(const Local< S > &that) const
Definition: v8.h:519
P * ClearWeak()
Definition: v8.h:9287
PersistentBase(const PersistentBase &other)=delete
bool operator!=(const PersistentBase< S > &that) const
Definition: v8.h:528
void Reset(Isolate *isolate, const Local< S > &other)
Definition: v8.h:9251
bool operator==(const PersistentBase< S > &that) const
Definition: v8.h:510
friend class PersistentBase
Definition: v8.h:616
friend class Utils
Definition: v8.h:611
bool IsEmpty() const
Definition: v8.h:502
void SetWrapperClassId(uint16_t class_id)
Definition: v8.h:9319
uint16_t WrapperClassId() const
Definition: v8.h:9329
bool operator!=(const Local< S > &that) const
Definition: v8.h:533
void operator=(const PersistentBase &)=delete
void MarkIndependent()
Definition: v8.h:9301
Definition: v8.h:6631
Definition: v8-util.h:162
Definition: v8-util.h:574
Definition: v8.h:677
Persistent(Isolate *isolate, Local< S > that)
Definition: v8.h:689
~Persistent()
Definition: v8.h:730
Persistent(const Persistent< S, M2 > &that)
Definition: v8.h:713
Persistent()
Definition: v8.h:682
Persistent< S > & As() const
Definition: v8.h:747
static Persistent< T > & Cast(const Persistent< S > &that)
Definition: v8.h:736
Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8.h:721
Persistent & operator=(const Persistent &that)
Definition: v8.h:716
friend class Utils
Definition: v8.h:753
friend class Persistent
Definition: v8.h:755
Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8.h:699
Persistent(const Persistent &that)
Definition: v8.h:709
Definition: v8-platform.h:121
Definition: v8.h:2392
Definition: v8.h:2881
Local< Value > Name() const
static Local< Private > ForApi(Isolate *isolate, Local< String > name)
static Local< Private > New(Isolate *isolate, Local< String > name=Local< String >())
Definition: v8.h:6256
Local< Promise > GetPromise() const
Definition: v8.h:6265
PromiseRejectEvent GetEvent() const
Definition: v8.h:6266
Local< Value > GetValue() const
Definition: v8.h:6267
Local< StackTrace > GetStackTrace() const
Definition: v8.h:6270
Definition: v8.h:3936
static MaybeLocal< Resolver > New(Local< Context > context)
Maybe< bool > Resolve(Local< Context > context, Local< Value > value)
void Reject(Local< Value > value)
Local< Promise > GetPromise()
static Local< Resolver > New(Isolate *isolate)
static Resolver * Cast(Value *obj)
Definition: v8.h:9984
Maybe< bool > Reject(Local< Context > context, Local< Value > value)
void Resolve(Local< Value > value)
Definition: v8.h:3928
Local< Promise > Catch(Local< Function > handler)
PromiseState
Definition: v8.h:3934
@ kFulfilled
Definition: v8.h:3934
Local< Value > Result()
PromiseState State()
MaybeLocal< Promise > Catch(Local< Context > context, Local< Function > handler)
Local< Promise > Then(Local< Function > handler)
static Promise * Cast(Value *obj)
Definition: v8.h:9962
MaybeLocal< Promise > Then(Local< Context > context, Local< Function > handler)
bool HasHandler()
Definition: v8.h:3714
static const int kReturnValueDefaultValueIndex
Definition: v8.h:3811
Local< Value > Data() const
Definition: v8.h:10127
friend class internal::PropertyCallbackArguments
Definition: v8.h:3806
static const int kDataIndex
Definition: v8.h:3813
PropertyCallbackInfo(internal::Object **args)
Definition: v8.h:3816
internal::Object ** args_
Definition: v8.h:3817
static const int kIsolateIndex
Definition: v8.h:3810
Local< Object > Holder() const
Definition: v8.h:10139
static const int kThisIndex
Definition: v8.h:3814
bool ShouldThrowOnError() const
Definition: v8.h:10150
static const int kHolderIndex
Definition: v8.h:3809
static const int kArgsLength
Definition: v8.h:3802
ReturnValue< T > GetReturnValue() const
Definition: v8.h:10145
static const int kShouldThrowOnErrorIndex
Definition: v8.h:3808
static const int kReturnValueIndex
Definition: v8.h:3812
friend class MacroAssembler
Definition: v8.h:3805
Local< Object > This() const
Definition: v8.h:10133
Isolate * GetIsolate() const
Definition: v8.h:10121
Definition: v8.h:4040
void set_enumerable(bool enumerable)
bool has_writable() const
bool has_value() const
Local< Value > get() const
Local< Value > set() const
PropertyDescriptor(Local< Value > get, Local< Value > set)
bool has_enumerable() const
PropertyDescriptor(Local< Value > value)
PrivateData * get_private() const
Definition: v8.h:4076
void operator=(const PropertyDescriptor &)=delete
Local< Value > value() const
bool enumerable() const
PropertyDescriptor(Local< Value > value, bool writable)
void set_configurable(bool configurable)
PropertyDescriptor(const PropertyDescriptor &)=delete
bool has_configurable() const
bool configurable() const
Definition: v8.h:4089
void Revoke()
Local< Value > GetHandler()
static Proxy * Cast(Value *obj)
Definition: v8.h:9970
Local< Object > GetTarget()
bool IsRevoked()
static MaybeLocal< Proxy > New(Local< Context > context, Local< Object > local_target, Local< Object > local_handler)
Definition: v8.h:4921
Flags
Definition: v8.h:4927
Local< String > GetSource() const
Flags GetFlags() const
static RegExp * Cast(Value *obj)
Definition: v8.h:9922
static MaybeLocal< RegExp > New(Local< Context > context, Local< String > pattern, Flags flags)
Definition: v8.h:6055
Definition: v8-profiler.h:843
Definition: v8.h:3599
void Set(const Persistent< S > &handle)
Definition: v8.h:9343
void SetEmptyString()
Definition: v8.h:9431
friend class ReturnValue
Definition: v8.h:3635
ReturnValue(const ReturnValue< S > &that)
Definition: v8.h:3601
Local< Value > Get() const
Definition: v8.h:9444
void SetNull()
Definition: v8.h:9417
Isolate * GetIsolate() const
Definition: v8.h:9438
void SetUndefined()
Definition: v8.h:9424
virtual ~ExternalSourceStream()
Definition: v8.h:1305
virtual size_t GetMoreData(const uint8_t **src)=0
virtual ~ScriptStreamingTask()
Definition: v8.h:1379
Definition: v8.h:1261
~Source()
Definition: v8.h:9585
Source(const Source &)=delete
Source & operator=(const Source &)=delete
const CachedData * GetCachedData() const
Definition: v8.h:9590
const ScriptOriginOptions & GetResourceOptions() const
Definition: v8.h:9595
Source(Local< String > source_string, const ScriptOrigin &origin, CachedData *cached_data=NULL)
Definition: v8.h:9569
const CachedData * GetCachedData() const
StreamedSource(ExternalSourceStream *source_stream, Encoding encoding)
StreamedSource & operator=(const StreamedSource &)=delete
internal::StreamedSource * impl() const
Definition: v8.h:1363
StreamedSource(const StreamedSource &)=delete
Definition: v8.h:1218
static MaybeLocal< Module > CompileModule(Isolate *isolate, Source *source)
static MaybeLocal< UnboundScript > CompileUnboundScript(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions)
static MaybeLocal< Function > CompileFunctionInContext(Local< Context > context, Source *source, size_t arguments_count, Local< String > arguments[], size_t context_extension_count, Local< Object > context_extensions[])
static ScriptStreamingTask * StartStreamingScript(Isolate *isolate, StreamedSource *source, CompileOptions options=kNoCompileOptions)
CompileOptions
Definition: v8.h:1383
@ kProduceParserCache
Definition: v8.h:1385
@ kConsumeParserCache
Definition: v8.h:1386
@ kProduceCodeCache
Definition: v8.h:1387
static MaybeLocal< Script > Compile(Local< Context > context, StreamedSource *source, Local< String > full_source_string, const ScriptOrigin &origin)
static MaybeLocal< Script > Compile(Local< Context > context, Source *source, CompileOptions options=kNoCompileOptions)
static uint32_t CachedDataVersionTag()
Definition: v8.h:985
bool IsModule() const
Definition: v8.h:1002
bool IsWasm() const
Definition: v8.h:1001
ScriptOriginOptions(bool is_shared_cross_origin=false, bool is_opaque=false, bool is_wasm=false, bool is_module=false)
Definition: v8.h:987
bool IsOpaque() const
Definition: v8.h:1000
int Flags() const
Definition: v8.h:1004
ScriptOriginOptions(int flags)
Definition: v8.h:993
bool IsSharedCrossOrigin() const
Definition: v8.h:997
Definition: v8.h:1019
Local< Integer > ResourceColumnOffset() const
Definition: v8.h:9558
ScriptOriginOptions Options() const
Definition: v8.h:1037
ScriptOrigin(Local< Value > resource_name, Local< Integer > resource_line_offset=Local< Integer >(), Local< Integer > resource_column_offset=Local< Integer >(), 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 >())
Definition: v8.h:9531
Local< Value > ResourceName() const
Definition: v8.h:9550
Local< Value > SourceMapUrl() const
Definition: v8.h:9566
Local< Integer > ScriptID() const
Definition: v8.h:9563
Local< Integer > ResourceLineOffset() const
Definition: v8.h:9553
Definition: v8.h:1183
static MaybeLocal< Script > Compile(Local< Context > context, Local< String > source, ScriptOrigin *origin=nullptr)
MaybeLocal< Value > Run(Local< Context > context)
Local< UnboundScript > GetUnboundScript()
Local< Value > Run()
Definition: v8.h:948
SealHandleScope(const SealHandleScope &)=delete
void operator=(const SealHandleScope &)=delete
SealHandleScope(Isolate *isolate)
Definition: v8.h:3569
static Set * Cast(Value *obj)
Definition: v8.h:9954
static Local< Set > New(Isolate *isolate)
void Clear()
Maybe< bool > Delete(Local< Context > context, Local< Value > key)
Local< Array > AsArray() const
Maybe< bool > Has(Local< Context > context, Local< Value > key)
size_t Size() const
MaybeLocal< Set > Add(Local< Context > context, Local< Value > key)
Definition: v8.h:4720
Contents()
Definition: v8.h:4722
void * AllocationBase() const
Definition: v8.h:4729
size_t ByteLength() const
Definition: v8.h:4736
size_t AllocationLength() const
Definition: v8.h:4730
void * Data() const
Definition: v8.h:4735
ArrayBuffer::Allocator::AllocationMode AllocationMode() const
Definition: v8.h:4731
Definition: v8.h:4707
size_t ByteLength() const
static SharedArrayBuffer * Cast(Value *obj)
Definition: v8.h:10096
bool IsExternal() const
static Local< SharedArrayBuffer > New(Isolate *isolate, void *data, size_t byte_length, ArrayBufferCreationMode mode=ArrayBufferCreationMode::kExternalized)
static Local< SharedArrayBuffer > New(Isolate *isolate, size_t byte_length)
Definition: v8.h:5948
Definition: v8.h:8172
FunctionCodeHandling
Definition: v8.h:8174
Definition: v8.h:1663
int GetLineNumber() const
int GetColumn() const
Local< String > GetScriptName() const
Local< String > GetScriptNameOrSourceURL() const
bool IsConstructor() const
bool IsEval() const
Local< String > GetFunctionName() const
int GetScriptId() const
bool IsWasm() const
Definition: v8.h:1611
static Local< StackTrace > CurrentStackTrace(Isolate *isolate, int frame_limit, StackTraceOptions options=kDetailed)
Local< StackFrame > GetFrame(uint32_t index) const
StackTraceOptions
Definition: v8.h:1619
int GetFrameCount() const
Local< Array > AsArray()
Definition: v8.h:7749
Definition: v8.h:4889
Local< String > ValueOf() const
static StringObject * Cast(Value *obj)
Definition: v8.h:9890
static Local< Value > New(Local< String > value)
virtual ~ExternalOneByteStringResource()
Definition: v8.h:2628
ExternalOneByteStringResource()
Definition: v8.h:2634
virtual const char * data() const =0
virtual ~ExternalStringResourceBase()
Definition: v8.h:2558
void operator=(const ExternalStringResourceBase &)=delete
ExternalStringResourceBase(const ExternalStringResourceBase &)=delete
ExternalStringResourceBase()
Definition: v8.h:2563
virtual bool IsCompressible() const
Definition: v8.h:2560
virtual void Dispose()
Definition: v8.h:2571
virtual ~ExternalStringResource()
Definition: v8.h:2595
virtual const uint16_t * data() const =0
ExternalStringResource()
Definition: v8.h:2608
virtual size_t length() const =0
Definition: v8.h:2773
char * operator*()
Definition: v8.h:2779
Utf8Value(Isolate *isolate, Local< v8::Value > obj)
Utf8Value(const Utf8Value &)=delete
const char * operator*() const
Definition: v8.h:2780
Utf8Value(Local< v8::Value > obj)
void operator=(const Utf8Value &)=delete
int length() const
Definition: v8.h:2781
Definition: v8.h:2798
const uint16_t * operator*() const
Definition: v8.h:2805
uint16_t * operator*()
Definition: v8.h:2804
Value(Local< v8::Value > obj)
Value(Isolate *isolate, Local< v8::Value > obj)
Value(const Value &)=delete
void operator=(const Value &)=delete
int length() const
Definition: v8.h:2806
Definition: v8.h:2453
int Utf8Length() const
bool CanMakeExternal()
bool IsExternal() const
int WriteOneByte(uint8_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
bool IsExternalOneByte() const
bool ContainsOnlyOneByte() const
Encoding
Definition: v8.h:2458
ExternalStringResourceBase * GetExternalStringResourceBase(Encoding *encoding_out) const
Definition: v8.h:9683
NewStringType
Definition: v8.h:2660
static MaybeLocal< String > NewExternalOneByte(Isolate *isolate, ExternalOneByteStringResource *resource)
int Write(uint16_t *buffer, int start=0, int length=-1, int options=NO_OPTIONS) const
bool MakeExternal(ExternalStringResource *resource)
bool MakeExternal(ExternalOneByteStringResource *resource)
static MaybeLocal< String > NewFromTwoByte(Isolate *isolate, const uint16_t *data, v8::NewStringType type, int length=-1)
static MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, v8::NewStringType type, int length=-1)
const ExternalOneByteStringResource * GetExternalOneByteStringResource() const
static String * Cast(v8::Value *obj)
Definition: v8.h:9648
static MaybeLocal< String > NewExternalTwoByte(Isolate *isolate, ExternalStringResource *resource)
static MaybeLocal< String > NewFromOneByte(Isolate *isolate, const uint8_t *data, v8::NewStringType type, int length=-1)
bool IsOneByte() const
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
WriteOptions
Definition: v8.h:2514
int WriteUtf8(char *buffer, int length=-1, int *nchars_ref=NULL, int options=NO_OPTIONS) const
static Local< String > Empty(Isolate *isolate)
Definition: v8.h:9656
static Local< String > Concat(Local< String > left, Local< String > right)
ExternalStringResource * GetExternalStringResource() const
Definition: v8.h:9665
int Length() const
Definition: v8.h:4905
static SymbolObject * Cast(Value *obj)
Definition: v8.h:9898
Local< Symbol > ValueOf() const
static Local< Value > New(Isolate *isolate, Local< Symbol > value)
Definition: v8.h:2828
static Local< Symbol > GetMatch(Isolate *isolate)
static Local< Symbol > GetIterator(Isolate *isolate)
static Local< Symbol > GetSearch(Isolate *isolate)
static Local< Symbol > GetToPrimitive(Isolate *isolate)
static Local< Symbol > For(Isolate *isolate, Local< String > name)
static Local< Symbol > GetIsConcatSpreadable(Isolate *isolate)
static Local< Symbol > New(Isolate *isolate, Local< String > name=Local< String >())
Local< Value > Name() const
static Local< Symbol > GetReplace(Isolate *isolate)
static Symbol * Cast(Value *obj)
Definition: v8.h:9842
static Local< Symbol > GetToStringTag(Isolate *isolate)
static Local< Symbol > GetSplit(Isolate *isolate)
static Local< Symbol > GetUnscopables(Isolate *isolate)
static Local< Symbol > ForApi(Isolate *isolate, Local< String > name)
static Local< Symbol > GetHasInstance(Isolate *isolate)
Definition: v8.h:5005
void Set(Local< Name > name, Local< Data > value, PropertyAttribute attributes=None)
Definition: v8.h:8326
MaybeLocal< Value > StackTrace(Local< Context > context) const
Definition: v8.h:4511
size_t Length()
static TypedArray * Cast(Value *obj)
Definition: v8.h:10008
Definition: v8.h:4587
static Local< Uint16Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Uint16Array * Cast(Value *obj)
Definition: v8.h:10032
static Local< Uint16Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
Definition: v8.h:4621
static Uint32Array * Cast(Value *obj)
Definition: v8.h:10048
static Local< Uint32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Uint32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
Definition: v8.h:2956
static Uint32 * Cast(v8::Value *obj)
Definition: v8.h:9874
uint32_t Value() const
Definition: v8.h:4536
static Uint8Array * Cast(Value *obj)
Definition: v8.h:10016
static Local< Uint8Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Uint8Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
Definition: v8.h:4553
static Local< Uint8ClampedArray > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Uint8ClampedArray > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Uint8ClampedArray * Cast(Value *obj)
Definition: v8.h:10080
Definition: v8.h:1051
int GetLineNumber(int code_pos)
Local< Value > GetSourceMappingURL()
Local< Value > GetScriptName()
Local< Value > GetSourceURL()
Local< Script > BindToCurrentContext()
Definition: v8.h:8833
Definition: v8.h:7782
static void RemoveMessageListeners(MessageCallback that)
Definition: v8.h:10280
static void InitializeExternalStartupData(const char *natives_blob, const char *snapshot_blob)
static void TerminateExecution(Isolate *isolate)
Definition: v8.h:10319
static void SetFatalErrorHandler(FatalErrorCallback that)
Definition: v8.h:10301
static void SetCaptureStackTraceForUncaughtExceptions(bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
Definition: v8.h:10293
static void VisitExternalResources(ExternalResourceVisitor *visitor)
Definition: v8.h:10335
static bool AddMessageListener(MessageCallback that, Local< Value > data=Local< Value >())
Definition: v8.h:10274
static void VisitHandlesWithClassIds(PersistentHandleVisitor *visitor)
Definition: v8.h:10341
static void AddGCPrologueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
static void RemoveGCEpilogueCallback(GCCallback callback)
Definition: v8.h:10313
static void AddGCEpilogueCallback(GCCallback callback, GCType gc_type_filter=kGCTypeAll)
static bool IsExecutionTerminating(Isolate *isolate=NULL)
Definition: v8.h:10322
static bool IsDead()
Definition: v8.h:10268
static void RemoveGCPrologueCallback(GCCallback callback)
Definition: v8.h:10306
static void VisitHandlesForPartialDependence(Isolate *isolate, PersistentHandleVisitor *visitor)
Definition: v8.h:10353
static void CancelTerminateExecution(Isolate *isolate)
Definition: v8.h:10330
static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)
Definition: v8.h:10286
Definition: v8.h:1932
virtual MaybeLocal< Object > ReadHostObject(Isolate *isolate)
virtual ~Delegate()
Definition: v8.h:1934
virtual MaybeLocal< WasmCompiledModule > GetWasmModuleFromId(Isolate *isolate, uint32_t transfer_id)
Definition: v8.h:1930
bool ReadUint64(uint64_t *value)
void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format)
ValueDeserializer(Isolate *isolate, const uint8_t *data, size_t size, Delegate *delegate)
void SetExpectInlineWasm(bool allow_inline_wasm)
void TransferSharedArrayBuffer(uint32_t id, Local< SharedArrayBuffer > shared_array_buffer)
bool ReadDouble(double *value)
bool ReadUint32(uint32_t *value)
void TransferArrayBuffer(uint32_t transfer_id, Local< ArrayBuffer > array_buffer)
ValueDeserializer(Isolate *isolate, const uint8_t *data, size_t size)
Maybe< bool > ReadHeader(Local< Context > context)
MaybeLocal< Value > ReadValue(Local< Context > context)
uint32_t GetWireFormatVersion() const
bool ReadRawBytes(size_t length, const void **data)
Definition: v8.h:1799
virtual void * ReallocateBufferMemory(void *old_buffer, size_t size, size_t *actual_size)
virtual Maybe< uint32_t > GetSharedArrayBufferId(Isolate *isolate, Local< SharedArrayBuffer > shared_array_buffer)
virtual void ThrowDataCloneError(Local< String > message)=0
virtual ~Delegate()
Definition: v8.h:1801
virtual void FreeBufferMemory(void *buffer)
virtual Maybe< uint32_t > GetWasmModuleTransferId(Isolate *isolate, Local< WasmCompiledModule > module)
virtual Maybe< bool > WriteHostObject(Isolate *isolate, Local< Object > object)
Definition: v8.h:1797
void TransferArrayBuffer(uint32_t transfer_id, Local< ArrayBuffer > array_buffer)
std::vector< uint8_t > ReleaseBuffer()
void WriteUint64(uint64_t value)
void WriteDouble(double value)
ValueSerializer(Isolate *isolate)
std::pair< uint8_t *, size_t > Release()
ValueSerializer(Isolate *isolate, Delegate *delegate)
void WriteUint32(uint32_t value)
Maybe< bool > WriteValue(Local< Context > context, Local< Value > value)
void WriteRawBytes(const void *source, size_t length)
void SetTreatArrayBufferViewsAsHostObjects(bool mode)
Definition: v8.h:2042
MaybeLocal< String > ToDetailString(Local< Context > context) const
bool IsRegExp() const
bool IsTypedArray() const
Local< Number > ToNumber(Isolate *isolate) const
MaybeLocal< Boolean > ToBoolean(Local< Context > context) const
Maybe< int32_t > Int32Value(Local< Context > context) const
double NumberValue() const
bool Equals(Local< Value > that) const
bool IsSymbol() const
bool IsSet() const
Local< Uint32 > ToArrayIndex() const
Local< Boolean > ToBoolean() const
Definition: v8.h:9778
Local< String > ToString() const
Definition: v8.h:9790
bool IsName() const
Local< String > ToDetailString(Isolate *isolate) const
bool IsSymbolObject() const
bool IsSharedArrayBuffer() const
static Value * Cast(T *value)
Definition: v8.h:9773
Local< String > TypeOf(Isolate *)
Local< Uint32 > ToUint32(Isolate *isolate) const
Local< String > ToDetailString() const
Definition: v8.h:9796
MaybeLocal< Int32 > ToInt32(Local< Context > context) const
Maybe< double > NumberValue(Local< Context > context) const
bool IsStringObject() const
bool BooleanValue() const
Local< Integer > ToInteger(Isolate *isolate) const
bool IsWeakMap() const
bool IsProxy() const
bool IsNullOrUndefined() const
Definition: v8.h:9738
bool IsTrue() const
bool IsArray() const
bool IsNumberObject() const
bool IsPromise() const
bool IsBooleanObject() const
bool IsUint32Array() const
Local< Boolean > ToBoolean(Isolate *isolate) const
Local< Integer > ToInteger() const
Definition: v8.h:9808
bool IsArrayBuffer() const
bool IsUint8ClampedArray() const
Local< Uint32 > ToUint32() const
Definition: v8.h:9814
bool IsWeakSet() const
Maybe< bool > BooleanValue(Local< Context > context) const
bool IsString() const
Definition: v8.h:9756
bool IsNumber() const
bool IsObject() const
MaybeLocal< Uint32 > ToArrayIndex(Local< Context > context) const
bool IsMapIterator() const
bool IsNull() const
Definition: v8.h:9721
Local< String > ToString(Isolate *isolate) const
int64_t IntegerValue() const
bool IsBoolean() const
bool SameValue(Local< Value > that) const
bool IsNativeError() const
bool IsFloat64Array() const
bool IsFalse() const
bool IsMap() const
Maybe< int64_t > IntegerValue(Local< Context > context) const
Local< Int32 > ToInt32(Isolate *isolate) const
bool IsInt16Array() const
bool IsExternal() const
bool IsSetIterator() const
MaybeLocal< String > ToString(Local< Context > context) const
Local< Int32 > ToInt32() const
Definition: v8.h:9820
int32_t Int32Value() const
Local< Object > ToObject(Isolate *isolate) const
bool IsDate() const
Maybe< uint32_t > Uint32Value(Local< Context > context) const
Maybe< bool > Equals(Local< Context > context, Local< Value > that) const
bool IsFloat32Array() const
bool IsArrayBufferView() const
bool IsGeneratorFunction() const
Local< Object > ToObject() const
Definition: v8.h:9802
bool IsFunction() const
bool StrictEquals(Local< Value > that) const
MaybeLocal< Uint32 > ToUint32(Local< Context > context) const
bool IsUndefined() const
Definition: v8.h:9703
bool IsInt32() const
MaybeLocal< Number > ToNumber(Local< Context > context) const
bool IsDataView() const
bool IsInt8Array() const
Maybe< bool > InstanceOf(Local< Context > context, Local< Object > object)
bool IsArgumentsObject() const
bool IsAsyncFunction() const
bool IsUint32() const
MaybeLocal< Integer > ToInteger(Local< Context > context) const
uint32_t Uint32Value() const
MaybeLocal< Object > ToObject(Local< Context > context) const
Local< Number > ToNumber() const
Definition: v8.h:9784
bool IsUint8Array() const
bool IsUint16Array() const
bool IsGeneratorObject() const
bool IsWebAssemblyCompiledModule() const
bool IsInt32Array() const
TransferrableModule & operator=(TransferrableModule &&src)=default
TransferrableModule(TransferrableModule &&src)=default
TransferrableModule(const TransferrableModule &src)=delete
TransferrableModule & operator=(const TransferrableModule &src)=delete
Definition: v8.h:4112
static MaybeLocal< WasmCompiledModule > DeserializeOrCompile(Isolate *isolate, const CallerOwnedBuffer &serialized_module, const CallerOwnedBuffer &wire_bytes)
SerializedModule Serialize()
TransferrableModule GetTransferrableModule()
static WasmCompiledModule * Cast(Value *obj)
Definition: v8.h:9977
Local< String > GetWasmWireBytes()
std::pair< const uint8_t *, size_t > CallerOwnedBuffer
Definition: v8.h:4116
static MaybeLocal< WasmCompiledModule > FromTransferrableModule(Isolate *isolate, const TransferrableModule &)
std::pair< std::unique_ptr< const uint8_t[]>, size_t > SerializedModule
Definition: v8.h:4114
WasmModuleObjectBuilderStreaming(Isolate *isolate)
void Abort(Local< Value > exception)
void OnBytesReceived(const uint8_t *, size_t size)
Definition: v8.h:4222
WasmModuleObjectBuilder(Isolate *isolate)
Definition: v8.h:4224
void OnBytesReceived(const uint8_t *, size_t size)
MaybeLocal< WasmCompiledModule > Finish()
Definition: v8.h:414
void * GetInternalField(int index) const
Definition: v8.h:9180
void * GetInternalField2() const
Definition: v8.h:436
Isolate * GetIsolate() const
Definition: v8.h:427
T * GetParameter() const
Definition: v8.h:428
void * GetInternalField1() const
Definition: v8.h:432
void(* Callback)(const WeakCallbackInfo< T > &data)
Definition: v8.h:416
WeakCallbackInfo(Isolate *isolate, T *parameter, void *embedder_fields[kEmbedderFieldsInWeakCallback], Callback *callback)
Definition: v8.h:418
void SetSecondPassCallback(Callback callback) const
Definition: v8.h:451
bool IsFirstPass() const
Definition: v8.h:441
Definition: v8.h:128
Definition: v8.h:148
Definition: v8.h:8969
static bool IsExternalTwoByteString(int instance_type)
Definition: v8.h:9062
static const int kHeapObjectMapOffset
Definition: v8.h:8973
static int GetOddballKind(const internal::Object *obj)
Definition: v8.h:9057
static const int kOddballType
Definition: v8.h:9017
static const int kNodeStateIsNearDeathValue
Definition: v8.h:9010
static const int kStringEncodingMask
Definition: v8.h:8985
static internal::Object * IntToSmi(int value)
Definition: v8.h:9041
static const int kNodeIsIndependentShift
Definition: v8.h:9011
static const uint32_t kNumIsolateDataSlots
Definition: v8.h:9023
static uint8_t GetNodeFlag(internal::Object **obj, int shift)
Definition: v8.h:9067
static const int kForeignType
Definition: v8.h:9018
static const int kExternalMemoryOffset
Definition: v8.h:8990
static int GetInstanceType(const internal::Object *obj)
Definition: v8.h:9049
static const int kIsolateRootsOffset
Definition: v8.h:8995
static const int kNodeIsActiveShift
Definition: v8.h:9012
static T ReadEmbedderData(const v8::Context *context, int index)
Definition: v8.h:9119
static const int kUndefinedOddballKind
Definition: v8.h:9020
static void UpdateNodeState(internal::Object **obj, uint8_t value)
Definition: v8.h:9084
static void CheckInitialized(v8::Isolate *isolate)
Definition: v8.h:9026
static const int kJSObjectType
Definition: v8.h:9015
static const int kFullStringRepresentationMask
Definition: v8.h:8984
static T ReadField(const internal::Object *ptr, int offset)
Definition: v8.h:9112
static const int kFirstNonstringType
Definition: v8.h:9016
static const int kEmptyStringRootIndex
Definition: v8.h:9003
static const int kFixedArrayHeaderSize
Definition: v8.h:8981
static const int kNullOddballKind
Definition: v8.h:9021
static const int kUndefinedValueRootIndex
Definition: v8.h:8998
static const int kExternalTwoByteRepresentationTag
Definition: v8.h:8986
static void CheckInitializedImpl(v8::Isolate *isolate)
static void * GetEmbedderData(const v8::Isolate *isolate, uint32_t slot)
Definition: v8.h:9098
static const int kNodeStateIsPendingValue
Definition: v8.h:9009
static const int kNodeStateMask
Definition: v8.h:9007
static uint8_t GetNodeState(internal::Object **obj)
Definition: v8.h:9079
static const int kNodeStateIsWeakValue
Definition: v8.h:9008
static const int kStringResourceOffset
Definition: v8.h:8976
static const int kFalseValueRootIndex
Definition: v8.h:9002
static const int kTrueValueRootIndex
Definition: v8.h:9001
static const int kOddballKindOffset
Definition: v8.h:8978
static int SmiValue(const internal::Object *value)
Definition: v8.h:9037
static const int kContextHeaderSize
Definition: v8.h:8982
static void UpdateNodeFlag(internal::Object **obj, bool value, int shift)
Definition: v8.h:9072
static const int kNullValueRootIndex
Definition: v8.h:9000
static void SetEmbedderData(v8::Isolate *isolate, uint32_t slot, void *data)
Definition: v8.h:9090
static const int kTheHoleValueRootIndex
Definition: v8.h:8999
static const int kExternalMemoryLimitOffset
Definition: v8.h:8991
static internal::Object ** GetRoot(v8::Isolate *isolate, int index)
Definition: v8.h:9105
static const int kExternalOneByteRepresentationTag
Definition: v8.h:8987
static bool IsValidSmi(intptr_t value)
Definition: v8.h:9045
static const int kForeignAddressOffset
Definition: v8.h:8979
static const int kIsolateEmbedderDataOffset
Definition: v8.h:8989
static const int kExternalMemoryAtLastMarkCompactOffset
Definition: v8.h:8993
static const int kMapInstanceTypeAndBitFieldOffset
Definition: v8.h:8974
static const int kNodeFlagsOffset
Definition: v8.h:9006
static const int kJSApiObjectType
Definition: v8.h:9014
static const int kNodeClassIdOffset
Definition: v8.h:9005
static const int kJSObjectHeaderSize
Definition: v8.h:8980
static bool HasHeapObjectTag(const internal::Object *value)
Definition: v8.h:9032
static const int kContextEmbedderDataIndex
Definition: v8.h:8983
const intptr_t kHeapObjectTagMask
Definition: v8.h:8893
SmiTagging< kApiPointerSize > PlatformSmiTagging
Definition: v8.h:8958
const int kSmiTagSize
Definition: v8.h:8897
const int kApiInt64Size
Definition: v8.h:8888
const int kApiIntSize
Definition: v8.h:8887
const int kApiPointerSize
Definition: v8.h:8886
const int kHeapObjectTag
Definition: v8.h:8891
const int kSmiShiftSize
Definition: v8.h:8959
const int kSmiValueSize
Definition: v8.h:8960
const intptr_t kSmiTagMask
Definition: v8.h:8898
const int kHeapObjectTagSize
Definition: v8.h:8892
const int kSmiTag
Definition: v8.h:8896
internal::Object * IntToSmi(int value)
Definition: v8.h:8903
Definition: libplatform.h:12
IntegrityLevel
Definition: v8.h:3049
PropertyAttribute
Definition: v8.h:2969
@ DontEnum
Definition: v8.h:2975
@ None
Definition: v8.h:2971
@ DontDelete
Definition: v8.h:2977
@ ReadOnly
Definition: v8.h:2973
JitCodeEventOptions
Definition: v8.h:6603
@ kJitCodeEventEnumExisting
Definition: v8.h:6606
@ kJitCodeEventDefault
Definition: v8.h:6604
KeyCollectionMode
Definition: v8.h:3038
bool(* AccessCheckCallback)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data)
Definition: v8.h:5368
void(* FailedAccessCheckCallback)(Local< Object > target, AccessType type, Local< Value > data)
Definition: v8.h:6340
void(* LogEventCallback)(const char *name, int event)
Definition: v8.h:6141
void(* MessageCallback)(Local< Message > message, Local< Value > data)
Definition: v8.h:6137
void *(* CreateHistogramCallback)(const char *name, int min, int max, size_t buckets)
Definition: v8.h:6176
void(* GenericNamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:5255
GCCallbackFlags
Definition: v8.h:6392
@ kGCCallbackScheduleIdleGarbageCollection
Definition: v8.h:6399
@ kGCCallbackFlagConstructRetainedObjectInfos
Definition: v8.h:6394
@ kGCCallbackFlagForced
Definition: v8.h:6395
@ kNoGCCallbackFlags
Definition: v8.h:6393
@ kGCCallbackFlagCollectAllExternalMemory
Definition: v8.h:6398
@ kGCCallbackFlagSynchronousPhantomCallbackProcessing
Definition: v8.h:6396
@ kGCCallbackFlagCollectAllAvailableGarbage
Definition: v8.h:6397
void(* GenericNamedPropertyGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5175
Local< Primitive > Null(Isolate *isolate)
Definition: v8.h:10165
SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback
Definition: v8.h:6742
MicrotasksPolicy
Definition: v8.h:6295
PromiseRejectEvent
Definition: v8.h:6251
@ kPromiseHandlerAddedAfterReject
Definition: v8.h:6253
@ kPromiseRejectWithNoHandler
Definition: v8.h:6252
RAILMode
Definition: v8.h:6583
@ PERFORMANCE_IDLE
Definition: v8.h:6594
@ PERFORMANCE_LOAD
Definition: v8.h:6597
@ PERFORMANCE_ANIMATION
Definition: v8.h:6591
@ PERFORMANCE_RESPONSE
Definition: v8.h:6587
AccessControl
Definition: v8.h:3012
@ PROHIBITS_OVERWRITING
Definition: v8.h:3016
@ ALL_CAN_WRITE
Definition: v8.h:3015
@ ALL_CAN_READ
Definition: v8.h:3014
@ DEFAULT
Definition: v8.h:3013
void(* PromiseRejectCallback)(PromiseRejectMessage message)
Definition: v8.h:6281
void(* JitCodeEventHandler)(const JitCodeEvent *event)
Definition: v8.h:6615
Maybe< T > Nothing()
Definition: v8.h:8312
IndexFilter
Definition: v8.h:3044
void(* AccessorNameSetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
Definition: v8.h:2997
void(* IndexedPropertyGetterCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5307
void(* IndexedPropertySetterCallback)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5314
void(* CallCompletedCallback)(Isolate *)
Definition: v8.h:6203
void(* NamedPropertyGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5094
void(* IndexedPropertyDeleterCallback)(uint32_t index, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:5329
void(* AddHistogramSampleCallback)(void *histogram, int sample)
Definition: v8.h:6181
void(* NamedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:5132
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8.h:10156
void(* MicrotaskCallback)(void *data)
Definition: v8.h:6285
void(* GenericNamedPropertyDefinerCallback)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5278
Intrinsic
Definition: v8.h:4993
WeakCallbackType
Definition: v8.h:466
void(* AccessorGetterCallback)(Local< String > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:2985
ConstructorBehavior
Definition: v8.h:3823
void(* IndexedPropertyDescriptorCallback)(uint32_t index, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5349
DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback
Definition: v8.h:6758
int *(* CounterLookupCallback)(const char *name)
Definition: v8.h:6174
void(* DeprecatedCallCompletedCallback)()
Definition: v8.h:6204
MaybeLocal< Promise >(* HostImportModuleDynamicallyCallback)(Local< Context > context, Local< String > referrer, Local< String > specifier)
Definition: v8.h:6226
uintptr_t(* ReturnAddressLocationResolver)(uintptr_t return_addr_location)
Definition: v8.h:7775
void(* GenericNamedPropertyDescriptorCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5301
void(* AccessorSetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
Definition: v8.h:2993
void(* AccessorNameGetterCallback)(Local< Name > property, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:2988
void(* NamedPropertySetterCallback)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5103
void(* IndexedPropertyDefinerCallback)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5342
void(* IndexedPropertyQueryCallback)(uint32_t index, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:5322
void(* OOMErrorCallback)(const char *location, bool is_heap_oom)
Definition: v8.h:6135
void(* FunctionCallback)(const FunctionCallbackInfo< Value > &info)
Definition: v8.h:3821
Local< Boolean > False(Isolate *isolate)
Definition: v8.h:10183
bool(* ExtensionCallback)(const FunctionCallbackInfo< Value > &)
Definition: v8.h:6354
void(* GCCallback)(GCType type, GCCallbackFlags flags)
Definition: v8.h:6402
void(* NamedPropertyDeleterCallback)(Local< String > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:5124
void(* FunctionEntryHook)(uintptr_t function, uintptr_t return_addr_location)
Definition: v8.h:6511
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context, Local< String > source)
Definition: v8.h:6350
bool(* EntropySource)(unsigned char *buffer, size_t length)
Definition: v8.h:7760
void(* ApiImplementationCallback)(const FunctionCallbackInfo< Value > &)
Definition: v8.h:6358
void(* FatalErrorCallback)(const char *location, const char *message)
Definition: v8.h:6133
void(* BeforeCallEnteredCallback)(Isolate *)
Definition: v8.h:6202
GCType
Definition: v8.h:6369
@ kGCTypeScavenge
Definition: v8.h:6370
@ kGCTypeProcessWeakCallbacks
Definition: v8.h:6373
@ kGCTypeMarkSweepCompact
Definition: v8.h:6371
@ kGCTypeAll
Definition: v8.h:6374
@ kGCTypeIncrementalMarking
Definition: v8.h:6372
void(* NamedPropertyQueryCallback)(Local< String > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:5114
Local< Boolean > True(Isolate *isolate)
Definition: v8.h:10174
NewStringType
Definition: v8.h:2436
void(* GenericNamedPropertyDeleterCallback)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info)
Definition: v8.h:5248
StateTag
Definition: v8.h:1729
@ COMPILER
Definition: v8.h:1734
@ BYTECODE_COMPILER
Definition: v8.h:1733
@ EXTERNAL
Definition: v8.h:1736
@ GC
Definition: v8.h:1731
@ PARSER
Definition: v8.h:1732
@ IDLE
Definition: v8.h:1737
@ JS
Definition: v8.h:1730
@ OTHER
Definition: v8.h:1735
void(* IndexedPropertyEnumeratorCallback)(const PropertyCallbackInfo< Array > &info)
Definition: v8.h:5336
AccessType
Definition: v8.h:5355
@ ACCESS_SET
Definition: v8.h:5357
@ ACCESS_HAS
Definition: v8.h:5358
@ ACCESS_KEYS
Definition: v8.h:5360
@ ACCESS_GET
Definition: v8.h:5356
@ ACCESS_DELETE
Definition: v8.h:5359
void(* GenericNamedPropertyQueryCallback)(Local< Name > property, const PropertyCallbackInfo< Integer > &info)
Definition: v8.h:5224
MemoryPressureLevel
Definition: v8.h:6646
AllocationAction
Definition: v8.h:6195
@ kAllocationActionAllocate
Definition: v8.h:6196
@ kAllocationActionAll
Definition: v8.h:6198
@ kAllocationActionFree
Definition: v8.h:6197
void RegisterExtension(Extension *extension)
ObjectSpace
Definition: v8.h:6184
@ kObjectSpaceOldSpace
Definition: v8.h:6186
@ kObjectSpaceAll
Definition: v8.h:6190
@ kObjectSpaceMapSpace
Definition: v8.h:6188
@ kObjectSpaceNewSpace
Definition: v8.h:6185
@ kObjectSpaceLoSpace
Definition: v8.h:6189
@ kObjectSpaceCodeSpace
Definition: v8.h:6187
ArrayBufferCreationMode
Definition: v8.h:4252
void(* PromiseHook)(PromiseHookType type, Local< Promise > promise, Local< Value > parent)
Definition: v8.h:6247
Maybe< T > Just(const T &t)
Definition: v8.h:8318
void(* InterruptCallback)(Isolate *isolate, void *data)
Definition: v8.h:6404
void(* MicrotasksCompletedCallback)(Isolate *)
Definition: v8.h:6284
PropertyHandlerFlags
Definition: v8.h:5597
void(* GenericNamedPropertySetterCallback)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info)
Definition: v8.h:5199
PropertyFilter
Definition: v8.h:3022
@ ONLY_CONFIGURABLE
Definition: v8.h:3026
@ SKIP_SYMBOLS
Definition: v8.h:3028
@ ONLY_WRITABLE
Definition: v8.h:3024
@ ALL_PROPERTIES
Definition: v8.h:3023
@ SKIP_STRINGS
Definition: v8.h:3027
@ ONLY_ENUMERABLE
Definition: v8.h:3025
PromiseHookType
Definition: v8.h:6245
Definition: v8.h:658
static const bool kResetInDestructor
Definition: v8.h:660
Persistent< T, CopyablePersistentTraits< T > > CopyablePersistent
Definition: v8.h:659
static void Copy(const Persistent< S, M > &source, CopyablePersistent *dest)
Definition: v8.h:662
void(* CallbackFunction)(Local< Object > holder, int index, StartupData payload, void *data)
Definition: v8.h:6749
void * data
Definition: v8.h:6756
void(* callback)(Local< Object > holder, int index, StartupData payload, void *data)
Definition: v8.h:6754
IndexedPropertyGetterCallback getter
Definition: v8.h:5711
IndexedPropertyDefinerCallback definer
Definition: v8.h:5716
PropertyHandlerFlags flags
Definition: v8.h:5719
IndexedPropertyDescriptorCallback descriptor
Definition: v8.h:5717
IndexedPropertySetterCallback setter
Definition: v8.h:5712
IndexedPropertyEnumeratorCallback enumerator
Definition: v8.h:5715
IndexedPropertyQueryCallback query
Definition: v8.h:5713
Local< Value > data
Definition: v8.h:5718
IndexedPropertyDeleterCallback deleter
Definition: v8.h:5714
Definition: v8.h:6773
Definition: v8.h:6557
size_t offset
Definition: v8.h:6559
size_t pos
Definition: v8.h:6561
PositionType position_type
Definition: v8.h:6563
Definition: v8.h:6549
const char * str
Definition: v8.h:6552
size_t len
Definition: v8.h:6554
Definition: v8.h:6519
PositionType
Definition: v8.h:6533
@ POSITION
Definition: v8.h:6533
@ STATEMENT_POSITION
Definition: v8.h:6533
struct name_t name
Definition: v8.h:6568
Local< UnboundScript > script
Definition: v8.h:6542
struct line_info_t line_info
Definition: v8.h:6571
void * user_data
Definition: v8.h:6547
void * new_code_start
Definition: v8.h:6574
EventType
Definition: v8.h:6520
@ CODE_END_LINE_INFO_RECORDING
Definition: v8.h:6526
@ CODE_ADDED
Definition: v8.h:6521
@ CODE_MOVED
Definition: v8.h:6522
@ CODE_ADD_LINE_POS_INFO
Definition: v8.h:6524
@ CODE_REMOVED
Definition: v8.h:6523
@ CODE_START_LINE_INFO_RECORDING
Definition: v8.h:6525
EventType type
Definition: v8.h:6536
size_t code_len
Definition: v8.h:6540
void * code_start
Definition: v8.h:6538
GenericNamedPropertySetterCallback setter
Definition: v8.h:5661
Local< Value > data
Definition: v8.h:5667
GenericNamedPropertyGetterCallback getter
Definition: v8.h:5660
GenericNamedPropertyDefinerCallback definer
Definition: v8.h:5665
GenericNamedPropertyEnumeratorCallback enumerator
Definition: v8.h:5664
GenericNamedPropertyDeleterCallback deleter
Definition: v8.h:5663
PropertyHandlerFlags flags
Definition: v8.h:5668
GenericNamedPropertyDescriptorCallback descriptor
Definition: v8.h:5666
GenericNamedPropertyQueryCallback query
Definition: v8.h:5662
Definition: v8.h:1742
void * sp
Definition: v8.h:1745
void * pc
Definition: v8.h:1744
void * fp
Definition: v8.h:1746
RegisterState()
Definition: v8.h:1743
Definition: v8.h:1750
size_t frames_count
Definition: v8.h:1751
void * external_callback_entry
Definition: v8.h:1753
StateTag vm_state
Definition: v8.h:1752
Definition: v8.h:1227
BufferPolicy buffer_policy
Definition: v8.h:1251
const uint8_t * data
Definition: v8.h:1248
CachedData(const CachedData &)=delete
bool rejected
Definition: v8.h:1250
CachedData(const uint8_t *data, int length, BufferPolicy buffer_policy=BufferNotOwned)
BufferPolicy
Definition: v8.h:1228
@ BufferNotOwned
Definition: v8.h:1229
CachedData()
Definition: v8.h:1233
int length
Definition: v8.h:1249
CachedData & operator=(const CachedData &)=delete
StartupData(* CallbackFunction)(Local< Object > holder, int index, void *data)
Definition: v8.h:6732
void * data
Definition: v8.h:6738
CallbackFunction callback
Definition: v8.h:6737
Definition: v8.h:8900
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
Definition: v8.h:4248
#define V8_EXPORT
Definition: v8.h:56
#define V8_INTRINSICS_LIST(F)
Definition: v8.h:4985
#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
Definition: v8.h:4454
#define V8_PROMISE_INTERNAL_FIELD_COUNT
Definition: v8.h:3922
#define V8_DECL_INTRINSIC(name, iname)
Definition: v8.h:4994
#define TYPE_CHECK(T, S)
Definition: v8.h:160
#define V8_DEPRECATED(message, declarator)
Definition: v8config.h:325
#define V8_INLINE
Definition: v8config.h:298
#define V8_LIKELY(condition)
Definition: v8config.h:350
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:412
#define V8_UNLIKELY(condition)
Definition: v8config.h:349
#define V8_DEPRECATE_SOON(message, declarator)
Definition: v8config.h:340