Skip to content

Commit

Permalink
Merge pull request #742 from Timbals/fix/java-bytecode-frontend
Browse files Browse the repository at this point in the history
fix issues with the java bytecode frontend
  • Loading branch information
swissiety authored Nov 8, 2023
2 parents 14227f1 + e7e565e commit f2e1465
Show file tree
Hide file tree
Showing 36 changed files with 1,376 additions and 1,656 deletions.
Binary file not shown.
33 changes: 33 additions & 0 deletions shared-test-resources/miniTestSuite/java6/source/LocalMerging.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
public class LocalMerging {
public void localMergingWithConstant(int n) {
String a = "one";
// The branch returns either a local or a constant.
// Because of the divergence neither `a` nor `"two"` should be inlined,
// but a stack local variable should be created for holding the result of the branch.
System.out.println(n == 1 ? a : "two");
}

public void localMergingWithOtherLocal(int n) {
String a = "one";
String b = "two";
// The branch returns either a local or a different local.
// Because of the divergence neither `a` nor `b` should be inlined,
// but a stack local variable should be created for holding the result of the branch.
System.out.println(n == 1 ? a : b);
}

public void localMergingWithDuplicateValue(int n) {
String a = "one";
// One of the branches for the first argument contains the constant "two"
// and the second argument also contains the constant "two".
// This test ensures that when the first argument gets replaced by a stack local,
// the second argument isn't replaced as well.
System.setProperty(n == 1 ? a : "two", "two");
}

public void localMergingWithInlining(int n) {
String[] arr = new String[] {"a", "b"};
int a = 1;
String b = arr[n == 1 ? 0 : a];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void caseInvokeStmt(@Nonnull JInvokeStmt stmt) {

@Override
public void caseAssignStmt(@Nonnull JAssignStmt stmt) {
// fall back to the original statement when none of the cases set a result
setResult(stmt);

// uses on the def side.. e.g. a base in an JArrayRef but NOT with a simple Local!
final Value leftOp = stmt.getLeftOp();
Expand Down Expand Up @@ -106,8 +108,6 @@ public void caseAssignStmt(@Nonnull JAssignStmt stmt) {
if (exprVisitor.getResult() != rValue) {
setResult(stmt.withRValue(exprVisitor.getResult()));
}
} else {
setResult(stmt);
}
}

Expand Down
Loading

0 comments on commit f2e1465

Please sign in to comment.