Commit b49050c8 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

[js] turn MinSimple/MaxSimple into macros.

Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I1a9561adc44ee1d8a6b68c36604992261c490043
Reviewed-on: https://chromium-review.googlesource.com/651414Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47848}
parent 9e995e12
......@@ -551,7 +551,6 @@ action("js2c") {
"src/js/macros.py",
"src/messages.h",
"src/js/prologue.js",
"src/js/max-min.js",
"src/js/v8natives.js",
"src/js/array.js",
"src/js/string.js",
......
......@@ -15,8 +15,6 @@ var GetIterator;
var GetMethod;
var GlobalArray = global.Array;
var InternalArray = utils.InternalArray;
var MaxSimple;
var MinSimple;
var ObjectHasOwnProperty = global.Object.prototype.hasOwnProperty;
var ObjectToString = global.Object.prototype.toString;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
......@@ -25,8 +23,6 @@ var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
GetIterator = from.GetIterator;
GetMethod = from.GetMethod;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
});
// -------------------------------------------------------------------
......@@ -226,7 +222,7 @@ function SparseMove(array, start_i, del_count, len, num_additional_args) {
// Move data to new array.
var new_array = new InternalArray(
// Clamp array length to 2^32-1 to avoid early RangeError.
MinSimple(len - del_count + num_additional_args, 0xffffffff));
MINSIMPLE(len - del_count + num_additional_args, 0xffffffff));
var big_indices;
var indices = %GetArrayKeys(array, len);
if (IS_NUMBER(indices)) {
......@@ -616,7 +612,7 @@ function ArraySliceFallback(start, end) {
if (end_i > len) end_i = len;
}
var result = ArraySpeciesCreate(array, MaxSimple(end_i - start_i, 0));
var result = ArraySpeciesCreate(array, MAXSIMPLE(end_i - start_i, 0));
if (end_i < start_i) return result;
......@@ -1085,28 +1081,28 @@ DEFINE_METHOD_LEN(
target = TO_INTEGER(target);
var to;
if (target < 0) {
to = MaxSimple(length + target, 0);
to = MAXSIMPLE(length + target, 0);
} else {
to = MinSimple(target, length);
to = MINSIMPLE(target, length);
}
start = TO_INTEGER(start);
var from;
if (start < 0) {
from = MaxSimple(length + start, 0);
from = MAXSIMPLE(length + start, 0);
} else {
from = MinSimple(start, length);
from = MINSIMPLE(start, length);
}
end = IS_UNDEFINED(end) ? length : TO_INTEGER(end);
var final;
if (end < 0) {
final = MaxSimple(length + end, 0);
final = MAXSIMPLE(length + end, 0);
} else {
final = MinSimple(end, length);
final = MINSIMPLE(end, length);
}
var count = MinSimple(final - from, length - to);
var count = MINSIMPLE(final - from, length - to);
var direction = 1;
if (from < to && to < (from + count)) {
direction = -1;
......
......@@ -31,7 +31,6 @@ var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
var IntlFallbackSymbol = utils.ImportNow("intl_fallback_symbol");
var InternalArray = utils.InternalArray;
var MaxSimple;
var ObjectHasOwnProperty = global.Object.prototype.hasOwnProperty;
var ObjectKeys = global.Object.keys;
var patternSymbol = utils.ImportNow("intl_pattern_symbol");
......@@ -42,7 +41,6 @@ var StringSubstring = GlobalString.prototype.substring;
utils.Import(function(from) {
ArrayJoin = from.ArrayJoin;
ArrayPush = from.ArrayPush;
MaxSimple = from.MaxSimple;
});
// Utilities for definitions
......@@ -1221,7 +1219,7 @@ function SetNumberFormatDigitOptions(internalOptions, options,
mnfdDefault);
defineWEProperty(internalOptions, 'minimumFractionDigits', mnfd);
var mxfdActualDefault = MaxSimple(mnfd, mxfdDefault);
var mxfdActualDefault = MAXSIMPLE(mnfd, mxfdDefault);
var mxfd = getNumberOption(options, 'maximumFractionDigits', mnfd, 20,
mxfdActualDefault);
......
......@@ -112,3 +112,7 @@ define PROPERTY_FILTER_NONE = 0;
# Check whether debug is active.
define DEBUG_IS_ACTIVE = (%_DebugIsActive() != 0);
# Min and max
macro MAXSIMPLE(a, b) = ((a) > (b) ? (a) : (b));
macro MINSIMPLE(a, b) = ((a) > (b) ? (b) : (a));
// Copyright 2006-2008 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();
function MaxSimple(a, b) {
return a > b ? a : b;
}
function MinSimple(a, b) {
return a > b ? b : a;
}
%SetForceInlineFlag(MaxSimple);
%SetForceInlineFlag(MinSimple);
// ----------------------------------------------------------------------------
// Exports
utils.Export(function(to) {
to.MaxSimple = MaxSimple;
to.MinSimple = MinSimple;
});
})
......@@ -25,8 +25,6 @@ var InnerArrayJoin;
var InnerArraySort;
var InnerArrayToLocaleString;
var InternalArray = utils.InternalArray;
var MaxSimple;
var MinSimple;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
......@@ -59,8 +57,6 @@ utils.Import(function(from) {
InnerArrayJoin = from.InnerArrayJoin;
InnerArraySort = from.InnerArraySort;
InnerArrayToLocaleString = from.InnerArrayToLocaleString;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
});
// ES2015 7.3.20
......@@ -208,15 +204,15 @@ function NAMESubArray(begin, end) {
}
if (beginInt < 0) {
beginInt = MaxSimple(0, srcLength + beginInt);
beginInt = MAXSIMPLE(0, srcLength + beginInt);
} else {
beginInt = MinSimple(beginInt, srcLength);
beginInt = MINSIMPLE(beginInt, srcLength);
}
if (endInt < 0) {
endInt = MaxSimple(0, srcLength + endInt);
endInt = MAXSIMPLE(0, srcLength + endInt);
} else {
endInt = MinSimple(endInt, srcLength);
endInt = MINSIMPLE(endInt, srcLength);
}
if (endInt < beginInt) {
......
......@@ -2305,7 +2305,6 @@
'js/macros.py',
'messages.h',
'js/prologue.js',
'js/max-min.js',
'js/v8natives.js',
'js/array.js',
'js/string.js',
......
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