Commit faccc95b authored by Z Nguyen-Huu's avatar Z Nguyen-Huu Committed by Commit Bot

Reland "[wasm] Perform NativeModule tier down in parallel."

This is a reland of 3352fcc9

Disable stress-opt for test and check recompilation before clearing
callbacks.

Original change's description:
> [wasm] Perform NativeModule tier down in parallel.
>
> Reuse logic in {CompileNativeModule} function in module-compiler.cc:
> initialize parallel compile jobs, then wait for them to finish while
> taking part in this compilation.
>
> Bug: v8:9654
> Change-Id: I9974d9f8b516e9faec716a592c7c0ee9c7077d8e
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1977041
> Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#65763}

Bug: v8:9654
Change-Id: I8e8830f05e189596207365b7332a2cc25e493e47
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002945
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65901}
parent 87f09404
...@@ -92,7 +92,8 @@ class WireBytesStorage { ...@@ -92,7 +92,8 @@ class WireBytesStorage {
enum class CompilationEvent : uint8_t { enum class CompilationEvent : uint8_t {
kFinishedBaselineCompilation, kFinishedBaselineCompilation,
kFinishedTopTierCompilation, kFinishedTopTierCompilation,
kFailedCompilation kFailedCompilation,
kFinishedRecompilation
}; };
// The implementation of {CompilationState} lives in module-compiler.cc. // The implementation of {CompilationState} lives in module-compiler.cc.
...@@ -117,6 +118,7 @@ class CompilationState { ...@@ -117,6 +118,7 @@ class CompilationState {
bool failed() const; bool failed() const;
V8_EXPORT_PRIVATE bool baseline_compilation_finished() const; V8_EXPORT_PRIVATE bool baseline_compilation_finished() const;
V8_EXPORT_PRIVATE bool top_tier_compilation_finished() const; V8_EXPORT_PRIVATE bool top_tier_compilation_finished() const;
V8_EXPORT_PRIVATE bool recompilation_finished() const;
// Override {operator delete} to avoid implicit instantiation of {operator // Override {operator delete} to avoid implicit instantiation of {operator
// delete} with {size_t} argument. The {size_t} argument would be incorrect. // delete} with {size_t} argument. The {size_t} argument would be incorrect.
......
This diff is collapsed.
...@@ -44,6 +44,9 @@ std::shared_ptr<NativeModule> CompileToNativeModule( ...@@ -44,6 +44,9 @@ std::shared_ptr<NativeModule> CompileToNativeModule(
std::shared_ptr<const WasmModule> module, const ModuleWireBytes& wire_bytes, std::shared_ptr<const WasmModule> module, const ModuleWireBytes& wire_bytes,
Handle<FixedArray>* export_wrappers_out); Handle<FixedArray>* export_wrappers_out);
void RecompileNativeModule(Isolate* isolate, NativeModule* native_module,
ExecutionTier tier);
V8_EXPORT_PRIVATE V8_EXPORT_PRIVATE
void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module, void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
Handle<FixedArray>* export_wrappers_out); Handle<FixedArray>* export_wrappers_out);
......
...@@ -1818,13 +1818,8 @@ void NativeModule::TierDown(Isolate* isolate) { ...@@ -1818,13 +1818,8 @@ void NativeModule::TierDown(Isolate* isolate) {
tier_down_ = true; tier_down_ = true;
} }
// Tier down all functions. // Tier down all functions.
// TODO(duongn): parallelize this eventually. isolate->wasm_engine()->RecompileAllFunctions(isolate, this,
for (uint32_t index = module_->num_imported_functions;
index < num_functions(); index++) {
isolate->wasm_engine()->CompileFunction(isolate, this, index,
ExecutionTier::kLiftoff); ExecutionTier::kLiftoff);
DCHECK(!compilation_state()->failed());
}
} }
void NativeModule::TierUp(Isolate* isolate) { void NativeModule::TierUp(Isolate* isolate) {
......
...@@ -488,6 +488,12 @@ void WasmEngine::CompileFunction(Isolate* isolate, NativeModule* native_module, ...@@ -488,6 +488,12 @@ void WasmEngine::CompileFunction(Isolate* isolate, NativeModule* native_module,
&native_module->module()->functions[function_index], tier); &native_module->module()->functions[function_index], tier);
} }
void WasmEngine::RecompileAllFunctions(Isolate* isolate,
NativeModule* native_module,
ExecutionTier tier) {
RecompileNativeModule(isolate, native_module, tier);
}
std::shared_ptr<NativeModule> WasmEngine::ExportNativeModule( std::shared_ptr<NativeModule> WasmEngine::ExportNativeModule(
Handle<WasmModuleObject> module_object) { Handle<WasmModuleObject> module_object) {
return module_object->shared_native_module(); return module_object->shared_native_module();
......
...@@ -148,6 +148,10 @@ class V8_EXPORT_PRIVATE WasmEngine { ...@@ -148,6 +148,10 @@ class V8_EXPORT_PRIVATE WasmEngine {
void CompileFunction(Isolate* isolate, NativeModule* native_module, void CompileFunction(Isolate* isolate, NativeModule* native_module,
uint32_t function_index, ExecutionTier tier); uint32_t function_index, ExecutionTier tier);
// Recompiles all functions at a specific compilation tier.
void RecompileAllFunctions(Isolate* isolate, NativeModule* native_module,
ExecutionTier tier);
// Exports the sharable parts of the given module object so that they can be // Exports the sharable parts of the given module object so that they can be
// transferred to a different Context/Isolate using the same engine. // transferred to a different Context/Isolate using the same engine.
std::shared_ptr<NativeModule> ExportNativeModule( std::shared_ptr<NativeModule> ExportNativeModule(
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --allow-natives-syntax --wasm-tier-up // Flags: --allow-natives-syntax --liftoff --wasm-tier-up --no-stress-opt
load('test/mjsunit/wasm/wasm-module-builder.js'); load('test/mjsunit/wasm/wasm-module-builder.js');
...@@ -41,7 +41,6 @@ function check(instance) { ...@@ -41,7 +41,6 @@ function check(instance) {
check(instance); check(instance);
})(); })();
async function testTierDownToLiftoffAsync() { async function testTierDownToLiftoffAsync() {
print(arguments.callee.name); print(arguments.callee.name);
const instance = await create_builder().asyncInstantiate(); const instance = await create_builder().asyncInstantiate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment