Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.ssa

public Class SsaConverter

extends Object
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.code.RegisterSpec, .RopMethod, org.droidparts.dexmaker.dx.util.IntIterator, java.util.ArrayList, .BitSet

Converts ROP methods to SSA Methods

Field Summary

Modifier and TypeField and Description
public static final boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static SsaMethod

Returns:

output in SSA form
convertToSsaMethod
(RopMethod
input
rmeth
,
int
the total width, in register-units, of the method's parameters
paramWidth
,
boolean
true if this method has no this pointer argument
isStatic
)

Returns an SSA representation, edge-split and with phi functions placed.

private static void
edgeSplit(SsaMethod
method to process
result
)

See Appel section 19.1: Converts CFG into "edge-split" form, such that each node either a unique successor or unique predecessor.

private static void
edgeSplitMoveExceptionsAndResults(SsaMethod
method to process
ssaMeth
)

In ROP form, move-exception must occur as the first insn in a block immediately succeeding the insn that could thrown an exception.

private static void
edgeSplitPredecessors(SsaMethod
non-null; method to process
result
)

Inserts Z nodes as new predecessors for every node that has multiple successors and multiple predecessors.

private static void
edgeSplitSuccessors(SsaMethod
non-null; method to process
result
)

Inserts Z nodes for every node that needs a new successor.

private static boolean

Returns:

true if a Z node is needed
needsNewSuccessor
(SsaBasicBlock
predecessor node
block
,
SsaBasicBlock
successor node
succ
)

Returns true if block and successor need a Z-node between them.

private static boolean

Returns:

true if this node needs to have a unique predecessor created for it
nodeNeedsUniquePredecessor
(SsaBasicBlock
non-null; block in question
block
)

private static void
placePhiFunctions(SsaMethod
non-null; method to process. Modifications are made in-place.
ssaMeth
,
LocalVariableInfo
non-null; local variable info, used when placing phis
localInfo
,
int
registers below this number are ignored
threshold
)

See Appel algorithm 19.6: Place Phi functions in appropriate locations.

public static SsaMethod

Returns:

an SSA represention with only the edge-splitter run
testEdgeSplit
(RopMethod
method to process
rmeth
,
int
width of all arguments in the method
paramWidth
,
boolean
true if this method has no this pointer argument
isStatic
)

Returns an SSA represention with only the edge-splitter run.

public static SsaMethod

Returns:

an SSA represention with only the edge-splitter run
testPhiPlacement
(RopMethod
method to process
rmeth
,
int
width of all arguments in the method
paramWidth
,
boolean
true if this method has no this pointer argument
isStatic
)

Returns an SSA represention with only the steps through the phi placement run.

public static void
updateSsaMethod(SsaMethod
input
ssaMeth
,
int
registers below this number are unchanged
threshold
)

Updates an SSA representation, placing phi functions and renaming all registers above a certain threshold number.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
public static final boolean DEBUG

Constructor Detail

SsaConverterback to summary
public SsaConverter()

Method Detail

convertToSsaMethodback to summary
public static SsaMethod convertToSsaMethod(RopMethod rmeth, int paramWidth, boolean isStatic)

Returns an SSA representation, edge-split and with phi functions placed.

Parameters
rmeth:RopMethod

input

paramWidth:int

the total width, in register-units, of the method's parameters

isStatic:boolean

true if this method has no this pointer argument

Returns:SsaMethod

output in SSA form

edgeSplitback to summary
private static void edgeSplit(SsaMethod result)

See Appel section 19.1: Converts CFG into "edge-split" form, such that each node either a unique successor or unique predecessor.

In addition, the SSA form we use enforces a further constraint, requiring each block with a final instruction that returns a value to have a primary successor that has no other predecessor. This ensures move statements can always be inserted correctly when phi statements are removed.

Parameters
result:SsaMethod

method to process

edgeSplitMoveExceptionsAndResultsback to summary
private static void edgeSplitMoveExceptionsAndResults(SsaMethod ssaMeth)

In ROP form, move-exception must occur as the first insn in a block immediately succeeding the insn that could thrown an exception. We may need room to insert move insns later, so make sure to split any block that starts with a move-exception such that there is a unique move-exception block for each predecessor.

Parameters
ssaMeth:SsaMethod

method to process

edgeSplitPredecessorsback to summary
private static void edgeSplitPredecessors(SsaMethod result)

Inserts Z nodes as new predecessors for every node that has multiple successors and multiple predecessors.

Parameters
result:SsaMethod

non-null; method to process

edgeSplitSuccessorsback to summary
private static void edgeSplitSuccessors(SsaMethod result)

Inserts Z nodes for every node that needs a new successor.

Parameters
result:SsaMethod

non-null; method to process

needsNewSuccessorback to summary
private static boolean needsNewSuccessor(SsaBasicBlock block, SsaBasicBlock succ)

Returns true if block and successor need a Z-node between them. Presently, this is true if the final instruction has any sources or results and the current successor block has more than one predecessor.

Parameters
block:SsaBasicBlock

predecessor node

succ:SsaBasicBlock

successor node

Returns:boolean

true if a Z node is needed

nodeNeedsUniquePredecessorback to summary
private static boolean nodeNeedsUniquePredecessor(SsaBasicBlock block)
Parameters
block:SsaBasicBlock

non-null; block in question

Returns:boolean

true if this node needs to have a unique predecessor created for it

placePhiFunctionsback to summary
private static void placePhiFunctions(SsaMethod ssaMeth, LocalVariableInfo localInfo, int threshold)

See Appel algorithm 19.6: Place Phi functions in appropriate locations.

Parameters
ssaMeth:SsaMethod

non-null; method to process. Modifications are made in-place.

localInfo:LocalVariableInfo

non-null; local variable info, used when placing phis

threshold:int

registers below this number are ignored

testEdgeSplitback to summary
public static SsaMethod testEdgeSplit(RopMethod rmeth, int paramWidth, boolean isStatic)

Returns an SSA represention with only the edge-splitter run.

Parameters
rmeth:RopMethod

method to process

paramWidth:int

width of all arguments in the method

isStatic:boolean

true if this method has no this pointer argument

Returns:SsaMethod

an SSA represention with only the edge-splitter run

testPhiPlacementback to summary
public static SsaMethod testPhiPlacement(RopMethod rmeth, int paramWidth, boolean isStatic)

Returns an SSA represention with only the steps through the phi placement run.

Parameters
rmeth:RopMethod

method to process

paramWidth:int

width of all arguments in the method

isStatic:boolean

true if this method has no this pointer argument

Returns:SsaMethod

an SSA represention with only the edge-splitter run

updateSsaMethodback to summary
public static void updateSsaMethod(SsaMethod ssaMeth, int threshold)

Updates an SSA representation, placing phi functions and renaming all registers above a certain threshold number.

Parameters
ssaMeth:SsaMethod

input

threshold:int

registers below this number are unchanged