Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
3eee83c2
Commit
3eee83c2
authored
Jul 07, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: adjust insn reorder check in code shrink visitor (#695)
parent
ed8c6626
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
49 deletions
+91
-49
ArgsInfo.java
...src/main/java/jadx/core/dex/visitors/shrink/ArgsInfo.java
+9
-2
TestConditions18.java
...a/jadx/tests/integration/conditions/TestConditions18.java
+37
-0
TestInlineInLoop.java
.../java/jadx/tests/integration/inline/TestInlineInLoop.java
+0
-47
TestConditions18.smali
jadx-core/src/test/smali/conditions/TestConditions18.smali
+45
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/shrink/ArgsInfo.java
View file @
3eee83c2
...
...
@@ -93,14 +93,21 @@ final class ArgsInfo {
movedSet
.
set
(
arg
.
getRegNum
());
}
}
boolean
canReorder
=
startInfo
.
insn
.
canReorder
();
for
(
int
i
=
start
;
i
<
to
;
i
++)
{
ArgsInfo
argsInfo
=
argsList
.
get
(
i
);
if
(
argsInfo
.
getInlinedInsn
()
==
this
)
{
continue
;
}
InsnNode
curInsn
=
argsInfo
.
insn
;
if
(!
curInsn
.
canReorder
()
||
usedArgAssign
(
curInsn
,
movedSet
))
{
return
false
;
if
(
canReorder
)
{
if
(
usedArgAssign
(
curInsn
,
movedSet
))
{
return
false
;
}
}
else
{
if
(!
curInsn
.
canReorder
()
||
usedArgAssign
(
curInsn
,
movedSet
))
{
return
false
;
}
}
}
return
true
;
...
...
jadx-core/src/test/java/jadx/tests/integration/conditions/TestConditions18.java
0 → 100644
View file @
3eee83c2
package
jadx
.
tests
.
integration
.
conditions
;
import
org.junit.jupiter.api.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.SmaliTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
public
class
TestConditions18
extends
SmaliTest
{
// @formatter:off
/*
public static class TestConditions18 {
private Map map;
public boolean test(Object obj) {
return this == obj || ((obj instanceof TestConditions18) && st(this.map, ((TestConditions18) obj).map));
}
private static boolean st(Object obj, Object obj2) {
return false;
}
}
*/
// @formatter:on
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNodeFromSmali
();
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"return this == obj"
+
" || ((obj instanceof TestConditions18) && st(this.map, ((TestConditions18) obj).map));"
));
}
}
jadx-core/src/test/java/jadx/tests/integration/inline/TestInlineInLoop.java
deleted
100644 → 0
View file @
ed8c6626
package
jadx
.
tests
.
integration
.
inline
;
import
org.junit.jupiter.api.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
public
class
TestInlineInLoop
extends
IntegrationTest
{
public
static
class
TestCls
{
public
static
void
main
(
String
[]
args
)
{
int
a
=
0
;
int
b
=
4
;
int
c
=
0
;
while
(
a
<
12
)
{
if
(
b
+
a
<
9
&&
b
<
8
)
{
if
(
b
>=
2
&&
a
>
-
1
&&
b
<
6
)
{
System
.
out
.
println
(
"OK"
);
c
=
b
+
1
;
}
c
=
b
;
}
c
=
b
;
b
++;
b
=
c
;
a
++;
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
// TODO: remove unused variables from test
assertThat
(
code
,
containsOne
(
"int c = b + 1"
));
assertThat
(
code
,
containsOne
(
"int c2 = b;"
));
assertThat
(
code
,
containsOne
(
"int c3 = b;"
));
assertThat
(
code
,
containsOne
(
"int b2 = b + 1;"
));
assertThat
(
code
,
containsOne
(
"b = c3"
));
assertThat
(
code
,
containsOne
(
"a++"
));
}
}
jadx-core/src/test/smali/conditions/TestConditions18.smali
0 → 100644
View file @
3eee83c2
.class public final Lconditions/TestConditions18;
.super Ljava/lang/Object;
.field private map:Ljava/util/Map;
.method public test(Ljava/lang/Object;)Z
.locals 1
if-eq p0, p1, :cond_1
instance-of v0, p1, Lconditions/TestConditions18;
if-eqz v0, :cond_0
check-cast p1, Lconditions/TestConditions18;
iget-object v0, p0, Lconditions/TestConditions18;->map:Ljava/util/Map;
iget-object p1, p1, Lconditions/TestConditions18;->map:Ljava/util/Map;
invoke-static {v0, p1}, Lconditions/TestConditions18;->st(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result p1
if-eqz p1, :cond_0
goto :goto_0
:cond_0
const/4 p1, 0x0
return p1
:cond_1
:goto_0
const/4 p1, 0x1
return p1
.end method
.method private static st(Ljava/lang/Object;Ljava/lang/Object;)Z
.locals 1
const/4 v0, 0x0
return v0
.end method
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment