OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 2882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2893 LLoadExternalArrayPointer* instr) { | 2893 LLoadExternalArrayPointer* instr) { |
2894 Register result = ToRegister(instr->result()); | 2894 Register result = ToRegister(instr->result()); |
2895 Register input = ToRegister(instr->object()); | 2895 Register input = ToRegister(instr->object()); |
2896 __ movq(result, FieldOperand(input, | 2896 __ movq(result, FieldOperand(input, |
2897 ExternalPixelArray::kExternalPointerOffset)); | 2897 ExternalPixelArray::kExternalPointerOffset)); |
2898 } | 2898 } |
2899 | 2899 |
2900 | 2900 |
2901 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { | 2901 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { |
2902 Register arguments = ToRegister(instr->arguments()); | 2902 Register arguments = ToRegister(instr->arguments()); |
2903 Register length = ToRegister(instr->length()); | |
2904 Register result = ToRegister(instr->result()); | 2903 Register result = ToRegister(instr->result()); |
2905 // There are two words between the frame pointer and the last argument. | 2904 |
2906 // Subtracting from length accounts for one of them add one more. | 2905 if (instr->length()->IsConstantOperand() && |
2907 if (instr->index()->IsRegister()) { | 2906 instr->index()->IsConstantOperand()) { |
2908 __ subl(length, ToRegister(instr->index())); | 2907 int const_index = ToInteger32(LConstantOperand::cast(instr->index())); |
| 2908 int const_length = ToInteger32(LConstantOperand::cast(instr->length())); |
| 2909 int index = (const_length - const_index) + 1; |
| 2910 __ movq(result, Operand(arguments, index * kPointerSize)); |
2909 } else { | 2911 } else { |
2910 __ subl(length, ToOperand(instr->index())); | 2912 Register length = ToRegister(instr->length()); |
| 2913 // There are two words between the frame pointer and the last argument. |
| 2914 // Subtracting from length accounts for one of them add one more. |
| 2915 if (instr->index()->IsRegister()) { |
| 2916 __ subl(length, ToRegister(instr->index())); |
| 2917 } else { |
| 2918 __ subl(length, ToOperand(instr->index())); |
| 2919 } |
| 2920 __ movq(result, |
| 2921 Operand(arguments, length, times_pointer_size, kPointerSize)); |
2911 } | 2922 } |
2912 __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize)); | |
2913 } | 2923 } |
2914 | 2924 |
2915 | 2925 |
2916 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { | 2926 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
2917 ElementsKind elements_kind = instr->elements_kind(); | 2927 ElementsKind elements_kind = instr->elements_kind(); |
2918 LOperand* key = instr->key(); | 2928 LOperand* key = instr->key(); |
2919 if (!key->IsConstantOperand()) { | 2929 if (!key->IsConstantOperand()) { |
2920 Register key_reg = ToRegister(key); | 2930 Register key_reg = ToRegister(key); |
2921 // Even though the HLoad/StoreKeyed (in this case) instructions force | 2931 // Even though the HLoad/StoreKeyed (in this case) instructions force |
2922 // the input representation for the key to be an integer, the input | 2932 // the input representation for the key to be an integer, the input |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3910 | 3920 |
3911 void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) { | 3921 void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) { |
3912 Register result = ToRegister(instr->result()); | 3922 Register result = ToRegister(instr->result()); |
3913 Register base = ToRegister(instr->base_object()); | 3923 Register base = ToRegister(instr->base_object()); |
3914 __ lea(result, Operand(base, instr->offset())); | 3924 __ lea(result, Operand(base, instr->offset())); |
3915 } | 3925 } |
3916 | 3926 |
3917 | 3927 |
3918 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { | 3928 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { |
3919 Register object = ToRegister(instr->object()); | 3929 Register object = ToRegister(instr->object()); |
3920 Register value = ToRegister(instr->value()); | |
3921 int offset = instr->offset(); | 3930 int offset = instr->offset(); |
3922 | 3931 |
3923 if (!instr->transition().is_null()) { | 3932 if (!instr->transition().is_null()) { |
3924 if (!instr->hydrogen()->NeedsWriteBarrierForMap()) { | 3933 if (!instr->hydrogen()->NeedsWriteBarrierForMap()) { |
3925 __ Move(FieldOperand(object, HeapObject::kMapOffset), | 3934 __ Move(FieldOperand(object, HeapObject::kMapOffset), |
3926 instr->transition()); | 3935 instr->transition()); |
3927 } else { | 3936 } else { |
3928 Register temp = ToRegister(instr->temp()); | 3937 Register temp = ToRegister(instr->temp()); |
3929 __ Move(kScratchRegister, instr->transition()); | 3938 __ Move(kScratchRegister, instr->transition()); |
3930 __ movq(FieldOperand(object, HeapObject::kMapOffset), kScratchRegister); | 3939 __ movq(FieldOperand(object, HeapObject::kMapOffset), kScratchRegister); |
3931 // Update the write barrier for the map field. | 3940 // Update the write barrier for the map field. |
3932 __ RecordWriteField(object, | 3941 __ RecordWriteField(object, |
3933 HeapObject::kMapOffset, | 3942 HeapObject::kMapOffset, |
3934 kScratchRegister, | 3943 kScratchRegister, |
3935 temp, | 3944 temp, |
3936 kSaveFPRegs, | 3945 kSaveFPRegs, |
3937 OMIT_REMEMBERED_SET, | 3946 OMIT_REMEMBERED_SET, |
3938 OMIT_SMI_CHECK); | 3947 OMIT_SMI_CHECK); |
3939 } | 3948 } |
3940 } | 3949 } |
3941 | 3950 |
3942 // Do the store. | 3951 // Do the store. |
3943 HType type = instr->hydrogen()->value()->type(); | 3952 HType type = instr->hydrogen()->value()->type(); |
3944 SmiCheck check_needed = | 3953 SmiCheck check_needed = |
3945 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; | 3954 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
3946 if (instr->is_in_object()) { | 3955 |
3947 __ movq(FieldOperand(object, offset), value); | 3956 Register write_register = object; |
3948 if (instr->hydrogen()->NeedsWriteBarrier()) { | 3957 if (!instr->is_in_object()) { |
3949 Register temp = ToRegister(instr->temp()); | 3958 write_register = ToRegister(instr->temp()); |
3950 // Update the write barrier for the object for in-object properties. | 3959 __ movq(write_register, FieldOperand(object, JSObject::kPropertiesOffset)); |
3951 __ RecordWriteField(object, | 3960 } |
3952 offset, | 3961 |
3953 value, | 3962 if (instr->value()->IsConstantOperand()) { |
3954 temp, | 3963 LConstantOperand* operand_value = LConstantOperand::cast(instr->value()); |
3955 kSaveFPRegs, | 3964 if (IsInteger32Constant(operand_value)) { |
3956 EMIT_REMEMBERED_SET, | 3965 int const_value = ToInteger32(operand_value); |
3957 check_needed); | 3966 __ movq(FieldOperand(write_register, offset), Immediate(const_value)); |
| 3967 } else { |
| 3968 if (operand_value->IsRegister()) { |
| 3969 __ movq(FieldOperand(write_register, offset), |
| 3970 ToRegister(operand_value)); |
| 3971 } else { |
| 3972 Handle<Object> handle_value = ToHandle(operand_value); |
| 3973 __ Move(FieldOperand(write_register, offset), handle_value); |
| 3974 } |
3958 } | 3975 } |
3959 } else { | 3976 } else { |
3960 Register temp = ToRegister(instr->temp()); | 3977 __ movq(FieldOperand(write_register, offset), ToRegister(instr->value())); |
3961 __ movq(temp, FieldOperand(object, JSObject::kPropertiesOffset)); | 3978 } |
3962 __ movq(FieldOperand(temp, offset), value); | 3979 |
3963 if (instr->hydrogen()->NeedsWriteBarrier()) { | 3980 if (instr->hydrogen()->NeedsWriteBarrier()) { |
3964 // Update the write barrier for the properties array. | 3981 Register value = ToRegister(instr->value()); |
3965 // object is used as a scratch register. | 3982 Register temp = instr->is_in_object() ? ToRegister(instr->temp()) : object; |
3966 __ RecordWriteField(temp, | 3983 // Update the write barrier for the object for in-object properties. |
3967 offset, | 3984 __ RecordWriteField(write_register, |
3968 value, | 3985 offset, |
3969 object, | 3986 value, |
3970 kSaveFPRegs, | 3987 temp, |
3971 EMIT_REMEMBERED_SET, | 3988 kSaveFPRegs, |
3972 check_needed); | 3989 EMIT_REMEMBERED_SET, |
3973 } | 3990 check_needed); |
3974 } | 3991 } |
3975 } | 3992 } |
3976 | 3993 |
3977 | 3994 |
3978 void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { | 3995 void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { |
3979 ASSERT(ToRegister(instr->object()).is(rdx)); | 3996 ASSERT(ToRegister(instr->object()).is(rdx)); |
3980 ASSERT(ToRegister(instr->value()).is(rax)); | 3997 ASSERT(ToRegister(instr->value()).is(rax)); |
3981 | 3998 |
3982 __ Move(rcx, instr->hydrogen()->name()); | 3999 __ Move(rcx, instr->hydrogen()->name()); |
3983 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) | 4000 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4129 key, | 4146 key, |
4130 FAST_DOUBLE_ELEMENTS, | 4147 FAST_DOUBLE_ELEMENTS, |
4131 FixedDoubleArray::kHeaderSize - kHeapObjectTag, | 4148 FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
4132 instr->additional_index()); | 4149 instr->additional_index()); |
4133 | 4150 |
4134 __ movsd(double_store_operand, value); | 4151 __ movsd(double_store_operand, value); |
4135 } | 4152 } |
4136 | 4153 |
4137 | 4154 |
4138 void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { | 4155 void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { |
4139 Register value = ToRegister(instr->value()); | |
4140 Register elements = ToRegister(instr->elements()); | 4156 Register elements = ToRegister(instr->elements()); |
4141 LOperand* key = instr->key(); | 4157 LOperand* key = instr->key(); |
4142 if (!key->IsConstantOperand()) { | 4158 if (!key->IsConstantOperand()) { |
4143 Register key_reg = ToRegister(key); | 4159 Register key_reg = ToRegister(key); |
4144 // Even though the HLoad/StoreKeyedFastElement instructions force | 4160 // Even though the HLoad/StoreKeyedFastElement instructions force |
4145 // the input representation for the key to be an integer, the | 4161 // the input representation for the key to be an integer, the |
4146 // input gets replaced during bound check elimination with the index | 4162 // input gets replaced during bound check elimination with the index |
4147 // argument to the bounds check, which can be tagged, so that case | 4163 // argument to the bounds check, which can be tagged, so that case |
4148 // must be handled here, too. | 4164 // must be handled here, too. |
4149 if (instr->hydrogen()->key()->representation().IsTagged()) { | 4165 if (instr->hydrogen()->key()->representation().IsTagged()) { |
4150 __ SmiToInteger64(key_reg, key_reg); | 4166 __ SmiToInteger64(key_reg, key_reg); |
4151 } else if (instr->hydrogen()->IsDehoisted()) { | 4167 } else if (instr->hydrogen()->IsDehoisted()) { |
4152 // Sign extend key because it could be a 32 bit negative value | 4168 // Sign extend key because it could be a 32 bit negative value |
4153 // and the dehoisted address computation happens in 64 bits | 4169 // and the dehoisted address computation happens in 64 bits |
4154 __ movsxlq(key_reg, key_reg); | 4170 __ movsxlq(key_reg, key_reg); |
4155 } | 4171 } |
4156 } | 4172 } |
4157 | 4173 |
4158 Operand operand = | 4174 Operand operand = |
4159 BuildFastArrayOperand(instr->elements(), | 4175 BuildFastArrayOperand(instr->elements(), |
4160 key, | 4176 key, |
4161 FAST_ELEMENTS, | 4177 FAST_ELEMENTS, |
4162 FixedArray::kHeaderSize - kHeapObjectTag, | 4178 FixedArray::kHeaderSize - kHeapObjectTag, |
4163 instr->additional_index()); | 4179 instr->additional_index()); |
| 4180 if (instr->value()->IsRegister()) { |
| 4181 __ movq(operand, ToRegister(instr->value())); |
| 4182 } else { |
| 4183 LConstantOperand* operand_value = LConstantOperand::cast(instr->value()); |
| 4184 if (IsInteger32Constant(operand_value)) { |
| 4185 int const_value = ToInteger32(operand_value); |
| 4186 __ movq(operand, Immediate(const_value)); |
| 4187 } else { |
| 4188 Handle<Object> handle_value = ToHandle(operand_value); |
| 4189 __ Move(operand, handle_value); |
| 4190 } |
| 4191 } |
4164 | 4192 |
4165 if (instr->hydrogen()->NeedsWriteBarrier()) { | 4193 if (instr->hydrogen()->NeedsWriteBarrier()) { |
| 4194 ASSERT(instr->value()->IsRegister()); |
| 4195 Register value = ToRegister(instr->value()); |
4166 ASSERT(!instr->key()->IsConstantOperand()); | 4196 ASSERT(!instr->key()->IsConstantOperand()); |
4167 HType type = instr->hydrogen()->value()->type(); | 4197 HType type = instr->hydrogen()->value()->type(); |
4168 SmiCheck check_needed = | 4198 SmiCheck check_needed = |
4169 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; | 4199 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
4170 // Compute address of modified element and store it into key register. | 4200 // Compute address of modified element and store it into key register. |
4171 Register key_reg(ToRegister(key)); | 4201 Register key_reg(ToRegister(key)); |
4172 __ lea(key_reg, operand); | 4202 __ lea(key_reg, operand); |
4173 __ movq(Operand(key_reg, 0), value); | |
4174 __ RecordWrite(elements, | 4203 __ RecordWrite(elements, |
4175 key_reg, | 4204 key_reg, |
4176 value, | 4205 value, |
4177 kSaveFPRegs, | 4206 kSaveFPRegs, |
4178 EMIT_REMEMBERED_SET, | 4207 EMIT_REMEMBERED_SET, |
4179 check_needed); | 4208 check_needed); |
4180 } else { | |
4181 __ movq(operand, value); | |
4182 } | 4209 } |
4183 } | 4210 } |
4184 | 4211 |
4185 | 4212 |
4186 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { | 4213 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { |
4187 if (instr->is_external()) { | 4214 if (instr->is_external()) { |
4188 DoStoreKeyedExternalArray(instr); | 4215 DoStoreKeyedExternalArray(instr); |
4189 } else if (instr->hydrogen()->value()->representation().IsDouble()) { | 4216 } else if (instr->hydrogen()->value()->representation().IsDouble()) { |
4190 DoStoreKeyedFixedDoubleArray(instr); | 4217 DoStoreKeyedFixedDoubleArray(instr); |
4191 } else { | 4218 } else { |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5660 FixedArray::kHeaderSize - kPointerSize)); | 5687 FixedArray::kHeaderSize - kPointerSize)); |
5661 __ bind(&done); | 5688 __ bind(&done); |
5662 } | 5689 } |
5663 | 5690 |
5664 | 5691 |
5665 #undef __ | 5692 #undef __ |
5666 | 5693 |
5667 } } // namespace v8::internal | 5694 } } // namespace v8::internal |
5668 | 5695 |
5669 #endif // V8_TARGET_ARCH_X64 | 5696 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |