Commit fd541d2e authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[snapshot] Better typing for WasmCompiledModuleSerializer.

R=jgruber@chromium.org
BUG=v8:7509

Change-Id: If5f7829c4f42e6cb2a8f39d2ddb92a6b024c3506
Reviewed-on: https://chromium-review.googlesource.com/948492Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51734}
parent bc72a831
......@@ -262,9 +262,7 @@ WasmCompiledModuleSerializer::WasmCompiledModuleSerializer(
}
std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
Isolate* isolate, Handle<Struct> input) {
Handle<WasmCompiledModule> compiled_module =
Handle<WasmCompiledModule>::cast(input);
Isolate* isolate, Handle<WasmCompiledModule> compiled_module) {
WasmCompiledModuleSerializer wasm_cs(
isolate, 0, isolate->native_context(),
handle(compiled_module->shared()->module_bytes()));
......@@ -272,11 +270,11 @@ std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
return std::unique_ptr<ScriptData>(data);
}
MaybeHandle<Struct> WasmCompiledModuleSerializer::DeserializeWasmModule(
MaybeHandle<WasmCompiledModule>
WasmCompiledModuleSerializer::DeserializeWasmModule(
Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) {
MaybeHandle<Struct> nothing;
if (!wasm::IsWasmCodegenAllowed(isolate, isolate->native_context())) {
return nothing;
return MaybeHandle<WasmCompiledModule>();
}
SerializedCodeData::SanityCheckResult sanity_check_result =
SerializedCodeData::CHECK_SUCCESS;
......@@ -285,7 +283,7 @@ MaybeHandle<Struct> WasmCompiledModuleSerializer::DeserializeWasmModule(
isolate, data, 0, &sanity_check_result);
if (sanity_check_result != SerializedCodeData::CHECK_SUCCESS) {
return nothing;
return MaybeHandle<WasmCompiledModule>();
}
// TODO(6792): No longer needed once WebAssembly code is off heap.
......@@ -295,7 +293,7 @@ MaybeHandle<Struct> WasmCompiledModuleSerializer::DeserializeWasmModule(
wire_bytes);
Handle<WasmCompiledModule> result;
if (!maybe_result.ToHandle(&result)) return nothing;
if (!maybe_result.ToHandle(&result)) return MaybeHandle<WasmCompiledModule>();
WasmCompiledModule::ReinitializeAfterDeserialization(isolate, result);
DCHECK(result->IsWasmCompiledModule());
......
......@@ -87,10 +87,9 @@ class CodeSerializer : public Serializer<> {
class WasmCompiledModuleSerializer : public CodeSerializer {
public:
// TODO(mstarzinger): Make these typed to {WasmCompiledModule} instead.
static std::unique_ptr<ScriptData> SerializeWasmModule(
Isolate* isolate, Handle<Struct> compiled_module);
static MaybeHandle<Struct> DeserializeWasmModule(
Isolate* isolate, Handle<WasmCompiledModule> compiled_module);
static MaybeHandle<WasmCompiledModule> DeserializeWasmModule(
Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes);
protected:
......
......@@ -633,13 +633,8 @@ MaybeHandle<WasmCompiledModule> DeserializeNativeModule(
Isolate* isolate, Vector<const byte> data, Vector<const byte> wire_bytes) {
if (!FLAG_wasm_jit_to_native) {
ScriptData script_data(data.start(), data.length());
Handle<Struct> compiled_module;
if (!WasmCompiledModuleSerializer::DeserializeWasmModule(
isolate, &script_data, wire_bytes)
.ToHandle(&compiled_module)) {
return {};
}
return Handle<WasmCompiledModule>::cast(compiled_module);
return WasmCompiledModuleSerializer::DeserializeWasmModule(
isolate, &script_data, wire_bytes);
}
if (!IsWasmCodegenAllowed(isolate, isolate->native_context())) {
return {};
......
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