| 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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 if (needs_environment && !instr->HasEnvironment()) { | 658 if (needs_environment && !instr->HasEnvironment()) { |
| 659 instr = AssignEnvironment(instr); | 659 instr = AssignEnvironment(instr); |
| 660 } | 660 } |
| 661 | 661 |
| 662 return instr; | 662 return instr; |
| 663 } | 663 } |
| 664 | 664 |
| 665 | 665 |
| 666 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { | 666 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { |
| 667 ASSERT(!instr->HasPointerMap()); | 667 ASSERT(!instr->HasPointerMap()); |
| 668 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); | 668 instr->set_pointer_map(new(zone()) LPointerMap(zone())); |
| 669 return instr; | 669 return instr; |
| 670 } | 670 } |
| 671 | 671 |
| 672 | 672 |
| 673 LUnallocated* LChunkBuilder::TempRegister() { | 673 LUnallocated* LChunkBuilder::TempRegister() { |
| 674 LUnallocated* operand = | 674 LUnallocated* operand = |
| 675 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 675 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
| 676 int vreg = allocator_->GetVirtualRegister(); | 676 int vreg = allocator_->GetVirtualRegister(); |
| 677 if (!allocator_->AllocationOk()) { | 677 if (!allocator_->AllocationOk()) { |
| 678 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); | 678 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 } | 852 } |
| 853 block->set_argument_count(argument_count_); | 853 block->set_argument_count(argument_count_); |
| 854 next_block_ = NULL; | 854 next_block_ = NULL; |
| 855 current_block_ = NULL; | 855 current_block_ = NULL; |
| 856 } | 856 } |
| 857 | 857 |
| 858 | 858 |
| 859 void LChunkBuilder::VisitInstruction(HInstruction* current) { | 859 void LChunkBuilder::VisitInstruction(HInstruction* current) { |
| 860 HInstruction* old_current = current_instruction_; | 860 HInstruction* old_current = current_instruction_; |
| 861 current_instruction_ = current; | 861 current_instruction_ = current; |
| 862 if (current->has_position()) position_ = current->position(); | |
| 863 | 862 |
| 864 LInstruction* instr = NULL; | 863 LInstruction* instr = NULL; |
| 865 if (current->CanReplaceWithDummyUses()) { | 864 if (current->CanReplaceWithDummyUses()) { |
| 866 HValue* first_operand = current->OperandCount() == 0 | 865 HValue* first_operand = current->OperandCount() == 0 |
| 867 ? graph()->GetConstant1() | 866 ? graph()->GetConstant1() |
| 868 : current->OperandAt(0); | 867 : current->OperandAt(0); |
| 869 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand))); | 868 instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand))); |
| 870 for (int i = 1; i < current->OperandCount(); ++i) { | 869 for (int i = 1; i < current->OperandCount(); ++i) { |
| 871 LInstruction* dummy = | 870 LInstruction* dummy = |
| 872 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); | 871 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; | 906 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; |
| 908 } | 907 } |
| 909 for (TempIterator it(instr); !it.Done(); it.Advance()) { | 908 for (TempIterator it(instr); !it.Done(); it.Advance()) { |
| 910 LUnallocated* operand = LUnallocated::cast(it.Current()); | 909 LUnallocated* operand = LUnallocated::cast(it.Current()); |
| 911 if (operand->HasFixedPolicy()) ++fixed; | 910 if (operand->HasFixedPolicy()) ++fixed; |
| 912 } | 911 } |
| 913 ASSERT(fixed == 0 || used_at_start == 0); | 912 ASSERT(fixed == 0 || used_at_start == 0); |
| 914 } | 913 } |
| 915 #endif | 914 #endif |
| 916 | 915 |
| 917 instr->set_position(position_); | |
| 918 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | 916 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { |
| 919 instr = AssignPointerMap(instr); | 917 instr = AssignPointerMap(instr); |
| 920 } | 918 } |
| 921 if (FLAG_stress_environments && !instr->HasEnvironment()) { | 919 if (FLAG_stress_environments && !instr->HasEnvironment()) { |
| 922 instr = AssignEnvironment(instr); | 920 instr = AssignEnvironment(instr); |
| 923 } | 921 } |
| 924 chunk_->AddInstruction(instr, current_block_); | 922 chunk_->AddInstruction(instr, current_block_); |
| 925 } | 923 } |
| 926 current_instruction_ = old_current; | 924 current_instruction_ = old_current; |
| 927 } | 925 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 | 1068 |
| 1071 LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( | 1069 LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( |
| 1072 HInstanceOfKnownGlobal* instr) { | 1070 HInstanceOfKnownGlobal* instr) { |
| 1073 LInstanceOfKnownGlobal* result = | 1071 LInstanceOfKnownGlobal* result = |
| 1074 new(zone()) LInstanceOfKnownGlobal(UseFixed(instr->left(), rax), | 1072 new(zone()) LInstanceOfKnownGlobal(UseFixed(instr->left(), rax), |
| 1075 FixedTemp(rdi)); | 1073 FixedTemp(rdi)); |
| 1076 return MarkAsCall(DefineFixed(result, rax), instr); | 1074 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1077 } | 1075 } |
| 1078 | 1076 |
| 1079 | 1077 |
| 1080 LInstruction* LChunkBuilder::DoInstanceSize(HInstanceSize* instr) { | |
| 1081 LOperand* object = UseRegisterAtStart(instr->object()); | |
| 1082 return DefineAsRegister(new(zone()) LInstanceSize(object)); | |
| 1083 } | |
| 1084 | |
| 1085 | |
| 1086 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 1078 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 1087 LOperand* receiver = UseRegister(instr->receiver()); | 1079 LOperand* receiver = UseRegister(instr->receiver()); |
| 1088 LOperand* function = UseRegisterAtStart(instr->function()); | 1080 LOperand* function = UseRegisterAtStart(instr->function()); |
| 1089 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); | 1081 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); |
| 1090 return AssignEnvironment(DefineSameAsFirst(result)); | 1082 return AssignEnvironment(DefineSameAsFirst(result)); |
| 1091 } | 1083 } |
| 1092 | 1084 |
| 1093 | 1085 |
| 1094 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { | 1086 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { |
| 1095 LOperand* function = UseFixed(instr->function(), rdi); | 1087 LOperand* function = UseFixed(instr->function(), rdi); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 | 1207 |
| 1216 | 1208 |
| 1217 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { | 1209 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { |
| 1218 LOperand* input = UseRegisterAtStart(instr->value()); | 1210 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1219 LMathAbs* result = new(zone()) LMathAbs(input); | 1211 LMathAbs* result = new(zone()) LMathAbs(input); |
| 1220 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1212 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 1221 } | 1213 } |
| 1222 | 1214 |
| 1223 | 1215 |
| 1224 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { | 1216 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { |
| 1225 LOperand* input = UseFixedDouble(instr->value(), xmm1); | 1217 ASSERT(instr->representation().IsDouble()); |
| 1218 ASSERT(instr->value()->representation().IsDouble()); |
| 1219 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1226 LMathLog* result = new(zone()) LMathLog(input); | 1220 LMathLog* result = new(zone()) LMathLog(input); |
| 1227 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); | 1221 return DefineSameAsFirst(result); |
| 1228 } | 1222 } |
| 1229 | 1223 |
| 1230 | 1224 |
| 1231 LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { | 1225 LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) { |
| 1232 LOperand* input = UseFixedDouble(instr->value(), xmm1); | 1226 LOperand* input = UseFixedDouble(instr->value(), xmm1); |
| 1233 LMathSin* result = new(zone()) LMathSin(input); | 1227 LMathSin* result = new(zone()) LMathSin(input); |
| 1234 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); | 1228 return MarkAsCall(DefineFixedDouble(result, xmm1), instr); |
| 1235 } | 1229 } |
| 1236 | 1230 |
| 1237 | 1231 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 LOperand* value = UseRegister(instr->value()); | 1815 LOperand* value = UseRegister(instr->value()); |
| 1822 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1816 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1823 } | 1817 } |
| 1824 from = Representation::Tagged(); | 1818 from = Representation::Tagged(); |
| 1825 } | 1819 } |
| 1826 // Only mark conversions that might need to allocate as calling rather than | 1820 // Only mark conversions that might need to allocate as calling rather than |
| 1827 // all changes. This makes simple, non-allocating conversion not have to force | 1821 // all changes. This makes simple, non-allocating conversion not have to force |
| 1828 // building a stack frame. | 1822 // building a stack frame. |
| 1829 if (from.IsTagged()) { | 1823 if (from.IsTagged()) { |
| 1830 if (to.IsDouble()) { | 1824 if (to.IsDouble()) { |
| 1831 info()->MarkAsDeferredCalling(); | |
| 1832 LOperand* value = UseRegister(instr->value()); | 1825 LOperand* value = UseRegister(instr->value()); |
| 1833 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1826 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
| 1834 return AssignEnvironment(DefineAsRegister(res)); | 1827 return AssignEnvironment(DefineAsRegister(res)); |
| 1835 } else if (to.IsSmi()) { | 1828 } else if (to.IsSmi()) { |
| 1836 HValue* val = instr->value(); | 1829 HValue* val = instr->value(); |
| 1837 LOperand* value = UseRegister(val); | 1830 LOperand* value = UseRegister(val); |
| 1838 if (val->type().IsSmi()) { | 1831 if (val->type().IsSmi()) { |
| 1839 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1832 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1840 } | 1833 } |
| 1841 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); | 1834 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1876 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 1884 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1877 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
| 1885 return DefineSameAsFirst(new(zone()) LSmiTag(value)); | 1878 return DefineSameAsFirst(new(zone()) LSmiTag(value)); |
| 1886 } else { | 1879 } else { |
| 1887 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1880 LNumberTagI* result = new(zone()) LNumberTagI(value); |
| 1888 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1881 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| 1889 } | 1882 } |
| 1890 } else if (to.IsSmi()) { | 1883 } else if (to.IsSmi()) { |
| 1891 HValue* val = instr->value(); | 1884 HValue* val = instr->value(); |
| 1892 LOperand* value = UseRegister(val); | 1885 LOperand* value = UseRegister(val); |
| 1893 LInstruction* result = | 1886 LInstruction* result = NULL; |
| 1894 DefineAsRegister(new(zone()) LInteger32ToSmi(value)); | 1887 if (val->CheckFlag(HInstruction::kUint32)) { |
| 1895 if (val->HasRange() && val->range()->IsInSmiRange()) { | 1888 result = DefineAsRegister(new(zone()) LUint32ToSmi(value)); |
| 1896 return result; | 1889 if (val->HasRange() && val->range()->IsInSmiRange() && |
| 1890 val->range()->upper() != kMaxInt) { |
| 1891 return result; |
| 1892 } |
| 1893 } else { |
| 1894 result = DefineAsRegister(new(zone()) LInteger32ToSmi(value)); |
| 1895 if (val->HasRange() && val->range()->IsInSmiRange()) { |
| 1896 return result; |
| 1897 } |
| 1897 } | 1898 } |
| 1898 return AssignEnvironment(result); | 1899 return AssignEnvironment(result); |
| 1899 } else { | 1900 } else { |
| 1900 if (instr->value()->CheckFlag(HInstruction::kUint32)) { | 1901 if (instr->value()->CheckFlag(HInstruction::kUint32)) { |
| 1901 LOperand* temp = FixedTemp(xmm1); | 1902 LOperand* temp = FixedTemp(xmm1); |
| 1902 return DefineAsRegister( | 1903 return DefineAsRegister( |
| 1903 new(zone()) LUint32ToDouble(UseRegister(instr->value()), temp)); | 1904 new(zone()) LUint32ToDouble(UseRegister(instr->value()), temp)); |
| 1904 } else { | 1905 } else { |
| 1905 ASSERT(to.IsDouble()); | 1906 ASSERT(to.IsDouble()); |
| 1906 LOperand* value = Use(instr->value()); | 1907 LOperand* value = Use(instr->value()); |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2544 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2545 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2545 LOperand* object = UseRegister(instr->object()); | 2546 LOperand* object = UseRegister(instr->object()); |
| 2546 LOperand* index = UseTempRegister(instr->index()); | 2547 LOperand* index = UseTempRegister(instr->index()); |
| 2547 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2548 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2548 } | 2549 } |
| 2549 | 2550 |
| 2550 | 2551 |
| 2551 } } // namespace v8::internal | 2552 } } // namespace v8::internal |
| 2552 | 2553 |
| 2553 #endif // V8_TARGET_ARCH_X64 | 2554 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |