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

Side by Side Diff: src/runtime.js

Issue 1348943002: Slightly optimize performance of ToLength() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/macros.py ('k') | src/v8natives.js » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 // ECMA-262, section 9.4, page 34. 294 // ECMA-262, section 9.4, page 34.
295 function ToInteger(x) { 295 function ToInteger(x) {
296 if (%_IsSmi(x)) return x; 296 if (%_IsSmi(x)) return x;
297 return %NumberToInteger(ToNumber(x)); 297 return %NumberToInteger(ToNumber(x));
298 } 298 }
299 299
300 300
301 // ES6, draft 08-24-14, section 7.1.15 301 // ES6, draft 08-24-14, section 7.1.15
302 function ToLength(arg) { 302 function ToLength(arg) {
303 arg = ToInteger(arg); 303 if (!%_IsSmi(arg)) {
304 arg = %NumberToInteger(ToNumber(arg));
305 }
304 if (arg < 0) return 0; 306 if (arg < 0) return 0;
305 return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg 307 return arg < kMaxSafeInteger ? arg : kMaxSafeInteger;
306 : GlobalNumber.MAX_SAFE_INTEGER;
307 } 308 }
308 309
309 310
310 // ES5, section 9.12 311 // ES5, section 9.12
311 function SameValue(x, y) { 312 function SameValue(x, y) {
312 if (typeof x != typeof y) return false; 313 if (typeof x != typeof y) return false;
313 if (IS_NUMBER(x)) { 314 if (IS_NUMBER(x)) {
314 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true; 315 if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
315 // x is +0 and y is -0 or vice versa. 316 // x is +0 and y is -0 or vice versa.
316 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) { 317 if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 456
456 utils.Export(function(to) { 457 utils.Export(function(to) {
457 to.ToBoolean = ToBoolean; 458 to.ToBoolean = ToBoolean;
458 to.ToLength = ToLength; 459 to.ToLength = ToLength;
459 to.ToNumber = ToNumber; 460 to.ToNumber = ToNumber;
460 to.ToPrimitive = ToPrimitive; 461 to.ToPrimitive = ToPrimitive;
461 to.ToString = ToString; 462 to.ToString = ToString;
462 }); 463 });
463 464
464 }) 465 })
OLDNEW
« no previous file with comments | « src/macros.py ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698