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

Unified Diff: src/js/math.js

Issue 2402363002: [Math] implement Math.random as TFJ builtin. (Closed)
Patch Set: fix golden file Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: src/js/math.js
diff --git a/src/js/math.js b/src/js/math.js
deleted file mode 100644
index 346da2459641ff59f625e14dc869eb823804cf0d..0000000000000000000000000000000000000000
--- a/src/js/math.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(function(global, utils) {
-"use strict";
-
-%CheckIsBootstrapping();
-
-// -------------------------------------------------------------------
-// Imports
-
-// The first two slots are reserved to persist PRNG state.
-define kRandomNumberStart = 2;
-
-var GlobalMath = global.Math;
-var NaN = %GetRootNaN();
-var nextRandomIndex = 0;
-var randomNumbers = UNDEFINED;
-var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
-
-//-------------------------------------------------------------------
-// ECMA 262 - 15.8.2.14
-function MathRandom() {
- // While creating a startup snapshot, %GenerateRandomNumbers returns a
- // normal array containing a single random number, and has to be called for
- // every new random number.
- // Otherwise, it returns a pre-populated typed array of random numbers. The
- // first two elements are reserved for the PRNG state.
- if (nextRandomIndex <= kRandomNumberStart) {
- randomNumbers = %GenerateRandomNumbers(randomNumbers);
- if (%_IsTypedArray(randomNumbers)) {
- nextRandomIndex = %_TypedArrayGetLength(randomNumbers);
- } else {
- nextRandomIndex = randomNumbers.length;
- }
- }
- return randomNumbers[--nextRandomIndex];
-}
-
-// -------------------------------------------------------------------
-
-%AddNamedProperty(GlobalMath, toStringTagSymbol, "Math", READ_ONLY | DONT_ENUM);
-
-// Set up non-enumerable functions of the Math object and
-// set their names.
-utils.InstallFunctions(GlobalMath, DONT_ENUM, [
- "random", MathRandom,
-]);
-
-%SetForceInlineFlag(MathRandom);
-
-// -------------------------------------------------------------------
-// Exports
-
-utils.Export(function(to) {
- to.MathRandom = MathRandom;
-});
-
-})
« no previous file with comments | « src/js/collection.js ('k') | src/runtime/runtime.h » ('j') | test/mjsunit/debug-script.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698