LibJS: Update spec notes for a resizable ArrayBuffer workaround

This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/22de374

The issue noted here has been fixed in the same way that we previously
worked around it. Update the spec notes to match.
This commit is contained in:
Timothy Flynn 2024-01-11 17:18:32 -05:00 committed by Tim Flynn
parent 7566ff90ee
commit 75262a92e1
Notes: sideshowbarker 2024-07-17 03:35:24 +09:00

View file

@ -1616,14 +1616,13 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::slice)
// d. Set final to min(final, len).
final = min(final, length);
// FIXME: Spec issue: If the TypedArray length changed, the count must also be updated.
// https://github.com/tc39/ecma262/issues/3248
// e. Set count to max(final - k, 0).
count = max(final - k, 0);
// e. Let srcType be TypedArrayElementType(O).
// f. Let targetType be TypedArrayElementType(A).
// f. Let srcType be TypedArrayElementType(O).
// g. Let targetType be TypedArrayElementType(A).
// g. If srcType is targetType, then
// h. If srcType is targetType, then
if (typed_array->element_name() == array->element_name()) {
// i. NOTE: The transfer must be performed in a manner that preserves the bit-level encoding of the source data.
@ -1651,8 +1650,8 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::slice)
// vii. Let targetByteIndex be A.[[ByteOffset]].
auto target_byte_index = array->byte_offset();
// viii. Let limit be targetByteIndex + min(count, len) × elementSize.
Checked<u32> limit = min(count, length);
// viii. Let limit be targetByteIndex + (count × elementSize).
Checked<u32> limit = count;
limit *= element_size;
limit += target_byte_index;
if (limit.has_overflow()) {
@ -1675,7 +1674,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::slice)
++target_byte_index;
}
}
// h. Else,
// i. Else,
else {
// i. Let n be 0.
u32 n = 0;