| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 // ==================================================== | 5 // ==================================================== |
| 6 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | 6 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
| 7 // | 7 // |
| 8 // Developed at SunSoft, a Sun Microsystems, Inc. business. | 8 // Developed at SunSoft, a Sun Microsystems, Inc. business. |
| 9 // Permission to use, copy, modify, and distribute this | 9 // Permission to use, copy, modify, and distribute this |
| 10 // software is freely granted, provided that this notice | 10 // software is freely granted, provided that this notice |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 double fq[10]; | 172 double fq[10]; |
| 173 for (int i = jz; i >= 0; i--) { | 173 for (int i = jz; i >= 0; i--) { |
| 174 fw = 0.0; | 174 fw = 0.0; |
| 175 for (int k = 0; k <= jk && k <= jz - i; k++) fw += PIo2[k] * q[i + k]; | 175 for (int k = 0; k <= jk && k <= jz - i; k++) fw += PIo2[k] * q[i + k]; |
| 176 fq[jz - i] = fw; | 176 fq[jz - i] = fw; |
| 177 } | 177 } |
| 178 | 178 |
| 179 fw = 0.0; | 179 fw = 0.0; |
| 180 for (int i = jz; i >= 0; i--) fw += fq[i]; | 180 for (int i = jz; i >= 0; i--) fw += fq[i]; |
| 181 y[0] = (ih == 0) ? fw : -fw; | 181 *y = (ih == 0) ? fw : -fw; |
| 182 fw = fq[0] - fw; | |
| 183 for (int i = 1; i <= jz; i++) fw += fq[i]; | |
| 184 y[1] = (ih == 0) ? fw : -fw; | |
| 185 return n & 7; | 182 return n & 7; |
| 186 } | 183 } |
| 187 | 184 |
| 188 | 185 |
| 189 int rempio2(double x, double* y) { | 186 int rempio2(double x, double* y) { |
| 190 int32_t hx = static_cast<int32_t>(double_to_uint64(x) >> 32); | 187 int32_t hx = static_cast<int32_t>(double_to_uint64(x) >> 32); |
| 191 int32_t ix = hx & 0x7fffffff; | 188 int32_t ix = hx & 0x7fffffff; |
| 192 | 189 |
| 193 ASSERT(ix > 0x413921fb); // Handling of lower ix has been omitted. | 190 ASSERT(ix > 0x413921fb); // Handling of lower ix has been omitted. |
| 194 | 191 |
| 195 int32_t e0 = (ix >> 20) - 1046; | 192 int32_t e0 = (ix >> 20) - 1046; |
| 196 uint64_t zi = double_to_uint64(x) & 0xFFFFFFFFu; | 193 uint64_t zi = double_to_uint64(x) & 0xFFFFFFFFu; |
| 197 zi |= static_cast<uint64_t>(ix - (e0 << 20)) << 32; | 194 zi |= static_cast<uint64_t>(ix - (e0 << 20)) << 32; |
| 198 double z = uint64_to_double(zi); | 195 double z = uint64_to_double(zi); |
| 199 | 196 |
| 200 double tx[3]; | 197 double tx[3]; |
| 201 for (int i = 0; i < 2; i++) { | 198 for (int i = 0; i < 2; i++) { |
| 202 tx[i] = static_cast<double>(static_cast<int32_t>(z)); | 199 tx[i] = static_cast<double>(static_cast<int32_t>(z)); |
| 203 z = (z - tx[i]) * two24; | 200 z = (z - tx[i]) * two24; |
| 204 } | 201 } |
| 205 tx[2] = z; | 202 tx[2] = z; |
| 206 | 203 |
| 207 int nx = 3; | 204 int nx = 3; |
| 208 while (tx[nx - 1] == zero) nx--; | 205 while (tx[nx - 1] == zero) nx--; |
| 209 int n = __kernel_rem_pio2(tx, y, e0, nx); | 206 int n = __kernel_rem_pio2(tx, y, e0, nx); |
| 210 if (hx < 0) { | 207 if (hx < 0) { |
| 211 y[0] = -y[0]; | 208 *y = -*y; |
| 212 y[1] = -y[1]; | |
| 213 return -n; | 209 return -n; |
| 214 } | 210 } |
| 215 return n; | 211 return n; |
| 216 } | 212 } |
| 217 | 213 |
| 218 } } // namespace v8::internal | 214 } } // namespace v8::internal |
| OLD | NEW |