Commit 1d706f1e authored by Aibek Sarimbekov's avatar Aibek Sarimbekov
Browse files

moved immutability analysis to the example folder

ported immutability analysis  to the new guards
parent a1e5c923
user.runtime.jar.name=test-runtime.jar
\ No newline at end of file
<project name="disl-test" default="compile" basedir=".">
<property file="../disl.version"/>
<property file="../build.properties"/>
<property file="build.properties"/>
<property name="disl.jar.path" value="../build/disl-${disl.version}.jar"/>
<path id="buildpath">
<pathelement location="${disl.jar.path}"/>
<pathelement location="../${asm.path}"/>
<pathelement location="../${jborat.path}"/>
<pathelement location="../${jborat-runtime.path}"/>
<pathelement location="lib/stp.jar"/>
</path>
<target name="check-disl-jar">
<available file="${disl.jar.path}" property="disl.jar.present"/>
</target>
<target name="report-missing-jar" depends="check-disl-jar" unless="disl.jar.present">
<fail message="DiSL jar not found at ${disl.jar.path}. Build DiSL first!" />
</target>
<target name="compile" depends="report-missing-jar">
<mkdir dir="bin"/>
<javac srcdir="src" destdir="bin" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
<compilerarg value="-Xbootclasspath/p:lib/Thread_test.jar"/>
</javac>
</target>
<target name="agent" description="create simple agent jar file" >
<mkdir dir="build"/>
<jar jarfile="build/agent-light.jar">
<manifest>
<attribute name="Premain-Class" value="ch.usi.dag.disl.test.agent.Agent"/>
</manifest>
</jar>
</target>
<target name="check-test-property">
<condition property="test.set">
<isset property="test.name"/>
</condition>
</target>
<target name="report-missing-property" depends="check-test-property" unless="test.set">
<fail message="Property test.name is not set. Set it using -Dtest.name=value" />
</target>
<property name="test.path" value="ch/usi/dag/disl/example/${test.name}"/>
<target name="package" depends="report-missing-property,compile" description="create instrumentation package for specified test">
<mkdir dir="build"/>
<jar jarfile="./build/${user.runtime.jar.name}"
basedir="./bin"
includes="${test.path}/runtime/**">
</jar>
<jar jarfile="../build/${instr.jar.name}"
basedir="./bin"
includes="${test.path}/*"
excludes="${test.path}/runtime ${test.path}/TargetClass*.class ${test.path}/MANIFEST.MF"
manifest="./src/${test.path}/MANIFEST.MF">
</jar>
</target>
<target name="clean">
<delete dir="bin"/>
<delete dir="build"/>
</target>
</project>
# BEGIN JDK
# ALL JDK CLASSES MUST HAVE TWO VERSIONS
org.jcp.*
org.omg.*
org.xml.*
org.ietf.*
java.*
javax.*
com.sun.*
sun.*
sunx.*
com.apple.*
# END JDK
# BEGIN APPLICATION CODE
# IF YOU DON'T WEAVE JDK (see excluded.lst), YOU SHOULD APPLY
# THE CODE-MERGER TO THE APPLICATION CODE
#org.*
\ No newline at end of file
# THESE ARE THE BASIC SETTINGS
ch.usi.dag.jborat.*
sun.instrument.*
# THESE ARE THE RUNTIME CLASSES THAT MUST NOT BE WOVEN
ch.usi.dag.disl.test.senseo.runtime.*
ch.usi.dag.disl.test.map.runtime.*
ch.usi.dag.disl.test.jp2.runtime.*
ch.usi.dag.disl.test.virda.runtime.*
ch.usi.dag.disl.test.after2.runtime.*
ch.usi.dag.sample.runtime.*
# BEGIN JDK WEAVING
# COMMENT THE FOLLOWING FOR FULL COVERAGE
#org.jcp.*
#org.omg.*
#org.xml.*
#org.ietf.*
#java.*
#javax.*
#com.sun.*
#com.apple.*
#sun.*
#sunx.*
# END JDK
# This is a sample configuration with relative paths
# you can use full path using file:/// format
../lib/asm-debug-all-4.0.jar
lib/remote-jborat.jar
../lib/jborat.jar
# This is a sample configuration with relative paths
# you can use full path using file:/// format
../lib/asm-debug-all-4.0.jar
../build/disl-unspec.jar
../build/dislinstr.jar
# /bin/sh
EXPECTED_ARGS=1
if [ $# -lt $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` test-case [pkg]"
exit
fi
SERVER_FILE=.server.pid
export SERVER_FILE
if [ -e ${SERVER_FILE} ]
then
kill -KILL `cat ${SERVER_FILE}`
rm .server.pid
fi
DISL_CLASS="./bin/ch/usi/dag/disl/test/$1/DiSLClass.class"
TARGET_CLASS="ch.usi.dag.disl.test.$1.TargetClass"
if [ "$2" = "pkg" ]
then
# start server and take pid
ant package -Dtest.name=$1
./runServer.sh
else
# start server and take pid
./runServer.sh -Ddisl.classes=${DISL_CLASS}
fi
# wait for server startup
sleep 5
# run client
./runClient.sh ${TARGET_CLASS}
# kill server
kill -KILL `cat ${SERVER_FILE}`
rm .server.pid
#!/bin/bash
OS=`uname`
ARCH_RAW=`uname -m`
ARCH="unspec"
if [ "${ARCH_RAW}" = "i686" -o "${ARCH_RAW}" = "x86_32" ]; then
ARCH="x32"
elif [ "${ARCH_RAW}" = "i386" ]; then
ARCH="x64"
else
echo "Unknow architecture...."
exit -1
fi
if [ "${OS}" = "Darwin" ]; then
JBORAT_AGENT="macosx/${ARCH}/"libjboratagent.jnilib
elif [ "${OS}" = "Linux" ]; then
JBORAT_AGENT="linux/${ARCH}/"libjboratagent.so
else
echo "Unknow platform..."
exit -1
fi
# shared memory is the default communication
# to enable socket, add ",ipc.socket" to the options
JBORAT_AGENT_OPTS="1234,localhost,ipc.socket"
java -noverify -XX:MaxPermSize=128m \
-Xmx2G \
-javaagent:lib/agent.jar \
-Xbootclasspath/p:lib/remote-runtime.jar:../lib/jborat-runtime.jar:build/test-runtime.jar \
-agentpath:lib/${JBORAT_AGENT}=${JBORAT_AGENT_OPTS} \
-cp ./bin \
-jar /Users/aibeksarimbekov/Downloads/Programming/dacapo-9.12-bach.jar -s small xalan
# $*
#!/bin/sh
OS=`uname`
ARCH_RAW=`uname -m`
ARCH="unspec"
if [ "${ARCH_RAW}" = "i686" -o "${ARCH_RAW}" = "x86_32" ]; then
ARCH="x32"
elif [ "${ARCH_RAW}" = "i386" ]; then
ARCH="x64"
else
echo "Unknow architecture.."
exit -1
fi
if [ "${OS}" = "Darwin" ]; then
JBORAT_AGENT_PATH="macosx/${ARCH}"
elif [ "${OS}" = "Linux" ]; then
JBORAT_AGENT_PATH="linux/${ARCH}"
else
echo "Unknow platform..."
exit -1
fi
CLASSPATH=../lib/jborat-agent.jar:../lib/jborat-runtime.jar:../lib/jborat-interface.jar:lib/remote-server.jar
java -Dch.usi.dag.jborat.instrumented="instrumented" \
-Djborat.debug \
-Ddisl.dynbypass=true \
-Ddisl.debug \
-Djborat.ipc.socket=true \
-Djava.library.path=./lib/${JBORAT_AGENT_PATH} \
-Dch.usi.dag.jborat.instrumentation="ch.usi.dag.disl.DiSL" \
-Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" \
-Dch.usi.dag.jborat.liblist="conf/lib.lst" \
-Dch.usi.dag.jborat.udiliblist="conf/udilib.lst" \
-Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" \
$* \
-cp ${CLASSPATH} \
ch.usi.dag.jborat.remote.server.Server \
&
echo $! > ${SERVER_FILE}
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis;
import java.util.Stack;
......@@ -7,10 +7,12 @@ import ch.usi.dag.disl.annotation.AfterReturning;
import ch.usi.dag.disl.annotation.Before;
import ch.usi.dag.disl.annotation.ThreadLocal;
import ch.usi.dag.disl.dynamiccontext.DynamicContext;
import ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.runtime.ImmutabilityAnalysis;
import ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.OnlyInit;
import ch.usi.dag.disl.marker.BodyMarker;
import ch.usi.dag.disl.marker.BytecodeMarker;
import ch.usi.dag.disl.staticcontext.MethodSC;
import ch.usi.dag.disl.test.fieldsImmutabilityAnalysis.runtime.ImmutabilityAnalysis;
public class DiSLClass {
......@@ -38,18 +40,18 @@ public class DiSLClass {
}
/** ALLOCATION SITE **/
@AfterReturning(marker = BytecodeMarker.class, args = "new", scope = "*.*", order = 0)
@AfterReturning(marker = BytecodeMarker.class, args = "new", guard = NoClInit.class, scope = "*.*", order = 0)
public static void BeforeInitialization(MethodSC sc, MyAnalysis ma, DynamicContext dc) {
Object allocatedObj = dc.stackValue(0, Object.class);
String allocationSite = sc.thisMethodFullName() + " [" + ma.getInMethodIndex() + "]";
ImmutabilityAnalysis.onObjectInitialization(allocatedObj, allocationSite);
}
//guard = NoClInit.class,
/** FIELD ACCESSES **/
@Before(marker=BytecodeMarker.class, args = "putfield", scope = "*.*", order = 0)
@Before(marker=BytecodeMarker.class, args = "putfield", guard = NoClInit.class, scope = "*.*", order = 0)
public static void onFieldWrite(MethodSC sc, MyAnalysis ma, DynamicContext dc) {
String accessSite = sc.thisMethodFullName() + " [" + ma.getInMethodIndex() + "]";
Object accessedObj = dc.stackValue(1, Object.class);
......@@ -58,7 +60,7 @@ public class DiSLClass {
ImmutabilityAnalysis.onFieldWrite(accessedObj, accessedFieldName, accessSite, stackTL);
}
@Before(marker=BytecodeMarker.class, args = "getfield", scope = "*.*", order = 0)
@Before(marker=BytecodeMarker.class, args = "getfield", guard = NoClInit.class, scope = "*.*", order = 0)
public static void onFieldRead(MethodSC sc, MyAnalysis ma, DynamicContext dc) {
String accessSite = sc.thisMethodFullName() + " [" + ma.getInMethodIndex() + "]";
Object accessedObj = dc.stackValue(0, Object.class);
......
Manifest-Version: 1.0
DiSL-Classes: ch/usi/dag/disl/example/fieldsImmutabilityAnalysis/DiSLClass.class
\ No newline at end of file
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis;
import java.util.Iterator;
......
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis;
import ch.usi.dag.disl.staticcontext.AbstractStaticContext;
public class MyStaticContext extends AbstractStaticContext {
public boolean isInTheConstructor() {
return (staticContextData.getMethodNode().name.equals("<init>") && !staticContextData.getMethodNode().name.equals("java/lang/Object")) ? true : false;
}
public boolean isInTheStaticInitializer() {
return (staticContextData.getMethodNode().name.equals("<clinit>") ? false : true);
}
}
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis;
import ch.usi.dag.disl.annotation.GuardMethod;
import ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.MyStaticContext;
public abstract class NoClInit {
@GuardMethod
public static boolean isApplicable(MyStaticContext sc) {
return sc.isInTheStaticInitializer();
}
}
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis;
import ch.usi.dag.disl.annotation.GuardMethod;
public abstract class OnlyInit {
@GuardMethod
public static boolean isApplicable(MyStaticContext sc) {
return (sc.isInTheConstructor());
}
}
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis;
import java.util.ArrayList;
import java.util.List;
......
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis.runtime;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.runtime;
import java.io.PrintStream;
......
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis.runtime;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.runtime;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
......
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis.runtime;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.runtime;
import java.io.PrintStream;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import ch.usi.dag.disl.test.fieldsImmutabilityAnalysis.runtime.MyWeakKeyIdentityHashMap.EntryDumper;
import ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.runtime.MyWeakKeyIdentityHashMap.EntryDumper;
public class MyDumper implements EntryDumper<MyWeakReference<Object>, ConcurrentHashMap<String, FieldState>>{
......
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis.runtime;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.runtime;
/**
* Identity-based hashmap that internally uses {@code MyWeakReference} to
......
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis.runtime;
package ch.usi.dag.disl.example.fieldsImmutabilityAnalysis.runtime;
import java.lang.ref.WeakReference;
......
Manifest-Version: 1.0
DiSL-Classes: ch/usi/dag/disl/test/fieldsImmutabilityAnalysis/DiSLClass.class
\ No newline at end of file
package ch.usi.dag.disl.test.fieldsImmutabilityAnalysis;
import ch.usi.dag.disl.guard.SnippetGuard;
import ch.usi.dag.disl.snippet.Shadow;
public class OnlyInit implements SnippetGuard {
@Override
public boolean isApplicable(Shadow shadow) {
return (shadow.getMethodNode().name.equals("<init>") && !shadow.getMethodNode().name.equals("java/lang/Object")) ? true : false;
}
}
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