fix(built-ins): permit preventExtensions on fixed-length typed arrays backed by GSABs#5262
fix(built-ins): permit preventExtensions on fixed-length typed arrays backed by GSABs#5262AlvinThorn008 wants to merge 7 commits intoboa-dev:mainfrom
Conversation
… by GSABs As required by ecma262, `Object.preventExtensions` may be applied to typed arrays without error if the `IsTypedArrayFixedLength` is not false. Prior to this commit, this check was incorrectly implemented via `ArrayBuffer::is_fixed_len` which does not/can not include an AUTO length check. This discrepancy lies in that the requirements of a fixed-length `TypedArray` slightly differ from a fixed-length arraybuffer.
…th typed arrays backed by GSABs
…l. Tests addec to guard against this.
There was a problem hiding this comment.
I think it would be much nicer if you implement the IsTypedArrayFixedLength operation as a function, similar to:
boa/core/engine/src/builtins/typed_array/builtin.rs
Lines 3269 to 3293 in 2437b67
Note that you should put the spec as comment.
|
@zhuzhu81998 Thanks |
…e function for use in `typed_array_exotic_prevent_extensions`.
|
I've copied the format of the function you linked. Everything seems to be working as before. |
| /// - [ECMAScript reference][spec] | ||
| /// | ||
| /// [spec]: https://tc39.es/ecma262/#sec-istypedarrayfixedlength | ||
| fn is_typed_array_fixed_length(obj: &JsObject) -> JsResult<bool> { |
There was a problem hiding this comment.
I think it's better to put this in TypedArray, such that we can simplify the name to is_fixed_length just like ArrayBuffer.is_fixed_len()
There was a problem hiding this comment.
Makes sense. I'll do that shortly
There was a problem hiding this comment.
I ran into a small borrowing error but it resolved now.
Test262 conformance changes
Fixed tests (3):Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5262 +/- ##
===========================================
+ Coverage 47.24% 59.75% +12.50%
===========================================
Files 476 589 +113
Lines 46892 63413 +16521
===========================================
+ Hits 22154 37890 +15736
- Misses 24738 25523 +785 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This Pull Request fixes/closes #5256.
As required by ecma262,
Object.preventExtensionsmay be applied to typed arrays without error if theIsTypedArrayFixedLengthis not false. Prior to this commit, this check was incorrectly implemented viaArrayBuffer::is_fixed_lenwhich does not/can not include an AUTO length check. This discrepancy lies in that the requirements of a fixed-lengthTypedArrayslightly differ from a fixed-length arraybuffer.It adds and replaces the checks as specified by
sec-istypedarrayfixedlength. Now, typed_array_exotic_prevent_extensions shouldOk(false)when theTypedArrayis auto length or when the backingArrayBufferis resizable.ordinary_prevent_extensionsif the backing array is aSharedArrayBuffer.This PR also adds a test to ensure what the title of this issue says. In addition, test262's
test/staging/built-ins/preventExtensionsshould now pass completely.