use of com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException in project fb-contrib by mebigfatguy.
the class PossibleMemoryBloat method removeFieldsThatGetReturned.
protected void removeFieldsThatGetReturned() {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item returnItem = stack.getStackItem(0);
XField field = returnItem.getXField();
if (field != null) {
bloatableCandidates.remove(field);
bloatableFields.remove(field);
if (bloatableCandidates.isEmpty()) {
throw new StopOpcodeParsingException();
}
}
}
}
use of com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException in project fb-contrib by mebigfatguy.
the class PossibleMemoryBloat method visitClassContext.
/**
* collects static fields that are likely bloatable objects and if found allows the visitor to proceed, at the end report all leftover fields
*
* @param classContext
* the class context object of the currently parsed java class
*/
@Override
public void visitClassContext(ClassContext classContext) {
try {
bloatableCandidates = new HashMap<>();
bloatableFields = new HashMap<>();
threadLocalNonStaticFields = new HashSet<>();
parseFields(classContext);
if (!bloatableCandidates.isEmpty()) {
stack = new OpcodeStack();
super.visitClassContext(classContext);
reportMemoryBloatBugs();
reportThreadLocalBugs();
}
} catch (StopOpcodeParsingException e) {
// no more bloatable candidates
} finally {
stack = null;
bloatableCandidates = null;
bloatableFields = null;
threadLocalNonStaticFields = null;
}
}
use of com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException in project fb-contrib by mebigfatguy.
the class SluggishGui method visitAfter.
/**
* overrides the visitor to visit all of the collected listener methods
*
* @param obj
* the context object of the currently parsed class
*/
@Override
public void visitAfter(JavaClass obj) {
isListenerMethod = true;
for (Code l : listenerCode.keySet()) {
try {
super.visitCode(l);
} catch (StopOpcodeParsingException e) {
// method already reported
}
}
super.visitAfter(obj);
}
use of com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException in project fb-contrib by mebigfatguy.
the class SluggishGui method visitCode.
/**
* overrides the visitor to segregate method into two, those that implement listeners, and those that don't. The ones that don't are processed first.
*
* @param obj
* the context object of the currently parsed code block
*/
@Override
public void visitCode(Code obj) {
try {
for (JavaClass inf : guiInterfaces) {
Method[] methods = inf.getMethods();
for (Method m : methods) {
if (m.getName().equals(methodName) && m.getSignature().equals(methodSig)) {
listenerCode.put(obj, this.getMethod());
return;
}
}
}
isListenerMethod = false;
super.visitCode(obj);
} catch (StopOpcodeParsingException e) {
// method already reported
}
}
use of com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException in project fb-contrib by mebigfatguy.
the class TristateBooleanPattern method visitCode.
/**
* implements the visitor to filter out methods that don't return Boolean,
*
* @param obj
* the context object for the currently parsed code block
*/
@Override
public void visitCode(Code obj) {
try {
Method m = getMethod();
Type retType = m.getReturnType();
if ("Ljava/lang/Boolean;".equals(retType.getSignature())) {
stack.resetForMethodEntry(this);
super.visitCode(obj);
}
} catch (StopOpcodeParsingException e) {
// if the method was already reported
}
}
Aggregations