-
Notifications
You must be signed in to change notification settings - Fork 273
Introduce temporary stack variables for getfield/-static and ?load #931
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
Introduce temporary stack variables for getfield/-static and ?load #931
Conversation
this fixes the obvious cases, regression tests and thinking about possibly other cases is needed |
strong candidates for additional cases:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this file (and the other .j files) included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will do, the stack_test.java
is always the entry point and creates an object instance of the class created via jasmin.
@@ -0,0 +1,2 @@ | |||
This regression test is created from the .j file with the jasmin assembler. | |||
https://github.com/Sable/jasmin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-) it is actually jasmin $FILE.j
but I'll add this to the READMEs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments about jasmin, how to get it and how to use it on .j
files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
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.