Commit 5c05165d authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[Torque] Make Throw*Error() take context implicitly

Change-Id: I5f0d915351c24b9a2916b8ab1d4bafb4d7eb21c7
Reviewed-on: https://chromium-review.googlesource.com/c/1491217Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59889}
parent 4422cc44
......@@ -142,11 +142,10 @@ namespace array {
}
}
label TypeError deferred {
ThrowTypeError(context, kCalledNonCallable, arguments[0]);
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NullOrUndefinedError deferred {
ThrowTypeError(
context, kCalledOnNullOrUndefined, 'Array.prototype.every');
ThrowTypeError(kCalledOnNullOrUndefined, 'Array.prototype.every');
}
}
}
......@@ -222,11 +222,10 @@ namespace array_filter {
o, callbackfn, thisArg, array, o, k, len, to);
}
label TypeError deferred {
ThrowTypeError(context, kCalledNonCallable, arguments[0]);
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NullOrUndefinedError deferred {
ThrowTypeError(
context, kCalledOnNullOrUndefined, 'Array.prototype.filter');
ThrowTypeError(kCalledOnNullOrUndefined, 'Array.prototype.filter');
}
}
}
......@@ -141,11 +141,10 @@ namespace array_foreach {
o, callbackfn, thisArg, Undefined, o, k, len, Undefined);
}
label TypeError deferred {
ThrowTypeError(context, kCalledNonCallable, arguments[0]);
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NullOrUndefinedError deferred {
ThrowTypeError(
context, kCalledOnNullOrUndefined, 'Array.prototype.forEach');
ThrowTypeError(kCalledOnNullOrUndefined, 'Array.prototype.forEach');
}
}
}
......@@ -78,7 +78,7 @@ namespace array_join {
return ToString_Inline(context, result);
}
label TypeError {
ThrowTypeError(context, kCalledNonCallable, prop);
ThrowTypeError(kCalledNonCallable, prop);
}
}
......@@ -565,7 +565,7 @@ namespace array_join {
// Only handle valid array lengths. Although the spec allows larger values,
// this matches historical V8 behavior.
if (len > kMaxArrayIndex + 1) ThrowTypeError(context, kInvalidArrayLength);
if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength);
return CycleProtectedArrayJoin<JSArray>(
false, o, len, separator, Undefined, Undefined);
......@@ -585,7 +585,7 @@ namespace array_join {
// Only handle valid array lengths. Although the spec allows larger values,
// this matches historical V8 behavior.
if (len > kMaxArrayIndex + 1) ThrowTypeError(context, kInvalidArrayLength);
if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength);
return CycleProtectedArrayJoin<JSArray>(
true, o, len, ',', locales, options);
......
......@@ -303,10 +303,10 @@ namespace array_map {
o, callbackfn, thisArg, array, o, k, len, Undefined);
}
label TypeError deferred {
ThrowTypeError(context, kCalledNonCallable, arguments[0]);
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NullOrUndefinedError deferred {
ThrowTypeError(context, kCalledOnNullOrUndefined, 'Array.prototype.map');
ThrowTypeError(kCalledOnNullOrUndefined, 'Array.prototype.map');
}
}
}
......@@ -100,7 +100,7 @@ namespace array {
// If the accumulator is discovered with the sentinel hole value,
// this means kPresent is false.
if (accumulator == Hole) {
ThrowTypeError(context, kReduceNoInitial, 'Array.prototype.reduceRight');
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight');
}
return accumulator;
}
......@@ -127,7 +127,7 @@ namespace array {
}
}
if (accumulator == Hole) {
ThrowTypeError(context, kReduceNoInitial, 'Array.prototype.reduceRight');
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight');
}
return accumulator;
}
......@@ -186,11 +186,10 @@ namespace array {
}
}
label NoCallableError deferred {
ThrowTypeError(context, kCalledNonCallable, arguments[0]);
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NullOrUndefinedError deferred {
ThrowTypeError(
context, kCalledOnNullOrUndefined, 'Array.prototype.reduceRight');
ThrowTypeError(kCalledOnNullOrUndefined, 'Array.prototype.reduceRight');
}
}
}
......@@ -99,7 +99,7 @@ namespace array {
// If the accumulator is discovered with the sentinel hole value,
// this means kPresent is false.
if (accumulator == Hole) {
ThrowTypeError(context, kReduceNoInitial, 'Array.prototype.reduce');
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce');
}
return accumulator;
}
......@@ -126,7 +126,7 @@ namespace array {
}
}
if (accumulator == Hole) {
ThrowTypeError(context, kReduceNoInitial, 'Array.prototype.reduce');
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce');
}
return accumulator;
}
......@@ -185,11 +185,10 @@ namespace array {
}
}
label NoCallableError deferred {
ThrowTypeError(context, kCalledNonCallable, arguments[0]);
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NullOrUndefinedError deferred {
ThrowTypeError(
context, kCalledOnNullOrUndefined, 'Array.prototype.reduce');
ThrowTypeError(kCalledOnNullOrUndefined, 'Array.prototype.reduce');
}
}
}
......@@ -141,10 +141,10 @@ namespace array {
}
}
label TypeError deferred {
ThrowTypeError(context, kCalledNonCallable, arguments[0]);
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NullOrUndefinedError deferred {
ThrowTypeError(context, kCalledOnNullOrUndefined, 'Array.prototype.some');
ThrowTypeError(kCalledOnNullOrUndefined, 'Array.prototype.some');
}
}
}
......@@ -398,7 +398,7 @@ namespace array_splice {
// Bailout exception.
const newLength: Number = len + insertCount - actualDeleteCount;
if (newLength > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength, start);
ThrowTypeError(kInvalidArrayLength, start);
}
try {
......
......@@ -36,7 +36,7 @@ namespace array_unshift {
if (argCount > 0) {
// a. If len + argCount > 2**53 - 1, throw a TypeError exception.
if (length + argCount > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength);
ThrowTypeError(kInvalidArrayLength);
}
// b. Let k be len.
......
......@@ -488,14 +488,18 @@ extern transitioning builtin HasProperty(implicit context: Context)(
extern transitioning macro HasProperty_Inline(implicit context: Context)(
JSReceiver, Object): Boolean;
extern macro ThrowRangeError(Context, constexpr MessageTemplate): never;
extern macro ThrowRangeError(Context, constexpr MessageTemplate, Object): never;
extern macro ThrowTypeError(Context, constexpr MessageTemplate): never;
extern macro ThrowTypeError(
Context, constexpr MessageTemplate, constexpr string): never;
extern macro ThrowTypeError(Context, constexpr MessageTemplate, Object): never;
extern macro ThrowTypeError(
Context, constexpr MessageTemplate, Object, Object, Object): never;
extern macro ThrowRangeError(implicit context: Context)(
constexpr MessageTemplate): never;
extern macro ThrowRangeError(implicit context: Context)(
constexpr MessageTemplate, Object): never;
extern macro ThrowTypeError(implicit context: Context)(
constexpr MessageTemplate): never;
extern macro ThrowTypeError(implicit context: Context)(
constexpr MessageTemplate, constexpr string): never;
extern macro ThrowTypeError(implicit context: Context)(
constexpr MessageTemplate, Object): never;
extern macro ThrowTypeError(implicit context: Context)(
constexpr MessageTemplate, Object, Object, Object): never;
extern macro ArraySpeciesCreate(Context, Object, Number): JSReceiver;
extern macro ArrayCreate(implicit context: Context)(Number): JSArray;
extern macro BuildAppendJSArray(
......
......@@ -37,7 +37,7 @@ namespace collections {
goto MayHaveSideEffects;
}
case (o: Object): deferred {
ThrowTypeError(context, kIteratorValueNotAnObject, o);
ThrowTypeError(kIteratorValueNotAnObject, o);
}
}
}
......
......@@ -68,7 +68,7 @@ namespace data_view {
return Cast<JSDataView>(o) otherwise CastError;
}
label CastError {
ThrowTypeError(context, kIncompatibleMethodReceiver, method);
ThrowTypeError(kIncompatibleMethodReceiver, method);
}
}
......@@ -393,15 +393,14 @@ namespace data_view {
getIndex = ToIndex(offset, context) otherwise RangeError;
}
label RangeError {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
ThrowRangeError(kInvalidDataViewAccessorOffset);
}
let littleEndian: bool = ToBoolean(requestedLittleEndian);
let buffer: JSArrayBuffer = dataView.buffer;
if (IsDetachedBuffer(buffer)) {
ThrowTypeError(
context, kDetachedOperation, MakeDataViewGetterNameString(kind));
ThrowTypeError(kDetachedOperation, MakeDataViewGetterNameString(kind));
}
let getIndexFloat: float64 = Convert<float64>(getIndex);
......@@ -412,7 +411,7 @@ namespace data_view {
let elementSizeFloat: float64 = DataViewElementSize(kind);
if (getIndexFloat + elementSizeFloat > viewSizeFloat) {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
ThrowRangeError(kInvalidDataViewAccessorOffset);
}
let bufferIndex: uintptr = getIndexWord + viewOffsetWord;
......@@ -671,7 +670,7 @@ namespace data_view {
getIndex = ToIndex(offset, context) otherwise RangeError;
}
label RangeError {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
ThrowRangeError(kInvalidDataViewAccessorOffset);
}
let littleEndian: bool = ToBoolean(requestedLittleEndian);
......@@ -683,8 +682,7 @@ namespace data_view {
let bigIntValue: BigInt = ToBigInt(context, value);
if (IsDetachedBuffer(buffer)) {
ThrowTypeError(
context, kDetachedOperation, MakeDataViewSetterNameString(kind));
ThrowTypeError(kDetachedOperation, MakeDataViewSetterNameString(kind));
}
let getIndexFloat: float64 = Convert<float64>(getIndex);
......@@ -695,7 +693,7 @@ namespace data_view {
let elementSizeFloat: float64 = DataViewElementSize(kind);
if (getIndexFloat + elementSizeFloat > viewSizeFloat) {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
ThrowRangeError(kInvalidDataViewAccessorOffset);
}
let bufferIndex: uintptr = getIndexWord + viewOffsetWord;
......@@ -704,8 +702,7 @@ namespace data_view {
let numValue: Number = ToNumber(context, value);
if (IsDetachedBuffer(buffer)) {
ThrowTypeError(
context, kDetachedOperation, MakeDataViewSetterNameString(kind));
ThrowTypeError(kDetachedOperation, MakeDataViewSetterNameString(kind));
}
let getIndexFloat: float64 = Convert<float64>(getIndex);
......@@ -716,7 +713,7 @@ namespace data_view {
let elementSizeFloat: float64 = DataViewElementSize(kind);
if (getIndexFloat + elementSizeFloat > viewSizeFloat) {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
ThrowRangeError(kInvalidDataViewAccessorOffset);
}
let bufferIndex: uintptr = getIndexWord + viewOffsetWord;
......
......@@ -63,7 +63,7 @@ namespace object {
}
}
label Throw deferred {
ThrowTypeError(context, kNotIterable);
ThrowTypeError(kNotIterable);
}
}
} // namespace object
......@@ -41,8 +41,7 @@ namespace string {
// 3. Let isRegExp be ? IsRegExp(searchString).
// 4. If isRegExp is true, throw a TypeError exception.
if (IsRegExp(searchString)) {
ThrowTypeError(
context, kFirstArgumentNotRegExp, 'String.prototype.endsWith');
ThrowTypeError(kFirstArgumentNotRegExp, 'String.prototype.endsWith');
}
// 5. Let searchStr be ? ToString(searchString).
......
......@@ -12,8 +12,7 @@ namespace string {
macro RequireObjectCoercible(implicit context: Context)(argument: Object):
Object {
if (IsNullOrUndefined(argument)) {
ThrowTypeError(
context, kCalledOnNullOrUndefined, 'String.prototype.startsWith');
ThrowTypeError(kCalledOnNullOrUndefined, 'String.prototype.startsWith');
}
return argument;
}
......@@ -33,8 +32,7 @@ namespace string {
// 3. Let isRegExp be ? IsRegExp(searchString).
// 4. If isRegExp is true, throw a TypeError exception.
if (IsRegExp(searchString)) {
ThrowTypeError(
context, kFirstArgumentNotRegExp, 'String.prototype.startsWith');
ThrowTypeError(kFirstArgumentNotRegExp, 'String.prototype.startsWith');
}
// 5. Let searchStr be ? ToString(searchString).
......
......@@ -34,8 +34,8 @@ namespace typed_array_createtypedarray {
initialize: constexpr bool, typedArray: JSTypedArray, length: PositiveSmi,
elementsInfo: typed_array::TypedArrayElementsInfo,
bufferConstructor: JSReceiver): uintptr {
const byteLength = elementsInfo.CalculateByteLength(
length) otherwise ThrowRangeError(context, kInvalidArrayBufferLength);
const byteLength = elementsInfo.CalculateByteLength(length)
otherwise ThrowRangeError(kInvalidArrayBufferLength);
const byteLengthNum = Convert<Number>(byteLength);
const defaultConstructor = GetArrayBufferFunction();
......@@ -93,7 +93,7 @@ namespace typed_array_createtypedarray {
// representation (which uses Smis).
// TODO(7881): support larger-than-smi typed array lengths
const positiveLength: PositiveSmi = Cast<PositiveSmi>(convertedLength)
otherwise ThrowRangeError(context, kInvalidTypedArrayLength, length);
otherwise ThrowRangeError(kInvalidTypedArrayLength, length);
const defaultConstructor: Constructor = GetArrayBufferFunction();
const initialize: constexpr bool = true;
TypedArrayInitialize(
......@@ -109,7 +109,7 @@ namespace typed_array_createtypedarray {
bufferConstructor: JSReceiver): void {
// The caller has looked up length on arrayLike, which is observable.
const length: PositiveSmi = ToSmiLength(initialLength)
otherwise ThrowRangeError(context, kInvalidTypedArrayLength, initialLength);
otherwise ThrowRangeError(kInvalidTypedArrayLength, initialLength);
const initialize: constexpr bool = false;
const byteLength = TypedArrayInitialize(
initialize, typedArray, length, elementsInfo, bufferConstructor);
......@@ -118,7 +118,7 @@ namespace typed_array_createtypedarray {
const src: JSTypedArray = Cast<JSTypedArray>(arrayLike) otherwise IfSlow;
if (IsDetachedBuffer(src.buffer)) {
ThrowTypeError(context, kDetachedOperation, 'Construct');
ThrowTypeError(kDetachedOperation, 'Construct');
} else if (src.elements_kind != elementsInfo.kind) {
goto IfSlow;
......@@ -197,7 +197,7 @@ namespace typed_array_createtypedarray {
// 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
if (IsDetachedBuffer(buffer)) {
ThrowTypeError(context, kDetachedOperation, 'Construct');
ThrowTypeError(kDetachedOperation, 'Construct');
}
// 10. Let bufferByteLength be buffer.[[ArrayBufferByteLength]].
......@@ -242,13 +242,13 @@ namespace typed_array_createtypedarray {
ThrowInvalidTypedArrayAlignment(typedArray.map, problemString);
}
label IfInvalidByteLength deferred {
ThrowRangeError(context, kInvalidArrayBufferLength);
ThrowRangeError(kInvalidArrayBufferLength);
}
label IfInvalidLength deferred {
ThrowRangeError(context, kInvalidTypedArrayLength, length);
ThrowRangeError(kInvalidTypedArrayLength, length);
}
label IfInvalidOffset deferred {
ThrowRangeError(context, kInvalidOffset, byteOffset);
ThrowRangeError(kInvalidOffset, byteOffset);
}
}
......@@ -260,7 +260,7 @@ namespace typed_array_createtypedarray {
const iteratorMethod: Object =
GetIteratorMethod(obj) otherwise IfIteratorUndefined;
const iteratorFn: Callable = Cast<Callable>(iteratorMethod)
otherwise ThrowTypeError(context, kIteratorSymbolNonCallable);
otherwise ThrowTypeError(kIteratorSymbolNonCallable);
ConstructByIterable(array, obj, iteratorFn, elementsInfo)
otherwise IfConstructByArrayLike;
}
......@@ -271,7 +271,7 @@ namespace typed_array_createtypedarray {
goto IfConstructByArrayLike(obj, length, GetArrayBufferFunction());
}
label IfInvalidLength(length: Object) {
ThrowRangeError(context, kInvalidTypedArrayLength, length);
ThrowRangeError(kInvalidTypedArrayLength, length);
}
}
......
......@@ -128,8 +128,7 @@ namespace typed_array {
// b. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
if (IsDetachedBuffer(array.buffer)) {
ThrowTypeError(
context, kDetachedOperation, '%TypedArray%.prototype.sort');
ThrowTypeError(kDetachedOperation, '%TypedArray%.prototype.sort');
}
// c. If v is NaN, return +0.
......@@ -199,7 +198,7 @@ namespace typed_array {
const comparefnObj: Object =
arguments.length > 0 ? arguments[0] : Undefined;
if (comparefnObj != Undefined && !TaggedIsCallable(comparefnObj)) {
ThrowTypeError(context, kBadSortComparisonFunction, comparefnObj);
ThrowTypeError(kBadSortComparisonFunction, comparefnObj);
}
// 2. Let obj be the this value.
......
......@@ -646,7 +646,7 @@ namespace test {
macro TestCatch1(implicit context: Context)(): Smi {
let r: Smi = 0;
try {
ThrowTypeError(context, kInvalidArrayLength);
ThrowTypeError(kInvalidArrayLength);
} catch (e) {
r = 1;
return r;
......@@ -654,7 +654,7 @@ namespace test {
}
macro TestCatch2Wrapper(implicit context: Context)(): never {
ThrowTypeError(context, kInvalidArrayLength);
ThrowTypeError(kInvalidArrayLength);
}
macro TestCatch2(implicit context: Context)(): Smi {
......@@ -669,7 +669,7 @@ namespace test {
macro TestCatch3WrapperWithLabel(implicit context: Context)(): never
labels Abort {
ThrowTypeError(context, kInvalidArrayLength);
ThrowTypeError(kInvalidArrayLength);
}
macro TestCatch3(implicit context: Context)(): Smi {
......
......@@ -301,7 +301,7 @@ namespace array {
// as SetProperty would.
const receiver = sortState.receiver;
ThrowTypeError(
context, kStrictReadOnlyProperty, index, Typeof(receiver), receiver);
kStrictReadOnlyProperty, index, Typeof(receiver), receiver);
}
label Fail {
return Failure(sortState);
......@@ -1401,7 +1401,7 @@ namespace array {
// throw a TypeError exception.
const comparefnObj: Object = arguments[0];
const comparefn = Cast<(Undefined | Callable)>(comparefnObj) otherwise
ThrowTypeError(context, kBadSortComparisonFunction, comparefnObj);
ThrowTypeError(kBadSortComparisonFunction, comparefnObj);
// 2. Let obj be ? ToObject(this value).
const obj: JSReceiver = ToObject(context, receiver);
......
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