| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2061 case C_OLE_D: | 2061 case C_OLE_D: |
| 2062 set_fcsr_bit(fcsr_cc, (fs <= ft)); | 2062 set_fcsr_bit(fcsr_cc, (fs <= ft)); |
| 2063 break; | 2063 break; |
| 2064 case C_ULE_D: | 2064 case C_ULE_D: |
| 2065 set_fcsr_bit(fcsr_cc, (fs <= ft) || (isnan(fs) || isnan(ft))); | 2065 set_fcsr_bit(fcsr_cc, (fs <= ft) || (isnan(fs) || isnan(ft))); |
| 2066 break; | 2066 break; |
| 2067 case CVT_W_D: // Convert double to word. | 2067 case CVT_W_D: // Convert double to word. |
| 2068 // Rounding modes are not yet supported. | 2068 // Rounding modes are not yet supported. |
| 2069 ASSERT((FCSR_ & 3) == 0); | 2069 ASSERT((FCSR_ & 3) == 0); |
| 2070 // In rounding mode 0 it should behave like ROUND. | 2070 // In rounding mode 0 it should behave like ROUND. |
| 2071 case ROUND_W_D: // Round double to word. | 2071 case ROUND_W_D: // Round double to word (round half to even). |
| 2072 { | 2072 { |
| 2073 double rounded = fs > 0 ? floor(fs + 0.5) : ceil(fs - 0.5); | 2073 double rounded = floor(fs + 0.5); |
| 2074 int32_t result = static_cast<int32_t>(rounded); | 2074 int32_t result = static_cast<int32_t>(rounded); |
| 2075 if ((result & 1) != 0 && result - fs == 0.5) { |
| 2076 // If the number is halfway between two integers, |
| 2077 // round to the even one. |
| 2078 result--; |
| 2079 } |
| 2075 set_fpu_register(fd_reg, result); | 2080 set_fpu_register(fd_reg, result); |
| 2076 if (set_fcsr_round_error(fs, rounded)) { | 2081 if (set_fcsr_round_error(fs, rounded)) { |
| 2077 set_fpu_register(fd_reg, kFPUInvalidResult); | 2082 set_fpu_register(fd_reg, kFPUInvalidResult); |
| 2078 } | 2083 } |
| 2079 } | 2084 } |
| 2080 break; | 2085 break; |
| 2081 case TRUNC_W_D: // Truncate double to word (round towards 0). | 2086 case TRUNC_W_D: // Truncate double to word (round towards 0). |
| 2082 { | 2087 { |
| 2083 double rounded = trunc(fs); | 2088 double rounded = trunc(fs); |
| 2084 int32_t result = static_cast<int32_t>(rounded); | 2089 int32_t result = static_cast<int32_t>(rounded); |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2832 } | 2837 } |
| 2833 | 2838 |
| 2834 | 2839 |
| 2835 #undef UNSUPPORTED | 2840 #undef UNSUPPORTED |
| 2836 | 2841 |
| 2837 } } // namespace v8::internal | 2842 } } // namespace v8::internal |
| 2838 | 2843 |
| 2839 #endif // USE_SIMULATOR | 2844 #endif // USE_SIMULATOR |
| 2840 | 2845 |
| 2841 #endif // V8_TARGET_ARCH_MIPS | 2846 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |