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

Unified Diff: src/api.cc

Issue 2762273002: Reland of [wasm] Transferrable modules (Closed)
Patch Set: 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 | « include/v8.h ('k') | src/value-serializer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 404d1e4f4ae987ab6bca0c1d1550bbfdee5e7cc7..1720995d9f8611345ceafc665692f458ef77206b 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3129,6 +3129,11 @@
return Nothing<uint32_t>();
}
+Maybe<uint32_t> ValueSerializer::Delegate::GetWasmModuleTransferId(
+ Isolate* v8_isolate, Local<WasmCompiledModule> module) {
+ return Nothing<uint32_t>();
+}
+
void* ValueSerializer::Delegate::ReallocateBufferMemory(void* old_buffer,
size_t size,
size_t* actual_size) {
@@ -3215,6 +3220,15 @@
isolate->error_function(),
i::MessageTemplate::kDataCloneDeserializationError));
return MaybeLocal<Object>();
+}
+
+MaybeLocal<WasmCompiledModule> ValueDeserializer::Delegate::GetWasmModuleFromId(
+ Isolate* v8_isolate, uint32_t id) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
+ isolate->ScheduleThrow(*isolate->factory()->NewError(
+ isolate->error_function(),
+ i::MessageTemplate::kDataCloneDeserializationError));
+ return MaybeLocal<WasmCompiledModule>();
}
struct ValueDeserializer::PrivateData {
@@ -3277,6 +3291,10 @@
void ValueDeserializer::SetSupportsLegacyWireFormat(
bool supports_legacy_wire_format) {
private_->supports_legacy_wire_format = supports_legacy_wire_format;
+}
+
+void ValueDeserializer::SetExpectInlineWasm(bool expect_inline_wasm) {
+ private_->deserializer.set_expect_inline_wasm(expect_inline_wasm);
}
uint32_t ValueDeserializer::GetWireFormatVersion() const {
@@ -7510,6 +7528,36 @@
return Local<String>::Cast(Utils::ToLocal(wire_bytes));
}
+// Currently, wasm modules are bound, both to Isolate and to
+// the Context they were created in. The currently-supported means to
+// decontextualize and then re-contextualize a module is via
+// serialization/deserialization.
+WasmCompiledModule::TransferrableModule
+WasmCompiledModule::GetTransferrableModule() {
+ i::DisallowHeapAllocation no_gc;
+ WasmCompiledModule::SerializedModule compiled_part = Serialize();
+
+ Local<String> wire_bytes = GetWasmWireBytes();
+ size_t wire_size = static_cast<size_t>(wire_bytes->Length());
+ uint8_t* bytes = new uint8_t[wire_size];
+ wire_bytes->WriteOneByte(bytes, 0, wire_bytes->Length());
+
+ return TransferrableModule(
+ std::move(compiled_part),
+ std::make_pair(
+ std::unique_ptr<const uint8_t[]>(const_cast<const uint8_t*>(bytes)),
+ wire_size));
+}
+
+MaybeLocal<WasmCompiledModule> WasmCompiledModule::FromTransferrableModule(
+ Isolate* isolate,
+ const WasmCompiledModule::TransferrableModule& transferrable_module) {
+ MaybeLocal<WasmCompiledModule> ret =
+ Deserialize(isolate, AsCallerOwned(transferrable_module.compiled_code),
+ AsCallerOwned(transferrable_module.wire_bytes));
+ return ret;
+}
+
WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() {
i::Handle<i::JSObject> obj =
i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
« no previous file with comments | « include/v8.h ('k') | src/value-serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698