static JNIEnv *my_env_jni_;
static jclass my_cls_jni_;
+struct dbg_info
+{
+ int idx;
+};
+
static void
my_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info) {
if (pair_id) {
dbg_init(&my_dbg_info_merge_pair, &my_dbg_info_merge_sets);
}
+
+/** Return the dbg object index of the given node. A new dbg object is created, if needed. */
+jint Java_firmjni_Dbginfo_getDbgInfoIdx (JNIEnv *env, jclass clss, jint jnode)
+{
+ /*
+ ir_node *node = (ir_node*) jnode;
+
+ dbg_info *info = get_irn_dbg_info (node);
+
+ if (0 == info) {
+ info = get_dbg_info ();
+ set_irn_dbg_info (node, info);
+ }
+
+ return (info->idx);
+ */
+
+ return (0);
+}
+
+/** Return the dbg object index of the given node, or <TT>-1</TT> if none has been set. */
+jint Java_firmjni_Dbginfo_doGetDbgInfoIdx (JNIEnv *env, jclass clss, jint jnode)
+{
+ /*
+ ir_node *node = (ir_node*) jnode;
+
+ dbg_info *info = get_irn_dbg_info (node);
+
+ if (0 == info) {
+ return (-1);
+ }
+
+ return (info->idx);
+ */
+
+ return (0);
+}
public class Dbginfo {
- // Set env var LD_LIBRARY_PATH accordingly.
- static {
- System.loadLibrary("firmjni");
- }
+ public Dbginfo (java.lang.Object file, int line)
+ {
+ _file = file;
+ _line = line;
+ }
+
+ // Set env var LD_LIBRARY_PATH accordingly.
+ static {
+ System.loadLibrary("firmjni");
+ dbgInit ();
+ }
+
+ public static native void dbgInit ();
+
+ /** Return the dbg object index of the given node. A new dbg object is created, if needed. */
+ public static native int getDbgInfoIdx (int node);
- public static native void dbgInit ();
+ /** Return the dbg object index of the given node, or <TT>-1</TT> if none has been set. */
+ public static native int doGetDbgInfoIdx (int node);
- public static void myJavaDbgInfoMergePair(int new_node, int old_node, int info) {
- System.out.println("Optimization: "+ info);
- System.out.println("new Node " + Irnode.getIrnNodeNr(new_node));
- System.out.println("old Node " + Irnode.getIrnNodeNr(old_node));
+ /** Return the dbg object of the given node, or <TT>null</TT> if none has been set. */
+ public static Dbginfo getDbgInfo (int node)
+ {
+ int idx = doGetDbgInfoIdx (node);
+
+ if (-1 == idx) {
+ return (null);
}
- public static void myJavaDbgInfoMergeSets(int new_nodes[], int old_nodes[], int info) {
- System.out.println("Optimization: "+ info);
- System.out.print("new Nodes: ");
- for (int i = 0; i < new_nodes.length; i++)
- System.out.print(Irnode.getIrnNodeNr(new_nodes[i]) + ", ");
- System.out.print("\nold Nodes: ");
- for (int i = 0; i < old_nodes.length; i++)
- System.out.print(Irnode.getIrnNodeNr(old_nodes[i]) + ", ");
- System.out.println("");
+ return (_infos [idx]);
+ }
+
+ public static void setDbgInfo (int node, java.lang.Object file, int line)
+ {
+ int idx = doGetDbgInfoIdx (node);
+
+ if (_infos.length < idx) {
+ Dbginfo [] infos = new Dbginfo [idx+1];
+
+ for (int i = 0; i < _infos.length; i ++) {
+ infos [i] = _infos [i];
+ }
+
+ _infos = infos;
}
+
+ _infos [idx] = new Dbginfo (file, line);
+ }
+
+ public static void myJavaDbgInfoMergePair(int new_node, int old_node, int info) {
+ System.out.println("Optimization: "+ info);
+ System.out.println("new Node " + Irnode.getIrnNodeNr(new_node));
+ System.out.println("old Node " + Irnode.getIrnNodeNr(old_node));
+ }
+
+ public static void myJavaDbgInfoMergeSets(int new_nodes[], int old_nodes[], int info) {
+ System.out.println("Optimization: "+ info);
+ System.out.print("new Nodes: ");
+ for (int i = 0; i < new_nodes.length; i++)
+ System.out.print(Irnode.getIrnNodeNr(new_nodes[i]) + ", ");
+ System.out.print("\nold Nodes: ");
+ for (int i = 0; i < old_nodes.length; i++)
+ System.out.print(Irnode.getIrnNodeNr(old_nodes[i]) + ", ");
+ System.out.println("");
+ }
+
+ /**
+ <P>Return the file this debug info object is from:</P>
+ */
+ public java.lang.Object getFile ()
+ {
+ return (_file);
+ }
+
+ /**
+ <P>Return which line this debug info object is from:</P>
+ */
+ public int getLine ()
+ {
+ return (_line);
+ }
+
+ private java.lang.Object _file;
+ private int _line;
+
+ private static Dbginfo [] _infos = new Dbginfo [1000];
}
CPPFLAGS = -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \
-I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr \
-I$(top_srcdir)/ir/tv -I$(top_srcdir)/ir/debug \
- -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st @CPPFLAGS@
+ -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st \
+ -I$(top_srcdir)/../opt/heapanal \
+ -I$(top_srcdir)/include \
+ -I/usr/local/jdk1.3.1/include \
+ -I/usr/local/jdk1.3.1/include/freebsd @CPPFLAGS@
LDFLAGS += $(topdir)
FIRM_SOURCE_DIR_HEADERS=$(addprefix $(SOURCE_DIR)/,$(FIRM_HEADERS))
# hand implemented members
-IMPL_MEMBERS = Dbginfo.m
+IMPL_MEMBERS = Dbginfo.m Heapanal.m
# The directory containing crecoder.jar and, for now,
# remove_cpp_comands.perl
Dbginfo.java:
- cp $(srcdir)/Dbginfo.java .
- cp $(srcdir)/Dbginfo.c .
+ cp $(top_srcdir)/aux/Dbginfo.java $(top_srcdir)/aux/Dbginfo.c .
+Heapanal.java:
+ cp $(top_srcdir)/aux/Heapanal.java $(top_srcdir)/aux/Heapanal.c .
%.h: %.class
javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=)
gcc $(CPPFLAGS) -c $(@:.o=.c) -o $@
jni: $(HFILES) $(OFILES) # ../libfirm.a
- gcc -shared -fPIC -o $(LIBNAME) *.o -lfirm -L..
+ gcc -shared -fPIC -o $(LIBNAME) *.o -lfirm -L.. -lheapanal -L../../opt/heapanal \
+ -liberty -L../../sw/lib
install:
cp libfirmjni.so $(libdir)