Commit 7f26e5d3 authored by Lubomir Bulej's avatar Lubomir Bulej

Stop using deprecated methods in tests.

parent 5aa62335
......@@ -6,7 +6,7 @@ import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.ThreadLocal;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.staticcontext.uid.UniqueMethodId;
import ch.usi.dag.disl.staticcontext.uid.RandomMethodUid;
import ch.usi.dag.disl.test.suite.after2.instr.runtime.Analysis;
public class DiSLClass {
......@@ -15,7 +15,7 @@ public class DiSLClass {
static Stack<Integer> stackTL;
@Before(marker = BodyMarker.class, order = 0, scope = "*.*", guard = NotInitNorClinit.class)
public static void onMethodEntryObjectArgs(UniqueMethodId id) {
public static void onMethodEntryObjectArgs(final RandomMethodUid id) {
Stack<Integer> thisStack;
if((thisStack = stackTL) == null) {
thisStack = (stackTL = new Stack<Integer>());
......@@ -24,7 +24,7 @@ public class DiSLClass {
}
@After(marker = BodyMarker.class, order = 0, scope = "*.*", guard = NotInitNorClinit.class)
public static void onMethodExit(UniqueMethodId id) {
public static void onMethodExit(final RandomMethodUid id) {
Analysis.onExit(stackTL, id.get());
}
......
......@@ -3,20 +3,21 @@ package ch.usi.dag.disl.test.suite.afterinit2.instr;
import ch.usi.dag.disl.annotation.After;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.marker.AfterInitBodyMarker;
import ch.usi.dag.disl.staticcontext.ClassStaticContext;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
public class DiSLClass {
@Before (marker = AfterInitBodyMarker.class, scope = "*.app.Target*.<init>")
public static void after (final MethodStaticContext msc) {
System.out.println (msc.thisClassSimpleName () +"."+ msc.thisMethodName () + " before");
public static void after (final ClassStaticContext csc, final MethodStaticContext msc) {
System.out.println (csc.getSimpleName () +"."+ msc.thisMethodName () + " before");
}
@After (marker = AfterInitBodyMarker.class, scope = "*.app.Target*.<init>")
public static void afterThrowning (final MethodStaticContext msc) {
System.out.println (msc.thisClassSimpleName () +"."+ msc.thisMethodName () +" after");
public static void afterThrowning (final ClassStaticContext csc, final MethodStaticContext msc) {
System.out.println (csc.getSimpleName () +"."+ msc.thisMethodName () +" after");
}
}
......@@ -6,6 +6,7 @@ import ch.usi.dag.disl.marker.BasicBlockMarker;
import ch.usi.dag.disl.marker.PreciseBasicBlockMarker;
import ch.usi.dag.disl.staticcontext.BasicBlockStaticContext;
public class DiSLClass {
@Before(marker = PreciseBasicBlockMarker.class, scope = "TargetClass.print(boolean)", order = 0)
......@@ -19,8 +20,8 @@ public class DiSLClass {
}
@Before(marker = BasicBlockMarker.class, scope = "TargetClass.print(boolean)", order = 2)
public static void precondition1(BasicBlockStaticContext bba) {
System.out.println("disl: b enter bb index=" + bba.getBBindex() + " size=" + bba.getBBSize());
public static void precondition1(final BasicBlockStaticContext bba) {
System.out.println("disl: b enter bb index=" + bba.getIndex() + " size=" + bba.getSize());
}
@AfterReturning(marker = BasicBlockMarker.class, scope = "TargetClass.print(boolean)", order = 3)
......
......@@ -2,13 +2,14 @@ package ch.usi.dag.disl.test.suite.bytecodemarker.instr;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.marker.BytecodeMarker;
import ch.usi.dag.disl.staticcontext.BytecodeStaticContext;
import ch.usi.dag.disl.staticcontext.InstructionStaticContext;
public class DiSLClass {
@Before(marker = BytecodeMarker.class, args="aload, if_icmpne", scope = "TargetClass.main")
public static void precondition(BytecodeStaticContext ba) {
System.out.println(ba.getBytecodeNumber());
public static void precondition(InstructionStaticContext insn) {
System.out.println(insn.getOpcode());
}
}
package ch.usi.dag.disl.test.suite.classinfo.instr;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.classcontext.ClassContext;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
import ch.usi.dag.disl.staticcontext.ClassStaticContext;
public class DiSLClass {
@Before(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 0)
public static void precondition(MethodStaticContext msc, ClassContext cc) {
System.out.println("disl: " + cc.asClass( msc.thisClassName()));
public static void precondition(final ClassStaticContext csc) {
System.out.println("disl: class " + csc.getName ());
}
}
package ch.usi.dag.disl.test.suite.dispatch2.app;
public class TargetClass {
public static void main(final String[] args) throws InterruptedException {
final long start = System.nanoTime();
final int COUNT = 2000000;
final TargetClass ta[] = new TargetClass[COUNT];
int i;
for(i = 0; i < COUNT; ++i) {
for (int i = 0; i < COUNT; ++i) {
ta[i] = new TargetClass();
}
System.out.println("Allocated " + i + " objects");
//System.out.println("Allocated " + i + " objects in "
// + (System.nanoTime() - start) / 1000000 + " ms");
System.out.println("Allocated " + COUNT + " objects");
}
}
......@@ -9,18 +9,14 @@ public class TargetClass {
@Override
public void run() {
final long start = System.nanoTime();
final int COUNT = 2000000;
final TargetClass ta[] = new TargetClass[COUNT];
int i;
for (i = 0; i < COUNT; ++i) {
for (int i = 0; i < COUNT; ++i) {
ta[i] = new TargetClass();
}
System.out.println("Allocated " + i + " objects");
//System.out.println("Allocated " + i + " objects in "
// + (System.nanoTime() - start) / 1000000 + " ms");
System.out.println("Allocated " + COUNT + " objects");
}
}
......
......@@ -2,17 +2,25 @@ package ch.usi.dag.disl.test.suite.pe2.instr;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.staticcontext.ClassStaticContext;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
public class DiSLClass {
@Before(marker = BodyMarker.class, scope = "TargetClass.*", order = 0)
public static void precondition(MethodStaticContext msc) {
public static void precondition(
final ClassStaticContext csc, final MethodStaticContext msc
) {
if (!msc.thisMethodName().equals("<clinit>")
&& !(msc.thisMethodName().equals("<init>") && (msc
.thisClassName().equals("java/lang/Object") || msc
.thisClassName().equals("java/lang/Thread")))) {
&& !(
msc.thisMethodName().equals("<init>")
&& (
csc.getInternalName ().equals("java/lang/Object")
|| csc.getInternalName ().equals("java/lang/Thread")
)
)
) {
System.out.println("disl: go ahead");
} else {
System.out.println("disl: not a good idea to weave some code here");
......
......@@ -3,27 +3,32 @@ package ch.usi.dag.disl.test.suite.pe3.instr;
import org.objectweb.asm.Opcodes;
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.BytecodeStaticContext;
import ch.usi.dag.disl.staticcontext.ClassStaticContext;
import ch.usi.dag.disl.staticcontext.InstructionStaticContext;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
public class DiSLClass {
@Before(marker = BytecodeMarker.class, args = "putfield, getfield", scope = "TargetClass.public_method", order = 0)
public static void beforeFieldAccess(DynamicContext dc,
BytecodeStaticContext bsc, MethodStaticContext msc) {
public static void beforeFieldAccess(
final InstructionStaticContext insn,
final ClassStaticContext csc, final MethodStaticContext msc
) {
//
// Keep the code as is. The partial evaluator should be able to construct
// a string literal for each instatiation of the snippet
//
String operationID;
if (bsc.getBytecodeNumber() == Opcodes.PUTFIELD) {
if (insn.getOpcode() == Opcodes.PUTFIELD) {
operationID = "disl: write:";
} else {
operationID = "disl: read:";
}
operationID += msc.thisClassName() + ":" + msc.thisMethodName() + ":"
operationID += csc.getInternalName() + ":" + msc.thisMethodName() + ":"
+ msc.thisMethodDescriptor();
System.out.println(operationID);
}
......
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