[torque] Remove unnecessary arguments length checks

arguments[i] already returns undefined if arguments is not large
enough.

BUG=v8:10468

Change-Id: I0755014d0f1b61d5e3e2069ef4d14a9b51f2ebee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2170092
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67467}
This commit is contained in:
Marja Hölttä 2020-04-28 12:16:49 +02:00 committed by Commit Bot
parent a596efccd1
commit 218fc55708
11 changed files with 60 additions and 76 deletions

View File

@ -128,7 +128,7 @@ namespace array {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: JSAny = arguments[1];
// Special cases.
try {

View File

@ -164,7 +164,7 @@ namespace array {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: JSAny = arguments[1];
let output: JSReceiver;
// Special cases.

View File

@ -136,7 +136,7 @@ namespace array {
Cast<Callable>(arguments[0]) otherwise NotCallableError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: JSAny = arguments[1];
// Special cases.
try {

View File

@ -137,7 +137,7 @@ namespace array {
Cast<Callable>(arguments[0]) otherwise NotCallableError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: JSAny = arguments[1];
// Special cases.
try {

View File

@ -109,7 +109,7 @@ namespace array {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: JSAny = arguments[1];
// Special cases.
let k: Number = 0;

View File

@ -241,7 +241,7 @@ namespace array {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: JSAny = arguments[1];
let array: JSReceiver;
let k: Number = 0;

View File

@ -128,7 +128,7 @@ namespace array {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: JSAny = arguments[1];
// Special cases.
try {

View File

@ -432,7 +432,7 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetUint8(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const offset: JSAny = arguments[0];
return DataViewGet(
context, receiver, offset, Undefined, ElementsKind::UINT8_ELEMENTS);
}
@ -440,7 +440,7 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetInt8(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const offset: JSAny = arguments[0];
return DataViewGet(
context, receiver, offset, Undefined, ElementsKind::INT8_ELEMENTS);
}
@ -448,9 +448,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetUint16(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::UINT16_ELEMENTS);
@ -459,9 +458,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetInt16(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::INT16_ELEMENTS);
@ -470,9 +468,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetUint32(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::UINT32_ELEMENTS);
@ -481,9 +478,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetInt32(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::INT32_ELEMENTS);
@ -492,9 +488,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetFloat32(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::FLOAT32_ELEMENTS);
@ -503,9 +498,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetFloat64(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::FLOAT64_ELEMENTS);
@ -514,9 +508,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetBigUint64(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::BIGUINT64_ELEMENTS);
@ -525,9 +518,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeGetBigInt64(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const isLittleEndian: JSAny = arguments[1];
return DataViewGet(
context, receiver, offset, isLittleEndian,
ElementsKind::BIGINT64_ELEMENTS);
@ -767,8 +759,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetUint8(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
return DataViewSet(
context, receiver, offset, value, Undefined,
ElementsKind::UINT8_ELEMENTS);
@ -777,8 +769,8 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetInt8(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
return DataViewSet(
context, receiver, offset, value, Undefined,
ElementsKind::INT8_ELEMENTS);
@ -787,10 +779,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetUint16(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::UINT16_ELEMENTS);
@ -799,10 +790,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetInt16(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::INT16_ELEMENTS);
@ -811,10 +801,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetUint32(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::UINT32_ELEMENTS);
@ -823,10 +812,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetInt32(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::INT32_ELEMENTS);
@ -835,10 +823,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetFloat32(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::FLOAT32_ELEMENTS);
@ -847,10 +834,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetFloat64(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::FLOAT64_ELEMENTS);
@ -859,10 +845,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetBigUint64(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::BIGUINT64_ELEMENTS);
@ -871,10 +856,9 @@ namespace data_view {
transitioning javascript builtin DataViewPrototypeSetBigInt64(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
const offset: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const value: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: JSAny =
arguments.length > 2 ? arguments[2] : Undefined;
const offset: JSAny = arguments[0];
const value: JSAny = arguments[1];
const isLittleEndian: JSAny = arguments[2];
return DataViewSet(
context, receiver, offset, value, isLittleEndian,
ElementsKind::BIGINT64_ELEMENTS);

View File

@ -61,14 +61,14 @@ namespace reflect {
// ES6 section 26.1.6 Reflect.get
transitioning javascript builtin
ReflectGet(js-implicit context: NativeContext)(...arguments): JSAny {
const length = arguments.length;
const object: JSAny = length > 0 ? arguments[0] : Undefined;
const object: JSAny = arguments[0];
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(
MessageTemplate::kCalledOnNonObject, 'Reflect.get');
const propertyKey: JSAny = length > 1 ? arguments[1] : Undefined;
const propertyKey: JSAny = arguments[1];
const name: AnyName = ToName(propertyKey);
const receiver: JSAny = length > 2 ? arguments[2] : objectJSReceiver;
const receiver: JSAny =
arguments.length > 2 ? arguments[2] : objectJSReceiver;
return GetPropertyWithReceiver(
objectJSReceiver, name, receiver, SmiConstant(kReturnUndefined));
}

View File

@ -91,7 +91,7 @@ namespace typed_array {
receiver: JSAny)(...arguments): JSTypedArray {
// 1. If comparefn is not undefined and IsCallable(comparefn) is false,
// throw a TypeError exception.
const comparefnObj: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const comparefnObj: JSAny = arguments[0];
if (comparefnObj != Undefined && !Is<Callable>(comparefnObj)) {
ThrowTypeError(MessageTemplate::kBadSortComparisonFunction, comparefnObj);
}

View File

@ -30,12 +30,12 @@ namespace error {
// b. Let msgDesc be the PropertyDescriptor { [[Value]]: _msg_,
// [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true*
// c. Perform ! DefinePropertyOrThrow(_O_, *"message"*, _msgDesc_).
const message: JSAny = arguments.length > 0 ? arguments[1] : Undefined;
const message: JSAny = arguments[1];
const obj: JSAggregateError =
ConstructAggregateErrorHelper(context, target, newTarget, message);
// 4. Let errorsList be ? IterableToList(errors).
const errors: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
const errors: JSAny = arguments[0];
const errorsArray =
iterator::IterableToFixedArrayWithSymbolLookupSlow(errors);
MakeFixedArrayCOW(errorsArray);