| Index: src/js/typedarray.js
|
| diff --git a/src/js/typedarray.js b/src/js/typedarray.js
|
| index 15bc7296624036a65d3d6d185a325a491dbb1f5b..204e0918b24a45550be3440ac389cd2178751838 100644
|
| --- a/src/js/typedarray.js
|
| +++ b/src/js/typedarray.js
|
| @@ -38,8 +38,6 @@ var InnerArraySort;
|
| var InnerArrayToLocaleString;
|
| var InternalArray = utils.InternalArray;
|
| var IsNaN;
|
| -var MakeRangeError;
|
| -var MakeTypeError;
|
| var MaxSimple;
|
| var MinSimple;
|
| var PackedArrayReverse;
|
| @@ -90,8 +88,6 @@ utils.Import(function(from) {
|
| InnerArraySort = from.InnerArraySort;
|
| InnerArrayToLocaleString = from.InnerArrayToLocaleString;
|
| IsNaN = from.IsNaN;
|
| - MakeRangeError = from.MakeRangeError;
|
| - MakeTypeError = from.MakeTypeError;
|
| MaxSimple = from.MaxSimple;
|
| MinSimple = from.MinSimple;
|
| PackedArrayReverse = from.PackedArrayReverse;
|
| @@ -111,7 +107,7 @@ TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR_CASE)
|
| }
|
| // The TypeError should not be generated since all callers should
|
| // have already called ValidateTypedArray.
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| + throw %make_type_error(kIncompatibleMethodReceiver,
|
| "TypedArrayDefaultConstructor", this);
|
| }
|
|
|
| @@ -121,12 +117,12 @@ function TypedArrayCreate(constructor, arg0, arg1, arg2) {
|
| } else {
|
| var newTypedArray = new constructor(arg0, arg1, arg2);
|
| }
|
| - if (!IS_TYPEDARRAY(newTypedArray)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(newTypedArray)) throw %make_type_error(kNotTypedArray);
|
| // TODO(littledan): Check for being detached, here and elsewhere
|
| // All callers where the first argument is a Number have no additional
|
| // arguments.
|
| if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) {
|
| - throw MakeTypeError(kTypedArrayTooShort);
|
| + throw %make_type_error(kTypedArrayTooShort);
|
| }
|
| return newTypedArray;
|
| }
|
| @@ -155,11 +151,11 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
|
| offset = byteOffset;
|
|
|
| if (offset % ELEMENT_SIZE !== 0) {
|
| - throw MakeRangeError(kInvalidTypedArrayAlignment,
|
| + throw %make_range_error(kInvalidTypedArrayAlignment,
|
| "start offset", "NAME", ELEMENT_SIZE);
|
| }
|
| if (offset > bufferByteLength) {
|
| - throw MakeRangeError(kInvalidTypedArrayOffset);
|
| + throw %make_range_error(kInvalidTypedArrayOffset);
|
| }
|
| }
|
|
|
| @@ -167,7 +163,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
|
| var newLength;
|
| if (IS_UNDEFINED(length)) {
|
| if (bufferByteLength % ELEMENT_SIZE !== 0) {
|
| - throw MakeRangeError(kInvalidTypedArrayAlignment,
|
| + throw %make_range_error(kInvalidTypedArrayAlignment,
|
| "byte length", "NAME", ELEMENT_SIZE);
|
| }
|
| newByteLength = bufferByteLength - offset;
|
| @@ -178,7 +174,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
|
| }
|
| if ((offset + newByteLength > bufferByteLength)
|
| || (newLength > %_MaxSmi())) {
|
| - throw MakeRangeError(kInvalidTypedArrayLength);
|
| + throw %make_range_error(kInvalidTypedArrayLength);
|
| }
|
| %_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength, true);
|
| }
|
| @@ -187,7 +183,7 @@ function NAMEConstructByLength(obj, length) {
|
| var l = IS_UNDEFINED(length) ?
|
| 0 : ToPositiveInteger(length, kInvalidTypedArrayLength);
|
| if (l > %_MaxSmi()) {
|
| - throw MakeRangeError(kInvalidTypedArrayLength);
|
| + throw %make_range_error(kInvalidTypedArrayLength);
|
| }
|
| var byteLength = l * ELEMENT_SIZE;
|
| if (byteLength > %_TypedArrayMaxSizeInHeap()) {
|
| @@ -202,7 +198,7 @@ function NAMEConstructByArrayLike(obj, arrayLike, length) {
|
| var l = ToPositiveInteger(length, kInvalidTypedArrayLength);
|
|
|
| if (l > %_MaxSmi()) {
|
| - throw MakeRangeError(kInvalidTypedArrayLength);
|
| + throw %make_range_error(kInvalidTypedArrayLength);
|
| }
|
| var initialized = false;
|
| var byteLength = l * ELEMENT_SIZE;
|
| @@ -275,7 +271,7 @@ function NAMEConstructor(arg1, arg2, arg3) {
|
| }
|
| }
|
| } else {
|
| - throw MakeTypeError(kConstructorNotFunction, "NAME")
|
| + throw %make_type_error(kConstructorNotFunction, "NAME")
|
| }
|
| }
|
|
|
| @@ -325,7 +321,7 @@ macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE)
|
| endmacro
|
| TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE)
|
| }
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| + throw %make_type_error(kIncompatibleMethodReceiver,
|
| "get TypedArray.prototype.subarray", this);
|
| }
|
| %SetForceInlineFlag(TypedArraySubArray);
|
| @@ -399,10 +395,10 @@ function TypedArraySetFromOverlappingTypedArray(target, source, offset) {
|
|
|
| function TypedArraySet(obj, offset) {
|
| var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset);
|
| - if (intOffset < 0) throw MakeTypeError(kTypedArraySetNegativeOffset);
|
| + if (intOffset < 0) throw %make_type_error(kTypedArraySetNegativeOffset);
|
|
|
| if (intOffset > %_MaxSmi()) {
|
| - throw MakeRangeError(kTypedArraySetSourceTooLarge);
|
| + throw %make_range_error(kTypedArraySetSourceTooLarge);
|
| }
|
| switch (%TypedArraySetFastCases(this, obj, intOffset)) {
|
| // These numbers should be synchronized with runtime.cc.
|
| @@ -423,13 +419,13 @@ function TypedArraySet(obj, offset) {
|
| // instead of silently ignoring the call, so that
|
| // the user knows (s)he did something wrong.
|
| // (Consistent with Firefox and Blink/WebKit)
|
| - throw MakeTypeError(kInvalidArgument);
|
| + throw %make_type_error(kInvalidArgument);
|
| }
|
| return;
|
| }
|
| l = TO_LENGTH(l);
|
| if (intOffset + l > %_TypedArrayGetLength(this)) {
|
| - throw MakeRangeError(kTypedArraySetSourceTooLarge);
|
| + throw %make_range_error(kTypedArraySetSourceTooLarge);
|
| }
|
| TypedArraySetFromArrayLike(this, obj, l, intOffset);
|
| return;
|
| @@ -446,7 +442,7 @@ function TypedArrayGetToStringTag() {
|
|
|
|
|
| function TypedArrayCopyWithin(target, start, end) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -458,7 +454,7 @@ function TypedArrayCopyWithin(target, start, end) {
|
|
|
| // ES6 draft 05-05-15, section 22.2.3.7
|
| function TypedArrayEvery(f, receiver) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -469,7 +465,7 @@ function TypedArrayEvery(f, receiver) {
|
|
|
| // ES6 draft 08-24-14, section 22.2.3.12
|
| function TypedArrayForEach(f, receiver) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -480,7 +476,7 @@ function TypedArrayForEach(f, receiver) {
|
|
|
| // ES6 draft 04-05-14 section 22.2.3.8
|
| function TypedArrayFill(value, start, end) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -491,10 +487,10 @@ function TypedArrayFill(value, start, end) {
|
|
|
| // ES6 draft 07-15-13, section 22.2.3.9
|
| function TypedArrayFilter(f, thisArg) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
| - if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
|
| + if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
|
| var result = new InternalArray();
|
| InnerArrayFilter(f, thisArg, this, length, result);
|
| var captured = result.length;
|
| @@ -509,7 +505,7 @@ function TypedArrayFilter(f, thisArg) {
|
|
|
| // ES6 draft 07-15-13, section 22.2.3.10
|
| function TypedArrayFind(predicate, thisArg) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -520,7 +516,7 @@ function TypedArrayFind(predicate, thisArg) {
|
|
|
| // ES6 draft 07-15-13, section 22.2.3.11
|
| function TypedArrayFindIndex(predicate, thisArg) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -531,7 +527,7 @@ function TypedArrayFindIndex(predicate, thisArg) {
|
|
|
| // ES6 draft 05-18-15, section 22.2.3.21
|
| function TypedArrayReverse() {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -559,7 +555,7 @@ function TypedArrayComparefn(x, y) {
|
|
|
| // ES6 draft 05-18-15, section 22.2.3.25
|
| function TypedArraySort(comparefn) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -573,7 +569,7 @@ function TypedArraySort(comparefn) {
|
|
|
| // ES6 section 22.2.3.13
|
| function TypedArrayIndexOf(element, index) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
| return InnerArrayIndexOf(this, element, index, length);
|
| @@ -583,7 +579,7 @@ function TypedArrayIndexOf(element, index) {
|
|
|
| // ES6 section 22.2.3.16
|
| function TypedArrayLastIndexOf(element, index) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -595,11 +591,11 @@ function TypedArrayLastIndexOf(element, index) {
|
|
|
| // ES6 draft 07-15-13, section 22.2.3.18
|
| function TypedArrayMap(f, thisArg) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
| var result = TypedArraySpeciesCreate(this, length);
|
| - if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
|
| + if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
|
| for (var i = 0; i < length; i++) {
|
| var element = this[i];
|
| result[i] = %_Call(f, thisArg, element, i, this);
|
| @@ -611,7 +607,7 @@ function TypedArrayMap(f, thisArg) {
|
|
|
| // ES6 draft 05-05-15, section 22.2.3.24
|
| function TypedArraySome(f, receiver) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -622,7 +618,7 @@ function TypedArraySome(f, receiver) {
|
|
|
| // ES6 section 22.2.3.27
|
| function TypedArrayToLocaleString() {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -632,7 +628,7 @@ function TypedArrayToLocaleString() {
|
|
|
| // ES6 section 22.2.3.14
|
| function TypedArrayJoin(separator) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -642,7 +638,7 @@ function TypedArrayJoin(separator) {
|
|
|
| // ES6 draft 07-15-13, section 22.2.3.19
|
| function TypedArrayReduce(callback, current) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
| return InnerArrayReduce(callback, current, this, length,
|
| @@ -653,7 +649,7 @@ function TypedArrayReduce(callback, current) {
|
|
|
| // ES6 draft 07-15-13, section 22.2.3.19
|
| function TypedArrayReduceRight(callback, current) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
| return InnerArrayReduceRight(callback, current, this, length,
|
| @@ -663,7 +659,7 @@ function TypedArrayReduceRight(callback, current) {
|
|
|
|
|
| function TypedArraySlice(start, end) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
| var len = %_TypedArrayGetLength(this);
|
|
|
| var relativeStart = TO_INTEGER(start);
|
| @@ -707,7 +703,7 @@ function TypedArraySlice(start, end) {
|
|
|
| // ES2016 draft, section 22.2.3.14
|
| function TypedArrayIncludes(searchElement, fromIndex) {
|
| - if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
|
| + if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
|
|
|
| var length = %_TypedArrayGetLength(this);
|
|
|
| @@ -771,10 +767,10 @@ function IterableToArrayLike(items) {
|
| // ES#sec-%typedarray%.from
|
| // %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
|
| function TypedArrayFrom(source, mapfn, thisArg) {
|
| - if (!%IsConstructor(this)) throw MakeTypeError(kNotConstructor, this);
|
| + if (!%IsConstructor(this)) throw %make_type_error(kNotConstructor, this);
|
| var mapping;
|
| if (!IS_UNDEFINED(mapfn)) {
|
| - if (!IS_CALLABLE(mapfn)) throw MakeTypeError(kCalledNonCallable, this);
|
| + if (!IS_CALLABLE(mapfn)) throw %make_type_error(kCalledNonCallable, this);
|
| mapping = true;
|
| } else {
|
| mapping = false;
|
| @@ -799,10 +795,10 @@ function TypedArrayFrom(source, mapfn, thisArg) {
|
| // TODO(bmeurer): Migrate this to a proper builtin.
|
| function TypedArrayConstructor() {
|
| if (IS_UNDEFINED(new.target)) {
|
| - throw MakeTypeError(kConstructorNonCallable, "TypedArray");
|
| + throw %make_type_error(kConstructorNonCallable, "TypedArray");
|
| }
|
| if (new.target === GlobalTypedArray) {
|
| - throw MakeTypeError(kConstructAbstractClass, "TypedArray");
|
| + throw %make_type_error(kConstructAbstractClass, "TypedArray");
|
| }
|
| }
|
|
|
| @@ -883,10 +879,10 @@ endmacro
|
| macro DATA_VIEW_GETTER_SETTER(TYPENAME)
|
| function DataViewGetTYPENAMEJS(offset, little_endian) {
|
| if (!IS_DATAVIEW(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| + throw %make_type_error(kIncompatibleMethodReceiver,
|
| 'DataView.getTYPENAME', this);
|
| }
|
| - if (arguments.length < 1) throw MakeTypeError(kInvalidArgument);
|
| + if (arguments.length < 1) throw %make_type_error(kInvalidArgument);
|
| offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
|
| return %DataViewGetTYPENAME(this, offset, !!little_endian);
|
| }
|
| @@ -894,10 +890,10 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
|
|
|
| function DataViewSetTYPENAMEJS(offset, value, little_endian) {
|
| if (!IS_DATAVIEW(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| + throw %make_type_error(kIncompatibleMethodReceiver,
|
| 'DataView.setTYPENAME', this);
|
| }
|
| - if (arguments.length < 2) throw MakeTypeError(kInvalidArgument);
|
| + if (arguments.length < 2) throw %make_type_error(kInvalidArgument);
|
| offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
|
| %DataViewSetTYPENAME(this, offset, TO_NUMBER(value), !!little_endian);
|
| }
|
|
|