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

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 6352006: Remove instruction summaries and provide a LIR-interface for the register all... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #if defined(V8_TARGET_ARCH_IA32) 30 #if defined(V8_TARGET_ARCH_IA32)
31 31
32 #include "lithium-allocator-inl.h"
32 #include "ia32/lithium-ia32.h" 33 #include "ia32/lithium-ia32.h"
33 #include "ia32/lithium-codegen-ia32.h" 34 #include "ia32/lithium-codegen-ia32.h"
34 35
35 namespace v8 { 36 namespace v8 {
36 namespace internal { 37 namespace internal {
37 38
38 #define DEFINE_COMPILE(type) \ 39 #define DEFINE_COMPILE(type) \
39 void L##type::CompileToNative(LCodeGen* generator) { \ 40 void L##type::CompileToNative(LCodeGen* generator) { \
40 generator->Do##type(this); \ 41 generator->Do##type(this); \
41 } 42 }
(...skipping 19 matching lines...) Expand all
61 62
62 63
63 void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index, 64 void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index,
64 LOperand* spill_operand) { 65 LOperand* spill_operand) {
65 ASSERT(spill_operand->IsDoubleStackSlot()); 66 ASSERT(spill_operand->IsDoubleStackSlot());
66 ASSERT(double_register_spills_[allocation_index] == NULL); 67 ASSERT(double_register_spills_[allocation_index] == NULL);
67 double_register_spills_[allocation_index] = spill_operand; 68 double_register_spills_[allocation_index] = spill_operand;
68 } 69 }
69 70
70 71
72 TempIterator LInstruction::GetTempIterator() { return TempIterator(this); }
73
74
75 UseIterator LInstruction::GetUseIterator() { return UseIterator(this); }
76
77
78 #ifdef DEBUG
79 void LInstruction::VerifyCall() {
80 // Call instructions can use only fixed registers as
81 // temporaries and outputs because all registers
82 // are blocked by the calling convention.
83 // Inputs can use either fixed register or have a short lifetime (be
84 // used at start of the instruction).
85 ASSERT(Output() == NULL ||
86 LUnallocated::cast(Output())->HasFixedPolicy() ||
87 !LUnallocated::cast(Output())->HasRegisterPolicy());
88 for (UseIterator it = GetUseIterator(); it.HasNext(); ) {
Kevin Millikin (Chromium) 2011/01/20 12:20:30 I don't think the GetUseIterator/GetTempIterator f
fschneider 2011/01/20 17:13:08 Done.
89 LOperand* operand = it.Next();
90 ASSERT(LUnallocated::cast(operand)->HasFixedPolicy() ||
91 LUnallocated::cast(operand)->IsUsedAtStart() ||
92 !LUnallocated::cast(operand)->HasRegisterPolicy());
93 }
94 for (TempIterator it = GetTempIterator(); it.HasNext(); ) {
95 LOperand* operand = it.Next();
96 ASSERT(LUnallocated::cast(operand)->HasFixedPolicy() ||
97 !LUnallocated::cast(operand)->HasRegisterPolicy());
98 }
99 }
100 #endif
101
102
71 void LInstruction::PrintTo(StringStream* stream) { 103 void LInstruction::PrintTo(StringStream* stream) {
72 stream->Add("%s ", this->Mnemonic()); 104 stream->Add("%s ", this->Mnemonic());
73 if (HasResult()) { 105
74 PrintOutputOperandTo(stream); 106 PrintOutputOperandTo(stream);
75 }
76 107
77 PrintDataTo(stream); 108 PrintDataTo(stream);
78 109
79 if (HasEnvironment()) { 110 if (HasEnvironment()) {
80 stream->Add(" "); 111 stream->Add(" ");
81 environment()->PrintTo(stream); 112 environment()->PrintTo(stream);
82 } 113 }
83 114
84 if (HasPointerMap()) { 115 if (HasPointerMap()) {
85 stream->Add(" "); 116 stream->Add(" ");
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 693
663 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() { 694 void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() {
664 instructions_pending_deoptimization_environment_ = NULL; 695 instructions_pending_deoptimization_environment_ = NULL;
665 pending_deoptimization_ast_id_ = AstNode::kNoNumber; 696 pending_deoptimization_ast_id_ = AstNode::kNoNumber;
666 } 697 }
667 698
668 699
669 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, 700 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
670 HInstruction* hinstr, 701 HInstruction* hinstr,
671 CanDeoptimize can_deoptimize) { 702 CanDeoptimize can_deoptimize) {
672 allocator_->MarkAsCall(); 703 #ifdef DEBUG
704 instr->VerifyCall();
705 #endif
706 instr->MarkAsCall();
673 instr = AssignPointerMap(instr); 707 instr = AssignPointerMap(instr);
674 708
675 if (hinstr->HasSideEffects()) { 709 if (hinstr->HasSideEffects()) {
676 ASSERT(hinstr->next()->IsSimulate()); 710 ASSERT(hinstr->next()->IsSimulate());
677 HSimulate* sim = HSimulate::cast(hinstr->next()); 711 HSimulate* sim = HSimulate::cast(hinstr->next());
678 instr = SetInstructionPendingDeoptimizationEnvironment( 712 instr = SetInstructionPendingDeoptimizationEnvironment(
679 instr, sim->ast_id()); 713 instr, sim->ast_id());
680 } 714 }
681 715
682 // If instruction does not have side-effects lazy deoptimization 716 // If instruction does not have side-effects lazy deoptimization
683 // after the call will try to deoptimize to the point before the call. 717 // after the call will try to deoptimize to the point before the call.
684 // Thus we still need to attach environment to this call even if 718 // Thus we still need to attach environment to this call even if
685 // call sequence can not deoptimize eagerly. 719 // call sequence can not deoptimize eagerly.
686 bool needs_environment = 720 bool needs_environment =
687 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects(); 721 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || !hinstr->HasSideEffects();
688 if (needs_environment && !instr->HasEnvironment()) { 722 if (needs_environment && !instr->HasEnvironment()) {
689 instr = AssignEnvironment(instr); 723 instr = AssignEnvironment(instr);
690 } 724 }
691 725
692 return instr; 726 return instr;
693 } 727 }
694 728
695 729
696 LInstruction* LChunkBuilder::MarkAsSaveDoubles(LInstruction* instr) { 730 LInstruction* LChunkBuilder::MarkAsSaveDoubles(LInstruction* instr) {
697 allocator_->MarkAsSaveDoubles(); 731 instr->MarkAsSaveDoubles();
698 return instr; 732 return instr;
699 } 733 }
700 734
701 735
702 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { 736 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
703 ASSERT(!instr->HasPointerMap()); 737 ASSERT(!instr->HasPointerMap());
704 instr->set_pointer_map(new LPointerMap(position_)); 738 instr->set_pointer_map(new LPointerMap(position_));
705 return instr; 739 return instr;
706 } 740 }
707 741
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } 910 }
877 block->set_argument_count(argument_count_); 911 block->set_argument_count(argument_count_);
878 next_block_ = NULL; 912 next_block_ = NULL;
879 current_block_ = NULL; 913 current_block_ = NULL;
880 } 914 }
881 915
882 916
883 void LChunkBuilder::VisitInstruction(HInstruction* current) { 917 void LChunkBuilder::VisitInstruction(HInstruction* current) {
884 HInstruction* old_current = current_instruction_; 918 HInstruction* old_current = current_instruction_;
885 current_instruction_ = current; 919 current_instruction_ = current;
886 allocator_->BeginInstruction();
887 if (current->has_position()) position_ = current->position(); 920 if (current->has_position()) position_ = current->position();
888 LInstruction* instr = current->CompileToLithium(this); 921 LInstruction* instr = current->CompileToLithium(this);
889 922
890 if (instr != NULL) { 923 if (instr != NULL) {
891 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { 924 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
892 instr = AssignPointerMap(instr); 925 instr = AssignPointerMap(instr);
893 } 926 }
894 if (FLAG_stress_environments && !instr->HasEnvironment()) { 927 if (FLAG_stress_environments && !instr->HasEnvironment()) {
895 instr = AssignEnvironment(instr); 928 instr = AssignEnvironment(instr);
896 } 929 }
897 if (current->IsBranch() && !instr->IsGoto()) { 930 if (current->IsBranch() && !instr->IsGoto()) {
898 // TODO(fschneider): Handle branch instructions uniformly like 931 // TODO(fschneider): Handle branch instructions uniformly like
899 // other instructions. This requires us to generate the right 932 // other instructions. This requires us to generate the right
900 // branch instruction already at the HIR level. 933 // branch instruction already at the HIR level.
901 ASSERT(instr->IsControl()); 934 ASSERT(instr->IsControl());
902 HBranch* branch = HBranch::cast(current); 935 HBranch* branch = HBranch::cast(current);
903 instr->set_hydrogen_value(branch->value()); 936 instr->set_hydrogen_value(branch->value());
904 HBasicBlock* first = branch->FirstSuccessor(); 937 HBasicBlock* first = branch->FirstSuccessor();
905 HBasicBlock* second = branch->SecondSuccessor(); 938 HBasicBlock* second = branch->SecondSuccessor();
906 ASSERT(first != NULL && second != NULL); 939 ASSERT(first != NULL && second != NULL);
907 instr->SetBranchTargets(first->block_id(), second->block_id()); 940 instr->SetBranchTargets(first->block_id(), second->block_id());
908 } else { 941 } else {
909 instr->set_hydrogen_value(current); 942 instr->set_hydrogen_value(current);
910 } 943 }
911 944
912 int index = chunk_->AddInstruction(instr, current_block_); 945 chunk_->AddInstruction(instr, current_block_);
Kevin Millikin (Chromium) 2011/01/20 12:20:30 Since you now always ignore the return value, you
fschneider 2011/01/20 17:13:08 Done.
Kevin Millikin (Chromium) 2011/02/04 11:48:09 I mean "make AddInstruction a void function".
913 allocator_->SummarizeInstruction(index);
914 } else {
915 // This instruction should be omitted.
916 allocator_->OmitInstruction();
917 } 946 }
947
918 current_instruction_ = old_current; 948 current_instruction_ = old_current;
919 } 949 }
920 950
921 951
922 LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) { 952 LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) {
923 if (hydrogen_env == NULL) return NULL; 953 if (hydrogen_env == NULL) return NULL;
924 954
925 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer()); 955 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer());
926 int ast_id = hydrogen_env->ast_id(); 956 int ast_id = hydrogen_env->ast_id();
927 ASSERT(ast_id != AstNode::kNoNumber); 957 ASSERT(ast_id != AstNode::kNoNumber);
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { 1916 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
1887 HEnvironment* outer = current_block_->last_environment()->outer(); 1917 HEnvironment* outer = current_block_->last_environment()->outer();
1888 current_block_->UpdateEnvironment(outer); 1918 current_block_->UpdateEnvironment(outer);
1889 return NULL; 1919 return NULL;
1890 } 1920 }
1891 1921
1892 1922
1893 } } // namespace v8::internal 1923 } } // namespace v8::internal
1894 1924
1895 #endif // V8_TARGET_ARCH_IA32 1925 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698