Commit ea2de39f authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Remove {InterpreterCompilationUnit}

{InterpreterCompilationUnit} does not store any data except for a
pointer back to the {WasmCompilationUnit}, and has a single method only.
Thus remove it, and replace it by a static function.
This saves one field per compilation unit. We can probably also remove
{TurbofanWasmCompilationUnit} in a similar way, which I will do in a
follow-up CL.

R=mstarzinger@chromium.org

Change-Id: I8fc2e18366757573499fd57f909ec8222c27be38
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1587387
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61083}
parent 99254554
...@@ -5534,7 +5534,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -5534,7 +5534,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
return true; return true;
} }
void BuildWasmInterpreterEntry(uint32_t func_index) { void BuildWasmInterpreterEntry(int func_index) {
int param_count = static_cast<int>(sig_->parameter_count()); int param_count = static_cast<int>(sig_->parameter_count());
// Build the start and the parameter nodes. // Build the start and the parameter nodes.
...@@ -6263,9 +6263,9 @@ wasm::WasmCompilationResult TurbofanWasmCompilationUnit::ExecuteCompilation( ...@@ -6263,9 +6263,9 @@ wasm::WasmCompilationResult TurbofanWasmCompilationUnit::ExecuteCompilation(
return std::move(*result); return std::move(*result);
} }
wasm::WasmCompilationResult InterpreterCompilationUnit::ExecuteCompilation( wasm::WasmCompilationResult ExecuteInterpreterEntryCompilation(
wasm::WasmEngine* wasm_engine, wasm::CompilationEnv* env, wasm::WasmEngine* wasm_engine, wasm::CompilationEnv* env,
const wasm::FunctionBody& func_body, Counters* counters, const wasm::FunctionBody& func_body, int func_index, Counters* counters,
wasm::WasmFeatures* detected) { wasm::WasmFeatures* detected) {
Zone zone(wasm_engine->allocator(), ZONE_NAME); Zone zone(wasm_engine->allocator(), ZONE_NAME);
const wasm::WasmModule* module = env ? env->module : nullptr; const wasm::WasmModule* module = env ? env->module : nullptr;
...@@ -6274,9 +6274,8 @@ wasm::WasmCompilationResult InterpreterCompilationUnit::ExecuteCompilation( ...@@ -6274,9 +6274,8 @@ wasm::WasmCompilationResult InterpreterCompilationUnit::ExecuteCompilation(
decoder.Decode(); decoder.Decode();
if (decoder.failed()) return wasm::WasmCompilationResult{}; if (decoder.failed()) return wasm::WasmCompilationResult{};
wasm::WasmCompilationResult result = wasm::WasmCompilationResult result = CompileWasmInterpreterEntry(
CompileWasmInterpreterEntry(wasm_engine, env->enabled_features, wasm_engine, env->enabled_features, func_index, func_body.sig);
wasm_unit_->func_index_, func_body.sig);
DCHECK(result.succeeded()); DCHECK(result.succeeded());
DCHECK_EQ(wasm::ExecutionTier::kInterpreter, result.result_tier); DCHECK_EQ(wasm::ExecutionTier::kInterpreter, result.result_tier);
......
...@@ -70,22 +70,9 @@ class TurbofanWasmCompilationUnit { ...@@ -70,22 +70,9 @@ class TurbofanWasmCompilationUnit {
DISALLOW_COPY_AND_ASSIGN(TurbofanWasmCompilationUnit); DISALLOW_COPY_AND_ASSIGN(TurbofanWasmCompilationUnit);
}; };
class InterpreterCompilationUnit final { wasm::WasmCompilationResult ExecuteInterpreterEntryCompilation(
public: wasm::WasmEngine*, wasm::CompilationEnv*, const wasm::FunctionBody&,
explicit InterpreterCompilationUnit(wasm::WasmCompilationUnit* wasm_unit) int func_index, Counters*, wasm::WasmFeatures* detected);
: wasm_unit_(wasm_unit) {}
wasm::WasmCompilationResult ExecuteCompilation(wasm::WasmEngine*,
wasm::CompilationEnv*,
const wasm::FunctionBody&,
Counters*,
wasm::WasmFeatures* detected);
private:
wasm::WasmCompilationUnit* const wasm_unit_;
DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationUnit);
};
// Calls to WASM imports are handled in several different ways, depending on the // Calls to WASM imports are handled in several different ways, depending on the
// type of the target function/callable and whether the signature matches the // type of the target function/callable and whether the signature matches the
......
...@@ -172,8 +172,8 @@ WasmCompilationResult WasmCompilationUnit::ExecuteCompilation( ...@@ -172,8 +172,8 @@ WasmCompilationResult WasmCompilationUnit::ExecuteCompilation(
break; break;
case ExecutionTier::kInterpreter: case ExecutionTier::kInterpreter:
result = interpreter_unit_->ExecuteCompilation( result = compiler::ExecuteInterpreterEntryCompilation(
wasm_engine, env, func_body, counters, detected); wasm_engine, env, func_body, func_index_, counters, detected);
break; break;
} }
...@@ -190,28 +190,12 @@ WasmCompilationResult WasmCompilationUnit::ExecuteCompilation( ...@@ -190,28 +190,12 @@ WasmCompilationResult WasmCompilationUnit::ExecuteCompilation(
} }
void WasmCompilationUnit::SwitchTier(ExecutionTier new_tier) { void WasmCompilationUnit::SwitchTier(ExecutionTier new_tier) {
// This method is being called in the constructor, where neither // This method is being called in the constructor, where {turbofan_unit_} is
// {turbofan_unit_} nor {interpreter_unit_} are set, or to switch tier from // not set, or to switch tier from kLiftoff to kTurbofan.
// kLiftoff to kTurbofan. DCHECK(!turbofan_unit_);
switch (new_tier) { if (new_tier == ExecutionTier::kTurbofan) {
case ExecutionTier::kLiftoff: turbofan_unit_.reset(new compiler::TurbofanWasmCompilationUnit(this));
DCHECK(!turbofan_unit_);
DCHECK(!interpreter_unit_);
return;
case ExecutionTier::kTurbofan:
DCHECK(!turbofan_unit_);
DCHECK(!interpreter_unit_);
turbofan_unit_.reset(new compiler::TurbofanWasmCompilationUnit(this));
return;
case ExecutionTier::kInterpreter:
DCHECK(!turbofan_unit_);
DCHECK(!interpreter_unit_);
interpreter_unit_.reset(new compiler::InterpreterCompilationUnit(this));
return;
case ExecutionTier::kNone:
UNREACHABLE();
} }
UNREACHABLE();
} }
// static // static
......
...@@ -20,7 +20,6 @@ class AssemblerBuffer; ...@@ -20,7 +20,6 @@ class AssemblerBuffer;
class Counters; class Counters;
namespace compiler { namespace compiler {
class InterpreterCompilationUnit;
class Pipeline; class Pipeline;
class TurbofanWasmCompilationUnit; class TurbofanWasmCompilationUnit;
} // namespace compiler } // namespace compiler
...@@ -85,15 +84,12 @@ class V8_EXPORT_PRIVATE WasmCompilationUnit final { ...@@ -85,15 +84,12 @@ class V8_EXPORT_PRIVATE WasmCompilationUnit final {
private: private:
friend class compiler::TurbofanWasmCompilationUnit; friend class compiler::TurbofanWasmCompilationUnit;
friend class compiler::InterpreterCompilationUnit;
const int func_index_; const int func_index_;
ExecutionTier tier_; ExecutionTier tier_;
// TurbofanWasmCompilationUnit, set if {tier_ == kTurbofan}. // TurbofanWasmCompilationUnit, set if {tier_ == kTurbofan}.
std::unique_ptr<compiler::TurbofanWasmCompilationUnit> turbofan_unit_; std::unique_ptr<compiler::TurbofanWasmCompilationUnit> turbofan_unit_;
// InterpreterCompilationUnit, set if {tier_ == kInterpreter}.
std::unique_ptr<compiler::InterpreterCompilationUnit> interpreter_unit_;
void SwitchTier(ExecutionTier new_tier); void SwitchTier(ExecutionTier new_tier);
......
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