OLD | NEW |
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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3510 movsd(MemOperand(rsp, 0), input_reg); | 3510 movsd(MemOperand(rsp, 0), input_reg); |
3511 SlowTruncateToI(result_reg, rsp, 0); | 3511 SlowTruncateToI(result_reg, rsp, 0); |
3512 addp(rsp, Immediate(kDoubleSize)); | 3512 addp(rsp, Immediate(kDoubleSize)); |
3513 | 3513 |
3514 bind(&done); | 3514 bind(&done); |
3515 // Keep our invariant that the upper 32 bits are zero. | 3515 // Keep our invariant that the upper 32 bits are zero. |
3516 movl(result_reg, result_reg); | 3516 movl(result_reg, result_reg); |
3517 } | 3517 } |
3518 | 3518 |
3519 | 3519 |
3520 void MacroAssembler::DoubleToI(Register result_reg, | 3520 void MacroAssembler::DoubleToI(Register result_reg, XMMRegister input_reg, |
3521 XMMRegister input_reg, | |
3522 XMMRegister scratch, | 3521 XMMRegister scratch, |
3523 MinusZeroMode minus_zero_mode, | 3522 MinusZeroMode minus_zero_mode, |
3524 Label* conversion_failed, | 3523 Label* lost_precision, Label* is_nan, |
3525 Label::Distance dst) { | 3524 Label* minus_zero, Label::Distance dst) { |
3526 cvttsd2si(result_reg, input_reg); | 3525 cvttsd2si(result_reg, input_reg); |
3527 Cvtlsi2sd(xmm0, result_reg); | 3526 Cvtlsi2sd(xmm0, result_reg); |
3528 ucomisd(xmm0, input_reg); | 3527 ucomisd(xmm0, input_reg); |
3529 j(not_equal, conversion_failed, dst); | 3528 j(not_equal, lost_precision, dst); |
3530 j(parity_even, conversion_failed, dst); // NaN. | 3529 j(parity_even, is_nan, dst); // NaN. |
3531 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { | 3530 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { |
3532 Label done; | 3531 Label done; |
3533 // The integer converted back is equal to the original. We | 3532 // The integer converted back is equal to the original. We |
3534 // only have to test if we got -0 as an input. | 3533 // only have to test if we got -0 as an input. |
3535 testl(result_reg, result_reg); | 3534 testl(result_reg, result_reg); |
3536 j(not_zero, &done, Label::kNear); | 3535 j(not_zero, &done, Label::kNear); |
3537 movmskpd(result_reg, input_reg); | 3536 movmskpd(result_reg, input_reg); |
3538 // Bit 0 contains the sign of the double in input_reg. | 3537 // Bit 0 contains the sign of the double in input_reg. |
3539 // If input was positive, we are ok and return 0, otherwise | 3538 // If input was positive, we are ok and return 0, otherwise |
3540 // jump to conversion_failed. | 3539 // jump to minus_zero. |
3541 andl(result_reg, Immediate(1)); | 3540 andl(result_reg, Immediate(1)); |
3542 j(not_zero, conversion_failed, dst); | 3541 j(not_zero, minus_zero, dst); |
3543 bind(&done); | 3542 bind(&done); |
3544 } | 3543 } |
3545 } | 3544 } |
3546 | 3545 |
3547 | 3546 |
3548 void MacroAssembler::LoadInstanceDescriptors(Register map, | 3547 void MacroAssembler::LoadInstanceDescriptors(Register map, |
3549 Register descriptors) { | 3548 Register descriptors) { |
3550 movp(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); | 3549 movp(descriptors, FieldOperand(map, Map::kDescriptorsOffset)); |
3551 } | 3550 } |
3552 | 3551 |
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5336 if (mag.shift > 0) sarl(rdx, Immediate(mag.shift)); | 5335 if (mag.shift > 0) sarl(rdx, Immediate(mag.shift)); |
5337 movl(rax, dividend); | 5336 movl(rax, dividend); |
5338 shrl(rax, Immediate(31)); | 5337 shrl(rax, Immediate(31)); |
5339 addl(rdx, rax); | 5338 addl(rdx, rax); |
5340 } | 5339 } |
5341 | 5340 |
5342 | 5341 |
5343 } } // namespace v8::internal | 5342 } } // namespace v8::internal |
5344 | 5343 |
5345 #endif // V8_TARGET_ARCH_X64 | 5344 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |