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/adapters.h" | 10 #include "src/base/adapters.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 } | 403 } |
404 | 404 |
405 private: | 405 private: |
406 Reducer* const reducer_; | 406 Reducer* const reducer_; |
407 SourcePositionTable* const table_; | 407 SourcePositionTable* const table_; |
408 | 408 |
409 DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); | 409 DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); |
410 }; | 410 }; |
411 | 411 |
412 | 412 |
413 class JSGraphReducer final : public GraphReducer { | |
414 public: | |
415 JSGraphReducer(JSGraph* js, Zone* zone) | |
416 : GraphReducer(js->graph(), dead_value(js), dead_control(js), zone) {} | |
titzer
2015/06/05 09:42:26
Why not just inline these private methods?
Michael Starzinger
2015/06/05 11:06:55
Done.
| |
417 | |
418 private: | |
419 Node* dead_value(JSGraph* jsgraph) { return jsgraph->TheHoleConstant(); } | |
420 Node* dead_control(JSGraph* jsgraph) { return jsgraph->DeadControl(); } | |
421 }; | |
422 | |
423 | |
413 void AddReducer(PipelineData* data, GraphReducer* graph_reducer, | 424 void AddReducer(PipelineData* data, GraphReducer* graph_reducer, |
414 Reducer* reducer) { | 425 Reducer* reducer) { |
415 if (data->info()->is_source_positions_enabled()) { | 426 if (data->info()->is_source_positions_enabled()) { |
416 void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); | 427 void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); |
417 SourcePositionWrapper* const wrapper = | 428 SourcePositionWrapper* const wrapper = |
418 new (buffer) SourcePositionWrapper(reducer, data->source_positions()); | 429 new (buffer) SourcePositionWrapper(reducer, data->source_positions()); |
419 graph_reducer->AddReducer(wrapper); | 430 graph_reducer->AddReducer(wrapper); |
420 } else { | 431 } else { |
421 graph_reducer->AddReducer(reducer); | 432 graph_reducer->AddReducer(reducer); |
422 } | 433 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
481 } | 492 } |
482 } | 493 } |
483 }; | 494 }; |
484 | 495 |
485 | 496 |
486 struct ContextSpecializerPhase { | 497 struct ContextSpecializerPhase { |
487 static const char* phase_name() { return "context specializing"; } | 498 static const char* phase_name() { return "context specializing"; } |
488 | 499 |
489 void Run(PipelineData* data, Zone* temp_zone) { | 500 void Run(PipelineData* data, Zone* temp_zone) { |
490 JSContextSpecializer spec(data->jsgraph()); | 501 JSContextSpecializer spec(data->jsgraph()); |
491 GraphReducer graph_reducer(data->graph(), temp_zone); | 502 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
492 AddReducer(data, &graph_reducer, &spec); | 503 AddReducer(data, &graph_reducer, &spec); |
493 graph_reducer.ReduceGraph(); | 504 graph_reducer.ReduceGraph(); |
494 } | 505 } |
495 }; | 506 }; |
496 | 507 |
497 | 508 |
498 struct InliningPhase { | 509 struct InliningPhase { |
499 static const char* phase_name() { return "inlining"; } | 510 static const char* phase_name() { return "inlining"; } |
500 | 511 |
501 void Run(PipelineData* data, Zone* temp_zone) { | 512 void Run(PipelineData* data, Zone* temp_zone) { |
502 GraphReducer graph_reducer(data->graph(), temp_zone); | 513 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
503 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() | 514 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() |
504 ? JSInliner::kGeneralInlining | 515 ? JSInliner::kGeneralInlining |
505 : JSInliner::kRestrictedInlining, | 516 : JSInliner::kRestrictedInlining, |
506 temp_zone, data->info(), data->jsgraph()); | 517 temp_zone, data->info(), data->jsgraph()); |
507 AddReducer(data, &graph_reducer, &inliner); | 518 AddReducer(data, &graph_reducer, &inliner); |
508 graph_reducer.ReduceGraph(); | 519 graph_reducer.ReduceGraph(); |
509 } | 520 } |
510 }; | 521 }; |
511 | 522 |
512 | 523 |
(...skipping 15 matching lines...) Expand all Loading... | |
528 | 539 |
529 | 540 |
530 struct JSTypeFeedbackPhase { | 541 struct JSTypeFeedbackPhase { |
531 static const char* phase_name() { return "type feedback specializing"; } | 542 static const char* phase_name() { return "type feedback specializing"; } |
532 | 543 |
533 void Run(PipelineData* data, Zone* temp_zone) { | 544 void Run(PipelineData* data, Zone* temp_zone) { |
534 Handle<Context> native_context(data->info()->context()->native_context()); | 545 Handle<Context> native_context(data->info()->context()->native_context()); |
535 TypeFeedbackOracle oracle(data->isolate(), temp_zone, | 546 TypeFeedbackOracle oracle(data->isolate(), temp_zone, |
536 data->info()->unoptimized_code(), | 547 data->info()->unoptimized_code(), |
537 data->info()->feedback_vector(), native_context); | 548 data->info()->feedback_vector(), native_context); |
538 GraphReducer graph_reducer(data->graph(), temp_zone); | 549 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
539 Handle<GlobalObject> global_object = Handle<GlobalObject>::null(); | 550 Handle<GlobalObject> global_object = Handle<GlobalObject>::null(); |
540 if (data->info()->has_global_object()) { | 551 if (data->info()->has_global_object()) { |
541 global_object = | 552 global_object = |
542 Handle<GlobalObject>(data->info()->global_object(), data->isolate()); | 553 Handle<GlobalObject>(data->info()->global_object(), data->isolate()); |
543 } | 554 } |
544 // TODO(titzer): introduce a specialization mode/flags enum to control | 555 // TODO(titzer): introduce a specialization mode/flags enum to control |
545 // specializing to the global object here. | 556 // specializing to the global object here. |
546 JSTypeFeedbackSpecializer specializer( | 557 JSTypeFeedbackSpecializer specializer( |
547 &graph_reducer, data->jsgraph(), data->js_type_feedback(), &oracle, | 558 &graph_reducer, data->jsgraph(), data->js_type_feedback(), &oracle, |
548 global_object, data->info()->is_deoptimization_enabled() | 559 global_object, data->info()->is_deoptimization_enabled() |
549 ? JSTypeFeedbackSpecializer::kDeoptimizationEnabled | 560 ? JSTypeFeedbackSpecializer::kDeoptimizationEnabled |
550 : JSTypeFeedbackSpecializer::kDeoptimizationDisabled, | 561 : JSTypeFeedbackSpecializer::kDeoptimizationDisabled, |
551 data->info()->dependencies()); | 562 data->info()->dependencies()); |
552 AddReducer(data, &graph_reducer, &specializer); | 563 AddReducer(data, &graph_reducer, &specializer); |
553 graph_reducer.ReduceGraph(); | 564 graph_reducer.ReduceGraph(); |
554 } | 565 } |
555 }; | 566 }; |
556 | 567 |
557 | 568 |
558 struct TypedLoweringPhase { | 569 struct TypedLoweringPhase { |
559 static const char* phase_name() { return "typed lowering"; } | 570 static const char* phase_name() { return "typed lowering"; } |
560 | 571 |
561 void Run(PipelineData* data, Zone* temp_zone) { | 572 void Run(PipelineData* data, Zone* temp_zone) { |
562 GraphReducer graph_reducer(data->graph(), temp_zone); | 573 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
563 LoadElimination load_elimination; | 574 LoadElimination load_elimination; |
564 JSBuiltinReducer builtin_reducer(data->jsgraph()); | 575 JSBuiltinReducer builtin_reducer(data->jsgraph()); |
565 JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone); | 576 JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone); |
566 JSIntrinsicLowering intrinsic_lowering( | 577 JSIntrinsicLowering intrinsic_lowering( |
567 &graph_reducer, data->jsgraph(), | 578 &graph_reducer, data->jsgraph(), |
568 data->info()->is_deoptimization_enabled() | 579 data->info()->is_deoptimization_enabled() |
569 ? JSIntrinsicLowering::kDeoptimizationEnabled | 580 ? JSIntrinsicLowering::kDeoptimizationEnabled |
570 : JSIntrinsicLowering::kDeoptimizationDisabled); | 581 : JSIntrinsicLowering::kDeoptimizationDisabled); |
571 CommonOperatorReducer common_reducer(data->jsgraph()); | 582 CommonOperatorReducer common_reducer(data->jsgraph()); |
572 AddReducer(data, &graph_reducer, &builtin_reducer); | 583 AddReducer(data, &graph_reducer, &builtin_reducer); |
573 AddReducer(data, &graph_reducer, &typed_lowering); | 584 AddReducer(data, &graph_reducer, &typed_lowering); |
574 AddReducer(data, &graph_reducer, &intrinsic_lowering); | 585 AddReducer(data, &graph_reducer, &intrinsic_lowering); |
575 AddReducer(data, &graph_reducer, &load_elimination); | 586 AddReducer(data, &graph_reducer, &load_elimination); |
576 AddReducer(data, &graph_reducer, &common_reducer); | 587 AddReducer(data, &graph_reducer, &common_reducer); |
577 graph_reducer.ReduceGraph(); | 588 graph_reducer.ReduceGraph(); |
578 } | 589 } |
579 }; | 590 }; |
580 | 591 |
581 | 592 |
582 struct SimplifiedLoweringPhase { | 593 struct SimplifiedLoweringPhase { |
583 static const char* phase_name() { return "simplified lowering"; } | 594 static const char* phase_name() { return "simplified lowering"; } |
584 | 595 |
585 void Run(PipelineData* data, Zone* temp_zone) { | 596 void Run(PipelineData* data, Zone* temp_zone) { |
586 SimplifiedLowering lowering(data->jsgraph(), temp_zone, | 597 SimplifiedLowering lowering(data->jsgraph(), temp_zone, |
587 data->source_positions()); | 598 data->source_positions()); |
588 lowering.LowerAllNodes(); | 599 lowering.LowerAllNodes(); |
589 ValueNumberingReducer vn_reducer(temp_zone); | 600 ValueNumberingReducer vn_reducer(temp_zone); |
590 MachineOperatorReducer machine_reducer(data->jsgraph()); | 601 MachineOperatorReducer machine_reducer(data->jsgraph()); |
591 CommonOperatorReducer common_reducer(data->jsgraph()); | 602 CommonOperatorReducer common_reducer(data->jsgraph()); |
592 GraphReducer graph_reducer(data->graph(), temp_zone); | 603 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
593 AddReducer(data, &graph_reducer, &vn_reducer); | 604 AddReducer(data, &graph_reducer, &vn_reducer); |
594 AddReducer(data, &graph_reducer, &machine_reducer); | 605 AddReducer(data, &graph_reducer, &machine_reducer); |
595 AddReducer(data, &graph_reducer, &common_reducer); | 606 AddReducer(data, &graph_reducer, &common_reducer); |
596 graph_reducer.ReduceGraph(); | 607 graph_reducer.ReduceGraph(); |
597 } | 608 } |
598 }; | 609 }; |
599 | 610 |
600 | 611 |
601 struct ControlFlowOptimizationPhase { | 612 struct ControlFlowOptimizationPhase { |
602 static const char* phase_name() { return "control flow optimization"; } | 613 static const char* phase_name() { return "control flow optimization"; } |
603 | 614 |
604 void Run(PipelineData* data, Zone* temp_zone) { | 615 void Run(PipelineData* data, Zone* temp_zone) { |
605 ControlFlowOptimizer optimizer(data->graph(), data->common(), | 616 ControlFlowOptimizer optimizer(data->graph(), data->common(), |
606 data->machine(), temp_zone); | 617 data->machine(), temp_zone); |
607 optimizer.Optimize(); | 618 optimizer.Optimize(); |
608 } | 619 } |
609 }; | 620 }; |
610 | 621 |
611 | 622 |
612 struct ChangeLoweringPhase { | 623 struct ChangeLoweringPhase { |
613 static const char* phase_name() { return "change lowering"; } | 624 static const char* phase_name() { return "change lowering"; } |
614 | 625 |
615 void Run(PipelineData* data, Zone* temp_zone) { | 626 void Run(PipelineData* data, Zone* temp_zone) { |
616 ValueNumberingReducer vn_reducer(temp_zone); | 627 ValueNumberingReducer vn_reducer(temp_zone); |
617 ChangeLowering lowering(data->jsgraph()); | 628 ChangeLowering lowering(data->jsgraph()); |
618 MachineOperatorReducer machine_reducer(data->jsgraph()); | 629 MachineOperatorReducer machine_reducer(data->jsgraph()); |
619 CommonOperatorReducer common_reducer(data->jsgraph()); | 630 CommonOperatorReducer common_reducer(data->jsgraph()); |
620 GraphReducer graph_reducer(data->graph(), temp_zone); | 631 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
621 AddReducer(data, &graph_reducer, &vn_reducer); | 632 AddReducer(data, &graph_reducer, &vn_reducer); |
622 AddReducer(data, &graph_reducer, &lowering); | 633 AddReducer(data, &graph_reducer, &lowering); |
623 AddReducer(data, &graph_reducer, &machine_reducer); | 634 AddReducer(data, &graph_reducer, &machine_reducer); |
624 AddReducer(data, &graph_reducer, &common_reducer); | 635 AddReducer(data, &graph_reducer, &common_reducer); |
625 graph_reducer.ReduceGraph(); | 636 graph_reducer.ReduceGraph(); |
626 } | 637 } |
627 }; | 638 }; |
628 | 639 |
629 | 640 |
630 struct EarlyControlReductionPhase { | 641 struct EarlyControlReductionPhase { |
(...skipping 28 matching lines...) Expand all Loading... | |
659 | 670 |
660 | 671 |
661 struct GenericLoweringPhase { | 672 struct GenericLoweringPhase { |
662 static const char* phase_name() { return "generic lowering"; } | 673 static const char* phase_name() { return "generic lowering"; } |
663 | 674 |
664 void Run(PipelineData* data, Zone* temp_zone) { | 675 void Run(PipelineData* data, Zone* temp_zone) { |
665 JSGenericLowering generic(data->info()->is_typing_enabled(), | 676 JSGenericLowering generic(data->info()->is_typing_enabled(), |
666 data->jsgraph()); | 677 data->jsgraph()); |
667 SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); | 678 SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); |
668 TailCallOptimization tco(data->common(), data->graph()); | 679 TailCallOptimization tco(data->common(), data->graph()); |
669 GraphReducer graph_reducer(data->graph(), temp_zone); | 680 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
670 AddReducer(data, &graph_reducer, &generic); | 681 AddReducer(data, &graph_reducer, &generic); |
671 AddReducer(data, &graph_reducer, &select); | 682 AddReducer(data, &graph_reducer, &select); |
672 // TODO(turbofan): TCO is currently limited to stubs. | 683 // TODO(turbofan): TCO is currently limited to stubs. |
673 if (data->info()->IsStub()) AddReducer(data, &graph_reducer, &tco); | 684 if (data->info()->IsStub()) AddReducer(data, &graph_reducer, &tco); |
674 graph_reducer.ReduceGraph(); | 685 graph_reducer.ReduceGraph(); |
675 } | 686 } |
676 }; | 687 }; |
677 | 688 |
678 | 689 |
679 struct ComputeSchedulePhase { | 690 struct ComputeSchedulePhase { |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1320 tcf << AsC1VRegisterAllocationData("CodeGen", | 1331 tcf << AsC1VRegisterAllocationData("CodeGen", |
1321 data->register_allocation_data()); | 1332 data->register_allocation_data()); |
1322 } | 1333 } |
1323 | 1334 |
1324 data->DeleteRegisterAllocationZone(); | 1335 data->DeleteRegisterAllocationZone(); |
1325 } | 1336 } |
1326 | 1337 |
1327 } // namespace compiler | 1338 } // namespace compiler |
1328 } // namespace internal | 1339 } // namespace internal |
1329 } // namespace v8 | 1340 } // namespace v8 |
OLD | NEW |