New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer index vs. array index in [[OwnPropertyKeys]]() on TypedArrays #1244

Open
mathiasbynens opened this Issue Jun 22, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@mathiasbynens
Member

mathiasbynens commented Jun 22, 2018

Per spec, a TypedArray length is limited to 2**53-1, i.e. the greatest possible integer index, because of step 3 in https://tc39.github.io/ecma262/#sec-typedarray-length.

However, in practice all engines except JavaScriptCore don’t even support creating a TypedArray with a length equal to the greatest possible array index + 1, i.e. 2**32-1. Note that I couldn’t test the actual JavaScriptCore behavior as my machine (128 GB RAM) ran out of memory.

$ eshost -e 'new Uint8Array(2**32-1)'
#### Chakra
RangeError: Invalid offset/length when creating typed array

#### V8 --harmony
RangeError: Invalid typed array length: 4294967295

#### V8
RangeError: Invalid typed array length: 4294967295

#### JavaScriptCore
Error: Out of memory

#### SpiderMonkey
RangeError: invalid array length

This means that the use of “integer index” over “array index” in https://tc39.github.io/ecma262/#sec-integer-indexed-exotic-objects-ownpropertykeys is not currently supported by engines, either.

We could reduce the unimplemented parts of the spec to a smaller subset that is consistent with existing OwnPropertyKeys implementations for other kinds of objects.

See #1242 and #1243.

@ChALkeR

This comment has been minimized.

Show comment
Hide comment
@ChALkeR

ChALkeR Jun 22, 2018

Some earlier part of the conversation at IRC: Gist (as IRC logs seem broken).
Also, tc39/test262#1580 is related.

ChALkeR commented Jun 22, 2018

Some earlier part of the conversation at IRC: Gist (as IRC logs seem broken).
Also, tc39/test262#1580 is related.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Jun 24, 2018

Member

I think the use of a larger maximum here was a deliberate, forward-looking design decision. Given that JSC seems to support larger sizes already, what is the motivation for considering a change?

Member

littledan commented Jun 24, 2018

I think the use of a larger maximum here was a deliberate, forward-looking design decision. Given that JSC seems to support larger sizes already, what is the motivation for considering a change?

@mathiasbynens

This comment has been minimized.

Show comment
Hide comment
@mathiasbynens

mathiasbynens Jun 25, 2018

Member

Given that JSC seems to support larger sizes already

I’m not sure about that. As stated, new Uint8Array(2**32-1) ran out of memory on a machine with 128 GB RAM.

what is the motivation for considering a change

The fact that engines currently don’t implement this. Having the spec contradict reality is not useful.

Member

mathiasbynens commented Jun 25, 2018

Given that JSC seems to support larger sizes already

I’m not sure about that. As stated, new Uint8Array(2**32-1) ran out of memory on a machine with 128 GB RAM.

what is the motivation for considering a change

The fact that engines currently don’t implement this. Having the spec contradict reality is not useful.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Jun 25, 2018

Member

BTW ES6 made the whole ToLength change to support large TypedArrays. It was a rather large change that ran into some web compat fixes that were needed.

Member

littledan commented Jun 25, 2018

BTW ES6 made the whole ToLength change to support large TypedArrays. It was a rather large change that ran into some web compat fixes that were needed.

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Jun 29, 2018

Contributor

Just because engines currently seem to restrict ArrayBuffer allocation to 2GB doesn't mean that we should put that as the maximum into the spec.

Contributor

anba commented Jun 29, 2018

Just because engines currently seem to restrict ArrayBuffer allocation to 2GB doesn't mean that we should put that as the maximum into the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment