Commit fa12290d authored by Stephan Herhut's avatar Stephan Herhut Committed by Commit Bot

[wasm] Avoid workaround for mising source positions

Bug: v8:8015
Change-Id: I6540104f58acd819d5a57edae49f8b909aa1a065
Reviewed-on: https://chromium-review.googlesource.com/1203892Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Stephan Herhut <herhut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55608}
parent 7623d0fa
......@@ -302,9 +302,11 @@ class JSONGraphNodeWriter {
if (opcode == IrOpcode::kBranch) {
os_ << ",\"rankInputs\":[0]";
}
SourcePosition position = positions_->GetSourcePosition(node);
if (position.IsKnown()) {
os_ << ", \"sourcePosition\" : " << AsJSON(position);
if (positions_ != nullptr) {
SourcePosition position = positions_->GetSourcePosition(node);
if (position.IsKnown()) {
os_ << ", \"sourcePosition\" : " << AsJSON(position);
}
}
if (origins_) {
NodeOrigin origin = origins_->GetNodeOrigin(node);
......
......@@ -1081,6 +1081,7 @@ void InstructionSelector::VisitBlock(BasicBlock* block) {
std::reverse(instructions_.begin() + instruction_start,
instructions_.end());
if (!node) return true;
if (!source_positions_) return true;
SourcePosition source_position = source_positions_->GetSourcePosition(node);
if (source_position.IsKnown() && IsSourcePositionUsed(node)) {
sequence()->SetSourcePosition(instructions_[instruction_start],
......
......@@ -2157,10 +2157,9 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
// Construct a pipeline for scheduling and code generation.
ZoneStats zone_stats(isolate->allocator());
SourcePositionTable source_positions(graph);
NodeOriginTable node_origins(graph);
PipelineData data(&zone_stats, &info, isolate, graph, schedule,
&source_positions, &node_origins, jump_opt, options);
PipelineData data(&zone_stats, &info, isolate, graph, schedule, nullptr,
&node_origins, jump_opt, options);
data.set_verify_graph(FLAG_verify_csa);
std::unique_ptr<PipelineStatistics> pipeline_statistics;
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
......@@ -2202,10 +2201,6 @@ MaybeHandle<Code> Pipeline::GenerateCodeForWasmStub(
OptimizedCompilationInfo info(CStrVector(debug_name), graph->zone(), kind);
// Construct a pipeline for scheduling and code generation.
ZoneStats zone_stats(isolate->allocator());
// TODO(wasm): Refactor code generation to check for non-existing source
// table, then remove this conditional allocation.
if (!source_positions)
source_positions = new (graph->zone()) SourcePositionTable(graph);
NodeOriginTable* node_positions = new (graph->zone()) NodeOriginTable(graph);
PipelineData data(&zone_stats, &info, isolate, graph, nullptr,
source_positions, node_positions, nullptr, options);
......@@ -2269,17 +2264,12 @@ MaybeHandle<Code> Pipeline::GenerateCodeForTesting(
MaybeHandle<Code> Pipeline::GenerateCodeForTesting(
OptimizedCompilationInfo* info, Isolate* isolate,
CallDescriptor* call_descriptor, Graph* graph,
const AssemblerOptions& options, Schedule* schedule,
SourcePositionTable* source_positions) {
const AssemblerOptions& options, Schedule* schedule) {
// Construct a pipeline for scheduling and code generation.
ZoneStats zone_stats(isolate->allocator());
// TODO(wasm): Refactor code generation to check for non-existing source
// table, then remove this conditional allocation.
if (!source_positions)
source_positions = new (info->zone()) SourcePositionTable(graph);
NodeOriginTable* node_positions = new (info->zone()) NodeOriginTable(graph);
PipelineData data(&zone_stats, info, isolate, graph, schedule,
source_positions, node_positions, nullptr, options);
PipelineData data(&zone_stats, info, isolate, graph, schedule, nullptr,
node_positions, nullptr, options);
std::unique_ptr<PipelineStatistics> pipeline_statistics;
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.reset(new PipelineStatistics(
......@@ -2423,7 +2413,11 @@ bool PipelineImpl::SelectInstructions(Linkage* linkage) {
if (info()->trace_turbo_json_enabled()) {
std::ostringstream source_position_output;
// Output source position information before the graph is deleted.
data_->source_positions()->PrintJson(source_position_output);
if (data_->source_positions() != nullptr) {
data_->source_positions()->PrintJson(source_position_output);
} else {
source_position_output << "{}";
}
source_position_output << ",\n\"NodeOrigins\" : ";
data_->node_origins()->PrintJson(source_position_output);
data_->set_source_position_output(source_position_output.str());
......
......@@ -83,8 +83,7 @@ class Pipeline : public AllStatic {
V8_EXPORT_PRIVATE static MaybeHandle<Code> GenerateCodeForTesting(
OptimizedCompilationInfo* info, Isolate* isolate,
CallDescriptor* call_descriptor, Graph* graph,
const AssemblerOptions& options, Schedule* schedule = nullptr,
SourcePositionTable* source_positions = nullptr);
const AssemblerOptions& options, Schedule* schedule = nullptr);
// Run just the register allocator phases.
V8_EXPORT_PRIVATE static bool AllocateRegistersForTesting(
......
......@@ -363,7 +363,7 @@ Handle<Code> WasmFunctionWrapper::GetWrapperCode() {
Code::C_WASM_ENTRY);
code_ = compiler::Pipeline::GenerateCodeForTesting(
&info, isolate, call_descriptor, graph(),
AssemblerOptions::Default(isolate), nullptr);
AssemblerOptions::Default(isolate));
code = code_.ToHandleChecked();
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_opt_code) {
......
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