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

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

Issue 1065863003: Use array literals instead of array constructor in native javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 5 years, 8 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/symbol.js ('k') | src/typedarray.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-2004 by Sun Microsystems, Inc. All rights reserved. 4 // Copyright (C) 1993-2004 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 15 matching lines...) Expand all
26 var kMath; 26 var kMath;
27 var rempio2result; 27 var rempio2result;
28 28
29 (function() { 29 (function() {
30 30
31 "use strict"; 31 "use strict";
32 32
33 %CheckIsBootstrapping(); 33 %CheckIsBootstrapping();
34 34
35 var GlobalMath = global.Math; 35 var GlobalMath = global.Math;
36 var GlobalArray = global.Array;
37 36
38 //------------------------------------------------------------------- 37 //-------------------------------------------------------------------
39 38
40 const INVPIO2 = kMath[0]; 39 const INVPIO2 = kMath[0];
41 const PIO2_1 = kMath[1]; 40 const PIO2_1 = kMath[1];
42 const PIO2_1T = kMath[2]; 41 const PIO2_1T = kMath[2];
43 const PIO2_2 = kMath[3]; 42 const PIO2_2 = kMath[3];
44 const PIO2_2T = kMath[4]; 43 const PIO2_2T = kMath[4];
45 const PIO2_3 = kMath[5]; 44 const PIO2_3 = kMath[5];
46 const PIO2_3T = kMath[6]; 45 const PIO2_3T = kMath[6];
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 k -= 54; 879 k -= 54;
881 x *= TWO54; 880 x *= TWO54;
882 hx = %_DoubleHi(x); 881 hx = %_DoubleHi(x);
883 lx = %_DoubleLo(x); 882 lx = %_DoubleLo(x);
884 } 883 }
885 884
886 // Infinity or NaN. 885 // Infinity or NaN.
887 if (hx >= 0x7ff00000) return x; 886 if (hx >= 0x7ff00000) return x;
888 887
889 k += (hx >> 20) - 1023; 888 k += (hx >> 20) - 1023;
890 i = (k & 0x80000000) >> 31; 889 var i = (k & 0x80000000) >> 31;
891 hx = (hx & 0x000fffff) | ((0x3ff - i) << 20); 890 hx = (hx & 0x000fffff) | ((0x3ff - i) << 20);
892 y = k + i; 891 var y = k + i;
893 x = %_ConstructDouble(hx, lx); 892 x = %_ConstructDouble(hx, lx);
894 893
895 z = y * LOG10_2LO + IVLN10 * %_MathLogRT(x); 894 var z = y * LOG10_2LO + IVLN10 * %_MathLogRT(x);
896 return z + y * LOG10_2HI; 895 return z + y * LOG10_2HI;
897 } 896 }
898 897
899 898
900 // ES6 draft 09-27-13, section 20.2.2.22. 899 // ES6 draft 09-27-13, section 20.2.2.22.
901 // Return the base 2 logarithm of x 900 // Return the base 2 logarithm of x
902 // 901 //
903 // fdlibm does not have an explicit log2 function, but fdlibm's pow 902 // fdlibm does not have an explicit log2 function, but fdlibm's pow
904 // function does implement an accurate log2 function as part of the 903 // function does implement an accurate log2 function as part of the
905 // pow implementation. This extracts the core parts of that as a 904 // pow implementation. This extracts the core parts of that as a
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 var t = n; 1005 var t = n;
1007 var t1 = %_ConstructDouble(%_DoubleHi(((z_h + z_l) + dp_h) + t), 0); 1006 var t1 = %_ConstructDouble(%_DoubleHi(((z_h + z_l) + dp_h) + t), 0);
1008 var t2 = z_l - (((t1 - t) - dp_h) - z_h); 1007 var t2 = z_l - (((t1 - t) - dp_h) - z_h);
1009 1008
1010 // t1 + t2 = log2(ax), sum up because we do not care about extra precision. 1009 // t1 + t2 = log2(ax), sum up because we do not care about extra precision.
1011 return t1 + t2; 1010 return t1 + t2;
1012 } 1011 }
1013 1012
1014 //------------------------------------------------------------------- 1013 //-------------------------------------------------------------------
1015 1014
1016 InstallFunctions(GlobalMath, DONT_ENUM, GlobalArray( 1015 InstallFunctions(GlobalMath, DONT_ENUM, [
1017 "cos", MathCos, 1016 "cos", MathCos,
1018 "sin", MathSin, 1017 "sin", MathSin,
1019 "tan", MathTan, 1018 "tan", MathTan,
1020 "sinh", MathSinh, 1019 "sinh", MathSinh,
1021 "cosh", MathCosh, 1020 "cosh", MathCosh,
1022 "log10", MathLog10, 1021 "log10", MathLog10,
1023 "log2", MathLog2, 1022 "log2", MathLog2,
1024 "log1p", MathLog1p, 1023 "log1p", MathLog1p,
1025 "expm1", MathExpm1 1024 "expm1", MathExpm1
1026 )); 1025 ]);
1027 1026
1028 %SetInlineBuiltinFlag(MathSin); 1027 %SetInlineBuiltinFlag(MathSin);
1029 %SetInlineBuiltinFlag(MathCos); 1028 %SetInlineBuiltinFlag(MathCos);
1030 1029
1031 })(); 1030 })();
OLDNEW
« no previous file with comments | « src/symbol.js ('k') | src/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698