[wasm] Pass and store fewer wasm engine pointers

There is exactly one WasmEngine per process, hence we do not need to
store or pass a pointer to it. We just use {GetWasmEngine} (which just
reads a global variable) whenever we need it.

R=jkummerow@chromium.org

Bug: v8:11879
Change-Id: I7e0e86e326f4cafe5a894af0ff6d35803c0340a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2972725
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75266}
This commit is contained in:
Clemens Backes 2021-06-21 13:20:13 +02:00 committed by V8 LUCI CQ
parent fa3cd68a3f
commit 089221ef96
18 changed files with 169 additions and 210 deletions

View File

@ -1037,9 +1037,8 @@ PipelineStatistics* CreatePipelineStatistics(Handle<Script> script,
#if V8_ENABLE_WEBASSEMBLY
PipelineStatistics* CreatePipelineStatistics(
wasm::WasmEngine* wasm_engine, wasm::FunctionBody function_body,
const wasm::WasmModule* wasm_module, OptimizedCompilationInfo* info,
ZoneStats* zone_stats) {
wasm::FunctionBody function_body, const wasm::WasmModule* wasm_module,
OptimizedCompilationInfo* info, ZoneStats* zone_stats) {
PipelineStatistics* pipeline_statistics = nullptr;
bool tracing_enabled;
@ -1047,7 +1046,7 @@ PipelineStatistics* CreatePipelineStatistics(
TRACE_DISABLED_BY_DEFAULT("v8.wasm.turbofan"), &tracing_enabled);
if (tracing_enabled || FLAG_turbo_stats_wasm) {
pipeline_statistics = new PipelineStatistics(
info, wasm_engine->GetOrCreateTurboStatistics(), zone_stats);
info, wasm::GetWasmEngine()->GetOrCreateTurboStatistics(), zone_stats);
pipeline_statistics->BeginPhaseKind("V8.WasmInitializing");
}
@ -2549,8 +2548,7 @@ struct VerifyGraphPhase {
#if V8_ENABLE_WEBASSEMBLY
class WasmHeapStubCompilationJob final : public OptimizedCompilationJob {
public:
WasmHeapStubCompilationJob(Isolate* isolate, wasm::WasmEngine* wasm_engine,
CallDescriptor* call_descriptor,
WasmHeapStubCompilationJob(Isolate* isolate, CallDescriptor* call_descriptor,
std::unique_ptr<Zone> zone, Graph* graph,
CodeKind kind, std::unique_ptr<char[]> debug_name,
const AssemblerOptions& options,
@ -2566,11 +2564,10 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob {
zone_stats_(zone->allocator()),
zone_(std::move(zone)),
graph_(graph),
data_(&zone_stats_, &info_, isolate, wasm_engine->allocator(), graph_,
nullptr, nullptr, source_positions,
data_(&zone_stats_, &info_, isolate, wasm::GetWasmEngine()->allocator(),
graph_, nullptr, nullptr, source_positions,
zone_->New<NodeOriginTable>(graph_), nullptr, options, nullptr),
pipeline_(&data_),
wasm_engine_(wasm_engine) {}
pipeline_(&data_) {}
WasmHeapStubCompilationJob(const WasmHeapStubCompilationJob&) = delete;
WasmHeapStubCompilationJob& operator=(const WasmHeapStubCompilationJob&) =
@ -2591,18 +2588,19 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob {
Graph* graph_;
PipelineData data_;
PipelineImpl pipeline_;
wasm::WasmEngine* wasm_engine_;
};
// static
std::unique_ptr<OptimizedCompilationJob>
Pipeline::NewWasmHeapStubCompilationJob(
Isolate* isolate, wasm::WasmEngine* wasm_engine,
CallDescriptor* call_descriptor, std::unique_ptr<Zone> zone, Graph* graph,
CodeKind kind, std::unique_ptr<char[]> debug_name,
const AssemblerOptions& options, SourcePositionTable* source_positions) {
Pipeline::NewWasmHeapStubCompilationJob(Isolate* isolate,
CallDescriptor* call_descriptor,
std::unique_ptr<Zone> zone,
Graph* graph, CodeKind kind,
std::unique_ptr<char[]> debug_name,
const AssemblerOptions& options,
SourcePositionTable* source_positions) {
return std::make_unique<WasmHeapStubCompilationJob>(
isolate, wasm_engine, call_descriptor, std::move(zone), graph, kind,
isolate, call_descriptor, std::move(zone), graph, kind,
std::move(debug_name), options, source_positions);
}
@ -2616,7 +2614,8 @@ CompilationJob::Status WasmHeapStubCompilationJob::ExecuteJobImpl(
std::unique_ptr<PipelineStatistics> pipeline_statistics;
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.reset(new PipelineStatistics(
&info_, wasm_engine_->GetOrCreateTurboStatistics(), &zone_stats_));
&info_, wasm::GetWasmEngine()->GetOrCreateTurboStatistics(),
&zone_stats_));
pipeline_statistics->BeginPhaseKind("V8.WasmStubCodegen");
}
if (info_.trace_turbo_json() || info_.trace_turbo_graph()) {
@ -3138,13 +3137,14 @@ std::ostream& operator<<(std::ostream& out, const BlockStartsAsJSON& s) {
#if V8_ENABLE_WEBASSEMBLY
// static
wasm::WasmCompilationResult Pipeline::GenerateCodeForWasmNativeStub(
wasm::WasmEngine* wasm_engine, CallDescriptor* call_descriptor,
MachineGraph* mcgraph, CodeKind kind, int wasm_kind, const char* debug_name,
const AssemblerOptions& options, SourcePositionTable* source_positions) {
CallDescriptor* call_descriptor, MachineGraph* mcgraph, CodeKind kind,
int wasm_kind, const char* debug_name, const AssemblerOptions& options,
SourcePositionTable* source_positions) {
Graph* graph = mcgraph->graph();
OptimizedCompilationInfo info(base::CStrVector(debug_name), graph->zone(),
kind);
// Construct a pipeline for scheduling and code generation.
wasm::WasmEngine* wasm_engine = wasm::GetWasmEngine();
ZoneStats zone_stats(wasm_engine->allocator());
NodeOriginTable* node_positions = graph->zone()->New<NodeOriginTable>(graph);
// {instruction_buffer} must live longer than {PipelineData}, since
@ -3241,15 +3241,15 @@ wasm::WasmCompilationResult Pipeline::GenerateCodeForWasmNativeStub(
// static
void Pipeline::GenerateCodeForWasmFunction(
OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
MachineGraph* mcgraph, CallDescriptor* call_descriptor,
SourcePositionTable* source_positions, NodeOriginTable* node_origins,
wasm::FunctionBody function_body, const wasm::WasmModule* module,
int function_index, std::vector<compiler::WasmLoopInfo>* loop_info) {
OptimizedCompilationInfo* info, MachineGraph* mcgraph,
CallDescriptor* call_descriptor, SourcePositionTable* source_positions,
NodeOriginTable* node_origins, wasm::FunctionBody function_body,
const wasm::WasmModule* module, int function_index,
std::vector<compiler::WasmLoopInfo>* loop_info) {
auto* wasm_engine = wasm::GetWasmEngine();
ZoneStats zone_stats(wasm_engine->allocator());
std::unique_ptr<PipelineStatistics> pipeline_statistics(
CreatePipelineStatistics(wasm_engine, function_body, module, info,
&zone_stats));
CreatePipelineStatistics(function_body, module, info, &zone_stats));
// {instruction_buffer} must live longer than {PipelineData}, since
// {PipelineData} will reference the {instruction_buffer} via the
// {AssemblerBuffer} of the {Assembler} contained in the {CodeGenerator}.

View File

@ -54,25 +54,24 @@ class Pipeline : public AllStatic {
// Run the pipeline for the WebAssembly compilation info.
static void GenerateCodeForWasmFunction(
OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
MachineGraph* mcgraph, CallDescriptor* call_descriptor,
SourcePositionTable* source_positions, NodeOriginTable* node_origins,
wasm::FunctionBody function_body, const wasm::WasmModule* module,
int function_index, std::vector<compiler::WasmLoopInfo>* loop_infos);
OptimizedCompilationInfo* info, MachineGraph* mcgraph,
CallDescriptor* call_descriptor, SourcePositionTable* source_positions,
NodeOriginTable* node_origins, wasm::FunctionBody function_body,
const wasm::WasmModule* module, int function_index,
std::vector<compiler::WasmLoopInfo>* loop_infos);
// Run the pipeline on a machine graph and generate code.
static wasm::WasmCompilationResult GenerateCodeForWasmNativeStub(
wasm::WasmEngine* wasm_engine, CallDescriptor* call_descriptor,
MachineGraph* mcgraph, CodeKind kind, int wasm_kind,
const char* debug_name, const AssemblerOptions& assembler_options,
CallDescriptor* call_descriptor, MachineGraph* mcgraph, CodeKind kind,
int wasm_kind, const char* debug_name,
const AssemblerOptions& assembler_options,
SourcePositionTable* source_positions = nullptr);
// Returns a new compilation job for a wasm heap stub.
static std::unique_ptr<OptimizedCompilationJob> NewWasmHeapStubCompilationJob(
Isolate* isolate, wasm::WasmEngine* wasm_engine,
CallDescriptor* call_descriptor, std::unique_ptr<Zone> zone, Graph* graph,
CodeKind kind, std::unique_ptr<char[]> debug_name,
const AssemblerOptions& options,
Isolate* isolate, CallDescriptor* call_descriptor,
std::unique_ptr<Zone> zone, Graph* graph, CodeKind kind,
std::unique_ptr<char[]> debug_name, const AssemblerOptions& options,
SourcePositionTable* source_positions = nullptr);
// Run the pipeline on a machine graph and generate code.

View File

@ -7287,14 +7287,14 @@ void BuildInlinedJSToWasmWrapper(
}
std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
Isolate* isolate, wasm::WasmEngine* wasm_engine,
const wasm::FunctionSig* sig, const wasm::WasmModule* module,
bool is_import, const wasm::WasmFeatures& enabled_features) {
Isolate* isolate, const wasm::FunctionSig* sig,
const wasm::WasmModule* module, bool is_import,
const wasm::WasmFeatures& enabled_features) {
//----------------------------------------------------------------------------
// Create the Graph.
//----------------------------------------------------------------------------
std::unique_ptr<Zone> zone = std::make_unique<Zone>(
wasm_engine->allocator(), ZONE_NAME, kCompressGraphZone);
wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
Graph* graph = zone->New<Graph>(zone.get());
CommonOperatorBuilder* common = zone->New<CommonOperatorBuilder>(zone.get());
MachineOperatorBuilder* machine = zone->New<MachineOperatorBuilder>(
@ -7318,9 +7318,8 @@ std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
zone.get(), false, params + 1, CallDescriptor::kNoFlags);
return Pipeline::NewWasmHeapStubCompilationJob(
isolate, wasm_engine, incoming, std::move(zone), graph,
CodeKind::JS_TO_WASM_FUNCTION, std::move(debug_name),
WasmAssemblerOptions());
isolate, incoming, std::move(zone), graph, CodeKind::JS_TO_WASM_FUNCTION,
std::move(debug_name), WasmAssemblerOptions());
}
std::pair<WasmImportCallKind, Handle<JSReceiver>> ResolveWasmImportCall(
@ -7487,14 +7486,13 @@ wasm::WasmOpcode GetMathIntrinsicOpcode(WasmImportCallKind kind,
}
wasm::WasmCompilationResult CompileWasmMathIntrinsic(
wasm::WasmEngine* wasm_engine, WasmImportCallKind kind,
const wasm::FunctionSig* sig) {
WasmImportCallKind kind, const wasm::FunctionSig* sig) {
DCHECK_EQ(1, sig->return_count());
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileWasmMathIntrinsic");
Zone zone(wasm_engine->allocator(), ZONE_NAME, kCompressGraphZone);
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
// Compile a Wasm function with a single bytecode and let TurboFan
// generate either inlined machine code or a call to a helper.
@ -7541,7 +7539,7 @@ wasm::WasmCompilationResult CompileWasmMathIntrinsic(
}
wasm::WasmCompilationResult result = Pipeline::GenerateCodeForWasmNativeStub(
wasm_engine, call_descriptor, mcgraph, CodeKind::WASM_FUNCTION,
call_descriptor, mcgraph, CodeKind::WASM_FUNCTION,
wasm::WasmCode::kFunction, debug_name, WasmStubAssemblerOptions(),
source_positions);
return result;
@ -7550,9 +7548,8 @@ wasm::WasmCompilationResult CompileWasmMathIntrinsic(
} // namespace
wasm::WasmCompilationResult CompileWasmImportCallWrapper(
wasm::WasmEngine* wasm_engine, wasm::CompilationEnv* env,
WasmImportCallKind kind, const wasm::FunctionSig* sig,
bool source_positions, int expected_arity) {
wasm::CompilationEnv* env, WasmImportCallKind kind,
const wasm::FunctionSig* sig, bool source_positions, int expected_arity) {
DCHECK_NE(WasmImportCallKind::kLinkError, kind);
DCHECK_NE(WasmImportCallKind::kWasmToWasm, kind);
@ -7560,7 +7557,7 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
if (FLAG_wasm_math_intrinsics &&
kind >= WasmImportCallKind::kFirstMathIntrinsic &&
kind <= WasmImportCallKind::kLastMathIntrinsic) {
return CompileWasmMathIntrinsic(wasm_engine, kind, sig);
return CompileWasmMathIntrinsic(kind, sig);
}
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
@ -7568,7 +7565,7 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
//----------------------------------------------------------------------------
// Create the Graph
//----------------------------------------------------------------------------
Zone zone(wasm_engine->allocator(), ZONE_NAME, kCompressGraphZone);
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
Graph* graph = zone.New<Graph>(&zone);
CommonOperatorBuilder* common = zone.New<CommonOperatorBuilder>(&zone);
MachineOperatorBuilder* machine = zone.New<MachineOperatorBuilder>(
@ -7601,20 +7598,19 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
incoming = GetI32WasmCallDescriptor(&zone, incoming);
}
wasm::WasmCompilationResult result = Pipeline::GenerateCodeForWasmNativeStub(
wasm_engine, incoming, mcgraph, CodeKind::WASM_TO_JS_FUNCTION,
incoming, mcgraph, CodeKind::WASM_TO_JS_FUNCTION,
wasm::WasmCode::kWasmToJsWrapper, func_name, WasmStubAssemblerOptions(),
source_position_table);
result.kind = wasm::WasmCompilationResult::kWasmToJsWrapper;
return result;
}
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine* wasm_engine,
wasm::NativeModule* native_module,
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::NativeModule* native_module,
const wasm::FunctionSig* sig) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileWasmCapiFunction");
Zone zone(wasm_engine->allocator(), ZONE_NAME, kCompressGraphZone);
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
// TODO(jkummerow): Extract common code into helper method.
SourcePositionTable* source_positions = nullptr;
@ -7646,7 +7642,7 @@ wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine* wasm_engine,
const char* debug_name = "WasmCapiCall";
wasm::WasmCompilationResult result = Pipeline::GenerateCodeForWasmNativeStub(
wasm_engine, call_descriptor, mcgraph, CodeKind::WASM_TO_CAPI_FUNCTION,
call_descriptor, mcgraph, CodeKind::WASM_TO_CAPI_FUNCTION,
wasm::WasmCode::kWasmToCapiWrapper, debug_name,
WasmStubAssemblerOptions(), source_positions);
std::unique_ptr<wasm::WasmCode> wasm_code = native_module->AddCode(
@ -7695,7 +7691,7 @@ MaybeHandle<Code> CompileWasmToJSWrapper(Isolate* isolate,
// Run the compilation job synchronously.
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmHeapStubCompilationJob(
isolate, wasm::GetWasmEngine(), incoming, std::move(zone), graph,
isolate, incoming, std::move(zone), graph,
CodeKind::WASM_TO_JS_FUNCTION, std::move(name_buffer),
AssemblerOptions::Default(isolate)));
@ -7742,7 +7738,7 @@ MaybeHandle<Code> CompileJSToJSWrapper(Isolate* isolate,
// Run the compilation job synchronously.
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmHeapStubCompilationJob(
isolate, wasm::GetWasmEngine(), incoming, std::move(zone), graph,
isolate, incoming, std::move(zone), graph,
CodeKind::JS_TO_JS_FUNCTION, std::move(name_buffer),
AssemblerOptions::Default(isolate)));
@ -7797,9 +7793,8 @@ Handle<CodeT> CompileCWasmEntry(Isolate* isolate, const wasm::FunctionSig* sig,
// Run the compilation job synchronously.
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmHeapStubCompilationJob(
isolate, wasm::GetWasmEngine(), incoming, std::move(zone), graph,
CodeKind::C_WASM_ENTRY, std::move(name_buffer),
AssemblerOptions::Default(isolate)));
isolate, incoming, std::move(zone), graph, CodeKind::C_WASM_ENTRY,
std::move(name_buffer), AssemblerOptions::Default(isolate)));
CHECK_NE(job->ExecuteJob(isolate->counters()->runtime_call_stats(), nullptr),
CompilationJob::FAILED);
@ -7814,8 +7809,7 @@ Handle<CodeT> CompileCWasmEntry(Isolate* isolate, const wasm::FunctionSig* sig,
namespace {
bool BuildGraphForWasmFunction(AccountingAllocator* allocator,
wasm::CompilationEnv* env,
bool BuildGraphForWasmFunction(wasm::CompilationEnv* env,
const wasm::FunctionBody& func_body,
int func_index, wasm::WasmFeatures* detected,
MachineGraph* mcgraph,
@ -7825,6 +7819,7 @@ bool BuildGraphForWasmFunction(AccountingAllocator* allocator,
// Create a TF graph during decoding.
WasmGraphBuilder builder(env, mcgraph->zone(), mcgraph, func_body.sig,
source_positions);
auto* allocator = wasm::GetWasmEngine()->allocator();
wasm::VoidResult graph_construction_result = wasm::BuildTFGraph(
allocator, env->enabled_features, env->module, &builder, detected,
func_body, loop_infos, node_origins, func_index);
@ -7864,13 +7859,12 @@ base::Vector<const char> GetDebugName(Zone* zone, int index) {
} // namespace
wasm::WasmCompilationResult ExecuteTurbofanWasmCompilation(
wasm::WasmEngine* wasm_engine, wasm::CompilationEnv* env,
const wasm::FunctionBody& func_body, int func_index, Counters* counters,
wasm::WasmFeatures* detected) {
wasm::CompilationEnv* env, const wasm::FunctionBody& func_body,
int func_index, Counters* counters, wasm::WasmFeatures* detected) {
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileTopTier", "func_index", func_index, "body_size",
func_body.end - func_body.start);
Zone zone(wasm_engine->allocator(), ZONE_NAME, kCompressGraphZone);
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
MachineGraph* mcgraph = zone.New<MachineGraph>(
zone.New<Graph>(&zone), zone.New<CommonOperatorBuilder>(&zone),
zone.New<MachineOperatorBuilder>(
@ -7897,9 +7891,8 @@ wasm::WasmCompilationResult ExecuteTurbofanWasmCompilation(
std::vector<WasmLoopInfo> loop_infos;
if (!BuildGraphForWasmFunction(wasm_engine->allocator(), env, func_body,
func_index, detected, mcgraph, &loop_infos,
node_origins, source_positions)) {
if (!BuildGraphForWasmFunction(env, func_body, func_index, detected, mcgraph,
&loop_infos, node_origins, source_positions)) {
return wasm::WasmCompilationResult{};
}
@ -7918,8 +7911,8 @@ wasm::WasmCompilationResult ExecuteTurbofanWasmCompilation(
}
Pipeline::GenerateCodeForWasmFunction(
&info, wasm_engine, mcgraph, call_descriptor, source_positions,
node_origins, func_body, env->module, func_index, &loop_infos);
&info, mcgraph, call_descriptor, source_positions, node_origins,
func_body, env->module, func_index, &loop_infos);
if (counters) {
counters->wasm_compile_function_peak_memory_bytes()->AddSample(

View File

@ -59,8 +59,8 @@ enum class LoadTransformationKind : uint8_t;
namespace compiler {
wasm::WasmCompilationResult ExecuteTurbofanWasmCompilation(
wasm::WasmEngine*, wasm::CompilationEnv*, const wasm::FunctionBody&,
int func_index, Counters*, wasm::WasmFeatures* detected);
wasm::CompilationEnv*, const wasm::FunctionBody&, int func_index, Counters*,
wasm::WasmFeatures* detected);
// 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
@ -116,19 +116,18 @@ ResolveWasmImportCall(Handle<JSReceiver> callable, const wasm::FunctionSig* sig,
// Compiles an import call wrapper, which allows Wasm to call imports.
V8_EXPORT_PRIVATE wasm::WasmCompilationResult CompileWasmImportCallWrapper(
wasm::WasmEngine*, wasm::CompilationEnv* env, WasmImportCallKind,
const wasm::FunctionSig*, bool source_positions, int expected_arity);
wasm::CompilationEnv* env, WasmImportCallKind, const wasm::FunctionSig*,
bool source_positions, int expected_arity);
// Compiles a host call wrapper, which allows Wasm to call host functions.
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine*,
wasm::NativeModule*,
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::NativeModule*,
const wasm::FunctionSig*);
// Returns an OptimizedCompilationJob object for a JS to Wasm wrapper.
std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
Isolate* isolate, wasm::WasmEngine* wasm_engine,
const wasm::FunctionSig* sig, const wasm::WasmModule* module,
bool is_import, const wasm::WasmFeatures& enabled_features);
Isolate* isolate, const wasm::FunctionSig* sig,
const wasm::WasmModule* module, bool is_import,
const wasm::WasmFeatures& enabled_features);
MaybeHandle<Code> CompileWasmToJSWrapper(Isolate* isolate,
const wasm::FunctionSig* sig,

View File

@ -6184,9 +6184,8 @@ constexpr base::EnumSet<ValueKind> LiftoffCompiler::kExternRefSupported;
} // namespace
WasmCompilationResult ExecuteLiftoffCompilation(
AccountingAllocator* allocator, CompilationEnv* env,
const FunctionBody& func_body, int func_index, ForDebugging for_debugging,
Counters* counters, WasmFeatures* detected,
CompilationEnv* env, const FunctionBody& func_body, int func_index,
ForDebugging for_debugging, Counters* counters, WasmFeatures* detected,
base::Vector<const int> breakpoints,
std::unique_ptr<DebugSideTable>* debug_sidetable, int dead_breakpoint,
int* max_steps) {
@ -6195,7 +6194,7 @@ WasmCompilationResult ExecuteLiftoffCompilation(
"wasm.CompileBaseline", "funcIndex", func_index, "bodySize",
func_body_size);
Zone zone(allocator, "LiftoffCompilationZone");
Zone zone(GetWasmEngine()->allocator(), "LiftoffCompilationZone");
auto call_descriptor = compiler::GetWasmCallDescriptor(&zone, func_body.sig);
size_t code_size_estimate =
WasmCodeManager::EstimateLiftoffCodeSize(func_body_size);

View File

@ -54,8 +54,8 @@ enum LiftoffBailoutReason : int8_t {
};
V8_EXPORT_PRIVATE WasmCompilationResult ExecuteLiftoffCompilation(
AccountingAllocator*, CompilationEnv*, const FunctionBody&, int func_index,
ForDebugging, Counters*, WasmFeatures* detected_features,
CompilationEnv*, const FunctionBody&, int func_index, ForDebugging,
Counters*, WasmFeatures* detected_features,
base::Vector<const int> breakpoints = {},
std::unique_ptr<DebugSideTable>* = nullptr, int dead_breakpoint = 0,
int* max_steps = nullptr);

View File

@ -112,7 +112,7 @@ class V8_EXPORT_PRIVATE CompilationState {
~CompilationState();
void InitCompileJob(WasmEngine*);
void InitCompileJob();
void CancelCompilation();

View File

@ -121,15 +121,14 @@ ExecutionTier WasmCompilationUnit::GetBaselineExecutionTier(
}
WasmCompilationResult WasmCompilationUnit::ExecuteCompilation(
WasmEngine* engine, CompilationEnv* env,
const WireBytesStorage* wire_bytes_storage, Counters* counters,
WasmFeatures* detected) {
CompilationEnv* env, const WireBytesStorage* wire_bytes_storage,
Counters* counters, WasmFeatures* detected) {
WasmCompilationResult result;
if (func_index_ < static_cast<int>(env->module->num_imported_functions)) {
result = ExecuteImportWrapperCompilation(engine, env);
result = ExecuteImportWrapperCompilation(env);
} else {
result = ExecuteFunctionCompilation(engine, env, wire_bytes_storage,
counters, detected);
result =
ExecuteFunctionCompilation(env, wire_bytes_storage, counters, detected);
}
if (result.succeeded() && counters) {
@ -145,22 +144,21 @@ WasmCompilationResult WasmCompilationUnit::ExecuteCompilation(
}
WasmCompilationResult WasmCompilationUnit::ExecuteImportWrapperCompilation(
WasmEngine* engine, CompilationEnv* env) {
CompilationEnv* env) {
const FunctionSig* sig = env->module->functions[func_index_].sig;
// Assume the wrapper is going to be a JS function with matching arity at
// instantiation time.
auto kind = compiler::kDefaultImportCallKind;
bool source_positions = is_asmjs_module(env->module);
WasmCompilationResult result = compiler::CompileWasmImportCallWrapper(
engine, env, kind, sig, source_positions,
env, kind, sig, source_positions,
static_cast<int>(sig->parameter_count()));
return result;
}
WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
WasmEngine* wasm_engine, CompilationEnv* env,
const WireBytesStorage* wire_bytes_storage, Counters* counters,
WasmFeatures* detected) {
CompilationEnv* env, const WireBytesStorage* wire_bytes_storage,
Counters* counters, WasmFeatures* detected) {
auto* func = &env->module->functions[func_index_];
base::Vector<const uint8_t> code = wire_bytes_storage->GetCode(func->code);
wasm::FunctionBody func_body{func->sig, func->code.offset(), code.begin(),
@ -198,15 +196,14 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
if (V8_LIKELY(func_index_ >= 32 || (FLAG_wasm_debug_mask_for_testing &
(1 << func_index_)) == 0)) {
result = ExecuteLiftoffCompilation(
wasm_engine->allocator(), env, func_body, func_index_,
for_debugging_, counters, detected);
env, func_body, func_index_, for_debugging_, counters, detected);
} else {
// We don't use the debug side table, we only pass it to cover
// different code paths in Liftoff for testing.
std::unique_ptr<DebugSideTable> debug_sidetable;
result = ExecuteLiftoffCompilation(
wasm_engine->allocator(), env, func_body, func_index_,
kForDebugging, counters, detected, {}, &debug_sidetable);
result = ExecuteLiftoffCompilation(env, func_body, func_index_,
kForDebugging, counters, detected,
{}, &debug_sidetable);
}
if (result.succeeded()) break;
}
@ -218,7 +215,7 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
case ExecutionTier::kTurbofan:
result = compiler::ExecuteTurbofanWasmCompilation(
wasm_engine, env, func_body, func_index_, counters, detected);
env, func_body, func_index_, counters, detected);
result.for_debugging = for_debugging_;
break;
}
@ -266,8 +263,7 @@ void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate,
WasmCompilationUnit unit(function->func_index, tier, kNoDebugging);
CompilationEnv env = native_module->CreateCompilationEnv();
WasmCompilationResult result = unit.ExecuteCompilation(
GetWasmEngine(), &env,
native_module->compilation_state()->GetWireBytesStorage().get(),
&env, native_module->compilation_state()->GetWireBytesStorage().get(),
isolate->counters(), detected);
if (result.succeeded()) {
WasmCodeRefScope code_ref_scope;
@ -303,18 +299,18 @@ bool UseGenericWrapper(const FunctionSig* sig) {
} // namespace
JSToWasmWrapperCompilationUnit::JSToWasmWrapperCompilationUnit(
Isolate* isolate, WasmEngine* wasm_engine, const FunctionSig* sig,
const WasmModule* module, bool is_import,
const WasmFeatures& enabled_features, AllowGeneric allow_generic)
Isolate* isolate, const FunctionSig* sig, const WasmModule* module,
bool is_import, const WasmFeatures& enabled_features,
AllowGeneric allow_generic)
: isolate_(isolate),
is_import_(is_import),
sig_(sig),
use_generic_wrapper_(allow_generic && UseGenericWrapper(sig) &&
!is_import),
job_(use_generic_wrapper_ ? nullptr
: compiler::NewJSToWasmCompilationJob(
isolate, wasm_engine, sig, module,
is_import, enabled_features)) {}
job_(use_generic_wrapper_
? nullptr
: compiler::NewJSToWasmCompilationJob(
isolate, sig, module, is_import, enabled_features)) {}
JSToWasmWrapperCompilationUnit::~JSToWasmWrapperCompilationUnit() = default;
@ -349,9 +345,8 @@ Handle<Code> JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
bool is_import) {
// Run the compilation unit synchronously.
WasmFeatures enabled_features = WasmFeatures::FromIsolate(isolate);
JSToWasmWrapperCompilationUnit unit(isolate, GetWasmEngine(), sig, module,
is_import, enabled_features,
kAllowGeneric);
JSToWasmWrapperCompilationUnit unit(isolate, sig, module, is_import,
enabled_features, kAllowGeneric);
unit.Execute();
return unit.Finalize();
}
@ -362,9 +357,8 @@ Handle<Code> JSToWasmWrapperCompilationUnit::CompileSpecificJSToWasmWrapper(
// Run the compilation unit synchronously.
const bool is_import = false;
WasmFeatures enabled_features = WasmFeatures::FromIsolate(isolate);
JSToWasmWrapperCompilationUnit unit(isolate, GetWasmEngine(), sig, module,
is_import, enabled_features,
kDontAllowGeneric);
JSToWasmWrapperCompilationUnit unit(isolate, sig, module, is_import,
enabled_features, kDontAllowGeneric);
unit.Execute();
return unit.Finalize();
}

View File

@ -84,7 +84,7 @@ class V8_EXPORT_PRIVATE WasmCompilationUnit final {
WasmCompilationUnit(int index, ExecutionTier tier, ForDebugging for_debugging)
: func_index_(index), tier_(tier), for_debugging_(for_debugging) {}
WasmCompilationResult ExecuteCompilation(WasmEngine*, CompilationEnv*,
WasmCompilationResult ExecuteCompilation(CompilationEnv*,
const WireBytesStorage*, Counters*,
WasmFeatures* detected);
@ -96,13 +96,12 @@ class V8_EXPORT_PRIVATE WasmCompilationUnit final {
ExecutionTier);
private:
WasmCompilationResult ExecuteFunctionCompilation(WasmEngine*, CompilationEnv*,
WasmCompilationResult ExecuteFunctionCompilation(CompilationEnv*,
const WireBytesStorage*,
Counters*,
WasmFeatures* detected);
WasmCompilationResult ExecuteImportWrapperCompilation(WasmEngine*,
CompilationEnv*);
WasmCompilationResult ExecuteImportWrapperCompilation(CompilationEnv*);
int func_index_;
ExecutionTier tier_;
@ -120,8 +119,7 @@ class V8_EXPORT_PRIVATE JSToWasmWrapperCompilationUnit final {
// and return the builtin (generic) wrapper, when available.
enum AllowGeneric : bool { kAllowGeneric = true, kDontAllowGeneric = false };
JSToWasmWrapperCompilationUnit(Isolate* isolate, WasmEngine* wasm_engine,
const FunctionSig* sig,
JSToWasmWrapperCompilationUnit(Isolate* isolate, const FunctionSig* sig,
const wasm::WasmModule* module, bool is_import,
const WasmFeatures& enabled_features,
AllowGeneric allow_generic);

View File

@ -535,7 +535,7 @@ class CompilationStateImpl {
// Call right after the constructor, after the {compilation_state_} field in
// the {NativeModule} has been initialized.
void InitCompileJob(WasmEngine*);
void InitCompileJob();
// {kCancelUnconditionally}: Cancel all compilation.
// {kCancelInitialCompilation}: Cancel all compilation if initial (baseline)
@ -784,9 +784,7 @@ void UpdateFeatureUseCounts(Isolate* isolate, const WasmFeatures& detected) {
CompilationState::~CompilationState() { Impl(this)->~CompilationStateImpl(); }
void CompilationState::InitCompileJob(WasmEngine* engine) {
Impl(this)->InitCompileJob(engine);
}
void CompilationState::InitCompileJob() { Impl(this)->InitCompileJob(); }
void CompilationState::CancelCompilation() {
Impl(this)->CancelCompilation(CompilationStateImpl::kCancelUnconditionally);
@ -1128,7 +1126,7 @@ bool CompileLazy(Isolate* isolate, Handle<WasmModuleObject> module_object,
WasmEngine* engine = GetWasmEngine();
WasmFeatures detected_features;
WasmCompilationResult result = baseline_unit.ExecuteCompilation(
engine, &env, compilation_state->GetWireBytesStorage().get(), counters,
&env, compilation_state->GetWireBytesStorage().get(), counters,
&detected_features);
compilation_state->OnCompilationStopped(detected_features);
@ -1218,8 +1216,7 @@ CompilationExecutionResult ExecuteJSToWasmWrapperCompilationUnits(
if (!wrapper_unit) return kNoMoreUnits;
isolate = wrapper_unit->isolate();
wrapper_compilation_token =
compile_scope.native_module()->engine()->StartWrapperCompilation(
isolate);
wasm::GetWasmEngine()->StartWrapperCompilation(isolate);
if (!wrapper_compilation_token) return kNoMoreUnits;
}
@ -1277,7 +1274,6 @@ CompilationExecutionResult ExecuteCompilationUnits(
// These fields are initialized in a {BackgroundCompileScope} before
// starting compilation.
WasmEngine* engine;
base::Optional<CompilationEnv> env;
std::shared_ptr<WireBytesStorage> wire_bytes;
std::shared_ptr<const WasmModule> module;
@ -1296,7 +1292,6 @@ CompilationExecutionResult ExecuteCompilationUnits(
{
BackgroundCompileScope compile_scope(native_module);
if (compile_scope.cancelled()) return kYield;
engine = compile_scope.native_module()->engine();
env.emplace(compile_scope.native_module()->CreateCompilationEnv());
wire_bytes = compile_scope.compilation_state()->GetWireBytesStorage();
module = compile_scope.native_module()->shared_module();
@ -1315,7 +1310,7 @@ CompilationExecutionResult ExecuteCompilationUnits(
while (unit->tier() == current_tier) {
// (asynchronous): Execute the compilation.
WasmCompilationResult result = unit->ExecuteCompilation(
engine, &env.value(), wire_bytes.get(), counters, &detected_features);
&env.value(), wire_bytes.get(), counters, &detected_features);
results_to_publish.emplace_back(std::move(result));
bool yield = delegate && delegate->ShouldYield();
@ -1369,8 +1364,7 @@ CompilationExecutionResult ExecuteCompilationUnits(
using JSToWasmWrapperKey = std::pair<bool, FunctionSig>;
// Returns the number of units added.
int AddExportWrapperUnits(Isolate* isolate, WasmEngine* wasm_engine,
NativeModule* native_module,
int AddExportWrapperUnits(Isolate* isolate, NativeModule* native_module,
CompilationUnitBuilder* builder,
const WasmFeatures& enabled_features) {
std::unordered_set<JSToWasmWrapperKey, base::hash<JSToWasmWrapperKey>> keys;
@ -1380,9 +1374,8 @@ int AddExportWrapperUnits(Isolate* isolate, WasmEngine* wasm_engine,
JSToWasmWrapperKey key(function.imported, *function.sig);
if (keys.insert(key).second) {
auto unit = std::make_shared<JSToWasmWrapperCompilationUnit>(
isolate, wasm_engine, function.sig, native_module->module(),
function.imported, enabled_features,
JSToWasmWrapperCompilationUnit::kAllowGeneric);
isolate, function.sig, native_module->module(), function.imported,
enabled_features, JSToWasmWrapperCompilationUnit::kAllowGeneric);
builder->AddJSToWasmWrapperUnit(std::move(unit));
}
}
@ -1455,9 +1448,8 @@ void InitializeCompilationUnits(Isolate* isolate, NativeModule* native_module) {
}
}
int num_import_wrappers = AddImportWrapperUnits(native_module, &builder);
int num_export_wrappers =
AddExportWrapperUnits(isolate, GetWasmEngine(), native_module, &builder,
WasmFeatures::FromIsolate(isolate));
int num_export_wrappers = AddExportWrapperUnits(
isolate, native_module, &builder, WasmFeatures::FromIsolate(isolate));
compilation_state->InitializeCompilationProgress(
lazy_module, num_import_wrappers, num_export_wrappers);
builder.Commit();
@ -1631,10 +1623,9 @@ void CompileNativeModule(Isolate* isolate,
class BackgroundCompileJob final : public JobTask {
public:
explicit BackgroundCompileJob(std::weak_ptr<NativeModule> native_module,
WasmEngine* engine,
std::shared_ptr<Counters> async_counters)
: native_module_(std::move(native_module)),
engine_barrier_(engine->GetBarrierForBackgroundCompile()),
engine_barrier_(GetWasmEngine()->GetBarrierForBackgroundCompile()),
async_counters_(std::move(async_counters)) {}
void Run(JobDelegate* delegate) override {
@ -1830,7 +1821,6 @@ class AsyncStreamingProcessor final : public StreamingProcessor {
ModuleDecoder decoder_;
AsyncCompileJob* job_;
WasmEngine* wasm_engine_;
std::unique_ptr<CompilationUnitBuilder> compilation_unit_builder_;
int num_functions_ = 0;
bool prefix_cache_hit_ = false;
@ -2452,7 +2442,6 @@ AsyncStreamingProcessor::AsyncStreamingProcessor(
AccountingAllocator* allocator)
: decoder_(job->enabled_features_),
job_(job),
wasm_engine_(GetWasmEngine()),
compilation_unit_builder_(nullptr),
async_counters_(async_counters),
allocator_(allocator) {}
@ -2576,7 +2565,7 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(
prefix_hash_ = base::hash_combine(prefix_hash_,
static_cast<uint32_t>(code_section_length));
if (!wasm_engine_->GetStreamingCompilationOwnership(prefix_hash_)) {
if (!GetWasmEngine()->GetStreamingCompilationOwnership(prefix_hash_)) {
// Known prefix, wait until the end of the stream and check the cache.
prefix_cache_hit_ = true;
return true;
@ -2611,8 +2600,8 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(
int num_import_wrappers =
AddImportWrapperUnits(native_module, compilation_unit_builder_.get());
int num_export_wrappers = AddExportWrapperUnits(
job_->isolate_, wasm_engine_, native_module,
compilation_unit_builder_.get(), job_->enabled_features_);
job_->isolate_, native_module, compilation_unit_builder_.get(),
job_->enabled_features_);
compilation_state->InitializeCompilationProgress(
lazy_module, num_import_wrappers, num_export_wrappers);
return true;
@ -2825,12 +2814,11 @@ CompilationStateImpl::CompilationStateImpl(
async_counters_(std::move(async_counters)),
compilation_unit_queues_(native_module->num_functions()) {}
void CompilationStateImpl::InitCompileJob(WasmEngine* engine) {
void CompilationStateImpl::InitCompileJob() {
DCHECK_NULL(compile_job_);
compile_job_ = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserVisible,
std::make_unique<BackgroundCompileJob>(native_module_weak_, engine,
async_counters_));
TaskPriority::kUserVisible, std::make_unique<BackgroundCompileJob>(
native_module_weak_, async_counters_));
}
void CompilationStateImpl::CancelCompilation(
@ -3485,8 +3473,8 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
JSToWasmWrapperKey key(function.imported, *function.sig);
if (queue.insert(key)) {
auto unit = std::make_unique<JSToWasmWrapperCompilationUnit>(
isolate, GetWasmEngine(), function.sig, module, function.imported,
enabled_features, JSToWasmWrapperCompilationUnit::kAllowGeneric);
isolate, function.sig, module, function.imported, enabled_features,
JSToWasmWrapperCompilationUnit::kAllowGeneric);
compilation_units.emplace(key, std::move(unit));
}
}
@ -3520,7 +3508,7 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
}
WasmCode* CompileImportWrapper(
WasmEngine* wasm_engine, NativeModule* native_module, Counters* counters,
NativeModule* native_module, Counters* counters,
compiler::WasmImportCallKind kind, const FunctionSig* sig,
int expected_arity,
WasmImportWrapperCache::ModificationScope* cache_scope) {
@ -3534,7 +3522,7 @@ WasmCode* CompileImportWrapper(
WasmCodeRefScope code_ref_scope;
CompilationEnv env = native_module->CreateCompilationEnv();
WasmCompilationResult result = compiler::CompileWasmImportCallWrapper(
wasm_engine, &env, kind, sig, source_positions, expected_arity);
&env, kind, sig, source_positions, expected_arity);
std::unique_ptr<WasmCode> wasm_code = native_module->AddCode(
result.func_index, result.code_desc, result.frame_slot_count,
result.tagged_parameter_slots,

View File

@ -64,7 +64,7 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
// compiled yet.
V8_EXPORT_PRIVATE
WasmCode* CompileImportWrapper(
WasmEngine* wasm_engine, NativeModule* native_module, Counters* counters,
NativeModule* native_module, Counters* counters,
compiler::WasmImportCallKind kind, const FunctionSig* sig,
int expected_arity, WasmImportWrapperCache::ModificationScope* cache_scope);

View File

@ -45,11 +45,10 @@ using ImportWrapperQueue = WrapperQueue<WasmImportWrapperCache::CacheKey,
class CompileImportWrapperJob final : public JobTask {
public:
CompileImportWrapperJob(
WasmEngine* engine, Counters* counters, NativeModule* native_module,
Counters* counters, NativeModule* native_module,
ImportWrapperQueue* queue,
WasmImportWrapperCache::ModificationScope* cache_scope)
: engine_(engine),
counters_(counters),
: counters_(counters),
native_module_(native_module),
queue_(queue),
cache_scope_(cache_scope) {}
@ -65,14 +64,13 @@ class CompileImportWrapperJob final : public JobTask {
void Run(JobDelegate* delegate) override {
while (base::Optional<WasmImportWrapperCache::CacheKey> key =
queue_->pop()) {
CompileImportWrapper(engine_, native_module_, counters_, key->kind,
key->signature, key->expected_arity, cache_scope_);
CompileImportWrapper(native_module_, counters_, key->kind, key->signature,
key->expected_arity, cache_scope_);
if (delegate->ShouldYield()) return;
}
}
private:
WasmEngine* const engine_;
Counters* const counters_;
NativeModule* const native_module_;
ImportWrapperQueue* const queue_;
@ -997,8 +995,8 @@ bool InstanceBuilder::ProcessImportedFunction(
if (wasm_code == nullptr) {
WasmCodeRefScope code_ref_scope;
WasmImportWrapperCache::ModificationScope cache_scope(cache);
wasm_code = compiler::CompileWasmCapiCallWrapper(
wasm::GetWasmEngine(), native_module, expected_sig);
wasm_code =
compiler::CompileWasmCapiCallWrapper(native_module, expected_sig);
WasmImportWrapperCache::CacheKey key(kind, expected_sig,
expected_arity);
cache_scope[key] = wasm_code;
@ -1438,8 +1436,7 @@ void InstanceBuilder::CompileImportWrappers(
}
auto compile_job_task = std::make_unique<CompileImportWrapperJob>(
wasm::GetWasmEngine(), isolate_->counters(), native_module,
&import_wrapper_queue, &cache_scope);
isolate_->counters(), native_module, &import_wrapper_queue, &cache_scope);
auto compile_job = V8::GetCurrentPlatform()->PostJob(
TaskPriority::kUserVisible, std::move(compile_job_task));

View File

@ -863,7 +863,7 @@ NativeModule::NativeModule(WasmEngine* engine, const WasmFeatures& enabled,
shared_this->reset(this);
compilation_state_ =
CompilationState::New(*shared_this, std::move(async_counters));
compilation_state_->InitCompileJob(engine);
compilation_state_->InitCompileJob();
DCHECK_NOT_NULL(module_);
if (module_->num_declared_functions > 0) {
code_table_ =

View File

@ -283,9 +283,9 @@ class DebugInfoImpl {
Counters* counters = nullptr;
WasmFeatures unused_detected;
WasmCompilationResult result = ExecuteLiftoffCompilation(
native_module_->engine()->allocator(), &env, body, func_index,
for_debugging, counters, &unused_detected, offsets,
generate_debug_sidetable ? &debug_sidetable : nullptr, dead_breakpoint);
&env, body, func_index, for_debugging, counters, &unused_detected,
offsets, generate_debug_sidetable ? &debug_sidetable : nullptr,
dead_breakpoint);
// Liftoff compilation failure is a FATAL error. We rely on complete Liftoff
// support for debugging.
if (!result.succeeded()) FATAL("Liftoff compilation failed");

View File

@ -624,8 +624,7 @@ void WasmTableObject::UpdateDispatchTables(
if (wasm_code == nullptr) {
wasm::WasmCodeRefScope code_ref_scope;
wasm::WasmImportWrapperCache::ModificationScope cache_scope(cache);
wasm_code = compiler::CompileWasmCapiCallWrapper(wasm::GetWasmEngine(),
native_module, &sig);
wasm_code = compiler::CompileWasmCapiCallWrapper(native_module, &sig);
wasm::WasmImportWrapperCache::CacheKey key(kind, &sig, param_count);
cache_scope[key] = wasm_code;
wasm_code->IncRef();
@ -1544,7 +1543,7 @@ void WasmInstanceObject::ImportWasmJSFunctionIntoTable(
.internal_formal_parameter_count();
}
wasm::WasmCompilationResult result = compiler::CompileWasmImportCallWrapper(
wasm::GetWasmEngine(), &env, kind, sig, false, expected_arity);
&env, kind, sig, false, expected_arity);
std::unique_ptr<wasm::WasmCode> wasm_code = native_module->AddCode(
result.func_index, result.code_desc, result.frame_slot_count,
result.tagged_parameter_slots,

View File

@ -45,11 +45,11 @@ class LiftoffCompileEnvironment {
WasmFeatures detected1;
WasmFeatures detected2;
WasmCompilationResult result1 = ExecuteLiftoffCompilation(
isolate_->allocator(), &env, test_func.body, test_func.code->index(),
kNoDebugging, isolate_->counters(), &detected1);
&env, test_func.body, test_func.code->index(), kNoDebugging,
isolate_->counters(), &detected1);
WasmCompilationResult result2 = ExecuteLiftoffCompilation(
isolate_->allocator(), &env, test_func.body, test_func.code->index(),
kNoDebugging, isolate_->counters(), &detected2);
&env, test_func.body, test_func.code->index(), kNoDebugging,
isolate_->counters(), &detected2);
CHECK(result1.succeeded());
CHECK(result2.succeeded());
@ -74,9 +74,8 @@ class LiftoffCompileEnvironment {
WasmFeatures detected;
std::unique_ptr<DebugSideTable> debug_side_table_via_compilation;
auto result = ExecuteLiftoffCompilation(
CcTest::i_isolate()->allocator(), &env, test_func.body, 0,
kForDebugging, nullptr, &detected, base::VectorOf(breakpoints),
&debug_side_table_via_compilation);
&env, test_func.body, 0, kForDebugging, nullptr, &detected,
base::VectorOf(breakpoints), &debug_side_table_via_compilation);
CHECK(result.succeeded());
// If there are no breakpoint, then {ExecuteLiftoffCompilation} should

View File

@ -39,9 +39,8 @@ TEST(CacheHit) {
auto sig = sigs.i_i();
int expected_arity = static_cast<int>(sig->parameter_count());
WasmCode* c1 =
CompileImportWrapper(GetWasmEngine(), module.get(), isolate->counters(),
kind, sig, expected_arity, &cache_scope);
WasmCode* c1 = CompileImportWrapper(module.get(), isolate->counters(), kind,
sig, expected_arity, &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
@ -66,9 +65,8 @@ TEST(CacheMissSig) {
auto sig2 = sigs.i_ii();
int expected_arity2 = static_cast<int>(sig2->parameter_count());
WasmCode* c1 =
CompileImportWrapper(GetWasmEngine(), module.get(), isolate->counters(),
kind, sig1, expected_arity1, &cache_scope);
WasmCode* c1 = CompileImportWrapper(module.get(), isolate->counters(), kind,
sig1, expected_arity1, &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
@ -91,9 +89,8 @@ TEST(CacheMissKind) {
auto sig = sigs.i_i();
int expected_arity = static_cast<int>(sig->parameter_count());
WasmCode* c1 =
CompileImportWrapper(GetWasmEngine(), module.get(), isolate->counters(),
kind1, sig, expected_arity, &cache_scope);
WasmCode* c1 = CompileImportWrapper(module.get(), isolate->counters(), kind1,
sig, expected_arity, &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
@ -117,9 +114,8 @@ TEST(CacheHitMissSig) {
auto sig2 = sigs.i_ii();
int expected_arity2 = static_cast<int>(sig2->parameter_count());
WasmCode* c1 =
CompileImportWrapper(GetWasmEngine(), module.get(), isolate->counters(),
kind, sig1, expected_arity1, &cache_scope);
WasmCode* c1 = CompileImportWrapper(module.get(), isolate->counters(), kind,
sig1, expected_arity1, &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
@ -128,8 +124,8 @@ TEST(CacheHitMissSig) {
CHECK_NULL(c2);
c2 = CompileImportWrapper(GetWasmEngine(), module.get(), isolate->counters(),
kind, sig2, expected_arity2, &cache_scope);
c2 = CompileImportWrapper(module.get(), isolate->counters(), kind, sig2,
expected_arity2, &cache_scope);
CHECK_NE(c1, c2);

View File

@ -63,8 +63,7 @@ TestingModuleBuilder::TestingModuleBuilder(
auto import_wrapper = cache_scope[key];
if (import_wrapper == nullptr) {
import_wrapper = CompileImportWrapper(
GetWasmEngine(), native_module_, isolate_->counters(), kind,
maybe_import->sig,
native_module_, isolate_->counters(), kind, maybe_import->sig,
static_cast<int>(maybe_import->sig->parameter_count()), &cache_scope);
}
@ -559,15 +558,14 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
if (builder_->test_execution_tier() ==
TestExecutionTier::kLiftoffForFuzzing) {
result.emplace(ExecuteLiftoffCompilation(
GetWasmEngine()->allocator(), &env, func_body, function_->func_index,
kForDebugging, isolate()->counters(), &unused_detected_features, {},
nullptr, 0, builder_->max_steps_ptr()));
&env, func_body, function_->func_index, kForDebugging,
isolate()->counters(), &unused_detected_features, {}, nullptr, 0,
builder_->max_steps_ptr()));
} else {
WasmCompilationUnit unit(function_->func_index, builder_->execution_tier(),
for_debugging);
result.emplace(unit.ExecuteCompilation(
GetWasmEngine(), &env,
native_module->compilation_state()->GetWireBytesStorage().get(),
&env, native_module->compilation_state()->GetWireBytesStorage().get(),
isolate()->counters(), &unused_detected_features));
}
WasmCode* code = native_module->PublishCode(