Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: src/compiler/pipeline.cc

Issue 1168693002: [turbofan] Allow ReplaceWithValue to kill control. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/typer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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* jsgraph, Zone* zone)
416 : GraphReducer(zone, jsgraph->graph(), jsgraph->TheHoleConstant(),
417 jsgraph->DeadControl()) {}
418 ~JSGraphReducer() final {}
419 };
420
421
413 void AddReducer(PipelineData* data, GraphReducer* graph_reducer, 422 void AddReducer(PipelineData* data, GraphReducer* graph_reducer,
414 Reducer* reducer) { 423 Reducer* reducer) {
415 if (data->info()->is_source_positions_enabled()) { 424 if (data->info()->is_source_positions_enabled()) {
416 void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper)); 425 void* const buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper));
417 SourcePositionWrapper* const wrapper = 426 SourcePositionWrapper* const wrapper =
418 new (buffer) SourcePositionWrapper(reducer, data->source_positions()); 427 new (buffer) SourcePositionWrapper(reducer, data->source_positions());
419 graph_reducer->AddReducer(wrapper); 428 graph_reducer->AddReducer(wrapper);
420 } else { 429 } else {
421 graph_reducer->AddReducer(reducer); 430 graph_reducer->AddReducer(reducer);
422 } 431 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 490 }
482 } 491 }
483 }; 492 };
484 493
485 494
486 struct ContextSpecializerPhase { 495 struct ContextSpecializerPhase {
487 static const char* phase_name() { return "context specializing"; } 496 static const char* phase_name() { return "context specializing"; }
488 497
489 void Run(PipelineData* data, Zone* temp_zone) { 498 void Run(PipelineData* data, Zone* temp_zone) {
490 JSContextSpecializer spec(data->jsgraph()); 499 JSContextSpecializer spec(data->jsgraph());
491 GraphReducer graph_reducer(data->graph(), temp_zone); 500 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
492 AddReducer(data, &graph_reducer, &spec); 501 AddReducer(data, &graph_reducer, &spec);
493 graph_reducer.ReduceGraph(); 502 graph_reducer.ReduceGraph();
494 } 503 }
495 }; 504 };
496 505
497 506
498 struct InliningPhase { 507 struct InliningPhase {
499 static const char* phase_name() { return "inlining"; } 508 static const char* phase_name() { return "inlining"; }
500 509
501 void Run(PipelineData* data, Zone* temp_zone) { 510 void Run(PipelineData* data, Zone* temp_zone) {
502 GraphReducer graph_reducer(data->graph(), temp_zone); 511 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
503 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() 512 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled()
504 ? JSInliner::kGeneralInlining 513 ? JSInliner::kGeneralInlining
505 : JSInliner::kRestrictedInlining, 514 : JSInliner::kRestrictedInlining,
506 temp_zone, data->info(), data->jsgraph()); 515 temp_zone, data->info(), data->jsgraph());
507 AddReducer(data, &graph_reducer, &inliner); 516 AddReducer(data, &graph_reducer, &inliner);
508 graph_reducer.ReduceGraph(); 517 graph_reducer.ReduceGraph();
509 } 518 }
510 }; 519 };
511 520
512 521
(...skipping 15 matching lines...) Expand all
528 537
529 538
530 struct JSTypeFeedbackPhase { 539 struct JSTypeFeedbackPhase {
531 static const char* phase_name() { return "type feedback specializing"; } 540 static const char* phase_name() { return "type feedback specializing"; }
532 541
533 void Run(PipelineData* data, Zone* temp_zone) { 542 void Run(PipelineData* data, Zone* temp_zone) {
534 Handle<Context> native_context(data->info()->context()->native_context()); 543 Handle<Context> native_context(data->info()->context()->native_context());
535 TypeFeedbackOracle oracle(data->isolate(), temp_zone, 544 TypeFeedbackOracle oracle(data->isolate(), temp_zone,
536 data->info()->unoptimized_code(), 545 data->info()->unoptimized_code(),
537 data->info()->feedback_vector(), native_context); 546 data->info()->feedback_vector(), native_context);
538 GraphReducer graph_reducer(data->graph(), temp_zone); 547 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
539 Handle<GlobalObject> global_object = Handle<GlobalObject>::null(); 548 Handle<GlobalObject> global_object = Handle<GlobalObject>::null();
540 if (data->info()->has_global_object()) { 549 if (data->info()->has_global_object()) {
541 global_object = 550 global_object =
542 Handle<GlobalObject>(data->info()->global_object(), data->isolate()); 551 Handle<GlobalObject>(data->info()->global_object(), data->isolate());
543 } 552 }
544 // TODO(titzer): introduce a specialization mode/flags enum to control 553 // TODO(titzer): introduce a specialization mode/flags enum to control
545 // specializing to the global object here. 554 // specializing to the global object here.
546 JSTypeFeedbackSpecializer specializer( 555 JSTypeFeedbackSpecializer specializer(
547 &graph_reducer, data->jsgraph(), data->js_type_feedback(), &oracle, 556 &graph_reducer, data->jsgraph(), data->js_type_feedback(), &oracle,
548 global_object, data->info()->is_deoptimization_enabled() 557 global_object, data->info()->is_deoptimization_enabled()
549 ? JSTypeFeedbackSpecializer::kDeoptimizationEnabled 558 ? JSTypeFeedbackSpecializer::kDeoptimizationEnabled
550 : JSTypeFeedbackSpecializer::kDeoptimizationDisabled, 559 : JSTypeFeedbackSpecializer::kDeoptimizationDisabled,
551 data->info()->dependencies()); 560 data->info()->dependencies());
552 AddReducer(data, &graph_reducer, &specializer); 561 AddReducer(data, &graph_reducer, &specializer);
553 graph_reducer.ReduceGraph(); 562 graph_reducer.ReduceGraph();
554 } 563 }
555 }; 564 };
556 565
557 566
558 struct TypedLoweringPhase { 567 struct TypedLoweringPhase {
559 static const char* phase_name() { return "typed lowering"; } 568 static const char* phase_name() { return "typed lowering"; }
560 569
561 void Run(PipelineData* data, Zone* temp_zone) { 570 void Run(PipelineData* data, Zone* temp_zone) {
562 GraphReducer graph_reducer(data->graph(), temp_zone); 571 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
563 LoadElimination load_elimination; 572 LoadElimination load_elimination;
564 JSBuiltinReducer builtin_reducer(data->jsgraph()); 573 JSBuiltinReducer builtin_reducer(data->jsgraph());
565 JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone); 574 JSTypedLowering typed_lowering(&graph_reducer, data->jsgraph(), temp_zone);
566 JSIntrinsicLowering intrinsic_lowering( 575 JSIntrinsicLowering intrinsic_lowering(
567 &graph_reducer, data->jsgraph(), 576 &graph_reducer, data->jsgraph(),
568 data->info()->is_deoptimization_enabled() 577 data->info()->is_deoptimization_enabled()
569 ? JSIntrinsicLowering::kDeoptimizationEnabled 578 ? JSIntrinsicLowering::kDeoptimizationEnabled
570 : JSIntrinsicLowering::kDeoptimizationDisabled); 579 : JSIntrinsicLowering::kDeoptimizationDisabled);
571 CommonOperatorReducer common_reducer(data->jsgraph()); 580 CommonOperatorReducer common_reducer(data->jsgraph());
572 AddReducer(data, &graph_reducer, &builtin_reducer); 581 AddReducer(data, &graph_reducer, &builtin_reducer);
573 AddReducer(data, &graph_reducer, &typed_lowering); 582 AddReducer(data, &graph_reducer, &typed_lowering);
574 AddReducer(data, &graph_reducer, &intrinsic_lowering); 583 AddReducer(data, &graph_reducer, &intrinsic_lowering);
575 AddReducer(data, &graph_reducer, &load_elimination); 584 AddReducer(data, &graph_reducer, &load_elimination);
576 AddReducer(data, &graph_reducer, &common_reducer); 585 AddReducer(data, &graph_reducer, &common_reducer);
577 graph_reducer.ReduceGraph(); 586 graph_reducer.ReduceGraph();
578 } 587 }
579 }; 588 };
580 589
581 590
582 struct SimplifiedLoweringPhase { 591 struct SimplifiedLoweringPhase {
583 static const char* phase_name() { return "simplified lowering"; } 592 static const char* phase_name() { return "simplified lowering"; }
584 593
585 void Run(PipelineData* data, Zone* temp_zone) { 594 void Run(PipelineData* data, Zone* temp_zone) {
586 SimplifiedLowering lowering(data->jsgraph(), temp_zone, 595 SimplifiedLowering lowering(data->jsgraph(), temp_zone,
587 data->source_positions()); 596 data->source_positions());
588 lowering.LowerAllNodes(); 597 lowering.LowerAllNodes();
589 ValueNumberingReducer vn_reducer(temp_zone); 598 ValueNumberingReducer vn_reducer(temp_zone);
590 MachineOperatorReducer machine_reducer(data->jsgraph()); 599 MachineOperatorReducer machine_reducer(data->jsgraph());
591 CommonOperatorReducer common_reducer(data->jsgraph()); 600 CommonOperatorReducer common_reducer(data->jsgraph());
592 GraphReducer graph_reducer(data->graph(), temp_zone); 601 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
593 AddReducer(data, &graph_reducer, &vn_reducer); 602 AddReducer(data, &graph_reducer, &vn_reducer);
594 AddReducer(data, &graph_reducer, &machine_reducer); 603 AddReducer(data, &graph_reducer, &machine_reducer);
595 AddReducer(data, &graph_reducer, &common_reducer); 604 AddReducer(data, &graph_reducer, &common_reducer);
596 graph_reducer.ReduceGraph(); 605 graph_reducer.ReduceGraph();
597 } 606 }
598 }; 607 };
599 608
600 609
601 struct ControlFlowOptimizationPhase { 610 struct ControlFlowOptimizationPhase {
602 static const char* phase_name() { return "control flow optimization"; } 611 static const char* phase_name() { return "control flow optimization"; }
603 612
604 void Run(PipelineData* data, Zone* temp_zone) { 613 void Run(PipelineData* data, Zone* temp_zone) {
605 ControlFlowOptimizer optimizer(data->graph(), data->common(), 614 ControlFlowOptimizer optimizer(data->graph(), data->common(),
606 data->machine(), temp_zone); 615 data->machine(), temp_zone);
607 optimizer.Optimize(); 616 optimizer.Optimize();
608 } 617 }
609 }; 618 };
610 619
611 620
612 struct ChangeLoweringPhase { 621 struct ChangeLoweringPhase {
613 static const char* phase_name() { return "change lowering"; } 622 static const char* phase_name() { return "change lowering"; }
614 623
615 void Run(PipelineData* data, Zone* temp_zone) { 624 void Run(PipelineData* data, Zone* temp_zone) {
616 ValueNumberingReducer vn_reducer(temp_zone); 625 ValueNumberingReducer vn_reducer(temp_zone);
617 ChangeLowering lowering(data->jsgraph()); 626 ChangeLowering lowering(data->jsgraph());
618 MachineOperatorReducer machine_reducer(data->jsgraph()); 627 MachineOperatorReducer machine_reducer(data->jsgraph());
619 CommonOperatorReducer common_reducer(data->jsgraph()); 628 CommonOperatorReducer common_reducer(data->jsgraph());
620 GraphReducer graph_reducer(data->graph(), temp_zone); 629 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
621 AddReducer(data, &graph_reducer, &vn_reducer); 630 AddReducer(data, &graph_reducer, &vn_reducer);
622 AddReducer(data, &graph_reducer, &lowering); 631 AddReducer(data, &graph_reducer, &lowering);
623 AddReducer(data, &graph_reducer, &machine_reducer); 632 AddReducer(data, &graph_reducer, &machine_reducer);
624 AddReducer(data, &graph_reducer, &common_reducer); 633 AddReducer(data, &graph_reducer, &common_reducer);
625 graph_reducer.ReduceGraph(); 634 graph_reducer.ReduceGraph();
626 } 635 }
627 }; 636 };
628 637
629 638
630 struct EarlyControlReductionPhase { 639 struct EarlyControlReductionPhase {
(...skipping 28 matching lines...) Expand all
659 668
660 669
661 struct GenericLoweringPhase { 670 struct GenericLoweringPhase {
662 static const char* phase_name() { return "generic lowering"; } 671 static const char* phase_name() { return "generic lowering"; }
663 672
664 void Run(PipelineData* data, Zone* temp_zone) { 673 void Run(PipelineData* data, Zone* temp_zone) {
665 JSGenericLowering generic(data->info()->is_typing_enabled(), 674 JSGenericLowering generic(data->info()->is_typing_enabled(),
666 data->jsgraph()); 675 data->jsgraph());
667 SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); 676 SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common());
668 TailCallOptimization tco(data->common(), data->graph()); 677 TailCallOptimization tco(data->common(), data->graph());
669 GraphReducer graph_reducer(data->graph(), temp_zone); 678 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
670 AddReducer(data, &graph_reducer, &generic); 679 AddReducer(data, &graph_reducer, &generic);
671 AddReducer(data, &graph_reducer, &select); 680 AddReducer(data, &graph_reducer, &select);
672 // TODO(turbofan): TCO is currently limited to stubs. 681 // TODO(turbofan): TCO is currently limited to stubs.
673 if (data->info()->IsStub()) AddReducer(data, &graph_reducer, &tco); 682 if (data->info()->IsStub()) AddReducer(data, &graph_reducer, &tco);
674 graph_reducer.ReduceGraph(); 683 graph_reducer.ReduceGraph();
675 } 684 }
676 }; 685 };
677 686
678 687
679 struct ComputeSchedulePhase { 688 struct ComputeSchedulePhase {
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 tcf << AsC1VRegisterAllocationData("CodeGen", 1329 tcf << AsC1VRegisterAllocationData("CodeGen",
1321 data->register_allocation_data()); 1330 data->register_allocation_data());
1322 } 1331 }
1323 1332
1324 data->DeleteRegisterAllocationZone(); 1333 data->DeleteRegisterAllocationZone();
1325 } 1334 }
1326 1335
1327 } // namespace compiler 1336 } // namespace compiler
1328 } // namespace internal 1337 } // namespace internal
1329 } // namespace v8 1338 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698