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

Side by Side Diff: src/math.js

Issue 1294583006: Clean up native context slots and add new ones. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/json-stringifier.h ('k') | src/messages.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 (function(global, utils) { 7 (function(global, utils) {
8 "use strict"; 8 "use strict";
9 9
10 %CheckIsBootstrapping(); 10 %CheckIsBootstrapping();
11 11
12 // ------------------------------------------------------------------- 12 // -------------------------------------------------------------------
13 // Imports 13 // Imports
14 14
15 var GlobalMath = global.Math;
15 var GlobalObject = global.Object; 16 var GlobalObject = global.Object;
16 var InternalArray = utils.InternalArray; 17 var InternalArray = utils.InternalArray;
17 18
18 //------------------------------------------------------------------- 19 //-------------------------------------------------------------------
19 20
20 // ECMA 262 - 15.8.2.1 21 // ECMA 262 - 15.8.2.1
21 function MathAbs(x) { 22 function MathAbs(x) {
22 x = +x; 23 x = +x;
23 return (x > 0) ? x : 0 - x; 24 return (x > 0) ? x : 0 - x;
24 } 25 }
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 var approx_hi = MathFloorJS(%_DoubleHi(x) / 3) + 0x2A9F7893; 281 var approx_hi = MathFloorJS(%_DoubleHi(x) / 3) + 0x2A9F7893;
281 var approx = %_ConstructDouble(approx_hi, 0); 282 var approx = %_ConstructDouble(approx_hi, 0);
282 approx = NEWTON_ITERATION_CBRT(x, approx); 283 approx = NEWTON_ITERATION_CBRT(x, approx);
283 approx = NEWTON_ITERATION_CBRT(x, approx); 284 approx = NEWTON_ITERATION_CBRT(x, approx);
284 approx = NEWTON_ITERATION_CBRT(x, approx); 285 approx = NEWTON_ITERATION_CBRT(x, approx);
285 return NEWTON_ITERATION_CBRT(x, approx); 286 return NEWTON_ITERATION_CBRT(x, approx);
286 } 287 }
287 288
288 // ------------------------------------------------------------------- 289 // -------------------------------------------------------------------
289 290
290 // Instance class name can only be set on functions. That is the only 291 %AddNamedProperty(GlobalMath, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
291 // purpose for MathConstructor.
292 function MathConstructor() {}
293
294 var Math = new MathConstructor();
295
296 %InternalSetPrototype(Math, GlobalObject.prototype);
297 %AddNamedProperty(global, "Math", Math, DONT_ENUM);
298 %FunctionSetInstanceClassName(MathConstructor, 'Math');
299
300 %AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
301 292
302 // Set up math constants. 293 // Set up math constants.
303 utils.InstallConstants(Math, [ 294 utils.InstallConstants(GlobalMath, [
304 // ECMA-262, section 15.8.1.1. 295 // ECMA-262, section 15.8.1.1.
305 "E", 2.7182818284590452354, 296 "E", 2.7182818284590452354,
306 // ECMA-262, section 15.8.1.2. 297 // ECMA-262, section 15.8.1.2.
307 "LN10", 2.302585092994046, 298 "LN10", 2.302585092994046,
308 // ECMA-262, section 15.8.1.3. 299 // ECMA-262, section 15.8.1.3.
309 "LN2", 0.6931471805599453, 300 "LN2", 0.6931471805599453,
310 // ECMA-262, section 15.8.1.4. 301 // ECMA-262, section 15.8.1.4.
311 "LOG2E", 1.4426950408889634, 302 "LOG2E", 1.4426950408889634,
312 "LOG10E", 0.4342944819032518, 303 "LOG10E", 0.4342944819032518,
313 "PI", 3.1415926535897932, 304 "PI", 3.1415926535897932,
314 "SQRT1_2", 0.7071067811865476, 305 "SQRT1_2", 0.7071067811865476,
315 "SQRT2", 1.4142135623730951 306 "SQRT2", 1.4142135623730951
316 ]); 307 ]);
317 308
318 // Set up non-enumerable functions of the Math object and 309 // Set up non-enumerable functions of the Math object and
319 // set their names. 310 // set their names.
320 utils.InstallFunctions(Math, DONT_ENUM, [ 311 utils.InstallFunctions(GlobalMath, DONT_ENUM, [
321 "random", MathRandom, 312 "random", MathRandom,
322 "abs", MathAbs, 313 "abs", MathAbs,
323 "acos", MathAcosJS, 314 "acos", MathAcosJS,
324 "asin", MathAsinJS, 315 "asin", MathAsinJS,
325 "atan", MathAtanJS, 316 "atan", MathAtanJS,
326 "ceil", MathCeil, 317 "ceil", MathCeil,
327 "exp", MathExp, 318 "exp", MathExp,
328 "floor", MathFloorJS, 319 "floor", MathFloorJS,
329 "log", MathLog, 320 "log", MathLog,
330 "round", MathRound, 321 "round", MathRound,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 utils.Export(function(to) { 356 utils.Export(function(to) {
366 to.MathAbs = MathAbs; 357 to.MathAbs = MathAbs;
367 to.MathExp = MathExp; 358 to.MathExp = MathExp;
368 to.MathFloor = MathFloorJS; 359 to.MathFloor = MathFloorJS;
369 to.IntRandom = MathRandomRaw; 360 to.IntRandom = MathRandomRaw;
370 to.MathMax = MathMax; 361 to.MathMax = MathMax;
371 to.MathMin = MathMin; 362 to.MathMin = MathMin;
372 }); 363 });
373 364
374 }) 365 })
OLDNEW
« no previous file with comments | « src/json-stringifier.h ('k') | src/messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698