Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
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
a4632d6e
Commit
a4632d6e
authored
Sep 04, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix high memory usage while process conditions
parent
2a3162f8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
20 deletions
+87
-20
IfInfo.java
...rc/main/java/jadx/core/dex/regions/conditions/IfInfo.java
+14
-9
IfMakerHelper.java
...in/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
+3
-11
TestConditions15.java
...java/jadx/tests/internal/conditions/TestConditions15.java
+70
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/regions/conditions/IfInfo.java
View file @
a4632d6e
...
@@ -3,8 +3,6 @@ package jadx.core.dex.regions.conditions;
...
@@ -3,8 +3,6 @@ package jadx.core.dex.regions.conditions;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.BlockNode
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
public
final
class
IfInfo
{
public
final
class
IfInfo
{
...
@@ -12,13 +10,13 @@ public final class IfInfo {
...
@@ -12,13 +10,13 @@ public final class IfInfo {
private
final
Set
<
BlockNode
>
mergedBlocks
;
private
final
Set
<
BlockNode
>
mergedBlocks
;
private
final
BlockNode
thenBlock
;
private
final
BlockNode
thenBlock
;
private
final
BlockNode
elseBlock
;
private
final
BlockNode
elseBlock
;
private
final
Lis
t
<
BlockNode
>
skipBlocks
;
private
final
Se
t
<
BlockNode
>
skipBlocks
;
private
BlockNode
outBlock
;
private
BlockNode
outBlock
;
@Deprecated
@Deprecated
private
BlockNode
ifBlock
;
private
BlockNode
ifBlock
;
public
IfInfo
(
IfCondition
condition
,
BlockNode
thenBlock
,
BlockNode
elseBlock
)
{
public
IfInfo
(
IfCondition
condition
,
BlockNode
thenBlock
,
BlockNode
elseBlock
)
{
this
(
condition
,
thenBlock
,
elseBlock
,
new
HashSet
<
BlockNode
>(),
new
LinkedLis
t
<
BlockNode
>());
this
(
condition
,
thenBlock
,
elseBlock
,
new
HashSet
<
BlockNode
>(),
new
HashSe
t
<
BlockNode
>());
}
}
public
IfInfo
(
IfCondition
condition
,
IfInfo
info
)
{
public
IfInfo
(
IfCondition
condition
,
IfInfo
info
)
{
...
@@ -30,7 +28,7 @@ public final class IfInfo {
...
@@ -30,7 +28,7 @@ public final class IfInfo {
}
}
private
IfInfo
(
IfCondition
condition
,
BlockNode
thenBlock
,
BlockNode
elseBlock
,
private
IfInfo
(
IfCondition
condition
,
BlockNode
thenBlock
,
BlockNode
elseBlock
,
Set
<
BlockNode
>
mergedBlocks
,
Lis
t
<
BlockNode
>
skipBlocks
)
{
Set
<
BlockNode
>
mergedBlocks
,
Se
t
<
BlockNode
>
skipBlocks
)
{
this
.
condition
=
condition
;
this
.
condition
=
condition
;
this
.
thenBlock
=
thenBlock
;
this
.
thenBlock
=
thenBlock
;
this
.
elseBlock
=
elseBlock
;
this
.
elseBlock
=
elseBlock
;
...
@@ -47,6 +45,13 @@ public final class IfInfo {
...
@@ -47,6 +45,13 @@ public final class IfInfo {
return
tmpIf
;
return
tmpIf
;
}
}
public
void
merge
(
IfInfo
...
arr
)
{
for
(
IfInfo
info
:
arr
)
{
mergedBlocks
.
addAll
(
info
.
getMergedBlocks
());
skipBlocks
.
addAll
(
info
.
getSkipBlocks
());
}
}
public
IfCondition
getCondition
()
{
public
IfCondition
getCondition
()
{
return
condition
;
return
condition
;
}
}
...
@@ -55,6 +60,10 @@ public final class IfInfo {
...
@@ -55,6 +60,10 @@ public final class IfInfo {
return
mergedBlocks
;
return
mergedBlocks
;
}
}
public
Set
<
BlockNode
>
getSkipBlocks
()
{
return
skipBlocks
;
}
public
BlockNode
getThenBlock
()
{
public
BlockNode
getThenBlock
()
{
return
thenBlock
;
return
thenBlock
;
}
}
...
@@ -71,10 +80,6 @@ public final class IfInfo {
...
@@ -71,10 +80,6 @@ public final class IfInfo {
this
.
outBlock
=
outBlock
;
this
.
outBlock
=
outBlock
;
}
}
public
List
<
BlockNode
>
getSkipBlocks
()
{
return
skipBlocks
;
}
public
BlockNode
getIfBlock
()
{
public
BlockNode
getIfBlock
()
{
return
ifBlock
;
return
ifBlock
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
View file @
a4632d6e
...
@@ -190,12 +190,7 @@ public class IfMakerHelper {
...
@@ -190,12 +190,7 @@ public class IfMakerHelper {
nextThen
.
getCondition
(),
nextElse
.
getCondition
());
nextThen
.
getCondition
(),
nextElse
.
getCondition
());
IfInfo
result
=
new
IfInfo
(
newCondition
,
nextThen
.
getThenBlock
(),
nextThen
.
getElseBlock
());
IfInfo
result
=
new
IfInfo
(
newCondition
,
nextThen
.
getThenBlock
(),
nextThen
.
getElseBlock
());
result
.
setIfBlock
(
currentIf
.
getIfBlock
());
result
.
setIfBlock
(
currentIf
.
getIfBlock
());
result
.
getMergedBlocks
().
addAll
(
currentIf
.
getMergedBlocks
());
result
.
merge
(
currentIf
,
nextThen
,
nextElse
);
result
.
getMergedBlocks
().
addAll
(
nextThen
.
getMergedBlocks
());
result
.
getMergedBlocks
().
addAll
(
nextElse
.
getMergedBlocks
());
result
.
getSkipBlocks
().
addAll
(
currentIf
.
getSkipBlocks
());
result
.
getSkipBlocks
().
addAll
(
nextThen
.
getSkipBlocks
());
result
.
getSkipBlocks
().
addAll
(
nextElse
.
getSkipBlocks
());
confirmMerge
(
result
);
confirmMerge
(
result
);
return
result
;
return
result
;
}
}
...
@@ -215,10 +210,7 @@ public class IfMakerHelper {
...
@@ -215,10 +210,7 @@ public class IfMakerHelper {
IfCondition
condition
=
IfCondition
.
merge
(
mergeOperation
,
first
.
getCondition
(),
second
.
getCondition
());
IfCondition
condition
=
IfCondition
.
merge
(
mergeOperation
,
first
.
getCondition
(),
second
.
getCondition
());
IfInfo
result
=
new
IfInfo
(
condition
,
second
);
IfInfo
result
=
new
IfInfo
(
condition
,
second
);
result
.
setIfBlock
(
first
.
getIfBlock
());
result
.
setIfBlock
(
first
.
getIfBlock
());
result
.
getMergedBlocks
().
addAll
(
first
.
getMergedBlocks
());
result
.
merge
(
first
,
second
);
result
.
getMergedBlocks
().
addAll
(
second
.
getMergedBlocks
());
result
.
getSkipBlocks
().
addAll
(
first
.
getSkipBlocks
());
result
.
getSkipBlocks
().
addAll
(
second
.
getSkipBlocks
());
BlockNode
otherPathBlock
=
followThenBranch
?
first
.
getElseBlock
()
:
first
.
getThenBlock
();
BlockNode
otherPathBlock
=
followThenBranch
?
first
.
getElseBlock
()
:
first
.
getThenBlock
();
skipSimplePath
(
otherPathBlock
,
result
.
getSkipBlocks
());
skipSimplePath
(
otherPathBlock
,
result
.
getSkipBlocks
());
...
@@ -303,7 +295,7 @@ public class IfMakerHelper {
...
@@ -303,7 +295,7 @@ public class IfMakerHelper {
return
null
;
return
null
;
}
}
private
static
void
skipSimplePath
(
BlockNode
block
,
Lis
t
<
BlockNode
>
skipped
)
{
private
static
void
skipSimplePath
(
BlockNode
block
,
Se
t
<
BlockNode
>
skipped
)
{
while
(
block
!=
null
while
(
block
!=
null
&&
block
.
getCleanSuccessors
().
size
()
<
2
&&
block
.
getCleanSuccessors
().
size
()
<
2
&&
block
.
getPredecessors
().
size
()
==
1
)
{
&&
block
.
getPredecessors
().
size
()
==
1
)
{
...
...
jadx-core/src/test/java/jadx/tests/internal/conditions/TestConditions15.java
0 → 100644
View file @
a4632d6e
package
jadx
.
tests
.
internal
.
conditions
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestConditions15
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
static
boolean
test
(
final
String
name
)
{
if
(
isEmpty
(
name
))
{
return
false
;
}
if
(
"1"
.
equals
(
name
)
||
"2"
.
equals
(
name
)
||
"3"
.
equals
(
name
)
||
"4"
.
equals
(
name
)
||
"5"
.
equals
(
name
)
||
"6"
.
equals
(
name
)
||
"7"
.
equals
(
name
)
||
"8"
.
equals
(
name
)
||
"9"
.
equals
(
name
)
||
"10"
.
equals
(
name
)
||
"11"
.
equals
(
name
)
||
"12"
.
equals
(
name
)
||
"13"
.
equals
(
name
)
||
"14"
.
equals
(
name
)
||
"15"
.
equals
(
name
)
||
"16"
.
equals
(
name
)
||
"17"
.
equals
(
name
)
||
"18"
.
equals
(
name
)
||
"19"
.
equals
(
name
)
||
"20"
.
equals
(
name
)
||
"22"
.
equals
(
name
)
||
"22"
.
equals
(
name
)
||
"23"
.
equals
(
name
)
||
"24"
.
equals
(
name
)
||
"25"
.
equals
(
name
)
||
"26"
.
equals
(
name
)
||
"27"
.
equals
(
name
)
||
"28"
.
equals
(
name
)
||
"29"
.
equals
(
name
)
||
"30"
.
equals
(
name
))
{
return
false
;
}
else
{
return
true
;
}
}
private
static
boolean
isEmpty
(
String
name
)
{
return
name
.
isEmpty
();
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
"\"1\".equals(name)"
));
assertThat
(
code
,
containsOne
(
"\"30\".equals(name)"
));
}
}
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