Commit 8ee1ee50 authored by Lukáš Marek's avatar Lukáš Marek

DiSL now compiles (but does not run ;) using build file under java 6 and 7

To develop under eclipse use "ant eclipse" to build necessary jar
parent cbdb3aed
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
<classpathentry kind="src" path="src-test"/> <classpathentry kind="src" path="src-test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/asm-debug-all-4.0.jar"/> <classpathentry kind="lib" path="lib/asm-debug-all-4.0.jar"/>
<classpathentry kind="lib" path="build/eclipse-dynamicbypass.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>
asm.path=lib/asm-debug-all-4.0.jar asm.path=lib/asm-debug-all-4.0.jar
src.disl=src
src.dynbypass=src-dynbypass
src.dynbypass.act=src-dynbypass-act
src.agent.java=src-agent-java
bin=bin
build=build
build.thread=build-thread
extendthread.path=${build}/extendedthread.jar
instr.jar.name=dislinstr.jar instr.jar.name=dislinstr.jar
...@@ -5,33 +5,38 @@ ...@@ -5,33 +5,38 @@
<path id="buildpath"> <path id="buildpath">
<pathelement location="${asm.path}"/> <pathelement location="${asm.path}"/>
<pathelement location="./bin"/> <pathelement location="${bin}"/>
</path> </path>
<target name="compileTLVInserter"> <!-- it automatically compiles all other necessary stuff :) -->
<mkdir dir="bin"/> <target name="compile-tlvinserter">
<javac srcdir="src-jborat" includes="ch/usi/dag/tlvinserter/" destdir="bin" debug="true" includeAntRuntime="false"> <mkdir dir="${bin}"/>
<javac srcdir="${src.disl}" includes="ch/usi/dag/disl/tlvinserter/" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/> <classpath refid="buildpath"/>
</javac> </javac>
</target> </target>
<target name="extendThread"/> <target name="prepare-extendedthread" depends="compile-tlvinserter">
<mkdir dir="bin-thread/java/lang"/>
<target name="compile-dynamicbypass"> <java fork="true" classname="ch.usi.dag.disl.tlvinserter.ExtendThread">
<mkdir dir="bin"/>
<javac srcdir="src-dynamicbypass" destdir="bin" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/> <classpath refid="buildpath"/>
</javac> </java>
<mkdir dir="${build}"/>
<jar basedir="bin-thread" destfile="${extendthread.path}" />
<delete dir="bin-thread"/>
</target> </target>
<target name="compile-jborat" depends="compile-dynamicbypass"> <target name="compile-dynamicbypass" depends="prepare-extendedthread">
<javac srcdir="src-jborat" destdir="bin" debug="true" includeAntRuntime="false"> <mkdir dir="${bin}"/>
<javac srcdir="${src.dynbypass}" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/> <classpath refid="buildpath"/>
<compilerarg value="-Xbootclasspath/p:${extendthread.path}"/>
</javac> </javac>
<delete file="${extendthread.path}"/>
</target> </target>
<target name="compile-disl" depends="compile-jborat"> <target name="compile-disl" depends="compile-dynamicbypass">
<javac srcdir="src" destdir="bin" debug="true" includeAntRuntime="false"> <javac srcdir="${src.disl}" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/> <classpath refid="buildpath"/>
</javac> </javac>
</target> </target>
...@@ -41,17 +46,20 @@ ...@@ -41,17 +46,20 @@
<target name="prepare-dynamicbypass-afterbootstrap"/> <target name="prepare-dynamicbypass-afterbootstrap"/>
<target name="package" depends="compile,prepare-dynamicbypass-afterbootstrap"> <target name="package" depends="compile,prepare-dynamicbypass-afterbootstrap">
<mkdir dir="build"/> <jar basedir="${bin}" destfile="${build}/disl-${disl.version}.jar">
<jar basedir="bin" destfile="build/disl-${disl.version}.jar">
<manifest> <manifest>
<attribute name="Class-Path" value="${instr.jar.name}"/> <attribute name="Class-Path" value="${instr.jar.name}"/>
</manifest> </manifest>
</jar> </jar>
</target> </target>
<target name="eclipse" depends="compile-dynamicbypass">
<jar basedir="${bin}" destfile="${build}/eclipse-dynamicbypass.jar" includes="ch/usi/dag/disl/dynamicbypass/" />
</target>
<target name="clean"> <target name="clean">
<delete dir="bin"/> <delete dir="${bin}"/>
<delete dir="build"/> <delete dir="${build}"/>
</target> </target>
</project> </project>
...@@ -4,8 +4,8 @@ include Makefile.local ...@@ -4,8 +4,8 @@ include Makefile.local
endif endif
# Source lists # Source lists
LIBNAME=jboratagent LIBNAME=dislagent
SOURCES= jboratagent.c SOURCES= dislagent.c
# Object files needed to create library # Object files needed to create library
OBJECTS=$(SOURCES:%.c=%.o) OBJECTS=$(SOURCES:%.c=%.o)
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <jvmti.h> #include <jvmti.h>
#include <jni.h> #include <jni.h>
#include "jboratagent.h" #include "dislagent.h"
static int total = 0; static int total = 0;
static long contention = 0; static long contention = 0;
......
...@@ -296,6 +296,8 @@ public class DiSL { ...@@ -296,6 +296,8 @@ public class DiSL {
// dynamic bypass // dynamic bypass
if(useDynamicBypass) { if(useDynamicBypass) {
// prepare dynamic bypass thread local variable
ThreadLocalVar tlv = new ThreadLocalVar(null, "bypass", ThreadLocalVar tlv = new ThreadLocalVar(null, "bypass",
Type.getType(boolean.class), false); Type.getType(boolean.class), false);
tlv.setDefaultValue(0); tlv.setDefaultValue(0);
......
package ch.usi.dag.disl.tlvinserter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Type;
import ch.usi.dag.disl.localvar.ThreadLocalVar;
import ch.usi.dag.disl.util.Constants;
/**
* This is just a utility class for disl compilation
*/
public final class ExtendThread {
private static final String THREAD_BIN_DIR = "./bin-thread/";
public static void main(String[] args) throws Exception {
Class<?> tc = Thread.class;
// get thread class as resource
InputStream tis = tc.getResourceAsStream("Thread.class");
// prepare dynamic bypass variable
ThreadLocalVar tlv = new ThreadLocalVar(null, "bypass",
Type.getType(boolean.class), false);
tlv.setDefaultValue(0);
// prepare Set with dynamic bypass
Set<ThreadLocalVar> tlvs = new HashSet<ThreadLocalVar>();
tlvs.add(tlv);
// parse Thread in ASM
ClassReader cr = new ClassReader(tis);
ClassWriter cw = new ClassWriter(cr, 0);
// put dynamic bypass into Thread using TLVInserter
cr.accept(new TLVInserter(cw, tlvs), 0);
// prepare Thread file name
String threadFileName = tc.getName();
threadFileName = threadFileName.replace(
Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_ASM_DELIM);
threadFileName += Constants.CLASS_EXT;
// output Thread code into special thread bin directory
write(THREAD_BIN_DIR + threadFileName, cw.toByteArray());
}
private static void write(String outputFile, byte[] data) throws IOException {
FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(data);
fos.close();
}
}
...@@ -4,6 +4,7 @@ public class Constants { ...@@ -4,6 +4,7 @@ public class Constants {
final public static String STATIC_CONTEXT_METHOD_DELIM = "."; final public static String STATIC_CONTEXT_METHOD_DELIM = ".";
// TODO ! rename to PACKAGE_INTERN_DELIM
final public static char PACKAGE_ASM_DELIM = '/'; final public static char PACKAGE_ASM_DELIM = '/';
final public static char PACKAGE_STD_DELIM = '.'; final public static char PACKAGE_STD_DELIM = '.';
...@@ -11,4 +12,6 @@ public class Constants { ...@@ -11,4 +12,6 @@ public class Constants {
final public static String STATIC_INIT_NAME = "<clinit>"; final public static String STATIC_INIT_NAME = "<clinit>";
final public static String CLASS_DELIM = "."; final public static String CLASS_DELIM = ".";
final public static String CLASS_EXT = ".class";
} }
...@@ -8,11 +8,6 @@ public class DiSLServerException extends Exception { ...@@ -8,11 +8,6 @@ public class DiSLServerException extends Exception {
super(); super();
} }
public DiSLServerException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public DiSLServerException(String message, Throwable cause) { public DiSLServerException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
......
...@@ -11,11 +11,12 @@ import java.util.HashSet; ...@@ -11,11 +11,12 @@ import java.util.HashSet;
import java.util.Scanner; import java.util.Scanner;
import java.util.Set; import java.util.Set;
import org.objectweb.asm.Type;
import ch.usi.dag.disl.DiSL; import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.exception.DiSLException; import ch.usi.dag.disl.exception.DiSLException;
import ch.usi.dag.disl.scope.WildCard; import ch.usi.dag.disl.scope.WildCard;
import ch.usi.dag.disl.util.Constants;
import com.sun.xml.internal.ws.org.objectweb.asm.Type;
public class Worker extends Thread { public class Worker extends Thread {
...@@ -120,10 +121,8 @@ public class Worker extends Thread { ...@@ -120,10 +121,8 @@ public class Worker extends Thread {
private String internClassName(String normalClassName) { private String internClassName(String normalClassName) {
final char NORMAL_DELIM = '.'; return normalClassName.replace(
final char INTERN_DELIM = '/'; Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_ASM_DELIM);
return normalClassName.replace(NORMAL_DELIM, INTERN_DELIM);
} }
private void instrumentationLoop() throws DiSLServerException, DiSLException { private void instrumentationLoop() throws DiSLServerException, DiSLException {
...@@ -209,13 +208,10 @@ public class Worker extends Thread { ...@@ -209,13 +208,10 @@ public class Worker extends Thread {
private void dump(String className, byte[] codeAsBytes, String path) private void dump(String className, byte[] codeAsBytes, String path)
throws DiSLServerException { throws DiSLServerException {
final String CLASS_DELIM = "/";
final String CLASS_EXT = ".class";
try { try {
// extract the class name and package name // extract the class name and package name
int i = className.lastIndexOf(CLASS_DELIM); int i = className.lastIndexOf(Constants.PACKAGE_ASM_DELIM);
String onlyClassName = className.substring(i + 1); String onlyClassName = className.substring(i + 1);
String packageName = className.substring(0, i + 1); String packageName = className.substring(0, i + 1);
...@@ -227,7 +223,7 @@ public class Worker extends Thread { ...@@ -227,7 +223,7 @@ public class Worker extends Thread {
// dump the class code // dump the class code
FileOutputStream fo = new FileOutputStream(pathWithPkg FileOutputStream fo = new FileOutputStream(pathWithPkg
+ onlyClassName + CLASS_EXT); + onlyClassName + Constants.CLASS_EXT);
fo.write(codeAsBytes); fo.write(codeAsBytes);
fo.close(); fo.close();
} }
......
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