-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
fix issues with the java bytecode frontend #742
Merged
swissiety
merged 14 commits into
soot-oss:develop
from
Timbals:fix/java-bytecode-frontend
Nov 8, 2023
Merged
fix issues with the java bytecode frontend #742
swissiety
merged 14 commits into
soot-oss:develop
from
Timbals:fix/java-bytecode-frontend
Nov 8, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 tasks
Certain assign statement would produce in no result. Because the visitor is stateful, this would result in an old result being used later.
Moved the logic for assigning the values of operands to stack locals out of `OperandStack` and into `Operand`. That means that the assignments are created when the operands are used as a local/immediate with the `toLocal` and `toImmediate` methods instead of when they are popped of the stack with `popLocal` and `popImmediate`. This fixes some issues where the wrong `pop` method was used which caused unnecessary stack local variables to get created. This also results in improved type-safety and gets rid of a bunch of casts, because `toLocal` and `toImmediate` actually return the `Local` and `Immediate` types instead of a generic `Operand`. Significantly simplified merging logic in `StackFrame`. Factored a bunch of duplicated code into the new `changeStackLocal` in `Operand`. The old version actually incorrectly merged operands at times (See `SwitchExprWithYieldTest`). I will add a test for this in a later commit. Fixed updating usages of the `value`/`stackLocal` in `Operand`. This is now part of the `changeStackLocal` method. Simplified duplication instructions (Thanks to `Operand.DWORD_DUMMY`). Removed some commented out code.
This removes the duplicated logic that was present in *every* convert method with any inputs/outputs.
Timbals
force-pushed
the
fix/java-bytecode-frontend
branch
from
November 6, 2023 20:07
557d2b3
to
8aa2a08
Compare
The class had nothing to do with stack frames
4 tasks
…merging Instead, rely on the fact that all `convert` methods override their respective statements. That means just changing the incoming operands will automatically correctly update the statement. Also added a test case to make sure this works with the special case of using a normal local as a stack local.
When converting the instructions for a branch, there might not be a line number node after the branch target. This would result in incorrect line numbers being used until the next line number node. The fix is to simply store the line number for branches and restore the current line number when handling that branch.
Timbals
force-pushed
the
fix/java-bytecode-frontend
branch
from
November 8, 2023 15:27
10740b2
to
e7e565e
Compare
swissiety
approved these changes
Nov 8, 2023
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.
looks excellent - thx for cleaning that up ❤️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry for the big PR. The bytecode fronted has a lot of shared state that makes it difficult to change in small steps.
Moved the logic for assigning the values of operands to stack locals out of
OperandStack
and intoOperand
.That means that the assignments are created when the operands are used as a local/immediate with the
toLocal
andtoImmediate
methods instead of when they are popped of the stack withpopLocal
andpopImmediate
.This fixes some issues where the wrong
pop
method was used which caused unnecessary stack local variables to get created.This also results in improved type-safety and gets rid of a bunch of casts, because
toLocal
andtoImmediate
actually return theLocal
andImmediate
types instead of a genericOperand
.Significantly simplified merging logic in
StackFrame
.All
convert
methods had a code path for the first time they were called and for merging subsequent calls.These two code paths have been combined now.
Factored a bunch of duplicated code into the new
changeStackLocal
inOperand
.The old version actually incorrectly merged operands at times (See
SwitchExprWithYieldTest
).This code
would previously produce
but now produces
This adds the missing assignment and doesn't produce so many stack local variables.
Fixed updating usages of the
value
/stackLocal
inOperand
. This is now part of thechangeStackLocal
method.Simplified duplication instructions (Thanks to
Operand.DWORD_DUMMY
).Removed some commented out code.
Fixed an issue in the
ReplaceUseStmtVisitor
that would produce stale results.Fixes #698
Fixes #631
TODO:
StackFrame
(it has nothing to do with stack frames)addReadOperandAssignments_internal
doesand maybe remove it