| Index: src/compiler/pipeline.cc
|
| diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
|
| index c8ce77e00f5df4c6ada56254a687b4a4b6d31f3b..cb6d82d6a341fbeafa2bfd99ed3e8bc0f60c4fab 100644
|
| --- a/src/compiler/pipeline.cc
|
| +++ b/src/compiler/pipeline.cc
|
| @@ -9,6 +9,7 @@
|
|
|
| #include "src/base/platform/elapsed-timer.h"
|
| #include "src/compiler/ast-graph-builder.h"
|
| +#include "src/compiler/ast-loop-assignment-analyzer.h"
|
| #include "src/compiler/basic-block-instrumentor.h"
|
| #include "src/compiler/change-lowering.h"
|
| #include "src/compiler/code-generator.h"
|
| @@ -57,6 +58,7 @@ class PipelineData {
|
| graph_zone_scope_(zone_pool_),
|
| graph_zone_(nullptr),
|
| graph_(nullptr),
|
| + loop_assignment_(nullptr),
|
| machine_(nullptr),
|
| common_(nullptr),
|
| javascript_(nullptr),
|
| @@ -134,6 +136,12 @@ class PipelineData {
|
| JSGraph* jsgraph() const { return jsgraph_; }
|
| Typer* typer() const { return typer_.get(); }
|
|
|
| + LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; }
|
| + void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) {
|
| + DCHECK_EQ(nullptr, loop_assignment_);
|
| + loop_assignment_ = loop_assignment;
|
| + }
|
| +
|
| Node* context_node() const { return context_node_; }
|
| void set_context_node(Node* context_node) {
|
| DCHECK_EQ(nullptr, context_node_);
|
| @@ -160,6 +168,7 @@ class PipelineData {
|
| graph_zone_scope_.Destroy();
|
| graph_zone_ = nullptr;
|
| graph_ = nullptr;
|
| + loop_assignment_ = nullptr;
|
| machine_ = nullptr;
|
| common_ = nullptr;
|
| javascript_ = nullptr;
|
| @@ -205,13 +214,14 @@ class PipelineData {
|
| bool compilation_failed_;
|
| Handle<Code> code_;
|
|
|
| - ZonePool::Scope graph_zone_scope_;
|
| - Zone* graph_zone_;
|
| // All objects in the following group of fields are allocated in graph_zone_.
|
| // They are all set to NULL when the graph_zone_ is destroyed.
|
| + ZonePool::Scope graph_zone_scope_;
|
| + Zone* graph_zone_;
|
| Graph* graph_;
|
| // TODO(dcarney): make this into a ZoneObject.
|
| SmartPointer<SourcePositionTable> source_positions_;
|
| + LoopAssignmentAnalysis* loop_assignment_;
|
| MachineOperatorBuilder* machine_;
|
| CommonOperatorBuilder* common_;
|
| JSOperatorBuilder* javascript_;
|
| @@ -277,10 +287,11 @@ static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) {
|
|
|
| class AstGraphBuilderWithPositions : public AstGraphBuilder {
|
| public:
|
| - explicit AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
|
| - JSGraph* jsgraph,
|
| - SourcePositionTable* source_positions)
|
| - : AstGraphBuilder(local_zone, info, jsgraph),
|
| + AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
|
| + JSGraph* jsgraph,
|
| + LoopAssignmentAnalysis* loop_assignment,
|
| + SourcePositionTable* source_positions)
|
| + : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment),
|
| source_positions_(source_positions) {}
|
|
|
| bool CreateGraph() {
|
| @@ -337,12 +348,24 @@ void Pipeline::Run(Arg0 arg_0) {
|
| }
|
|
|
|
|
| +struct LoopAssignmentAnalysisPhase {
|
| + static const char* phase_name() { return "loop assignment analysis"; }
|
| +
|
| + void Run(PipelineData* data, Zone* temp_zone) {
|
| + AstLoopAssignmentAnalyzer analyzer(data->graph_zone(), data->info());
|
| + LoopAssignmentAnalysis* loop_assignment = analyzer.Analyze();
|
| + data->set_loop_assignment(loop_assignment);
|
| + }
|
| +};
|
| +
|
| +
|
| struct GraphBuilderPhase {
|
| static const char* phase_name() { return "graph builder"; }
|
|
|
| void Run(PipelineData* data, Zone* temp_zone) {
|
| AstGraphBuilderWithPositions graph_builder(
|
| - temp_zone, data->info(), data->jsgraph(), data->source_positions());
|
| + temp_zone, data->info(), data->jsgraph(), data->loop_assignment(),
|
| + data->source_positions());
|
| if (graph_builder.CreateGraph()) {
|
| data->set_context_node(graph_builder.GetFunctionContext());
|
| } else {
|
| @@ -743,6 +766,10 @@ Handle<Code> Pipeline::GenerateCode() {
|
|
|
| data.source_positions()->AddDecorator();
|
|
|
| + if (FLAG_loop_assignment_analysis) {
|
| + Run<LoopAssignmentAnalysisPhase>();
|
| + }
|
| +
|
| Run<GraphBuilderPhase>();
|
| if (data.compilation_failed()) return Handle<Code>::null();
|
| RunPrintAndVerify("Initial untyped", true);
|
|
|