Chromium Code Reviews| 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; | |
| 111 template <class T> class Local; | 112 template <class T> class Local; |
| 112 template <class T> | 113 template <class T> |
| 113 class MaybeLocal; | 114 class MaybeLocal; |
| 114 template <class T> class Eternal; | 115 template <class T> class Eternal; |
| 115 template<class T> class NonCopyablePersistentTraits; | 116 template<class T> class NonCopyablePersistentTraits; |
| 116 template<class T> class PersistentBase; | 117 template<class T> class PersistentBase; |
| 117 template <class T, class M = NonCopyablePersistentTraits<T> > | 118 template <class T, class M = NonCopyablePersistentTraits<T> > |
| 118 class Persistent; | 119 class Persistent; |
| 119 template <class T> | 120 template <class T> |
| 120 class Global; | 121 class Global; |
| (...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1707 * object, using the same ID if this SharedArrayBuffer has already been | 1708 * object, using the same ID if this SharedArrayBuffer has already been |
| 1708 * serialized in this buffer. When deserializing, this ID will be passed to | 1709 * serialized in this buffer. When deserializing, this ID will be passed to |
| 1709 * ValueDeserializer::TransferSharedArrayBuffer as |transfer_id|. | 1710 * ValueDeserializer::TransferSharedArrayBuffer as |transfer_id|. |
| 1710 * | 1711 * |
| 1711 * If the object cannot be serialized, an | 1712 * If the object cannot be serialized, an |
| 1712 * exception should be thrown and Nothing<uint32_t>() returned. | 1713 * exception should be thrown and Nothing<uint32_t>() returned. |
| 1713 */ | 1714 */ |
| 1714 virtual Maybe<uint32_t> GetSharedArrayBufferId( | 1715 virtual Maybe<uint32_t> GetSharedArrayBufferId( |
| 1715 Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer); | 1716 Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer); |
| 1716 | 1717 |
| 1718 virtual Maybe<uint32_t> GetWasmModuleTransferId( | |
|
jbroman
2017/03/13 18:53:37
Here and elsewhere: Before landing, add comments t
Mircea Trofin
2017/03/15 18:02:28
Done.
| |
| 1719 Isolate* isolate, Local<WasmCompiledModule> module); | |
| 1717 /* | 1720 /* |
| 1718 * Allocates memory for the buffer of at least the size provided. The actual | 1721 * Allocates memory for the buffer of at least the size provided. The actual |
| 1719 * size (which may be greater or equal) is written to |actual_size|. If no | 1722 * size (which may be greater or equal) is written to |actual_size|. If no |
| 1720 * buffer has been allocated yet, nullptr will be provided. | 1723 * buffer has been allocated yet, nullptr will be provided. |
| 1721 * | 1724 * |
| 1722 * If the memory cannot be allocated, nullptr should be returned. | 1725 * If the memory cannot be allocated, nullptr should be returned. |
| 1723 * |actual_size| will be ignored. It is assumed that |old_buffer| is still | 1726 * |actual_size| will be ignored. It is assumed that |old_buffer| is still |
| 1724 * valid in this case and has not been modified. | 1727 * valid in this case and has not been modified. |
| 1725 */ | 1728 */ |
| 1726 virtual void* ReallocateBufferMemory(void* old_buffer, size_t size, | 1729 virtual void* ReallocateBufferMemory(void* old_buffer, size_t size, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1817 class V8_EXPORT Delegate { | 1820 class V8_EXPORT Delegate { |
| 1818 public: | 1821 public: |
| 1819 virtual ~Delegate() {} | 1822 virtual ~Delegate() {} |
| 1820 | 1823 |
| 1821 /* | 1824 /* |
| 1822 * The embedder overrides this method to read some kind of host object, if | 1825 * The embedder overrides this method to read some kind of host object, if |
| 1823 * possible. If not, a suitable exception should be thrown and | 1826 * possible. If not, a suitable exception should be thrown and |
| 1824 * MaybeLocal<Object>() returned. | 1827 * MaybeLocal<Object>() returned. |
| 1825 */ | 1828 */ |
| 1826 virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); | 1829 virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); |
| 1830 virtual MaybeLocal<WasmCompiledModule> GetWasmModuleFromId(Isolate* isolate, | |
| 1831 uint32_t id); | |
|
jbroman
2017/03/13 18:53:38
Ditto: we've tried to reduce the number of virtual
Mircea Trofin
2017/03/15 18:02:28
This is more like transferring SharedArrayBuffers,
Mircea Trofin
2017/03/16 20:17:27
As discussed offline - changed the design on deser
| |
| 1832 virtual bool AllowInlineWasm() const { return false; } | |
|
jbroman
2017/03/13 18:53:37
Is there a reason this might vary over the lifetim
Mircea Trofin
2017/03/15 18:02:28
Following the SetSupportsLegacyWireFormat would, a
| |
| 1827 }; | 1833 }; |
| 1828 | 1834 |
| 1829 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); | 1835 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); |
| 1830 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size, | 1836 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size, |
| 1831 Delegate* delegate); | 1837 Delegate* delegate); |
| 1832 ~ValueDeserializer(); | 1838 ~ValueDeserializer(); |
| 1833 | 1839 |
| 1834 /* | 1840 /* |
| 1835 * Reads and validates a header (including the format version). | 1841 * Reads and validates a header (including the format version). |
| 1836 * May, for example, reject an invalid or unsupported wire format. | 1842 * May, for example, reject an invalid or unsupported wire format. |
| (...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3901 private: | 3907 private: |
| 3902 Proxy(); | 3908 Proxy(); |
| 3903 static void CheckCast(Value* obj); | 3909 static void CheckCast(Value* obj); |
| 3904 }; | 3910 }; |
| 3905 | 3911 |
| 3906 class V8_EXPORT WasmCompiledModule : public Object { | 3912 class V8_EXPORT WasmCompiledModule : public Object { |
| 3907 public: | 3913 public: |
| 3908 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; | 3914 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; |
| 3909 // A buffer that is owned by the caller. | 3915 // A buffer that is owned by the caller. |
| 3910 typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; | 3916 typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; |
| 3917 | |
| 3918 // An opaque, native heap object for transferring wasm modules. It | |
| 3919 // supports move semantics, and does not support copy semantics. | |
| 3920 class TransferrableModule final { | |
| 3921 public: | |
| 3922 TransferrableModule(TransferrableModule&& src) = default; | |
| 3923 TransferrableModule(const TransferrableModule& src) = delete; | |
| 3924 | |
| 3925 TransferrableModule& operator=(TransferrableModule&& src) = default; | |
| 3926 TransferrableModule& operator=(const TransferrableModule& src) = delete; | |
| 3927 | |
| 3928 private: | |
| 3929 typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer; | |
| 3930 friend class WasmCompiledModule; | |
| 3931 TransferrableModule(OwnedBuffer&& code, OwnedBuffer&& bytes) | |
| 3932 : compiled_code(std::move(code)), wire_bytes(std::move(bytes)) {} | |
| 3933 | |
| 3934 OwnedBuffer compiled_code = {nullptr, 0}; | |
| 3935 OwnedBuffer wire_bytes = {nullptr, 0}; | |
| 3936 }; | |
| 3937 | |
| 3938 TransferrableModule AsTransferrableModule(); | |
| 3939 static MaybeLocal<WasmCompiledModule> FromTransferrableModule( | |
| 3940 Isolate* isolate, TransferrableModule&); | |
|
jbroman
2017/03/13 18:53:38
(destructive) lvalue-ref parameter here is strange
Mircea Trofin
2017/03/15 18:02:28
It's remnants from debugging something. What I wan
| |
| 3941 | |
| 3911 // Get the wasm-encoded bytes that were used to compile this module. | 3942 // Get the wasm-encoded bytes that were used to compile this module. |
| 3912 Local<String> GetWasmWireBytes(); | 3943 Local<String> GetWasmWireBytes(); |
| 3913 | 3944 |
| 3914 // Serialize the compiled module. The serialized data does not include the | 3945 // Serialize the compiled module. The serialized data does not include the |
| 3915 // uncompiled bytes. | 3946 // uncompiled bytes. |
| 3916 SerializedModule Serialize(); | 3947 SerializedModule Serialize(); |
| 3917 | 3948 |
| 3918 // If possible, deserialize the module, otherwise compile it from the provided | 3949 // If possible, deserialize the module, otherwise compile it from the provided |
| 3919 // uncompiled bytes. | 3950 // uncompiled bytes. |
| 3920 static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( | 3951 static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( |
| 3921 Isolate* isolate, const CallerOwnedBuffer& serialized_module, | 3952 Isolate* isolate, const CallerOwnedBuffer& serialized_module, |
| 3922 const CallerOwnedBuffer& wire_bytes); | 3953 const CallerOwnedBuffer& wire_bytes); |
| 3923 V8_INLINE static WasmCompiledModule* Cast(Value* obj); | 3954 V8_INLINE static WasmCompiledModule* Cast(Value* obj); |
| 3924 | 3955 |
| 3925 private: | 3956 private: |
| 3926 static MaybeLocal<WasmCompiledModule> Deserialize( | 3957 static MaybeLocal<WasmCompiledModule> Deserialize( |
| 3927 Isolate* isolate, const CallerOwnedBuffer& serialized_module, | 3958 Isolate* isolate, const CallerOwnedBuffer& serialized_module, |
| 3928 const CallerOwnedBuffer& wire_bytes); | 3959 const CallerOwnedBuffer& wire_bytes); |
| 3929 static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, | 3960 static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, |
| 3930 const uint8_t* start, | 3961 const uint8_t* start, |
| 3931 size_t length); | 3962 size_t length); |
| 3963 static CallerOwnedBuffer AsCallerOwned( | |
| 3964 const TransferrableModule::OwnedBuffer& buff) { | |
| 3965 return {buff.first.get(), buff.second}; | |
| 3966 } | |
| 3967 | |
| 3932 WasmCompiledModule(); | 3968 WasmCompiledModule(); |
| 3933 static void CheckCast(Value* obj); | 3969 static void CheckCast(Value* obj); |
| 3934 }; | 3970 }; |
| 3935 | 3971 |
| 3936 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT | 3972 #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT |
| 3937 // The number of required internal fields can be defined by embedder. | 3973 // The number of required internal fields can be defined by embedder. |
| 3938 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 | 3974 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 |
| 3939 #endif | 3975 #endif |
| 3940 | 3976 |
| 3941 | 3977 |
| (...skipping 5874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9816 */ | 9852 */ |
| 9817 | 9853 |
| 9818 | 9854 |
| 9819 } // namespace v8 | 9855 } // namespace v8 |
| 9820 | 9856 |
| 9821 | 9857 |
| 9822 #undef TYPE_CHECK | 9858 #undef TYPE_CHECK |
| 9823 | 9859 |
| 9824 | 9860 |
| 9825 #endif // INCLUDE_V8_H_ | 9861 #endif // INCLUDE_V8_H_ |
| OLD | NEW |