| 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 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 case Token::ADD: __ addsd(xmm0, xmm1); break; | 1786 case Token::ADD: __ addsd(xmm0, xmm1); break; |
| 1787 case Token::SUB: __ subsd(xmm0, xmm1); break; | 1787 case Token::SUB: __ subsd(xmm0, xmm1); break; |
| 1788 case Token::MUL: __ mulsd(xmm0, xmm1); break; | 1788 case Token::MUL: __ mulsd(xmm0, xmm1); break; |
| 1789 case Token::DIV: __ divsd(xmm0, xmm1); break; | 1789 case Token::DIV: __ divsd(xmm0, xmm1); break; |
| 1790 default: UNREACHABLE(); | 1790 default: UNREACHABLE(); |
| 1791 } | 1791 } |
| 1792 // Check result type if it is currently Int32. | 1792 // Check result type if it is currently Int32. |
| 1793 if (result_type_ <= BinaryOpIC::INT32) { | 1793 if (result_type_ <= BinaryOpIC::INT32) { |
| 1794 __ cvttsd2si(ecx, Operand(xmm0)); | 1794 __ cvttsd2si(ecx, Operand(xmm0)); |
| 1795 __ cvtsi2sd(xmm2, ecx); | 1795 __ cvtsi2sd(xmm2, ecx); |
| 1796 __ pcmpeqd(xmm2, xmm0); | 1796 __ ucomisd(xmm0, xmm2); |
| 1797 __ movmskpd(ecx, xmm2); | 1797 __ j(not_zero, ¬_int32); |
| 1798 __ test(ecx, Immediate(1)); | 1798 __ j(carry, ¬_int32); |
| 1799 __ j(zero, ¬_int32); | |
| 1800 } | 1799 } |
| 1801 GenerateHeapResultAllocation(masm, &call_runtime); | 1800 GenerateHeapResultAllocation(masm, &call_runtime); |
| 1802 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); | 1801 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); |
| 1803 __ ret(0); | 1802 __ ret(0); |
| 1804 } | 1803 } |
| 1805 } else { // SSE2 not available, use FPU. | 1804 } else { // SSE2 not available, use FPU. |
| 1806 FloatingPointHelper::CheckFloatOperands(masm, ¬_floats, ebx); | 1805 FloatingPointHelper::CheckFloatOperands(masm, ¬_floats, ebx); |
| 1807 FloatingPointHelper::LoadFloatOperands( | 1806 FloatingPointHelper::LoadFloatOperands( |
| 1808 masm, | 1807 masm, |
| 1809 ecx, | 1808 ecx, |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3207 } | 3206 } |
| 3208 | 3207 |
| 3209 // Calculate power with integer exponent. | 3208 // Calculate power with integer exponent. |
| 3210 __ bind(&int_exponent); | 3209 __ bind(&int_exponent); |
| 3211 const XMMRegister double_scratch2 = double_exponent; | 3210 const XMMRegister double_scratch2 = double_exponent; |
| 3212 __ mov(scratch, exponent); // Back up exponent. | 3211 __ mov(scratch, exponent); // Back up exponent. |
| 3213 __ movsd(double_scratch, double_base); // Back up base. | 3212 __ movsd(double_scratch, double_base); // Back up base. |
| 3214 __ movsd(double_scratch2, double_result); // Load double_exponent with 1. | 3213 __ movsd(double_scratch2, double_result); // Load double_exponent with 1. |
| 3215 | 3214 |
| 3216 // Get absolute value of exponent. | 3215 // Get absolute value of exponent. |
| 3217 Label no_neg, while_true, while_false; | 3216 Label no_neg, while_true, no_multiply; |
| 3218 __ test(scratch, scratch); | 3217 __ test(scratch, scratch); |
| 3219 __ j(positive, &no_neg, Label::kNear); | 3218 __ j(positive, &no_neg, Label::kNear); |
| 3220 __ neg(scratch); | 3219 __ neg(scratch); |
| 3221 __ bind(&no_neg); | 3220 __ bind(&no_neg); |
| 3222 | 3221 |
| 3223 __ j(zero, &while_false, Label::kNear); | |
| 3224 __ shr(scratch, 1); | |
| 3225 // Above condition means CF==0 && ZF==0. This means that the | |
| 3226 // bit that has been shifted out is 0 and the result is not 0. | |
| 3227 __ j(above, &while_true, Label::kNear); | |
| 3228 __ movsd(double_result, double_scratch); | |
| 3229 __ j(zero, &while_false, Label::kNear); | |
| 3230 | |
| 3231 __ bind(&while_true); | 3222 __ bind(&while_true); |
| 3232 __ shr(scratch, 1); | 3223 __ shr(scratch, 1); |
| 3224 __ j(not_carry, &no_multiply, Label::kNear); |
| 3225 __ mulsd(double_result, double_scratch); |
| 3226 __ bind(&no_multiply); |
| 3227 |
| 3233 __ mulsd(double_scratch, double_scratch); | 3228 __ mulsd(double_scratch, double_scratch); |
| 3234 __ j(above, &while_true, Label::kNear); | |
| 3235 __ mulsd(double_result, double_scratch); | |
| 3236 __ j(not_zero, &while_true); | 3229 __ j(not_zero, &while_true); |
| 3237 | 3230 |
| 3238 __ bind(&while_false); | |
| 3239 // scratch has the original value of the exponent - if the exponent is | 3231 // scratch has the original value of the exponent - if the exponent is |
| 3240 // negative, return 1/result. | 3232 // negative, return 1/result. |
| 3241 __ test(exponent, exponent); | 3233 __ test(exponent, exponent); |
| 3242 __ j(positive, &done); | 3234 __ j(positive, &done); |
| 3243 __ divsd(double_scratch2, double_result); | 3235 __ divsd(double_scratch2, double_result); |
| 3244 __ movsd(double_result, double_scratch2); | 3236 __ movsd(double_result, double_scratch2); |
| 3245 // Test whether result is zero. Bail out to check for subnormal result. | 3237 // Test whether result is zero. Bail out to check for subnormal result. |
| 3246 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. | 3238 // Due to subnormals, x^-y == (1/x)^y does not hold in all cases. |
| 3247 __ xorps(double_scratch2, double_scratch2); | 3239 __ xorps(double_scratch2, double_scratch2); |
| 3248 __ ucomisd(double_scratch2, double_result); // Result cannot be NaN. | 3240 __ ucomisd(double_scratch2, double_result); // Result cannot be NaN. |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4171 // Fill out the elements FixedArray. | 4163 // Fill out the elements FixedArray. |
| 4172 // eax: JSArray. | 4164 // eax: JSArray. |
| 4173 // ebx: FixedArray. | 4165 // ebx: FixedArray. |
| 4174 // ecx: Number of elements in array, as smi. | 4166 // ecx: Number of elements in array, as smi. |
| 4175 | 4167 |
| 4176 // Set map. | 4168 // Set map. |
| 4177 __ mov(FieldOperand(ebx, HeapObject::kMapOffset), | 4169 __ mov(FieldOperand(ebx, HeapObject::kMapOffset), |
| 4178 Immediate(factory->fixed_array_map())); | 4170 Immediate(factory->fixed_array_map())); |
| 4179 // Set length. | 4171 // Set length. |
| 4180 __ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx); | 4172 __ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx); |
| 4181 // Fill contents of fixed-array with undefined. | 4173 // Fill contents of fixed-array with the-hole. |
| 4182 __ SmiUntag(ecx); | 4174 __ SmiUntag(ecx); |
| 4183 __ mov(edx, Immediate(factory->undefined_value())); | 4175 __ mov(edx, Immediate(factory->the_hole_value())); |
| 4184 __ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize)); | 4176 __ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize)); |
| 4185 // Fill fixed array elements with undefined. | 4177 // Fill fixed array elements with hole. |
| 4186 // eax: JSArray. | 4178 // eax: JSArray. |
| 4187 // ecx: Number of elements to fill. | 4179 // ecx: Number of elements to fill. |
| 4188 // ebx: Start of elements in FixedArray. | 4180 // ebx: Start of elements in FixedArray. |
| 4189 // edx: undefined. | 4181 // edx: the hole. |
| 4190 Label loop; | 4182 Label loop; |
| 4191 __ test(ecx, ecx); | 4183 __ test(ecx, ecx); |
| 4192 __ bind(&loop); | 4184 __ bind(&loop); |
| 4193 __ j(less_equal, &done, Label::kNear); // Jump if ecx is negative or zero. | 4185 __ j(less_equal, &done, Label::kNear); // Jump if ecx is negative or zero. |
| 4194 __ sub(ecx, Immediate(1)); | 4186 __ sub(ecx, Immediate(1)); |
| 4195 __ mov(Operand(ebx, ecx, times_pointer_size, 0), edx); | 4187 __ mov(Operand(ebx, ecx, times_pointer_size, 0), edx); |
| 4196 __ jmp(&loop); | 4188 __ jmp(&loop); |
| 4197 | 4189 |
| 4198 __ bind(&done); | 4190 __ bind(&done); |
| 4199 __ ret(3 * kPointerSize); | 4191 __ ret(3 * kPointerSize); |
| (...skipping 2999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7199 RecordWriteStub stub(entry->object, | 7191 RecordWriteStub stub(entry->object, |
| 7200 entry->value, | 7192 entry->value, |
| 7201 entry->address, | 7193 entry->address, |
| 7202 entry->action, | 7194 entry->action, |
| 7203 kDontSaveFPRegs); | 7195 kDontSaveFPRegs); |
| 7204 stub.GetCode()->set_is_pregenerated(true); | 7196 stub.GetCode()->set_is_pregenerated(true); |
| 7205 } | 7197 } |
| 7206 } | 7198 } |
| 7207 | 7199 |
| 7208 | 7200 |
| 7209 bool CodeStub::CanUseFPRegisters() { | |
| 7210 return CpuFeatures::IsSupported(SSE2); | |
| 7211 } | |
| 7212 | |
| 7213 | |
| 7214 // Takes the input in 3 registers: address_ value_ and object_. A pointer to | 7201 // Takes the input in 3 registers: address_ value_ and object_. A pointer to |
| 7215 // the value has just been written into the object, now this stub makes sure | 7202 // the value has just been written into the object, now this stub makes sure |
| 7216 // we keep the GC informed. The word in the object where the value has been | 7203 // we keep the GC informed. The word in the object where the value has been |
| 7217 // written is in the address register. | 7204 // written is in the address register. |
| 7218 void RecordWriteStub::Generate(MacroAssembler* masm) { | 7205 void RecordWriteStub::Generate(MacroAssembler* masm) { |
| 7219 Label skip_to_incremental_noncompacting; | 7206 Label skip_to_incremental_noncompacting; |
| 7220 Label skip_to_incremental_compacting; | 7207 Label skip_to_incremental_compacting; |
| 7221 | 7208 |
| 7222 // The first two instructions are generated with labels so as to get the | 7209 // The first two instructions are generated with labels so as to get the |
| 7223 // offset fixed up correctly by the bind(Label*) call. We patch it back and | 7210 // offset fixed up correctly by the bind(Label*) call. We patch it back and |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7324 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_); | 7311 regs_.RestoreCallerSaveRegisters(masm, save_fp_regs_mode_); |
| 7325 } | 7312 } |
| 7326 | 7313 |
| 7327 | 7314 |
| 7328 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( | 7315 void RecordWriteStub::CheckNeedsToInformIncrementalMarker( |
| 7329 MacroAssembler* masm, | 7316 MacroAssembler* masm, |
| 7330 OnNoNeedToInformIncrementalMarker on_no_need, | 7317 OnNoNeedToInformIncrementalMarker on_no_need, |
| 7331 Mode mode) { | 7318 Mode mode) { |
| 7332 Label object_is_black, need_incremental, need_incremental_pop_object; | 7319 Label object_is_black, need_incremental, need_incremental_pop_object; |
| 7333 | 7320 |
| 7334 __ mov(regs_.scratch0(), Immediate(~Page::kPageAlignmentMask)); | |
| 7335 __ and_(regs_.scratch0(), regs_.object()); | |
| 7336 __ mov(regs_.scratch1(), | |
| 7337 Operand(regs_.scratch0(), | |
| 7338 MemoryChunk::kWriteBarrierCounterOffset)); | |
| 7339 __ sub(regs_.scratch1(), Immediate(1)); | |
| 7340 __ mov(Operand(regs_.scratch0(), | |
| 7341 MemoryChunk::kWriteBarrierCounterOffset), | |
| 7342 regs_.scratch1()); | |
| 7343 __ j(negative, &need_incremental); | |
| 7344 | |
| 7345 // Let's look at the color of the object: If it is not black we don't have | 7321 // Let's look at the color of the object: If it is not black we don't have |
| 7346 // to inform the incremental marker. | 7322 // to inform the incremental marker. |
| 7347 __ JumpIfBlack(regs_.object(), | 7323 __ JumpIfBlack(regs_.object(), |
| 7348 regs_.scratch0(), | 7324 regs_.scratch0(), |
| 7349 regs_.scratch1(), | 7325 regs_.scratch1(), |
| 7350 &object_is_black, | 7326 &object_is_black, |
| 7351 Label::kNear); | 7327 Label::kNear); |
| 7352 | 7328 |
| 7353 regs_.Restore(masm); | 7329 regs_.Restore(masm); |
| 7354 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { | 7330 if (on_no_need == kUpdateRememberedSetOnNoNeedToInformIncrementalMarker) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7528 // Restore ecx. | 7504 // Restore ecx. |
| 7529 __ pop(ecx); | 7505 __ pop(ecx); |
| 7530 __ ret(0); | 7506 __ ret(0); |
| 7531 } | 7507 } |
| 7532 | 7508 |
| 7533 #undef __ | 7509 #undef __ |
| 7534 | 7510 |
| 7535 } } // namespace v8::internal | 7511 } } // namespace v8::internal |
| 7536 | 7512 |
| 7537 #endif // V8_TARGET_ARCH_IA32 | 7513 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |