Skip to content
Permalink
Browse files

v8: backport pieces from 99743ad460e

Backport new virtual methods from
99743ad460e (“[wasm] Transferrable modules”).

Ref: https://codereview.chromium.org/2748473004
Ref: v8/v8@99743ad

PR-URL: #12875
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
addaleax authored and jasnell committed May 6, 2017
1 parent 385499c commit 25430fd2478d3ea60e9407d7dd384db514f9bd03
Showing with 24 additions and 0 deletions.
  1. +10 −0 deps/v8/include/v8.h
  2. +14 −0 deps/v8/src/api.cc
@@ -108,6 +108,7 @@ class Private;
class Uint32;
class Utils;
class Value;
class WasmCompiledModule;
template <class T> class Local;
template <class T>
class MaybeLocal;
@@ -1707,6 +1708,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
@@ -1817,6 +1820,13 @@ class V8_EXPORT ValueDeserializer {
* MaybeLocal<Object>() returned.
*/
virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);

/*
* Get a WasmCompiledModule given a transfer_id previously provided
* by ValueSerializer::GetWasmModuleTransferId
*/
virtual MaybeLocal<WasmCompiledModule> GetWasmModuleFromId(
Isolate* isolate, uint32_t transfer_id);
};

ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
@@ -3119,6 +3119,11 @@ Maybe<uint32_t> ValueSerializer::Delegate::GetSharedArrayBufferId(
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) {
@@ -3207,6 +3212,15 @@ MaybeLocal<Object> ValueDeserializer::Delegate::ReadHostObject(
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 {
PrivateData(i::Isolate* i, i::Vector<const uint8_t> data, Delegate* delegate)
: isolate(i), deserializer(i, data, delegate) {}

0 comments on commit 25430fd

Please sign in to comment.
You can’t perform that action at this time.