Too tired to write descriptive message
This commit is contained in:
parent
6f3012cf9e
commit
a78c260dbf
5 changed files with 14 additions and 11 deletions
2
DiSLProject2022/source.sh
Normal file
2
DiSLProject2022/source.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home"
|
|
@ -2,11 +2,13 @@ package ex2;
|
|||
|
||||
import ch.usi.dag.disl.annotation.GuardMethod;
|
||||
import ch.usi.dag.disl.staticcontext.ClassStaticContext;
|
||||
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
|
||||
|
||||
public class IsNotTriviallyThreadGuard {
|
||||
|
||||
@GuardMethod
|
||||
public static boolean isNotTriviallyThread(final ClassStaticContext csc) {
|
||||
return !IsTriviallyThreadGuard.isThread(csc);
|
||||
public static boolean isNotTriviallyThread(final ClassStaticContext csc, final MethodStaticContext msc) {
|
||||
return !msc.isMethodStatic() && !IsTriviallyThreadGuard.isThread(csc, msc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package ex2;
|
||||
|
||||
import ch.usi.dag.disl.annotation.GuardMethod;
|
||||
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
|
||||
import ch.usi.dag.disl.staticcontext.ClassStaticContext;
|
||||
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
|
||||
|
||||
public class IsTriviallyThreadGuard {
|
||||
@GuardMethod
|
||||
public static boolean isThread(ClassStaticContext csc) {
|
||||
return csc.getInternalName().equals("java/lang/Thread") ||
|
||||
csc.getSuperClassInternalName().equals("java/lang/Thread");
|
||||
public static boolean isThread(final ClassStaticContext csc, final MethodStaticContext msc) {
|
||||
return !msc.isMethodStatic() && (csc.getInternalName().equals("java/lang/Thread") ||
|
||||
csc.getSuperClassInternalName().equals("java/lang/Thread"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,12 @@ package ex2;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
public final class Profiler {
|
||||
|
||||
// not concurrent on purpose, since the value of the map is computed with a pure function
|
||||
// on the map key, and thus we don't care if the value is overwritten as a result of a
|
||||
// race condition
|
||||
private static final Map<Class<?>, Boolean> isThread = new HashMap<>();
|
||||
private static final Map<Class<?>, Boolean> isThread = new ConcurrentHashMap<>();
|
||||
|
||||
private static final LongAdder reads = new LongAdder();
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@ package ex3;
|
|||
import ch.usi.dag.disl.annotation.Before;
|
||||
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
|
||||
import ch.usi.dag.disl.marker.BytecodeMarker;
|
||||
import ch.usi.dag.disl.staticcontext.InstructionStaticContext;
|
||||
|
||||
public class Instrumentation {
|
||||
@Before(marker = BytecodeMarker.class, args = "astore", scope = "ex3.MainThread.checkAccess")
|
||||
static void printVariable(final InstructionStaticContext isc, final DynamicContext dc) {
|
||||
static void printVariable(final DynamicContext dc) {
|
||||
if ("granted".equals(dc.getStackValue(0, Object.class))) {
|
||||
System.out.printf("Thread: %s\n", Thread.currentThread().getName());
|
||||
}
|
||||
|
|
Reference in a new issue