Java Code Examples for com.android.dx.rop.code.RegOps#MARK_LOCAL
The following examples show how to use
com.android.dx.rop.code.RegOps#MARK_LOCAL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NormalSsaInsn.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public RegisterSpec getLocalAssignment() { RegisterSpec assignment; if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { assignment = insn.getSources().get(0); } else { assignment = getResult(); } if (assignment == null) { return null; } LocalItem local = assignment.getLocalItem(); if (local == null) { return null; } return assignment; }
Example 2
Source File: SsaMethod.java From Box with Apache License 2.0 | 6 votes |
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
Example 3
Source File: NormalSsaInsn.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public RegisterSpec getLocalAssignment() { RegisterSpec assignment; if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { assignment = insn.getSources().get(0); } else { assignment = getResult(); } if (assignment == null) { return null; } LocalItem local = assignment.getLocalItem(); if (local == null) { return null; } return assignment; }
Example 4
Source File: SsaMethod.java From Box with Apache License 2.0 | 6 votes |
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
Example 5
Source File: NormalSsaInsn.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public RegisterSpec getLocalAssignment() { RegisterSpec assignment; if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { assignment = insn.getSources().get(0); } else { assignment = getResult(); } if (assignment == null) { return null; } LocalItem local = assignment.getLocalItem(); if (local == null) { return null; } return assignment; }
Example 6
Source File: SsaMethod.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
Example 7
Source File: NormalSsaInsn.java From buck with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public RegisterSpec getLocalAssignment() { RegisterSpec assignment; if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { assignment = insn.getSources().get(0); } else { assignment = getResult(); } if (assignment == null) { return null; } LocalItem local = assignment.getLocalItem(); if (local == null) { return null; } return assignment; }
Example 8
Source File: SsaMethod.java From buck with Apache License 2.0 | 6 votes |
/** * Checks to see if the given SSA reg is ever associated with a local * local variable. Each SSA reg may be associated with at most one * local var. * * @param spec {@code non-null;} ssa reg * @return true if reg is ever associated with a local */ public boolean isRegALocal(RegisterSpec spec) { SsaInsn defn = getDefinitionForRegister(spec.getReg()); if (defn == null) { // version 0 registers are never used as locals return false; } // Does the definition have a local associated with it? if (defn.getLocalAssignment() != null) return true; // If not, is there a mark-local insn? for (SsaInsn use : getUseListForRegister(spec.getReg())) { Insn insn = use.getOriginalRopInsn(); if (insn != null && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) { return true; } } return false; }
Example 9
Source File: RopTranslator.java From Box with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }
Example 10
Source File: EscapeAnalysis.java From Box with Apache License 2.0 | 4 votes |
/** * Replaces the use for a scalar replaceable array. Gets and puts become * move instructions, and array lengths and fills are handled. Can also * identify ArrayIndexOutOfBounds exceptions and throw them if detected. * * @param use {@code non-null;} move result instruction for array * @param prev {@code non-null;} instruction for instantiating new array * @param newRegs {@code non-null;} mapping of array indices to new * registers * @param deletedInsns {@code non-null;} set of instructions marked for * deletion */ private void replaceUse(SsaInsn use, SsaInsn prev, ArrayList<RegisterSpec> newRegs, HashSet<SsaInsn> deletedInsns) { int index; int length = newRegs.size(); SsaInsn next; RegisterSpecList sources; RegisterSpec source, result; CstLiteralBits indexReg; switch (use.getOpcode().getOpcode()) { case RegOps.AGET: // Replace array gets with moves next = getMoveForInsn(use); sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(1).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = newRegs.get(index); result = source.withReg(next.getResult().getReg()); insertPlainInsnBefore(next, RegisterSpecList.make(source), result, RegOps.MOVE, null); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(next, sources.get(1), deletedInsns); deletedInsns.add(next.getBlock().getInsns().get(2)); } deletedInsns.add(next); break; case RegOps.APUT: // Replace array puts with moves sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(2).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = sources.get(0); result = source.withReg(newRegs.get(index).getReg()); insertPlainInsnBefore(use, RegisterSpecList.make(source), result, RegOps.MOVE, null); // Update the newReg entry to mark value as unknown now newRegs.set(index, result.withSimpleType()); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(use, sources.get(2), deletedInsns); } break; case RegOps.ARRAY_LENGTH: // Replace array lengths with const instructions TypeBearer lengthReg = prev.getSources().get(0).getTypeBearer(); //CstInteger lengthReg = CstInteger.make(length); next = getMoveForInsn(use); insertPlainInsnBefore(next, RegisterSpecList.EMPTY, next.getResult(), RegOps.CONST, (Constant) lengthReg); deletedInsns.add(next); break; case RegOps.MARK_LOCAL: // Remove mark local instructions break; case RegOps.FILL_ARRAY_DATA: // Create const instructions for each fill value Insn ropUse = use.getOriginalRopInsn(); FillArrayDataInsn fill = (FillArrayDataInsn) ropUse; ArrayList<Constant> constList = fill.getInitValues(); for (int i = 0; i < length; i++) { RegisterSpec newFill = RegisterSpec.make(newRegs.get(i).getReg(), (TypeBearer) constList.get(i)); insertPlainInsnBefore(use, RegisterSpecList.EMPTY, newFill, RegOps.CONST, constList.get(i)); // Update the newRegs to hold the new const value newRegs.set(i, newFill); } break; default: } }
Example 11
Source File: RopTranslator.java From Box with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }
Example 12
Source File: EscapeAnalysis.java From Box with Apache License 2.0 | 4 votes |
/** * Replaces the use for a scalar replaceable array. Gets and puts become * move instructions, and array lengths and fills are handled. Can also * identify ArrayIndexOutOfBounds exceptions and throw them if detected. * * @param use {@code non-null;} move result instruction for array * @param prev {@code non-null;} instruction for instantiating new array * @param newRegs {@code non-null;} mapping of array indices to new * registers * @param deletedInsns {@code non-null;} set of instructions marked for * deletion */ private void replaceUse(SsaInsn use, SsaInsn prev, ArrayList<RegisterSpec> newRegs, HashSet<SsaInsn> deletedInsns) { int index; int length = newRegs.size(); SsaInsn next; RegisterSpecList sources; RegisterSpec source, result; CstLiteralBits indexReg; switch (use.getOpcode().getOpcode()) { case RegOps.AGET: // Replace array gets with moves next = getMoveForInsn(use); sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(1).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = newRegs.get(index); result = source.withReg(next.getResult().getReg()); insertPlainInsnBefore(next, RegisterSpecList.make(source), result, RegOps.MOVE, null); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(next, sources.get(1), deletedInsns); deletedInsns.add(next.getBlock().getInsns().get(2)); } deletedInsns.add(next); break; case RegOps.APUT: // Replace array puts with moves sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(2).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = sources.get(0); result = source.withReg(newRegs.get(index).getReg()); insertPlainInsnBefore(use, RegisterSpecList.make(source), result, RegOps.MOVE, null); // Update the newReg entry to mark value as unknown now newRegs.set(index, result.withSimpleType()); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(use, sources.get(2), deletedInsns); } break; case RegOps.ARRAY_LENGTH: // Replace array lengths with const instructions TypeBearer lengthReg = prev.getSources().get(0).getTypeBearer(); //CstInteger lengthReg = CstInteger.make(length); next = getMoveForInsn(use); insertPlainInsnBefore(next, RegisterSpecList.EMPTY, next.getResult(), RegOps.CONST, (Constant) lengthReg); deletedInsns.add(next); break; case RegOps.MARK_LOCAL: // Remove mark local instructions break; case RegOps.FILL_ARRAY_DATA: // Create const instructions for each fill value Insn ropUse = use.getOriginalRopInsn(); FillArrayDataInsn fill = (FillArrayDataInsn) ropUse; ArrayList<Constant> constList = fill.getInitValues(); for (int i = 0; i < length; i++) { RegisterSpec newFill = RegisterSpec.make(newRegs.get(i).getReg(), (TypeBearer) constList.get(i)); insertPlainInsnBefore(use, RegisterSpecList.EMPTY, newFill, RegOps.CONST, constList.get(i)); // Update the newRegs to hold the new const value newRegs.set(i, newFill); } break; default: } }
Example 13
Source File: RopTranslator.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }
Example 14
Source File: EscapeAnalysis.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** * Replaces the use for a scalar replaceable array. Gets and puts become * move instructions, and array lengths and fills are handled. Can also * identify ArrayIndexOutOfBounds exceptions and throw them if detected. * * @param use {@code non-null;} move result instruction for array * @param prev {@code non-null;} instruction for instantiating new array * @param newRegs {@code non-null;} mapping of array indices to new * registers * @param deletedInsns {@code non-null;} set of instructions marked for * deletion */ private void replaceUse(SsaInsn use, SsaInsn prev, ArrayList<RegisterSpec> newRegs, HashSet<SsaInsn> deletedInsns) { int index; int length = newRegs.size(); SsaInsn next; RegisterSpecList sources; RegisterSpec source, result; CstLiteralBits indexReg; switch (use.getOpcode().getOpcode()) { case RegOps.AGET: // Replace array gets with moves next = getMoveForInsn(use); sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(1).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = newRegs.get(index); result = source.withReg(next.getResult().getReg()); insertPlainInsnBefore(next, RegisterSpecList.make(source), result, RegOps.MOVE, null); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(next, sources.get(1), deletedInsns); deletedInsns.add(next.getBlock().getInsns().get(2)); } deletedInsns.add(next); break; case RegOps.APUT: // Replace array puts with moves sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(2).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = sources.get(0); result = source.withReg(newRegs.get(index).getReg()); insertPlainInsnBefore(use, RegisterSpecList.make(source), result, RegOps.MOVE, null); // Update the newReg entry to mark value as unknown now newRegs.set(index, result.withSimpleType()); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(use, sources.get(2), deletedInsns); } break; case RegOps.ARRAY_LENGTH: // Replace array lengths with const instructions TypeBearer lengthReg = prev.getSources().get(0).getTypeBearer(); //CstInteger lengthReg = CstInteger.make(length); next = getMoveForInsn(use); insertPlainInsnBefore(next, RegisterSpecList.EMPTY, next.getResult(), RegOps.CONST, (Constant) lengthReg); deletedInsns.add(next); break; case RegOps.MARK_LOCAL: // Remove mark local instructions break; case RegOps.FILL_ARRAY_DATA: // Create const instructions for each fill value Insn ropUse = use.getOriginalRopInsn(); FillArrayDataInsn fill = (FillArrayDataInsn) ropUse; ArrayList<Constant> constList = fill.getInitValues(); for (int i = 0; i < length; i++) { RegisterSpec newFill = RegisterSpec.make(newRegs.get(i).getReg(), (TypeBearer) constList.get(i)); insertPlainInsnBefore(use, RegisterSpecList.EMPTY, newFill, RegOps.CONST, constList.get(i)); // Update the newRegs to hold the new const value newRegs.set(i, newFill); } break; default: } }
Example 15
Source File: RopTranslator.java From buck with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void visitPlainInsn(PlainInsn insn) { Rop rop = insn.getOpcode(); if (rop.getOpcode() == RegOps.MARK_LOCAL) { /* * Ignore these. They're dealt with by * the LocalVariableAwareTranslationVisitor */ return; } if (rop.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) { // These get skipped return; } SourcePosition pos = insn.getPosition(); Dop opcode = RopToDop.dopFor(insn); DalvInsn di; switch (rop.getBranchingness()) { case Rop.BRANCH_NONE: case Rop.BRANCH_RETURN: case Rop.BRANCH_THROW: { di = new SimpleInsn(opcode, pos, getRegs(insn)); break; } case Rop.BRANCH_GOTO: { /* * Code in the main translation loop will emit a * goto if necessary (if the branch isn't to the * immediately subsequent block). */ return; } case Rop.BRANCH_IF: { int target = block.getSuccessors().get(1); di = new TargetInsn(opcode, pos, getRegs(insn), addresses.getStart(target)); break; } default: { throw new RuntimeException("shouldn't happen"); } } addOutput(di); }
Example 16
Source File: EscapeAnalysis.java From buck with Apache License 2.0 | 4 votes |
/** * Replaces the use for a scalar replaceable array. Gets and puts become * move instructions, and array lengths and fills are handled. Can also * identify ArrayIndexOutOfBounds exceptions and throw them if detected. * * @param use {@code non-null;} move result instruction for array * @param prev {@code non-null;} instruction for instantiating new array * @param newRegs {@code non-null;} mapping of array indices to new * registers * @param deletedInsns {@code non-null;} set of instructions marked for * deletion */ private void replaceUse(SsaInsn use, SsaInsn prev, ArrayList<RegisterSpec> newRegs, HashSet<SsaInsn> deletedInsns) { int index; int length = newRegs.size(); SsaInsn next; RegisterSpecList sources; RegisterSpec source, result; CstLiteralBits indexReg; switch (use.getOpcode().getOpcode()) { case RegOps.AGET: // Replace array gets with moves next = getMoveForInsn(use); sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(1).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = newRegs.get(index); result = source.withReg(next.getResult().getReg()); insertPlainInsnBefore(next, RegisterSpecList.make(source), result, RegOps.MOVE, null); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(next, sources.get(1), deletedInsns); deletedInsns.add(next.getBlock().getInsns().get(2)); } deletedInsns.add(next); break; case RegOps.APUT: // Replace array puts with moves sources = use.getSources(); indexReg = ((CstLiteralBits) sources.get(2).getTypeBearer()); index = indexReg.getIntBits(); if (index < length) { source = sources.get(0); result = source.withReg(newRegs.get(index).getReg()); insertPlainInsnBefore(use, RegisterSpecList.make(source), result, RegOps.MOVE, null); // Update the newReg entry to mark value as unknown now newRegs.set(index, result.withSimpleType()); } else { // Throw an exception if the index is out of bounds insertExceptionThrow(use, sources.get(2), deletedInsns); } break; case RegOps.ARRAY_LENGTH: // Replace array lengths with const instructions TypeBearer lengthReg = prev.getSources().get(0).getTypeBearer(); //CstInteger lengthReg = CstInteger.make(length); next = getMoveForInsn(use); insertPlainInsnBefore(next, RegisterSpecList.EMPTY, next.getResult(), RegOps.CONST, (Constant) lengthReg); deletedInsns.add(next); break; case RegOps.MARK_LOCAL: // Remove mark local instructions break; case RegOps.FILL_ARRAY_DATA: // Create const instructions for each fill value Insn ropUse = use.getOriginalRopInsn(); FillArrayDataInsn fill = (FillArrayDataInsn) ropUse; ArrayList<Constant> constList = fill.getInitValues(); for (int i = 0; i < length; i++) { RegisterSpec newFill = RegisterSpec.make(newRegs.get(i).getReg(), (TypeBearer) constList.get(i)); insertPlainInsnBefore(use, RegisterSpecList.EMPTY, newFill, RegOps.CONST, constList.get(i)); // Update the newRegs to hold the new const value newRegs.set(i, newFill); } break; default: } }