| OLD | NEW | 
|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/compiler/pipeline.h" | 5 #include "src/compiler/pipeline.h" | 
| 6 | 6 | 
| 7 #include <fstream>  // NOLINT(readability/streams) | 7 #include <fstream>  // NOLINT(readability/streams) | 
| 8 #include <sstream> | 8 #include <sstream> | 
| 9 | 9 | 
| 10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" | 
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 283 } | 283 } | 
| 284 | 284 | 
| 285 | 285 | 
| 286 class AstGraphBuilderWithPositions : public AstGraphBuilder { | 286 class AstGraphBuilderWithPositions : public AstGraphBuilder { | 
| 287  public: | 287  public: | 
| 288   AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, | 288   AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, | 
| 289                                JSGraph* jsgraph, | 289                                JSGraph* jsgraph, | 
| 290                                LoopAssignmentAnalysis* loop_assignment, | 290                                LoopAssignmentAnalysis* loop_assignment, | 
| 291                                SourcePositionTable* source_positions) | 291                                SourcePositionTable* source_positions) | 
| 292       : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment), | 292       : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment), | 
| 293         source_positions_(source_positions) {} | 293         source_positions_(source_positions), | 
|  | 294         start_position_(info->shared_info()->start_position()) {} | 
| 294 | 295 | 
| 295   bool CreateGraph() { | 296   bool CreateGraph() { | 
| 296     SourcePositionTable::Scope pos(source_positions_, | 297     SourcePositionTable::Scope pos_scope(source_positions_, start_position_); | 
| 297                                    SourcePosition::Unknown()); |  | 
| 298     return AstGraphBuilder::CreateGraph(); | 298     return AstGraphBuilder::CreateGraph(); | 
| 299   } | 299   } | 
| 300 | 300 | 
| 301 #define DEF_VISIT(type)                                               \ | 301 #define DEF_VISIT(type)                                               \ | 
| 302   void Visit##type(type* node) OVERRIDE {                             \ | 302   void Visit##type(type* node) OVERRIDE {                             \ | 
| 303     SourcePositionTable::Scope pos(source_positions_,                 \ | 303     SourcePositionTable::Scope pos(source_positions_,                 \ | 
| 304                                    SourcePosition(node->position())); \ | 304                                    SourcePosition(node->position())); \ | 
| 305     AstGraphBuilder::Visit##type(node);                               \ | 305     AstGraphBuilder::Visit##type(node);                               \ | 
| 306   } | 306   } | 
| 307   AST_NODE_LIST(DEF_VISIT) | 307   AST_NODE_LIST(DEF_VISIT) | 
| 308 #undef DEF_VISIT | 308 #undef DEF_VISIT | 
| 309 | 309 | 
| 310   Node* GetFunctionContext() { return AstGraphBuilder::GetFunctionContext(); } | 310   Node* GetFunctionContext() { return AstGraphBuilder::GetFunctionContext(); } | 
| 311 | 311 | 
| 312  private: | 312  private: | 
| 313   SourcePositionTable* source_positions_; | 313   SourcePositionTable* source_positions_; | 
|  | 314   SourcePosition start_position_; | 
| 314 }; | 315 }; | 
| 315 | 316 | 
| 316 | 317 | 
|  | 318 namespace { | 
|  | 319 | 
|  | 320 class SourcePositionWrapper : public Reducer { | 
|  | 321  public: | 
|  | 322   // Allocate SourcePositionWrapper can't inherit from ZoneObject due to code | 
|  | 323   // style multiple-inheritance restrictions. | 
|  | 324   void* operator new(size_t size, Zone* zone) { | 
|  | 325     return zone->New(static_cast<int>(size)); | 
|  | 326   } | 
|  | 327 | 
|  | 328   SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) | 
|  | 329       : reducer_(reducer), table_(table) {} | 
|  | 330   virtual ~SourcePositionWrapper() {} | 
|  | 331 | 
|  | 332   virtual Reduction Reduce(Node* node) { | 
|  | 333     SourcePosition pos = table_->GetSourcePosition(node); | 
|  | 334     SourcePositionTable::Scope position(table_, pos); | 
|  | 335     return reducer_->Reduce(node); | 
|  | 336   } | 
|  | 337 | 
|  | 338  private: | 
|  | 339   Reducer* reducer_; | 
|  | 340   SourcePositionTable* table_; | 
|  | 341 | 
|  | 342   DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); | 
|  | 343 }; | 
|  | 344 | 
|  | 345 | 
|  | 346 static void AddReducer(PipelineData* data, GraphReducer* graph_reducer, | 
|  | 347                        Reducer* reducer) { | 
|  | 348   if (FLAG_turbo_source_positions) { | 
|  | 349     SourcePositionWrapper* wrapper = new (data->graph_zone()) | 
|  | 350         SourcePositionWrapper(reducer, data->source_positions()); | 
|  | 351     graph_reducer->AddReducer(wrapper); | 
|  | 352   } else { | 
|  | 353     graph_reducer->AddReducer(reducer); | 
|  | 354   } | 
|  | 355 } | 
|  | 356 }; | 
|  | 357 | 
| 317 class PipelineRunScope { | 358 class PipelineRunScope { | 
| 318  public: | 359  public: | 
| 319   PipelineRunScope(PipelineData* data, const char* phase_name) | 360   PipelineRunScope(PipelineData* data, const char* phase_name) | 
| 320       : phase_scope_( | 361       : phase_scope_( | 
| 321             phase_name == nullptr ? nullptr : data->pipeline_statistics(), | 362             phase_name == nullptr ? nullptr : data->pipeline_statistics(), | 
| 322             phase_name), | 363             phase_name), | 
| 323         zone_scope_(data->zone_pool()) {} | 364         zone_scope_(data->zone_pool()) {} | 
| 324 | 365 | 
| 325   Zone* zone() { return zone_scope_.zone(); } | 366   Zone* zone() { return zone_scope_.zone(); } | 
| 326 | 367 | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 375 | 416 | 
| 376 struct ContextSpecializerPhase { | 417 struct ContextSpecializerPhase { | 
| 377   static const char* phase_name() { return "context specializing"; } | 418   static const char* phase_name() { return "context specializing"; } | 
| 378 | 419 | 
| 379   void Run(PipelineData* data, Zone* temp_zone) { | 420   void Run(PipelineData* data, Zone* temp_zone) { | 
| 380     SourcePositionTable::Scope pos(data->source_positions(), | 421     SourcePositionTable::Scope pos(data->source_positions(), | 
| 381                                    SourcePosition::Unknown()); | 422                                    SourcePosition::Unknown()); | 
| 382     JSContextSpecializer spec(data->info(), data->jsgraph(), | 423     JSContextSpecializer spec(data->info(), data->jsgraph(), | 
| 383                               data->context_node()); | 424                               data->context_node()); | 
| 384     GraphReducer graph_reducer(data->graph(), temp_zone); | 425     GraphReducer graph_reducer(data->graph(), temp_zone); | 
| 385     graph_reducer.AddReducer(&spec); | 426     AddReducer(data, &graph_reducer, &spec); | 
| 386     graph_reducer.ReduceGraph(); | 427     graph_reducer.ReduceGraph(); | 
| 387   } | 428   } | 
| 388 }; | 429 }; | 
| 389 | 430 | 
| 390 | 431 | 
| 391 struct InliningPhase { | 432 struct InliningPhase { | 
| 392   static const char* phase_name() { return "inlining"; } | 433   static const char* phase_name() { return "inlining"; } | 
| 393 | 434 | 
| 394   void Run(PipelineData* data, Zone* temp_zone) { | 435   void Run(PipelineData* data, Zone* temp_zone) { | 
| 395     SourcePositionTable::Scope pos(data->source_positions(), | 436     SourcePositionTable::Scope pos(data->source_positions(), | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 428     SourcePositionTable::Scope pos(data->source_positions(), | 469     SourcePositionTable::Scope pos(data->source_positions(), | 
| 429                                    SourcePosition::Unknown()); | 470                                    SourcePosition::Unknown()); | 
| 430     ValueNumberingReducer vn_reducer(temp_zone); | 471     ValueNumberingReducer vn_reducer(temp_zone); | 
| 431     LoadElimination load_elimination; | 472     LoadElimination load_elimination; | 
| 432     JSBuiltinReducer builtin_reducer(data->jsgraph()); | 473     JSBuiltinReducer builtin_reducer(data->jsgraph()); | 
| 433     JSTypedLowering typed_lowering(data->jsgraph(), temp_zone); | 474     JSTypedLowering typed_lowering(data->jsgraph(), temp_zone); | 
| 434     JSIntrinsicLowering intrinsic_lowering(data->jsgraph()); | 475     JSIntrinsicLowering intrinsic_lowering(data->jsgraph()); | 
| 435     SimplifiedOperatorReducer simple_reducer(data->jsgraph()); | 476     SimplifiedOperatorReducer simple_reducer(data->jsgraph()); | 
| 436     CommonOperatorReducer common_reducer; | 477     CommonOperatorReducer common_reducer; | 
| 437     GraphReducer graph_reducer(data->graph(), temp_zone); | 478     GraphReducer graph_reducer(data->graph(), temp_zone); | 
| 438     graph_reducer.AddReducer(&vn_reducer); | 479     AddReducer(data, &graph_reducer, &vn_reducer); | 
| 439     graph_reducer.AddReducer(&builtin_reducer); | 480     AddReducer(data, &graph_reducer, &builtin_reducer); | 
| 440     graph_reducer.AddReducer(&typed_lowering); | 481     AddReducer(data, &graph_reducer, &typed_lowering); | 
| 441     graph_reducer.AddReducer(&intrinsic_lowering); | 482     AddReducer(data, &graph_reducer, &intrinsic_lowering); | 
| 442     graph_reducer.AddReducer(&load_elimination); | 483     AddReducer(data, &graph_reducer, &load_elimination); | 
| 443     graph_reducer.AddReducer(&simple_reducer); | 484     AddReducer(data, &graph_reducer, &simple_reducer); | 
| 444     graph_reducer.AddReducer(&common_reducer); | 485     AddReducer(data, &graph_reducer, &common_reducer); | 
| 445     graph_reducer.ReduceGraph(); | 486     graph_reducer.ReduceGraph(); | 
| 446   } | 487   } | 
| 447 }; | 488 }; | 
| 448 | 489 | 
| 449 | 490 | 
| 450 struct SimplifiedLoweringPhase { | 491 struct SimplifiedLoweringPhase { | 
| 451   static const char* phase_name() { return "simplified lowering"; } | 492   static const char* phase_name() { return "simplified lowering"; } | 
| 452 | 493 | 
| 453   void Run(PipelineData* data, Zone* temp_zone) { | 494   void Run(PipelineData* data, Zone* temp_zone) { | 
| 454     SourcePositionTable::Scope pos(data->source_positions(), | 495     SourcePositionTable::Scope pos(data->source_positions(), | 
| 455                                    SourcePosition::Unknown()); | 496                                    SourcePosition::Unknown()); | 
| 456     SimplifiedLowering lowering(data->jsgraph(), temp_zone); | 497     SimplifiedLowering lowering(data->jsgraph(), temp_zone, | 
|  | 498                                 data->source_positions()); | 
| 457     lowering.LowerAllNodes(); | 499     lowering.LowerAllNodes(); | 
| 458     ValueNumberingReducer vn_reducer(temp_zone); | 500     ValueNumberingReducer vn_reducer(temp_zone); | 
| 459     SimplifiedOperatorReducer simple_reducer(data->jsgraph()); | 501     SimplifiedOperatorReducer simple_reducer(data->jsgraph()); | 
| 460     MachineOperatorReducer machine_reducer(data->jsgraph()); | 502     MachineOperatorReducer machine_reducer(data->jsgraph()); | 
| 461     CommonOperatorReducer common_reducer; | 503     CommonOperatorReducer common_reducer; | 
| 462     GraphReducer graph_reducer(data->graph(), temp_zone); | 504     GraphReducer graph_reducer(data->graph(), temp_zone); | 
| 463     graph_reducer.AddReducer(&vn_reducer); | 505     AddReducer(data, &graph_reducer, &vn_reducer); | 
| 464     graph_reducer.AddReducer(&simple_reducer); | 506     AddReducer(data, &graph_reducer, &simple_reducer); | 
| 465     graph_reducer.AddReducer(&machine_reducer); | 507     AddReducer(data, &graph_reducer, &machine_reducer); | 
| 466     graph_reducer.AddReducer(&common_reducer); | 508     AddReducer(data, &graph_reducer, &common_reducer); | 
| 467     graph_reducer.ReduceGraph(); | 509     graph_reducer.ReduceGraph(); | 
| 468   } | 510   } | 
| 469 }; | 511 }; | 
| 470 | 512 | 
| 471 | 513 | 
| 472 struct ChangeLoweringPhase { | 514 struct ChangeLoweringPhase { | 
| 473   static const char* phase_name() { return "change lowering"; } | 515   static const char* phase_name() { return "change lowering"; } | 
| 474 | 516 | 
| 475   void Run(PipelineData* data, Zone* temp_zone) { | 517   void Run(PipelineData* data, Zone* temp_zone) { | 
| 476     SourcePositionTable::Scope pos(data->source_positions(), | 518     SourcePositionTable::Scope pos(data->source_positions(), | 
| 477                                    SourcePosition::Unknown()); | 519                                    SourcePosition::Unknown()); | 
| 478     Linkage linkage(data->graph_zone(), data->info()); | 520     Linkage linkage(data->graph_zone(), data->info()); | 
| 479     ValueNumberingReducer vn_reducer(temp_zone); | 521     ValueNumberingReducer vn_reducer(temp_zone); | 
| 480     SimplifiedOperatorReducer simple_reducer(data->jsgraph()); | 522     SimplifiedOperatorReducer simple_reducer(data->jsgraph()); | 
| 481     ChangeLowering lowering(data->jsgraph(), &linkage); | 523     ChangeLowering lowering(data->jsgraph(), &linkage); | 
| 482     MachineOperatorReducer machine_reducer(data->jsgraph()); | 524     MachineOperatorReducer machine_reducer(data->jsgraph()); | 
| 483     CommonOperatorReducer common_reducer; | 525     CommonOperatorReducer common_reducer; | 
| 484     GraphReducer graph_reducer(data->graph(), temp_zone); | 526     GraphReducer graph_reducer(data->graph(), temp_zone); | 
| 485     graph_reducer.AddReducer(&vn_reducer); | 527     graph_reducer.AddReducer(&vn_reducer); | 
| 486     graph_reducer.AddReducer(&simple_reducer); | 528     AddReducer(data, &graph_reducer, &simple_reducer); | 
| 487     graph_reducer.AddReducer(&lowering); | 529     AddReducer(data, &graph_reducer, &lowering); | 
| 488     graph_reducer.AddReducer(&machine_reducer); | 530     AddReducer(data, &graph_reducer, &machine_reducer); | 
| 489     graph_reducer.AddReducer(&common_reducer); | 531     AddReducer(data, &graph_reducer, &common_reducer); | 
| 490     graph_reducer.ReduceGraph(); | 532     graph_reducer.ReduceGraph(); | 
| 491   } | 533   } | 
| 492 }; | 534 }; | 
| 493 | 535 | 
| 494 | 536 | 
| 495 struct ControlReductionPhase { | 537 struct ControlReductionPhase { | 
| 496   void Run(PipelineData* data, Zone* temp_zone) { | 538   void Run(PipelineData* data, Zone* temp_zone) { | 
| 497     SourcePositionTable::Scope pos(data->source_positions(), | 539     SourcePositionTable::Scope pos(data->source_positions(), | 
| 498                                    SourcePosition::Unknown()); | 540                                    SourcePosition::Unknown()); | 
| 499     ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), data->common()); | 541     ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), data->common()); | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 530 | 572 | 
| 531 struct GenericLoweringPhase { | 573 struct GenericLoweringPhase { | 
| 532   static const char* phase_name() { return "generic lowering"; } | 574   static const char* phase_name() { return "generic lowering"; } | 
| 533 | 575 | 
| 534   void Run(PipelineData* data, Zone* temp_zone) { | 576   void Run(PipelineData* data, Zone* temp_zone) { | 
| 535     SourcePositionTable::Scope pos(data->source_positions(), | 577     SourcePositionTable::Scope pos(data->source_positions(), | 
| 536                                    SourcePosition::Unknown()); | 578                                    SourcePosition::Unknown()); | 
| 537     JSGenericLowering generic(data->info(), data->jsgraph()); | 579     JSGenericLowering generic(data->info(), data->jsgraph()); | 
| 538     SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); | 580     SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); | 
| 539     GraphReducer graph_reducer(data->graph(), temp_zone); | 581     GraphReducer graph_reducer(data->graph(), temp_zone); | 
| 540     graph_reducer.AddReducer(&generic); | 582     AddReducer(data, &graph_reducer, &generic); | 
| 541     graph_reducer.AddReducer(&select); | 583     AddReducer(data, &graph_reducer, &select); | 
| 542     graph_reducer.ReduceGraph(); | 584     graph_reducer.ReduceGraph(); | 
| 543   } | 585   } | 
| 544 }; | 586 }; | 
| 545 | 587 | 
| 546 | 588 | 
| 547 struct ComputeSchedulePhase { | 589 struct ComputeSchedulePhase { | 
| 548   static const char* phase_name() { return "scheduling"; } | 590   static const char* phase_name() { return "scheduling"; } | 
| 549 | 591 | 
| 550   void Run(PipelineData* data, Zone* temp_zone) { | 592   void Run(PipelineData* data, Zone* temp_zone) { | 
| 551     Schedule* schedule = Scheduler::ComputeSchedule( | 593     Schedule* schedule = Scheduler::ComputeSchedule( | 
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1143 } | 1185 } | 
| 1144 | 1186 | 
| 1145 | 1187 | 
| 1146 void Pipeline::TearDown() { | 1188 void Pipeline::TearDown() { | 
| 1147   InstructionOperand::TearDownCaches(); | 1189   InstructionOperand::TearDownCaches(); | 
| 1148 } | 1190 } | 
| 1149 | 1191 | 
| 1150 }  // namespace compiler | 1192 }  // namespace compiler | 
| 1151 }  // namespace internal | 1193 }  // namespace internal | 
| 1152 }  // namespace v8 | 1194 }  // namespace v8 | 
| OLD | NEW | 
|---|