| 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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 j(no_overflow, &done, Label::kNear); | 243 j(no_overflow, &done, Label::kNear); |
| 244 | 244 |
| 245 sub(esp, Immediate(kDoubleSize)); | 245 sub(esp, Immediate(kDoubleSize)); |
| 246 movsd(MemOperand(esp, 0), input_reg); | 246 movsd(MemOperand(esp, 0), input_reg); |
| 247 SlowTruncateToI(result_reg, esp, 0); | 247 SlowTruncateToI(result_reg, esp, 0); |
| 248 add(esp, Immediate(kDoubleSize)); | 248 add(esp, Immediate(kDoubleSize)); |
| 249 bind(&done); | 249 bind(&done); |
| 250 } | 250 } |
| 251 | 251 |
| 252 | 252 |
| 253 void MacroAssembler::DoubleToI(Register result_reg, | 253 void MacroAssembler::DoubleToI(Register result_reg, XMMRegister input_reg, |
| 254 XMMRegister input_reg, | |
| 255 XMMRegister scratch, | 254 XMMRegister scratch, |
| 256 MinusZeroMode minus_zero_mode, | 255 MinusZeroMode minus_zero_mode, |
| 257 Label* conversion_failed, | 256 Label* lost_precision, Label* is_nan, |
| 258 Label::Distance dst) { | 257 Label* minus_zero, Label::Distance dst) { |
| 259 DCHECK(!input_reg.is(scratch)); | 258 DCHECK(!input_reg.is(scratch)); |
| 260 cvttsd2si(result_reg, Operand(input_reg)); | 259 cvttsd2si(result_reg, Operand(input_reg)); |
| 261 Cvtsi2sd(scratch, Operand(result_reg)); | 260 Cvtsi2sd(scratch, Operand(result_reg)); |
| 262 ucomisd(scratch, input_reg); | 261 ucomisd(scratch, input_reg); |
| 263 j(not_equal, conversion_failed, dst); | 262 j(not_equal, lost_precision, dst); |
| 264 j(parity_even, conversion_failed, dst); // NaN. | 263 j(parity_even, is_nan, dst); |
| 265 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { | 264 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { |
| 266 Label done; | 265 Label done; |
| 267 // The integer converted back is equal to the original. We | 266 // The integer converted back is equal to the original. We |
| 268 // only have to test if we got -0 as an input. | 267 // only have to test if we got -0 as an input. |
| 269 test(result_reg, Operand(result_reg)); | 268 test(result_reg, Operand(result_reg)); |
| 270 j(not_zero, &done, Label::kNear); | 269 j(not_zero, &done, Label::kNear); |
| 271 movmskpd(result_reg, input_reg); | 270 movmskpd(result_reg, input_reg); |
| 272 // Bit 0 contains the sign of the double in input_reg. | 271 // Bit 0 contains the sign of the double in input_reg. |
| 273 // If input was positive, we are ok and return 0, otherwise | 272 // If input was positive, we are ok and return 0, otherwise |
| 274 // jump to conversion_failed. | 273 // jump to minus_zero. |
| 275 and_(result_reg, 1); | 274 and_(result_reg, 1); |
| 276 j(not_zero, conversion_failed, dst); | 275 j(not_zero, minus_zero, dst); |
| 277 bind(&done); | 276 bind(&done); |
| 278 } | 277 } |
| 279 } | 278 } |
| 280 | 279 |
| 281 | 280 |
| 282 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, | 281 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, |
| 283 Register input_reg) { | 282 Register input_reg) { |
| 284 Label done, slow_case; | 283 Label done, slow_case; |
| 285 | 284 |
| 286 if (CpuFeatures::IsSupported(SSE3)) { | 285 if (CpuFeatures::IsSupported(SSE3)) { |
| (...skipping 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3394 if (mag.shift > 0) sar(edx, mag.shift); | 3393 if (mag.shift > 0) sar(edx, mag.shift); |
| 3395 mov(eax, dividend); | 3394 mov(eax, dividend); |
| 3396 shr(eax, 31); | 3395 shr(eax, 31); |
| 3397 add(edx, eax); | 3396 add(edx, eax); |
| 3398 } | 3397 } |
| 3399 | 3398 |
| 3400 | 3399 |
| 3401 } } // namespace v8::internal | 3400 } } // namespace v8::internal |
| 3402 | 3401 |
| 3403 #endif // V8_TARGET_ARCH_IA32 | 3402 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |