Explorar el Código

Revert "LibJS: Add fast path for getting the TA length of valid TAs"

This reverts commit 9c943f36ed11f5b490163a93e1f637153919545b.

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.
Timothy Flynn hace 1 año
padre
commit
d0d22304e4

+ 5 - 2
Userland/Libraries/LibJS/Runtime/TypedArray.cpp

@@ -639,8 +639,11 @@ u32 typed_array_byte_length(TypedArrayWithBufferWitness const& typed_array_recor
 }
 
 // 10.4.5.12 TypedArrayLength ( taRecord ), https://tc39.es/ecma262/#sec-typedarraylength
-u32 typed_array_length_with_known_valid_bounds(TypedArrayWithBufferWitness const& typed_array_record)
+u32 typed_array_length(TypedArrayWithBufferWitness const& typed_array_record)
 {
+    // 1. Assert: IsTypedArrayOutOfBounds(taRecord) is false.
+    VERIFY(!is_typed_array_out_of_bounds(typed_array_record));
+
     // 2. Let O be taRecord.[[Object]].
     auto object = typed_array_record.object;
 
@@ -723,7 +726,7 @@ bool is_valid_integer_index_slow_case(TypedArrayBase const& typed_array, Canonic
         return false;
 
     // 7. Let length be TypedArrayLength(taRecord).
-    auto length = typed_array_length_with_known_valid_bounds(typed_array_record);
+    auto length = typed_array_length(typed_array_record);
 
     // 8. If ℝ(index) < 0 or ℝ(index) ≥ length, return false.
     if (property_index.as_index() >= length)

+ 1 - 14
Userland/Libraries/LibJS/Runtime/TypedArray.h

@@ -96,21 +96,8 @@ struct TypedArrayWithBufferWitness {
 
 TypedArrayWithBufferWitness make_typed_array_with_buffer_witness_record(TypedArrayBase const&, ArrayBuffer::Order);
 u32 typed_array_byte_length(TypedArrayWithBufferWitness const&);
+u32 typed_array_length(TypedArrayWithBufferWitness const&);
 bool is_typed_array_out_of_bounds(TypedArrayWithBufferWitness const&);
-
-// Fast-path version of TypedArrayLength when you already know the TA is within its bounds,
-// i.e. you previously checked IsTypedArrayOutOfBounds.
-u32 typed_array_length_with_known_valid_bounds(TypedArrayWithBufferWitness const&);
-
-// 10.4.5.12 TypedArrayLength ( taRecord ), https://tc39.es/ecma262/#sec-typedarraylength
-inline u32 typed_array_length(TypedArrayWithBufferWitness const& typed_array_record)
-{
-    // 1. Assert: IsTypedArrayOutOfBounds(taRecord) is false.
-    VERIFY(!is_typed_array_out_of_bounds(typed_array_record));
-
-    return typed_array_length_with_known_valid_bounds(typed_array_record);
-}
-
 bool is_valid_integer_index_slow_case(TypedArrayBase const&, CanonicalIndex property_index);
 
 // 10.4.5.14 IsValidIntegerIndex ( O, index ), https://tc39.es/ecma262/#sec-isvalidintegerindex