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

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

Issue 866553003: Allocate typed array for rempio2 result. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 years, 10 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
« no previous file with comments | « src/runtime/runtime-maths.cc ('k') | src/third_party/fdlibm/fdlibm.js » ('j') | 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 // ====================================================
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 7.54978941586159635335e-08, // 0x3E74442D, 0x00000000 119 7.54978941586159635335e-08, // 0x3E74442D, 0x00000000
120 5.39030252995776476554e-15, // 0x3CF84698, 0x80000000 120 5.39030252995776476554e-15, // 0x3CF84698, 0x80000000
121 3.28200341580791294123e-22, // 0x3B78CC51, 0x60000000 121 3.28200341580791294123e-22, // 0x3B78CC51, 0x60000000
122 1.27065575308067607349e-29, // 0x39F01B83, 0x80000000 122 1.27065575308067607349e-29, // 0x39F01B83, 0x80000000
123 1.22933308981111328932e-36, // 0x387A2520, 0x40000000 123 1.22933308981111328932e-36, // 0x387A2520, 0x40000000
124 2.73370053816464559624e-44, // 0x36E38222, 0x80000000 124 2.73370053816464559624e-44, // 0x36E38222, 0x80000000
125 2.16741683877804819444e-51 // 0x3569F31D, 0x00000000 125 2.16741683877804819444e-51 // 0x3569F31D, 0x00000000
126 }; 126 };
127 127
128 128
129 int __kernel_rem_pio2(double* x, double* y, int e0, int nx) { 129 INLINE(int __kernel_rem_pio2(double* x, double* y, int e0, int nx)) {
130 static const int32_t jk = 3; 130 static const int32_t jk = 3;
131 double fw; 131 double fw;
132 int32_t jx = nx - 1; 132 int32_t jx = nx - 1;
133 int32_t jv = (e0 - 3) / 24; 133 int32_t jv = (e0 - 3) / 24;
134 if (jv < 0) jv = 0; 134 if (jv < 0) jv = 0;
135 int32_t q0 = e0 - 24 * (jv + 1); 135 int32_t q0 = e0 - 24 * (jv + 1);
136 int32_t m = jx + jk; 136 int32_t m = jx + jk;
137 137
138 double f[10]; 138 double f[20];
139 for (int i = 0, j = jv - jx; i <= m; i++, j++) { 139 for (int i = 0, j = jv - jx; i <= m; i++, j++) {
140 f[i] = (j < 0) ? zero : static_cast<double>(two_over_pi[j]); 140 f[i] = (j < 0) ? zero : static_cast<double>(two_over_pi[j]);
141 } 141 }
142 142
143 double q[10]; 143 double q[20];
144 for (int i = 0; i <= jk; i++) { 144 for (int i = 0; i <= jk; i++) {
145 fw = 0.0; 145 fw = 0.0;
146 for (int j = 0; j <= jx; j++) fw += x[j] * f[jx + i - j]; 146 for (int j = 0; j <= jx; j++) fw += x[j] * f[jx + i - j];
147 q[i] = fw; 147 q[i] = fw;
148 } 148 }
149 149
150 int32_t jz = jk; 150 int32_t jz = jk;
151 151
152 recompute: 152 recompute:
153 153
154 int32_t iq[10]; 154 int32_t iq[20];
155 double z = q[jz]; 155 double z = q[jz];
156 for (int i = 0, j = jz; j > 0; i++, j--) { 156 for (int i = 0, j = jz; j > 0; i++, j--) {
157 fw = static_cast<double>(static_cast<int32_t>(twon24 * z)); 157 fw = static_cast<double>(static_cast<int32_t>(twon24 * z));
158 iq[i] = static_cast<int32_t>(z - two24 * fw); 158 iq[i] = static_cast<int32_t>(z - two24 * fw);
159 z = q[j - 1] + fw; 159 z = q[j - 1] + fw;
160 } 160 }
161 161
162 z = scalbn(z, q0); 162 z = scalbn(z, q0);
163 z -= 8.0 * std::floor(z * 0.125); 163 z -= 8.0 * std::floor(z * 0.125);
164 int32_t n = static_cast<int32_t>(z); 164 int32_t n = static_cast<int32_t>(z);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 iq[jz] = static_cast<int32_t>(z); 235 iq[jz] = static_cast<int32_t>(z);
236 } 236 }
237 } 237 }
238 238
239 fw = scalbn(one, q0); 239 fw = scalbn(one, q0);
240 for (int i = jz; i >= 0; i--) { 240 for (int i = jz; i >= 0; i--) {
241 q[i] = fw * static_cast<double>(iq[i]); 241 q[i] = fw * static_cast<double>(iq[i]);
242 fw *= twon24; 242 fw *= twon24;
243 } 243 }
244 244
245 double fq[10]; 245 double fq[20];
246 for (int i = jz; i >= 0; i--) { 246 for (int i = jz; i >= 0; i--) {
247 fw = 0.0; 247 fw = 0.0;
248 for (int k = 0; k <= jk && k <= jz - i; k++) fw += PIo2[k] * q[i + k]; 248 for (int k = 0; k <= jk && k <= jz - i; k++) fw += PIo2[k] * q[i + k];
249 fq[jz - i] = fw; 249 fq[jz - i] = fw;
250 } 250 }
251 251
252 fw = 0.0; 252 fw = 0.0;
253 for (int i = jz; i >= 0; i--) fw += fq[i]; 253 for (int i = jz; i >= 0; i--) fw += fq[i];
254 y[0] = (ih == 0) ? fw : -fw; 254 y[0] = (ih == 0) ? fw : -fw;
255 fw = fq[0] - fw; 255 fw = fq[0] - fw;
(...skipping 29 matching lines...) Expand all
285 int n = __kernel_rem_pio2(tx, y, e0, nx); 285 int n = __kernel_rem_pio2(tx, y, e0, nx);
286 if (hx < 0) { 286 if (hx < 0) {
287 y[0] = -y[0]; 287 y[0] = -y[0];
288 y[1] = -y[1]; 288 y[1] = -y[1];
289 return -n; 289 return -n;
290 } 290 }
291 return n; 291 return n;
292 } 292 }
293 } 293 }
294 } // namespace v8::internal 294 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-maths.cc ('k') | src/third_party/fdlibm/fdlibm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698