From 8241dd19e4262c12b9d742ab2ca5d11e9d7b34ab Mon Sep 17 00:00:00 2001 From: Florian Liekweg Date: Tue, 27 Apr 2004 12:23:48 +0000 Subject: [PATCH] Added .cvsignore Fixed Dbginfo.c Dbginfo.java [r2773] --- firmjni/.cvsignore | 10 +++++ firmjni/Dbginfo.c | 42 +++++++++++++++++++ firmjni/Dbginfo.java | 99 ++++++++++++++++++++++++++++++++++++-------- firmjni/Makefile.in | 16 ++++--- 4 files changed, 144 insertions(+), 23 deletions(-) create mode 100644 firmjni/.cvsignore diff --git a/firmjni/.cvsignore b/firmjni/.cvsignore new file mode 100644 index 000000000..13c7aa192 --- /dev/null +++ b/firmjni/.cvsignore @@ -0,0 +1,10 @@ +*.java +*.c +*.vcg +*.o +*.h +*.class +sources +testprograms +Makefile +testprograms/Makefile diff --git a/firmjni/Dbginfo.c b/firmjni/Dbginfo.c index a0bfe8cf4..7f19e7e42 100644 --- a/firmjni/Dbginfo.c +++ b/firmjni/Dbginfo.c @@ -21,6 +21,11 @@ static jmethodID sets_id; 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) { @@ -54,3 +59,40 @@ void Java_firmjni_Dbginfo_dbgInit (JNIEnv *env_jni_, jclass cls_jni_) { 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 -1 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); +} diff --git a/firmjni/Dbginfo.java b/firmjni/Dbginfo.java index 4360f8f3d..105da5d27 100644 --- a/firmjni/Dbginfo.java +++ b/firmjni/Dbginfo.java @@ -16,27 +16,90 @@ import firmjni.*; 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 -1 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 null 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(""); + } + + /** +

Return the file this debug info object is from:

+ */ + public java.lang.Object getFile () + { + return (_file); + } + + /** +

Return which line this debug info object is from:

+ */ + public int getLine () + { + return (_line); + } + + private java.lang.Object _file; + private int _line; + + private static Dbginfo [] _infos = new Dbginfo [1000]; } diff --git a/firmjni/Makefile.in b/firmjni/Makefile.in index 7371b5c08..3f715a2d8 100644 --- a/firmjni/Makefile.in +++ b/firmjni/Makefile.in @@ -42,7 +42,11 @@ CLASSFILES = $(MEMBERS:.m=.class) 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) @@ -67,7 +71,7 @@ FIRM_PATH_HEADERS=common/firm.h common/firm_common.h \ 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 @@ -102,9 +106,10 @@ Type_or_entity.h: Type_or_entity.class 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=) @@ -116,7 +121,8 @@ $(OFILES): 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) -- 2.20.1