diff options
Diffstat (limited to 'chromium/v8/src/wasm/function-compiler.h')
-rw-r--r-- | chromium/v8/src/wasm/function-compiler.h | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/chromium/v8/src/wasm/function-compiler.h b/chromium/v8/src/wasm/function-compiler.h index a270d36f788..7e19f4d12fa 100644 --- a/chromium/v8/src/wasm/function-compiler.h +++ b/chromium/v8/src/wasm/function-compiler.h @@ -6,10 +6,15 @@ #define V8_WASM_FUNCTION_COMPILER_H_ #include "src/wasm/function-body-decoder.h" +#include "src/wasm/wasm-limits.h" +#include "src/wasm/wasm-module.h" +#include "src/wasm/wasm-tier.h" namespace v8 { namespace internal { +class Counters; + namespace compiler { class TurbofanWasmCompilationUnit; } // namespace compiler @@ -30,6 +35,8 @@ enum RuntimeExceptionSupport : bool { enum UseTrapHandler : bool { kUseTrapHandler = true, kNoTrapHandler = false }; +enum LowerSimd : bool { kLowerSimd = true, kNoLowerSimd = false }; + // The {ModuleEnv} encapsulates the module data that is used during compilation. // ModuleEnvs are shareable across multiple compilations. struct ModuleEnv { @@ -45,40 +52,55 @@ struct ModuleEnv { // be generated differently. const RuntimeExceptionSupport runtime_exception_support; + // The smallest size of any memory that could be used with this module, in + // bytes. + const uint64_t min_memory_size; + + // The largest size of any memory that could be used with this module, in + // bytes. + const uint64_t max_memory_size; + + const LowerSimd lower_simd; + constexpr ModuleEnv(const WasmModule* module, UseTrapHandler use_trap_handler, - RuntimeExceptionSupport runtime_exception_support) + RuntimeExceptionSupport runtime_exception_support, + LowerSimd lower_simd = kNoLowerSimd) : module(module), use_trap_handler(use_trap_handler), - runtime_exception_support(runtime_exception_support) {} + runtime_exception_support(runtime_exception_support), + min_memory_size(module ? module->initial_pages * uint64_t{kWasmPageSize} + : 0), + max_memory_size(module && module->has_maximum_pages + ? (module->maximum_pages * uint64_t{kWasmPageSize}) + : kSpecMaxWasmMemoryBytes), + lower_simd(lower_simd) {} }; class WasmCompilationUnit final { public: - enum class CompilationMode : uint8_t { kLiftoff, kTurbofan }; - static CompilationMode GetDefaultCompilationMode(); + static ExecutionTier GetDefaultExecutionTier(); // If constructing from a background thread, pass in a Counters*, and ensure // that the Counters live at least as long as this compilation unit (which // typically means to hold a std::shared_ptr<Counters>). - // If no such pointer is passed, Isolate::counters() will be called. This is - // only allowed to happen on the foreground thread. - WasmCompilationUnit(Isolate*, ModuleEnv*, wasm::NativeModule*, - wasm::FunctionBody, wasm::WasmName, int index, - CompilationMode = GetDefaultCompilationMode(), - Counters* = nullptr, bool lower_simd = false); + // If used exclusively from a foreground thread, Isolate::counters() may be + // used by callers to pass Counters. + WasmCompilationUnit(WasmEngine* wasm_engine, ModuleEnv*, NativeModule*, + FunctionBody, WasmName, int index, Counters*, + ExecutionTier = GetDefaultExecutionTier()); ~WasmCompilationUnit(); - void ExecuteCompilation(); - wasm::WasmCode* FinishCompilation(wasm::ErrorThrower* thrower); + void ExecuteCompilation(WasmFeatures* detected); + WasmCode* FinishCompilation(ErrorThrower* thrower); - static wasm::WasmCode* CompileWasmFunction( - wasm::NativeModule* native_module, wasm::ErrorThrower* thrower, - Isolate* isolate, ModuleEnv* env, const wasm::WasmFunction* function, - CompilationMode = GetDefaultCompilationMode()); + static WasmCode* CompileWasmFunction( + Isolate* isolate, NativeModule* native_module, WasmFeatures* detected, + ErrorThrower* thrower, ModuleEnv* env, const WasmFunction* function, + ExecutionTier = GetDefaultExecutionTier()); - wasm::NativeModule* native_module() const { return native_module_; } - CompilationMode mode() const { return mode_; } + NativeModule* native_module() const { return native_module_; } + ExecutionTier mode() const { return mode_; } private: friend class LiftoffCompilationUnit; @@ -86,20 +108,18 @@ class WasmCompilationUnit final { ModuleEnv* env_; WasmEngine* wasm_engine_; - wasm::FunctionBody func_body_; - wasm::WasmName func_name_; + FunctionBody func_body_; + WasmName func_name_; Counters* counters_; int func_index_; - wasm::NativeModule* native_module_; - // TODO(wasm): Put {lower_simd_} inside the {ModuleEnv}. - bool lower_simd_; - CompilationMode mode_; + NativeModule* native_module_; + ExecutionTier mode_; // LiftoffCompilationUnit, set if {mode_ == kLiftoff}. std::unique_ptr<LiftoffCompilationUnit> liftoff_unit_; // TurbofanWasmCompilationUnit, set if {mode_ == kTurbofan}. std::unique_ptr<compiler::TurbofanWasmCompilationUnit> turbofan_unit_; - void SwitchMode(CompilationMode new_mode); + void SwitchMode(ExecutionTier new_mode); DISALLOW_COPY_AND_ASSIGN(WasmCompilationUnit); }; |