4 ms·
I wonder, why they implemented Baseline JS interpreter in C++? Why not Rust?
by xvilka 7y ago
I wonder, why they implemented Baseline JS interpreter in C++? Why not Rust?
- stuartd 7y agoBecause the interpreter pipeline shares code and data structures [0]: a couple of examples from the link below: > The Baseline Interpreter uses the same frame layout as the Baseline JIT, but we’ve added some interpreter-specific fields to the frame. > Because the Baseline Interpreter and JIT are so similar, a lot of the code generation code can be shared too. To do this, we added a templated BaselineCodeGen base class with two derived classes: - BaselineCompiler: used by the Baseline JIT to compile a script’s bytecode to machine code. - BaselineInterpreterGenerator: used to generate the Baseline Interpreter code. [0] https://hacks.mozilla.org/2019/08/the-baseline-interpreter-a-faster-js-interpreter-in-firefox-70/ https://hacks.mozilla.org/2019/08/the-baseline-interpreter-a...
- pjc50 7y agoI believe the Rust rewrite of parts is proceeding, but this tech blog explains what's going on: https://hacks.mozilla.org/2019/08/the-baseline-interpreter-a-faster-js-interpreter-in-firefox-70/ https://hacks.mozilla.org/2019/08/the-baseline-interpreter-a... > The Baseline Interpreter sits between the C++ interpreter and the Baseline JIT and has elements from both. It executes all bytecode instructions with a fixed interpreter loop (like the C++ interpreter). In addition, it uses Inline Caches to improve performance and collect type information (like the Baseline JIT). Including elements [of code] from both would be considerably harder in another language. If you read closely it appears the interpreter is "generated" - that it, it's not written directly in C++ or anything at all, but is instead an interpreter emitted by the JIT compiler!
- eyegor 7y agoI was under the impression that this was a side goal of the servo project. Of course now it looks like it is it's own thing: https://servo.org/ https://servo.org/ Does anyone know if servo is supposed to be related to Firefox in some way, or if it is always meant to be independent?
- timerol 7y agoServo is supposed to be a playground of sorts for architectural innovations in the browser space. Successful experiments from Servo will then get ported to FF. Project Quantum ported over the Stylo CSS improvements from Servo: https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-engine-quantum-css-aka-stylo/ https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-en.... WebRender has also been making it's way over: https://hacks.mozilla.org/2017/10/the-whole-web-at-maximum-fps-how-webrender-gets-rid-of-jank/ https://hacks.mozilla.org/2017/10/the-whole-web-at-maximum-f...