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
9132ef57
Commit
9132ef57
authored
Jan 25, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: use late deletion for NOP instruction (#215)
parent
d42bf2d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
21 deletions
+25
-21
InsnDecoder.java
...src/main/java/jadx/core/dex/instructions/InsnDecoder.java
+2
-0
BlockSplitter.java
...ava/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java
+23
-21
No files found.
jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
View file @
9132ef57
...
...
@@ -69,6 +69,8 @@ public class InsnDecoder {
private
InsnNode
decode
(
DecodedInstruction
insn
,
int
offset
)
throws
DecodeException
{
switch
(
insn
.
getOpcode
())
{
case
Opcodes
.
NOP
:
return
new
InsnNode
(
InsnType
.
NOP
,
0
);
case
Opcodes
.
PACKED_SWITCH_PAYLOAD
:
case
Opcodes
.
SPARSE_SWITCH_PAYLOAD
:
case
Opcodes
.
FILL_ARRAY_DATA_PAYLOAD
:
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/BlockSplitter.java
View file @
9132ef57
package
jadx
.
core
.
dex
.
visitors
.
blocksmaker
;
import
java.util.EnumSet
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.attributes.AType
;
import
jadx.core.dex.attributes.nodes.JumpInfo
;
...
...
@@ -14,13 +20,6 @@ import jadx.core.dex.trycatch.SplitterBlockAttr;
import
jadx.core.dex.visitors.AbstractVisitor
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.util.EnumSet
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
public
class
BlockSplitter
extends
AbstractVisitor
{
// leave these instructions alone in block node
...
...
@@ -43,6 +42,7 @@ public class BlockSplitter extends AbstractVisitor {
mth
.
initBasicBlocks
();
splitBasicBlocks
(
mth
);
removeInsns
(
mth
);
removeEmptyBlocks
(
mth
);
}
private
static
void
splitBasicBlocks
(
MethodNode
mth
)
{
...
...
@@ -197,14 +197,12 @@ public class BlockSplitter extends AbstractVisitor {
private
static
boolean
isDoWhile
(
Map
<
Integer
,
BlockNode
>
blocksMap
,
BlockNode
curBlock
,
InsnNode
insn
)
{
// split 'do-while' block (last instruction: 'if', target this block)
if
(
insn
.
getType
()
==
InsnType
.
IF
)
{
IfNode
ifs
=
(
IfNode
)
insn
;
BlockNode
targetBlock
=
blocksMap
.
get
(
ifs
.
getTarget
());
if
(
targetBlock
==
curBlock
)
{
return
true
;
}
if
(
insn
.
getType
()
!=
InsnType
.
IF
)
{
return
false
;
}
return
false
;
IfNode
ifs
=
(
IfNode
)
insn
;
BlockNode
targetBlock
=
blocksMap
.
get
(
ifs
.
getTarget
());
return
targetBlock
==
curBlock
;
}
private
static
BlockNode
getBlock
(
int
offset
,
Map
<
Integer
,
BlockNode
>
blocksMap
)
{
...
...
@@ -217,14 +215,18 @@ public class BlockSplitter extends AbstractVisitor {
private
static
void
removeInsns
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
Iterator
<
InsnNode
>
it
=
block
.
getInstructions
().
iterator
();
while
(
it
.
hasNext
())
{
InsnType
insnType
=
it
.
next
().
getType
();
if
(
insnType
==
InsnType
.
GOTO
||
insnType
==
InsnType
.
NOP
)
{
it
.
remove
();
}
}
block
.
getInstructions
().
removeIf
(
insn
->
{
InsnType
insnType
=
insn
.
getType
();
return
insnType
==
InsnType
.
GOTO
||
insnType
==
InsnType
.
NOP
;
});
}
}
private
void
removeEmptyBlocks
(
MethodNode
mth
)
{
mth
.
getBasicBlocks
().
removeIf
(
block
->
block
.
getInstructions
().
isEmpty
()
&&
block
.
getPredecessors
().
isEmpty
()
&&
block
.
getSuccessors
().
isEmpty
()
);
}
}
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