Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: third_party/fdlibm/fdlibm.cc

Issue 446863002: Move fdlibm from v8::internal to v8::fdlibm. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/fdlibm/fdlibm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm). 1 // The following is adapted from fdlibm (http://www.netlib.org/fdlibm).
2 // 2 //
3 // ==================================================== 3 // ====================================================
4 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 // 5 //
6 // Developed at SunSoft, a Sun Microsystems, Inc. business. 6 // Developed at SunSoft, a Sun Microsystems, Inc. business.
7 // Permission to use, copy, modify, and distribute this 7 // Permission to use, copy, modify, and distribute this
8 // software is freely granted, provided that this notice 8 // software is freely granted, provided that this notice
9 // is preserved. 9 // is preserved.
10 // ==================================================== 10 // ====================================================
11 // 11 //
12 // The original source code covered by the above license above has been 12 // The original source code covered by the above license above has been
13 // modified significantly by Google Inc. 13 // modified significantly by Google Inc.
14 // Copyright 2014 the V8 project authors. All rights reserved. 14 // Copyright 2014 the V8 project authors. All rights reserved.
15 15
16 #include "src/v8.h" 16 #include "src/v8.h"
17 17
18 #include "src/double.h" 18 #include "src/double.h"
19 #include "third_party/fdlibm/fdlibm.h" 19 #include "third_party/fdlibm/fdlibm.h"
20 20
21 21
22 namespace v8 { 22 namespace v8 {
23 namespace internal { 23 namespace fdlibm {
24 24
25 #ifdef _MSC_VER 25 #ifdef _MSC_VER
26 inline double scalbn(double x, int y) { return _scalb(x, y); } 26 inline double scalbn(double x, int y) { return _scalb(x, y); }
27 #endif // _MSC_VER 27 #endif // _MSC_VER
28 28
29 const double TrigonometricConstants::constants[] = { 29 const double TrigonometricConstants::constants[] = {
30 6.36619772367581382433e-01, // invpio2 0 30 6.36619772367581382433e-01, // invpio2 0
31 1.57079632673412561417e+00, // pio2_1 1 31 1.57079632673412561417e+00, // pio2_1 1
32 6.07710050650619224932e-11, // pio2_1t 2 32 6.07710050650619224932e-11, // pio2_1t 2
33 6.07710050630396597660e-11, // pio2_2 3 33 6.07710050630396597660e-11, // pio2_2 3
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 for (int i = jz; i >= 0; i--) fw += fq[i]; 221 for (int i = jz; i >= 0; i--) fw += fq[i];
222 y[0] = (ih == 0) ? fw : -fw; 222 y[0] = (ih == 0) ? fw : -fw;
223 fw = fq[0] - fw; 223 fw = fq[0] - fw;
224 for (int i = 1; i <= jz; i++) fw += fq[i]; 224 for (int i = 1; i <= jz; i++) fw += fq[i];
225 y[1] = (ih == 0) ? fw : -fw; 225 y[1] = (ih == 0) ? fw : -fw;
226 return n & 7; 226 return n & 7;
227 } 227 }
228 228
229 229
230 int rempio2(double x, double* y) { 230 int rempio2(double x, double* y) {
231 int32_t hx = static_cast<int32_t>(double_to_uint64(x) >> 32); 231 int32_t hx = static_cast<int32_t>(internal::double_to_uint64(x) >> 32);
232 int32_t ix = hx & 0x7fffffff; 232 int32_t ix = hx & 0x7fffffff;
233 233
234 if (ix >= 0x7ff00000) { 234 if (ix >= 0x7ff00000) {
235 *y = base::OS::nan_value(); 235 *y = base::OS::nan_value();
236 return 0; 236 return 0;
237 } 237 }
238 238
239 int32_t e0 = (ix >> 20) - 1046; 239 int32_t e0 = (ix >> 20) - 1046;
240 uint64_t zi = double_to_uint64(x) & 0xFFFFFFFFu; 240 uint64_t zi = internal::double_to_uint64(x) & 0xFFFFFFFFu;
241 zi |= static_cast<uint64_t>(ix - (e0 << 20)) << 32; 241 zi |= static_cast<uint64_t>(ix - (e0 << 20)) << 32;
242 double z = uint64_to_double(zi); 242 double z = internal::uint64_to_double(zi);
243 243
244 double tx[3]; 244 double tx[3];
245 for (int i = 0; i < 2; i++) { 245 for (int i = 0; i < 2; i++) {
246 tx[i] = static_cast<double>(static_cast<int32_t>(z)); 246 tx[i] = static_cast<double>(static_cast<int32_t>(z));
247 z = (z - tx[i]) * two24; 247 z = (z - tx[i]) * two24;
248 } 248 }
249 tx[2] = z; 249 tx[2] = z;
250 250
251 int nx = 3; 251 int nx = 3;
252 while (tx[nx - 1] == zero) nx--; 252 while (tx[nx - 1] == zero) nx--;
253 int n = __kernel_rem_pio2(tx, y, e0, nx); 253 int n = __kernel_rem_pio2(tx, y, e0, nx);
254 if (hx < 0) { 254 if (hx < 0) {
255 y[0] = -y[0]; 255 y[0] = -y[0];
256 y[1] = -y[1]; 256 y[1] = -y[1];
257 return -n; 257 return -n;
258 } 258 }
259 return n; 259 return n;
260 } 260 }
261 } 261 }
262 } // namespace v8::internal 262 } // namespace v8::internal
OLDNEW
« no previous file with comments | « third_party/fdlibm/fdlibm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698