Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2251)

Unified Diff: include/v8.h

Issue 2748473004: [wasm] Transferrable modules (Closed)
Patch Set: compile error Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/value-serializer.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index beba2bb97c7e9331ae6bde2df3d3a3f7edffa09f..45ca37da64e3fee82c6be30c7c52bd0dacea2b2d 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;
@@ -1710,6 +1711,8 @@ class V8_EXPORT ValueSerializer {
virtual Maybe<uint32_t> GetSharedArrayBufferId(
Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
+ virtual Maybe<uint32_t> GetWasmModuleTransferId(
+ 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
@@ -1854,6 +1857,13 @@ class V8_EXPORT ValueDeserializer {
Local<SharedArrayBuffer> shared_array_buffer);
/*
+ * Similar to TransferSharedArrayBuffer, for wasm compiled modules. See
+ * v8:6106
+ */
+ void TransferWasmCompiledModule(uint32_t id,
+ Local<WasmCompiledModule> module);
+
+ /*
* Must be called before ReadHeader to enable support for reading the legacy
* wire format (i.e., which predates this being shipped).
*
@@ -1863,6 +1873,11 @@ class V8_EXPORT ValueDeserializer {
void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
/*
+ * Inline wasm in the data stream (versus transfer it in memory)
+ */
+ void SetAllowInlineWasm(bool allow_inline_wasm);
+
+ /*
* Reads the underlying wire format version. Likely mostly to be useful to
* legacy code reading old wire format versions. Must be called after
* ReadHeader.
@@ -3904,6 +3919,37 @@ 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};
+ };
+
+ // Get an in-memory, non-persistable, and context-independent (meaning,
+ // suitable for transfer to another Isolate and Context) representation
+ // of this wasm compiled module.
+ TransferrableModule GetTransferrableModule();
+
+ // Efficiently re-create a WasmCompiledModule, without recompiling, from
+ // a TransferrableModule.
+ static MaybeLocal<WasmCompiledModule> FromTransferrableModule(
+ Isolate* isolate, const TransferrableModule&);
+
// Get the wasm-encoded bytes that were used to compile this module.
Local<String> GetWasmWireBytes();
@@ -3925,6 +3971,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);
};
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/value-serializer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698