Commit 70aacc2e authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Make WasmCompilationUnit independent of Isolate.

R=clemensh@chromium.org
BUG=v8:7424

Change-Id: I3055d4d98c108ce6e576f7171b8fae4e6b2c3948
Reviewed-on: https://chromium-review.googlesource.com/1131132
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54470}
parent 8a011b57
......@@ -723,7 +723,7 @@ void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) {
buffer << "-- ";
// Turbolizer only needs the source position, as it can reconstruct
// the inlining stack from other information.
if (info->trace_turbo_json_enabled() ||
if (info->trace_turbo_json_enabled() || !tasm()->isolate() ||
tasm()->isolate()->concurrent_recompilation_enabled()) {
buffer << source_position;
} else {
......
......@@ -105,6 +105,7 @@ class PipelineData {
OptimizedCompilationInfo* info,
PipelineStatistics* pipeline_statistics)
: isolate_(isolate),
allocator_(isolate->allocator()),
info_(info),
debug_name_(info_->GetDebugName()),
may_have_unverifiable_graph_(false),
......@@ -140,16 +141,17 @@ class PipelineData {
}
// For WebAssembly compile entry point.
PipelineData(ZoneStats* zone_stats, Isolate* isolate,
wasm::WasmEngine* wasm_engine, OptimizedCompilationInfo* info,
MachineGraph* mcgraph, PipelineStatistics* pipeline_statistics,
PipelineData(ZoneStats* zone_stats, wasm::WasmEngine* wasm_engine,
OptimizedCompilationInfo* info, MachineGraph* mcgraph,
PipelineStatistics* pipeline_statistics,
SourcePositionTable* source_positions,
NodeOriginTable* node_origins,
WasmCompilationData* wasm_compilation_data,
int wasm_function_index,
const AssemblerOptions& assembler_options)
: isolate_(isolate),
: isolate_(nullptr),
wasm_engine_(wasm_engine),
allocator_(wasm_engine->allocator()),
info_(info),
debug_name_(info_->GetDebugName()),
wasm_function_index_(wasm_function_index),
......@@ -179,6 +181,7 @@ class PipelineData {
NodeOriginTable* node_origins, JumpOptimizationInfo* jump_opt,
const AssemblerOptions& assembler_options)
: isolate_(isolate),
allocator_(isolate->allocator()),
info_(info),
debug_name_(info_->GetDebugName()),
zone_stats_(zone_stats),
......@@ -200,6 +203,7 @@ class PipelineData {
PipelineData(ZoneStats* zone_stats, OptimizedCompilationInfo* info,
Isolate* isolate, InstructionSequence* sequence)
: isolate_(isolate),
allocator_(isolate->allocator()),
info_(info),
debug_name_(info_->GetDebugName()),
zone_stats_(zone_stats),
......@@ -223,6 +227,7 @@ class PipelineData {
}
Isolate* isolate() const { return isolate_; }
AccountingAllocator* allocator() const { return allocator_; }
OptimizedCompilationInfo* info() const { return info_; }
ZoneStats* zone_stats() const { return zone_stats_; }
CompilationDependencies* dependencies() const { return dependencies_; }
......@@ -414,6 +419,7 @@ class PipelineData {
private:
Isolate* const isolate_;
wasm::WasmEngine* const wasm_engine_ = nullptr;
AccountingAllocator* const allocator_;
OptimizedCompilationInfo* const info_;
std::unique_ptr<char[]> debug_name_;
int wasm_function_index_ = -1;
......@@ -980,24 +986,27 @@ void PipelineCompilationJob::RegisterWeakObjectsInOptimizedCode(
code->set_can_have_weak_objects(true);
}
// The stack limit used during compilation is used to limit the recursion
// depth in, e.g. AST walking. No such recursion happens in WASM compilations.
constexpr uintptr_t kNoStackLimit = 0;
class PipelineWasmCompilationJob final : public OptimizedCompilationJob {
public:
explicit PipelineWasmCompilationJob(
OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
Isolate* isolate, MachineGraph* mcgraph, CallDescriptor* call_descriptor,
MachineGraph* mcgraph, CallDescriptor* call_descriptor,
SourcePositionTable* source_positions, NodeOriginTable* node_origins,
WasmCompilationData* wasm_compilation_data,
wasm::FunctionBody function_body, wasm::WasmModule* wasm_module,
wasm::NativeModule* native_module, int function_index, bool asmjs_origin)
: OptimizedCompilationJob(isolate->stack_guard()->real_climit(), info,
"TurboFan", State::kReadyToExecute),
zone_stats_(isolate->allocator()),
: OptimizedCompilationJob(kNoStackLimit, info, "TurboFan",
State::kReadyToExecute),
zone_stats_(wasm_engine->allocator()),
pipeline_statistics_(CreatePipelineStatistics(
wasm_engine, function_body, wasm_module, info, &zone_stats_)),
data_(&zone_stats_, isolate, wasm_engine, info, mcgraph,
data_(&zone_stats_, wasm_engine, info, mcgraph,
pipeline_statistics_.get(), source_positions, node_origins,
wasm_compilation_data, function_index,
WasmAssemblerOptions(isolate)),
wasm_compilation_data, function_index, WasmAssemblerOptions()),
pipeline_(&data_),
linkage_(call_descriptor),
native_module_(native_module),
......@@ -1673,7 +1682,7 @@ struct InstructionSelectionPhase {
FLAG_turbo_instruction_scheduling
? InstructionSelector::kEnableScheduling
: InstructionSelector::kDisableScheduling,
data->isolate()->serializer_enabled()
!data->isolate() || data->isolate()->serializer_enabled()
? InstructionSelector::kDisableRootsRelativeAddressing
: InstructionSelector::kEnableRootsRelativeAddressing,
data->info()->GetPoisoningMitigationLevel(),
......@@ -2242,14 +2251,14 @@ OptimizedCompilationJob* Pipeline::NewCompilationJob(
// static
OptimizedCompilationJob* Pipeline::NewWasmCompilationJob(
OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
Isolate* isolate, MachineGraph* mcgraph, CallDescriptor* call_descriptor,
MachineGraph* mcgraph, CallDescriptor* call_descriptor,
SourcePositionTable* source_positions, NodeOriginTable* node_origins,
WasmCompilationData* wasm_compilation_data,
wasm::FunctionBody function_body, wasm::WasmModule* wasm_module,
wasm::NativeModule* native_module, int function_index,
wasm::ModuleOrigin asmjs_origin) {
return new PipelineWasmCompilationJob(
info, wasm_engine, isolate, mcgraph, call_descriptor, source_positions,
info, wasm_engine, mcgraph, call_descriptor, source_positions,
node_origins, wasm_compilation_data, function_body, wasm_module,
native_module, function_index, asmjs_origin);
}
......@@ -2318,7 +2327,7 @@ bool PipelineImpl::SelectInstructions(Linkage* linkage) {
<< "--- End of " << data->debug_name() << " generated by TurboFan\n"
<< "--------------------------------------------------\n";
}
Zone temp_zone(data->isolate()->allocator(), ZONE_NAME);
Zone temp_zone(data->allocator(), ZONE_NAME);
MachineGraphVerifier::Run(data->graph(), data->schedule(), linkage,
data->info()->IsStub(), data->debug_name(),
&temp_zone);
......@@ -2545,7 +2554,7 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
std::unique_ptr<Zone> verifier_zone;
RegisterAllocatorVerifier* verifier = nullptr;
if (run_verifier) {
verifier_zone.reset(new Zone(isolate()->allocator(), ZONE_NAME));
verifier_zone.reset(new Zone(data->allocator(), ZONE_NAME));
verifier = new (verifier_zone.get()) RegisterAllocatorVerifier(
verifier_zone.get(), config, data->sequence());
}
......
......@@ -49,7 +49,7 @@ class Pipeline : public AllStatic {
// Returns a new compilation job for the WebAssembly compilation info.
static OptimizedCompilationJob* NewWasmCompilationJob(
OptimizedCompilationInfo* info, wasm::WasmEngine* wasm_engine,
Isolate* isolate, MachineGraph* mcgraph, CallDescriptor* call_descriptor,
MachineGraph* mcgraph, CallDescriptor* call_descriptor,
SourcePositionTable* source_positions, NodeOriginTable* node_origins,
WasmCompilationData* wasm_compilation_data,
wasm::FunctionBody function_body, wasm::WasmModule* wasm_module,
......
......@@ -4852,7 +4852,7 @@ MaybeHandle<Code> CompileJSToWasmWrapper(
&zone, false, params + 1, CallDescriptor::kNoFlags);
MaybeHandle<Code> maybe_code = Pipeline::GenerateCodeForTesting(
&info, isolate, incoming, &graph, WasmAssemblerOptions(isolate));
&info, isolate, incoming, &graph, WasmAssemblerOptions());
Handle<Code> code;
if (!maybe_code.ToHandle(&code)) {
return maybe_code;
......@@ -5101,7 +5101,7 @@ SourcePositionTable* TurbofanWasmCompilationUnit::BuildGraphForWasmFunction(
WasmGraphBuilder builder(wasm_unit_->env_, mcgraph->zone(), mcgraph,
wasm_unit_->func_body_.sig, source_position_table);
graph_construction_result_ =
wasm::BuildTFGraph(wasm_unit_->isolate_->allocator(), &builder,
wasm::BuildTFGraph(wasm_unit_->wasm_engine_->allocator(), &builder,
wasm_unit_->func_body_, node_origins);
if (graph_construction_result_.failed()) {
if (FLAG_trace_wasm_compiler) {
......@@ -5123,8 +5123,9 @@ SourcePositionTable* TurbofanWasmCompilationUnit::BuildGraphForWasmFunction(
if (wasm_unit_->func_index_ >= FLAG_trace_wasm_ast_start &&
wasm_unit_->func_index_ < FLAG_trace_wasm_ast_end) {
PrintRawWasmCode(wasm_unit_->isolate_->allocator(), wasm_unit_->func_body_,
wasm_unit_->env_->module, wasm::kPrintLocals);
PrintRawWasmCode(wasm_unit_->wasm_engine_->allocator(),
wasm_unit_->func_body_, wasm_unit_->env_->module,
wasm::kPrintLocals);
}
if (FLAG_trace_wasm_decode_time) {
*decode_ms = decode_timer.Elapsed().InMillisecondsF();
......@@ -5162,7 +5163,7 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation() {
// Scope for the {graph_zone}.
{
Zone graph_zone(wasm_unit_->isolate_->allocator(), ZONE_NAME);
Zone graph_zone(wasm_unit_->wasm_engine_->allocator(), ZONE_NAME);
MachineGraph* mcgraph = new (&graph_zone)
MachineGraph(new (&graph_zone) Graph(&graph_zone),
new (&graph_zone) CommonOperatorBuilder(&graph_zone),
......@@ -5171,7 +5172,7 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation() {
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements()));
Zone compilation_zone(wasm_unit_->isolate_->allocator(), ZONE_NAME);
Zone compilation_zone(wasm_unit_->wasm_engine_->allocator(), ZONE_NAME);
OptimizedCompilationInfo info(
GetDebugName(&compilation_zone, wasm_unit_->func_name_,
......@@ -5210,9 +5211,9 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation() {
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmCompilationJob(
&info, wasm_unit_->isolate_->wasm_engine(), wasm_unit_->isolate_,
mcgraph, call_descriptor, source_positions, node_origins,
&wasm_compilation_data_, wasm_unit_->func_body_,
&info, wasm_unit_->wasm_engine_, mcgraph, call_descriptor,
source_positions, node_origins, &wasm_compilation_data_,
wasm_unit_->func_body_,
const_cast<wasm::WasmModule*>(wasm_unit_->env_->module),
wasm_unit_->native_module_, wasm_unit_->func_index_,
wasm_unit_->env_->module->origin));
......@@ -5446,8 +5447,8 @@ CallDescriptor* GetI32WasmCallDescriptorForSimd(
MachineRepresentation::kWord32);
}
AssemblerOptions WasmAssemblerOptions(Isolate* isolate) {
AssemblerOptions options = AssemblerOptions::Default(isolate);
AssemblerOptions WasmAssemblerOptions() {
AssemblerOptions options;
options.record_reloc_info_for_serialization = true;
options.enable_root_array_delta_access = false;
return options;
......
......@@ -504,7 +504,7 @@ V8_EXPORT_PRIVATE CallDescriptor* GetI32WasmCallDescriptor(
V8_EXPORT_PRIVATE CallDescriptor* GetI32WasmCallDescriptorForSimd(
Zone* zone, CallDescriptor* call_descriptor);
AssemblerOptions WasmAssemblerOptions(Isolate* isolate);
AssemblerOptions WasmAssemblerOptions();
} // namespace compiler
} // namespace internal
......
......@@ -1840,7 +1840,7 @@ bool LiftoffCompilationUnit::ExecuteCompilation() {
compile_timer.Start();
}
Zone zone(wasm_unit_->isolate_->allocator(), "LiftoffCompilationZone");
Zone zone(wasm_unit_->wasm_engine_->allocator(), "LiftoffCompilationZone");
const wasm::WasmModule* module =
wasm_unit_->env_ ? wasm_unit_->env_->module : nullptr;
auto call_descriptor =
......
......@@ -39,8 +39,8 @@ WasmCompilationUnit::WasmCompilationUnit(Isolate* isolate, ModuleEnv* env,
wasm::WasmName name, int index,
CompilationMode mode,
Counters* counters, bool lower_simd)
: isolate_(isolate),
env_(env),
: env_(env),
wasm_engine_(isolate->wasm_engine()),
func_body_(body),
func_name_(name),
counters_(counters ? counters : isolate->counters()),
......
......@@ -20,6 +20,7 @@ class LiftoffCompilationUnit;
struct ModuleWireBytes;
class NativeModule;
class WasmCode;
class WasmEngine;
struct WasmFunction;
enum RuntimeExceptionSupport : bool {
......@@ -83,8 +84,8 @@ class WasmCompilationUnit final {
friend class LiftoffCompilationUnit;
friend class compiler::TurbofanWasmCompilationUnit;
Isolate* isolate_;
ModuleEnv* env_;
WasmEngine* wasm_engine_;
wasm::FunctionBody func_body_;
wasm::WasmName func_name_;
Counters* counters_;
......
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