decorators_(zone) {}
-void Graph::Decorate(Node* node) {
- for (auto const decorator : decorators_) decorator->Decorate(node);
+void Graph::Decorate(Node* node, bool incomplete) {
+ for (auto const decorator : decorators_) {
+ decorator->Decorate(node, incomplete);
+ }
}
DCHECK_LE(op->ValueInputCount(), input_count);
Node* const node =
Node::New(zone(), NextNodeId(), op, input_count, inputs, incomplete);
- if (!incomplete) Decorate(node);
+ Decorate(node, incomplete);
return node;
}
int NodeCount() const { return next_node_id_; }
- void Decorate(Node* node);
+ void Decorate(Node* node, bool incomplete);
void AddDecorator(GraphDecorator* decorator);
void RemoveDecorator(GraphDecorator* decorator);
class GraphDecorator : public ZoneObject {
public:
virtual ~GraphDecorator() {}
- virtual void Decorate(Node* node) = 0;
+ virtual void Decorate(Node* node, bool incomplete) = 0;
};
} // namespace compiler
LoopAssignmentAnalysis* loop_assignment,
SourcePositionTable* source_positions)
: AstGraphBuilder(local_zone, info, jsgraph, loop_assignment),
- source_positions_(source_positions) {}
+ source_positions_(source_positions),
+ start_position_(info->shared_info()->start_position()) {}
bool CreateGraph() {
- SourcePositionTable::Scope pos(source_positions_,
- SourcePosition::Unknown());
+ SourcePositionTable::Scope pos_scope(source_positions_, start_position_);
return AstGraphBuilder::CreateGraph();
}
private:
SourcePositionTable* source_positions_;
+ SourcePosition start_position_;
};
+namespace {
+
+class SourcePositionWrapper : public Reducer {
+ public:
+ SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table)
+ : reducer_(reducer), table_(table) {}
+ virtual ~SourcePositionWrapper() {}
+
+ virtual Reduction Reduce(Node* node) {
+ SourcePosition pos = table_->GetSourcePosition(node);
+ SourcePositionTable::Scope position(table_, pos);
+ return reducer_->Reduce(node);
+ }
+
+ private:
+ Reducer* reducer_;
+ SourcePositionTable* table_;
+
+ DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper);
+};
+
+
+static void AddReducer(PipelineData* data, GraphReducer* graph_reducer,
+ Reducer* reducer) {
+ if (FLAG_turbo_source_positions) {
+ void* buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper));
+ SourcePositionWrapper* wrapper =
+ new (buffer) SourcePositionWrapper(reducer, data->source_positions());
+ graph_reducer->AddReducer(wrapper);
+ } else {
+ graph_reducer->AddReducer(reducer);
+ }
+}
+} // namespace
+
class PipelineRunScope {
public:
PipelineRunScope(PipelineData* data, const char* phase_name)
JSContextSpecializer spec(data->info(), data->jsgraph(),
data->context_node());
GraphReducer graph_reducer(data->graph(), temp_zone);
- graph_reducer.AddReducer(&spec);
+ AddReducer(data, &graph_reducer, &spec);
graph_reducer.ReduceGraph();
}
};
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
CommonOperatorReducer common_reducer;
GraphReducer graph_reducer(data->graph(), temp_zone);
- graph_reducer.AddReducer(&vn_reducer);
- graph_reducer.AddReducer(&builtin_reducer);
- graph_reducer.AddReducer(&typed_lowering);
- graph_reducer.AddReducer(&intrinsic_lowering);
- graph_reducer.AddReducer(&load_elimination);
- graph_reducer.AddReducer(&simple_reducer);
- graph_reducer.AddReducer(&common_reducer);
+ AddReducer(data, &graph_reducer, &vn_reducer);
+ AddReducer(data, &graph_reducer, &builtin_reducer);
+ AddReducer(data, &graph_reducer, &typed_lowering);
+ AddReducer(data, &graph_reducer, &intrinsic_lowering);
+ AddReducer(data, &graph_reducer, &load_elimination);
+ AddReducer(data, &graph_reducer, &simple_reducer);
+ AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
}
};
void Run(PipelineData* data, Zone* temp_zone) {
SourcePositionTable::Scope pos(data->source_positions(),
SourcePosition::Unknown());
- SimplifiedLowering lowering(data->jsgraph(), temp_zone);
+ SimplifiedLowering lowering(data->jsgraph(), temp_zone,
+ data->source_positions());
lowering.LowerAllNodes();
ValueNumberingReducer vn_reducer(temp_zone);
SimplifiedOperatorReducer simple_reducer(data->jsgraph());
MachineOperatorReducer machine_reducer(data->jsgraph());
CommonOperatorReducer common_reducer;
GraphReducer graph_reducer(data->graph(), temp_zone);
- graph_reducer.AddReducer(&vn_reducer);
- graph_reducer.AddReducer(&simple_reducer);
- graph_reducer.AddReducer(&machine_reducer);
- graph_reducer.AddReducer(&common_reducer);
+ AddReducer(data, &graph_reducer, &vn_reducer);
+ AddReducer(data, &graph_reducer, &simple_reducer);
+ AddReducer(data, &graph_reducer, &machine_reducer);
+ AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
}
};
CommonOperatorReducer common_reducer;
GraphReducer graph_reducer(data->graph(), temp_zone);
graph_reducer.AddReducer(&vn_reducer);
- graph_reducer.AddReducer(&simple_reducer);
- graph_reducer.AddReducer(&lowering);
- graph_reducer.AddReducer(&machine_reducer);
- graph_reducer.AddReducer(&common_reducer);
+ AddReducer(data, &graph_reducer, &simple_reducer);
+ AddReducer(data, &graph_reducer, &lowering);
+ AddReducer(data, &graph_reducer, &machine_reducer);
+ AddReducer(data, &graph_reducer, &common_reducer);
graph_reducer.ReduceGraph();
}
};
JSGenericLowering generic(data->info(), data->jsgraph());
SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common());
GraphReducer graph_reducer(data->graph(), temp_zone);
- graph_reducer.AddReducer(&generic);
- graph_reducer.AddReducer(&select);
+ AddReducer(data, &graph_reducer, &generic);
+ AddReducer(data, &graph_reducer, &select);
graph_reducer.ReduceGraph();
}
};
#include "src/compiler/representation-change.h"
#include "src/compiler/simplified-lowering.h"
#include "src/compiler/simplified-operator.h"
+#include "src/compiler/source-position.h"
#include "src/objects.h"
namespace v8 {
};
RepresentationSelector(JSGraph* jsgraph, Zone* zone,
- RepresentationChanger* changer)
+ RepresentationChanger* changer,
+ SourcePositionTable* source_positions)
: jsgraph_(jsgraph),
count_(jsgraph->graph()->NodeCount()),
info_(zone->NewArray<NodeInfo>(count_)),
replacements_(zone),
phase_(PROPAGATE),
changer_(changer),
- queue_(zone) {
+ queue_(zone),
+ source_positions_(source_positions) {
memset(info_, 0, sizeof(NodeInfo) * count_);
safe_int_additive_range_ =
Node* node = *i;
TRACE((" visit #%d: %s\n", node->id(), node->op()->mnemonic()));
// Reuse {VisitNode()} so the representation rules are in one place.
- VisitNode(node, GetUseInfo(node), lowering);
+ if (FLAG_turbo_source_positions) {
+ SourcePositionTable::Scope scope(
+ source_positions_, source_positions_->GetSourcePosition(node));
+ VisitNode(node, GetUseInfo(node), lowering);
+ } else {
+ VisitNode(node, GetUseInfo(node), lowering);
+ }
}
// Perform the final replacements.
Phase phase_; // current phase of algorithm
RepresentationChanger* changer_; // for inserting representation changes
ZoneQueue<Node*> queue_; // queue for traversing the graph
+ // TODO(danno): RepresentationSelector shouldn't know anything about the
+ // source positions table, but must for now since there currently is no other
+ // way to pass down source position information to nodes created during
+ // lowering. Once this phase becomes a vanilla reducer, it should get source
+ // position information via the SourcePositionWrapper like all other reducers.
+ SourcePositionTable* source_positions_;
Type* safe_int_additive_range_;
NodeInfo* GetInfo(Node* node) {
void SimplifiedLowering::LowerAllNodes() {
SimplifiedOperatorBuilder simplified(graph()->zone());
RepresentationChanger changer(jsgraph(), &simplified, jsgraph()->isolate());
- RepresentationSelector selector(jsgraph(), zone_, &changer);
+ RepresentationSelector selector(jsgraph(), zone_, &changer,
+ source_positions_);
selector.Run(this);
}
// Forward declarations.
class RepresentationChanger;
-
+class SourcePositionTable;
class SimplifiedLowering FINAL {
public:
- SimplifiedLowering(JSGraph* jsgraph, Zone* zone)
- : jsgraph_(jsgraph), zone_(zone) {}
+ SimplifiedLowering(JSGraph* jsgraph, Zone* zone,
+ SourcePositionTable* source_positions)
+ : jsgraph_(jsgraph), zone_(zone), source_positions_(source_positions) {}
~SimplifiedLowering() {}
void LowerAllNodes();
JSGraph* const jsgraph_;
Zone* const zone_;
+ // TODO(danno): SimplifiedLowering shouldn't know anything about the source
+ // positions table, but must for now since there currently is no other way to
+ // pass down source position information to nodes created during
+ // lowering. Once this phase becomes a vanilla reducer, it should get source
+ // position information via the SourcePositionWrapper like all other reducers.
+ SourcePositionTable* source_positions_;
+
Node* SmiTag(Node* node);
Node* IsTagged(Node* node);
Node* Untag(Node* node);
explicit Decorator(SourcePositionTable* source_positions)
: source_positions_(source_positions) {}
- void Decorate(Node* node) FINAL {
+ void Decorate(Node* node, bool incomplete) FINAL {
DCHECK(!source_positions_->current_position_.IsInvalid());
source_positions_->table_.Set(node, source_positions_->current_position_);
}
class Typer::Decorator FINAL : public GraphDecorator {
public:
explicit Decorator(Typer* typer) : typer_(typer) {}
- void Decorate(Node* node) FINAL;
+ void Decorate(Node* node, bool incomplete) FINAL;
private:
Typer* typer_;
}
-void Typer::Decorator::Decorate(Node* node) {
+void Typer::Decorator::Decorate(Node* node, bool incomplete) {
+ if (incomplete) return;
if (node->op()->ValueOutputCount() > 0) {
// Only eagerly type-decorate nodes with known input types.
// Other cases will generally require a proper fixpoint iteration with Run.
#include "src/compiler/pipeline.h"
#include "src/compiler/representation-change.h"
#include "src/compiler/simplified-lowering.h"
+#include "src/compiler/source-position.h"
#include "src/compiler/typer.h"
#include "src/compiler/verifier.h"
#include "src/execution.h"
javascript(this->zone()),
jsgraph(this->isolate(), this->graph(), this->common(), &javascript,
this->machine()),
- lowering(&jsgraph, this->zone()) {}
+ source_positions(jsgraph.graph()),
+ lowering(&jsgraph, this->zone(), &source_positions) {}
Typer typer;
JSOperatorBuilder javascript;
JSGraph jsgraph;
+ SourcePositionTable source_positions;
SimplifiedLowering lowering;
void LowerAllNodes() {
CHECK_EQ(expected, node->opcode());
}
- void Lower() { SimplifiedLowering(&jsgraph, jsgraph.zone()).LowerAllNodes(); }
+ void Lower() {
+ SourcePositionTable table(jsgraph.graph());
+ SimplifiedLowering(&jsgraph, jsgraph.zone(), &table).LowerAllNodes();
+ }
// Inserts the node as the return value of the graph.
Node* Return(Node* node) {