LibJS: Use memmove in Object::indexed_take_first()

The element-by-element loop compiled to scalar 8-byte moves that the
compiler could not vectorize: source and destination alias, and strict
aliasing prevented hoisting the m_indexed_elements pointer load out of
the loop body. memmove collapses the shift into a single vectorized
copy.
This commit is contained in:
Aliaksandr Kalenik
2026-04-23 17:19:55 +02:00
committed by Andreas Kling
parent 3d3b02b9c0
commit ad7177eccb
Notes: github-actions[bot] 2026-04-23 19:48:29 +00:00

View File

@@ -2007,9 +2007,8 @@ ValueAndAttributes Object::indexed_take_first()
auto available_elements = min(m_indexed_array_like_size, indexed_elements_capacity());
auto first = available_elements > 0 ? m_indexed_elements[0] : js_special_empty_value();
// Shift all elements left
for (u32 i = 0; i + 1 < available_elements; ++i)
m_indexed_elements[i] = m_indexed_elements[i + 1];
if (available_elements > 1)
memmove(m_indexed_elements, m_indexed_elements + 1, (available_elements - 1) * sizeof(Value));
m_indexed_array_like_size--;
if (available_elements > 0)