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 @@
<classpathentry kind="src" path="src-test"/>
<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="build/eclipse-dynamicbypass.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
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
......@@ -5,33 +5,38 @@
<path id="buildpath">
<pathelement location="${asm.path}"/>
<pathelement location="./bin"/>
<pathelement location="${bin}"/>
</path>
<target name="compileTLVInserter">
<mkdir dir="bin"/>
<javac srcdir="src-jborat" includes="ch/usi/dag/tlvinserter/" destdir="bin" debug="true" includeAntRuntime="false">
<!-- it automatically compiles all other necessary stuff :) -->
<target name="compile-tlvinserter">
<mkdir dir="${bin}"/>
<javac srcdir="${src.disl}" includes="ch/usi/dag/disl/tlvinserter/" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
</javac>
</target>
<target name="extendThread"/>
<target name="compile-dynamicbypass">
<mkdir dir="bin"/>
<javac srcdir="src-dynamicbypass" destdir="bin" debug="true" includeAntRuntime="false">
<target name="prepare-extendedthread" depends="compile-tlvinserter">
<mkdir dir="bin-thread/java/lang"/>
<java fork="true" classname="ch.usi.dag.disl.tlvinserter.ExtendThread">
<classpath refid="buildpath"/>
</javac>
</java>
<mkdir dir="${build}"/>
<jar basedir="bin-thread" destfile="${extendthread.path}" />
<delete dir="bin-thread"/>
</target>
<target name="compile-jborat" depends="compile-dynamicbypass">
<javac srcdir="src-jborat" destdir="bin" debug="true" includeAntRuntime="false">
<target name="compile-dynamicbypass" depends="prepare-extendedthread">
<mkdir dir="${bin}"/>
<javac srcdir="${src.dynbypass}" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
<compilerarg value="-Xbootclasspath/p:${extendthread.path}"/>
</javac>
<delete file="${extendthread.path}"/>
</target>
<target name="compile-disl" depends="compile-jborat">
<javac srcdir="src" destdir="bin" debug="true" includeAntRuntime="false">
<target name="compile-disl" depends="compile-dynamicbypass">
<javac srcdir="${src.disl}" destdir="${bin}" debug="true" includeAntRuntime="false">
<classpath refid="buildpath"/>
</javac>
</target>
......@@ -41,17 +46,20 @@
<target name="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>
<attribute name="Class-Path" value="${instr.jar.name}"/>
</manifest>
</jar>
</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">
<delete dir="bin"/>
<delete dir="build"/>
<delete dir="${bin}"/>
<delete dir="${build}"/>
</target>
</project>
......@@ -4,8 +4,8 @@ include Makefile.local
endif
# Source lists
LIBNAME=jboratagent
SOURCES= jboratagent.c
LIBNAME=dislagent
SOURCES= dislagent.c
# Object files needed to create library
OBJECTS=$(SOURCES:%.c=%.o)
......
......@@ -20,7 +20,7 @@
#include <jvmti.h>
#include <jni.h>
#include "jboratagent.h"
#include "dislagent.h"
static int total = 0;
static long contention = 0;
......
......@@ -296,6 +296,8 @@ public class DiSL {
// dynamic bypass
if(useDynamicBypass) {
// prepare dynamic bypass thread local variable
ThreadLocalVar tlv = new ThreadLocalVar(null, "bypass",
Type.getType(boolean.class), false);
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 {
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_STD_DELIM = '.';
......@@ -11,4 +12,6 @@ public class Constants {
final public static String STATIC_INIT_NAME = "<clinit>";
final public static String CLASS_DELIM = ".";
final public static String CLASS_EXT = ".class";
}
......@@ -8,11 +8,6 @@ public class DiSLServerException extends Exception {
super();
}
public DiSLServerException(String message, Throwable cause,
boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public DiSLServerException(String message, Throwable cause) {
super(message, cause);
}
......
......@@ -11,11 +11,12 @@ import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import org.objectweb.asm.Type;
import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.exception.DiSLException;
import ch.usi.dag.disl.scope.WildCard;
import com.sun.xml.internal.ws.org.objectweb.asm.Type;
import ch.usi.dag.disl.util.Constants;
public class Worker extends Thread {
......@@ -120,10 +121,8 @@ public class Worker extends Thread {
private String internClassName(String normalClassName) {
final char NORMAL_DELIM = '.';
final char INTERN_DELIM = '/';
return normalClassName.replace(NORMAL_DELIM, INTERN_DELIM);
return normalClassName.replace(
Constants.PACKAGE_STD_DELIM, Constants.PACKAGE_ASM_DELIM);
}
private void instrumentationLoop() throws DiSLServerException, DiSLException {
......@@ -209,13 +208,10 @@ public class Worker extends Thread {
private void dump(String className, byte[] codeAsBytes, String path)
throws DiSLServerException {
final String CLASS_DELIM = "/";
final String CLASS_EXT = ".class";
try {
// 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 packageName = className.substring(0, i + 1);
......@@ -227,7 +223,7 @@ public class Worker extends Thread {
// dump the class code
FileOutputStream fo = new FileOutputStream(pathWithPkg
+ onlyClassName + CLASS_EXT);
+ onlyClassName + Constants.CLASS_EXT);
fo.write(codeAsBytes);
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