5 #ifndef V8_WASM_MODULE_COMPILER_H_ 6 #define V8_WASM_MODULE_COMPILER_H_ 12 #include "src/cancelable-task.h" 13 #include "src/globals.h" 14 #include "src/wasm/compilation-environment.h" 15 #include "src/wasm/wasm-features.h" 16 #include "src/wasm/wasm-module.h" 24 class WasmModuleObject;
25 class WasmInstanceObject;
32 struct CompilationEnv;
33 class CompilationResultResolver;
40 std::unique_ptr<NativeModule> CompileToNativeModule(
41 Isolate* isolate,
const WasmFeatures& enabled, ErrorThrower* thrower,
42 std::shared_ptr<const WasmModule> module,
const ModuleWireBytes& wire_bytes,
43 Handle<FixedArray>* export_wrappers_out);
45 MaybeHandle<WasmInstanceObject> InstantiateToInstanceObject(
46 Isolate* isolate, ErrorThrower* thrower,
47 Handle<WasmModuleObject> module_object, MaybeHandle<JSReceiver> imports,
48 MaybeHandle<JSArrayBuffer> memory);
51 void CompileJsToWasmWrappers(Isolate* isolate, NativeModule* native_module,
52 Handle<FixedArray> export_wrappers);
54 V8_EXPORT_PRIVATE Handle<Script> CreateWasmScript(
55 Isolate* isolate,
const ModuleWireBytes& wire_bytes,
56 const std::string& source_map_url);
60 Address CompileLazy(Isolate*, NativeModule*,
uint32_t func_index);
72 std::unique_ptr<byte[]> bytes_copy,
size_t length,
74 std::shared_ptr<CompilationResultResolver> resolver);
79 std::shared_ptr<StreamingDecoder> CreateStreamingDecoder();
82 void CancelPendingForegroundTask();
84 Isolate* isolate()
const {
return isolate_; }
104 V8_WARN_UNUSED_RESULT
bool DecrementAndCheckFinisherCount() {
105 return outstanding_finishers_.fetch_sub(1) == 1;
108 void PrepareRuntimeObjects(std::shared_ptr<const WasmModule>);
110 void FinishCompile(
bool compile_wrappers);
116 void StartForegroundTask();
117 void ExecuteForegroundTaskImmediately();
119 void StartBackgroundTask();
121 enum UseExistingForegroundTask :
bool {
122 kUseExistingForegroundTask =
true,
123 kAssertNoExistingForegroundTask =
false 129 template <
typename Step,
130 UseExistingForegroundTask = kAssertNoExistingForegroundTask,
132 void DoSync(Args&&... args);
135 template <
typename Step,
typename... Args>
136 void DoImmediately(Args&&... args);
140 template <
typename Step,
typename... Args>
141 void DoAsync(Args&&... args);
145 template <
typename Step,
typename... Args>
146 void NextStep(Args&&... args);
152 std::unique_ptr<byte[]> bytes_copy_;
157 const std::shared_ptr<CompilationResultResolver> resolver_;
159 std::vector<DeferredHandles*> deferred_handles_;
163 std::unique_ptr<CompileStep> step_;
166 std::shared_ptr<v8::TaskRunner> foreground_task_runner_;
171 std::atomic<int32_t> outstanding_finishers_{1};
180 std::shared_ptr<StreamingDecoder> stream_;
187 #endif // V8_WASM_MODULE_COMPILER_H_