Introduce temporary stack variables for getfield/-static and ?load#931
Introduce temporary stack variables for getfield/-static and ?load#931mgudemann wants to merge 11 commits intodiffblue:masterfrom
Conversation
|
this fixes the obvious cases, regression tests and thinking about possibly other cases is needed |
|
strong candidates for additional cases:
|
peterschrammel
left a comment
There was a problem hiding this comment.
Do you have tests that expose the bug?
|
one is the code in #926 where the assert currently still succeeds (which is shouldn't) but the accessed index is the correct one now |
|
instead of it's now |
smowton
left a comment
There was a problem hiding this comment.
A possibility for the future to obtain correctness without dramatic uglification of the code: create the temp variables only when we come across an instruction that writes while there are reads on the stack (e.g. before an astore, for each operand it would not remove from the stack and which is non-constant, now synthesise temporary names to store them; in the common case that there are no such non-constants held over the write op (i.e. the write op drains the stack) we could still produce brief code as we do now.
However this is trickier, so this fix is probably the right way to go for now.
|
Can this please not be merged without regression tests being added? (Also all three checks are failing at the moment.) |
|
@tautschnig the regression tests are fixed, I will add specific ones for this, too |
88d5080 to
9f41808
Compare
78ffc65 to
6303a86
Compare
6303a86 to
8cacd7d
Compare
|
@tautschnig I added regression tests for the bytecode instructions in question @smowton you are right about polluting the GOTOs, effectively this partially recreates the stack state now, which is sub-optimal. |
| @@ -0,0 +1,22 @@ | |||
| .class public stack_var1 | |||
There was a problem hiding this comment.
Why is this file (and the other .j files) included?
There was a problem hiding this comment.
these are the source files I used to create the classes. This is very bytecode specific, in particular the dup2_x? are very rare, so I used the jasmin assembler to create the regression tests.
There was a problem hiding this comment.
Ah, cool. Would you mind adding information in either the commit message or some extra readme file so that these steps become reproducible? I had naively thought that the .class files had been produced from the accompanying .java.
There was a problem hiding this comment.
ok, will do, the stack_test.java is always the entry point and creates an object instance of the class created via jasmin.
There was a problem hiding this comment.
Would it be possible to add as many details as possible, such as the precise command line? This is information that you've now got right at hand, but it will be much more work to reproduce later on. Memory is weak, git is strong!
There was a problem hiding this comment.
:-) it is actually jasmin $FILE.j but I'll add this to the READMEs
There was a problem hiding this comment.
I added some comments about jasmin, how to get it and how to use it on .j files
67d361d to
52f522d
Compare
|
see #951 for an alternative fix working on the write instructions |
|
superseded by #951 which takes a different approach that creates less temporary variables |
When a value is pushed on the stack, it must be ensured that modification of the
origin will not modify the values on the stack.