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