| Index: src/js/typedarray.js
|
| diff --git a/src/js/typedarray.js b/src/js/typedarray.js
|
| index 6c858236a826c9a626819af7cd63a347136a776a..50aae94bdcca99cbc567901d775e767bbac5f7b4 100644
|
| --- a/src/js/typedarray.js
|
| +++ b/src/js/typedarray.js
|
| @@ -68,6 +68,8 @@ endmacro
|
|
|
| TYPED_ARRAYS(DECLARE_GLOBALS)
|
|
|
| +var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array);
|
| +
|
| utils.Import(function(from) {
|
| ArrayValues = from.ArrayValues;
|
| GetIterator = from.GetIterator;
|
| @@ -329,42 +331,6 @@ TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE)
|
| }
|
| %SetForceInlineFlag(TypedArraySubArray);
|
|
|
| -function TypedArrayGetBuffer() {
|
| - if (!IS_TYPEDARRAY(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| - "get TypedArray.prototype.buffer", this);
|
| - }
|
| - return %TypedArrayGetBuffer(this);
|
| -}
|
| -%SetForceInlineFlag(TypedArrayGetBuffer);
|
| -
|
| -function TypedArrayGetByteLength() {
|
| - if (!IS_TYPEDARRAY(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| - "get TypedArray.prototype.byteLength", this);
|
| - }
|
| - return %_ArrayBufferViewGetByteLength(this);
|
| -}
|
| -%SetForceInlineFlag(TypedArrayGetByteLength);
|
| -
|
| -function TypedArrayGetByteOffset() {
|
| - if (!IS_TYPEDARRAY(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| - "get TypedArray.prototype.byteOffset", this);
|
| - }
|
| - return %_ArrayBufferViewGetByteOffset(this);
|
| -}
|
| -%SetForceInlineFlag(TypedArrayGetByteOffset);
|
| -
|
| -function TypedArrayGetLength() {
|
| - if (!IS_TYPEDARRAY(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| - "get TypedArray.prototype.length", this);
|
| - }
|
| - return %_TypedArrayGetLength(this);
|
| -}
|
| -%SetForceInlineFlag(TypedArrayGetLength);
|
| -
|
|
|
|
|
| function TypedArraySetFromArrayLike(target, source, sourceLength, offset) {
|
| @@ -808,33 +774,26 @@ function TypedArrayFrom(source, mapfn, thisArg) {
|
| }
|
| %FunctionSetLength(TypedArrayFrom, 1);
|
|
|
| -function TypedArray() {
|
| +// TODO(bmeurer): Migrate this to a proper builtin.
|
| +function TypedArrayConstructor() {
|
| if (IS_UNDEFINED(new.target)) {
|
| throw MakeTypeError(kConstructorNonCallable, "TypedArray");
|
| }
|
| - if (new.target === TypedArray) {
|
| + if (new.target === GlobalTypedArray) {
|
| throw MakeTypeError(kConstructAbstractClass, "TypedArray");
|
| }
|
| }
|
|
|
| // -------------------------------------------------------------------
|
|
|
| -%FunctionSetPrototype(TypedArray, new GlobalObject());
|
| -%AddNamedProperty(TypedArray.prototype,
|
| - "constructor", TypedArray, DONT_ENUM);
|
| -utils.InstallFunctions(TypedArray, DONT_ENUM, [
|
| +%SetCode(GlobalTypedArray, TypedArrayConstructor);
|
| +utils.InstallFunctions(GlobalTypedArray, DONT_ENUM, [
|
| "from", TypedArrayFrom,
|
| "of", TypedArrayOf
|
| ]);
|
| -utils.InstallGetter(TypedArray.prototype, "buffer", TypedArrayGetBuffer);
|
| -utils.InstallGetter(TypedArray.prototype, "byteOffset",
|
| - TypedArrayGetByteOffset);
|
| -utils.InstallGetter(TypedArray.prototype, "byteLength",
|
| - TypedArrayGetByteLength);
|
| -utils.InstallGetter(TypedArray.prototype, "length", TypedArrayGetLength);
|
| -utils.InstallGetter(TypedArray.prototype, toStringTagSymbol,
|
| +utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol,
|
| TypedArrayGetToStringTag);
|
| -utils.InstallFunctions(TypedArray.prototype, DONT_ENUM, [
|
| +utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [
|
| "subarray", TypedArraySubArray,
|
| "set", TypedArraySet,
|
| "copyWithin", TypedArrayCopyWithin,
|
| @@ -858,15 +817,15 @@ utils.InstallFunctions(TypedArray.prototype, DONT_ENUM, [
|
| "toLocaleString", TypedArrayToLocaleString
|
| ]);
|
|
|
| -%AddNamedProperty(TypedArray.prototype, "toString", ArrayToString,
|
| +%AddNamedProperty(GlobalTypedArray.prototype, "toString", ArrayToString,
|
| DONT_ENUM);
|
|
|
|
|
| macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
|
| %SetCode(GlobalNAME, NAMEConstructor);
|
| %FunctionSetPrototype(GlobalNAME, new GlobalObject());
|
| - %InternalSetPrototype(GlobalNAME, TypedArray);
|
| - %InternalSetPrototype(GlobalNAME.prototype, TypedArray.prototype);
|
| + %InternalSetPrototype(GlobalNAME, GlobalTypedArray);
|
| + %InternalSetPrototype(GlobalNAME.prototype, GlobalTypedArray.prototype);
|
|
|
| %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
|
| READ_ONLY | DONT_ENUM | DONT_DELETE);
|
| @@ -882,29 +841,6 @@ TYPED_ARRAYS(SETUP_TYPED_ARRAY)
|
|
|
| // --------------------------- DataView -----------------------------
|
|
|
| -function DataViewGetBufferJS() {
|
| - if (!IS_DATAVIEW(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this);
|
| - }
|
| - return %DataViewGetBuffer(this);
|
| -}
|
| -
|
| -function DataViewGetByteOffset() {
|
| - if (!IS_DATAVIEW(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| - 'DataView.byteOffset', this);
|
| - }
|
| - return %_ArrayBufferViewGetByteOffset(this);
|
| -}
|
| -
|
| -function DataViewGetByteLength() {
|
| - if (!IS_DATAVIEW(this)) {
|
| - throw MakeTypeError(kIncompatibleMethodReceiver,
|
| - 'DataView.byteLength', this);
|
| - }
|
| - return %_ArrayBufferViewGetByteLength(this);
|
| -}
|
| -
|
| macro DATA_VIEW_TYPES(FUNCTION)
|
| FUNCTION(Int8)
|
| FUNCTION(Uint8)
|
| @@ -943,21 +879,6 @@ endmacro
|
|
|
| DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
|
|
|
| -// Setup the DataView constructor.
|
| -%FunctionSetPrototype(GlobalDataView, new GlobalObject);
|
| -
|
| -// Set up constructor property on the DataView prototype.
|
| -%AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView,
|
| - DONT_ENUM);
|
| -%AddNamedProperty(GlobalDataView.prototype, toStringTagSymbol, "DataView",
|
| - READ_ONLY|DONT_ENUM);
|
| -
|
| -utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
|
| -utils.InstallGetter(GlobalDataView.prototype, "byteOffset",
|
| - DataViewGetByteOffset);
|
| -utils.InstallGetter(GlobalDataView.prototype, "byteLength",
|
| - DataViewGetByteLength);
|
| -
|
| utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [
|
| "getInt8", DataViewGetInt8JS,
|
| "setInt8", DataViewSetInt8JS,
|
|
|