21:28
<Himanshu Shubham>
Hello everyone, I'm curious if anyone here understands how V8 implements the shift function for Arrays. I recently stumbled upon a question regarding the time complexity of the shift operation on an array in JavaScript. I know that when you remove an element from the front of the array, all other elements need to be shifted to the left. However, during my research, I found an interesting blog post by Jandemooij titled "Some SpiderMonkey Optimizations in Firefox Quantum," which suggests that SpiderMonkey has optimized the shift operation to have an O(1) time complexity. This got me wondering: Does V8 also implement a similar optimization for the shift function, or is it handled differently? Any insights or resources on this topic would be greatly appreciated!
21:35
<shu>
yes, but we don't like it: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=3597;drc=90f276be1122336c6ff7b808054fb183af7a2a9e
21:35
<shu>
the GC complexity is gross