Commit c692ae8d authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

Use "javac -h" instead of "javah" to generate header files

This requires adding @Native annotations to CodeOption.Flag
members and updating the mapping to human-usable names in
src-disl-agent/dislagent.c and src-shvm-agent/disl/disl.h

Also ensure that the headers in src-disl-agent/codeflags.h and
src-shvm-agent/disl/codeflags.h are up-to-date with respect to
the CodeOption.java file.
parent b00f394d
Pipeline #7112 failed with stages
in 5 minutes
<project
name="disl" default="build" basedir="."
name="master" default="build" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:ac="antlib:net.sf.ant-contrib"
>
......@@ -502,35 +502,41 @@
</target>
<!-- DiSL agent -->
<!-- Code Flags -->
<!--
The DiSL agent requires a header file containing flags for
various code generation options. This target generates the
header using "javah" after compiling DiSL.
Both agents require a header file containing flags for various code
generation options. This target triggers generation of the header file
using the "generate-codeflags" target in the DiSL subproject.
-->
<target name="-check-disl-agent-codeflags">
<target name="-check-codeflags">
<property name="build.disl.agent.codeflags.path" value="${src.disl.agent}/codeflags.h"/>
<uptodate property="build.disl.agent.codeflags.uptodate" targetfile="${build.disl.agent.codeflags.path}">
<srcfiles dir="${src.disl.prefix}/src" includes="**/DiSL.java"/>
</uptodate>
<property name="build.shvm.agent.codeflags.path" value="${src.shvm.agent}/disl/codeflags.h"/>
<condition property="build.disl.codeflags.uptodate">
<and>
<uptodate targetfile="${build.disl.agent.codeflags.path}" >
<srcfiles dir="${src.disl.prefix}/src" includes="**/CodeOption.java"/>
</uptodate>
<uptodate targetfile="${build.shvm.agent.codeflags.path}" >
<srcfiles dir="${src.disl.prefix}/src" includes="**/CodeOption.java"/>
</uptodate>
</and>
</condition>
</target>
<target name="-generate-disl-agent-codeflags-if-needed" unless="build.disl.agent.codeflags.uptodate" depends="-check-disl-agent-codeflags">
<antcall target="-generate-disl-agent-codeflags"/>
</target>
<target name="-generate-disl-agent-codeflags" depends="compile-disl">
<local name="flags.class"/>
<find-class property="flags.class" dir="${src.disl.prefix}/${build.disl}" name="*CodeOption$Flag"/>
<target name="-generate-codeflags-if-needed" unless="build.disl.codeflags.uptodate" depends="-check-codeflags">
<ant dir="${src.disl.prefix}" target="generate-codeflags" />
<javah outputFile="${build.disl.agent.codeflags.path}" force="yes">
<class name="${flags.class}"/>
<classpath refid="disl.classpath"/>
</javah>
<copy file="${src.disl.prefix}/${build.disl.codeflags.path}" tofile="${build.disl.agent.codeflags.path}" />
<copy file="${src.disl.prefix}/${build.disl.codeflags.path}" tofile="${build.shvm.agent.codeflags.path}" />
</target>
<!-- DiSL agent -->
<!--
The DiSL agent requires the bytecode of several bypass
classes. This target generates the "bytecode.c" containing
......@@ -602,7 +608,7 @@
</target>
<target name="prepare-disl-agent" depends="-generate-disl-agent-codeflags-if-needed,-generate-disl-agent-bytecode-if-needed"/>
<target name="prepare-disl-agent" depends="-generate-codeflags-if-needed,-generate-disl-agent-bytecode-if-needed" />
<target name="compile-disl-agent" depends="prepare-disl-agent">
......@@ -647,7 +653,7 @@
<!-- Shadow VM agent -->
<target name="compile-shvm-agent">
<target name="compile-shvm-agent" depends="-generate-codeflags-if-needed">
<exec executable="make" dir="${src.shvm.agent}">
<arg value="WHOLE=1"/>
</exec>
......
......@@ -50,6 +50,8 @@ build.disl-server=${build.dir}/disl-server
build.disl.thread=${build.disl}-thread
build.disl.bypass=${build.disl}-bypass
build.disl.codeflags.path=${build.dir}/include/codeflags.h
build.shvm=${build.dir}/${src.shvm.prefix}
build.shvm-server=${build.dir}/shvm-server
build.shvm.dispatch=${build.shvm}-dispatch
......
......@@ -21,3 +21,5 @@ src.disl.weaver=src-weaver
src.disl.test=src-test
build.disl.test=${build.dir}/test
build.disl.native=${build.dir}/native
......@@ -74,6 +74,23 @@
</javac>
</target>
<target name="generate-codeflags" depends="compile">
<delete dir="${build.disl.native}" />
<mkdir dir="${build.disl.native}" />
<javac srcdir="src/${src.disl.main}" destdir="${build.disl.native}" nativeheaderdir="${build.disl.native}" debug="false" includeantruntime="false">
<include name="**/CodeOption.java" />
<classpath>
<path path="${build.disl}"/>
</classpath>
</javac>
<concat destfile="${build.disl.codeflags.path}">
<fileset file="${build.disl.native}/*.h" />
</concat>
<delete dir="${build.disl.native}" />
</target>
<target name="compile-tests" depends="compile">
<javac destdir="${build.disl.test}" debug="true" srcdir="${src.disl.test}" includeantruntime="false">
<classpath>
......
package ch.usi.dag.disl;
import java.lang.annotation.Native;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
......@@ -40,9 +41,16 @@ public enum CodeOption {
* used when communicating with DiSL agent.
*/
public interface Flag {
@Native
static final int CREATE_BYPASS = 1 << 0;
@Native
static final int DYNAMIC_BYPASS = 1 << 1;
@Native
static final int SPLIT_METHODS = 1 << 2;
@Native
static final int CATCH_EXCEPTIONS = 1 << 3;
}
......
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ch_usi_dag_disl_DiSL_CodeOption_Flag */
/* Header for class ch_usi_dag_disl_CodeOption_Flag */
#ifndef _Included_ch_usi_dag_disl_DiSL_CodeOption_Flag
#define _Included_ch_usi_dag_disl_DiSL_CodeOption_Flag
#ifndef _Included_ch_usi_dag_disl_CodeOption_Flag
#define _Included_ch_usi_dag_disl_CodeOption_Flag
#ifdef __cplusplus
extern "C" {
#endif
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_CREATE_BYPASS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_CREATE_BYPASS 1L
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_DYNAMIC_BYPASS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_DYNAMIC_BYPASS 2L
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_SPLIT_METHODS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_SPLIT_METHODS 4L
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_CATCH_EXCEPTIONS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_CATCH_EXCEPTIONS 8L
#undef ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS
#define ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS 1L
#undef ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS
#define ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS 2L
#undef ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS
#define ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS 4L
#undef ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS
#define ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS 8L
#ifdef __cplusplus
}
#endif
......
......@@ -60,10 +60,10 @@
* Flags representing code options, derived from the values generated from Java.
*/
enum code_flags {
CF_CREATE_BYPASS = ch_usi_dag_disl_DiSL_CodeOption_Flag_CREATE_BYPASS,
CF_DYNAMIC_BYPASS = ch_usi_dag_disl_DiSL_CodeOption_Flag_DYNAMIC_BYPASS,
CF_SPLIT_METHODS = ch_usi_dag_disl_DiSL_CodeOption_Flag_SPLIT_METHODS,
CF_CATCH_EXCEPTIONS = ch_usi_dag_disl_DiSL_CodeOption_Flag_CATCH_EXCEPTIONS,
CF_CREATE_BYPASS = ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS,
CF_DYNAMIC_BYPASS = ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS,
CF_SPLIT_METHODS = ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS,
CF_CATCH_EXCEPTIONS = ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS,
};
......
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ch_usi_dag_disl_DiSL_CodeOption_Flag */
/* Header for class ch_usi_dag_disl_CodeOption_Flag */
#ifndef _Included_ch_usi_dag_disl_DiSL_CodeOption_Flag
#define _Included_ch_usi_dag_disl_DiSL_CodeOption_Flag
#ifndef _Included_ch_usi_dag_disl_CodeOption_Flag
#define _Included_ch_usi_dag_disl_CodeOption_Flag
#ifdef __cplusplus
extern "C" {
#endif
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_CREATE_BYPASS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_CREATE_BYPASS 1L
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_DYNAMIC_BYPASS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_DYNAMIC_BYPASS 2L
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_SPLIT_METHODS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_SPLIT_METHODS 4L
#undef ch_usi_dag_disl_DiSL_CodeOption_Flag_CATCH_EXCEPTIONS
#define ch_usi_dag_disl_DiSL_CodeOption_Flag_CATCH_EXCEPTIONS 8L
#undef ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS
#define ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS 1L
#undef ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS
#define ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS 2L
#undef ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS
#define ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS 4L
#undef ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS
#define ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS 8L
#ifdef __cplusplus
}
#endif
......
......@@ -28,10 +28,10 @@ static volatile bool jvm_is_initialized;
* Flags representing code options, derived from the values generated from Java.
*/
enum code_flags {
CF_CREATE_BYPASS = ch_usi_dag_disl_DiSL_CodeOption_Flag_CREATE_BYPASS,
CF_DYNAMIC_BYPASS = ch_usi_dag_disl_DiSL_CodeOption_Flag_DYNAMIC_BYPASS,
CF_SPLIT_METHODS = ch_usi_dag_disl_DiSL_CodeOption_Flag_SPLIT_METHODS,
CF_CATCH_EXCEPTIONS = ch_usi_dag_disl_DiSL_CodeOption_Flag_CATCH_EXCEPTIONS,
CF_CREATE_BYPASS = ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS,
CF_DYNAMIC_BYPASS = ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS,
CF_SPLIT_METHODS = ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS,
CF_CATCH_EXCEPTIONS = ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS,
};
/*
......
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