Commit 172b3b53 authored by Lukáš Marek's avatar Lukáš Marek
Browse files

Removed all runDacapo script

Improved processor test
Redone args test
parent ca9d44a1
# /bin/sh
echo "RUNNING DACAPO BENCH $1"
java -javaagent:../lib/jborat-agent.jar -Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" -Dch.usi.dag.jborat.liblist="conf/lib.lst" -Dch.usi.dag.jborat.instrumentation="ch.usi.dag.disl.DiSL" -Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" -Dch.usi.dag.jborat.uninstrumented="uninstrumented" -Dch.usi.dag.jborat.instrumented="instrumented" -Xbootclasspath/p:lib/Thread_test.jar:lib/test-runtime.jar:../lib/jborat-runtime.jar -Ddisl.dynbypass=yes -Ddisl.analysis.umidfile="dico.log" -cp "./bin/" -jar dacapo-9.12-bach.jar --no-validation $1 $2 $3
......@@ -2,6 +2,7 @@ package ch.usi.dag.disl.test.after2;
public class TargetClass {
public static void main(String[] args) {
// NOTE: this test is better to use on large project and not this simple class
System.out.println("TargetClass.test");
}
}
package ch.usi.dag.disl.test.args;
import org.objectweb.asm.Type;
import ch.usi.dag.disl.staticcontext.AbstractStaticContext;
public class ArgsAnalysis extends AbstractStaticContext {
public int getNumberOfArgs() {
return Type.getArgumentTypes(staticContextData.getMethodNode().desc).length;
}
}
package ch.usi.dag.disl.test.args;
import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.SyntheticLocal;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.processorcontext.ProcessorContext;
import ch.usi.dag.disl.processorcontext.ProcessorMode;
import ch.usi.dag.disl.staticcontext.MethodSC;
// This example shows how to emulate AspectJ's thisJoinPoint.getArgs()
public class DiSLClass {
@SyntheticLocal
public static Object[] args;
@Before(marker = BodyMarker.class, scope = "*.*", guard = HasArgsGuard.class)
public static void precondition(ArgsAnalysis ma, ProcessorContext pc) {
args = new Object[ma.getNumberOfArgs()];
// get the actual types of the arguments
pc.apply(ProcessorTest.class, ProcessorMode.METHOD_ARGS);
}
@AfterReturning(marker = BodyMarker.class, scope = "*.*", guard = HasArgsGuard.class)
public static void postcondition(MethodSC sc) {
@AfterReturning(marker = BodyMarker.class, scope = "TargetClass.*")
public static void postcondition(MethodSC sc, ProcessorContext pc) {
System.out.println("args for " + sc.thisMethodFullName() + " " + sc.thisMethodDescriptor());
for(int i = 0 ; i < args.length; i++) {
Object[] args = pc.getArgs(ProcessorMode.METHOD_ARGS);
for(int i = 0 ; i < args.length; ++i) {
System.out.println(" arg[" + i + "] " + args[i]);
}
}
......
package ch.usi.dag.disl.test.args;
import org.objectweb.asm.Type;
import ch.usi.dag.disl.annotation.GuardMethod;
import ch.usi.dag.disl.staticcontext.MethodSC;
public class HasArgsGuard {
@GuardMethod
public static boolean isApplicable(MethodSC msc) {
if(Type.getArgumentTypes(msc.thisMethodDescriptor()).length>0)
return true;
return false;
}
}
Manifest-Version: 1.0
DiSL-Classes: ch/usi/dag/disl/test/args/DiSLClass.class:ch/usi/dag/disl/test/args/ProcessorTest.class
\ No newline at end of file
DiSL-Classes: ch/usi/dag/disl/test/args/DiSLClass.class
\ No newline at end of file
package ch.usi.dag.disl.test.args;
import ch.usi.dag.disl.annotation.ArgsProcessor;
import ch.usi.dag.disl.processorcontext.ArgumentContext;
@ArgsProcessor
public class ProcessorTest {
public static void objPM(Object o, ArgumentContext ac) {
DiSLClass.args[ac.position()] = o;
}
public static void booleanPM(boolean b, ArgumentContext ac) {
DiSLClass.args[ac.position()] = b;
}
public static void bytePM(byte b, ArgumentContext ac) {
DiSLClass.args[ac.position()] = b;
}
public static void charPM(char c, ArgumentContext ac) {
DiSLClass.args[ac.position()] = c;
}
public static void doublePM(double d, ArgumentContext ac) {
DiSLClass.args[ac.position()] = d;
}
public static void floatPM(float f, ArgumentContext ac) {
DiSLClass.args[ac.position()] = f;
}
public static void intPM(int i, ArgumentContext ac) {
DiSLClass.args[ac.position()] = i;
}
public static void longPM(long l, ArgumentContext ac) {
DiSLClass.args[ac.position()] = l;
}
public static void shortPM(short s, ArgumentContext ac) {
DiSLClass.args[ac.position()] = s;
}
}
......@@ -2,6 +2,7 @@ package ch.usi.dag.disl.test.processor;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.SyntheticLocal;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.marker.BytecodeMarker;
import ch.usi.dag.disl.processorcontext.ProcessorContext;
......@@ -14,12 +15,14 @@ public class DiSLClass {
public static String flag = "Start";
@Before(marker = BodyMarker.class, order = 0, scope = "TargetClass.*")
public static void insideMethod(MethodSC ci, ProcessorContext pc) {
public static void insideMethod(MethodSC ci, ProcessorContext pc, DynamicContext dc) {
System.out.println("(In) Method " + ci.thisMethodName() + ": ");
System.out.println(flag);
pc.apply(ProcessorTest.class, ProcessorMode.METHOD_ARGS);
System.out.println("Receiver is " + pc.getReceiver(ProcessorMode.METHOD_ARGS));
System.out.println("This is " + dc.thisValue());
System.out.println(flag);
System.out.println(ProcessorTest.flag);
......@@ -31,6 +34,7 @@ public class DiSLClass {
System.out.println("(Before) Method : ");
pc.apply(ProcessorTest.class, ProcessorMode.CALLSITE_ARGS);
System.out.println("Receiver is " + pc.getReceiver(ProcessorMode.CALLSITE_ARGS));
System.out.println(ProcessorTest.flag);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment