One VM to Rule Them All
Created: 2020-08-20T06:50:58.906509
Return to the Index
This card pertains to a resource available on the internet.
- Semantics for a guest language are implemented in the form of a tree interpreter; it visits nodes in an abstract syntax tree and performs operations upon them.
- AST nodes include "profiling and frequency" information
- A visitor is allowed to replace its own node. For example value nodes can notice they are storing integers and replace themselves with specialized integer nodes. Math nodes may then notice they have two integers and specialize a math operation.
- A separate compiler system exists which consumes AST and produces machine code as well as execution guards. If a guard is violated / AST node would have been rewritten then "de-optimization" is triggered.
- Polymorphic inline caches can be made by just chaining nodes together with failover.
- One-off tasks can be performed when evaluating a node, then the node replaces itself with another version which no longer does the one-off.
- Nodes reset their run counter when they replace themselves.
- When the interpreter notices a tree is executed "too many" times, the node is subjected to being re-compiled.
- Interpreter can check how often certain branch paths are taken and attempt to optimize them for the platform's branch predictor.