Commit d2a64c81 authored by tebbi's avatar tebbi Committed by Commit bot

[turbofan] track source positions in EffectControlLinearizer

R=jarin@chromium.org

BUG=

Review-Url: https://codereview.chromium.org/2504913003
Cr-Commit-Position: refs/heads/master@{#41040}
parent 09326775
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "src/code-factory.h" #include "src/code-factory.h"
#include "src/compiler/access-builder.h" #include "src/compiler/access-builder.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h" #include "src/compiler/linkage.h"
#include "src/compiler/node-matchers.h" #include "src/compiler/node-matchers.h"
...@@ -17,10 +18,13 @@ namespace v8 { ...@@ -17,10 +18,13 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
EffectControlLinearizer::EffectControlLinearizer(JSGraph* js_graph, EffectControlLinearizer::EffectControlLinearizer(
Schedule* schedule, JSGraph* js_graph, Schedule* schedule, Zone* temp_zone,
Zone* temp_zone) SourcePositionTable* source_positions)
: js_graph_(js_graph), schedule_(schedule), temp_zone_(temp_zone) {} : js_graph_(js_graph),
schedule_(schedule),
temp_zone_(temp_zone),
source_positions_(source_positions) {}
Graph* EffectControlLinearizer::graph() const { return js_graph_->graph(); } Graph* EffectControlLinearizer::graph() const { return js_graph_->graph(); }
CommonOperatorBuilder* EffectControlLinearizer::common() const { CommonOperatorBuilder* EffectControlLinearizer::common() const {
...@@ -144,7 +148,8 @@ void RemoveRegionNode(Node* node) { ...@@ -144,7 +148,8 @@ void RemoveRegionNode(Node* node) {
void TryCloneBranch(Node* node, BasicBlock* block, Graph* graph, void TryCloneBranch(Node* node, BasicBlock* block, Graph* graph,
CommonOperatorBuilder* common, CommonOperatorBuilder* common,
BlockEffectControlMap* block_effects) { BlockEffectControlMap* block_effects,
SourcePositionTable* source_positions) {
DCHECK_EQ(IrOpcode::kBranch, node->opcode()); DCHECK_EQ(IrOpcode::kBranch, node->opcode());
// This optimization is a special case of (super)block cloning. It takes an // This optimization is a special case of (super)block cloning. It takes an
...@@ -196,6 +201,8 @@ void TryCloneBranch(Node* node, BasicBlock* block, Graph* graph, ...@@ -196,6 +201,8 @@ void TryCloneBranch(Node* node, BasicBlock* block, Graph* graph,
// ^ ^ // ^ ^
// | | // | |
SourcePositionTable::Scope scope(source_positions,
source_positions->GetSourcePosition(node));
Node* branch = node; Node* branch = node;
Node* cond = NodeProperties::GetValueInput(branch, 0); Node* cond = NodeProperties::GetValueInput(branch, 0);
if (!cond->OwnedBy(branch) || cond->opcode() != IrOpcode::kPhi) return; if (!cond->OwnedBy(branch) || cond->opcode() != IrOpcode::kPhi) return;
...@@ -448,7 +455,7 @@ void EffectControlLinearizer::Run() { ...@@ -448,7 +455,7 @@ void EffectControlLinearizer::Run() {
case BasicBlock::kBranch: case BasicBlock::kBranch:
ProcessNode(block->control_input(), &frame_state, &effect, &control); ProcessNode(block->control_input(), &frame_state, &effect, &control);
TryCloneBranch(block->control_input(), block, graph(), common(), TryCloneBranch(block->control_input(), block, graph(), common(),
&block_effects); &block_effects, source_positions_);
break; break;
} }
...@@ -494,6 +501,9 @@ void TryScheduleCallIfSuccess(Node* node, Node** control) { ...@@ -494,6 +501,9 @@ void TryScheduleCallIfSuccess(Node* node, Node** control) {
void EffectControlLinearizer::ProcessNode(Node* node, Node** frame_state, void EffectControlLinearizer::ProcessNode(Node* node, Node** frame_state,
Node** effect, Node** control) { Node** effect, Node** control) {
SourcePositionTable::Scope scope(source_positions_,
source_positions_->GetSourcePosition(node));
// If the node needs to be wired into the effect/control chain, do this // If the node needs to be wired into the effect/control chain, do this
// here. Pass current frame state for lowering to eager deoptimization. // here. Pass current frame state for lowering to eager deoptimization.
if (TryWireInStateEffect(node, *frame_state, effect, control)) { if (TryWireInStateEffect(node, *frame_state, effect, control)) {
......
...@@ -25,10 +25,12 @@ class MachineOperatorBuilder; ...@@ -25,10 +25,12 @@ class MachineOperatorBuilder;
class JSGraph; class JSGraph;
class Graph; class Graph;
class Schedule; class Schedule;
class SourcePositionTable;
class V8_EXPORT_PRIVATE EffectControlLinearizer { class V8_EXPORT_PRIVATE EffectControlLinearizer {
public: public:
EffectControlLinearizer(JSGraph* graph, Schedule* schedule, Zone* temp_zone); EffectControlLinearizer(JSGraph* graph, Schedule* schedule, Zone* temp_zone,
SourcePositionTable* source_positions);
void Run(); void Run();
...@@ -226,6 +228,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer { ...@@ -226,6 +228,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
Schedule* schedule_; Schedule* schedule_;
Zone* temp_zone_; Zone* temp_zone_;
RegionObservability region_observability_ = RegionObservability::kObservable; RegionObservability region_observability_ = RegionObservability::kObservable;
SourcePositionTable* source_positions_;
SetOncePointer<Operator const> to_number_operator_; SetOncePointer<Operator const> to_number_operator_;
}; };
......
...@@ -1048,7 +1048,8 @@ struct EffectControlLinearizationPhase { ...@@ -1048,7 +1048,8 @@ struct EffectControlLinearizationPhase {
// chains and lower them, // chains and lower them,
// - get rid of the region markers, // - get rid of the region markers,
// - introduce effect phis and rewire effects to get SSA again. // - introduce effect phis and rewire effects to get SSA again.
EffectControlLinearizer linearizer(data->jsgraph(), schedule, temp_zone); EffectControlLinearizer linearizer(data->jsgraph(), schedule, temp_zone,
data->source_positions());
linearizer.Run(); linearizer.Run();
} }
}; };
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/compiler/effect-control-linearizer.h" #include "src/compiler/effect-control-linearizer.h"
#include "src/compiler/access-builder.h" #include "src/compiler/access-builder.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/js-graph.h" #include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h" #include "src/compiler/linkage.h"
#include "src/compiler/node-properties.h" #include "src/compiler/node-properties.h"
...@@ -29,16 +30,20 @@ class EffectControlLinearizerTest : public GraphTest { ...@@ -29,16 +30,20 @@ class EffectControlLinearizerTest : public GraphTest {
javascript_(zone()), javascript_(zone()),
simplified_(zone()), simplified_(zone()),
jsgraph_(isolate(), graph(), common(), &javascript_, &simplified_, jsgraph_(isolate(), graph(), common(), &javascript_, &simplified_,
&machine_) {} &machine_) {
source_positions_ = new (zone()) SourcePositionTable(graph());
}
JSGraph* jsgraph() { return &jsgraph_; } JSGraph* jsgraph() { return &jsgraph_; }
SimplifiedOperatorBuilder* simplified() { return &simplified_; } SimplifiedOperatorBuilder* simplified() { return &simplified_; }
SourcePositionTable* source_positions() { return source_positions_; }
private: private:
MachineOperatorBuilder machine_; MachineOperatorBuilder machine_;
JSOperatorBuilder javascript_; JSOperatorBuilder javascript_;
SimplifiedOperatorBuilder simplified_; SimplifiedOperatorBuilder simplified_;
JSGraph jsgraph_; JSGraph jsgraph_;
SourcePositionTable* source_positions_;
}; };
namespace { namespace {
...@@ -76,7 +81,8 @@ TEST_F(EffectControlLinearizerTest, SimpleLoad) { ...@@ -76,7 +81,8 @@ TEST_F(EffectControlLinearizerTest, SimpleLoad) {
schedule.AddReturn(start, ret); schedule.AddReturn(start, ret);
// Run the state effect introducer. // Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); EffectControlLinearizer introducer(jsgraph(), &schedule, zone(),
source_positions());
introducer.Run(); introducer.Run();
EXPECT_THAT(load, EXPECT_THAT(load,
...@@ -137,7 +143,8 @@ TEST_F(EffectControlLinearizerTest, DiamondLoad) { ...@@ -137,7 +143,8 @@ TEST_F(EffectControlLinearizerTest, DiamondLoad) {
schedule.AddReturn(mblock, ret); schedule.AddReturn(mblock, ret);
// Run the state effect introducer. // Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); EffectControlLinearizer introducer(jsgraph(), &schedule, zone(),
source_positions());
introducer.Run(); introducer.Run();
// The effect input to the return should be an effect phi with the // The effect input to the return should be an effect phi with the
...@@ -255,7 +262,8 @@ TEST_F(EffectControlLinearizerTest, FloatingDiamondsControlWiring) { ...@@ -255,7 +262,8 @@ TEST_F(EffectControlLinearizerTest, FloatingDiamondsControlWiring) {
schedule.AddReturn(m2block, ret); schedule.AddReturn(m2block, ret);
// Run the state effect introducer. // Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); EffectControlLinearizer introducer(jsgraph(), &schedule, zone(),
source_positions());
introducer.Run(); introducer.Run();
// The effect input to the return should be an effect phi with the // The effect input to the return should be an effect phi with the
...@@ -323,7 +331,8 @@ TEST_F(EffectControlLinearizerTest, LoopLoad) { ...@@ -323,7 +331,8 @@ TEST_F(EffectControlLinearizerTest, LoopLoad) {
schedule.AddReturn(rblock, ret); schedule.AddReturn(rblock, ret);
// Run the state effect introducer. // Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); EffectControlLinearizer introducer(jsgraph(), &schedule, zone(),
source_positions());
introducer.Run(); introducer.Run();
ASSERT_THAT(ret, IsReturn(load, load, if_true)); ASSERT_THAT(ret, IsReturn(load, load, if_true));
...@@ -385,7 +394,8 @@ TEST_F(EffectControlLinearizerTest, CloneBranch) { ...@@ -385,7 +394,8 @@ TEST_F(EffectControlLinearizerTest, CloneBranch) {
schedule.AddNode(mblock, merge); schedule.AddNode(mblock, merge);
schedule.AddNode(mblock, graph()->end()); schedule.AddNode(mblock, graph()->end());
EffectControlLinearizer introducer(jsgraph(), &schedule, zone()); EffectControlLinearizer introducer(jsgraph(), &schedule, zone(),
source_positions());
introducer.Run(); introducer.Run();
Capture<Node *> branch1_capture, branch2_capture; Capture<Node *> branch1_capture, branch2_capture;
......
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