From 83d6f2c59c8569327c960d10871bce6fef0e161a Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 28 Oct 2016 12:53:51 +0300 Subject: [PATCH] speedup emulated method breakpoints --- .../ui/breakpoints/MethodBreakpoint.java | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java index 452c54a9f00f..07f418e52547 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java @@ -156,33 +156,35 @@ public class MethodBreakpoint extends BreakpointWithHighlighter 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