archives

« Bugzilla Issues Index

#1934 — 22.2.3.*, 23.*, 24.*: Replace ToObject calls with type checks in non-generic functions


The following functions should perform a type check instead of calling ToObject(). The ToObject coercion is somewhat useless because the functions are all non-generic, i.e. they require certain internal data properties to be present on the input value. And wrapped primitives don't provide these internal data properties. Removing the ToObject calls also saves at least on additional step in the algorithms. For example:

1. Let obj be the result of ToObject(arg).
2. ReturnIfAbrupt(obj).

Can be reduced to:

1. If Type(arg) is not Object, then throw a TypeError exception.


22.2.3.1 get %TypedArray%.prototype.buffer
22.2.3.2 get %TypedArray%.prototype.byteLength
22.2.3.3 get %TypedArray%.prototype.byteOffset
22.2.3.17 get %TypedArray%.prototype.length
22.2.3.22 %TypedArray%.prototype.set(array, offset = 0)
22.2.3.23 %TypedArray%.prototype.set(typedArray, offset = 0)
22.2.3.27 %TypedArray%.prototype.subarray(begin = 0, end = this.length)
22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]

23.1.5.1 CreateMapIterator Abstract Operation
23.2.5.1 CreateSetIterator Abstract Operation

24.1.4.1 get ArrayBuffer.prototype.byteLength
24.1.4.3 ArrayBuffer.prototype.slice ( start , end)

24.2.1.1 GetViewValue(view, requestIndex, isLittleEndian, type)
24.2.1.2 SetViewValue(view, requestIndex, isLittleEndian, type, value)
24.2.4.1 get DataView.prototype.buffer
24.2.4.2 get DataView.prototype.byteLength
24.2.4.3 get DataView.prototype.byteOffset


And the "If Type(arg) is not Object, ..." form is already used in the specification for other non-generic functions.


fixed in rev19 editor's draft


fixed in rev19