Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index f012b3bdd1a6137ea8db88d783781590296060f1..9df4d6e41fcafc37c506497855a44c558ee07824 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -108,6 +108,7 @@ class Private; |
class Uint32; |
class Utils; |
class Value; |
+class WasmCompiledModule; |
template <class T> class Local; |
template <class T> |
class MaybeLocal; |
@@ -1714,6 +1715,8 @@ class V8_EXPORT ValueSerializer { |
virtual Maybe<uint32_t> GetSharedArrayBufferId( |
Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer); |
+ 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.
|
+ Isolate* isolate, Local<WasmCompiledModule> module); |
/* |
* Allocates memory for the buffer of at least the size provided. The actual |
* size (which may be greater or equal) is written to |actual_size|. If no |
@@ -1824,6 +1827,9 @@ class V8_EXPORT ValueDeserializer { |
* MaybeLocal<Object>() returned. |
*/ |
virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); |
+ virtual MaybeLocal<WasmCompiledModule> GetWasmModuleFromId(Isolate* isolate, |
+ 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
|
+ 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
|
}; |
ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); |
@@ -3908,6 +3914,31 @@ class V8_EXPORT WasmCompiledModule : public Object { |
typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; |
// A buffer that is owned by the caller. |
typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; |
+ |
+ // An opaque, native heap object for transferring wasm modules. It |
+ // supports move semantics, and does not support copy semantics. |
+ class TransferrableModule final { |
+ public: |
+ TransferrableModule(TransferrableModule&& src) = default; |
+ TransferrableModule(const TransferrableModule& src) = delete; |
+ |
+ TransferrableModule& operator=(TransferrableModule&& src) = default; |
+ TransferrableModule& operator=(const TransferrableModule& src) = delete; |
+ |
+ private: |
+ typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer; |
+ friend class WasmCompiledModule; |
+ TransferrableModule(OwnedBuffer&& code, OwnedBuffer&& bytes) |
+ : compiled_code(std::move(code)), wire_bytes(std::move(bytes)) {} |
+ |
+ OwnedBuffer compiled_code = {nullptr, 0}; |
+ OwnedBuffer wire_bytes = {nullptr, 0}; |
+ }; |
+ |
+ TransferrableModule AsTransferrableModule(); |
+ static MaybeLocal<WasmCompiledModule> FromTransferrableModule( |
+ 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
|
+ |
// Get the wasm-encoded bytes that were used to compile this module. |
Local<String> GetWasmWireBytes(); |
@@ -3929,6 +3960,11 @@ class V8_EXPORT WasmCompiledModule : public Object { |
static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, |
const uint8_t* start, |
size_t length); |
+ static CallerOwnedBuffer AsCallerOwned( |
+ const TransferrableModule::OwnedBuffer& buff) { |
+ return {buff.first.get(), buff.second}; |
+ } |
+ |
WasmCompiledModule(); |
static void CheckCast(Value* obj); |
}; |