diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc index 5b664de438..33bebae33a 100644 --- a/src/snapshot/code-serializer.cc +++ b/src/snapshot/code-serializer.cc @@ -13,11 +13,8 @@ #include "src/objects-inl.h" #include "src/snapshot/object-deserializer.h" #include "src/snapshot/snapshot.h" -#include "src/trap-handler/trap-handler.h" #include "src/version.h" #include "src/visitors.h" -#include "src/wasm/wasm-module.h" -#include "src/wasm/wasm-objects-inl.h" namespace v8 { namespace internal { @@ -253,92 +250,6 @@ MaybeHandle CodeSerializer::Deserialize( return scope.CloseAndEscape(result); } -WasmCompiledModuleSerializer::WasmCompiledModuleSerializer( - Isolate* isolate, uint32_t source_hash, Handle native_context, - Handle module_bytes) - : CodeSerializer(isolate, source_hash) { - reference_map()->AddAttachedReference(*isolate->native_context()); - reference_map()->AddAttachedReference(*module_bytes); -} - -std::unique_ptr WasmCompiledModuleSerializer::SerializeWasmModule( - Isolate* isolate, Handle compiled_module) { - WasmCompiledModuleSerializer wasm_cs( - isolate, 0, isolate->native_context(), - handle(compiled_module->shared()->module_bytes())); - ScriptData* data = wasm_cs.Serialize(compiled_module); - return std::unique_ptr(data); -} - -MaybeHandle -WasmCompiledModuleSerializer::DeserializeWasmModule( - Isolate* isolate, ScriptData* data, Vector wire_bytes) { - if (!wasm::IsWasmCodegenAllowed(isolate, isolate->native_context())) { - return MaybeHandle(); - } - SerializedCodeData::SanityCheckResult sanity_check_result = - SerializedCodeData::CHECK_SUCCESS; - - const SerializedCodeData scd = SerializedCodeData::FromCachedData( - isolate, data, 0, &sanity_check_result); - - if (sanity_check_result != SerializedCodeData::CHECK_SUCCESS) { - return MaybeHandle(); - } - - // TODO(6792): No longer needed once WebAssembly code is off heap. - CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); - MaybeHandle maybe_result = - ObjectDeserializer::DeserializeWasmCompiledModule(isolate, &scd, - wire_bytes); - - Handle result; - if (!maybe_result.ToHandle(&result)) return MaybeHandle(); - - WasmCompiledModule::ReinitializeAfterDeserialization(isolate, result); - DCHECK(result->IsWasmCompiledModule()); - return result; -} - -void WasmCompiledModuleSerializer::SerializeCodeObject( - Code* code_object, HowToCode how_to_code, WhereToPoint where_to_point) { - Code::Kind kind = code_object->kind(); - switch (kind) { - case Code::WASM_FUNCTION: - case Code::JS_TO_WASM_FUNCTION: { - // TODO(6792): No longer needed once WebAssembly code is off heap. - CodeSpaceMemoryModificationScope modification_scope(isolate()->heap()); - // Because the trap handler index is not meaningful across copies and - // serializations, we need to serialize it as kInvalidIndex. We do this by - // saving the old value, setting the index to kInvalidIndex and then - // restoring the old value. - const int old_trap_handler_index = - code_object->trap_handler_index()->value(); - code_object->set_trap_handler_index( - Smi::FromInt(trap_handler::kInvalidIndex)); - - // Just serialize the code_object. - SerializeGeneric(code_object, how_to_code, where_to_point); - code_object->set_trap_handler_index(Smi::FromInt(old_trap_handler_index)); - break; - } - case Code::WASM_INTERPRETER_ENTRY: - case Code::WASM_TO_JS_FUNCTION: - case Code::WASM_TO_WASM_FUNCTION: - // Serialize the illegal builtin instead. On instantiation of a - // deserialized module, these will be replaced again. - SerializeBuiltinReference(*BUILTIN_CODE(isolate(), Illegal), how_to_code, - where_to_point, 0); - break; - default: - UNREACHABLE(); - } -} - -bool WasmCompiledModuleSerializer::ElideObject(Object* obj) { - return obj->IsWeakCell() || obj->IsForeign() || obj->IsBreakPointInfo(); -} - class Checksum { public: explicit Checksum(Vector payload) { diff --git a/src/snapshot/code-serializer.h b/src/snapshot/code-serializer.h index 67b90cd960..c2c34b6ec6 100644 --- a/src/snapshot/code-serializer.h +++ b/src/snapshot/code-serializer.h @@ -85,25 +85,6 @@ class CodeSerializer : public Serializer<> { DISALLOW_COPY_AND_ASSIGN(CodeSerializer); }; -class WasmCompiledModuleSerializer : public CodeSerializer { - public: - static std::unique_ptr SerializeWasmModule( - Isolate* isolate, Handle compiled_module); - static MaybeHandle DeserializeWasmModule( - Isolate* isolate, ScriptData* data, Vector wire_bytes); - - protected: - void SerializeCodeObject(Code* code_object, HowToCode how_to_code, - WhereToPoint where_to_point) override; - bool ElideObject(Object* obj) override; - - private: - WasmCompiledModuleSerializer(Isolate* isolate, uint32_t source_hash, - Handle native_context, - Handle module_bytes); - DISALLOW_COPY_AND_ASSIGN(WasmCompiledModuleSerializer); -}; - // Wrapper around ScriptData to provide code-serializer-specific functionality. class SerializedCodeData : public SerializedData { public: