Commit d67e25e5 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Construct {WasmCompilationUnit} without Isolate.

R=clemensh@chromium.org

Change-Id: Ib4f84d9b0bb2c54d5e1743c34b4034b14cb1152a
Reviewed-on: https://chromium-review.googlesource.com/1143188Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54560}
parent efbb3d8d
...@@ -33,17 +33,15 @@ WasmCompilationUnit::GetDefaultCompilationMode() { ...@@ -33,17 +33,15 @@ WasmCompilationUnit::GetDefaultCompilationMode() {
return FLAG_liftoff ? CompilationMode::kLiftoff : CompilationMode::kTurbofan; return FLAG_liftoff ? CompilationMode::kLiftoff : CompilationMode::kTurbofan;
} }
WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate, ModuleEnv* env, WasmCompilationUnit::WasmCompilationUnit(
wasm::NativeModule* native_module, WasmEngine* wasm_engine, ModuleEnv* env, wasm::NativeModule* native_module,
wasm::FunctionBody body, wasm::FunctionBody body, wasm::WasmName name, int index, Counters* counters,
wasm::WasmName name, int index, CompilationMode mode, bool lower_simd)
CompilationMode mode,
Counters* counters, bool lower_simd)
: env_(env), : env_(env),
wasm_engine_(isolate->wasm_engine()), wasm_engine_(wasm_engine),
func_body_(body), func_body_(body),
func_name_(name), func_name_(name),
counters_(counters ? counters : isolate->counters()), counters_(counters),
func_index_(index), func_index_(index),
native_module_(native_module), native_module_(native_module),
lower_simd_(lower_simd), lower_simd_(lower_simd),
...@@ -141,9 +139,10 @@ wasm::WasmCode* WasmCompilationUnit::CompileWasmFunction( ...@@ -141,9 +139,10 @@ wasm::WasmCode* WasmCompilationUnit::CompileWasmFunction(
wire_bytes.start() + function->code.offset(), wire_bytes.start() + function->code.offset(),
wire_bytes.start() + function->code.end_offset()}; wire_bytes.start() + function->code.end_offset()};
WasmCompilationUnit unit(isolate, env, native_module, function_body, WasmCompilationUnit unit(isolate->wasm_engine(), env, native_module,
function_body,
wire_bytes.GetNameOrNull(function, env->module), wire_bytes.GetNameOrNull(function, env->module),
function->func_index, mode); function->func_index, isolate->counters(), mode);
unit.ExecuteCompilation(); unit.ExecuteCompilation();
return unit.FinishCompilation(thrower); return unit.FinishCompilation(thrower);
} }
......
...@@ -60,12 +60,12 @@ class WasmCompilationUnit final { ...@@ -60,12 +60,12 @@ class WasmCompilationUnit final {
// If constructing from a background thread, pass in a Counters*, and ensure // 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 // that the Counters live at least as long as this compilation unit (which
// typically means to hold a std::shared_ptr<Counters>). // typically means to hold a std::shared_ptr<Counters>).
// If no such pointer is passed, Isolate::counters() will be called. This is // If used exclusively from a foreground thread, Isolate::counters() may be
// only allowed to happen on the foreground thread. // used by callers to pass Counters.
WasmCompilationUnit(Isolate*, ModuleEnv*, wasm::NativeModule*, WasmCompilationUnit(WasmEngine* wasm_engine, ModuleEnv*, wasm::NativeModule*,
wasm::FunctionBody, wasm::WasmName, int index, wasm::FunctionBody, wasm::WasmName, int index, Counters*,
CompilationMode = GetDefaultCompilationMode(), CompilationMode = GetDefaultCompilationMode(),
Counters* = nullptr, bool lower_simd = false); bool lower_simd = false);
~WasmCompilationUnit(); ~WasmCompilationUnit();
......
...@@ -108,6 +108,7 @@ class CompilationState { ...@@ -108,6 +108,7 @@ class CompilationState {
return baseline_compilation_finished_; return baseline_compilation_finished_;
} }
WasmEngine* wasm_engine() const { return wasm_engine_; }
CompileMode compile_mode() const { return compile_mode_; } CompileMode compile_mode() const { return compile_mode_; }
ModuleEnv* module_env() { return &module_env_; } ModuleEnv* module_env() { return &module_env_; }
...@@ -357,8 +358,8 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate, ...@@ -357,8 +358,8 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate,
module_start + func->code.end_offset()}; module_start + func->code.end_offset()};
ErrorThrower thrower(isolate, "WasmLazyCompile"); ErrorThrower thrower(isolate, "WasmLazyCompile");
WasmCompilationUnit unit(isolate, module_env, native_module, body, func_name, WasmCompilationUnit unit(isolate->wasm_engine(), module_env, native_module,
func_index); body, func_name, func_index, isolate->counters());
unit.ExecuteCompilation(); unit.ExecuteCompilation();
wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower); wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower);
...@@ -506,12 +507,12 @@ class CompilationUnitBuilder { ...@@ -506,12 +507,12 @@ class CompilationUnitBuilder {
Vector<const uint8_t> bytes, WasmName name, Vector<const uint8_t> bytes, WasmName name,
WasmCompilationUnit::CompilationMode mode) { WasmCompilationUnit::CompilationMode mode) {
return base::make_unique<WasmCompilationUnit>( return base::make_unique<WasmCompilationUnit>(
compilation_state_->isolate(), compilation_state_->module_env(), compilation_state_->wasm_engine(), compilation_state_->module_env(),
native_module_, native_module_,
wasm::FunctionBody{function->sig, buffer_offset, bytes.begin(), wasm::FunctionBody{function->sig, buffer_offset, bytes.begin(),
bytes.end()}, bytes.end()},
name, function->func_index, mode, name, function->func_index,
compilation_state_->isolate()->async_counters().get()); compilation_state_->isolate()->async_counters().get(), mode);
} }
NativeModule* native_module_; NativeModule* native_module_;
......
...@@ -422,9 +422,10 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) { ...@@ -422,9 +422,10 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
: WasmCompilationUnit::CompilationMode::kTurbofan; : WasmCompilationUnit::CompilationMode::kTurbofan;
NativeModule* native_module = NativeModule* native_module =
builder_->instance_object()->module_object()->native_module(); builder_->instance_object()->module_object()->native_module();
WasmCompilationUnit unit(isolate(), &module_env, native_module, func_body, WasmCompilationUnit unit(isolate()->wasm_engine(), &module_env, native_module,
func_name, function_->func_index, comp_mode, func_body, func_name, function_->func_index,
isolate()->counters(), builder_->lower_simd()); isolate()->counters(), comp_mode,
builder_->lower_simd());
unit.ExecuteCompilation(); unit.ExecuteCompilation();
wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower); wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower);
if (wasm::WasmCode::ShouldBeLogged(isolate())) { if (wasm::WasmCode::ShouldBeLogged(isolate())) {
......
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