speedup emulated method breakpoints

This commit is contained in:
Egor.Ushakov
2016-10-28 12:57:25 +03:00
parent 99041414ab
commit 83d6f2c59c
@@ -156,33 +156,35 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
for (Method method : classType.methods()) {
if (getMethodName().equals(method.name()) && mySignature.getName(debugProcess).equals(method.signature())) {
List<Location> allLineLocations = method.allLineLocations();
if (isWatchEntry()) {
createLocationBreakpointRequest(ContainerUtil.getFirstItem(allLineLocations), debugProcess);
}
if (isWatchExit()) {
MethodBytecodeUtil.visit(classType, method, new MethodVisitor(Opcodes.API_VERSION) {
int myLastLine = 0;
@Override
public void visitLineNumber(int line, Label start) {
myLastLine = line;
}
@Override
public void visitInsn(int opcode) {
switch (opcode) {
case Opcodes.RETURN:
case Opcodes.IRETURN:
case Opcodes.FRETURN:
case Opcodes.ARETURN:
case Opcodes.LRETURN:
case Opcodes.DRETURN:
//case Opcodes.ATHROW:
allLineLocations.stream()
.filter(l -> l.lineNumber() == myLastLine)
.findFirst().ifPresent(location -> createLocationBreakpointRequest(location, debugProcess));
if (!allLineLocations.isEmpty()) {
if (isWatchEntry()) {
createLocationBreakpointRequest(ContainerUtil.getFirstItem(allLineLocations), debugProcess);
}
if (isWatchExit()) {
MethodBytecodeUtil.visit(classType, method, new MethodVisitor(Opcodes.API_VERSION) {
int myLastLine = 0;
@Override
public void visitLineNumber(int line, Label start) {
myLastLine = line;
}
}
});
@Override
public void visitInsn(int opcode) {
switch (opcode) {
case Opcodes.RETURN:
case Opcodes.IRETURN:
case Opcodes.FRETURN:
case Opcodes.ARETURN:
case Opcodes.LRETURN:
case Opcodes.DRETURN:
//case Opcodes.ATHROW:
allLineLocations.stream()
.filter(l -> l.lineNumber() == myLastLine)
.findFirst().ifPresent(location -> createLocationBreakpointRequest(location, debugProcess));
}
}
});
}
}
if (base) {
// desired class found - now also track all new classes