mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[memory-agent] IDEA-209305 Delay between breakpoint triggering and UI responding
To avoid performance issues to check visibility of proxy class from a particular context, we load proxy class on each operation
This commit is contained in:
+12
-22
@@ -99,16 +99,13 @@ class MemoryAgentOperations {
|
||||
|
||||
private static ClassType getOrLoadProxyType(@NotNull EvaluationContextImpl evaluationContext) throws EvaluateException {
|
||||
ClassObjectReference classObjectReference = evaluationContext.computeAndKeep(() -> {
|
||||
ReferenceType referenceType = findProxy(evaluationContext);
|
||||
long start = System.currentTimeMillis();
|
||||
ReferenceType referenceType = loadUtilityClass(evaluationContext);
|
||||
if (referenceType == null) {
|
||||
long start = System.currentTimeMillis();
|
||||
referenceType = loadUtilityClass(evaluationContext);
|
||||
if (referenceType == null) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException("Could not load memory agent proxy class");
|
||||
}
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
LOG.info("Loading of agent proxy class took " + duration + " ms");
|
||||
throw EvaluateExceptionUtil.createEvaluateException("Could not load memory agent proxy class");
|
||||
}
|
||||
long duration = System.currentTimeMillis() - start;
|
||||
LOG.info("Loading of agent proxy class took " + duration + " ms");
|
||||
|
||||
return referenceType.classObject();
|
||||
});
|
||||
@@ -116,18 +113,6 @@ class MemoryAgentOperations {
|
||||
return (ClassType)classObjectReference.reflectedType();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ReferenceType findProxy(@NotNull EvaluationContextImpl evaluationContext) {
|
||||
DebugProcessImpl debugProcess = evaluationContext.getDebugProcess();
|
||||
|
||||
// We should use here this code to find proxy, but it will return nothing each time since we use newly created class loaded for every class loading
|
||||
//debugProcess.findClass(evaluationContext, MemoryAgentNames.PROXY_CLASS_NAME, evaluationContext.getClassLoader());
|
||||
|
||||
// But since we use only JDI to access static methods we do not bother about visibility issues
|
||||
List<ReferenceType> types = debugProcess.getVirtualMachineProxy().classesByName(MemoryAgentNames.PROXY_CLASS_NAME);
|
||||
return types.isEmpty() ? null : types.get(0);
|
||||
}
|
||||
|
||||
private static boolean checkAgentCapability(@NotNull EvaluationContextImpl evaluationContext,
|
||||
@NotNull ClassType proxyType,
|
||||
@NotNull String capabilityMethodName) {
|
||||
@@ -182,13 +167,18 @@ class MemoryAgentOperations {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ClassType loadUtilityClass(@NotNull EvaluationContextImpl context) throws EvaluateException {
|
||||
private static ReferenceType loadUtilityClass(@NotNull EvaluationContextImpl context) throws EvaluateException {
|
||||
DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
byte[] bytes = readUtilityClass();
|
||||
context.setAutoLoadClasses(true);
|
||||
ClassLoaderReference classLoader = ClassLoadingUtils.getClassLoader(context, debugProcess);
|
||||
ClassLoadingUtils.defineClass(MemoryAgentNames.PROXY_CLASS_NAME, bytes, context, debugProcess, classLoader);
|
||||
return (ClassType)debugProcess.findClass(context, MemoryAgentNames.PROXY_CLASS_NAME, classLoader);
|
||||
try {
|
||||
return debugProcess.loadClass(context, MemoryAgentNames.PROXY_CLASS_NAME, classLoader);
|
||||
}
|
||||
catch (InvocationException | ClassNotLoadedException | IncompatibleThreadStateException | InvalidTypeException e) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException("Could not load proxy class", e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user