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

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

Issue 296993002: Provide a helper to generate multiple Lithium instructions for one Hydrogen instruction. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments from Ulan Created 6 years, 7 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
« no previous file with comments | « src/x64/lithium-x64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "lithium-allocator-inl.h" 9 #include "lithium-allocator-inl.h"
10 #include "x64/lithium-x64.h" 10 #include "x64/lithium-x64.h"
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 chunk_->AddInstruction(dummy, current_block_); 849 chunk_->AddInstruction(dummy, current_block_);
850 } 850 }
851 } else { 851 } else {
852 instr = current->CompileToLithium(this); 852 instr = current->CompileToLithium(this);
853 } 853 }
854 854
855 argument_count_ += current->argument_delta(); 855 argument_count_ += current->argument_delta();
856 ASSERT(argument_count_ >= 0); 856 ASSERT(argument_count_ >= 0);
857 857
858 if (instr != NULL) { 858 if (instr != NULL) {
859 // Associate the hydrogen instruction first, since we may need it for 859 AddInstruction(instr, current);
860 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. 860 }
861 instr->set_hydrogen_value(current);
862 861
863 #if DEBUG
864 // Make sure that the lithium instruction has either no fixed register
865 // constraints in temps or the result OR no uses that are only used at
866 // start. If this invariant doesn't hold, the register allocator can decide
867 // to insert a split of a range immediately before the instruction due to an
868 // already allocated register needing to be used for the instruction's fixed
869 // register constraint. In this case, The register allocator won't see an
870 // interference between the split child and the use-at-start (it would if
871 // the it was just a plain use), so it is free to move the split child into
872 // the same register that is used for the use-at-start.
873 // See https://code.google.com/p/chromium/issues/detail?id=201590
874 if (!(instr->ClobbersRegisters() &&
875 instr->ClobbersDoubleRegisters(isolate()))) {
876 int fixed = 0;
877 int used_at_start = 0;
878 for (UseIterator it(instr); !it.Done(); it.Advance()) {
879 LUnallocated* operand = LUnallocated::cast(it.Current());
880 if (operand->IsUsedAtStart()) ++used_at_start;
881 }
882 if (instr->Output() != NULL) {
883 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
884 }
885 for (TempIterator it(instr); !it.Done(); it.Advance()) {
886 LUnallocated* operand = LUnallocated::cast(it.Current());
887 if (operand->HasFixedPolicy()) ++fixed;
888 }
889 ASSERT(fixed == 0 || used_at_start == 0);
890 }
891 #endif
892
893 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
894 instr = AssignPointerMap(instr);
895 }
896 if (FLAG_stress_environments && !instr->HasEnvironment()) {
897 instr = AssignEnvironment(instr);
898 }
899 chunk_->AddInstruction(instr, current_block_);
900
901 if (instr->IsCall()) {
902 HValue* hydrogen_value_for_lazy_bailout = current;
903 LInstruction* instruction_needing_environment = NULL;
904 if (current->HasObservableSideEffects()) {
905 HSimulate* sim = HSimulate::cast(current->next());
906 instruction_needing_environment = instr;
907 sim->ReplayEnvironment(current_block_->last_environment());
908 hydrogen_value_for_lazy_bailout = sim;
909 }
910 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout());
911 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout);
912 chunk_->AddInstruction(bailout, current_block_);
913 if (instruction_needing_environment != NULL) {
914 // Store the lazy deopt environment with the instruction if needed.
915 // Right now it is only used for LInstanceOfKnownGlobal.
916 instruction_needing_environment->
917 SetDeferredLazyDeoptimizationEnvironment(bailout->environment());
918 }
919 }
920 }
921 current_instruction_ = old_current; 862 current_instruction_ = old_current;
922 } 863 }
923 864
924 865
866 void LChunkBuilder::AddInstruction(LInstruction* instr,
867 HInstruction* hydrogen_val) {
868 // Associate the hydrogen instruction first, since we may need it for
869 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below.
870 instr->set_hydrogen_value(hydrogen_val);
871
872 #if DEBUG
873 // Make sure that the lithium instruction has either no fixed register
874 // constraints in temps or the result OR no uses that are only used at
875 // start. If this invariant doesn't hold, the register allocator can decide
876 // to insert a split of a range immediately before the instruction due to an
877 // already allocated register needing to be used for the instruction's fixed
878 // register constraint. In this case, The register allocator won't see an
879 // interference between the split child and the use-at-start (it would if
880 // the it was just a plain use), so it is free to move the split child into
881 // the same register that is used for the use-at-start.
882 // See https://code.google.com/p/chromium/issues/detail?id=201590
883 if (!(instr->ClobbersRegisters() &&
884 instr->ClobbersDoubleRegisters(isolate()))) {
885 int fixed = 0;
886 int used_at_start = 0;
887 for (UseIterator it(instr); !it.Done(); it.Advance()) {
888 LUnallocated* operand = LUnallocated::cast(it.Current());
889 if (operand->IsUsedAtStart()) ++used_at_start;
890 }
891 if (instr->Output() != NULL) {
892 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
893 }
894 for (TempIterator it(instr); !it.Done(); it.Advance()) {
895 LUnallocated* operand = LUnallocated::cast(it.Current());
896 if (operand->HasFixedPolicy()) ++fixed;
897 }
898 ASSERT(fixed == 0 || used_at_start == 0);
899 }
900 #endif
901
902 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
903 instr = AssignPointerMap(instr);
904 }
905 if (FLAG_stress_environments && !instr->HasEnvironment()) {
906 instr = AssignEnvironment(instr);
907 }
908 chunk_->AddInstruction(instr, current_block_);
909
910 if (instr->IsCall()) {
911 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val;
912 LInstruction* instruction_needing_environment = NULL;
913 if (hydrogen_val->HasObservableSideEffects()) {
914 HSimulate* sim = HSimulate::cast(hydrogen_val->next());
915 instruction_needing_environment = instr;
916 sim->ReplayEnvironment(current_block_->last_environment());
917 hydrogen_value_for_lazy_bailout = sim;
918 }
919 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout());
920 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout);
921 chunk_->AddInstruction(bailout, current_block_);
922 if (instruction_needing_environment != NULL) {
923 // Store the lazy deopt environment with the instruction if needed.
924 // Right now it is only used for LInstanceOfKnownGlobal.
925 instruction_needing_environment->
926 SetDeferredLazyDeoptimizationEnvironment(bailout->environment());
927 }
928 }
929 }
930
931
925 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { 932 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
926 return new(zone()) LGoto(instr->FirstSuccessor()); 933 return new(zone()) LGoto(instr->FirstSuccessor());
927 } 934 }
928 935
929 936
930 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { 937 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) {
931 return new(zone()) LDebugBreak(); 938 return new(zone()) LDebugBreak();
932 } 939 }
933 940
934 941
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 LOperand* index = UseTempRegister(instr->index()); 2600 LOperand* index = UseTempRegister(instr->index());
2594 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); 2601 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index);
2595 LInstruction* result = DefineSameAsFirst(load); 2602 LInstruction* result = DefineSameAsFirst(load);
2596 return AssignPointerMap(result); 2603 return AssignPointerMap(result);
2597 } 2604 }
2598 2605
2599 2606
2600 } } // namespace v8::internal 2607 } } // namespace v8::internal
2601 2608
2602 #endif // V8_TARGET_ARCH_X64 2609 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698