adding support for the dynamic call graph experiments

currentSite should be ThreadLocal because not having this screws up a lot of the instrumentation-based dynamic call graphs we generate for the shootout benchmarks.

I have also conditionally changed how the string of the currentSite is created based on the output format that Julian came up with for the dynamic call graph. This support is necessary, because the Java std libraries are not instrumented. Therefore, they would appear as if calls from them show up from nowhere in the log that WALA generates for the dynamic call graph. This fix make those calls originate from a fake library BLOB node in the call graph.
This commit is contained in:
Karim Ali 2017-10-23 17:54:01 -06:00
parent d22ee36b09
commit 423db824b3
1 changed files with 10 additions and 7 deletions

View File

@ -53,7 +53,7 @@ public class Runtime {
private PrintWriter output;
private SetOfClasses filter;
private Policy handleCallback;
private String currentSite;
private ThreadLocal<String> currentSite = new ThreadLocal<>();
private ThreadLocal<Stack<String>> callStacks = new ThreadLocal<Stack<String>>() {
@ -120,7 +120,7 @@ public class Runtime {
}
public static void execution(String klass, String method, Object receiver) {
runtime.currentSite = null;
runtime.currentSite.set(null);
if (runtime.filter == null || ! runtime.filter.contains(bashToDescriptor(klass))) {
if (runtime.output != null) {
String caller = runtime.callStacks.get().peek();
@ -164,23 +164,26 @@ public class Runtime {
}
public static void pop() {
if (runtime.currentSite != null) {
if (runtime.currentSite.get() != null) {
synchronized (runtime) {
if (runtime.output != null) {
runtime.output.printf("return from " + runtime.currentSite + "\n");
runtime.output.printf("return from " + runtime.currentSite.get() + "\n");
runtime.output.flush();
}
}
runtime.currentSite = null;
runtime.currentSite.set(null);
}
}
public static void addToCallStack(String klass, String method, Object receiver) {
runtime.currentSite = klass + "\t" + method + "\t" + receiver;
String callerClass = runtime.callStacks.get().isEmpty() ? "BLOB" : runtime.callStacks.get().peek().split("\t")[0];
String callerMethod = runtime.callStacks.get().isEmpty() ? "BLOB" : runtime.callStacks.get().peek().split("\t")[1];
runtime.currentSite.set(callerClass + "\t" + callerMethod + "\t" + klass + "\t" + method + "\t" + receiver);
// runtime.currentSite = klass + "\t" + method + "\t" + receiver;
synchronized (runtime) {
if (runtime.output != null) {
runtime.output.printf("call to " + runtime.currentSite + "\n");
runtime.output.printf("call to " + runtime.currentSite.get() + "\n");
runtime.output.flush();
}
}