in sdk/optimizationDetector/src/main/java/org/apache/teaclave/javasdk/tool/optimize/ECallInLoopDetector.java [74:95]
public static List<NodeSourcePosition> check(Method m) {
StructuredGraph graph = getGraph(m);
List<NodeSourcePosition> ret = new ArrayList<>();
ControlFlowGraph cfg = ControlFlowGraph.computeForSchedule(graph);
graph.getNodes(InvokeWithExceptionNode.TYPE).forEach(n -> {
Block block = cfg.blockFor(n);
if (block != null && block.getLoop() != null) {
ResolvedJavaMethod method = n.getTargetMethod();
if (isEnclaveService(method.getDeclaringClass())) {
ret.add(n.getNodeSourcePosition());
}
}
});
if (!ret.isEmpty()) {
int len = ret.size();
System.out.println("Detected " + len + " enclave service calls inside loop.");
for (int i = 0; i < len; i++) {
System.out.println((i + 1) + ". " + ret.get(i));
}
}
return ret;
}