// Copyright 2017 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_WASM_WASM_ENGINE_H_ #define V8_WASM_WASM_ENGINE_H_ #include #include #include "src/tasks/cancelable-task.h" #include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-memory.h" #include "src/wasm/wasm-tier.h" #include "src/zone/accounting-allocator.h" namespace v8 { namespace internal { class AsmWasmData; class CodeTracer; class CompilationStatistics; class HeapNumber; class WasmInstanceObject; class WasmModuleObject; namespace wasm { class AsyncCompileJob; class ErrorThrower; struct ModuleWireBytes; struct WasmFeatures; class V8_EXPORT_PRIVATE CompilationResultResolver { public: virtual void OnCompilationSucceeded(Handle result) = 0; virtual void OnCompilationFailed(Handle error_reason) = 0; virtual ~CompilationResultResolver() = default; }; class V8_EXPORT_PRIVATE InstantiationResultResolver { public: virtual void OnInstantiationSucceeded(Handle result) = 0; virtual void OnInstantiationFailed(Handle error_reason) = 0; virtual ~InstantiationResultResolver() = default; }; // The central data structure that represents an engine instance capable of // loading, instantiating, and executing WASM code. class V8_EXPORT_PRIVATE WasmEngine { public: WasmEngine(); ~WasmEngine(); // Synchronously validates the given bytes that represent an encoded WASM // module. bool SyncValidate(Isolate* isolate, const WasmFeatures& enabled, const ModuleWireBytes& bytes); // Synchronously compiles the given bytes that represent a translated // asm.js module. MaybeHandle SyncCompileTranslatedAsmJs( Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes, Vector asm_js_offset_table_bytes, Handle uses_bitset, LanguageMode language_mode); Handle FinalizeTranslatedAsmJs( Isolate* isolate, Handle asm_wasm_data, Handle