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

public Class LiteralOpUpgrader

extends Object
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.code.*, org.droidparts.dexmaker.dx.rop.cst.Constant, .CstLiteralBits, org.droidparts.dexmaker.dx.rop.type.Type, .TypeBearer, java.util.ArrayList, .List

Upgrades insn to their literal (constant-immediate) equivalent if possible. Also switches IF instructions that compare with a constant zero or null to be their IF_*Z equivalents.

Field Summary

Modifier and TypeField and Description
private final SsaMethod
ssaMeth

method we're processing

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static boolean

Returns:

true for 0 or null type bearers
isConstIntZeroOrKnownNull
(RegisterSpec
non-null spec
spec
)

Returns true if the register contains an integer 0 or a known-null object reference

public static void
process(SsaMethod
non-null; method to process
ssaMethod
)

Process a method.

private void
replacePlainInsn(NormalSsaInsn
non-null; an SsaInsn containing a PlainInsn
insn
,
RegisterSpecList
non-null; new sources list for new insn
newSources
,
int
A RegOp from RegOps
newOpcode
,
Constant
null-ok; constant for new instruction, if any
cst
)

Replaces an SsaInsn containing a PlainInsn with a new PlainInsn.

private void
run()

Run the literal op upgrader

private boolean

Returns:

true if the instruction was replaced
tryReplacingWithConstant
(NormalSsaInsn
non-null; instruction to try to replace
insn
)

Tries to replace an instruction with a const instruction.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ssaMethback to summary
private final SsaMethod ssaMeth

method we're processing

Constructor Detail

LiteralOpUpgraderback to summary
private LiteralOpUpgrader(SsaMethod ssaMethod)

Method Detail

isConstIntZeroOrKnownNullback to summary
private static boolean isConstIntZeroOrKnownNull(RegisterSpec spec)

Returns true if the register contains an integer 0 or a known-null object reference

Parameters
spec:RegisterSpec

non-null spec

Returns:boolean

true for 0 or null type bearers

processback to summary
public static void process(SsaMethod ssaMethod)

Process a method.

Parameters
ssaMethod:SsaMethod

non-null; method to process

replacePlainInsnback to summary
private void replacePlainInsn(NormalSsaInsn insn, RegisterSpecList newSources, int newOpcode, Constant cst)

Replaces an SsaInsn containing a PlainInsn with a new PlainInsn. The new PlainInsn is constructed with a new RegOp and new sources. TODO move this somewhere else.

Parameters
insn:NormalSsaInsn

non-null; an SsaInsn containing a PlainInsn

newSources:RegisterSpecList

non-null; new sources list for new insn

newOpcode:int

A RegOp from RegOps

cst:Constant

null-ok; constant for new instruction, if any

runback to summary
private void run()

Run the literal op upgrader

tryReplacingWithConstantback to summary
private boolean tryReplacingWithConstant(NormalSsaInsn insn)

Tries to replace an instruction with a const instruction. The given instruction must have a constant result for it to be replaced.

Parameters
insn:NormalSsaInsn

non-null; instruction to try to replace

Returns:boolean

true if the instruction was replaced