use of org.apache.bcel.generic.InstructionHandle in project jop by jop-devel.
the class MethodCode method removeLineNumbers.
/**
* Remove all line numbers.
*/
public void removeLineNumbers() {
methodGen.removeLineNumbers();
// TODO should we do something about the CFG?
for (InstructionHandle ih : methodGen.getInstructionList().getInstructionHandles()) {
ih.removeAttribute(KEY_SOURCECLASS);
ih.removeAttribute(KEY_LINENUMBER);
}
}
use of org.apache.bcel.generic.InstructionHandle in project jop by jop-devel.
the class KeyManager method clearAllValues.
public void clearAllValues(CustomKey key, ClassInfo classInfo) {
boolean fromStruct = key.getType().isStruct();
boolean fromCode = key.getType().isCode();
if (fromStruct) {
classInfo.removeCustomValue(key);
for (FieldInfo field : classInfo.getFields()) {
field.removeCustomValue(key);
}
}
for (MethodInfo method : classInfo.getMethods()) {
if (fromStruct) {
method.removeCustomValue(key);
}
if (fromCode && method.hasCode()) {
MethodCode code = method.getCode();
InstructionList il = code.getInstructionList();
for (InstructionHandle ih : il.getInstructionHandles()) {
code.clearCustomKey(ih, key);
}
}
}
}
use of org.apache.bcel.generic.InstructionHandle in project jop by jop-devel.
the class MethodCode method getNumberOfBytes.
/**
* @see ProcessorModel#getNumberOfBytes(MethodInfo, Instruction)
* @param il the instruction list to get the size for
* @return the number of bytes for a given instruction list on the target.
*/
public int getNumberOfBytes(InstructionList il) {
int sum = 0;
ProcessorModel pm = getAppInfo().getProcessorModel();
for (InstructionHandle ih : il.getInstructionHandles()) {
sum += pm.getNumberOfBytes(methodInfo, ih.getInstruction());
}
return sum;
}
use of org.apache.bcel.generic.InstructionHandle in project jop by jop-devel.
the class ReplaceIinc method replace.
private void replace(MethodInfo method) {
MethodCode mc = method.getCode();
InstructionList il = mc.getInstructionList();
InstructionFinder f = new InstructionFinder(il);
for (Iterator i = f.search("IINC"); i.hasNext(); ) {
InstructionHandle[] match = (InstructionHandle[]) i.next();
InstructionHandle ih = match[0];
IINC ii = (IINC) ih.getInstruction();
int idx = ii.getIndex();
int inc = ii.getIncrement();
// IINC rep = new IINC(idx, inc);
ih.setInstruction(new ILOAD(idx));
if (inc >= -1 && inc <= 5) {
ih = il.append(ih, new ICONST(inc));
} else if (inc >= -128 && inc < 127) {
ih = il.append(ih, new BIPUSH((byte) inc));
} else if (inc >= -32768 && inc < 32767) {
ih = il.append(ih, new SIPUSH((short) inc));
} else {
System.out.println("IINC constant too big");
System.exit(-1);
}
ih = il.append(ih, new IADD());
ih = il.append(ih, new ISTORE(idx));
}
method.compile();
}
use of org.apache.bcel.generic.InstructionHandle in project jop by jop-devel.
the class DFATool method dumpDFA.
public String dumpDFA(MethodInfo method) {
if (getLoopBounds() == null)
return "n/a";
if (method.isAbstract()) {
return "n/a";
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream os = new PrintStream(baos);
Map<InstructionHandle, ContextMap<CallString, Pair<ValueMapping, ValueMapping>>> results = getLoopBounds().getResult();
if (results == null)
return "n/a";
AnalysisResultSerialization<Pair<ValueMapping, ValueMapping>> printer = new AnalysisResultSerialization<Pair<ValueMapping, ValueMapping>>();
for (Entry<InstructionHandle, ContextMap<CallString, Pair<ValueMapping, ValueMapping>>> ihEntry : results.entrySet()) {
for (Entry<CallString, Pair<ValueMapping, ValueMapping>> csEntry : ihEntry.getValue().entrySet()) {
if (ihEntry.getValue().getContext().getMethodInfo().equals(method)) {
printer.addResult(method, ihEntry.getKey().getPosition(), csEntry.getKey(), csEntry.getValue());
}
}
}
printer.dump(os);
try {
return baos.toString("UTF-8");
} catch (UnsupportedEncodingException e) {
return baos.toString();
}
}
Aggregations