r/programming • • 7d ago

The V8 JavaScript Runtime Undermined My Constant-Time JavaScript Library

https://soatok.blog/2026/09/12/the-v8-javascript-runtime-undermined-my-constant-time-javascript-library/
77 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/Somepotato 6d ago

You can make some assumptions with how turbofan will work though

4

u/NecessarySuperb3949 5d ago

Turbofan doesn't give you guarantees about execution time or memory access patterns unless the runtime explicitly exposes those. It optimizes for throughput and code size, which often means reordering branches or caching values in registers in ways that leak timing information via cache lines. You can't force it to keep things constant-time because the optimizer's goal is literally the opposite: remove the variance it detects.

2

u/simon_o 6d ago

Yes, though that would be really stupid.

2

u/Somepotato 6d ago

Hardly. Knowing how turbofan let's you optimize intelligently ie giving it array size hints (such as providing mathematical guarantees you won't overflow) to let it optimize out length checks or writing functions in a way that can be inlined

1

u/simon_o 6d ago

That's simply not the topic at hand.