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

Side by Side Diff: src/math.js

Issue 1027713002: [turbofan] More inlinable Math builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/compiler/typer.cc ('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 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 var rngstate; // Initialized to a Uint32Array during genesis. 5 var rngstate; // Initialized to a Uint32Array during genesis.
6 6
7 var $abs; 7 var $abs;
8 var $exp; 8 var $exp;
9 var $floor; 9 var $floor;
10 var $max; 10 var $max;
(...skipping 12 matching lines...) Expand all
23 23
24 // ECMA 262 - 15.8.2.1 24 // ECMA 262 - 15.8.2.1
25 function MathAbs(x) { 25 function MathAbs(x) {
26 x = +x; 26 x = +x;
27 if (x > 0) return x; 27 if (x > 0) return x;
28 return 0 - x; 28 return 0 - x;
29 } 29 }
30 30
31 // ECMA 262 - 15.8.2.2 31 // ECMA 262 - 15.8.2.2
32 function MathAcosJS(x) { 32 function MathAcosJS(x) {
33 return %MathAcos(TO_NUMBER_INLINE(x)); 33 return %_MathAcos(+x);
34 } 34 }
35 35
36 // ECMA 262 - 15.8.2.3 36 // ECMA 262 - 15.8.2.3
37 function MathAsinJS(x) { 37 function MathAsinJS(x) {
38 return %MathAsin(TO_NUMBER_INLINE(x)); 38 return %_MathAsin(+x);
39 } 39 }
40 40
41 // ECMA 262 - 15.8.2.4 41 // ECMA 262 - 15.8.2.4
42 function MathAtanJS(x) { 42 function MathAtanJS(x) {
43 return %MathAtan(TO_NUMBER_INLINE(x)); 43 return %_MathAtan(+x);
44 } 44 }
45 45
46 // ECMA 262 - 15.8.2.5 46 // ECMA 262 - 15.8.2.5
47 // The naming of y and x matches the spec, as does the order in which 47 // The naming of y and x matches the spec, as does the order in which
48 // ToNumber (valueOf) is called. 48 // ToNumber (valueOf) is called.
49 function MathAtan2JS(y, x) { 49 function MathAtan2JS(y, x) {
50 return %MathAtan2(TO_NUMBER_INLINE(y), TO_NUMBER_INLINE(x)); 50 y = +y;
51 x = +x;
52 return %_MathAtan2(y, x);
51 } 53 }
52 54
53 // ECMA 262 - 15.8.2.6 55 // ECMA 262 - 15.8.2.6
54 function MathCeil(x) { 56 function MathCeil(x) {
55 return -%_MathFloor(-x); 57 return -%_MathFloor(-x);
56 } 58 }
57 59
58 // ECMA 262 - 15.8.2.8 60 // ECMA 262 - 15.8.2.8
59 function MathExp(x) { 61 function MathExp(x) {
60 return %MathExpRT(TO_NUMBER_INLINE(x)); 62 return %MathExpRT(TO_NUMBER_INLINE(x));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return %_MathSqrt(+x); 152 return %_MathSqrt(+x);
151 } 153 }
152 154
153 // Non-standard extension. 155 // Non-standard extension.
154 function MathImul(x, y) { 156 function MathImul(x, y) {
155 return %NumberImul(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); 157 return %NumberImul(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y));
156 } 158 }
157 159
158 // ES6 draft 09-27-13, section 20.2.2.28. 160 // ES6 draft 09-27-13, section 20.2.2.28.
159 function MathSign(x) { 161 function MathSign(x) {
160 x = TO_NUMBER_INLINE(x); 162 x = +x;
161 if (x > 0) return 1; 163 if (x > 0) return 1;
162 if (x < 0) return -1; 164 if (x < 0) return -1;
163 // -0, 0 or NaN. 165 // -0, 0 or NaN.
164 return x; 166 return x;
165 } 167 }
166 168
167 // ES6 draft 09-27-13, section 20.2.2.34. 169 // ES6 draft 09-27-13, section 20.2.2.34.
168 function MathTrunc(x) { 170 function MathTrunc(x) {
169 x = TO_NUMBER_INLINE(x); 171 x = +x;
170 if (x > 0) return MathFloorJS(x); 172 if (x > 0) return %_MathFloor(x);
171 if (x < 0) return MathCeil(x); 173 if (x < 0) return -%_MathFloor(-x);
172 // -0, 0 or NaN. 174 // -0, 0 or NaN.
173 return x; 175 return x;
174 } 176 }
175 177
176 // ES6 draft 09-27-13, section 20.2.2.33. 178 // ES6 draft 09-27-13, section 20.2.2.33.
177 function MathTanh(x) { 179 function MathTanh(x) {
178 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); 180 if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
179 // Idempotent for +/-0. 181 // Idempotent for +/-0.
180 if (x === 0) return x; 182 if (x === 0) return x;
181 // Returns +/-1 for +/-Infinity. 183 // Returns +/-1 for +/-Infinity.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 "asinh", MathAsinh, 336 "asinh", MathAsinh,
335 "acosh", MathAcosh, 337 "acosh", MathAcosh,
336 "atanh", MathAtanh, 338 "atanh", MathAtanh,
337 "hypot", MathHypot, 339 "hypot", MathHypot,
338 "fround", MathFroundJS, 340 "fround", MathFroundJS,
339 "clz32", MathClz32JS, 341 "clz32", MathClz32JS,
340 "cbrt", MathCbrt 342 "cbrt", MathCbrt
341 )); 343 ));
342 344
343 %SetInlineBuiltinFlag(MathAbs); 345 %SetInlineBuiltinFlag(MathAbs);
346 %SetInlineBuiltinFlag(MathAcosJS);
347 %SetInlineBuiltinFlag(MathAsinJS);
348 %SetInlineBuiltinFlag(MathAtanJS);
349 %SetInlineBuiltinFlag(MathAtan2JS);
344 %SetInlineBuiltinFlag(MathCeil); 350 %SetInlineBuiltinFlag(MathCeil);
345 %SetInlineBuiltinFlag(MathClz32JS); 351 %SetInlineBuiltinFlag(MathClz32JS);
346 %SetInlineBuiltinFlag(MathFloorJS); 352 %SetInlineBuiltinFlag(MathFloorJS);
347 %SetInlineBuiltinFlag(MathRandom); 353 %SetInlineBuiltinFlag(MathRandom);
354 %SetInlineBuiltinFlag(MathSign);
348 %SetInlineBuiltinFlag(MathSqrtJS); 355 %SetInlineBuiltinFlag(MathSqrtJS);
356 %SetInlineBuiltinFlag(MathTrunc);
349 357
350 // Expose to the global scope. 358 // Expose to the global scope.
351 $abs = MathAbs; 359 $abs = MathAbs;
352 $exp = MathExp; 360 $exp = MathExp;
353 $floor = MathFloorJS; 361 $floor = MathFloorJS;
354 $max = MathMax; 362 $max = MathMax;
355 $min = MathMin; 363 $min = MathMin;
356 364
357 })(); 365 })();
OLDNEW
« no previous file with comments | « src/compiler/typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698