OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 HConstant* HGraph::GetConstantFalse() { | 626 HConstant* HGraph::GetConstantFalse() { |
627 return GetConstant(&constant_false_, isolate()->factory()->false_value()); | 627 return GetConstant(&constant_false_, isolate()->factory()->false_value()); |
628 } | 628 } |
629 | 629 |
630 | 630 |
631 HConstant* HGraph::GetConstantHole() { | 631 HConstant* HGraph::GetConstantHole() { |
632 return GetConstant(&constant_hole_, isolate()->factory()->the_hole_value()); | 632 return GetConstant(&constant_hole_, isolate()->factory()->the_hole_value()); |
633 } | 633 } |
634 | 634 |
635 | 635 |
| 636 HGraphBuilder::CheckBuilder::CheckBuilder(HGraphBuilder* builder, BailoutId id) |
| 637 : builder_(builder), |
| 638 finished_(false), |
| 639 id_(id) { |
| 640 HEnvironment* env = builder->environment(); |
| 641 failure_block_ = builder->CreateBasicBlock(env->Copy()); |
| 642 merge_block_ = builder->CreateBasicBlock(env->Copy()); |
| 643 } |
| 644 |
| 645 |
| 646 void HGraphBuilder::CheckBuilder::CheckNotUndefined(HValue* value) { |
| 647 HEnvironment* env = builder_->environment(); |
| 648 HIsNilAndBranch* compare = |
| 649 new(zone()) HIsNilAndBranch(value, kStrictEquality, kUndefinedValue); |
| 650 HBasicBlock* success_block = builder_->CreateBasicBlock(env->Copy()); |
| 651 HBasicBlock* failure_block = builder_->CreateBasicBlock(env->Copy()); |
| 652 compare->SetSuccessorAt(0, failure_block); |
| 653 compare->SetSuccessorAt(1, success_block); |
| 654 failure_block->Goto(failure_block_); |
| 655 builder_->current_block()->Finish(compare); |
| 656 builder_->set_current_block(success_block); |
| 657 } |
| 658 |
| 659 |
| 660 void HGraphBuilder::CheckBuilder::CheckIntegerEq(HValue* left, HValue* right) { |
| 661 HEnvironment* env = builder_->environment(); |
| 662 HCompareIDAndBranch* compare = |
| 663 new(zone()) HCompareIDAndBranch(left, right, Token::EQ); |
| 664 compare->AssumeRepresentation(Representation::Integer32()); |
| 665 HBasicBlock* success_block = builder_->CreateBasicBlock(env->Copy()); |
| 666 HBasicBlock* failure_block = builder_->CreateBasicBlock(env->Copy()); |
| 667 compare->SetSuccessorAt(0, success_block); |
| 668 compare->SetSuccessorAt(1, failure_block); |
| 669 failure_block->Goto(failure_block_); |
| 670 builder_->current_block()->Finish(compare); |
| 671 builder_->set_current_block(success_block); |
| 672 } |
| 673 |
| 674 |
| 675 void HGraphBuilder::CheckBuilder::End() { |
| 676 ASSERT(!finished_); |
| 677 builder_->current_block()->Goto(merge_block_); |
| 678 failure_block_->FinishExitWithDeoptimization(HDeoptimize::kUseAll); |
| 679 failure_block_->SetJoinId(id_); |
| 680 builder_->set_current_block(merge_block_); |
| 681 merge_block_->SetJoinId(id_); |
| 682 finished_ = true; |
| 683 } |
| 684 |
| 685 |
636 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, BailoutId id) | 686 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, BailoutId id) |
637 : builder_(builder), | 687 : builder_(builder), |
638 finished_(false), | 688 finished_(false), |
639 id_(id) { | 689 id_(id) { |
640 HEnvironment* env = builder->environment(); | 690 HEnvironment* env = builder->environment(); |
641 HEnvironment* true_env = env->Copy(); | 691 true_block_ = builder->CreateBasicBlock(env->Copy()); |
642 HEnvironment* false_env = env->Copy(); | 692 false_block_ = builder->CreateBasicBlock(env->Copy()); |
643 HEnvironment* merge_env = env->Copy(); | 693 merge_block_ = builder->CreateBasicBlock(env->Copy()); |
644 true_block_ = builder->CreateBasicBlock(true_env); | |
645 false_block_ = builder->CreateBasicBlock(false_env); | |
646 merge_block_ = builder->CreateBasicBlock(merge_env); | |
647 } | 694 } |
648 | 695 |
649 | 696 |
650 void HGraphBuilder::IfBuilder::BeginTrue(HValue* left, | 697 void HGraphBuilder::IfBuilder::BeginTrue(HValue* left, |
651 HValue* right, | 698 HValue* right, |
652 Token::Value token) { | 699 Token::Value token) { |
653 HCompareIDAndBranch* compare = | 700 HCompareIDAndBranch* compare = |
654 new(zone()) HCompareIDAndBranch(left, right, token); | 701 new(zone()) HCompareIDAndBranch(left, right, token); |
655 compare->ChangeRepresentation(Representation::Integer32()); | 702 compare->ChangeRepresentation(Representation::Integer32()); |
656 compare->SetSuccessorAt(0, true_block_); | 703 compare->SetSuccessorAt(0, true_block_); |
(...skipping 21 matching lines...) Expand all Loading... |
678 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, | 725 HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, |
679 HValue* context, | 726 HValue* context, |
680 LoopBuilder::Direction direction, | 727 LoopBuilder::Direction direction, |
681 BailoutId id) | 728 BailoutId id) |
682 : builder_(builder), | 729 : builder_(builder), |
683 context_(context), | 730 context_(context), |
684 direction_(direction), | 731 direction_(direction), |
685 id_(id), | 732 id_(id), |
686 finished_(false) { | 733 finished_(false) { |
687 HEnvironment* env = builder_->environment(); | 734 HEnvironment* env = builder_->environment(); |
688 HEnvironment* body_env = env->Copy(); | |
689 HEnvironment* exit_env = env->Copy(); | |
690 header_block_ = builder->CreateLoopHeaderBlock(); | 735 header_block_ = builder->CreateLoopHeaderBlock(); |
691 body_block_ = builder->CreateBasicBlock(body_env); | 736 body_block_ = builder->CreateBasicBlock(env->Copy()); |
692 exit_block_ = builder->CreateBasicBlock(exit_env); | 737 exit_block_ = builder->CreateBasicBlock(env->Copy()); |
693 } | 738 } |
694 | 739 |
695 | 740 |
696 HValue* HGraphBuilder::LoopBuilder::BeginBody(HValue* initial, | 741 HValue* HGraphBuilder::LoopBuilder::BeginBody(HValue* initial, |
697 HValue* terminating, | 742 HValue* terminating, |
698 Token::Value token) { | 743 Token::Value token) { |
699 phi_ = new(zone()) HPhi(0, zone()); | 744 phi_ = new(zone()) HPhi(0, zone()); |
700 header_block_->AddPhi(phi_); | 745 header_block_->AddPhi(phi_); |
701 phi_->AddInput(initial); | 746 phi_->AddInput(initial); |
702 phi_->ChangeRepresentation(Representation::Integer32()); | 747 phi_->ChangeRepresentation(Representation::Integer32()); |
(...skipping 9919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10622 } | 10667 } |
10623 } | 10668 } |
10624 | 10669 |
10625 #ifdef DEBUG | 10670 #ifdef DEBUG |
10626 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10671 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10627 if (allocator_ != NULL) allocator_->Verify(); | 10672 if (allocator_ != NULL) allocator_->Verify(); |
10628 #endif | 10673 #endif |
10629 } | 10674 } |
10630 | 10675 |
10631 } } // namespace v8::internal | 10676 } } // namespace v8::internal |
OLD | NEW |