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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 274 } |
275 | 275 |
276 | 276 |
277 void MacroAssembler::DoubleToI(Register result_reg, | 277 void MacroAssembler::DoubleToI(Register result_reg, |
278 XMMRegister input_reg, | 278 XMMRegister input_reg, |
279 XMMRegister scratch, | 279 XMMRegister scratch, |
280 MinusZeroMode minus_zero_mode, | 280 MinusZeroMode minus_zero_mode, |
281 Label* conversion_failed, | 281 Label* conversion_failed, |
282 Label::Distance dst) { | 282 Label::Distance dst) { |
283 ASSERT(!input_reg.is(scratch)); | 283 ASSERT(!input_reg.is(scratch)); |
284 Label done; | |
285 cvttsd2si(result_reg, Operand(input_reg)); | 284 cvttsd2si(result_reg, Operand(input_reg)); |
286 cvtsi2sd(scratch, Operand(result_reg)); | 285 cvtsi2sd(scratch, Operand(result_reg)); |
287 ucomisd(scratch, input_reg); | 286 ucomisd(scratch, input_reg); |
288 j(not_equal, conversion_failed, dst); | 287 j(not_equal, conversion_failed, dst); |
289 j(parity_even, conversion_failed, dst); // NaN. | 288 j(parity_even, conversion_failed, dst); // NaN. |
290 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { | 289 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { |
| 290 Label done; |
| 291 // The integer converted back is equal to the original. We |
| 292 // only have to test if we got -0 as an input. |
291 test(result_reg, Operand(result_reg)); | 293 test(result_reg, Operand(result_reg)); |
292 j(not_zero, &done, Label::kNear); | 294 j(not_zero, &done, Label::kNear); |
293 movmskpd(result_reg, input_reg); | 295 movmskpd(result_reg, input_reg); |
| 296 // Bit 0 contains the sign of the double in input_reg. |
| 297 // If input was positive, we are ok and return 0, otherwise |
| 298 // jump to conversion_failed. |
294 and_(result_reg, 1); | 299 and_(result_reg, 1); |
295 j(not_zero, conversion_failed, dst); | 300 j(not_zero, conversion_failed, dst); |
| 301 bind(&done); |
296 } | 302 } |
297 bind(&done); | |
298 } | 303 } |
299 | 304 |
300 | 305 |
301 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, | 306 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, |
302 Register input_reg) { | 307 Register input_reg) { |
303 Label done, slow_case; | 308 Label done, slow_case; |
304 | 309 |
305 if (CpuFeatures::IsSupported(SSE3)) { | 310 if (CpuFeatures::IsSupported(SSE3)) { |
306 CpuFeatureScope scope(this, SSE3); | 311 CpuFeatureScope scope(this, SSE3); |
307 Label convert; | 312 Label convert; |
(...skipping 3108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3416 j(greater, &no_memento_available); | 3421 j(greater, &no_memento_available); |
3417 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), | 3422 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), |
3418 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); | 3423 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); |
3419 bind(&no_memento_available); | 3424 bind(&no_memento_available); |
3420 } | 3425 } |
3421 | 3426 |
3422 | 3427 |
3423 } } // namespace v8::internal | 3428 } } // namespace v8::internal |
3424 | 3429 |
3425 #endif // V8_TARGET_ARCH_IA32 | 3430 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |