Commit 0a60924e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Fix --trace-turbo handle dereferences.

Whenever tracing is activated we disable concurrent compilation. Hence
all tracing functions can safely dereference all handles. This fixes the
tracing functionality by annotating tracing functions with proper scopes.

R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/1976123002
Cr-Commit-Position: refs/heads/master@{#36241}
parent 7b1fe365
...@@ -403,6 +403,7 @@ struct TurboCfgFile : public std::ofstream { ...@@ -403,6 +403,7 @@ struct TurboCfgFile : public std::ofstream {
void TraceSchedule(CompilationInfo* info, Schedule* schedule) { void TraceSchedule(CompilationInfo* info, Schedule* schedule) {
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
AllowHandleDereference allow_deref;
FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+"); FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+");
if (json_file != nullptr) { if (json_file != nullptr) {
OFStream json_of(json_file); OFStream json_of(json_file);
...@@ -417,9 +418,11 @@ void TraceSchedule(CompilationInfo* info, Schedule* schedule) { ...@@ -417,9 +418,11 @@ void TraceSchedule(CompilationInfo* info, Schedule* schedule) {
fclose(json_file); fclose(json_file);
} }
} }
if (!FLAG_trace_turbo_graph && !FLAG_trace_turbo_scheduler) return; if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) {
OFStream os(stdout); AllowHandleDereference allow_deref;
os << "-- Schedule --------------------------------------\n" << *schedule; OFStream os(stdout);
os << "-- Schedule --------------------------------------\n" << *schedule;
}
} }
...@@ -1305,6 +1308,7 @@ struct PrintGraphPhase { ...@@ -1305,6 +1308,7 @@ struct PrintGraphPhase {
Graph* graph = data->graph(); Graph* graph = data->graph();
{ // Print JSON. { // Print JSON.
AllowHandleDereference allow_deref;
FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+"); FILE* json_file = OpenVisualizerLogFile(info, nullptr, "json", "a+");
if (json_file == nullptr) return; if (json_file == nullptr) return;
OFStream json_of(json_file); OFStream json_of(json_file);
...@@ -1314,6 +1318,7 @@ struct PrintGraphPhase { ...@@ -1314,6 +1318,7 @@ struct PrintGraphPhase {
} }
if (FLAG_trace_turbo_graph) { // Simple textual RPO. if (FLAG_trace_turbo_graph) { // Simple textual RPO.
AllowHandleDereference allow_deref;
OFStream os(stdout); OFStream os(stdout);
os << "-- Graph after " << phase << " -- " << std::endl; os << "-- Graph after " << phase << " -- " << std::endl;
os << AsRPO(*graph); os << AsRPO(*graph);
...@@ -1620,6 +1625,7 @@ bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage) { ...@@ -1620,6 +1625,7 @@ bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage) {
Run<InstructionSelectionPhase>(linkage); Run<InstructionSelectionPhase>(linkage);
if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) {
AllowHandleDereference allow_deref;
TurboCfgFile tcf(isolate()); TurboCfgFile tcf(isolate());
tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(),
data->sequence()); data->sequence());
...@@ -1751,10 +1757,10 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, ...@@ -1751,10 +1757,10 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
Run<ResolvePhisPhase>(); Run<ResolvePhisPhase>();
Run<BuildLiveRangesPhase>(); Run<BuildLiveRangesPhase>();
if (FLAG_trace_turbo_graph) { if (FLAG_trace_turbo_graph) {
AllowHandleDereference allow_deref;
OFStream os(stdout); OFStream os(stdout);
PrintableInstructionSequence printable = {config, data->sequence()};
os << "----- Instruction sequence before register allocation -----\n" os << "----- Instruction sequence before register allocation -----\n"
<< printable; << PrintableInstructionSequence({config, data->sequence()});
} }
if (verifier != nullptr) { if (verifier != nullptr) {
CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition()); CHECK(!data->register_allocation_data()->ExistsUseWithoutDefinition());
...@@ -1791,10 +1797,10 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, ...@@ -1791,10 +1797,10 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
Run<LocateSpillSlotsPhase>(); Run<LocateSpillSlotsPhase>();
if (FLAG_trace_turbo_graph) { if (FLAG_trace_turbo_graph) {
AllowHandleDereference allow_deref;
OFStream os(stdout); OFStream os(stdout);
PrintableInstructionSequence printable = {config, data->sequence()};
os << "----- Instruction sequence after register allocation -----\n" os << "----- Instruction sequence after register allocation -----\n"
<< printable; << PrintableInstructionSequence({config, data->sequence()});
} }
if (verifier != nullptr) { if (verifier != nullptr) {
......
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