diff options
Diffstat (limited to 'deps/v8/src/wasm/module-compiler.h')
-rw-r--r-- | deps/v8/src/wasm/module-compiler.h | 82 |
1 files changed, 39 insertions, 43 deletions
diff --git a/deps/v8/src/wasm/module-compiler.h b/deps/v8/src/wasm/module-compiler.h index f108a5f939..7f860ac036 100644 --- a/deps/v8/src/wasm/module-compiler.h +++ b/deps/v8/src/wasm/module-compiler.h @@ -11,6 +11,7 @@ #include "src/cancelable-task.h" #include "src/globals.h" +#include "src/wasm/compilation-environment.h" #include "src/wasm/wasm-features.h" #include "src/wasm/wasm-module.h" @@ -28,39 +29,27 @@ class Vector; namespace wasm { +struct CompilationEnv; class CompilationResultResolver; -class CompilationState; class ErrorThrower; class ModuleCompiler; class NativeModule; class WasmCode; -struct ModuleEnv; struct WasmModule; -struct CompilationStateDeleter { - void operator()(CompilationState* compilation_state) const; -}; - -// Wrapper to create a CompilationState exists in order to avoid having -// the CompilationState in the header file. -std::unique_ptr<CompilationState, CompilationStateDeleter> NewCompilationState( - Isolate* isolate, const ModuleEnv& env); - -ModuleEnv* GetModuleEnv(CompilationState* compilation_state); - -MaybeHandle<WasmModuleObject> CompileToModuleObject( +std::unique_ptr<NativeModule> CompileToNativeModule( Isolate* isolate, const WasmFeatures& enabled, ErrorThrower* thrower, std::shared_ptr<const WasmModule> module, const ModuleWireBytes& wire_bytes, - Handle<Script> asm_js_script, Vector<const byte> asm_js_offset_table_bytes); + Handle<FixedArray>* export_wrappers_out); -MaybeHandle<WasmInstanceObject> InstantiateToInstanceObject( - Isolate* isolate, ErrorThrower* thrower, - Handle<WasmModuleObject> module_object, MaybeHandle<JSReceiver> imports, - MaybeHandle<JSArrayBuffer> memory); +void CompileNativeModuleWithExplicitBoundsChecks(Isolate* isolate, + ErrorThrower* thrower, + const WasmModule* wasm_module, + NativeModule* native_module); V8_EXPORT_PRIVATE -void CompileJsToWasmWrappers(Isolate* isolate, - Handle<WasmModuleObject> module_object); +void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module, + Handle<FixedArray> export_wrappers); V8_EXPORT_PRIVATE Handle<Script> CreateWasmScript( Isolate* isolate, const ModuleWireBytes& wire_bytes, @@ -97,19 +86,25 @@ class AsyncCompileJob { private: class CompileTask; class CompileStep; + class CompilationStateCallback; // States of the AsyncCompileJob. class DecodeModule; // Step 1 (async) class DecodeFail; // Step 1b (sync) class PrepareAndStartCompile; // Step 2 (sync) class CompileFailed; // Step 4b (sync) - class CompileWrappers; // Step 5 (sync) - class FinishModule; // Step 6 (sync) - const std::shared_ptr<Counters>& async_counters() const { - return async_counters_; + friend class AsyncStreamingProcessor; + + // Decrements the number of outstanding finishers. The last caller of this + // function should finish the asynchronous compilation, see the comment on + // {outstanding_finishers_}. + V8_WARN_UNUSED_RESULT bool DecrementAndCheckFinisherCount() { + return outstanding_finishers_.fetch_sub(1) == 1; } - Counters* counters() const { return async_counters().get(); } + + void CreateNativeModule(std::shared_ptr<const WasmModule> module); + void PrepareRuntimeObjects(); void FinishCompile(); @@ -117,14 +112,26 @@ class AsyncCompileJob { void AsyncCompileSucceeded(Handle<WasmModuleObject> result); + void CompileWrappers(); + + void FinishModule(); + void StartForegroundTask(); void ExecuteForegroundTaskImmediately(); void StartBackgroundTask(); + enum UseExistingForegroundTask : bool { + kUseExistingForegroundTask = true, + kAssertNoExistingForegroundTask = false + }; // Switches to the compilation step {Step} and starts a foreground task to - // execute it. - template <typename Step, typename... Args> + // execute it. Most of the time we know that there cannot be a running + // foreground task. If there might be one, then pass + // kUseExistingForegroundTask to avoid spawning a second one. + template <typename Step, + UseExistingForegroundTask = kAssertNoExistingForegroundTask, + typename... Args> void DoSync(Args&&... args); // Switches to the compilation step {Step} and immediately executes that step. @@ -141,11 +148,8 @@ class AsyncCompileJob { template <typename Step, typename... Args> void NextStep(Args&&... args); - friend class AsyncStreamingProcessor; - - Isolate* isolate_; + Isolate* const isolate_; const WasmFeatures enabled_features_; - const std::shared_ptr<Counters> async_counters_; // Copy of the module wire bytes, moved into the {native_module_} on its // creation. std::unique_ptr<byte[]> bytes_copy_; @@ -153,11 +157,11 @@ class AsyncCompileJob { // {native_module_}). ModuleWireBytes wire_bytes_; Handle<Context> native_context_; - std::shared_ptr<CompilationResultResolver> resolver_; + const std::shared_ptr<CompilationResultResolver> resolver_; std::vector<DeferredHandles*> deferred_handles_; Handle<WasmModuleObject> module_object_; - NativeModule* native_module_ = nullptr; + std::shared_ptr<NativeModule> native_module_; std::unique_ptr<CompileStep> step_; CancelableTaskManager background_task_manager_; @@ -169,13 +173,6 @@ class AsyncCompileJob { // compilation can be finished. std::atomic<int32_t> outstanding_finishers_{1}; - // Decrements the number of outstanding finishers. The last caller of this - // function should finish the asynchronous compilation, see the comment on - // {outstanding_finishers_}. - V8_WARN_UNUSED_RESULT bool DecrementAndCheckFinisherCount() { - return outstanding_finishers_.fetch_sub(1) == 1; - } - // A reference to a pending foreground task, or {nullptr} if none is pending. CompileTask* pending_foreground_task_ = nullptr; @@ -184,9 +181,8 @@ class AsyncCompileJob { // compilation. The AsyncCompileJob does not actively use the // StreamingDecoder. std::shared_ptr<StreamingDecoder> stream_; - - bool tiering_completed_ = false; }; + } // namespace wasm } // namespace internal } // namespace v8 |