Commit 16afa0a2 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[api][wasm] Rename WasmCompiledModule to WasmModuleObject

A WasmModuleObject represents an instance of WebAssembly.Module. It is
called WasmModuleObject internally, so also use that name externally.

We still have a typedef for WasmCompiledModule which will be deprecated
once chromium has been updated to use WasmModuleObject.

R=titzer@chromium.org, adamk@chromium.org

Bug: v8:8238, chromium:912031
Change-Id: I2d7708d4dc183cb4f4714f741b1ea0c153014430
Reviewed-on: https://chromium-review.googlesource.com/c/1362048Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58055}
parent f8eb3dba
...@@ -81,7 +81,7 @@ class Private; ...@@ -81,7 +81,7 @@ class Private;
class Uint32; class Uint32;
class Utils; class Utils;
class Value; class Value;
class WasmCompiledModule; class WasmModuleObject;
template <class T> class Local; template <class T> class Local;
template <class T> template <class T>
class MaybeLocal; class MaybeLocal;
...@@ -1902,7 +1902,7 @@ class V8_EXPORT ValueSerializer { ...@@ -1902,7 +1902,7 @@ class V8_EXPORT ValueSerializer {
Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer); Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
virtual Maybe<uint32_t> GetWasmModuleTransferId( virtual Maybe<uint32_t> GetWasmModuleTransferId(
Isolate* isolate, Local<WasmCompiledModule> module); Isolate* isolate, Local<WasmModuleObject> module);
/** /**
* Allocates memory for the buffer of at least the size provided. The actual * 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 * size (which may be greater or equal) is written to |actual_size|. If no
...@@ -2006,10 +2006,10 @@ class V8_EXPORT ValueDeserializer { ...@@ -2006,10 +2006,10 @@ class V8_EXPORT ValueDeserializer {
virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);
/** /**
* Get a WasmCompiledModule given a transfer_id previously provided * Get a WasmModuleObject given a transfer_id previously provided
* by ValueSerializer::GetWasmModuleTransferId * by ValueSerializer::GetWasmModuleTransferId
*/ */
virtual MaybeLocal<WasmCompiledModule> GetWasmModuleFromId( virtual MaybeLocal<WasmModuleObject> GetWasmModuleFromId(
Isolate* isolate, uint32_t transfer_id); Isolate* isolate, uint32_t transfer_id);
/** /**
...@@ -4253,9 +4253,8 @@ class V8_EXPORT Proxy : public Object { ...@@ -4253,9 +4253,8 @@ class V8_EXPORT Proxy : public Object {
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
// TODO(mtrofin): rename WasmCompiledModule to WasmModuleObject, for // An instance of WebAssembly.Module.
// consistency with internal APIs. class V8_EXPORT WasmModuleObject : public Object {
class V8_EXPORT WasmCompiledModule : public Object {
public: public:
typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule;
...@@ -4284,7 +4283,7 @@ class V8_EXPORT WasmCompiledModule : public Object { ...@@ -4284,7 +4283,7 @@ class V8_EXPORT WasmCompiledModule : public Object {
private: private:
typedef std::shared_ptr<internal::wasm::NativeModule> SharedModule; typedef std::shared_ptr<internal::wasm::NativeModule> SharedModule;
typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer; typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer;
friend class WasmCompiledModule; friend class WasmModuleObject;
explicit TransferrableModule(SharedModule shared_module) explicit TransferrableModule(SharedModule shared_module)
: shared_module_(std::move(shared_module)) {} : shared_module_(std::move(shared_module)) {}
TransferrableModule(OwnedBuffer serialized, OwnedBuffer bytes) TransferrableModule(OwnedBuffer serialized, OwnedBuffer bytes)
...@@ -4303,10 +4302,10 @@ class V8_EXPORT WasmCompiledModule : public Object { ...@@ -4303,10 +4302,10 @@ class V8_EXPORT WasmCompiledModule : public Object {
TransferrableModule GetTransferrableModule(); TransferrableModule GetTransferrableModule();
/** /**
* Efficiently re-create a WasmCompiledModule, without recompiling, from * Efficiently re-create a WasmModuleObject, without recompiling, from
* a TransferrableModule. * a TransferrableModule.
*/ */
static MaybeLocal<WasmCompiledModule> FromTransferrableModule( static MaybeLocal<WasmModuleObject> FromTransferrableModule(
Isolate* isolate, const TransferrableModule&); Isolate* isolate, const TransferrableModule&);
/** /**
...@@ -4324,27 +4323,30 @@ class V8_EXPORT WasmCompiledModule : public Object { ...@@ -4324,27 +4323,30 @@ class V8_EXPORT WasmCompiledModule : public Object {
* If possible, deserialize the module, otherwise compile it from the provided * If possible, deserialize the module, otherwise compile it from the provided
* uncompiled bytes. * uncompiled bytes.
*/ */
static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( static MaybeLocal<WasmModuleObject> DeserializeOrCompile(
Isolate* isolate, BufferReference serialized_module, Isolate* isolate, BufferReference serialized_module,
BufferReference wire_bytes); BufferReference wire_bytes);
V8_INLINE static WasmCompiledModule* Cast(Value* obj); V8_INLINE static WasmModuleObject* Cast(Value* obj);
private: private:
static MaybeLocal<WasmCompiledModule> Deserialize( static MaybeLocal<WasmModuleObject> Deserialize(
Isolate* isolate, BufferReference serialized_module, Isolate* isolate, BufferReference serialized_module,
BufferReference wire_bytes); BufferReference wire_bytes);
static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, static MaybeLocal<WasmModuleObject> Compile(Isolate* isolate,
const uint8_t* start, const uint8_t* start,
size_t length); size_t length);
static BufferReference AsReference( static BufferReference AsReference(
const TransferrableModule::OwnedBuffer& buff) { const TransferrableModule::OwnedBuffer& buff) {
return {buff.first.get(), buff.second}; return {buff.first.get(), buff.second};
} }
WasmCompiledModule(); WasmModuleObject();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
V8_DEPRECATE_SOON("Use WasmModuleObject",
typedef WasmModuleObject WasmCompiledModule);
/** /**
* The V8 interface for WebAssembly streaming compilation. When streaming * The V8 interface for WebAssembly streaming compilation. When streaming
* compilation is initiated, V8 passes a {WasmStreaming} object to the embedder * compilation is initiated, V8 passes a {WasmStreaming} object to the embedder
...@@ -4384,7 +4386,7 @@ class V8_EXPORT WasmStreaming final { ...@@ -4384,7 +4386,7 @@ class V8_EXPORT WasmStreaming final {
* passed to {SetModuleCompiledCallback}, |compiled_module| is the result. * passed to {SetModuleCompiledCallback}, |compiled_module| is the result.
*/ */
typedef void (*ModuleCompiledCallback)( typedef void (*ModuleCompiledCallback)(
intptr_t data, Local<WasmCompiledModule> compiled_module); intptr_t data, Local<WasmModuleObject> compiled_module);
/** /**
* Sets a callback for when compilation of the Wasm module has been completed * Sets a callback for when compilation of the Wasm module has been completed
...@@ -10140,11 +10142,11 @@ Proxy* Proxy::Cast(v8::Value* value) { ...@@ -10140,11 +10142,11 @@ Proxy* Proxy::Cast(v8::Value* value) {
return static_cast<Proxy*>(value); return static_cast<Proxy*>(value);
} }
WasmCompiledModule* WasmCompiledModule::Cast(v8::Value* value) { WasmModuleObject* WasmModuleObject::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
CheckCast(value); CheckCast(value);
#endif #endif
return static_cast<WasmCompiledModule*>(value); return static_cast<WasmModuleObject*>(value);
} }
Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) { Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) {
......
...@@ -3043,7 +3043,7 @@ Maybe<uint32_t> ValueSerializer::Delegate::GetSharedArrayBufferId( ...@@ -3043,7 +3043,7 @@ Maybe<uint32_t> ValueSerializer::Delegate::GetSharedArrayBufferId(
} }
Maybe<uint32_t> ValueSerializer::Delegate::GetWasmModuleTransferId( Maybe<uint32_t> ValueSerializer::Delegate::GetWasmModuleTransferId(
Isolate* v8_isolate, Local<WasmCompiledModule> module) { Isolate* v8_isolate, Local<WasmModuleObject> module) {
return Nothing<uint32_t>(); return Nothing<uint32_t>();
} }
...@@ -3127,13 +3127,13 @@ MaybeLocal<Object> ValueDeserializer::Delegate::ReadHostObject( ...@@ -3127,13 +3127,13 @@ MaybeLocal<Object> ValueDeserializer::Delegate::ReadHostObject(
return MaybeLocal<Object>(); return MaybeLocal<Object>();
} }
MaybeLocal<WasmCompiledModule> ValueDeserializer::Delegate::GetWasmModuleFromId( MaybeLocal<WasmModuleObject> ValueDeserializer::Delegate::GetWasmModuleFromId(
Isolate* v8_isolate, uint32_t id) { Isolate* v8_isolate, uint32_t id) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
isolate->ScheduleThrow(*isolate->factory()->NewError( isolate->ScheduleThrow(*isolate->factory()->NewError(
isolate->error_function(), isolate->error_function(),
i::MessageTemplate::kDataCloneDeserializationError)); i::MessageTemplate::kDataCloneDeserializationError));
return MaybeLocal<WasmCompiledModule>(); return MaybeLocal<WasmModuleObject>();
} }
MaybeLocal<SharedArrayBuffer> MaybeLocal<SharedArrayBuffer>
...@@ -3745,10 +3745,10 @@ void v8::Proxy::CheckCast(Value* that) { ...@@ -3745,10 +3745,10 @@ void v8::Proxy::CheckCast(Value* that) {
"Could not convert to proxy"); "Could not convert to proxy");
} }
void v8::WasmCompiledModule::CheckCast(Value* that) { void v8::WasmModuleObject::CheckCast(Value* that) {
Utils::ApiCheck(that->IsWebAssemblyCompiledModule(), Utils::ApiCheck(that->IsWebAssemblyCompiledModule(),
"v8::WasmCompiledModule::Cast", "v8::WasmModuleObject::Cast",
"Could not convert to wasm compiled module"); "Could not convert to wasm module object");
} }
void v8::ArrayBuffer::CheckCast(Value* that) { void v8::ArrayBuffer::CheckCast(Value* that) {
...@@ -7352,21 +7352,21 @@ MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target, ...@@ -7352,21 +7352,21 @@ MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target,
RETURN_ESCAPED(result); RETURN_ESCAPED(result);
} }
WasmCompiledModule::BufferReference WasmCompiledModule::GetWasmWireBytesRef() { WasmModuleObject::BufferReference WasmModuleObject::GetWasmWireBytesRef() {
i::Handle<i::WasmModuleObject> obj = i::Handle<i::WasmModuleObject> obj =
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this)); i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
i::Vector<const uint8_t> bytes_vec = obj->native_module()->wire_bytes(); i::Vector<const uint8_t> bytes_vec = obj->native_module()->wire_bytes();
return {bytes_vec.start(), bytes_vec.size()}; return {bytes_vec.start(), bytes_vec.size()};
} }
WasmCompiledModule::TransferrableModule WasmModuleObject::TransferrableModule
WasmCompiledModule::GetTransferrableModule() { WasmModuleObject::GetTransferrableModule() {
if (i::FLAG_wasm_shared_code) { if (i::FLAG_wasm_shared_code) {
i::Handle<i::WasmModuleObject> obj = i::Handle<i::WasmModuleObject> obj =
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this)); i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
return TransferrableModule(obj->managed_native_module()->get()); return TransferrableModule(obj->managed_native_module()->get());
} else { } else {
WasmCompiledModule::SerializedModule serialized_module = Serialize(); WasmModuleObject::SerializedModule serialized_module = Serialize();
BufferReference wire_bytes_ref = GetWasmWireBytesRef(); BufferReference wire_bytes_ref = GetWasmWireBytesRef();
size_t wire_size = wire_bytes_ref.size; size_t wire_size = wire_bytes_ref.size;
std::unique_ptr<uint8_t[]> wire_bytes_copy(new uint8_t[wire_size]); std::unique_ptr<uint8_t[]> wire_bytes_copy(new uint8_t[wire_size]);
...@@ -7376,15 +7376,15 @@ WasmCompiledModule::GetTransferrableModule() { ...@@ -7376,15 +7376,15 @@ WasmCompiledModule::GetTransferrableModule() {
} }
} }
MaybeLocal<WasmCompiledModule> WasmCompiledModule::FromTransferrableModule( MaybeLocal<WasmModuleObject> WasmModuleObject::FromTransferrableModule(
Isolate* isolate, Isolate* isolate,
const WasmCompiledModule::TransferrableModule& transferrable_module) { const WasmModuleObject::TransferrableModule& transferrable_module) {
if (i::FLAG_wasm_shared_code) { if (i::FLAG_wasm_shared_code) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::WasmModuleObject> module_object = i::Handle<i::WasmModuleObject> module_object =
i_isolate->wasm_engine()->ImportNativeModule( i_isolate->wasm_engine()->ImportNativeModule(
i_isolate, transferrable_module.shared_module_); i_isolate, transferrable_module.shared_module_);
return Local<WasmCompiledModule>::Cast( return Local<WasmModuleObject>::Cast(
Utils::ToLocal(i::Handle<i::JSObject>::cast(module_object))); Utils::ToLocal(i::Handle<i::JSObject>::cast(module_object)));
} else { } else {
return Deserialize(isolate, AsReference(transferrable_module.serialized_), return Deserialize(isolate, AsReference(transferrable_module.serialized_),
...@@ -7392,7 +7392,7 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::FromTransferrableModule( ...@@ -7392,7 +7392,7 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::FromTransferrableModule(
} }
} }
WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() { WasmModuleObject::SerializedModule WasmModuleObject::Serialize() {
i::Handle<i::WasmModuleObject> obj = i::Handle<i::WasmModuleObject> obj =
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this)); i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
i::wasm::NativeModule* native_module = obj->native_module(); i::wasm::NativeModule* native_module = obj->native_module();
...@@ -7404,9 +7404,9 @@ WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() { ...@@ -7404,9 +7404,9 @@ WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() {
return {}; return {};
} }
MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize( MaybeLocal<WasmModuleObject> WasmModuleObject::Deserialize(
Isolate* isolate, WasmCompiledModule::BufferReference serialized_module, Isolate* isolate, WasmModuleObject::BufferReference serialized_module,
WasmCompiledModule::BufferReference wire_bytes) { WasmModuleObject::BufferReference wire_bytes) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::MaybeHandle<i::WasmModuleObject> maybe_module_object = i::MaybeHandle<i::WasmModuleObject> maybe_module_object =
i::wasm::DeserializeNativeModule( i::wasm::DeserializeNativeModule(
...@@ -7414,16 +7414,16 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize( ...@@ -7414,16 +7414,16 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize(
{wire_bytes.start, wire_bytes.size}); {wire_bytes.start, wire_bytes.size});
i::Handle<i::WasmModuleObject> module_object; i::Handle<i::WasmModuleObject> module_object;
if (!maybe_module_object.ToHandle(&module_object)) { if (!maybe_module_object.ToHandle(&module_object)) {
return MaybeLocal<WasmCompiledModule>(); return MaybeLocal<WasmModuleObject>();
} }
return Local<WasmCompiledModule>::Cast( return Local<WasmModuleObject>::Cast(
Utils::ToLocal(i::Handle<i::JSObject>::cast(module_object))); Utils::ToLocal(i::Handle<i::JSObject>::cast(module_object)));
} }
MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile( MaybeLocal<WasmModuleObject> WasmModuleObject::DeserializeOrCompile(
Isolate* isolate, WasmCompiledModule::BufferReference serialized_module, Isolate* isolate, WasmModuleObject::BufferReference serialized_module,
WasmCompiledModule::BufferReference wire_bytes) { WasmModuleObject::BufferReference wire_bytes) {
MaybeLocal<WasmCompiledModule> ret = MaybeLocal<WasmModuleObject> ret =
Deserialize(isolate, serialized_module, wire_bytes); Deserialize(isolate, serialized_module, wire_bytes);
if (!ret.IsEmpty()) { if (!ret.IsEmpty()) {
return ret; return ret;
...@@ -7431,21 +7431,21 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile( ...@@ -7431,21 +7431,21 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile(
return Compile(isolate, wire_bytes.start, wire_bytes.size); return Compile(isolate, wire_bytes.start, wire_bytes.size);
} }
MaybeLocal<WasmCompiledModule> WasmCompiledModule::Compile(Isolate* isolate, MaybeLocal<WasmModuleObject> WasmModuleObject::Compile(Isolate* isolate,
const uint8_t* start, const uint8_t* start,
size_t length) { size_t length) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::wasm::ErrorThrower thrower(i_isolate, "WasmCompiledModule::Compile()"); i::wasm::ErrorThrower thrower(i_isolate, "WasmModuleObject::Compile()");
if (!i::wasm::IsWasmCodegenAllowed(i_isolate, i_isolate->native_context())) { if (!i::wasm::IsWasmCodegenAllowed(i_isolate, i_isolate->native_context())) {
return MaybeLocal<WasmCompiledModule>(); return MaybeLocal<WasmModuleObject>();
} }
auto enabled_features = i::wasm::WasmFeaturesFromIsolate(i_isolate); auto enabled_features = i::wasm::WasmFeaturesFromIsolate(i_isolate);
i::MaybeHandle<i::JSObject> maybe_compiled = i::MaybeHandle<i::JSObject> maybe_compiled =
i_isolate->wasm_engine()->SyncCompile( i_isolate->wasm_engine()->SyncCompile(
i_isolate, enabled_features, &thrower, i_isolate, enabled_features, &thrower,
i::wasm::ModuleWireBytes(start, start + length)); i::wasm::ModuleWireBytes(start, start + length));
if (maybe_compiled.is_null()) return MaybeLocal<WasmCompiledModule>(); if (maybe_compiled.is_null()) return MaybeLocal<WasmModuleObject>();
return Local<WasmCompiledModule>::Cast( return Local<WasmModuleObject>::Cast(
Utils::ToLocal(maybe_compiled.ToHandleChecked())); Utils::ToLocal(maybe_compiled.ToHandleChecked()));
} }
......
...@@ -3121,7 +3121,7 @@ class Serializer : public ValueSerializer::Delegate { ...@@ -3121,7 +3121,7 @@ class Serializer : public ValueSerializer::Delegate {
} }
Maybe<uint32_t> GetWasmModuleTransferId( Maybe<uint32_t> GetWasmModuleTransferId(
Isolate* isolate, Local<WasmCompiledModule> module) override { Isolate* isolate, Local<WasmModuleObject> module) override {
DCHECK_NOT_NULL(data_); DCHECK_NOT_NULL(data_);
for (size_t index = 0; index < wasm_modules_.size(); ++index) { for (size_t index = 0; index < wasm_modules_.size(); ++index) {
if (wasm_modules_[index] == module) { if (wasm_modules_[index] == module) {
...@@ -3220,7 +3220,7 @@ class Serializer : public ValueSerializer::Delegate { ...@@ -3220,7 +3220,7 @@ class Serializer : public ValueSerializer::Delegate {
std::unique_ptr<SerializationData> data_; std::unique_ptr<SerializationData> data_;
std::vector<Global<ArrayBuffer>> array_buffers_; std::vector<Global<ArrayBuffer>> array_buffers_;
std::vector<Global<SharedArrayBuffer>> shared_array_buffers_; std::vector<Global<SharedArrayBuffer>> shared_array_buffers_;
std::vector<Global<WasmCompiledModule>> wasm_modules_; std::vector<Global<WasmModuleObject>> wasm_modules_;
std::vector<ExternalizedContents> externalized_contents_; std::vector<ExternalizedContents> externalized_contents_;
size_t current_memory_usage_; size_t current_memory_usage_;
...@@ -3264,14 +3264,14 @@ class Deserializer : public ValueDeserializer::Delegate { ...@@ -3264,14 +3264,14 @@ class Deserializer : public ValueDeserializer::Delegate {
return MaybeLocal<SharedArrayBuffer>(); return MaybeLocal<SharedArrayBuffer>();
} }
MaybeLocal<WasmCompiledModule> GetWasmModuleFromId( MaybeLocal<WasmModuleObject> GetWasmModuleFromId(
Isolate* isolate, uint32_t transfer_id) override { Isolate* isolate, uint32_t transfer_id) override {
DCHECK_NOT_NULL(data_); DCHECK_NOT_NULL(data_);
if (transfer_id < data_->transferrable_modules().size()) { if (transfer_id < data_->transferrable_modules().size()) {
return WasmCompiledModule::FromTransferrableModule( return WasmModuleObject::FromTransferrableModule(
isolate_, data_->transferrable_modules().at(transfer_id)); isolate_, data_->transferrable_modules().at(transfer_id));
} }
return MaybeLocal<WasmCompiledModule>(); return MaybeLocal<WasmModuleObject>();
} }
private: private:
......
...@@ -186,7 +186,7 @@ class SerializationData { ...@@ -186,7 +186,7 @@ class SerializationData {
shared_array_buffer_contents() { shared_array_buffer_contents() {
return shared_array_buffer_contents_; return shared_array_buffer_contents_;
} }
const std::vector<WasmCompiledModule::TransferrableModule>& const std::vector<WasmModuleObject::TransferrableModule>&
transferrable_modules() { transferrable_modules() {
return transferrable_modules_; return transferrable_modules_;
} }
...@@ -200,7 +200,7 @@ class SerializationData { ...@@ -200,7 +200,7 @@ class SerializationData {
size_t size_; size_t size_;
std::vector<ArrayBuffer::Contents> array_buffer_contents_; std::vector<ArrayBuffer::Contents> array_buffer_contents_;
std::vector<SharedArrayBuffer::Contents> shared_array_buffer_contents_; std::vector<SharedArrayBuffer::Contents> shared_array_buffer_contents_;
std::vector<WasmCompiledModule::TransferrableModule> transferrable_modules_; std::vector<WasmModuleObject::TransferrableModule> transferrable_modules_;
private: private:
friend class Serializer; friend class Serializer;
......
...@@ -68,8 +68,8 @@ bool IsWasmInstantiateAllowed(v8::Isolate* isolate, ...@@ -68,8 +68,8 @@ bool IsWasmInstantiateAllowed(v8::Isolate* isolate,
if (!module_or_bytes->IsWebAssemblyCompiledModule()) { if (!module_or_bytes->IsWebAssemblyCompiledModule()) {
return IsWasmCompileAllowed(isolate, module_or_bytes, is_async); return IsWasmCompileAllowed(isolate, module_or_bytes, is_async);
} }
v8::Local<v8::WasmCompiledModule> module = v8::Local<v8::WasmModuleObject> module =
v8::Local<v8::WasmCompiledModule>::Cast(module_or_bytes); v8::Local<v8::WasmModuleObject>::Cast(module_or_bytes);
return static_cast<uint32_t>(module->GetWasmWireBytesRef().size) <= return static_cast<uint32_t>(module->GetWasmWireBytesRef().size) <=
ctrls.MaxWasmBufferSize; ctrls.MaxWasmBufferSize;
} }
......
...@@ -874,7 +874,7 @@ Maybe<bool> ValueSerializer::WriteWasmModule(Handle<WasmModuleObject> object) { ...@@ -874,7 +874,7 @@ Maybe<bool> ValueSerializer::WriteWasmModule(Handle<WasmModuleObject> object) {
// TODO(titzer): introduce a Utils::ToLocal for WasmModuleObject. // TODO(titzer): introduce a Utils::ToLocal for WasmModuleObject.
Maybe<uint32_t> transfer_id = delegate_->GetWasmModuleTransferId( Maybe<uint32_t> transfer_id = delegate_->GetWasmModuleTransferId(
reinterpret_cast<v8::Isolate*>(isolate_), reinterpret_cast<v8::Isolate*>(isolate_),
v8::Local<v8::WasmCompiledModule>::Cast( v8::Local<v8::WasmModuleObject>::Cast(
Utils::ToLocal(Handle<JSObject>::cast(object)))); Utils::ToLocal(Handle<JSObject>::cast(object))));
RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate_, Nothing<bool>()); RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate_, Nothing<bool>());
uint32_t id = 0; uint32_t id = 0;
......
...@@ -62,10 +62,10 @@ class WasmStreaming::WasmStreamingImpl { ...@@ -62,10 +62,10 @@ class WasmStreaming::WasmStreamingImpl {
void SetModuleCompiledCallback(ModuleCompiledCallback callback, void SetModuleCompiledCallback(ModuleCompiledCallback callback,
intptr_t data) { intptr_t data) {
// Wrap the embedder callback here so we can also wrap the result as a // Wrap the embedder callback here so we can also wrap the result as a
// Local<WasmCompiledModule> here. // Local<WasmModuleObject> here.
streaming_decoder_->SetModuleCompiledCallback( streaming_decoder_->SetModuleCompiledCallback(
[callback, data](i::Handle<i::WasmModuleObject> module_object) { [callback, data](i::Handle<i::WasmModuleObject> module_object) {
callback(data, Local<WasmCompiledModule>::Cast(Utils::ToLocal( callback(data, Local<WasmModuleObject>::Cast(Utils::ToLocal(
i::Handle<i::JSObject>::cast(module_object)))); i::Handle<i::JSObject>::cast(module_object))));
}); });
} }
......
...@@ -58,12 +58,12 @@ void BuildTrivialModule(Zone* zone, ZoneBuffer* buffer) { ...@@ -58,12 +58,12 @@ void BuildTrivialModule(Zone* zone, ZoneBuffer* buffer) {
} }
bool TestModule(Isolate* isolate, bool TestModule(Isolate* isolate,
v8::WasmCompiledModule::BufferReference wire_bytes) { v8::WasmModuleObject::BufferReference wire_bytes) {
HandleScope scope(isolate); HandleScope scope(isolate);
v8::WasmCompiledModule::BufferReference serialized_module(nullptr, 0); v8::WasmModuleObject::BufferReference serialized_module(nullptr, 0);
MaybeLocal<v8::WasmCompiledModule> module = MaybeLocal<v8::WasmModuleObject> module =
v8::WasmCompiledModule::DeserializeOrCompile( v8::WasmModuleObject::DeserializeOrCompile(
reinterpret_cast<v8::Isolate*>(isolate), serialized_module, reinterpret_cast<v8::Isolate*>(isolate), serialized_module,
wire_bytes); wire_bytes);
return !module.IsEmpty(); return !module.IsEmpty();
...@@ -76,8 +76,8 @@ TEST(PropertiesOfCodegenCallbacks) { ...@@ -76,8 +76,8 @@ TEST(PropertiesOfCodegenCallbacks) {
Zone zone(&allocator, ZONE_NAME); Zone zone(&allocator, ZONE_NAME);
ZoneBuffer buffer(&zone); ZoneBuffer buffer(&zone);
BuildTrivialModule(&zone, &buffer); BuildTrivialModule(&zone, &buffer);
v8::WasmCompiledModule::BufferReference wire_bytes = {buffer.begin(), v8::WasmModuleObject::BufferReference wire_bytes = {buffer.begin(),
buffer.size()}; buffer.size()};
Isolate* isolate = CcTest::InitIsolateOnce(); Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate); HandleScope scope(isolate);
testing::SetupIsolateForWasmModule(isolate); testing::SetupIsolateForWasmModule(isolate);
......
...@@ -84,17 +84,17 @@ class WasmSerializationTest { ...@@ -84,17 +84,17 @@ class WasmSerializationTest {
*slot = 0u; *slot = 0u;
} }
v8::MaybeLocal<v8::WasmCompiledModule> Deserialize() { v8::MaybeLocal<v8::WasmModuleObject> Deserialize() {
ErrorThrower thrower(current_isolate(), ""); ErrorThrower thrower(current_isolate(), "");
v8::MaybeLocal<v8::WasmCompiledModule> deserialized = v8::MaybeLocal<v8::WasmModuleObject> deserialized =
v8::WasmCompiledModule::DeserializeOrCompile( v8::WasmModuleObject::DeserializeOrCompile(
current_isolate_v8(), serialized_bytes_, wire_bytes_); current_isolate_v8(), serialized_bytes_, wire_bytes_);
return deserialized; return deserialized;
} }
void DeserializeAndRun() { void DeserializeAndRun() {
ErrorThrower thrower(current_isolate(), ""); ErrorThrower thrower(current_isolate(), "");
v8::Local<v8::WasmCompiledModule> deserialized_module; v8::Local<v8::WasmModuleObject> deserialized_module;
CHECK(Deserialize().ToLocal(&deserialized_module)); CHECK(Deserialize().ToLocal(&deserialized_module));
Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast( Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast(
v8::Utils::OpenHandle(*deserialized_module)); v8::Utils::OpenHandle(*deserialized_module));
...@@ -159,9 +159,9 @@ class WasmSerializationTest { ...@@ -159,9 +159,9 @@ class WasmSerializationTest {
v8::Utils::ToLocal(Handle<JSObject>::cast(module_object)); v8::Utils::ToLocal(Handle<JSObject>::cast(module_object));
CHECK(v8_module_obj->IsWebAssemblyCompiledModule()); CHECK(v8_module_obj->IsWebAssemblyCompiledModule());
v8::Local<v8::WasmCompiledModule> v8_compiled_module = v8::Local<v8::WasmModuleObject> v8_compiled_module =
v8_module_obj.As<v8::WasmCompiledModule>(); v8_module_obj.As<v8::WasmModuleObject>();
v8::WasmCompiledModule::BufferReference uncompiled_bytes = v8::WasmModuleObject::BufferReference uncompiled_bytes =
v8_compiled_module->GetWasmWireBytesRef(); v8_compiled_module->GetWasmWireBytesRef();
uint8_t* bytes_copy = zone()->NewArray<uint8_t>(uncompiled_bytes.size); uint8_t* bytes_copy = zone()->NewArray<uint8_t>(uncompiled_bytes.size);
memcpy(bytes_copy, uncompiled_bytes.start, uncompiled_bytes.size); memcpy(bytes_copy, uncompiled_bytes.start, uncompiled_bytes.size);
...@@ -191,9 +191,9 @@ class WasmSerializationTest { ...@@ -191,9 +191,9 @@ class WasmSerializationTest {
v8::internal::AccountingAllocator allocator_; v8::internal::AccountingAllocator allocator_;
Zone zone_; Zone zone_;
v8::WasmCompiledModule::SerializedModule data_; v8::WasmModuleObject::SerializedModule data_;
v8::WasmCompiledModule::BufferReference wire_bytes_ = {nullptr, 0}; v8::WasmModuleObject::BufferReference wire_bytes_ = {nullptr, 0};
v8::WasmCompiledModule::BufferReference serialized_bytes_ = {nullptr, 0}; v8::WasmModuleObject::BufferReference serialized_bytes_ = {nullptr, 0};
v8::Isolate* current_isolate_v8_; v8::Isolate* current_isolate_v8_;
}; };
...@@ -263,7 +263,7 @@ TEST(BlockWasmCodeGenAtDeserialization) { ...@@ -263,7 +263,7 @@ TEST(BlockWasmCodeGenAtDeserialization) {
{ {
HandleScope scope(test.current_isolate()); HandleScope scope(test.current_isolate());
test.current_isolate_v8()->SetAllowCodeGenerationFromStringsCallback(False); test.current_isolate_v8()->SetAllowCodeGenerationFromStringsCallback(False);
v8::MaybeLocal<v8::WasmCompiledModule> nothing = test.Deserialize(); v8::MaybeLocal<v8::WasmModuleObject> nothing = test.Deserialize();
CHECK(nothing.IsEmpty()); CHECK(nothing.IsEmpty());
} }
Cleanup(test.current_isolate()); Cleanup(test.current_isolate());
...@@ -283,7 +283,7 @@ void TestTransferrableWasmModules(bool should_share) { ...@@ -283,7 +283,7 @@ void TestTransferrableWasmModules(bool should_share) {
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* from_isolate = v8::Isolate::New(create_params); v8::Isolate* from_isolate = v8::Isolate::New(create_params);
std::vector<v8::WasmCompiledModule::TransferrableModule> store; std::vector<v8::WasmModuleObject::TransferrableModule> store;
std::shared_ptr<NativeModule> original_native_module; std::shared_ptr<NativeModule> original_native_module;
{ {
v8::HandleScope scope(from_isolate); v8::HandleScope scope(from_isolate);
...@@ -299,8 +299,8 @@ void TestTransferrableWasmModules(bool should_share) { ...@@ -299,8 +299,8 @@ void TestTransferrableWasmModules(bool should_share) {
ModuleWireBytes(buffer.begin(), buffer.end())); ModuleWireBytes(buffer.begin(), buffer.end()));
Handle<WasmModuleObject> module_object = Handle<WasmModuleObject> module_object =
maybe_module_object.ToHandleChecked(); maybe_module_object.ToHandleChecked();
v8::Local<v8::WasmCompiledModule> v8_module = v8::Local<v8::WasmModuleObject> v8_module =
v8::Local<v8::WasmCompiledModule>::Cast( v8::Local<v8::WasmModuleObject>::Cast(
v8::Utils::ToLocal(Handle<JSObject>::cast(module_object))); v8::Utils::ToLocal(Handle<JSObject>::cast(module_object)));
store.push_back(v8_module->GetTransferrableModule()); store.push_back(v8_module->GetTransferrableModule());
original_native_module = module_object->managed_native_module()->get(); original_native_module = module_object->managed_native_module()->get();
...@@ -312,8 +312,8 @@ void TestTransferrableWasmModules(bool should_share) { ...@@ -312,8 +312,8 @@ void TestTransferrableWasmModules(bool should_share) {
v8::HandleScope scope(to_isolate); v8::HandleScope scope(to_isolate);
LocalContext env(to_isolate); LocalContext env(to_isolate);
v8::MaybeLocal<v8::WasmCompiledModule> transferred_module = v8::MaybeLocal<v8::WasmModuleObject> transferred_module =
v8::WasmCompiledModule::FromTransferrableModule(to_isolate, store[0]); v8::WasmModuleObject::FromTransferrableModule(to_isolate, store[0]);
CHECK(!transferred_module.IsEmpty()); CHECK(!transferred_module.IsEmpty());
Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast( Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast(
v8::Utils::OpenHandle(*transferred_module.ToLocalChecked())); v8::Utils::OpenHandle(*transferred_module.ToLocalChecked()));
......
...@@ -2382,7 +2382,7 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest { ...@@ -2382,7 +2382,7 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest {
class ThrowingSerializer : public ValueSerializer::Delegate { class ThrowingSerializer : public ValueSerializer::Delegate {
public: public:
Maybe<uint32_t> GetWasmModuleTransferId( Maybe<uint32_t> GetWasmModuleTransferId(
Isolate* isolate, Local<WasmCompiledModule> module) override { Isolate* isolate, Local<WasmModuleObject> module) override {
isolate->ThrowException(Exception::Error( isolate->ThrowException(Exception::Error(
String::NewFromOneByte( String::NewFromOneByte(
isolate, isolate,
...@@ -2398,10 +2398,10 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest { ...@@ -2398,10 +2398,10 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest {
class SerializeToTransfer : public ValueSerializer::Delegate { class SerializeToTransfer : public ValueSerializer::Delegate {
public: public:
SerializeToTransfer( SerializeToTransfer(
std::vector<WasmCompiledModule::TransferrableModule>* modules) std::vector<WasmModuleObject::TransferrableModule>* modules)
: modules_(modules) {} : modules_(modules) {}
Maybe<uint32_t> GetWasmModuleTransferId( Maybe<uint32_t> GetWasmModuleTransferId(
Isolate* isolate, Local<WasmCompiledModule> module) override { Isolate* isolate, Local<WasmModuleObject> module) override {
modules_->push_back(module->GetTransferrableModule()); modules_->push_back(module->GetTransferrableModule());
return Just(static_cast<uint32_t>(modules_->size()) - 1); return Just(static_cast<uint32_t>(modules_->size()) - 1);
} }
...@@ -2409,23 +2409,23 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest { ...@@ -2409,23 +2409,23 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest {
void ThrowDataCloneError(Local<String> message) override { UNREACHABLE(); } void ThrowDataCloneError(Local<String> message) override { UNREACHABLE(); }
private: private:
std::vector<WasmCompiledModule::TransferrableModule>* modules_; std::vector<WasmModuleObject::TransferrableModule>* modules_;
}; };
class DeserializeFromTransfer : public ValueDeserializer::Delegate { class DeserializeFromTransfer : public ValueDeserializer::Delegate {
public: public:
DeserializeFromTransfer( DeserializeFromTransfer(
std::vector<WasmCompiledModule::TransferrableModule>* modules) std::vector<WasmModuleObject::TransferrableModule>* modules)
: modules_(modules) {} : modules_(modules) {}
MaybeLocal<WasmCompiledModule> GetWasmModuleFromId(Isolate* isolate, MaybeLocal<WasmModuleObject> GetWasmModuleFromId(Isolate* isolate,
uint32_t id) override { uint32_t id) override {
return WasmCompiledModule::FromTransferrableModule(isolate, return WasmModuleObject::FromTransferrableModule(isolate,
modules_->at(id)); modules_->at(id));
} }
private: private:
std::vector<WasmCompiledModule::TransferrableModule>* modules_; std::vector<WasmModuleObject::TransferrableModule>* modules_;
}; };
ValueSerializer::Delegate* GetSerializerDelegate() override { ValueSerializer::Delegate* GetSerializerDelegate() override {
...@@ -2436,9 +2436,9 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest { ...@@ -2436,9 +2436,9 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest {
return current_deserializer_delegate_; return current_deserializer_delegate_;
} }
Local<WasmCompiledModule> MakeWasm() { Local<WasmModuleObject> MakeWasm() {
Context::Scope scope(serialization_context()); Context::Scope scope(serialization_context());
return WasmCompiledModule::DeserializeOrCompile( return WasmModuleObject::DeserializeOrCompile(
isolate(), {nullptr, 0}, isolate(), {nullptr, 0},
{kIncrementerWasm, sizeof(kIncrementerWasm)}) {kIncrementerWasm, sizeof(kIncrementerWasm)})
.ToLocalChecked(); .ToLocalChecked();
...@@ -2505,7 +2505,7 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest { ...@@ -2505,7 +2505,7 @@ class ValueSerializerTestWithWasm : public ValueSerializerTest {
private: private:
static bool g_saved_flag; static bool g_saved_flag;
std::vector<WasmCompiledModule::TransferrableModule> transfer_modules_; std::vector<WasmModuleObject::TransferrableModule> transfer_modules_;
SerializeToTransfer serialize_delegate_; SerializeToTransfer serialize_delegate_;
DeserializeFromTransfer deserialize_delegate_; DeserializeFromTransfer deserialize_delegate_;
ValueSerializer::Delegate* current_serializer_delegate_ = nullptr; ValueSerializer::Delegate* current_serializer_delegate_ = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment