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 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 // Move down according to the exponent. | 2430 // Move down according to the exponent. |
2431 mov(dest, Operand(scratch, LSR, dest)); | 2431 mov(dest, Operand(scratch, LSR, dest)); |
2432 // Fix sign if sign bit was set. | 2432 // Fix sign if sign bit was set. |
2433 rsb(dest, dest, Operand(0, RelocInfo::NONE), LeaveCC, ne); | 2433 rsb(dest, dest, Operand(0, RelocInfo::NONE), LeaveCC, ne); |
2434 bind(&done); | 2434 bind(&done); |
2435 } | 2435 } |
2436 } | 2436 } |
2437 | 2437 |
2438 | 2438 |
2439 void MacroAssembler::EmitVFPTruncate(VFPRoundingMode rounding_mode, | 2439 void MacroAssembler::EmitVFPTruncate(VFPRoundingMode rounding_mode, |
2440 SwVfpRegister result, | 2440 Register result, |
2441 DwVfpRegister double_input, | 2441 DwVfpRegister double_input, |
2442 Register scratch1, | 2442 Register scratch, |
2443 Register scratch2, | 2443 DwVfpRegister double_scratch, |
2444 CheckForInexactConversion check_inexact) { | 2444 CheckForInexactConversion check_inexact) { |
| 2445 ASSERT(!result.is(scratch)); |
| 2446 ASSERT(!double_input.is(double_scratch)); |
| 2447 |
2445 ASSERT(CpuFeatures::IsSupported(VFP2)); | 2448 ASSERT(CpuFeatures::IsSupported(VFP2)); |
2446 CpuFeatures::Scope scope(VFP2); | 2449 CpuFeatures::Scope scope(VFP2); |
2447 Register prev_fpscr = scratch1; | 2450 Register prev_fpscr = result; |
2448 Register scratch = scratch2; | 2451 Label done; |
2449 | 2452 |
| 2453 // Test for values that can be exactly represented as a signed 32-bit integer. |
| 2454 vcvt_s32_f64(double_scratch.low(), double_input); |
| 2455 vmov(result, double_scratch.low()); |
| 2456 vcvt_f64_s32(double_scratch, double_scratch.low()); |
| 2457 VFPCompareAndSetFlags(double_input, double_scratch); |
| 2458 b(eq, &done); |
| 2459 |
| 2460 // Convert to integer, respecting rounding mode. |
2450 int32_t check_inexact_conversion = | 2461 int32_t check_inexact_conversion = |
2451 (check_inexact == kCheckForInexactConversion) ? kVFPInexactExceptionBit : 0; | 2462 (check_inexact == kCheckForInexactConversion) ? kVFPInexactExceptionBit : 0; |
2452 | 2463 |
2453 // Set custom FPCSR: | 2464 // Set custom FPCSR: |
2454 // - Set rounding mode. | 2465 // - Set rounding mode. |
2455 // - Clear vfp cumulative exception flags. | 2466 // - Clear vfp cumulative exception flags. |
2456 // - Make sure Flush-to-zero mode control bit is unset. | 2467 // - Make sure Flush-to-zero mode control bit is unset. |
2457 vmrs(prev_fpscr); | 2468 vmrs(prev_fpscr); |
2458 bic(scratch, | 2469 bic(scratch, |
2459 prev_fpscr, | 2470 prev_fpscr, |
2460 Operand(kVFPExceptionMask | | 2471 Operand(kVFPExceptionMask | |
2461 check_inexact_conversion | | 2472 check_inexact_conversion | |
2462 kVFPRoundingModeMask | | 2473 kVFPRoundingModeMask | |
2463 kVFPFlushToZeroMask)); | 2474 kVFPFlushToZeroMask)); |
2464 // 'Round To Nearest' is encoded by 0b00 so no bits need to be set. | 2475 // 'Round To Nearest' is encoded by 0b00 so no bits need to be set. |
2465 if (rounding_mode != kRoundToNearest) { | 2476 if (rounding_mode != kRoundToNearest) { |
2466 orr(scratch, scratch, Operand(rounding_mode)); | 2477 orr(scratch, scratch, Operand(rounding_mode)); |
2467 } | 2478 } |
2468 vmsr(scratch); | 2479 vmsr(scratch); |
2469 | 2480 |
2470 // Convert the argument to an integer. | 2481 // Convert the argument to an integer. |
2471 vcvt_s32_f64(result, | 2482 vcvt_s32_f64(double_scratch.low(), |
2472 double_input, | 2483 double_input, |
2473 (rounding_mode == kRoundToZero) ? kDefaultRoundToZero | 2484 (rounding_mode == kRoundToZero) ? kDefaultRoundToZero |
2474 : kFPSCRRounding); | 2485 : kFPSCRRounding); |
2475 | 2486 |
2476 // Retrieve FPSCR. | 2487 // Retrieve FPSCR. |
2477 vmrs(scratch); | 2488 vmrs(scratch); |
2478 // Restore FPSCR. | 2489 // Restore FPSCR. |
2479 vmsr(prev_fpscr); | 2490 vmsr(prev_fpscr); |
| 2491 // Move the converted value into the result register. |
| 2492 vmov(result, double_scratch.low()); |
2480 // Check for vfp exceptions. | 2493 // Check for vfp exceptions. |
2481 tst(scratch, Operand(kVFPExceptionMask | check_inexact_conversion)); | 2494 tst(scratch, Operand(kVFPExceptionMask | check_inexact_conversion)); |
| 2495 |
| 2496 bind(&done); |
2482 } | 2497 } |
2483 | 2498 |
2484 | 2499 |
2485 void MacroAssembler::EmitOutOfInt32RangeTruncate(Register result, | 2500 void MacroAssembler::EmitOutOfInt32RangeTruncate(Register result, |
2486 Register input_high, | 2501 Register input_high, |
2487 Register input_low, | 2502 Register input_low, |
2488 Register scratch) { | 2503 Register scratch) { |
2489 Label done, normal_exponent, restore_sign; | 2504 Label done, normal_exponent, restore_sign; |
2490 | 2505 |
2491 // Extract the biased exponent in result. | 2506 // Extract the biased exponent in result. |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3839 void CodePatcher::EmitCondition(Condition cond) { | 3854 void CodePatcher::EmitCondition(Condition cond) { |
3840 Instr instr = Assembler::instr_at(masm_.pc_); | 3855 Instr instr = Assembler::instr_at(masm_.pc_); |
3841 instr = (instr & ~kCondMask) | cond; | 3856 instr = (instr & ~kCondMask) | cond; |
3842 masm_.emit(instr); | 3857 masm_.emit(instr); |
3843 } | 3858 } |
3844 | 3859 |
3845 | 3860 |
3846 } } // namespace v8::internal | 3861 } } // namespace v8::internal |
3847 | 3862 |
3848 #endif // V8_TARGET_ARCH_ARM | 3863 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |