diff --git a/Interpreter-optimization-resources.md b/Interpreter-optimization-resources.md index 81e4142..c35b94e 100644 --- a/Interpreter-optimization-resources.md +++ b/Interpreter-optimization-resources.md @@ -44,15 +44,17 @@ that makes interpretation nice with the hardware branch predictor. Practical imp Basically, instead of computed goto, you have computed "call" and each section called is ended by the ret (return) instruction. Note that it the address called is still inline, there is no parameter pushed on the stack. + The trick is that CPU has the following types of predictors: -• Linear or straight-line code -• Conditional branches -• Calls and Returns -• Indirect branches +- Linear or straight-line code +- Conditional branches +- Calls and Returns +- Indirect branches But direct threaded code / computed goto only makes use of indirect branches (goto). Context Threading seems to reduce -cache misses by up to 95%. +cache misses by up to 95% by exploiting all those predictors. However it requires assembly as there is no way to generate +arbitrary call and ret instructions. ## Codebases