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

public Class PhiTypeResolver

extends Object
Class Inheritance
Imports
org.droidparts.dexmaker.dx.cf.code.Merger, org.droidparts.dexmaker.dx.rop.code.LocalItem, .RegisterSpec, .RegisterSpecList, org.droidparts.dexmaker.dx.rop.type.Type, .TypeBearer, java.util.BitSet, .List

Resolves the result types of phi instructions. When phi instructions are inserted, their result types are set to BT_VOID (which is a nonsensical type for a register) but must be resolve to a real type before converting out of SSA form.

The resolve is done as an iterative merge of each phi's operand types. Phi operands may be themselves be the result of unresolved phis, and the algorithm tries to find the most-fit type (for example, if every operand is the same constant value or the same local variable info, we want that to be reflected).

This algorithm assumes a dead-code remover has already removed all circular-only phis that may have been inserted.

Field Summary

Modifier and TypeField and Description
pack-priv SsaMethod
private final BitSet
worklist

indexed by register; all registers still defined by unresolved phis

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static boolean

Returns:

true if equal
equalsHandlesNulls
(LocalItem a, LocalItem b)

Returns true if a and b are equal, whether or not either of them are null.

public static void
process(SsaMethod
method to process
ssaMeth
)

Resolves all phi types in the method

pack-priv boolean

Returns:

true if the result type changed, false if no change
resolveResultType
(PhiInsn insn)

Resolves the result of a phi insn based on its operands.

private void
run()

Runs the phi-type resolver.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ssaMethback to summary
pack-priv SsaMethod ssaMeth
worklistback to summary
private final BitSet worklist

indexed by register; all registers still defined by unresolved phis

Constructor Detail

PhiTypeResolverback to summary
private PhiTypeResolver(SsaMethod ssaMeth)

Method Detail

equalsHandlesNullsback to summary
private static boolean equalsHandlesNulls(LocalItem a, LocalItem b)

Returns true if a and b are equal, whether or not either of them are null.

Returns:boolean

true if equal

processback to summary
public static void process(SsaMethod ssaMeth)

Resolves all phi types in the method

Parameters
ssaMeth:SsaMethod

method to process

resolveResultTypeback to summary
pack-priv boolean resolveResultType(PhiInsn insn)

Resolves the result of a phi insn based on its operands. The "void" type, which is a nonsensical type for a register, is used for registers defined by as-of-yet-unresolved phi operations.

Returns:boolean

true if the result type changed, false if no change

runback to summary
private void run()

Runs the phi-type resolver.