Commit 3ece714d authored by aperez's avatar aperez Committed by Commit bot

Use a kMaxSafeInteger instead of Number.MAX_SAFE_INTEGER

Defines and uses a kMaxSafeInteger macro (which expands to the constant
2^53-1) instead of accessing Number.MAX_SAFE_INTEGER. This saves loading
the attribute from the Number object, which is slightly faster. This also
makes it clearer from reading the code that tha value being compared is
constant.

BUG=
LOG=N

Review URL: https://codereview.chromium.org/1353953002

Cr-Commit-Position: refs/heads/master@{#30814}
parent 05c804fc
......@@ -74,6 +74,9 @@ define kMaxMonth = 10000000;
# Reflect.construct().
define kSafeArgumentsLength = 0x800000;
# 2^53 - 1
define kMaxSafeInteger = 9007199254740991;
# Strict mode flags for passing to %SetProperty
define kSloppyMode = 0;
define kStrictMode = 1;
......
......@@ -33,7 +33,6 @@ var harmony_tolength = false;
var GlobalArray = global.Array;
var GlobalBoolean = global.Boolean;
var GlobalString = global.String;
var GlobalNumber = global.Number;
var isConcatSpreadableSymbol =
utils.ImportNow("is_concat_spreadable_symbol");
......@@ -302,8 +301,7 @@ function ToInteger(x) {
function ToLength(arg) {
arg = ToInteger(arg);
if (arg < 0) return 0;
return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg
: GlobalNumber.MAX_SAFE_INTEGER;
return arg < kMaxSafeInteger ? arg : kMaxSafeInteger;
}
......
......@@ -1544,7 +1544,7 @@ function NumberIsSafeInteger(number) {
if (NumberIsFinite(number)) {
var integral = TO_INTEGER(number);
if (integral == number) {
return MathAbs(integral) <= GlobalNumber.MAX_SAFE_INTEGER;
return MathAbs(integral) <= kMaxSafeInteger;
}
}
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment