-
Notifications
You must be signed in to change notification settings - Fork 224
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
[Shrike] pop2 opcode not translated to Pop(2) instruction #753
Comments
Sorry for my slow response. This looks like a clear bug to me. Any chance you could submit a PR with a fix? |
Alright, I will look into it in the next days |
There seems to be a lot to do to support handling two-word elements on the stack. I just read about the implementation of WALA/com.ibm.wala.shrike/src/main/java/com/ibm/wala/shrikeBT/DupInstruction.java Lines 40 to 46 in c358968
The solution by now is not using double or long at all??? DupInstruction s seem to be affected as well for this issue and there might be more.
Either way, I started to fix the issue for |
@RalfHerzog what is the scope of this problem? Is Shrike’s bytecode instrumentation broken in cases where the input bytecodes have |
"Broken" seem to be a bit too hard for this problem. In fact, if there is a I think there is a discrepancy in the implementation of the two different stacks as described in the jvm specification here (java 11). Cite of §4.10.2.3 (Values of Types long and double): Both places in the jvm spec describe a processing behavior I cannot see in the implementation of shrike, especially the use of an The WALA SSA IR seems not to be affected since pop- and dup-Instructions are omitted during analysis. I checked it with the PDF-examples. |
Thanks again for digging into this! Unfortunately I do not have deep expertise in the implementation of Shrike. Further, I don't think we have a lot of users making use of Shrike's bytecode instrumentation functionality. (I think most folks use ASM these days.) That said, if you get stuck trying to fix this bug, I will try to either help myself or track down someone who can help. |
Hi again, I recently looked deeper into the code for the necessary places to fix the long/double-support. Unfortunately, I couldn't just replace the stack element counting with stack size counting. Some of the methods are used by the SSA IR and thus not working properly anymore.
I will keep going working on that but any help implementing the functionality in a performant way would be appreciated. |
@RalfHerzog thanks for digging further into this. As I mentioned before I’m not an expert on these issues. Maybe you could look at the ASM code to see how they handle these situations? |
I am currently struggling with the correct implementation of the dup-instruction for delta grater than 0. A regular dup(1,0) pops off a single element and pushes it back twice, so far so good. |
@RalfHerzog How often do these bytecodes show up? If they are rare, I would be open to an implementation approach that is less performant. But I'm guessing they are not rare, and I don't want to compromise performance of the main static analysis use cases. If you like you can go ahead with a possibly-less-efficient approach, but we should run benchmarks before and after on use cases like pointer analysis before landing it. Thanks again for putting in so much work on this! |
There is some time passed on this issue and I fixed it as far as I need it for the two-word size shrike processing. Currently, 2 test failures are failing (to be exact 3 but one is occurring twice). Here are the two failed tests: first and second
I think the first failure is harder to fix than the second one since the object type detection is somehow broken. The second failure is somewhat hard to reproduce for me. I created test classes for my own and the javac compiler seems to prevent generating/compiling swap-Instructions. It always uses store- and load-Instructions instead of swapping. I would like to offer to continue maintaining this issue but fixing the very last edge case is too time-consuming for me now. |
@RalfHerzog we really appreciate all the work you've put in on this issue! Those failing test cases correspond to languages other than Java getting compiled to JVML. So there may be bytecode patterns that are never observed when using That said I completely understand if you don't have time to fix these cases. I do not expect much churn in the code you are modifying. So I think you should be able to maintain your patches in a branch pretty easily and merge in relevant changes from WALA master branch as needed, until we can find a better solution. |
Hello,
I currently got stuck understanding the PopInstruction size. It seems there are two possible values: 1 (single word) and 2 (double word) which are representing
pop
andpop2
in the jvm bytecode respectively. When there is a method like this:the following bytecode is compiled (output from eclipse internal class file viewer):
When I load the compiled class file with an OfflineInstrumenter, the MethodData holds the following instructions:
I am wondering why there is a Pop(1) for the pushed long value at index 3, since there is a
pop2
bytecode instruction in the compiled file. Is this correct or am I do something wrong?The text was updated successfully, but these errors were encountered: