Skip to content
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

Unpick doesn't transform 0 constants on value consumer side #7

Open
liach opened this issue Apr 3, 2021 · 1 comment
Open

Unpick doesn't transform 0 constants on value consumer side #7

liach opened this issue Apr 3, 2021 · 1 comment

Comments

@liach
Copy link

liach commented Apr 3, 2021

Say there is a use case of an unpick:

private static final int SOME_VALUE = 0;

public void user() {
  call(0);
}

public void call(int value) {
  if (value == 0) { /* do stuff */ }
}

If it's unpicked, unpick will only replace the 0 in the user(); it won't replace that in call(int)'s value == 0 check.

Screenshot:
image

Note: migrated from FabricMC/yarn#2268

@Earthcomputer
Copy link

This is an issue with conditional jumps comparing a value to 0. 0 is an implicit value in the ifeq, ifne, iflt etc instructions. To transform these, the field would need to be loaded, then the instruction transformed into if_icmpeq, if_icmpne etc.
The good news is I thought about this problem in advance, and my DFA code already detects these jump instructions as a "usage" of the constant variable. The only reason I didn't fix it fully is because it would require a change to the way ReplacementSet works, which I didn't feel like doing at the time.
I can fix this when I get home on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants