use of co.paralleluniverse.fibers.Instrumented in project quasar by puniverse.
the class SuspendableHelper method isCallSiteInstrumented.
public static Pair<Boolean, Instrumented> isCallSiteInstrumented(/*Executable*/
Member m, int sourceLine, int bci, ExtendedStackTraceElement[] stes, int currentSteIdx) {
if (m == null)
return new Pair<>(false, null);
if (isSyntheticAndNotLambda(m))
return new Pair<>(true, null);
final ExtendedStackTraceElement calleeSte = currentSteIdx - 1 >= 0 ? stes[currentSteIdx - 1] : null;
if (calleeSte != null && // `verifySuspend` and `popMethod` calls are not suspendable call sites, not verifying them.
((calleeSte.getClassName().equals(Fiber.class.getName()) && calleeSte.getMethodName().equals("verifySuspend")) || (calleeSte.getClassName().equals(Stack.class.getName()) && calleeSte.getMethodName().equals("popMethod")))) {
return new Pair<>(true, null);
} else {
final Instrumented i = getAnnotation(m, Instrumented.class);
if (i != null) {
if (calleeSte != null && i.suspendableCallSiteNames() != null) {
final Member callee = calleeSte.getMethod();
if (callee == null) {
boolean ok = false;
final String methodName = "." + calleeSte.getMethodName() + "(";
for (String callsite : i.suspendableCallSiteNames()) {
if (callsite.contains(methodName)) {
ok = true;
break;
}
}
return new Pair(ok, i);
} else {
final String nameAndDescSuffix = "." + callee.getName() + ASMUtil.getDescriptor(callee);
boolean ok = false;
final String[] callsites = i.suspendableCallSiteNames();
for (String callsite : callsites) {
if (callsite.endsWith(nameAndDescSuffix)) {
Class<?> callsiteOwner = null;
try {
callsiteOwner = Class.forName(getCallsiteOwner(callsite));
} catch (ClassNotFoundException e) {
}
if (callsiteOwner != null) {
final Class<?> owner = callee.getDeclaringClass();
if (callsiteOwner.isAssignableFrom(owner)) {
ok = true;
break;
}
}
}
}
return new Pair(ok, i);
}
} else // }
if (sourceLine >= 0) {
final int[] scs = i.suspendableCallSites();
for (int j : scs) {
if (j == sourceLine)
return new Pair<>(true, i);
}
}
return new Pair<>(false, i);
}
return new Pair<>(false, null);
}
}
Aggregations