370 ms·
I apologize - when people mention "memory safe" nowadays 95% of the time they're talking about Rust, I made an assumption. Interpreting JavaScript at all it at
by alexvitkov 2y ago
I apologize - when people mention "memory safe" nowadays 95% of the time they're talking about Rust, I made an assumption.
Interpreting JavaScript at all it at all is a problem. Ladybird's LibJS compiles it to bytecode and interprets that (which is usually better than intereprting the AST). The bytecode interpreter is written in C++, and it's still pretty damn slow - websites take a long time to load, and LibJS is the main bottleneck.
The reality is, modern websites throws so much junk at your JS implementation, that you basically need to JIT-compile it in order to have any sort of reasonable performance. And with JIT all memory safety guarantees are thrown out of the window - it doesn't matter if you write your compiler in Rust, C++ or a .NET language - if there's an exploit it's disproportionately more likely to be in the output assembly than it is to be in your compiler.
Browsers nowadays make a best effort, and they have a stack of other mitigations in case the JIT leaks: https://chromium.googlesource.com/chromium/src/+/main/docs/design/sandbox.md https://chromium.googlesource.com/chromium/src/+/main/docs/d...
- voidwtf 2y agoThis may be the biggest gap in my understanding. I didn’t realize that at some point the JavaScript is turned into instructions running directly on metal, I thought everything occurred within a synthetic/virtual environment.