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

Side by Side Diff: src/math.js

Issue 1009373002: Remove BLACKLIST from check-name-clashes.py, it's wrong nowadays. (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/ia32/code-stubs-ia32.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 function MathCeil(x) { 54 function MathCeil(x) {
55 return -%_MathFloor(-x); 55 return -%_MathFloor(-x);
56 } 56 }
57 57
58 // ECMA 262 - 15.8.2.8 58 // ECMA 262 - 15.8.2.8
59 function MathExp(x) { 59 function MathExp(x) {
60 return %MathExpRT(TO_NUMBER_INLINE(x)); 60 return %MathExpRT(TO_NUMBER_INLINE(x));
61 } 61 }
62 62
63 // ECMA 262 - 15.8.2.9 63 // ECMA 262 - 15.8.2.9
64 function MathFloor(x) { 64 function MathFloorJS(x) {
65 return %_MathFloor(+x); 65 return %_MathFloor(+x);
66 } 66 }
67 67
68 // ECMA 262 - 15.8.2.10 68 // ECMA 262 - 15.8.2.10
69 function MathLog(x) { 69 function MathLog(x) {
70 return %_MathLogRT(TO_NUMBER_INLINE(x)); 70 return %_MathLogRT(TO_NUMBER_INLINE(x));
71 } 71 }
72 72
73 // ECMA 262 - 15.8.2.11 73 // ECMA 262 - 15.8.2.11
74 function MathMax(arg1, arg2) { // length == 2 74 function MathMax(arg1, arg2) { // length == 2
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (!IS_NUMBER(n)) n = NonNumberToNumber(n); 118 if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
119 // Make sure -0 is considered less than +0. 119 // Make sure -0 is considered less than +0.
120 if (NUMBER_IS_NAN(n) || n < r || (r === 0 && n === 0 && %_IsMinusZero(n))) { 120 if (NUMBER_IS_NAN(n) || n < r || (r === 0 && n === 0 && %_IsMinusZero(n))) {
121 r = n; 121 r = n;
122 } 122 }
123 } 123 }
124 return r; 124 return r;
125 } 125 }
126 126
127 // ECMA 262 - 15.8.2.13 127 // ECMA 262 - 15.8.2.13
128 function MathPow(x, y) { 128 function MathPowJS(x, y) {
129 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); 129 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y));
130 } 130 }
131 131
132 // ECMA 262 - 15.8.2.14 132 // ECMA 262 - 15.8.2.14
133 function MathRandom() { 133 function MathRandom() {
134 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; 134 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
135 rngstate[0] = r0; 135 rngstate[0] = r0;
136 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; 136 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0;
137 rngstate[1] = r1; 137 rngstate[1] = r1;
138 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0; 138 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0;
139 // Division by 0x100000000 through multiplication by reciprocal. 139 // Division by 0x100000000 through multiplication by reciprocal.
140 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10; 140 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10;
141 } 141 }
142 142
143 // ECMA 262 - 15.8.2.15 143 // ECMA 262 - 15.8.2.15
144 function MathRound(x) { 144 function MathRound(x) {
145 return %RoundNumber(TO_NUMBER_INLINE(x)); 145 return %RoundNumber(TO_NUMBER_INLINE(x));
146 } 146 }
147 147
148 // ECMA 262 - 15.8.2.17 148 // ECMA 262 - 15.8.2.17
149 function MathSqrt(x) { 149 function MathSqrtJS(x) {
150 return %_MathSqrt(+x); 150 return %_MathSqrt(+x);
151 } 151 }
152 152
153 // Non-standard extension. 153 // Non-standard extension.
154 function MathImul(x, y) { 154 function MathImul(x, y) {
155 return %NumberImul(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); 155 return %NumberImul(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y));
156 } 156 }
157 157
158 // ES6 draft 09-27-13, section 20.2.2.28. 158 // ES6 draft 09-27-13, section 20.2.2.28.
159 function MathSign(x) { 159 function MathSign(x) {
160 x = TO_NUMBER_INLINE(x); 160 x = TO_NUMBER_INLINE(x);
161 if (x > 0) return 1; 161 if (x > 0) return 1;
162 if (x < 0) return -1; 162 if (x < 0) return -1;
163 // -0, 0 or NaN. 163 // -0, 0 or NaN.
164 return x; 164 return x;
165 } 165 }
166 166
167 // ES6 draft 09-27-13, section 20.2.2.34. 167 // ES6 draft 09-27-13, section 20.2.2.34.
168 function MathTrunc(x) { 168 function MathTrunc(x) {
169 x = TO_NUMBER_INLINE(x); 169 x = TO_NUMBER_INLINE(x);
170 if (x > 0) return MathFloor(x); 170 if (x > 0) return MathFloorJS(x);
171 if (x < 0) return MathCeil(x); 171 if (x < 0) return MathCeil(x);
172 // -0, 0 or NaN. 172 // -0, 0 or NaN.
173 return x; 173 return x;
174 } 174 }
175 175
176 // ES6 draft 09-27-13, section 20.2.2.33. 176 // ES6 draft 09-27-13, section 20.2.2.33.
177 function MathTanh(x) { 177 function MathTanh(x) {
178 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); 178 if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
179 // Idempotent for +/-0. 179 // Idempotent for +/-0.
180 if (x === 0) return x; 180 if (x === 0) return x;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); 273 if (!IS_NUMBER(x)) x = NonNumberToNumber(x);
274 if (x == 0 || !NUMBER_IS_FINITE(x)) return x; 274 if (x == 0 || !NUMBER_IS_FINITE(x)) return x;
275 return x >= 0 ? CubeRoot(x) : -CubeRoot(-x); 275 return x >= 0 ? CubeRoot(x) : -CubeRoot(-x);
276 } 276 }
277 277
278 macro NEWTON_ITERATION_CBRT(x, approx) 278 macro NEWTON_ITERATION_CBRT(x, approx)
279 (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); 279 (1.0 / 3.0) * (x / (approx * approx) + 2 * approx);
280 endmacro 280 endmacro
281 281
282 function CubeRoot(x) { 282 function CubeRoot(x) {
283 var approx_hi = MathFloor(%_DoubleHi(x) / 3) + 0x2A9F7893; 283 var approx_hi = MathFloorJS(%_DoubleHi(x) / 3) + 0x2A9F7893;
284 var approx = %_ConstructDouble(approx_hi, 0); 284 var approx = %_ConstructDouble(approx_hi, 0);
285 approx = NEWTON_ITERATION_CBRT(x, approx); 285 approx = NEWTON_ITERATION_CBRT(x, approx);
286 approx = NEWTON_ITERATION_CBRT(x, approx); 286 approx = NEWTON_ITERATION_CBRT(x, approx);
287 approx = NEWTON_ITERATION_CBRT(x, approx); 287 approx = NEWTON_ITERATION_CBRT(x, approx);
288 return NEWTON_ITERATION_CBRT(x, approx); 288 return NEWTON_ITERATION_CBRT(x, approx);
289 } 289 }
290 290
291 // ------------------------------------------------------------------- 291 // -------------------------------------------------------------------
292 292
293 // Instance class name can only be set on functions. That is the only 293 // Instance class name can only be set on functions. That is the only
(...skipping 27 matching lines...) Expand all
321 // Set up non-enumerable functions of the Math object and 321 // Set up non-enumerable functions of the Math object and
322 // set their names. 322 // set their names.
323 InstallFunctions(Math, DONT_ENUM, GlobalArray( 323 InstallFunctions(Math, DONT_ENUM, GlobalArray(
324 "random", MathRandom, 324 "random", MathRandom,
325 "abs", MathAbs, 325 "abs", MathAbs,
326 "acos", MathAcosJS, 326 "acos", MathAcosJS,
327 "asin", MathAsinJS, 327 "asin", MathAsinJS,
328 "atan", MathAtanJS, 328 "atan", MathAtanJS,
329 "ceil", MathCeil, 329 "ceil", MathCeil,
330 "exp", MathExp, 330 "exp", MathExp,
331 "floor", MathFloor, 331 "floor", MathFloorJS,
332 "log", MathLog, 332 "log", MathLog,
333 "round", MathRound, 333 "round", MathRound,
334 "sqrt", MathSqrt, 334 "sqrt", MathSqrtJS,
335 "atan2", MathAtan2JS, 335 "atan2", MathAtan2JS,
336 "pow", MathPow, 336 "pow", MathPowJS,
337 "max", MathMax, 337 "max", MathMax,
338 "min", MathMin, 338 "min", MathMin,
339 "imul", MathImul, 339 "imul", MathImul,
340 "sign", MathSign, 340 "sign", MathSign,
341 "trunc", MathTrunc, 341 "trunc", MathTrunc,
342 "tanh", MathTanh, 342 "tanh", MathTanh,
343 "asinh", MathAsinh, 343 "asinh", MathAsinh,
344 "acosh", MathAcosh, 344 "acosh", MathAcosh,
345 "atanh", MathAtanh, 345 "atanh", MathAtanh,
346 "hypot", MathHypot, 346 "hypot", MathHypot,
347 "fround", MathFroundJS, 347 "fround", MathFroundJS,
348 "clz32", MathClz32, 348 "clz32", MathClz32,
349 "cbrt", MathCbrt 349 "cbrt", MathCbrt
350 )); 350 ));
351 351
352 %SetInlineBuiltinFlag(MathAbs); 352 %SetInlineBuiltinFlag(MathAbs);
353 %SetInlineBuiltinFlag(MathCeil); 353 %SetInlineBuiltinFlag(MathCeil);
354 %SetInlineBuiltinFlag(MathFloor); 354 %SetInlineBuiltinFlag(MathFloorJS);
355 %SetInlineBuiltinFlag(MathRandom); 355 %SetInlineBuiltinFlag(MathRandom);
356 %SetInlineBuiltinFlag(MathSqrt); 356 %SetInlineBuiltinFlag(MathSqrtJS);
357 357
358 // Expose to the global scope. 358 // Expose to the global scope.
359 $abs = MathAbs; 359 $abs = MathAbs;
360 $exp = MathExp; 360 $exp = MathExp;
361 $floor = MathFloor; 361 $floor = MathFloorJS;
362 $max = MathMax; 362 $max = MathMax;
363 $min = MathMin; 363 $min = MathMin;
364 364
365 })(); 365 })();
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698