OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "lithium-allocator-inl.h" | 9 #include "lithium-allocator-inl.h" |
10 #include "ia32/lithium-ia32.h" | 10 #include "ia32/lithium-ia32.h" |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 chunk_->AddInstruction(dummy, current_block_); | 882 chunk_->AddInstruction(dummy, current_block_); |
883 } | 883 } |
884 } else { | 884 } else { |
885 instr = current->CompileToLithium(this); | 885 instr = current->CompileToLithium(this); |
886 } | 886 } |
887 | 887 |
888 argument_count_ += current->argument_delta(); | 888 argument_count_ += current->argument_delta(); |
889 ASSERT(argument_count_ >= 0); | 889 ASSERT(argument_count_ >= 0); |
890 | 890 |
891 if (instr != NULL) { | 891 if (instr != NULL) { |
892 // Associate the hydrogen instruction first, since we may need it for | 892 AddInstruction(instr, current); |
893 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. | 893 } |
894 instr->set_hydrogen_value(current); | |
895 | 894 |
896 #if DEBUG | |
897 // Make sure that the lithium instruction has either no fixed register | |
898 // constraints in temps or the result OR no uses that are only used at | |
899 // start. If this invariant doesn't hold, the register allocator can decide | |
900 // to insert a split of a range immediately before the instruction due to an | |
901 // already allocated register needing to be used for the instruction's fixed | |
902 // register constraint. In this case, The register allocator won't see an | |
903 // interference between the split child and the use-at-start (it would if | |
904 // the it was just a plain use), so it is free to move the split child into | |
905 // the same register that is used for the use-at-start. | |
906 // See https://code.google.com/p/chromium/issues/detail?id=201590 | |
907 if (!(instr->ClobbersRegisters() && | |
908 instr->ClobbersDoubleRegisters(isolate()))) { | |
909 int fixed = 0; | |
910 int used_at_start = 0; | |
911 for (UseIterator it(instr); !it.Done(); it.Advance()) { | |
912 LUnallocated* operand = LUnallocated::cast(it.Current()); | |
913 if (operand->IsUsedAtStart()) ++used_at_start; | |
914 } | |
915 if (instr->Output() != NULL) { | |
916 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; | |
917 } | |
918 for (TempIterator it(instr); !it.Done(); it.Advance()) { | |
919 LUnallocated* operand = LUnallocated::cast(it.Current()); | |
920 if (operand->HasFixedPolicy()) ++fixed; | |
921 } | |
922 ASSERT(fixed == 0 || used_at_start == 0); | |
923 } | |
924 #endif | |
925 | |
926 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | |
927 instr = AssignPointerMap(instr); | |
928 } | |
929 if (FLAG_stress_environments && !instr->HasEnvironment()) { | |
930 instr = AssignEnvironment(instr); | |
931 } | |
932 chunk_->AddInstruction(instr, current_block_); | |
933 | |
934 if (instr->IsCall()) { | |
935 HValue* hydrogen_value_for_lazy_bailout = current; | |
936 LInstruction* instruction_needing_environment = NULL; | |
937 if (current->HasObservableSideEffects()) { | |
938 HSimulate* sim = HSimulate::cast(current->next()); | |
939 instruction_needing_environment = instr; | |
940 sim->ReplayEnvironment(current_block_->last_environment()); | |
941 hydrogen_value_for_lazy_bailout = sim; | |
942 } | |
943 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); | |
944 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); | |
945 chunk_->AddInstruction(bailout, current_block_); | |
946 if (instruction_needing_environment != NULL) { | |
947 // Store the lazy deopt environment with the instruction if needed. | |
948 // Right now it is only used for LInstanceOfKnownGlobal. | |
949 instruction_needing_environment-> | |
950 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); | |
951 } | |
952 } | |
953 } | |
954 current_instruction_ = old_current; | 895 current_instruction_ = old_current; |
955 } | 896 } |
956 | 897 |
957 | 898 |
| 899 void LChunkBuilder::AddInstruction(LInstruction* instr, |
| 900 HInstruction* hydrogen_val) { |
| 901 // Associate the hydrogen instruction first, since we may need it for |
| 902 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. |
| 903 instr->set_hydrogen_value(hydrogen_val); |
| 904 |
| 905 #if DEBUG |
| 906 // Make sure that the lithium instruction has either no fixed register |
| 907 // constraints in temps or the result OR no uses that are only used at |
| 908 // start. If this invariant doesn't hold, the register allocator can decide |
| 909 // to insert a split of a range immediately before the instruction due to an |
| 910 // already allocated register needing to be used for the instruction's fixed |
| 911 // register constraint. In this case, The register allocator won't see an |
| 912 // interference between the split child and the use-at-start (it would if |
| 913 // the it was just a plain use), so it is free to move the split child into |
| 914 // the same register that is used for the use-at-start. |
| 915 // See https://code.google.com/p/chromium/issues/detail?id=201590 |
| 916 if (!(instr->ClobbersRegisters() && |
| 917 instr->ClobbersDoubleRegisters(isolate()))) { |
| 918 int fixed = 0; |
| 919 int used_at_start = 0; |
| 920 for (UseIterator it(instr); !it.Done(); it.Advance()) { |
| 921 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 922 if (operand->IsUsedAtStart()) ++used_at_start; |
| 923 } |
| 924 if (instr->Output() != NULL) { |
| 925 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; |
| 926 } |
| 927 for (TempIterator it(instr); !it.Done(); it.Advance()) { |
| 928 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 929 if (operand->HasFixedPolicy()) ++fixed; |
| 930 } |
| 931 ASSERT(fixed == 0 || used_at_start == 0); |
| 932 } |
| 933 #endif |
| 934 |
| 935 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 936 instr = AssignPointerMap(instr); |
| 937 } |
| 938 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 939 instr = AssignEnvironment(instr); |
| 940 } |
| 941 chunk_->AddInstruction(instr, current_block_); |
| 942 |
| 943 if (instr->IsCall()) { |
| 944 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; |
| 945 LInstruction* instruction_needing_environment = NULL; |
| 946 if (hydrogen_val->HasObservableSideEffects()) { |
| 947 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); |
| 948 instruction_needing_environment = instr; |
| 949 sim->ReplayEnvironment(current_block_->last_environment()); |
| 950 hydrogen_value_for_lazy_bailout = sim; |
| 951 } |
| 952 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); |
| 953 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); |
| 954 chunk_->AddInstruction(bailout, current_block_); |
| 955 if (instruction_needing_environment != NULL) { |
| 956 // Store the lazy deopt environment with the instruction if needed. |
| 957 // Right now it is only used for LInstanceOfKnownGlobal. |
| 958 instruction_needing_environment-> |
| 959 SetDeferredLazyDeoptimizationEnvironment(bailout->environment()); |
| 960 } |
| 961 } |
| 962 } |
| 963 |
| 964 |
958 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 965 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
959 return new(zone()) LGoto(instr->FirstSuccessor()); | 966 return new(zone()) LGoto(instr->FirstSuccessor()); |
960 } | 967 } |
961 | 968 |
962 | 969 |
963 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | 970 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { |
964 LInstruction* goto_instr = CheckElideControlInstruction(instr); | 971 LInstruction* goto_instr = CheckElideControlInstruction(instr); |
965 if (goto_instr != NULL) return goto_instr; | 972 if (goto_instr != NULL) return goto_instr; |
966 | 973 |
967 HValue* value = instr->value(); | 974 HValue* value = instr->value(); |
(...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 LOperand* index = UseTempRegister(instr->index()); | 2674 LOperand* index = UseTempRegister(instr->index()); |
2668 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); | 2675 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); |
2669 LInstruction* result = DefineSameAsFirst(load); | 2676 LInstruction* result = DefineSameAsFirst(load); |
2670 return AssignPointerMap(result); | 2677 return AssignPointerMap(result); |
2671 } | 2678 } |
2672 | 2679 |
2673 | 2680 |
2674 } } // namespace v8::internal | 2681 } } // namespace v8::internal |
2675 | 2682 |
2676 #endif // V8_TARGET_ARCH_IA32 | 2683 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |