本文整理汇总了Java中com.android.dx.rop.code.RopMethod类的典型用法代码示例。如果您正苦于以下问题:Java RopMethod类的具体用法?Java RopMethod怎么用?Java RopMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RopMethod类属于com.android.dx.rop.code包,在下文中一共展示了RopMethod类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupArrays
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Sets up the address arrays.
*/
private void setupArrays(RopMethod method) {
BasicBlockList blocks = method.getBlocks();
int sz = blocks.size();
for (int i = 0; i < sz; i++) {
BasicBlock one = blocks.get(i);
int label = one.getLabel();
Insn insn = one.getInsns().get(0);
starts[label] = new CodeAddress(insn.getPosition());
SourcePosition pos = one.getLastInsn().getPosition();
lasts[label] = new CodeAddress(pos);
ends[label] = new CodeAddress(pos);
}
}
示例2: StdCatchBuilder
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Constructs an instance. It merely holds onto its parameters for
* a subsequent call to {@link #build}.
*
* @param method {@code non-null;} method to build the list for
* @param order {@code non-null;} block output order
* @param addresses {@code non-null;} address objects for each block
*/
public StdCatchBuilder(RopMethod method, int[] order,
BlockAddresses addresses) {
if (method == null) {
throw new NullPointerException("method == null");
}
if (order == null) {
throw new NullPointerException("order == null");
}
if (addresses == null) {
throw new NullPointerException("addresses == null");
}
this.method = method;
this.order = order;
this.addresses = addresses;
}
示例3: updateRopStatistics
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Updates the ROP statistics.
*
* @param nonOptRmeth non-optimized method
* @param rmeth optimized method
*/
public static void updateRopStatistics(RopMethod nonOptRmeth,
RopMethod rmeth) {
int oldCountInsns
= nonOptRmeth.getBlocks().getEffectiveInstructionCount();
int oldCountRegs = nonOptRmeth.getBlocks().getRegCount();
if (DEBUG) {
System.err.println("insns (old/new): "
+ oldCountInsns + "/"
+ rmeth.getBlocks().getEffectiveInstructionCount()
+ " regs (o/n):" + oldCountRegs
+ "/" + rmeth.getBlocks().getRegCount());
}
int newCountInsns
= rmeth.getBlocks().getEffectiveInstructionCount();
runningDeltaInsns
+= (newCountInsns - oldCountInsns);
runningDeltaRegisters
+= (rmeth.getBlocks().getRegCount() - oldCountRegs);
runningTotalInsns += newCountInsns;
}
示例4: getRopMethod
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Extracts the resulting {@link RopMethod} from the instance.
*
* @return {@code non-null;} the method object
*/
private RopMethod getRopMethod() {
// Construct the final list of blocks.
int sz = result.size();
BasicBlockList bbl = new BasicBlockList(sz);
for (int i = 0; i < sz; i++) {
bbl.set(i, result.get(i));
}
bbl.setImmutable();
// Construct the method object to wrap it all up.
/*
* Note: The parameter assignment block is always the first
* that should be executed, hence the second argument to the
* constructor.
*/
return new RopMethod(bbl, getSpecialLabel(PARAM_ASSIGNMENT));
}
示例5: convertToSsaMethod
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Returns an SSA representation, edge-split and with phi
* functions placed.
*
* @param rmeth input
* @param paramWidth the total width, in register-units, of the method's
* parameters
* @param isStatic {@code true} if this method has no {@code this}
* pointer argument
* @return output in SSA form
*/
public static SsaMethod convertToSsaMethod(RopMethod rmeth,
int paramWidth, boolean isStatic) {
SsaMethod result
= SsaMethod.newFromRopMethod(rmeth, paramWidth, isStatic);
edgeSplit(result);
LocalVariableInfo localInfo = LocalVariableExtractor.extract(result);
placePhiFunctions(result, localInfo, 0);
new SsaRenamer(result).run();
/*
* The exit block, added here, is not considered for edge splitting
* or phi placement since no actual control flows to it.
*/
result.makeExitBlock();
return result;
}
示例6: optimize
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Runs optimization algorthims over this method, and returns a new
* instance of RopMethod with the changes.
*
* @param rmeth method to process
* @param paramWidth the total width, in register-units, of this method's
* parameters
* @param isStatic true if this method has no 'this' pointer argument.
* @param inPreserveLocals true if local variable info should be preserved,
* at the cost of some registers and insns
* @param inAdvice {@code non-null;} translation advice
* @param steps set of optional optimization steps to run
* @return optimized method
*/
public static RopMethod optimize(RopMethod rmeth, int paramWidth,
boolean isStatic, boolean inPreserveLocals,
TranslationAdvice inAdvice, EnumSet<OptionalStep> steps) {
SsaMethod ssaMeth = null;
preserveLocals = inPreserveLocals;
advice = inAdvice;
ssaMeth = SsaConverter.convertToSsaMethod(rmeth, paramWidth, isStatic);
runSsaFormSteps(ssaMeth, steps);
RopMethod resultMeth = SsaToRop.convertToRopMethod(ssaMeth, false);
if (resultMeth.getBlocks().getRegCount()
> advice.getMaxOptimalRegisterCount()) {
// Try to see if we can squeeze it under the register count bar
resultMeth = optimizeMinimizeRegisters(rmeth, paramWidth, isStatic,
steps);
}
return resultMeth;
}
示例7: optimizeMinimizeRegisters
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Runs the optimizer with a strategy to minimize the number of rop-form
* registers used by the end result. Dex bytecode does not have instruction
* forms that take register numbers larger than 15 for all instructions.
* If we've produced a method that uses more than 16 registers, try again
* with a different strategy to see if we can get under the bar. The end
* result will be much more efficient.
*
* @param rmeth method to process
* @param paramWidth the total width, in register-units, of this method's
* parameters
* @param isStatic true if this method has no 'this' pointer argument.
* @param steps set of optional optimization steps to run
* @return optimized method
*/
private static RopMethod optimizeMinimizeRegisters(RopMethod rmeth,
int paramWidth, boolean isStatic,
EnumSet<OptionalStep> steps) {
SsaMethod ssaMeth;
RopMethod resultMeth;
ssaMeth = SsaConverter.convertToSsaMethod(
rmeth, paramWidth, isStatic);
EnumSet<OptionalStep> newSteps = steps.clone();
/*
* CONST_COLLECTOR trades insns for registers, which is not an
* appropriate strategy here.
*/
newSteps.remove(OptionalStep.CONST_COLLECTOR);
runSsaFormSteps(ssaMeth, newSteps);
resultMeth = SsaToRop.convertToRopMethod(ssaMeth, true);
return resultMeth;
}
示例8: convertRopToSsaBlocks
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
private void convertRopToSsaBlocks(RopMethod rmeth) {
BasicBlockList ropBlocks = rmeth.getBlocks();
int sz = ropBlocks.size();
blocks = new ArrayList<SsaBasicBlock>(sz + 2);
for (int i = 0; i < sz; i++) {
SsaBasicBlock sbb = SsaBasicBlock.newFromRop(rmeth, i, this);
blocks.add(sbb);
}
// Add an no-op entry block.
int origEntryBlockIndex = rmeth.getBlocks()
.indexOfLabel(rmeth.getFirstLabel());
SsaBasicBlock entryBlock
= blocks.get(origEntryBlockIndex).insertNewPredecessor();
entryBlockIndex = entryBlock.getIndex();
exitBlockIndex = -1; // This gets made later.
}
示例9: getCode
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Extracts the code block from the given method of the given class, or
* <code>null</code>, if method is native or abstract.
*/
private static DalvCode getCode(Method method, DirectClassFile classFile) {
boolean isNative = AccessFlags.isNative(method.getAccessFlags());
boolean isStatic = AccessFlags.isStatic(method.getAccessFlags());
boolean isAbstract = AccessFlags.isAbstract(method.getAccessFlags());
if (isNative || isAbstract) {
return null;
}
ConcreteMethod concrete = new ConcreteMethod(method, classFile, false, false);
TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
RopMethod rmeth = Ropper.convert(concrete, advice);
CstMethodRef meth = new CstMethodRef(method.getDefiningClass(), method.getNat());
int paramSize = meth.getParameterWordCount(isStatic);
DalvCode code = RopTranslator.translate(rmeth, PositionList.NONE, null, paramSize);
DalvCode.AssignIndicesCallback callback = new DalvCode.AssignIndicesCallback() {
public int getIndex(Constant cst) {
// Everything is at index 0!
return 0;
}
};
code.assignIndices(callback);
return code;
}
示例10: updateRopStatistics
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Updates the ROP statistics.
*
* @param nonOptRmeth non-optimized method
* @param rmeth optimized method
*/
public void updateRopStatistics(RopMethod nonOptRmeth,
RopMethod rmeth) {
int oldCountInsns
= nonOptRmeth.getBlocks().getEffectiveInstructionCount();
int oldCountRegs = nonOptRmeth.getBlocks().getRegCount();
if (DEBUG) {
System.err.println("insns (old/new): "
+ oldCountInsns + "/"
+ rmeth.getBlocks().getEffectiveInstructionCount()
+ " regs (o/n):" + oldCountRegs
+ "/" + rmeth.getBlocks().getRegCount());
}
int newCountInsns
= rmeth.getBlocks().getEffectiveInstructionCount();
runningDeltaInsns
+= (newCountInsns - oldCountInsns);
runningDeltaRegisters
+= (rmeth.getBlocks().getRegCount() - oldCountRegs);
runningTotalInsns += newCountInsns;
}
示例11: convertToSsaMethod
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Returns an SSA representation, edge-split and with phi
* functions placed.
*
* @param rmeth input
* @param paramWidth the total width, in register-units, of the method's
* parameters
* @param isStatic {@code true} if this method has no {@code this}
* pointer argument
* @return output in SSA form
*/
public static SsaMethod convertToSsaMethod(Optimizer optimizer, RopMethod rmeth,
int paramWidth, boolean isStatic) {
SsaMethod result
= SsaMethod.newFromRopMethod(rmeth, paramWidth, isStatic);
edgeSplit(result);
LocalVariableInfo localInfo = LocalVariableExtractor.extract(result);
placePhiFunctions(result, localInfo, 0);
new SsaRenamer(optimizer, result).run();
/*
* The exit block, added here, is not considered for edge splitting
* or phi placement since no actual control flows to it.
*/
result.makeExitBlock();
return result;
}
示例12: optimize
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Runs optimization algorthims over this method, and returns a new
* instance of RopMethod with the changes.
*
* @param rmeth method to process
* @param paramWidth the total width, in register-units, of this method's
* parameters
* @param isStatic true if this method has no 'this' pointer argument.
* @param inPreserveLocals true if local variable info should be preserved,
* at the cost of some registers and insns
* @param inAdvice {@code non-null;} translation advice
* @param steps set of optional optimization steps to run
* @return optimized method
*/
public RopMethod optimize(RopMethod rmeth, int paramWidth,
boolean isStatic, boolean inPreserveLocals,
TranslationAdvice inAdvice, EnumSet<OptionalStep> steps) {
SsaMethod ssaMeth = null;
preserveLocals = inPreserveLocals;
advice = inAdvice;
ssaMeth = SsaConverter.convertToSsaMethod(this, rmeth, paramWidth, isStatic);
runSsaFormSteps(ssaMeth, steps);
RopMethod resultMeth = SsaToRop.convertToRopMethod(this, ssaMeth, false);
if (resultMeth.getBlocks().getRegCount()
> advice.getMaxOptimalRegisterCount()) {
// Try to see if we can squeeze it under the register count bar
resultMeth = optimizeMinimizeRegisters(rmeth, paramWidth, isStatic,
steps);
}
return resultMeth;
}
示例13: optimizeMinimizeRegisters
import com.android.dx.rop.code.RopMethod; //导入依赖的package包/类
/**
* Runs the optimizer with a strategy to minimize the number of rop-form
* registers used by the end result. Dex bytecode does not have instruction
* forms that take register numbers larger than 15 for all instructions.
* If we've produced a method that uses more than 16 registers, try again
* with a different strategy to see if we can get under the bar. The end
* result will be much more efficient.
*
* @param rmeth method to process
* @param paramWidth the total width, in register-units, of this method's
* parameters
* @param isStatic true if this method has no 'this' pointer argument.
* @param steps set of optional optimization steps to run
* @return optimized method
*/
private RopMethod optimizeMinimizeRegisters(RopMethod rmeth,
int paramWidth, boolean isStatic,
EnumSet<OptionalStep> steps) {
SsaMethod ssaMeth;
RopMethod resultMeth;
ssaMeth = SsaConverter.convertToSsaMethod(
this, rmeth, paramWidth, isStatic);
EnumSet<OptionalStep> newSteps = steps.clone();
/*
* CONST_COLLECTOR trades insns for registers, which is not an
* appropriate strategy here.
*/
newSteps.remove(OptionalStep.CONST_COLLECTOR);
runSsaFormSteps(ssaMeth, newSteps);
resultMeth = SsaToRop.convertToRopMethod(this, ssaMeth, true);
return resultMeth;
}