Commit dca275ba authored by bmeurer's avatar bmeurer Committed by Commit bot

Revert of [builtins] Remove bunch of uses of %_Arguments and...

Revert of [builtins] Remove bunch of uses of %_Arguments and %_ArgumentsLength. (patchset #1 id:1 of https://codereview.chromium.org/1678953004/ )

Reason for revert:
Breaks tree

Original issue's description:
> [builtins] Remove bunch of uses of %_Arguments and %_ArgumentsLength.
>
> There are a bunch of places in our builtins where we use %_Arguments and
> %_ArgumentsLength for no good reason, as arguments object and/or rest
> parameter is as good and performant in these cases. Now the only uses
> of %_Arguments and %_ArgumentsLength left are in string.js, which
> requires dedicated investigation.
>
> R=yangguo@chromium.org
>
> Committed: https://crrev.com/2160429fd458e3c095475e718c97f77ac90d906f
> Cr-Commit-Position: refs/heads/master@{#33834}

TBR=yangguo@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#33835}
parent 2160429f
......@@ -515,12 +515,12 @@ function ArrayPop() {
function ObservedArrayPush() {
var n = TO_LENGTH(this.length);
var m = arguments.length;
var m = %_ArgumentsLength();
try {
ObserveBeginPerformSplice(this);
for (var i = 0; i < m; i++) {
this[i+n] = arguments[i];
this[i+n] = %_Arguments(i);
}
var new_length = n + m;
this.length = new_length;
......@@ -543,7 +543,7 @@ function ArrayPush() {
var array = TO_OBJECT(this);
var n = TO_LENGTH(array.length);
var m = arguments.length;
var m = %_ArgumentsLength();
// It appears that there is no enforced, absolute limit on the number of
// arguments, but it would surely blow the stack to use 2**30 or more.
......@@ -555,7 +555,7 @@ function ArrayPush() {
}
for (var i = 0; i < m; i++) {
array[i+n] = arguments[i];
array[i+n] = %_Arguments(i);
}
var new_length = n + m;
......@@ -711,13 +711,13 @@ function ArrayShift() {
function ObservedArrayUnshift() {
var len = TO_LENGTH(this.length);
var num_arguments = arguments.length;
var num_arguments = %_ArgumentsLength();
try {
ObserveBeginPerformSplice(this);
SimpleMove(this, 0, 0, len, num_arguments);
for (var i = 0; i < num_arguments; i++) {
this[i] = arguments[i];
this[i] = %_Arguments(i);
}
var new_length = len + num_arguments;
this.length = new_length;
......@@ -738,7 +738,7 @@ function ArrayUnshift(arg1) { // length == 1
var array = TO_OBJECT(this);
var len = TO_LENGTH(array.length);
var num_arguments = arguments.length;
var num_arguments = %_ArgumentsLength();
if (len > 0 && UseSparseVariant(array, len, IS_ARRAY(array), len) &&
!%object_is_sealed(array)) {
......@@ -748,7 +748,7 @@ function ArrayUnshift(arg1) { // length == 1
}
for (var i = 0; i < num_arguments; i++) {
array[i] = arguments[i];
array[i] = %_Arguments(i);
}
var new_length = len + num_arguments;
......@@ -831,7 +831,7 @@ function ComputeSpliceDeleteCount(delete_count, num_arguments, len, start_i) {
function ObservedArraySplice(start, delete_count) {
var num_arguments = arguments.length;
var num_arguments = %_ArgumentsLength();
var len = TO_LENGTH(this.length);
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len);
var del_count = ComputeSpliceDeleteCount(delete_count, num_arguments, len,
......@@ -850,9 +850,9 @@ function ObservedArraySplice(start, delete_count) {
// place of the deleted elements.
var i = start_i;
var arguments_index = 2;
var arguments_length = arguments.length;
var arguments_length = %_ArgumentsLength();
while (arguments_index < arguments_length) {
this[i++] = arguments[arguments_index++];
this[i++] = %_Arguments(arguments_index++);
}
this.length = len - del_count + num_elements_to_add;
......@@ -877,7 +877,7 @@ function ArraySplice(start, delete_count) {
if (%IsObserved(this))
return ObservedArraySplice.apply(this, arguments);
var num_arguments = arguments.length;
var num_arguments = %_ArgumentsLength();
var array = TO_OBJECT(this);
var len = TO_LENGTH(array.length);
var start_i = ComputeSpliceStartIndex(TO_INTEGER(start), len);
......@@ -913,9 +913,9 @@ function ArraySplice(start, delete_count) {
// place of the deleted elements.
var i = start_i;
var arguments_index = 2;
var arguments_length = arguments.length;
var arguments_length = %_ArgumentsLength();
while (arguments_index < arguments_length) {
array[i++] = arguments[arguments_index++];
array[i++] = %_Arguments(arguments_index++);
}
array.length = len - del_count + num_elements_to_add;
......@@ -1469,7 +1469,7 @@ function ArrayLastIndexOf(element, index) {
var length = TO_LENGTH(this.length);
return InnerArrayLastIndexOf(this, element, index, length,
arguments.length);
%_ArgumentsLength());
}
......@@ -1508,7 +1508,7 @@ function ArrayReduce(callback, current) {
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
return InnerArrayReduce(callback, current, array, length,
arguments.length);
%_ArgumentsLength());
}
......@@ -1548,7 +1548,7 @@ function ArrayReduceRight(callback, current) {
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
return InnerArrayReduceRight(callback, current, array, length,
arguments.length);
%_ArgumentsLength());
}
......@@ -1822,13 +1822,13 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
// ES6, draft 05-22-14, section 22.1.2.3
function ArrayOf(...args) {
var length = args.length;
function ArrayOf() {
var length = %_ArgumentsLength();
var constructor = this;
// TODO: Implement IsConstructor (ES6 section 7.2.5)
var array = %IsConstructor(constructor) ? new constructor(length) : [];
for (var i = 0; i < length; i++) {
AddArrayElement(constructor, array, i, args[i]);
AddArrayElement(constructor, array, i, %_Arguments(i));
}
array.length = length;
return array;
......
......@@ -187,7 +187,7 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
function JSONStringify(value, replacer, space) {
if (arguments.length === 1 && !IS_PROXY(value)) {
if (%_ArgumentsLength() == 1 && !IS_PROXY(value)) {
return %BasicJSONStringify(value);
}
if (!IS_CALLABLE(replacer) && %is_arraylike(replacer)) {
......
......@@ -18,11 +18,11 @@ utils.Import(function(from) {
// -------------------------------------------------------------------
function SpreadArguments() {
var count = arguments.length;
var count = %_ArgumentsLength();
var args = new InternalArray();
for (var i = 0; i < count; ++i) {
var array = arguments[i];
var array = %_Arguments(i);
var length = array.length;
for (var j = 0; j < length; ++j) {
args.push(array[j]);
......
......@@ -615,7 +615,7 @@ function TypedArrayLastIndexOf(element, index) {
var length = %_TypedArrayGetLength(this);
return InnerArrayLastIndexOf(this, element, index, length,
arguments.length);
%_ArgumentsLength());
}
%FunctionSetLength(TypedArrayLastIndexOf, 1);
......@@ -679,7 +679,7 @@ function TypedArrayReduce(callback, current) {
var length = %_TypedArrayGetLength(this);
return InnerArrayReduce(callback, current, this, length,
arguments.length);
%_ArgumentsLength());
}
%FunctionSetLength(TypedArrayReduce, 1);
......@@ -690,7 +690,7 @@ function TypedArrayReduceRight(callback, current) {
var length = %_TypedArrayGetLength(this);
return InnerArrayReduceRight(callback, current, this, length,
arguments.length);
%_ArgumentsLength());
}
%FunctionSetLength(TypedArrayReduceRight, 1);
......@@ -751,10 +751,10 @@ function TypedArrayIncludes(searchElement, fromIndex) {
// ES6 draft 08-24-14, section 22.2.2.2
function TypedArrayOf() {
var length = arguments.length;
var length = %_ArgumentsLength();
var array = TypedArrayCreate(this, length);
for (var i = 0; i < length; i++) {
array[i] = arguments[i];
array[i] = %_Arguments(i);
}
return array;
}
......@@ -918,10 +918,9 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'DataView.getTYPENAME', this);
}
if (arguments.length < 1) throw MakeTypeError(kInvalidArgument);
if (%_ArgumentsLength() < 1) throw MakeTypeError(kInvalidArgument);
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
little_endian = TO_BOOLEAN(little_endian);
return %DataViewGetTYPENAME(this, offset, little_endian);
return %DataViewGetTYPENAME(this, offset, !!little_endian);
}
%FunctionSetLength(DataViewGetTYPENAMEJS, 1);
......@@ -930,10 +929,9 @@ function DataViewSetTYPENAMEJS(offset, value, little_endian) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'DataView.setTYPENAME', this);
}
if (arguments.length < 2) throw MakeTypeError(kInvalidArgument);
if (%_ArgumentsLength() < 2) throw MakeTypeError(kInvalidArgument);
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
little_endian = TO_BOOLEAN(little_endian);
%DataViewSetTYPENAME(this, offset, TO_NUMBER(value), little_endian);
%DataViewSetTYPENAME(this, offset, TO_NUMBER(value), !!little_endian);
}
%FunctionSetLength(DataViewSetTYPENAMEJS, 2);
endmacro
......
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