| 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 } | 842 } |
| 843 | 843 |
| 844 | 844 |
| 845 void LChunkBuilder::VisitInstruction(HInstruction* current) { | 845 void LChunkBuilder::VisitInstruction(HInstruction* current) { |
| 846 HInstruction* old_current = current_instruction_; | 846 HInstruction* old_current = current_instruction_; |
| 847 current_instruction_ = current; | 847 current_instruction_ = current; |
| 848 if (current->has_position()) position_ = current->position(); | 848 if (current->has_position()) position_ = current->position(); |
| 849 LInstruction* instr = current->CompileToLithium(this); | 849 LInstruction* instr = current->CompileToLithium(this); |
| 850 | 850 |
| 851 if (instr != NULL) { | 851 if (instr != NULL) { |
| 852 #if DEBUG |
| 853 // Make sure that the lithium instruction has either no fixed register |
| 854 // constraints in temps or the result OR no uses that are only used at |
| 855 // start. If this invariant doesn't hold, the register allocator can decide |
| 856 // to insert a split of a range immediately before the instruction due to an |
| 857 // already allocated register needing to be used for the instruction's fixed |
| 858 // register constraint. In this case, The register allocator won't see an |
| 859 // interference between the split child and the use-at-start (it would if |
| 860 // the it was just a plain use), so it is free to move the split child into |
| 861 // the same register that is used for the use-at-start. |
| 862 // See https://code.google.com/p/chromium/issues/detail?id=201590 |
| 863 if (!(instr->ClobbersRegisters() && instr->ClobbersDoubleRegisters())) { |
| 864 int fixed = 0; |
| 865 int used_at_start = 0; |
| 866 for (UseIterator it(instr); !it.Done(); it.Advance()) { |
| 867 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 868 if (operand->IsUsedAtStart()) ++used_at_start; |
| 869 } |
| 870 if (instr->Output() != NULL) { |
| 871 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; |
| 872 } |
| 873 for (TempIterator it(instr); !it.Done(); it.Advance()) { |
| 874 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 875 if (operand->HasFixedPolicy()) ++fixed; |
| 876 } |
| 877 ASSERT(fixed == 0 || used_at_start == 0); |
| 878 } |
| 879 #endif |
| 880 |
| 852 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 881 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 853 instr = AssignPointerMap(instr); | 882 instr = AssignPointerMap(instr); |
| 854 } | 883 } |
| 855 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 884 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 856 instr = AssignEnvironment(instr); | 885 instr = AssignEnvironment(instr); |
| 857 } | 886 } |
| 858 instr->set_hydrogen_value(current); | 887 instr->set_hydrogen_value(current); |
| 859 chunk_->AddInstruction(instr, current_block_); | 888 chunk_->AddInstruction(instr, current_block_); |
| 860 } | 889 } |
| 861 current_instruction_ = old_current; | 890 current_instruction_ = old_current; |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 LOperand* temp2 = TempRegister(); | 1106 LOperand* temp2 = TempRegister(); |
| 1078 LOperand* double_temp = FixedTemp(d3); // Chosen by fair dice roll. | 1107 LOperand* double_temp = FixedTemp(d3); // Chosen by fair dice roll. |
| 1079 LMathExp* result = new(zone()) LMathExp(input, double_temp, temp1, temp2); | 1108 LMathExp* result = new(zone()) LMathExp(input, double_temp, temp1, temp2); |
| 1080 return DefineAsRegister(result); | 1109 return DefineAsRegister(result); |
| 1081 } else if (op == kMathPowHalf) { | 1110 } else if (op == kMathPowHalf) { |
| 1082 LOperand* input = UseFixedDouble(instr->value(), d2); | 1111 LOperand* input = UseFixedDouble(instr->value(), d2); |
| 1083 LOperand* temp = FixedTemp(d3); | 1112 LOperand* temp = FixedTemp(d3); |
| 1084 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(input, temp); | 1113 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(input, temp); |
| 1085 return DefineFixedDouble(result, d2); | 1114 return DefineFixedDouble(result, d2); |
| 1086 } else { | 1115 } else { |
| 1087 LOperand* input = UseRegisterAtStart(instr->value()); | 1116 LOperand* input = UseRegister(instr->value()); |
| 1088 | 1117 |
| 1089 LOperand* temp = (op == kMathRound) ? FixedTemp(d3) : NULL; | 1118 LOperand* temp = (op == kMathRound) ? FixedTemp(d3) : NULL; |
| 1090 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(input, temp); | 1119 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(input, temp); |
| 1091 switch (op) { | 1120 switch (op) { |
| 1092 case kMathAbs: | 1121 case kMathAbs: |
| 1093 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); | 1122 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); |
| 1094 case kMathFloor: | 1123 case kMathFloor: |
| 1095 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); | 1124 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); |
| 1096 case kMathSqrt: | 1125 case kMathSqrt: |
| 1097 return DefineAsRegister(result); | 1126 return DefineAsRegister(result); |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 Representation from = instr->from(); | 1792 Representation from = instr->from(); |
| 1764 Representation to = instr->to(); | 1793 Representation to = instr->to(); |
| 1765 if (from.IsTagged()) { | 1794 if (from.IsTagged()) { |
| 1766 if (to.IsDouble()) { | 1795 if (to.IsDouble()) { |
| 1767 info()->MarkAsDeferredCalling(); | 1796 info()->MarkAsDeferredCalling(); |
| 1768 LOperand* value = UseRegister(instr->value()); | 1797 LOperand* value = UseRegister(instr->value()); |
| 1769 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1798 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
| 1770 return AssignEnvironment(DefineAsRegister(res)); | 1799 return AssignEnvironment(DefineAsRegister(res)); |
| 1771 } else { | 1800 } else { |
| 1772 ASSERT(to.IsInteger32()); | 1801 ASSERT(to.IsInteger32()); |
| 1773 LOperand* value = UseRegisterAtStart(instr->value()); | 1802 LOperand* value = NULL; |
| 1774 LInstruction* res = NULL; | 1803 LInstruction* res = NULL; |
| 1775 if (instr->value()->type().IsSmi()) { | 1804 if (instr->value()->type().IsSmi()) { |
| 1805 value = UseRegisterAtStart(instr->value()); |
| 1776 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1806 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
| 1777 } else { | 1807 } else { |
| 1808 value = UseRegister(instr->value()); |
| 1778 LOperand* temp1 = TempRegister(); | 1809 LOperand* temp1 = TempRegister(); |
| 1779 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() | 1810 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() |
| 1780 : NULL; | 1811 : NULL; |
| 1781 LOperand* temp3 = FixedTemp(d11); | 1812 LOperand* temp3 = FixedTemp(d11); |
| 1782 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, | 1813 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, |
| 1783 temp1, | 1814 temp1, |
| 1784 temp2, | 1815 temp2, |
| 1785 temp3)); | 1816 temp3)); |
| 1786 res = AssignEnvironment(res); | 1817 res = AssignEnvironment(res); |
| 1787 } | 1818 } |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2485 | 2516 |
| 2486 | 2517 |
| 2487 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2518 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2488 LOperand* object = UseRegister(instr->object()); | 2519 LOperand* object = UseRegister(instr->object()); |
| 2489 LOperand* index = UseRegister(instr->index()); | 2520 LOperand* index = UseRegister(instr->index()); |
| 2490 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2521 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2491 } | 2522 } |
| 2492 | 2523 |
| 2493 | 2524 |
| 2494 } } // namespace v8::internal | 2525 } } // namespace v8::internal |
| OLD | NEW |