| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
| 6 * | 6 * |
| 7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
| 8 * | 8 * |
| 9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
| 10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 class StackFrame; | 101 class StackFrame; |
| 102 class StackTrace; | 102 class StackTrace; |
| 103 class String; | 103 class String; |
| 104 class StringObject; | 104 class StringObject; |
| 105 class Symbol; | 105 class Symbol; |
| 106 class SymbolObject; | 106 class SymbolObject; |
| 107 class Private; | 107 class Private; |
| 108 class Uint32; | 108 class Uint32; |
| 109 class Utils; | 109 class Utils; |
| 110 class Value; | 110 class Value; |
| 111 class WasmCompiledModule; | |
| 112 template <class T> class Local; | 111 template <class T> class Local; |
| 113 template <class T> | 112 template <class T> |
| 114 class MaybeLocal; | 113 class MaybeLocal; |
| 115 template <class T> class Eternal; | 114 template <class T> class Eternal; |
| 116 template<class T> class NonCopyablePersistentTraits; | 115 template<class T> class NonCopyablePersistentTraits; |
| 117 template<class T> class PersistentBase; | 116 template<class T> class PersistentBase; |
| 118 template <class T, class M = NonCopyablePersistentTraits<T> > | 117 template <class T, class M = NonCopyablePersistentTraits<T> > |
| 119 class Persistent; | 118 class Persistent; |
| 120 template <class T> | 119 template <class T> |
| 121 class Global; | 120 class Global; |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 * object, using the same ID if this SharedArrayBuffer has already been | 1703 * object, using the same ID if this SharedArrayBuffer has already been |
| 1705 * serialized in this buffer. When deserializing, this ID will be passed to | 1704 * serialized in this buffer. When deserializing, this ID will be passed to |
| 1706 * ValueDeserializer::TransferSharedArrayBuffer as |transfer_id|. | 1705 * ValueDeserializer::TransferSharedArrayBuffer as |transfer_id|. |
| 1707 * | 1706 * |
| 1708 * If the object cannot be serialized, an | 1707 * If the object cannot be serialized, an |
| 1709 * exception should be thrown and Nothing<uint32_t>() returned. | 1708 * exception should be thrown and Nothing<uint32_t>() returned. |
| 1710 */ | 1709 */ |
| 1711 virtual Maybe<uint32_t> GetSharedArrayBufferId( | 1710 virtual Maybe<uint32_t> GetSharedArrayBufferId( |
| 1712 Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer); | 1711 Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer); |
| 1713 | 1712 |
| 1714 virtual Maybe<uint32_t> GetWasmModuleTransferId( | |
| 1715 Isolate* isolate, Local<WasmCompiledModule> module); | |
| 1716 /* | 1713 /* |
| 1717 * Allocates memory for the buffer of at least the size provided. The actual | 1714 * Allocates memory for the buffer of at least the size provided. The actual |
| 1718 * size (which may be greater or equal) is written to |actual_size|. If no | 1715 * size (which may be greater or equal) is written to |actual_size|. If no |
| 1719 * buffer has been allocated yet, nullptr will be provided. | 1716 * buffer has been allocated yet, nullptr will be provided. |
| 1720 * | 1717 * |
| 1721 * If the memory cannot be allocated, nullptr should be returned. | 1718 * If the memory cannot be allocated, nullptr should be returned. |
| 1722 * |actual_size| will be ignored. It is assumed that |old_buffer| is still | 1719 * |actual_size| will be ignored. It is assumed that |old_buffer| is still |
| 1723 * valid in this case and has not been modified. | 1720 * valid in this case and has not been modified. |
| 1724 */ | 1721 */ |
| 1725 virtual void* ReallocateBufferMemory(void* old_buffer, size_t size, | 1722 virtual void* ReallocateBufferMemory(void* old_buffer, size_t size, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 class V8_EXPORT Delegate { | 1813 class V8_EXPORT Delegate { |
| 1817 public: | 1814 public: |
| 1818 virtual ~Delegate() {} | 1815 virtual ~Delegate() {} |
| 1819 | 1816 |
| 1820 /* | 1817 /* |
| 1821 * The embedder overrides this method to read some kind of host object, if | 1818 * The embedder overrides this method to read some kind of host object, if |
| 1822 * possible. If not, a suitable exception should be thrown and | 1819 * possible. If not, a suitable exception should be thrown and |
| 1823 * MaybeLocal<Object>() returned. | 1820 * MaybeLocal<Object>() returned. |
| 1824 */ | 1821 */ |
| 1825 virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); | 1822 virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); |
| 1826 | |
| 1827 /* | |
| 1828 * Get a WasmCompiledModule given a transfer_id previously provided | |
| 1829 * by ValueSerializer::GetWasmModuleTransferId | |
| 1830 */ | |
| 1831 virtual MaybeLocal<WasmCompiledModule> GetWasmModuleFromId( | |
| 1832 Isolate* isolate, uint32_t transfer_id); | |
| 1833 }; | 1823 }; |
| 1834 | 1824 |
| 1835 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); | 1825 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); |
| 1836 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size, | 1826 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size, |
| 1837 Delegate* delegate); | 1827 Delegate* delegate); |
| 1838 ~ValueDeserializer(); | 1828 ~ValueDeserializer(); |
| 1839 | 1829 |
| 1840 /* | 1830 /* |
| 1841 * Reads and validates a header (including the format version). | 1831 * Reads and validates a header (including the format version). |
| 1842 * May, for example, reject an invalid or unsupported wire format. | 1832 * May, for example, reject an invalid or unsupported wire format. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1866 /* | 1856 /* |
| 1867 * Must be called before ReadHeader to enable support for reading the legacy | 1857 * Must be called before ReadHeader to enable support for reading the legacy |
| 1868 * wire format (i.e., which predates this being shipped). | 1858 * wire format (i.e., which predates this being shipped). |
| 1869 * | 1859 * |
| 1870 * Don't use this unless you need to read data written by previous versions of | 1860 * Don't use this unless you need to read data written by previous versions of |
| 1871 * blink::ScriptValueSerializer. | 1861 * blink::ScriptValueSerializer. |
| 1872 */ | 1862 */ |
| 1873 void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format); | 1863 void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format); |
| 1874 | 1864 |
| 1875 /* | 1865 /* |
| 1876 * Expect inline wasm in the data stream (rather than in-memory transfer) | |
| 1877 */ | |
| 1878 void SetExpectInlineWasm(bool allow_inline_wasm); | |
| 1879 | |
| 1880 /* | |
| 1881 * Reads the underlying wire format version. Likely mostly to be useful to | 1866 * Reads the underlying wire format version. Likely mostly to be useful to |
| 1882 * legacy code reading old wire format versions. Must be called after | 1867 * legacy code reading old wire format versions. Must be called after |
| 1883 * ReadHeader. | 1868 * ReadHeader. |
| 1884 */ | 1869 */ |
| 1885 uint32_t GetWireFormatVersion() const; | 1870 uint32_t GetWireFormatVersion() const; |
| 1886 | 1871 |
| 1887 /* | 1872 /* |
| 1888 * Reads raw data in various common formats to the buffer. | 1873 * Reads raw data in various common formats to the buffer. |
| 1889 * Note that integer types are read in base-128 varint format, not with a | 1874 * Note that integer types are read in base-128 varint format, not with a |
| 1890 * binary copy. For use during an override of Delegate::ReadHostObject. | 1875 * binary copy. For use during an override of Delegate::ReadHostObject. |
| (...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3912 private: | 3897 private: |
| 3913 Proxy(); | 3898 Proxy(); |
| 3914 static void CheckCast(Value* obj); | 3899 static void CheckCast(Value* obj); |
| 3915 }; | 3900 }; |
| 3916 | 3901 |
| 3917 class V8_EXPORT WasmCompiledModule : public Object { | 3902 class V8_EXPORT WasmCompiledModule : public Object { |
| 3918 public: | 3903 public: |
| 3919 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; | 3904 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; |
| 3920 // A buffer that is owned by the caller. | 3905 // A buffer that is owned by the caller. |
| 3921 typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; | 3906 typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; |
| 3922 | |
| 3923 // An opaque, native heap object for transferring wasm modules. It | |
| 3924 // supports move semantics, and does not support copy semantics. | |
| 3925 class TransferrableModule final { | |
| 3926 public: | |
| 3927 TransferrableModule(TransferrableModule&& src) = default; | |
| 3928 TransferrableModule(const TransferrableModule& src) = delete; | |
| 3929 | |
| 3930 TransferrableModule& operator=(TransferrableModule&& src) = default; | |
| 3931 TransferrableModule& operator=(const TransferrableModule& src) = delete; | |
| 3932 | |
| 3933 private: | |
| 3934 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer; | |
| 3935 friend class WasmCompiledModule; | |
| 3936 TransferrableModule(OwnedBuffer&& code, OwnedBuffer&& bytes) | |
| 3937 : compiled_code(std::move(code)), wire_bytes(std::move(bytes)) {} | |
| 3938 | |
| 3939 OwnedBuffer compiled_code = {nullptr, 0}; | |
| 3940 OwnedBuffer wire_bytes = {nullptr, 0}; | |
| 3941 }; | |
| 3942 | |
| 3943 // Get an in-memory, non-persistable, and context-independent (meaning, | |
| 3944 // suitable for transfer to another Isolate and Context) representation | |
| 3945 // of this wasm compiled module. | |
| 3946 TransferrableModule GetTransferrableModule(); | |
| 3947 | |
| 3948 // Efficiently re-create a WasmCompiledModule, without recompiling, from | |
| 3949 // a TransferrableModule. | |
| 3950 static MaybeLocal<WasmCompiledModule> FromTransferrableModule( | |
| 3951 Isolate* isolate, const TransferrableModule&); | |
| 3952 | |
| 3953 // Get the wasm-encoded bytes that were used to compile this module. | 3907 // Get the wasm-encoded bytes that were used to compile this module. |
| 3954 Local<String> GetWasmWireBytes(); | 3908 Local<String> GetWasmWireBytes(); |
| 3955 | 3909 |
| 3956 // Serialize the compiled module. The serialized data does not include the | 3910 // Serialize the compiled module. The serialized data does not include the |
| 3957 // uncompiled bytes. | 3911 // uncompiled bytes. |
| 3958 SerializedModule Serialize(); | 3912 SerializedModule Serialize(); |
| 3959 | 3913 |
| 3960 // If possible, deserialize the module, otherwise compile it from the provided | 3914 // If possible, deserialize the module, otherwise compile it from the provided |
| 3961 // uncompiled bytes. | 3915 // uncompiled bytes. |
| 3962 static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( | 3916 static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( |
| 3963 Isolate* isolate, const CallerOwnedBuffer& serialized_module, | 3917 Isolate* isolate, const CallerOwnedBuffer& serialized_module, |
| 3964 const CallerOwnedBuffer& wire_bytes); | 3918 const CallerOwnedBuffer& wire_bytes); |
| 3965 V8_INLINE static WasmCompiledModule* Cast(Value* obj); | 3919 V8_INLINE static WasmCompiledModule* Cast(Value* obj); |
| 3966 | 3920 |
| 3967 private: | 3921 private: |
| 3968 static MaybeLocal<WasmCompiledModule> Deserialize( | 3922 static MaybeLocal<WasmCompiledModule> Deserialize( |
| 3969 Isolate* isolate, const CallerOwnedBuffer& serialized_module, | 3923 Isolate* isolate, const CallerOwnedBuffer& serialized_module, |
| 3970 const CallerOwnedBuffer& wire_bytes); | 3924 const CallerOwnedBuffer& wire_bytes); |
| 3971 static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, | 3925 static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, |
| 3972 const uint8_t* start, | 3926 const uint8_t* start, |
| 3973 size_t length); | 3927 size_t length); |
| 3974 static CallerOwnedBuffer AsCallerOwned( | |
| 3975 const TransferrableModule::OwnedBuffer& buff) { | |
| 3976 return {buff.first.get(), buff.second}; | |
| 3977 } | |
| 3978 | |
| 3979 WasmCompiledModule(); | 3928 WasmCompiledModule(); |
| 3980 static void CheckCast(Value* obj); | 3929 static void CheckCast(Value* obj); |
| 3981 }; | 3930 }; |
| 3982 | 3931 |
| 3983 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | 3932 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT |
| 3984 // The number of required internal fields can be defined by embedder. | 3933 // The number of required internal fields can be defined by embedder. |
| 3985 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | 3934 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 |
| 3986 #endif | 3935 #endif |
| 3987 | 3936 |
| 3988 | 3937 |
| (...skipping 5899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9888 */ | 9837 */ |
| 9889 | 9838 |
| 9890 | 9839 |
| 9891 } // namespace v8 | 9840 } // namespace v8 |
| 9892 | 9841 |
| 9893 | 9842 |
| 9894 #undef TYPE_CHECK | 9843 #undef TYPE_CHECK |
| 9895 | 9844 |
| 9896 | 9845 |
| 9897 #endif // INCLUDE_V8_H_ | 9846 #endif // INCLUDE_V8_H_ |
| OLD | NEW |