mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Revert "LibJS: Add fast path for creating a TA record for attached TAs"
This reverts commit 72cee4c88b
.
This optimization is superseded by optimizing IsValidIntegerIndex for
TypedArrays with non-resizable ArrayBuffers. Reverting this commit has
no impact on test-js, test262, or live website performance.
This commit is contained in:
parent
08ad2d774e
commit
d8eb297b95
2 changed files with 14 additions and 18 deletions
|
@ -588,19 +588,26 @@ JS_ENUMERATE_TYPED_ARRAYS
|
||||||
#undef __JS_ENUMERATE
|
#undef __JS_ENUMERATE
|
||||||
|
|
||||||
// 10.4.5.9 MakeTypedArrayWithBufferWitnessRecord ( obj, order ), https://tc39.es/ecma262/#sec-maketypedarraywithbufferwitnessrecord
|
// 10.4.5.9 MakeTypedArrayWithBufferWitnessRecord ( obj, order ), https://tc39.es/ecma262/#sec-maketypedarraywithbufferwitnessrecord
|
||||||
TypedArrayWithBufferWitness make_typed_array_with_buffer_witness_record_for_known_attached_array(TypedArrayBase const& typed_array, ArrayBuffer::Order order)
|
TypedArrayWithBufferWitness make_typed_array_with_buffer_witness_record(TypedArrayBase const& typed_array, ArrayBuffer::Order order)
|
||||||
{
|
{
|
||||||
// 1. Let buffer be obj.[[ViewedArrayBuffer]].
|
// 1. Let buffer be obj.[[ViewedArrayBuffer]].
|
||||||
auto* buffer = typed_array.viewed_array_buffer();
|
auto* buffer = typed_array.viewed_array_buffer();
|
||||||
|
|
||||||
|
ByteLength byte_length { 0 };
|
||||||
|
|
||||||
// 2. If IsDetachedBuffer(buffer) is true, then
|
// 2. If IsDetachedBuffer(buffer) is true, then
|
||||||
// a. Let byteLength be detached.
|
if (buffer->is_detached()) {
|
||||||
|
// a. Let byteLength be detached.
|
||||||
|
byte_length = ByteLength::detached();
|
||||||
|
}
|
||||||
// 3. Else,
|
// 3. Else,
|
||||||
// a. Let byteLength be ArrayBufferByteLength(buffer, order).
|
else {
|
||||||
auto byte_length = array_buffer_byte_length(*buffer, order);
|
// a. Let byteLength be ArrayBufferByteLength(buffer, order).
|
||||||
|
byte_length = array_buffer_byte_length(*buffer, order);
|
||||||
|
}
|
||||||
|
|
||||||
// 4. Return the TypedArray With Buffer Witness Record { [[Object]]: obj, [[CachedBufferByteLength]]: byteLength }.
|
// 4. Return the TypedArray With Buffer Witness Record { [[Object]]: obj, [[CachedBufferByteLength]]: byteLength }.
|
||||||
return { .object = typed_array, .cached_buffer_byte_length = byte_length };
|
return { .object = typed_array, .cached_buffer_byte_length = move(byte_length) };
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.4.5.11 TypedArrayByteLength ( taRecord ), https://tc39.es/ecma262/#sec-typedarraybytelength
|
// 10.4.5.11 TypedArrayByteLength ( taRecord ), https://tc39.es/ecma262/#sec-typedarraybytelength
|
||||||
|
@ -703,7 +710,7 @@ bool is_typed_array_out_of_bounds_for_known_attached_array(TypedArrayWithBufferW
|
||||||
bool is_valid_integer_index_slow_case(TypedArrayBase const& typed_array, CanonicalIndex property_index)
|
bool is_valid_integer_index_slow_case(TypedArrayBase const& typed_array, CanonicalIndex property_index)
|
||||||
{
|
{
|
||||||
// 4. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, unordered).
|
// 4. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(O, unordered).
|
||||||
auto typed_array_record = make_typed_array_with_buffer_witness_record_for_known_attached_array(typed_array, ArrayBuffer::Unordered);
|
auto typed_array_record = make_typed_array_with_buffer_witness_record(typed_array, ArrayBuffer::Unordered);
|
||||||
|
|
||||||
// 5. NOTE: Bounds checking is not a synchronizing operation when O's backing buffer is a growable SharedArrayBuffer.
|
// 5. NOTE: Bounds checking is not a synchronizing operation when O's backing buffer is a growable SharedArrayBuffer.
|
||||||
|
|
||||||
|
|
|
@ -94,21 +94,10 @@ struct TypedArrayWithBufferWitness {
|
||||||
ByteLength cached_buffer_byte_length; // [[CachedBufferByteLength]]
|
ByteLength cached_buffer_byte_length; // [[CachedBufferByteLength]]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TypedArrayWithBufferWitness make_typed_array_with_buffer_witness_record(TypedArrayBase const&, ArrayBuffer::Order);
|
||||||
u32 typed_array_byte_length(TypedArrayWithBufferWitness const&);
|
u32 typed_array_byte_length(TypedArrayWithBufferWitness const&);
|
||||||
bool is_typed_array_out_of_bounds(TypedArrayWithBufferWitness const&);
|
bool is_typed_array_out_of_bounds(TypedArrayWithBufferWitness const&);
|
||||||
|
|
||||||
// Fast-path version of MakeTypedArrayWithBufferWitnessRecord when you already know the TA is not detached.
|
|
||||||
TypedArrayWithBufferWitness make_typed_array_with_buffer_witness_record_for_known_attached_array(TypedArrayBase const&, ArrayBuffer::Order);
|
|
||||||
|
|
||||||
// 10.4.5.9 MakeTypedArrayWithBufferWitnessRecord ( obj, order ), https://tc39.es/ecma262/#sec-maketypedarraywithbufferwitnessrecord
|
|
||||||
inline TypedArrayWithBufferWitness make_typed_array_with_buffer_witness_record(TypedArrayBase const& typed_array, ArrayBuffer::Order order)
|
|
||||||
{
|
|
||||||
if (typed_array.viewed_array_buffer()->is_detached())
|
|
||||||
return { .object = typed_array, .cached_buffer_byte_length = ByteLength::detached() };
|
|
||||||
|
|
||||||
return make_typed_array_with_buffer_witness_record_for_known_attached_array(typed_array, order);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fast-path version of TypedArrayLength when you already know the TA is within its bounds,
|
// Fast-path version of TypedArrayLength when you already know the TA is within its bounds,
|
||||||
// i.e. you previously checked IsTypedArrayOutOfBounds.
|
// i.e. you previously checked IsTypedArrayOutOfBounds.
|
||||||
u32 typed_array_length_with_known_valid_bounds(TypedArrayWithBufferWitness const&);
|
u32 typed_array_length_with_known_valid_bounds(TypedArrayWithBufferWitness const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue