-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Normative: Align detached buffer semantics with web reality #2164
Conversation
This change will also require updates to the TypedArray built-ins:
|
@anba %TypedArray%.prototype.slice does seem unique in this respect, but I'm also not sure a change is required? Step 15.b checks that O.[[ViewedArrayBuffer]] is detached before making a direct call to GetValueFromBuffer (and right after giving it a local name), but it seems that this is effectively an assertion, since we already verified this on step 2 (ValidateTypedArray step 4)? That said, we do double-down on this check (of IsDetachedBuffer after ValidateTypedArray and before Set) in %TypedArray%.prototype.fill step 10—is there some reason that this isn't redundant? |
|
Ah, thanks. I think I've (hopefully) covered your concerns now. |
Is there agreement to keep the explicit detached ArrayBuffer checks in
Correctly throws a TypeError in JSC and SM, but no error thrown in V8:
Same for
And for the explicit check in Correctly prints "0" and then throws TypeError in V8 and SM, but doesn't throw an error in JSC (, still stops after the first element):
Shouldn't throw a TypeError, but incorrectly throws one in V8:
There are probably still more differences in detached ArrayBuffer across engines. Do we attempt to find and fix them as part of this bug? For example in Expected: Prints "get length", "get one", and then throws a TypeError.
|
And more importantly [[GetOwnProperty]] needs to be changed to use |
|
My thinking is that we align with reality on what's here in this PR, and punt on the method incompats that @anba listed.
Edit: See below. I had misunderstood the invariants to be bidirectional on configurability. There's no issue making them configurable. We should make that change -- there is a compat risk but I'm willing to take it. Please point it out during plenary and ask if JSC and SM would be willing to make the change as well. |
Strictly speaking it is not an essential invariant that a |
Ah, good call on
|
8cad57f
to
7a4127f
Compare
As with |
Ah, of course, then there's no issue here. |
Agreed. The crucial thing here is fixing the spec where reality is consistent (and has been for a long time). Ending up with as much consistency as possible would be ideal, but it's less urgent since (1) behavior that engines don't agree upon is behavior that users can't rely upon and (2) removing errors is web-compatible. |
Integer indexed object will need to have their own [[Delete]] method. Something along the lines of:
And the configurable check in [[DefineOwnProperty]] needs to be flipped. |
8298b5c
to
d1523ce
Compare
@rkirsling My understanding of this PR currently is the following. Is this correct?
Unfortunately not all of these are web reality. Only I'd still prefer that we align on non-throwing behavior for [[Get]] and [[Set]], but would need input from Apple. Here's a test program and the output:
|
Note that this came up because I was going through JSC's test262 failures and looking for things to fix, so it should be understood that we have a slew of conformance bugs yet to fix in ArrayBuffer#slice and the EIMs for integer-indexed objects. (We can get explicit confirmation from an Appler if you're worried though. 😅) |
Good to hear! I'm not worried per se, but would nevertheless like explicit confirmation. Edit: I mean explicit confirmation during plenary itself, not necessary ahead of time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR lgtm editorially.
For
That doesn't match what @syg said above:
Though it does match V8 and SpiderMonkey's behavior reported above. Specifically, it's still throwing in the fourth case as a consequence of step 2, "Perform ? ValidateTypedArray(O).". Is that intentional? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM assuming the behavior described in my above comment is intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, though I would also be okay with delaying the ValidateTypedArray
call until after _count_
was determined so that we can conform to @shu's preference.
The change to |
d1523ce
to
00de41c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
editorial LGTM
00de41c
to
a4a142c
Compare
@rkirsling If you'd like to make that change (even though all implementations agree on throwing), please open a separate PR so we can get consensus on that. |
@bakkot Thanks for catching my misunderstanding re: #2164 (comment). I'm pretty sure I misread the PR at the time. The diff showed a bunch of steps moving under "If count > 0", which I must've misunderstood to mean it was moving the only detached throwing case to under that condition. For #2164 (comment), I didn't intend nor currently think we should be delaying |
Looking again, I think this ought to also have added a let x = new Uint8Array(20);
detach(x.buffer);
Object.getOwnPropertyNames(x) would produce (Aside: a simple |
…as configurable. r=tcampbell Implements the changes from <tc39/ecma262#2164> and <tc39/ecma262#2210> for [[GetOwnProperty]]. Part 3 will update [[DefineOwnProperty]] and part 5 updates [[Set]]. A side-effect of this change is that non-extensible, non-empty TypedArrays are no longer considered as sealed by `Object.isSealed()`. A later patch in this series will update test262 to enable more currently skipped TypedArray tests. Differential Revision: https://phabricator.services.mozilla.com/D99380
…as configurable. r=tcampbell Implements the changes from <tc39/ecma262#2164> and <tc39/ecma262#2210> for [[GetOwnProperty]]. Part 3 will update [[DefineOwnProperty]] and part 5 updates [[Set]]. A side-effect of this change is that non-extensible, non-empty TypedArrays are no longer considered as sealed by `Object.isSealed()`. A later patch in this series will update test262 to enable more currently skipped TypedArray tests. Differential Revision: https://phabricator.services.mozilla.com/D99380
…as configurable. r=tcampbell Implements the changes from <tc39/ecma262#2164> and <tc39/ecma262#2210> for [[GetOwnProperty]]. Part 3 will update [[DefineOwnProperty]] and part 5 updates [[Set]]. A side-effect of this change is that non-extensible, non-empty TypedArrays are no longer considered as sealed by `Object.isSealed()`. A later patch in this series will update test262 to enable more currently skipped TypedArray tests. Differential Revision: https://phabricator.services.mozilla.com/D99380 UltraBlame original commit: efd88e38955fc4722c6a882c175fdb48d6ff9e10
…as configurable. r=tcampbell Implements the changes from <tc39/ecma262#2164> and <tc39/ecma262#2210> for [[GetOwnProperty]]. Part 3 will update [[DefineOwnProperty]] and part 5 updates [[Set]]. A side-effect of this change is that non-extensible, non-empty TypedArrays are no longer considered as sealed by `Object.isSealed()`. A later patch in this series will update test262 to enable more currently skipped TypedArray tests. Differential Revision: https://phabricator.services.mozilla.com/D99380 UltraBlame original commit: efd88e38955fc4722c6a882c175fdb48d6ff9e10
…as configurable. r=tcampbell Implements the changes from <tc39/ecma262#2164> and <tc39/ecma262#2210> for [[GetOwnProperty]]. Part 3 will update [[DefineOwnProperty]] and part 5 updates [[Set]]. A side-effect of this change is that non-extensible, non-empty TypedArrays are no longer considered as sealed by `Object.isSealed()`. A later patch in this series will update test262 to enable more currently skipped TypedArray tests. Differential Revision: https://phabricator.services.mozilla.com/D99380 UltraBlame original commit: efd88e38955fc4722c6a882c175fdb48d6ff9e10
This implements the spec change in tc39/ecma262#2164 Making TA elements configurable has interaction with delete. While the elements are configurable, they are only "deletable" via detaching the underlying ArrayBuffer, not via `delete`. That is, `delete ta[idx]` for an in-bounds `idx` still returns false. Bug: v8:11281 Change-Id: I2e9348a7ec3c3239a92cc35e51b7182423736834 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2605234 Reviewed-by: Marja Hölttä <[email protected]> Commit-Queue: Shu-yu Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#71955}
https://bugs.webkit.org/show_bug.cgi?id=220492 Reviewed by Darin Adler. JSTests: * stress/array-species-config-array-constructor.js: * stress/put-direct-index-broken-2.js: Update assertions, which are most certainly incorrect, partly aligning JSC with V8. * stress/typedarray-access-monomorphic-neutered.js: * stress/typedarray-access-neutered.js: * stress/typedarray-defineOwnProperty-error.js: Added. * test262/expectations.yaml: Incorrect tests are being updated at tc39/test262#2958. Source/JavaScriptCore: While web reality [1] requires failures of the most TypeArray internal methods to be silent, [[DefineOwnProperty]] can fail loudly if called via Object.defineProperty. With this patch, TypeError is thrown for detached buffer, out-of-bounds index, and non-index canonical numeric string key. Aligns JSC with the spec [2], V8, and SM. [1]: tc39/ecma262#2164 [2]: https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-defineownproperty-p-desc (step 3.b) * runtime/JSGenericTypedArrayViewInlines.h: (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): Canonical link: https://commits.webkit.org/234754@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=220492 Reviewed by Darin Adler. JSTests: * stress/array-species-config-array-constructor.js: * stress/put-direct-index-broken-2.js: Update assertions, which are most certainly incorrect, partly aligning JSC with V8. * stress/typedarray-access-monomorphic-neutered.js: * stress/typedarray-access-neutered.js: * stress/typedarray-defineOwnProperty-error.js: Added. * test262/expectations.yaml: Incorrect tests are being updated at tc39/test262#2958. Source/JavaScriptCore: While web reality [1] requires failures of the most TypeArray internal methods to be silent, [[DefineOwnProperty]] can fail loudly if called via Object.defineProperty. With this patch, TypeError is thrown for detached buffer, out-of-bounds index, and non-index canonical numeric string key. Aligns JSC with the spec [2], V8, and SM. [1]: tc39/ecma262#2164 [2]: https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-defineownproperty-p-desc (step 3.b) * runtime/JSGenericTypedArrayViewInlines.h: (JSC::JSGenericTypedArrayView<Adaptor>::defineOwnProperty): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@273750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
%TypedArray.prototype% methods that receive a user callback fn should not break in the mid-way of the iteration when the backing array buffer was been detached. Instead, the iteration should continue with the value set to undefined. Notably, %TypedArray.prototype%.filter was throwing when the backing buffer was detached during iteration. This should not throw now. Refs: tc39/ecma262#2164 Bug: v8:4895 Change-Id: Ia7fab63264c8148a11f8f123b43c7b3ee0893300 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3066941 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Shu-yu Guo <[email protected]> Cr-Commit-Position: refs/heads/main@{#76611}
Resolves #678.
Specifically, web reality is such that IsDetachedBuffer checks should not cause the following to throw:
ArrayBuffer.prototype.byteLength
To ensure that we don't violate EIM invariants for typed arrays, we must also:
false
is returned upon attempted deletion of an integer-indexed element(CC @syg, @rwaldron)