Commit 88338c2d authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

Revert "[wasm] Add a separate CodeTracer to the WasmEngine."

This reverts commit b7f0951f.

Reason for revert: https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux64%20TSAN/21517

Original change's description:
> [wasm] Add a separate CodeTracer to the WasmEngine.
> 
> This makes sure the TurboFan pipeline is independent of the Isolate by
> getting the CodeTracer from the WasmEngine for WebAssembly compilations.
> 
> R=​clemensh@chromium.org
> 
> Change-Id: I343af1a2bfaeff77e2f41ef0c53fbfe165e2e202
> Reviewed-on: https://chromium-review.googlesource.com/1134997
> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#54455}

TBR=mstarzinger@chromium.org,clemensh@chromium.org

Change-Id: I5f69f12ab29dcb92e7b7f53632eb73a3abc1f6af
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/1138113Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54459}
parent d5998f08
......@@ -21,13 +21,11 @@ class CodeTracer final : public Malloced {
return;
}
if (FLAG_redirect_code_traces_to != nullptr) {
StrNCpy(filename_, FLAG_redirect_code_traces_to, filename_.length());
} else if (isolate_id >= 0) {
if (FLAG_redirect_code_traces_to == nullptr) {
SNPrintF(filename_, "code-%d-%d.asm", base::OS::GetCurrentProcessId(),
isolate_id);
} else {
SNPrintF(filename_, "code-%d.asm", base::OS::GetCurrentProcessId());
StrNCpy(filename_, FLAG_redirect_code_traces_to, filename_.length());
}
WriteChars(filename_.start(), "", 0, false);
......
......@@ -110,7 +110,6 @@ class PipelineData {
may_have_unverifiable_graph_(false),
zone_stats_(zone_stats),
pipeline_statistics_(pipeline_statistics),
code_tracer_(isolate->GetCodeTracer()),
graph_zone_scope_(zone_stats_, ZONE_NAME),
graph_zone_(graph_zone_scope_.zone()),
instruction_zone_scope_(zone_stats_, ZONE_NAME),
......@@ -143,7 +142,7 @@ class PipelineData {
// For WebAssembly compile entry point.
PipelineData(ZoneStats* zone_stats, Isolate* isolate,
OptimizedCompilationInfo* info, MachineGraph* mcgraph,
PipelineStatistics* pipeline_statistics, CodeTracer* code_tracer,
PipelineStatistics* pipeline_statistics,
SourcePositionTable* source_positions,
NodeOriginTable* node_origins,
WasmCompilationData* wasm_compilation_data,
......@@ -155,7 +154,6 @@ class PipelineData {
wasm_function_index_(wasm_function_index),
zone_stats_(zone_stats),
pipeline_statistics_(pipeline_statistics),
code_tracer_(code_tracer),
graph_zone_scope_(zone_stats_, ZONE_NAME),
graph_zone_(graph_zone_scope_.zone()),
graph_(mcgraph->graph()),
......@@ -183,7 +181,6 @@ class PipelineData {
info_(info),
debug_name_(info_->GetDebugName()),
zone_stats_(zone_stats),
code_tracer_(isolate->GetCodeTracer()),
graph_zone_scope_(zone_stats_, ZONE_NAME),
graph_(graph),
source_positions_(source_positions),
......@@ -205,7 +202,6 @@ class PipelineData {
info_(info),
debug_name_(info_->GetDebugName()),
zone_stats_(zone_stats),
code_tracer_(isolate->GetCodeTracer()),
graph_zone_scope_(zone_stats_, ZONE_NAME),
instruction_zone_scope_(zone_stats_, ZONE_NAME),
instruction_zone_(sequence->zone()),
......@@ -230,7 +226,6 @@ class PipelineData {
ZoneStats* zone_stats() const { return zone_stats_; }
CompilationDependencies* dependencies() const { return dependencies_; }
PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; }
CodeTracer* code_tracer() const { return code_tracer_; }
OsrHelper* osr_helper() { return &(*osr_helper_); }
bool compilation_failed() const { return compilation_failed_; }
void set_compilation_failed() { compilation_failed_ = true; }
......@@ -418,7 +413,6 @@ class PipelineData {
bool may_have_unverifiable_graph_ = true;
ZoneStats* const zone_stats_;
PipelineStatistics* pipeline_statistics_ = nullptr;
CodeTracer* const code_tracer_;
bool compilation_failed_ = false;
bool verify_graph_ = false;
int start_source_position_ = kNoSourcePosition;
......@@ -656,7 +650,7 @@ struct TurboCfgFile : public std::ofstream {
std::ios_base::app) {}
};
void TraceSchedule(OptimizedCompilationInfo* info, CodeTracer* code_tracer,
void TraceSchedule(OptimizedCompilationInfo* info, Isolate* isolate,
Schedule* schedule, const char* phase_name) {
if (info->trace_turbo_json_enabled()) {
AllowHandleDereference allow_deref;
......@@ -673,7 +667,7 @@ void TraceSchedule(OptimizedCompilationInfo* info, CodeTracer* code_tracer,
}
if (info->trace_turbo_graph_enabled() || FLAG_trace_turbo_scheduler) {
AllowHandleDereference allow_deref;
CodeTracer::Scope tracing_scope(code_tracer);
CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "-- Schedule --------------------------------------\n" << *schedule;
}
......@@ -994,9 +988,8 @@ class PipelineWasmCompilationJob final : public OptimizedCompilationJob {
pipeline_statistics_(CreatePipelineStatistics(
wasm_engine, function_body, wasm_module, info, &zone_stats_)),
data_(&zone_stats_, isolate, info, mcgraph, pipeline_statistics_.get(),
wasm_engine->GetCodeTracer(), source_positions, node_origins,
wasm_compilation_data, function_index,
WasmAssemblerOptions(isolate)),
source_positions, node_origins, wasm_compilation_data,
function_index, WasmAssemblerOptions(isolate)),
pipeline_(&data_),
linkage_(call_descriptor),
native_module_(native_module),
......@@ -1453,7 +1446,7 @@ struct EffectControlLinearizationPhase {
Schedule* schedule = Scheduler::ComputeSchedule(temp_zone, data->graph(),
Scheduler::kTempSchedule);
if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule);
TraceSchedule(data->info(), data->code_tracer(), schedule,
TraceSchedule(data->info(), data->isolate(), schedule,
"effect linearization schedule");
EffectControlLinearizer::MaskArrayIndexEnable mask_array_index =
......@@ -1901,13 +1894,13 @@ struct PrintGraphPhase {
}
AllowHandleDereference allow_deref;
CodeTracer::Scope tracing_scope(data->code_tracer());
CodeTracer::Scope tracing_scope(data->isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "-- Graph after " << phase << " -- " << std::endl;
os << AsScheduledGraph(schedule);
} else if (info->trace_turbo_graph_enabled()) { // Simple textual RPO.
AllowHandleDereference allow_deref;
CodeTracer::Scope tracing_scope(data->code_tracer());
CodeTracer::Scope tracing_scope(data->isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "-- Graph after " << phase << " -- " << std::endl;
os << AsRPO(*graph);
......@@ -1956,7 +1949,7 @@ bool PipelineImpl::CreateGraph() {
if (info()->trace_turbo_json_enabled() ||
info()->trace_turbo_graph_enabled()) {
CodeTracer::Scope tracing_scope(data->code_tracer());
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "---------------------------------------------------\n"
<< "Begin compiling method " << info()->GetDebugName().get()
......@@ -2140,7 +2133,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
DCHECK_NOT_NULL(data.schedule());
if (info.trace_turbo_json_enabled() || info.trace_turbo_graph_enabled()) {
CodeTracer::Scope tracing_scope(data.code_tracer());
CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "---------------------------------------------------\n"
<< "Begin compiling " << debug_name << " using Turbofan" << std::endl;
......@@ -2155,7 +2148,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
pipeline.Run<PrintGraphPhase>("Machine");
}
TraceSchedule(data.info(), data.code_tracer(), data.schedule(), "schedule");
TraceSchedule(data.info(), data.isolate(), data.schedule(), "schedule");
pipeline.Run<VerifyGraphPhase>(false, true);
return pipeline.GenerateCode(call_descriptor);
......@@ -2276,8 +2269,7 @@ void PipelineImpl::ComputeScheduledGraph() {
RunPrintAndVerify(LateGraphTrimmingPhase::phase_name(), true);
Run<ComputeSchedulePhase>();
TraceSchedule(data->info(), data->code_tracer(), data->schedule(),
"schedule");
TraceSchedule(data->info(), data->isolate(), data->schedule(), "schedule");
}
bool PipelineImpl::SelectInstructions(Linkage* linkage) {
......@@ -2308,7 +2300,7 @@ bool PipelineImpl::SelectInstructions(Linkage* linkage) {
!strcmp(FLAG_turbo_verify_machine_graph, data->debug_name())))) {
if (FLAG_trace_verify_csa) {
AllowHandleDereference allow_deref;
CodeTracer::Scope tracing_scope(data->code_tracer());
CodeTracer::Scope tracing_scope(data->isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "--------------------------------------------------\n"
<< "--- Verifying " << data->debug_name() << " generated by TurboFan\n"
......@@ -2512,7 +2504,7 @@ MaybeHandle<Code> PipelineImpl::FinalizeCode() {
}
if (info()->trace_turbo_json_enabled() ||
info()->trace_turbo_graph_enabled()) {
CodeTracer::Scope tracing_scope(data->code_tracer());
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "---------------------------------------------------\n"
<< "Finished compiling method " << info()->GetDebugName().get()
......@@ -2564,7 +2556,7 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
Run<BuildLiveRangesPhase>();
if (info()->trace_turbo_graph_enabled()) {
AllowHandleDereference allow_deref;
CodeTracer::Scope tracing_scope(data->code_tracer());
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "----- Instruction sequence before register allocation -----\n"
<< PrintableInstructionSequence({config, data->sequence()});
......@@ -2608,7 +2600,7 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
if (info()->trace_turbo_graph_enabled()) {
AllowHandleDereference allow_deref;
CodeTracer::Scope tracing_scope(data->code_tracer());
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
OFStream os(tracing_scope.file());
os << "----- Instruction sequence after register allocation -----\n"
<< PrintableInstructionSequence({config, data->sequence()});
......
......@@ -3344,9 +3344,7 @@ int Shell::Main(int argc, char* argv[]) {
if (i::FLAG_trace_turbo_cfg_file == nullptr) {
SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
}
if (i::FLAG_redirect_code_traces_to == nullptr) {
SetFlagsFromString("--redirect-code-traces-to=code.asm");
}
SetFlagsFromString("--redirect-code-traces-to=code.asm");
int result = 0;
Isolate::CreateParams create_params;
ShellArrayBufferAllocator shell_array_buffer_allocator;
......
......@@ -4,7 +4,6 @@
#include "src/wasm/wasm-engine.h"
#include "src/code-tracer.h"
#include "src/compilation-statistics.h"
#include "src/objects-inl.h"
#include "src/objects/js-promise.h"
......@@ -173,11 +172,6 @@ void WasmEngine::DumpAndResetTurboStatistics() {
compilation_stats_.reset();
}
CodeTracer* WasmEngine::GetCodeTracer() {
if (code_tracer_ == nullptr) code_tracer_.reset(new CodeTracer(-1));
return code_tracer_.get();
}
void WasmEngine::Register(CancelableTaskManager* task_manager) {
task_managers_.emplace_back(task_manager);
}
......
......@@ -14,7 +14,6 @@
namespace v8 {
namespace internal {
class CodeTracer;
class CompilationStatistics;
class WasmModuleObject;
class WasmInstanceObject;
......@@ -100,9 +99,6 @@ class V8_EXPORT_PRIVATE WasmEngine {
// Prints the gathered compilation statistics, then resets them.
void DumpAndResetTurboStatistics();
// Used to redirect tracing output from {stdout} to a file.
CodeTracer* GetCodeTracer();
// We register and unregister CancelableTaskManagers that run engine-dependent
// tasks. These tasks need to be shutdown if the engine is shut down.
void Register(CancelableTaskManager* task_manager);
......@@ -132,7 +128,6 @@ class V8_EXPORT_PRIVATE WasmEngine {
std::unordered_map<AsyncCompileJob*, std::unique_ptr<AsyncCompileJob>> jobs_;
std::unique_ptr<WasmCodeManager> code_manager_;
std::unique_ptr<CompilationStatistics> compilation_stats_;
std::unique_ptr<CodeTracer> code_tracer_;
WasmMemoryTracker memory_tracker_;
AccountingAllocator allocator_;
......
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