Skip to content

Commit

Permalink
fix: workaround to prevent incorrect order after move inline (#1472)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Apr 29, 2022
1 parent a71b3a7 commit a717392
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ private static boolean processMove(MethodNode mth, InsnNode move) {
}
SSAVar ssaVar = resultArg.getSVar();
if (ssaVar.isUsedInPhi()) {
return deleteMove(mth, move);
return false;
// TODO: review conditions of 'up' move inline (test TestMoveInline)
// return deleteMove(mth, move);
}
RegDebugInfoAttr debugInfo = moveArg.get(AType.REG_DEBUG_INFO);
for (RegisterArg useArg : ssaVar.getUseList()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package jadx.tests.integration.others;

import org.junit.jupiter.api.Test;

import jadx.tests.api.SmaliTest;

import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;

@SuppressWarnings("CommentedOutCode")
public class TestMoveInline extends SmaliTest {
// @formatter:off
/*
public final void Y(int i) throws k {
int i2 = 0;
while ((i & (-128)) != 0) {
this.h[i2] = (byte) ((i & 127) | 128);
i >>>= 7;
i2++;
}
byte[] bArr = this.h;
bArr[i2] = (byte) i;
this.a.k(bArr, 0, i2 + 1);
}
*/
// @formatter:on

@Test
public void test() {
getArgs().setRawCFGOutput(true);
assertThat(getClassNodeFromSmali())
.code()
// check operations order
.containsLines(3,
"i >>>= 7;",
"i2++;");
}
}
44 changes: 44 additions & 0 deletions jadx-core/src/test/smali/others/TestMoveInline.smali
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.class public Lothers/TestMoveInline;
.super Ljava/lang/Object;

.field private h:[B
.field private a:Lothers/TestMoveInline;

.method public k([BII)V
.registers 5
return-void
.end method

.method public test(I)V
.registers 7

const/4 v0, 0x0
move v1, v0

:goto_2
and-int/lit8 v2, p1, -0x80
if-nez v2, :cond_13

.line 1
iget-object v2, p0, Lothers/TestMoveInline;->h:[B
add-int/lit8 v3, v1, 0x1
int-to-byte p1, p1
aput-byte p1, v2, v1

.line 2
iget-object p1, p0, Lothers/TestMoveInline;->a:Lothers/TestMoveInline;
invoke-virtual {p1, v2, v0, v3}, Lothers/TestMoveInline;->k([BII)V
return-void

.line 3
:cond_13
iget-object v2, p0, Lothers/TestMoveInline;->h:[B
add-int/lit8 v3, v1, 0x1
and-int/lit8 v4, p1, 0x7f
or-int/lit16 v4, v4, 0x80
int-to-byte v4, v4
aput-byte v4, v2, v1
ushr-int/lit8 p1, p1, 0x7
move v1, v3
goto :goto_2
.end method

0 comments on commit a717392

Please sign in to comment.