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

Unified Diff: src/math.js

Issue 1000063002: Hide RegExp and String initialization in a closure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/i18n.js ('k') | src/messages.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/math.js
diff --git a/src/math.js b/src/math.js
index 6b51593adaae96b9b596edfd05ff4741bb5df792..d7e5f948a5c35811e8a5f61d79bada0dd378de52 100644
--- a/src/math.js
+++ b/src/math.js
@@ -2,13 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This file relies on the fact that the following declarations have been made
-// in runtime.js:
-// var $Object = global.Object;
-
-// Instance class name can only be set on functions. That is the only
-// purpose for MathConstructor.
-
var rngstate; // Initialized to a Uint32Array during genesis.
var $abs;
@@ -17,12 +10,17 @@ var $floor;
var $max;
var $min;
-// -------------------------------------------------------------------
-
(function() {
"use strict";
+%CheckIsBootstrapping();
+
+var GlobalObject = global.Object;
+var GlobalArray = global.Array;
+
+//-------------------------------------------------------------------
+
// ECMA 262 - 15.8.2.1
function MathAbs(x) {
if (%_IsSmi(x)) return x >= 0 ? x : -x;
@@ -293,20 +291,20 @@ function CubeRoot(x) {
// -------------------------------------------------------------------
-%CheckIsBootstrapping();
-
+// Instance class name can only be set on functions. That is the only
+// purpose for MathConstructor.
function MathConstructor() {}
var Math = new MathConstructor();
-%InternalSetPrototype(Math, $Object.prototype);
+%InternalSetPrototype(Math, GlobalObject.prototype);
%AddNamedProperty(global, "Math", Math, DONT_ENUM);
%FunctionSetInstanceClassName(MathConstructor, 'Math');
%AddNamedProperty(Math, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM);
// Set up math constants.
-InstallConstants(Math, $Array(
+InstallConstants(Math, GlobalArray(
// ECMA-262, section 15.8.1.1.
"E", 2.7182818284590452354,
// ECMA-262, section 15.8.1.2.
@@ -323,7 +321,7 @@ InstallConstants(Math, $Array(
// Set up non-enumerable functions of the Math object and
// set their names.
-InstallFunctions(Math, DONT_ENUM, $Array(
+InstallFunctions(Math, DONT_ENUM, GlobalArray(
"random", MathRandom,
"abs", MathAbs,
"acos", MathAcosJS,
« no previous file with comments | « src/i18n.js ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698