-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value stack underflow during JIT compilation (AB AB problem) #2
Labels
Milestone
Comments
This bug is highly related to current implementation of MethodCompiler. The upcoming instruction API in #32 will eliminate it automagically because of new graph representation of control flow. |
0x7CFE
added a commit
that referenced
this issue
Jun 13, 2014
Previous implementation incorrectly processed block chains with non-empty stacks. Consider the following situation: A(-2) <- B(1) <- C(1) Block A is the value consumer which requests two values from the refering blocks. Each of blocks B and C provide a single value on their local stack. First request with index 0 will be satisfied by block B because it has 1 value on the local stack. Request with index 1 is more complex. First, block A looks into block B because it is the only referer. But block B have only 1 value on the stack and therefore could not provide a value with index 1. Hence, block C is queried recursively. The problem is that block C also have only 1 value and could not satisfy request with index 1. Problem is solved by substracting the size of local stack from the requested index on each recursion entry. Finally, second value will be requested from block C with effective index 1 - 1 = 0. Issue: #32 Issue: #2
0x7CFE
added a commit
that referenced
this issue
Jun 14, 2014
Previous implementation incorrectly processed block chains with non-empty stacks. Consider the following situation: A(-2) <- B(1) <- C(1) Block A is the value consumer which requests two values from the refering blocks. Each of blocks B and C provide a single value on their local stack. First request with index 0 will be satisfied by block B because it has 1 value on the local stack. Request with index 1 is more complex. First, block A looks into block B because it is the only referer. But block B have only 1 value on the stack and therefore could not provide a value with index 1. Hence, block C is queried recursively. The problem is that block C also have only 1 value and could not satisfy request with index 1. Problem is solved by substracting the size of local stack from the requested index on each recursion entry. Finally, second value will be requested from block C with effective index 1 - 1 = 0. Issue: #32 Issue: #2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is in MethodCompiler::TJITContext::popValue due to the linkage of Smalltalk stack with LLVM IR tree during JIT compilation.
Code to reproduce the bug:
Bytecode:
The compiler links BBs together with "MethodCompiler::TRefererSet referers" in a linked tree:
As you can see, there is a duplicate of AB part, which leads to stack underflow.
JIT compiler produces the following pseudocode:
The compiler should link BBs in the following way:
The text was updated successfully, but these errors were encountered: