Re:The Fastest VM Bytecode Interpreter (2010)
by peterfirefly on Tuesday April 07, 2015 @08:31AM
(#9333444)
Because modern CPUs have a small internal return stack for target predictions for return instructions. If your calls and returns are not balanced, you get mispredictions (or it gives up and stops predicting altogether).
This type of branch predictor went mainstream in the late 90's with CPUs such as the AMD K6-2.
It is not a correctness issue (as long as there's nothing else that thinks it can put stuff on the stack), just a performance issue.
You should not expect that the code snippets you "return" to will leave the stack alone -- spill/fill and callee-save instructions etc will kill the part of the "stack" that has already been "returned" from which is fine as long as you don't want to reuse it. But I think you will.
http://en.wikipedia.org/wiki/Branch_predictor#Prediction_of_...
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc....
This type of branch predictor went mainstream in the late 90's with CPUs such as the AMD K6-2.
It is not a correctness issue (as long as there's nothing else that thinks it can put stuff on the stack), just a performance issue.
You should not expect that the code snippets you "return" to will leave the stack alone -- spill/fill and callee-save instructions etc will kill the part of the "stack" that has already been "returned" from which is fine as long as you don't want to reuse it. But I think you will.