Commit d97d095a authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Show for each node from which node it was created from

This also includes the precise reducer name. Currently the information
is available in the node tooltip in turbolizer. The new shortcut 's' in
the graph view selects the nodes the currently selected nodes were created
from.

Bug: v8:7327
Change-Id: I7ca7327d0cfa112972e3567df6e4a223c8eff3c0
Reviewed-on: https://chromium-review.googlesource.com/1064059
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53258}
parent cf00b353
......@@ -1719,6 +1719,8 @@ v8_source_set("v8_base") {
"src/compiler/node-marker.h",
"src/compiler/node-matchers.cc",
"src/compiler/node-matchers.h",
"src/compiler/node-origin-table.cc",
"src/compiler/node-origin-table.h",
"src/compiler/node-properties.cc",
"src/compiler/node-properties.h",
"src/compiler/node.cc",
......
......@@ -10,6 +10,7 @@
#include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/node.h"
#include "src/compiler/schedule.h"
......@@ -21,13 +22,14 @@ namespace compiler {
EffectControlLinearizer::EffectControlLinearizer(
JSGraph* js_graph, Schedule* schedule, Zone* temp_zone,
SourcePositionTable* source_positions,
SourcePositionTable* source_positions, NodeOriginTable* node_origins,
MaskArrayIndexEnable mask_array_index)
: js_graph_(js_graph),
schedule_(schedule),
temp_zone_(temp_zone),
mask_array_index_(mask_array_index),
source_positions_(source_positions),
node_origins_(node_origins),
graph_assembler_(js_graph, nullptr, nullptr, temp_zone),
frame_state_zapper_(nullptr) {}
......@@ -167,7 +169,8 @@ void RemoveRenameNode(Node* node) {
void TryCloneBranch(Node* node, BasicBlock* block, Zone* temp_zone,
Graph* graph, CommonOperatorBuilder* common,
BlockEffectControlMap* block_effects,
SourcePositionTable* source_positions) {
SourcePositionTable* source_positions,
NodeOriginTable* node_origins) {
DCHECK_EQ(IrOpcode::kBranch, node->opcode());
// This optimization is a special case of (super)block cloning. It takes an
......@@ -221,6 +224,7 @@ void TryCloneBranch(Node* node, BasicBlock* block, Zone* temp_zone,
SourcePositionTable::Scope scope(source_positions,
source_positions->GetSourcePosition(node));
NodeOriginTable::Scope origin_scope(node_origins, "clone branch", node);
Node* branch = node;
Node* cond = NodeProperties::GetValueInput(branch, 0);
if (!cond->OwnedBy(branch) || cond->opcode() != IrOpcode::kPhi) return;
......@@ -484,7 +488,8 @@ void EffectControlLinearizer::Run() {
case BasicBlock::kBranch:
ProcessNode(block->control_input(), &frame_state, &effect, &control);
TryCloneBranch(block->control_input(), block, temp_zone(), graph(),
common(), &block_effects, source_positions_);
common(), &block_effects, source_positions_,
node_origins_);
break;
}
......@@ -516,6 +521,7 @@ void EffectControlLinearizer::ProcessNode(Node* node, Node** frame_state,
Node** effect, Node** control) {
SourcePositionTable::Scope scope(source_positions_,
source_positions_->GetSourcePosition(node));
NodeOriginTable::Scope origin_scope(node_origins_, "process node", node);
// If the node needs to be wired into the effect/control chain, do this
// here. Pass current frame state for lowering to eager deoptimization.
......
......@@ -27,6 +27,7 @@ class JSGraph;
class Graph;
class Schedule;
class SourcePositionTable;
class NodeOriginTable;
class V8_EXPORT_PRIVATE EffectControlLinearizer {
public:
......@@ -34,6 +35,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
EffectControlLinearizer(JSGraph* graph, Schedule* schedule, Zone* temp_zone,
SourcePositionTable* source_positions,
NodeOriginTable* node_origins,
MaskArrayIndexEnable mask_array_index);
void Run();
......@@ -213,6 +215,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
MaskArrayIndexEnable mask_array_index_;
RegionObservability region_observability_ = RegionObservability::kObservable;
SourcePositionTable* source_positions_;
NodeOriginTable* node_origins_;
GraphAssembler graph_assembler_;
Node* frame_state_zapper_; // For tracking down compiler::Node::New crashes.
};
......
......@@ -12,6 +12,7 @@
#include "src/compiler/all-nodes.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/graph.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/node.h"
#include "src/compiler/opcodes.h"
......@@ -44,6 +45,11 @@ std::ostream& operator<<(std::ostream& out,
return out;
}
std::ostream& operator<<(std::ostream& out, const NodeOriginAsJSON& asJSON) {
asJSON.no.PrintJson(out);
return out;
}
void JsonPrintFunctionSource(std::ostream& os, int source_id,
std::unique_ptr<char[]> function_name,
Handle<Script> script, Isolate* isolate,
......@@ -245,11 +251,13 @@ class JSONEscaped {
class JSONGraphNodeWriter {
public:
JSONGraphNodeWriter(std::ostream& os, Zone* zone, const Graph* graph,
const SourcePositionTable* positions)
const SourcePositionTable* positions,
const NodeOriginTable* origins)
: os_(os),
all_(zone, graph, false),
live_(zone, graph, true),
positions_(positions),
origins_(origins),
first_node_(true) {}
void Print() {
......@@ -290,6 +298,12 @@ class JSONGraphNodeWriter {
if (position.IsKnown()) {
os_ << ", \"sourcePosition\" : " << AsJSON(position);
}
if (origins_) {
NodeOrigin origin = origins_->GetNodeOrigin(node);
if (origin.IsKnown()) {
os_ << ", \"origin\" : " << AsJSON(origin);
}
}
os_ << ",\"opcode\":\"" << IrOpcode::Mnemonic(node->opcode()) << "\"";
os_ << ",\"control\":" << (NodeProperties::IsControl(node) ? "true"
: "false");
......@@ -313,6 +327,7 @@ class JSONGraphNodeWriter {
AllNodes all_;
AllNodes live_;
const SourcePositionTable* positions_;
const NodeOriginTable* origins_;
bool first_node_;
DISALLOW_COPY_AND_ASSIGN(JSONGraphNodeWriter);
......@@ -373,7 +388,8 @@ std::ostream& operator<<(std::ostream& os, const GraphAsJSON& ad) {
AccountingAllocator allocator;
Zone tmp_zone(&allocator, ZONE_NAME);
os << "{\n\"nodes\":[";
JSONGraphNodeWriter(os, &tmp_zone, &ad.graph, ad.positions).Print();
JSONGraphNodeWriter(os, &tmp_zone, &ad.graph, ad.positions, ad.origins)
.Print();
os << "],\n\"edges\":[";
JSONGraphEdgeWriter(os, &tmp_zone, &ad.graph).Print();
os << "]}";
......
......@@ -22,6 +22,8 @@ namespace compiler {
class Graph;
class InstructionSequence;
class NodeOrigin;
class NodeOriginTable;
class RegisterAllocationData;
class Schedule;
class SourcePositionTable;
......@@ -40,6 +42,15 @@ AsJSON(const SourcePosition& sp) {
return SourcePositionAsJSON(sp);
}
struct NodeOriginAsJSON {
explicit NodeOriginAsJSON(const NodeOrigin& no) : no(no) {}
const NodeOrigin& no;
};
V8_INLINE V8_EXPORT_PRIVATE NodeOriginAsJSON AsJSON(const NodeOrigin& no) {
return NodeOriginAsJSON(no);
}
std::ostream& operator<<(std::ostream& out, const SourcePositionAsJSON& pos);
// Small helper that deduplicates SharedFunctionInfos.
......@@ -72,15 +83,17 @@ std::unique_ptr<char[]> GetVisualizerLogFileName(OptimizedCompilationInfo* info,
const char* suffix);
struct GraphAsJSON {
GraphAsJSON(const Graph& g, SourcePositionTable* p)
: graph(g), positions(p) {}
GraphAsJSON(const Graph& g, SourcePositionTable* p, NodeOriginTable* o)
: graph(g), positions(p), origins(o) {}
const Graph& graph;
const SourcePositionTable* positions;
const NodeOriginTable* origins;
};
V8_INLINE V8_EXPORT_PRIVATE GraphAsJSON AsJSON(const Graph& g,
SourcePositionTable* p) {
return GraphAsJSON(g, p);
SourcePositionTable* p,
NodeOriginTable* o) {
return GraphAsJSON(g, p, o);
}
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
......
......@@ -7,6 +7,7 @@
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/graph.h"
#include "src/compiler/node-marker.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/node.h"
#include "src/zone/zone.h"
......@@ -123,12 +124,14 @@ struct Peeling {
}
void CopyNodes(Graph* graph, Zone* tmp_zone_, Node* dead, NodeRange nodes,
SourcePositionTable* source_positions) {
SourcePositionTable* source_positions,
NodeOriginTable* node_origins) {
NodeVector inputs(tmp_zone_);
// Copy all the nodes first.
for (Node* node : nodes) {
SourcePositionTable::Scope position(
source_positions, source_positions->GetSourcePosition(node));
NodeOriginTable::Scope origin_scope(node_origins, "copy nodes", node);
inputs.clear();
for (Node* input : node->inputs()) {
inputs.push_back(map(input));
......@@ -226,7 +229,7 @@ PeeledIteration* LoopPeeler::Peel(LoopTree::Loop* loop) {
// Copy all the nodes of loop body for the peeled iteration.
peeling.CopyNodes(graph_, tmp_zone_, dead, loop_tree_->BodyNodes(loop),
source_positions_);
source_positions_, node_origins_);
//============================================================================
// Replace the entry to the loop with the output of the peeled iteration.
......
......@@ -13,6 +13,7 @@ namespace v8 {
namespace internal {
namespace compiler {
class NodeOriginTable;
class SourcePositionTable;
// Represents the output of peeling a loop, which is basically the mapping
......@@ -34,12 +35,14 @@ class CommonOperatorBuilder;
class V8_EXPORT_PRIVATE LoopPeeler {
public:
LoopPeeler(Graph* graph, CommonOperatorBuilder* common, LoopTree* loop_tree,
Zone* tmp_zone, SourcePositionTable* source_positions)
Zone* tmp_zone, SourcePositionTable* source_positions,
NodeOriginTable* node_origins)
: graph_(graph),
common_(common),
loop_tree_(loop_tree),
tmp_zone_(tmp_zone),
source_positions_(source_positions) {}
source_positions_(source_positions),
node_origins_(node_origins) {}
bool CanPeel(LoopTree::Loop* loop);
PeeledIteration* Peel(LoopTree::Loop* loop);
void PeelInnerLoopsOfTree();
......@@ -53,6 +56,7 @@ class V8_EXPORT_PRIVATE LoopPeeler {
LoopTree* const loop_tree_;
Zone* const tmp_zone_;
SourcePositionTable* const source_positions_;
NodeOriginTable* const node_origins_;
void PeelInnerLoops(LoopTree::Loop* loop);
};
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/node-origin-table.h"
#include "src/compiler/graph.h"
#include "src/compiler/node-aux-data.h"
namespace v8 {
namespace internal {
namespace compiler {
void NodeOrigin::PrintJson(std::ostream& out) const {
out << "{ "
<< "\"nodeId\" : " << created_from() << ", \"reducer\" : \""
<< reducer_name() << "\""
<< "}";
}
class NodeOriginTable::Decorator final : public GraphDecorator {
public:
explicit Decorator(NodeOriginTable* origins) : origins_(origins) {}
void Decorate(Node* node) final {
origins_->SetNodeOrigin(node, origins_->current_origin_);
}
private:
NodeOriginTable* origins_;
};
NodeOriginTable::NodeOriginTable(Graph* graph)
: graph_(graph),
decorator_(nullptr),
current_origin_(NodeOrigin::Unknown()),
table_(graph->zone()) {}
void NodeOriginTable::AddDecorator() {
DCHECK_NULL(decorator_);
decorator_ = new (graph_->zone()) Decorator(this);
graph_->AddDecorator(decorator_);
}
void NodeOriginTable::RemoveDecorator() {
DCHECK_NOT_NULL(decorator_);
graph_->RemoveDecorator(decorator_);
decorator_ = nullptr;
}
NodeOrigin NodeOriginTable::GetNodeOrigin(Node* node) const {
return table_.Get(node);
}
void NodeOriginTable::SetNodeOrigin(Node* node, const NodeOrigin& no) {
table_.Set(node, no);
}
void NodeOriginTable::PrintJson(std::ostream& os) const {
os << "{";
bool needs_comma = false;
for (auto i : table_) {
NodeOrigin no = i.second;
if (no.IsKnown()) {
if (needs_comma) {
os << ",";
}
os << "\"" << i.first << "\""
<< ": ";
no.PrintJson(os);
needs_comma = true;
}
}
os << "}";
}
} // namespace compiler
} // namespace internal
} // namespace v8
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILER_NODE_ORIGIN_TABLE_H_
#define V8_COMPILER_NODE_ORIGIN_TABLE_H_
#include <limits>
#include "src/base/compiler-specific.h"
#include "src/compiler/node-aux-data.h"
#include "src/globals.h"
#include "src/source-position.h"
namespace v8 {
namespace internal {
namespace compiler {
class NodeOrigin {
public:
NodeOrigin(const char* reducer_name, NodeId created_from)
: reducer_name_(reducer_name), created_from_(created_from) {}
NodeOrigin(const NodeOrigin& other) = default;
static NodeOrigin Unknown() { return NodeOrigin(); }
bool IsKnown() { return created_from_ >= 0; }
int64_t created_from() const { return created_from_; }
const char* reducer_name() const { return reducer_name_; }
bool operator==(const NodeOrigin& o) const {
return reducer_name_ == o.reducer_name_ && created_from_ == o.created_from_;
}
void PrintJson(std::ostream& out) const;
private:
NodeOrigin()
: reducer_name_(""), created_from_(std::numeric_limits<int64_t>::min()) {}
const char* reducer_name_;
int64_t created_from_;
};
inline bool operator!=(const NodeOrigin& lhs, const NodeOrigin& rhs) {
return !(lhs == rhs);
}
class V8_EXPORT_PRIVATE NodeOriginTable final
: public NON_EXPORTED_BASE(ZoneObject) {
public:
class Scope final {
public:
Scope(NodeOriginTable* origins, const char* reducer_name, Node* node)
: origins_(origins), prev_origin_(NodeOrigin::Unknown()) {
if (origins) {
prev_origin_ = origins->current_origin_;
origins->current_origin_ = NodeOrigin(reducer_name, node->id());
}
}
~Scope() {
if (origins_) origins_->current_origin_ = prev_origin_;
}
private:
NodeOriginTable* const origins_;
NodeOrigin prev_origin_;
DISALLOW_COPY_AND_ASSIGN(Scope);
};
explicit NodeOriginTable(Graph* graph);
void AddDecorator();
void RemoveDecorator();
NodeOrigin GetNodeOrigin(Node* node) const;
void SetNodeOrigin(Node* node, const NodeOrigin& no);
void SetCurrentPosition(const NodeOrigin& no) { current_origin_ = no; }
void PrintJson(std::ostream& os) const;
private:
class Decorator;
Graph* const graph_;
Decorator* decorator_;
NodeOrigin current_origin_;
NodeAuxData<NodeOrigin, NodeOrigin::Unknown> table_;
DISALLOW_COPY_AND_ASSIGN(NodeOriginTable);
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_NODE_ORIGIN_TABLE_H_
This diff is collapsed.
......@@ -30,6 +30,7 @@ class CallDescriptor;
class Graph;
class InstructionSequence;
class MachineGraph;
class NodeOriginTable;
class Schedule;
class SourcePositionTable;
class WasmCompilationData;
......@@ -44,7 +45,7 @@ class Pipeline : public AllStatic {
static OptimizedCompilationJob* NewWasmCompilationJob(
OptimizedCompilationInfo* info, Isolate* isolate, MachineGraph* mcgraph,
CallDescriptor* call_descriptor, SourcePositionTable* source_positions,
WasmCompilationData* wasm_compilation_data,
NodeOriginTable* node_origins, WasmCompilationData* wasm_compilation_data,
wasm::ModuleOrigin wasm_origin);
// Run the pipeline on a machine graph and generate code. The {schedule} must
......
......@@ -15,6 +15,7 @@
#include "src/compiler/diamond.h"
#include "src/compiler/linkage.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/operation-typer.h"
#include "src/compiler/operator-properties.h"
......@@ -287,7 +288,8 @@ class RepresentationSelector {
RepresentationSelector(JSGraph* jsgraph, Zone* zone,
RepresentationChanger* changer,
SourcePositionTable* source_positions)
SourcePositionTable* source_positions,
NodeOriginTable* node_origins)
: jsgraph_(jsgraph),
zone_(zone),
count_(jsgraph->graph()->NodeCount()),
......@@ -302,6 +304,7 @@ class RepresentationSelector {
queue_(zone),
typing_stack_(zone),
source_positions_(source_positions),
node_origins_(node_origins),
type_cache_(TypeCache::Get()),
op_typer_(jsgraph->isolate(), graph_zone()) {
}
......@@ -621,6 +624,8 @@ class RepresentationSelector {
// Reuse {VisitNode()} so the representation rules are in one place.
SourcePositionTable::Scope scope(
source_positions_, source_positions_->GetSourcePosition(node));
NodeOriginTable::Scope origin_scope(node_origins_, "simplified lowering",
node);
VisitNode(node, info->truncation(), lowering);
}
......@@ -3235,6 +3240,7 @@ class RepresentationSelector {
// lowering. Once this phase becomes a vanilla reducer, it should get source
// position information via the SourcePositionWrapper like all other reducers.
SourcePositionTable* source_positions_;
NodeOriginTable* node_origins_;
TypeCache const& type_cache_;
OperationTyper op_typer_; // helper for the feedback typer
......@@ -3248,17 +3254,19 @@ class RepresentationSelector {
SimplifiedLowering::SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
SourcePositionTable* source_positions,
NodeOriginTable* node_origins,
PoisoningMitigationLevel poisoning_level)
: jsgraph_(jsgraph),
zone_(zone),
type_cache_(TypeCache::Get()),
source_positions_(source_positions),
node_origins_(node_origins),
poisoning_level_(poisoning_level) {}
void SimplifiedLowering::LowerAllNodes() {
RepresentationChanger changer(jsgraph(), jsgraph()->isolate());
RepresentationSelector selector(jsgraph(), zone_, &changer,
source_positions_);
RepresentationSelector selector(jsgraph(), zone_, &changer, source_positions_,
node_origins_);
selector.Run(this);
}
......
......@@ -15,6 +15,7 @@ namespace internal {
namespace compiler {
// Forward declarations.
class NodeOriginTable;
class RepresentationChanger;
class RepresentationSelector;
class SourcePositionTable;
......@@ -24,6 +25,7 @@ class V8_EXPORT_PRIVATE SimplifiedLowering final {
public:
SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
SourcePositionTable* source_position,
NodeOriginTable* node_origins,
PoisoningMitigationLevel poisoning_level);
~SimplifiedLowering() {}
......@@ -59,6 +61,7 @@ class V8_EXPORT_PRIVATE SimplifiedLowering final {
// lowering. Once this phase becomes a vanilla reducer, it should get source
// position information via the SourcePositionWrapper like all other reducers.
SourcePositionTable* source_positions_;
NodeOriginTable* node_origins_;
PoisoningMitigationLevel poisoning_level_;
......
......@@ -28,6 +28,7 @@
#include "src/compiler/linkage.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/pipeline.h"
#include "src/compiler/simd-scalar-lowering.h"
#include "src/compiler/zone-stats.h"
......@@ -5110,9 +5111,14 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation() {
wasm_unit_->func_index_),
compilation_zone_.get(), Code::WASM_FUNCTION));
NodeOriginTable* node_origins = info_->trace_turbo_graph_enabled()
? new (&graph_zone)
NodeOriginTable(mcgraph_->graph())
: nullptr;
job_.reset(Pipeline::NewWasmCompilationJob(
info_.get(), wasm_unit_->isolate_, mcgraph_, call_descriptor,
source_positions, &wasm_compilation_data_,
source_positions, node_origins, &wasm_compilation_data_,
wasm_unit_->env_->module->origin()));
ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED;
// TODO(bradnelson): Improve histogram handling of size_t.
......
......@@ -8,6 +8,7 @@
#include "src/compiler/graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node.h"
#include "src/compiler/operator.h"
#include "src/compiler/schedule.h"
......@@ -40,7 +41,8 @@ TEST(NodeWithNullInputReachableFromEnd) {
OFStream os(stdout);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
NodeOriginTable table2(&graph);
os << AsJSON(graph, &table, &table2);
}
......@@ -59,7 +61,8 @@ TEST(NodeWithNullControlReachableFromEnd) {
OFStream os(stdout);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
NodeOriginTable table2(&graph);
os << AsJSON(graph, &table, &table2);
}
......@@ -78,7 +81,8 @@ TEST(NodeWithNullInputReachableFromStart) {
OFStream os(stdout);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
NodeOriginTable table2(&graph);
os << AsJSON(graph, &table, &table2);
}
......@@ -95,7 +99,8 @@ TEST(NodeWithNullControlReachableFromStart) {
OFStream os(stdout);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
NodeOriginTable table2(&graph);
os << AsJSON(graph, &table, &table2);
}
......@@ -122,7 +127,8 @@ TEST(NodeNetworkOfDummiesReachableFromEnd) {
OFStream os(stdout);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
NodeOriginTable table2(&graph);
os << AsJSON(graph, &table, &table2);
}
} // namespace compiler
......
......@@ -6,6 +6,7 @@
#include "src/bit-vector.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/graph-visualizer.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/zone/zone-containers.h"
#include "test/unittests/compiler/graph-unittest.h"
......@@ -32,7 +33,8 @@ class ControlEquivalenceTest : public GraphTest {
if (FLAG_trace_turbo) {
OFStream os(stdout);
SourcePositionTable table(graph());
os << AsJSON(*graph(), &table);
NodeOriginTable table2(graph());
os << AsJSON(*graph(), &table, &table2);
}
ControlEquivalence equivalence(zone(), graph());
equivalence.Run(node);
......
......@@ -7,6 +7,7 @@
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/schedule.h"
#include "src/compiler/simplified-operator.h"
......@@ -32,11 +33,13 @@ class EffectControlLinearizerTest : public GraphTest {
jsgraph_(isolate(), graph(), common(), &javascript_, &simplified_,
&machine_) {
source_positions_ = new (zone()) SourcePositionTable(graph());
node_origins_ = new (zone()) NodeOriginTable(graph());
}
JSGraph* jsgraph() { return &jsgraph_; }
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
SourcePositionTable* source_positions() { return source_positions_; }
NodeOriginTable* node_origins() { return node_origins_; }
private:
MachineOperatorBuilder machine_;
......@@ -44,6 +47,7 @@ class EffectControlLinearizerTest : public GraphTest {
SimplifiedOperatorBuilder simplified_;
JSGraph jsgraph_;
SourcePositionTable* source_positions_;
NodeOriginTable* node_origins_;
};
namespace {
......@@ -82,7 +86,7 @@ TEST_F(EffectControlLinearizerTest, SimpleLoad) {
// Run the state effect introducer.
EffectControlLinearizer introducer(
jsgraph(), &schedule, zone(), source_positions(),
jsgraph(), &schedule, zone(), source_positions(), node_origins(),
EffectControlLinearizer::kDoNotMaskArrayIndex);
introducer.Run();
......@@ -145,7 +149,7 @@ TEST_F(EffectControlLinearizerTest, DiamondLoad) {
// Run the state effect introducer.
EffectControlLinearizer introducer(
jsgraph(), &schedule, zone(), source_positions(),
jsgraph(), &schedule, zone(), source_positions(), node_origins(),
EffectControlLinearizer::kDoNotMaskArrayIndex);
introducer.Run();
......@@ -213,7 +217,7 @@ TEST_F(EffectControlLinearizerTest, LoopLoad) {
// Run the state effect introducer.
EffectControlLinearizer introducer(
jsgraph(), &schedule, zone(), source_positions(),
jsgraph(), &schedule, zone(), source_positions(), node_origins(),
EffectControlLinearizer::kDoNotMaskArrayIndex);
introducer.Run();
......@@ -277,7 +281,7 @@ TEST_F(EffectControlLinearizerTest, CloneBranch) {
schedule.AddNode(mblock, graph()->end());
EffectControlLinearizer introducer(
jsgraph(), &schedule, zone(), source_positions(),
jsgraph(), &schedule, zone(), source_positions(), node_origins(),
EffectControlLinearizer::kDoNotMaskArrayIndex);
introducer.Run();
......
......@@ -18,7 +18,8 @@ GraphTest::GraphTest(int num_parameters)
TestWithIsolateAndZone(),
common_(zone()),
graph_(zone()),
source_positions_(&graph_) {
source_positions_(&graph_),
node_origins_(&graph_) {
graph()->SetStart(graph()->NewNode(common()->Start(num_parameters)));
graph()->SetEnd(graph()->NewNode(common()->End(1), graph()->start()));
}
......
......@@ -8,6 +8,7 @@
#include "src/compiler/common-operator.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/graph.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/typer.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -60,11 +61,13 @@ class GraphTest : public virtual TestWithNativeContext,
CommonOperatorBuilder* common() { return &common_; }
Graph* graph() { return &graph_; }
SourcePositionTable* source_positions() { return &source_positions_; }
NodeOriginTable* node_origins() { return &node_origins_; }
private:
CommonOperatorBuilder common_;
Graph graph_;
SourcePositionTable source_positions_;
NodeOriginTable node_origins_;
};
......
......@@ -74,7 +74,8 @@ class LoopPeelingTest : public GraphTest {
PeeledIteration* PeelOne() {
LoopTree* loop_tree = GetLoopTree();
LoopTree::Loop* loop = loop_tree->outer_loops()[0];
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions());
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions(),
node_origins());
EXPECT_TRUE(peeler.CanPeel(loop));
return Peel(peeler, loop);
}
......@@ -250,7 +251,8 @@ TEST_F(LoopPeelingTest, SimpleNestedLoopWithCounter_peel_inner) {
EXPECT_NE(nullptr, loop);
EXPECT_EQ(1u, loop->depth());
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions());
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions(),
node_origins());
PeeledIteration* peeled = Peel(peeler, loop);
ExpectNotPeeled(outer.loop, peeled);
......@@ -290,7 +292,8 @@ TEST_F(LoopPeelingTest, SimpleInnerCounter_peel_inner) {
EXPECT_NE(nullptr, loop);
EXPECT_EQ(1u, loop->depth());
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions());
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions(),
node_origins());
PeeledIteration* peeled = Peel(peeler, loop);
ExpectNotPeeled(outer.loop, peeled);
......@@ -519,7 +522,8 @@ TEST_F(LoopPeelingTest, SimpleLoopWithUnmarkedExit) {
{
LoopTree* loop_tree = GetLoopTree();
LoopTree::Loop* loop = loop_tree->outer_loops()[0];
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions());
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions(),
node_origins());
EXPECT_FALSE(peeler.CanPeel(loop));
}
}
......
......@@ -9,6 +9,7 @@
#include "src/compiler/graph-visualizer.h"
#include "src/compiler/graph.h"
#include "src/compiler/js-operator.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"
......@@ -34,7 +35,8 @@ class SchedulerTest : public TestWithIsolateAndZone {
if (FLAG_trace_turbo) {
OFStream os(stdout);
SourcePositionTable table(graph());
os << AsJSON(*graph(), &table);
NodeOriginTable table2(graph());
os << AsJSON(*graph(), &table, &table2);
}
Schedule* schedule =
......
......@@ -47,6 +47,7 @@ class SimplifiedLoweringTest : public GraphTest {
}
SimplifiedLowering lowering(jsgraph(), zone(), source_positions(),
node_origins(),
PoisoningMitigationLevel::kDontPoison);
lowering.LowerAllNodes();
}
......
......@@ -621,6 +621,10 @@ class GraphView extends View {
eventHandled = false;
}
break;
case 83:
// 's'
graph.selectOrigins();
break;
case 191:
// '/'
document.getElementById("search-input").focus();
......@@ -646,6 +650,22 @@ class GraphView extends View {
layoutNodeGraph(this);
}
selectOrigins() {
const state = this.state;
const origins = [];
for (const n of state.selection) {
if (n.origin) {
const node = this.nodeMap[n.origin.nodeId];
origins.push(node);
}
}
if (origins.length) {
state.selection.clear();
state.selection.select(origins, true);
this.updateGraphVisibility();
}
}
// call to propagate changes to graph
updateGraphVisibility() {
let graph = this;
......
......@@ -57,7 +57,11 @@ var Node = {
} else {
propsString = "[" + this.properties + "]";
}
return this.title + "\n" + propsString + "\n" + this.opinfo;
let title = this.title + "\n" + propsString + "\n" + this.opinfo;
if (this.origin) {
title += `\nOrigin: ${this.origin.reducer} from #${this.origin.nodeId}`;
}
return title;
},
getDisplayLabel: function() {
var result = this.id + ":" + this.label;
......
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