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

Side by Side Diff: src/math.js

Issue 1149863005: Move hash code from hidden string to a private symbol (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix global object hash code. This eated about 5% of weak collection performance Created 5 years, 7 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
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;
11 var $min; 11 var $min;
12 var $intrandom;
12 13
13 (function(global, shared, exports) { 14 (function(global, shared, exports) {
14 15
15 "use strict"; 16 "use strict";
16 17
17 %CheckIsBootstrapping(); 18 %CheckIsBootstrapping();
18 19
19 // ------------------------------------------------------------------- 20 // -------------------------------------------------------------------
20 // Imports 21 // Imports
21 22
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 function MathRandom() { 138 function MathRandom() {
138 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; 139 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
139 rngstate[0] = r0; 140 rngstate[0] = r0;
140 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; 141 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0;
141 rngstate[1] = r1; 142 rngstate[1] = r1;
142 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0; 143 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0;
143 // Division by 0x100000000 through multiplication by reciprocal. 144 // Division by 0x100000000 through multiplication by reciprocal.
144 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10; 145 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10;
145 } 146 }
146 147
148 function MathRandomRaw() {
149 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
150 rngstate[0] = r0;
151 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0;
152 rngstate[1] = r1;
153 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0;
154 return x & 0x3fffffff;
155 }
156
147 // ECMA 262 - 15.8.2.15 157 // ECMA 262 - 15.8.2.15
148 function MathRound(x) { 158 function MathRound(x) {
149 return %RoundNumber(TO_NUMBER_INLINE(x)); 159 return %RoundNumber(TO_NUMBER_INLINE(x));
150 } 160 }
151 161
152 // ECMA 262 - 15.8.2.17 162 // ECMA 262 - 15.8.2.17
153 function MathSqrtJS(x) { 163 function MathSqrtJS(x) {
154 return %_MathSqrt(+x); 164 return %_MathSqrt(+x);
155 } 165 }
156 166
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 %SetInlineBuiltinFlag(MathFloorJS); 364 %SetInlineBuiltinFlag(MathFloorJS);
355 %SetInlineBuiltinFlag(MathRandom); 365 %SetInlineBuiltinFlag(MathRandom);
356 %SetInlineBuiltinFlag(MathSign); 366 %SetInlineBuiltinFlag(MathSign);
357 %SetInlineBuiltinFlag(MathSqrtJS); 367 %SetInlineBuiltinFlag(MathSqrtJS);
358 %SetInlineBuiltinFlag(MathTrunc); 368 %SetInlineBuiltinFlag(MathTrunc);
359 369
360 // Expose to the global scope. 370 // Expose to the global scope.
361 $abs = MathAbs; 371 $abs = MathAbs;
362 $exp = MathExp; 372 $exp = MathExp;
363 $floor = MathFloorJS; 373 $floor = MathFloorJS;
374 $intrandom = MathRandomRaw;
adamk 2015/05/21 19:11:32 One more camelCase nit here...$intRandom?
Erik Corry 2015/05/22 06:20:24 Done.
364 $max = MathMax; 375 $max = MathMax;
365 $min = MathMin; 376 $min = MathMin;
366 377
367 }) 378 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698