[wasm] Construct {WasmCompilationUnit} without Isolate.

R=clemensh@chromium.org

Change-Id: Ib4f84d9b0bb2c54d5e1743c34b4034b14cb1152a
Reviewed-on: https://chromium-review.googlesource.com/1143188
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54560}
This commit is contained in:
Michael Starzinger 2018-07-19 11:42:56 +02:00 committed by Commit Bot
parent efbb3d8d10
commit d67e25e5e6
4 changed files with 24 additions and 23 deletions

View File

@ -33,17 +33,15 @@ WasmCompilationUnit::GetDefaultCompilationMode() {
return FLAG_liftoff ? CompilationMode::kLiftoff : CompilationMode::kTurbofan;
}
WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate, ModuleEnv* env,
wasm::NativeModule* native_module,
wasm::FunctionBody body,
wasm::WasmName name, int index,
CompilationMode mode,
Counters* counters, bool lower_simd)
WasmCompilationUnit::WasmCompilationUnit(
WasmEngine* wasm_engine, ModuleEnv* env, wasm::NativeModule* native_module,
wasm::FunctionBody body, wasm::WasmName name, int index, Counters* counters,
CompilationMode mode, bool lower_simd)
: env_(env),
wasm_engine_(isolate->wasm_engine()),
wasm_engine_(wasm_engine),
func_body_(body),
func_name_(name),
counters_(counters ? counters : isolate->counters()),
counters_(counters),
func_index_(index),
native_module_(native_module),
lower_simd_(lower_simd),
@ -141,9 +139,10 @@ wasm::WasmCode* WasmCompilationUnit::CompileWasmFunction(
wire_bytes.start() + function->code.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),
function->func_index, mode);
function->func_index, isolate->counters(), mode);
unit.ExecuteCompilation();
return unit.FinishCompilation(thrower);
}

View File

@ -60,12 +60,12 @@ class WasmCompilationUnit final {
// 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,
// If used exclusively from a foreground thread, Isolate::counters() may be
// used by callers to pass Counters.
WasmCompilationUnit(WasmEngine* wasm_engine, ModuleEnv*, wasm::NativeModule*,
wasm::FunctionBody, wasm::WasmName, int index, Counters*,
CompilationMode = GetDefaultCompilationMode(),
Counters* = nullptr, bool lower_simd = false);
bool lower_simd = false);
~WasmCompilationUnit();

View File

@ -108,6 +108,7 @@ class CompilationState {
return baseline_compilation_finished_;
}
WasmEngine* wasm_engine() const { return wasm_engine_; }
CompileMode compile_mode() const { return compile_mode_; }
ModuleEnv* module_env() { return &module_env_; }
@ -357,8 +358,8 @@ wasm::WasmCode* LazyCompileFunction(Isolate* isolate,
module_start + func->code.end_offset()};
ErrorThrower thrower(isolate, "WasmLazyCompile");
WasmCompilationUnit unit(isolate, module_env, native_module, body, func_name,
func_index);
WasmCompilationUnit unit(isolate->wasm_engine(), module_env, native_module,
body, func_name, func_index, isolate->counters());
unit.ExecuteCompilation();
wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower);
@ -506,12 +507,12 @@ class CompilationUnitBuilder {
Vector<const uint8_t> bytes, WasmName name,
WasmCompilationUnit::CompilationMode mode) {
return base::make_unique<WasmCompilationUnit>(
compilation_state_->isolate(), compilation_state_->module_env(),
compilation_state_->wasm_engine(), compilation_state_->module_env(),
native_module_,
wasm::FunctionBody{function->sig, buffer_offset, bytes.begin(),
bytes.end()},
name, function->func_index, mode,
compilation_state_->isolate()->async_counters().get());
name, function->func_index,
compilation_state_->isolate()->async_counters().get(), mode);
}
NativeModule* native_module_;

View File

@ -422,9 +422,10 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
: WasmCompilationUnit::CompilationMode::kTurbofan;
NativeModule* native_module =
builder_->instance_object()->module_object()->native_module();
WasmCompilationUnit unit(isolate(), &module_env, native_module, func_body,
func_name, function_->func_index, comp_mode,
isolate()->counters(), builder_->lower_simd());
WasmCompilationUnit unit(isolate()->wasm_engine(), &module_env, native_module,
func_body, func_name, function_->func_index,
isolate()->counters(), comp_mode,
builder_->lower_simd());
unit.ExecuteCompilation();
wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower);
if (wasm::WasmCode::ShouldBeLogged(isolate())) {