dynamic native library loading, some inlining changes
authorjowenn <none@none>
Tue, 2 Nov 2004 08:58:26 +0000 (08:58 +0000)
committerjowenn <none@none>
Tue, 2 Nov 2004 08:58:26 +0000 (08:58 +0000)
40 files changed:
Makefile.am
configure.in
contrib/debugSetPathes [new file with mode: 0644]
exceptions.c
gennativetable.c
jit/codegen.inc
jit/codegen.inc.h
jit/i386/codegen.c
jit/inline.c
jit/jit.c
jit/parse.c
jit/reg.h
jit/reg.inc
jit/stack.c
jit/typecheck.c
loader.c
nat/Makefile.am
nat/Runtime.c
nat/gnu_java_nio_SelectorImpl.h
nat/implementednatives.data [new file with mode: 0644]
nat/java_io_ObjectInputStream.h
nat/java_lang_VMSystem.h
nat/java_util_TimeZone.h
native.c
src/native/native.c
src/native/tools/gennativetable.c
src/native/vm/Makefile.am
src/native/vm/VMRuntime.c
src/vm/exceptions.c
src/vm/jit/codegen.inc
src/vm/jit/codegen.inc.h
src/vm/jit/i386/codegen.c
src/vm/jit/inline/inline.c
src/vm/jit/jit.c
src/vm/jit/parse.c
src/vm/jit/reg.h
src/vm/jit/reg.inc
src/vm/jit/stack.c
src/vm/jit/verify/typecheck.c
src/vm/loader.c

index bf7c8e33754b41aca4800c2024e9a6847fa25af6..ad0fc8d882d257d3e2e6f82990afd016355f72ad 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-# $Id: Makefile.am 1333 2004-07-21 15:48:46Z twisti $
+# $Id: Makefile.am 1429 2004-11-02 08:58:26Z jowenn $
 
 @SET_MAKE@
 
@@ -59,12 +59,9 @@ cacao_LDADD = \
        $(BOEHM_LIBS) \
        @THREAD_OBJ@ \
        toolbox/libtoolbox.a \
-       classpath/native/jni/java-io/.libs/libjavaio.a \
-       classpath/native/jni/java-nio/.libs/libjavanio.a \
-       classpath/native/jni/java-net/.libs/libjavanet.a \
-       classpath/native/jni/java-util/.libs/libjavautil.a \
-       classpath/native/jni/java-lang/.libs/libjavalang.a \
-       classpath/native/jni/java-lang/.libs/libjavalangreflect.a \
+        classpath/native/fdlibm/.libs/libfdlibm.a \
+        @STATIC_CLASSPATH_LIBS@ \
+        @DYNAMIC_CLASSPATH_LIBS@ \
        @AWT_OBJS@ \
        @ZIP_LIBS@ \
        @THREAD_LIB@
@@ -78,12 +75,7 @@ cacao_DEPENDENCIES = \
        $(BOEHM_LIBS) \
        @THREAD_OBJ@ \
        toolbox/libtoolbox.a \
-       classpath/native/jni/java-io/.libs/libjavaio.a \
-       classpath/native/jni/java-nio/.libs/libjavanio.a \
-       classpath/native/jni/java-net/.libs/libjavanet.a \
-       classpath/native/jni/java-util/.libs/libjavautil.a \
-       classpath/native/jni/java-lang/.libs/libjavalang.a \
-       classpath/native/jni/java-lang/.libs/libjavalangreflect.a \
+        @STATIC_CLASSPATH_LIBS@ \
        nativetable.inc \
        @AWT_OBJS@ \
        @ZIP_LIBS@
@@ -136,7 +128,7 @@ gennativetable_LDADD = \
 natheaders: cacaoh
        CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip ./cacaoh $(CLASSES)
 
-nativetable.inc: gennativetable
+nativetable.inc: gennativetable nat/implementednatives.data
        CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip $(top_srcdir)/gennativetable $(CLASSES) > nativetable.inc
 
 native.c: nativetable.inc
index f2fb26f1f467963ede2e4416a2985a0024a7058a..b33c2bc9d54191eb6c7a1b436c3c4e4e28eb222b 100644 (file)
@@ -15,6 +15,7 @@ dnl system type
 case "$host_cpu" in
 alpha* )
        ARCH_DIR="alpha"
+        STATIC_CLASSPATH="1"
        CFLAGS="-Wall -O2 -g3 -mieee -D__ALPHA__"
        AC_DEFINE([TRACE_ARGS_NUM], 6, [Defines integer argument register count])
        AC_DEFINE([USE_CODEMMAP], 1, [use code mmap])
@@ -22,6 +23,7 @@ alpha* )
 
 i386* | i486* | i586* | i686* )
        ARCH_DIR="i386"
+        STATIC_CLASSPATH="0"
        CFLAGS="-Wall -O0 -g3 -D__I386__"
        AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
        AC_DEFINE([USE_CODEMMAP], 1, [use code mmap])
@@ -29,6 +31,7 @@ i386* | i486* | i586* | i686* )
 
 mips* )
        ARCH_DIR="mips"
+        STATIC_CLASSPATH="1"
        CFLAGS="-64 -O2 -OPT:Olimit=0 -g -DMAP_ANONYMOUS=0 -woff 1110,1164,1515 -D__MIPS__"
        LIBS="-lelfutil"
        AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
@@ -36,12 +39,14 @@ mips* )
 
 powerpc* | ppc* )
        ARCH_DIR="powerpc"
+        STATIC_CLASSPATH="1"
        CFLAGS="-Wall -O2 -g -DMAP_ANONYMOUS=0 -no-cpp-precomp -D__POWERPC__"
        AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
        ;;
 
 x86_64* )
        ARCH_DIR="x86_64"
+        STATIC_CLASSPATH="1"
        CFLAGS="-Wall -O2 -g3 -D__X86_64__"
        AC_DEFINE([TRACE_ARGS_NUM], 6, [Defines integer argument register count])
        AC_DEFINE([USE_CODEMMAP], 1, [use code mmap])
@@ -72,6 +77,20 @@ AC_SUBST(COMPILER_OBJECTS)
 AC_DEFINE_UNQUOTED([ARCH_DIR], "$ARCH_DIR", [Architecture directory])
 AC_SUBST(ARCH_DIR)
 
+AC_ARG_ENABLE([dynamicclasspath], [AS_HELP_STRING(--disable-dynamicclasspath, link classpath native code static even on platforms supporting dynamic loading)], [use_dynamicclasspath=$enableval], [use_dynamicclasspath=yes])
+dnl force static classpath linking ??
+AC_MSG_CHECKING(Link classpath static)
+if test "xno" == "x$use_dynamicclasspath"; then
+  STATIC_CLASSPATH="1"
+fi
+
+if test "$STATIC_CLASSPATH" == "1"; then
+       AC_MSG_RESULT(yes)
+else
+       AC_MSG_RESULT(no)
+fi
+AC_SUBST(STATIC_CLASSPATH)
+
 dnl Checks for programs.
 AC_PROG_CC
 AM_PROG_AS
@@ -299,6 +318,29 @@ else
 fi
 
 
+if test "x1" == "x$STATIC_CLASSPATH"; then
+       STATIC_CLASSPATH_LIBS=" \
+        classpath/native/jni/java-io/.libs/libjavaio.a \
+        classpath/native/jni/java-nio/.libs/libjavanio.a \
+        classpath/native/jni/java-net/.libs/libjavanet.a \
+        classpath/native/jni/java-util/.libs/libjavautil.a \
+        classpath/native/jni/java-lang/.libs/libjavalang.a \
+        classpath/native/jni/java-lang/.libs/libjavalangreflect.a"
+        DYNAMIC_CLASSPATH_LIBS=""
+       AC_SUBST(STATIC_CLASSPATH_LIBS)
+       AC_SUBST(DYNAMIC_CLASSPATH_LIBS)
+        AC_DEFINE([STATIC_CLASSPATH], 1, [use classpath statically linked])
+
+else
+       DYNAMIC_CLASSPATH_LIBS="-ldl -Wl,--export-dynamic"
+       STATIC_CLASSPATH_LIBS=""
+       AC_SUBST(STATIC_CLASSPATH_LIBS)
+       AC_SUBST(DYNAMIC_CLASSPATH_LIBS)
+fi
+
+
+
+
 dnl now configure boehm gc and gnu classpath
 dnl the export is not my favorite (is there another way?)
 export CFLAGS
diff --git a/contrib/debugSetPathes b/contrib/debugSetPathes
new file mode 100644 (file)
index 0000000..20f93f6
--- /dev/null
@@ -0,0 +1,7 @@
+export LD_LIBRARY_PATH=$PWD/classpath/native/jni/java-lang/.libs:$PWD/classpath/native/jni/java-io/.libs:$PWD/classpath/native/jni/java-nio/.libs:\
+$PWD/classpath/native/jni/java-util/.libs:$PWD/classpath/native/jni/java-awt/.libs:$PWD/classpath/native/jni/gtk-peer/.libs:\
+$PWD/classpath/native/jni/java-io/.libs:$PWD/classpath/native/jni/classpath/.libs:\
+$PWD/classpath/native/jni/java-net/.libs:$LD_LIBRARY_PATH
+export CLASSPATH=.:$PWD/classpath/lib/glibj.zip:$CLASSPATH
+export PATH=$PWD:$PATH
+
index 5bf3ec89a49b9b4fd6a1be4013a452f8c546a204..e34a4bfa4e17d046c73899de1676c44441db6fff 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: exceptions.c 1410 2004-08-17 13:01:24Z twisti $
+   $Id: exceptions.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -283,8 +283,9 @@ void throw_cacao_exception_exit(char *exception, char *message)
        s4 len;
 
        len = strlen(exception);
-       tmp = MNEW(char, len);
+       tmp = MNEW(char, len+1);
        strncpy(tmp, exception, len);
+        tmp[len]='\0';
 
        /* convert to classname */
 
index 77acc2180a9172dcef7084d6c5da5bc8c7beeebf..66a5f511cb374cb417e70b343238c50e34818b39 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: gennativetable.c 1405 2004-08-17 09:25:01Z twisti $
+   $Id: gennativetable.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -160,9 +160,11 @@ int main(int argc, char **argv)
        if (!file)
                panic("Can not open file 'nativetable' to store native-link-table");
 
-       fprintf(file, "/* Table of native methods: nativetables.hh */\n");
+       fprintf(file, "/* Table of native methods: nativetables.inc */\n");
        fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n"); 
 
+        fprintf(file, "#include \"config.h\"\n");
+
        c = chain_first(nativeclass_chain);
        while (c) {
                gen_header_filename(classname, c->name);
@@ -172,6 +174,7 @@ int main(int argc, char **argv)
        chain_free(nativeclass_chain);
 
        fprintf(file, "\n\n#include \"native.h\"\n\n");
+        fprintf(file, "#ifdef STATIC_CLASSPATH\n\n");
        fprintf(file, "static nativeref nativetable[] = {\n");
 
        m = chain_first(nativemethod_chain);
@@ -182,9 +185,28 @@ int main(int argc, char **argv)
        chain_free(nativemethod_chain);
 
        fprintf(file, "};\n");
-
+        fprintf(file,"\n#else\n");
+        fprintf(file, "/*ensure that symbols for functions implemented within cacao are used and exported to dlopen*/\n");
+        fprintf(file, "static functionptr dummynativetable[]={\n");
+       {
+               FILE *implData=fopen("nat/implementednatives.data","r");
+                if (!implData) {fclose(file); exit(3);}
+               while (!feof(implData)) {
+                       char functionLine[1024];
+                        functionLine[0]='\0';
+                       fgets(functionLine,1024,implData);
+                        if (strlen(functionLine)<2) continue;
+                       if (functionLine[strlen(functionLine)-1]!='\n') { fclose(implData); fclose(file); exit(4);}
+                        functionLine[strlen(functionLine)-1]=',';
+                       fprintf(file,"\t(functionptr) %s\n",functionLine);
+               }
+               fprintf(file,"\t(functionptr)0");
+                fclose(implData);
+       }
+        fprintf(file, "};\n");
+        fprintf(file,"\n#endif\n");
        fclose(file);
-
+       
        /* release all resources */
 
        loader_close();
index 6f127e4946161771a7c91fef51a169986f3058cf..e1038c05d594ad6c6177f22992c65a949052e19e 100644 (file)
@@ -48,7 +48,7 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen.inc 1420 2004-10-27 16:05:14Z twisti $
+   $Id: codegen.inc 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -63,7 +63,9 @@
 #include "toolbox/logging.h"
 #include "toolbox/avl.h"
 #include "threads/thread.h"
-
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
 
 /* in this tree we store all method addresses */
 
@@ -156,7 +158,13 @@ void codegen_setup(methodinfo *m, t_inlining_globals * e)
                        cd->exceptiontablelength=m->exceptiontablelength;
                        cd->exceptiontable  = MNEW(exceptiontable, m->exceptiontablelength + 1);
        }
-
+        if (e) {
+          cd->maxstack=e->cummaxstack;
+          cd->maxlocals=e->cumlocals;
+        } else {
+          cd->maxstack=m->maxstack;
+          cd->maxlocals=m->maxlocals;
+        }
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
        cd->threadcritcurrent.next = NULL;
        cd->threadcritcount = 0;
@@ -878,6 +886,156 @@ static void codegen_threadcritstop(methodinfo *m, int offset)
 }
 #endif
 
+#ifndef STATIC_CLASSPATH
+static size_t codegen_overloadPartLen(utf *desc) {
+        char *utf_ptr=desc->text;
+        u2 c;
+       size_t len=2;
+        while ((c=utf_nextu2(&utf_ptr))!=')') {
+                switch (c) {
+                        case 'I':
+                        case 'S':
+                        case 'B':
+                        case 'C':
+                        case 'Z':
+                        case 'J':
+                        case 'F':
+                        case 'D':
+                               len ++;
+                               break;
+                        case '[':
+                                len = len+2;
+                                break;
+                        case 'L':
+                                len++;
+                                while ( (c=utf_nextu2(&utf_ptr)) != ';')
+                                        len++;
+                                len=len+2;
+                                break;
+                        case '(':
+                                break;
+                        default: panic ("invalid method descriptor");
+                }
+        }
+       return len;
+
+}
+
+static void codegen_fillInOverloadPart(char *target,utf *desc) {
+        char *utf_ptr=desc->text;
+        u2 c;
+       char* insertpos=&target[strlen(target)];
+       *(insertpos++)='_';
+       *(insertpos++)='_';
+        while ((c=utf_nextu2(&utf_ptr))!=')') {
+                switch (c) {
+                        case 'I':
+                        case 'S':
+                        case 'B':
+                        case 'C':
+                        case 'Z':
+                        case 'J':
+                        case 'F':
+                        case 'D':
+                                *(insertpos++)=c;
+                                break;
+                        case '[':
+                               *(insertpos++)='_';
+                               *(insertpos++)='3';
+                                break;
+                        case 'L':
+                               *(insertpos++)='L';
+                                while ( (c=utf_nextu2(&utf_ptr)) != ';')
+                                       if ( ((c>='a') && (c<='z'))  ||
+                                               ((c>='A') && (c<='Z')) ||
+                                               ((c>='0') && (c<='9')) )
+                                                       *(insertpos++)=c;
+                                       else *(insertpos++)='_';
+                               *(insertpos++)='_';
+                               *(insertpos++)='2';
+                                break;
+                        case '(':
+                                break;
+                        default: panic ("invalid method descriptor");
+                }
+        }
+       *insertpos='\0';
+
+}
+
+static void codegen_resolve_native(methodinfo *m,void **insertionPoint,void *jmpTarget,void **jmpPatchTarget) {
+  char *nativeName;
+  size_t nativeLen;
+  size_t i;
+
+  builtin_monitorenter((java_objectheader*) m);
+  if ((*jmpPatchTarget)==jmpTarget) {
+    builtin_monitorexit((java_objectheader*) m);
+    return;
+  }
+  log_text("trying to resolve a native method");
+  utf_display(m->class->name);
+  utf_display(m->name);
+  
+  void *lib=dlopen(0,RTLD_NOW | RTLD_GLOBAL);
+  if (lib) {
+    int ok=0;
+    /*generate the name of the native function in the form Java_package1_package2...._classname_methodname*/
+    nativeLen=/*Java_*/5+strlen(m->class->name->text)+/*_*/1+strlen(m->name->text)+/*\0*/1;
+    nativeName=MNEW(char,nativeLen);
+    sprintf(nativeName,"Java_%s_%s",m->class->name->text,m->name->text);
+    for (i=0;i<nativeLen;i++) {
+      if (nativeName[i]=='/') nativeName[i]='_';
+    } 
+
+
+    void *sym=dlsym(lib,nativeName);
+    if (sym) {
+      ok=1;
+      log_text("resolved");
+      MFREE(nativeName,char,nativeLen);
+    } else {
+      size_t overloadedNativeLen=nativeLen+codegen_overloadPartLen(m->descriptor);
+      char *overloadedNative=MNEW(char,overloadedNativeLen);
+      sprintf(overloadedNative,"%s",nativeName);
+      MFREE(nativeName,char,nativeLen);
+      codegen_fillInOverloadPart(overloadedNative,m->descriptor);
+      log_text("symbol not found,trying harder (overloaded member ?)");
+      sym=dlsym(lib,overloadedNative);
+      if (sym) {
+        MFREE(overloadedNative,char,overloadedNativeLen);
+        ok=1;
+        log_text("resolved");
+      } else { 
+         MFREE(overloadedNative,char,overloadedNativeLen);
+         log_text("It was not possible to find the native function implementation. Not even in overloading case");
+      }
+   }
+    if (ok) {
+      (*insertionPoint)=sym;
+      (*jmpPatchTarget)=jmpTarget;
+      builtin_monitorexit((java_objectheader *) m );
+      return;
+    }
+
+  } else log_text("library not found");
+  
+
+  {
+    char *info;
+    size_t slen;
+    slen=2+strlen(m->class->name->text)+strlen(m->name->text)+strlen(m->descriptor->text);
+    info=(char*)MNEW(char,slen);
+    sprintf(info,"%s.%s%s",m->class->name->text,m->name->text,m->descriptor->text);
+    
+    builtin_monitorexit((java_objectheader *) m );
+    throw_cacao_exception_exit(string_java_lang_LinkageError,
+                                                       info);
+  }
+  
+}
+#endif
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
index 6b57ed670a820441f6a42c69f1a0404a23f89bb3..18a1d5ee76a2d9598a1e5c4a198ba44e740bbc26 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: codegen.inc.h 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: codegen.inc.h 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -104,6 +104,8 @@ struct codegendata {
        threadcritnodetemp *threadcrit; /* List of critical code regions          */
        threadcritnodetemp threadcritcurrent;
        s4 threadcritcount;             /* Number of critical regions             */
+        int maxstack;
+        int maxlocals;
 };
 
 
index 94ab359b1ca6dc86263fe2b80b8d0e7a7a8f3544..e44a002fb147f8ed26dc62ffaeee862f20490f6a 100644 (file)
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: codegen.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
 #define _GNU_SOURCE
 
+#include "config.h"
 #include "global.h"
 #include <stdio.h>
 #include <signal.h>
@@ -51,7 +52,6 @@
 #include "jit/reg.h"
 #include "jit/i386/codegen.h"
 #include "jit/i386/emitfuncs.h"
-
 /* include independent code generation stuff */
 #include "jit/codegen.inc"
 #include "jit/reg.inc"
@@ -4833,6 +4833,9 @@ u1 *createnativestub(functionptr f, methodinfo *m)
     int p, t;
        codegendata *cd;
 
+    void**  callAddrPatchPos=0;
+    u1* jmpInstrPos=0;
+    void** jmpInstrPatchPos=0;
        /* setup codegendata structure */
        codegen_setup(m,0);
 
@@ -4994,6 +4997,41 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
 /* CREATE DYNAMIC STACK INFO -- END*/
 
+/* RESOLVE NATIVE METHOD -- BEGIN*/
+#ifndef STATIC_CLASSPATH
+   if (f==0) {
+     log_text("Dynamic classpath: preparing for delayed native function resolving");
+     i386_jmp_imm(cd,0);
+     jmpInstrPos=cd->mcodeptr-4;
+     /*patchposition*/
+     i386_mov_imm_reg(cd,jmpInstrPos,REG_ITMP1);
+     i386_push_reg(cd,REG_ITMP1);
+     /*jmp offset*/
+     i386_mov_imm_reg(cd,0,REG_ITMP1);
+     jmpInstrPatchPos=cd->mcodeptr-4;
+     i386_push_reg(cd,REG_ITMP1);
+     /*position of call address to patch*/
+     i386_mov_imm_reg(cd,0,REG_ITMP1);
+     callAddrPatchPos=(cd->mcodeptr-4);
+     i386_push_reg(cd,REG_ITMP1);
+     /*method info structure*/
+     i386_mov_imm_reg(cd,(s4) m, REG_ITMP1);
+     i386_push_reg(cd,REG_ITMP1);
+     /*call resolve functions*/
+     i386_mov_imm_reg(cd, (s4)codegen_resolve_native,REG_ITMP1);
+     i386_call_reg(cd,REG_ITMP1);
+     /*cleanup*/
+     i386_pop_reg(cd,REG_ITMP1);
+     i386_pop_reg(cd,REG_ITMP1);
+     i386_pop_reg(cd,REG_ITMP1);
+     i386_pop_reg(cd,REG_ITMP1);
+     /*fix jmp offset replacement*/
+     (*jmpInstrPatchPos)=cd->mcodeptr-jmpInstrPos-4;
+   } else log_text("Dynamic classpath: immediate native function resolution possible");
+#endif
+/* RESOLVE NATIVE METHOD -- END*/
+
+
 
     tptr = m->paramtypes;
     for (i = 0; i < m->paramcount; i++) {
@@ -5029,7 +5067,12 @@ u1 *createnativestub(functionptr f, methodinfo *m)
        i386_mov_imm_membase(cd, (s4) &env, REG_SP, 0);
 
     i386_mov_imm_reg(cd, (s4) f, REG_ITMP1);
+#ifndef STATIC_CLASSPATH
+    if (f==0)
+      (*callAddrPatchPos)=(cd->mcodeptr-4);
+#endif
     i386_call_reg(cd, REG_ITMP1);
+
 /*REMOVE DYNAMIC STACK INFO -BEGIN */
     i386_push_reg(cd, REG_RESULT2);
     i386_mov_membase_reg(cd, REG_SP,stackframesize-8,REG_ITMP2); /*old value*/
index 1f59f473b59202c6fd1d892c62d9b53bd5080838..4448bc7265fdbef460dd9aa45fd5b32b33016e7e 100644 (file)
@@ -28,7 +28,7 @@ globals moved to structure and passed as parameter
 
    Authors: Dieter Thuernbeck
 
-   $Id: inline.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: inline.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -73,7 +73,7 @@ t_inlining_globals *inlining_init0(methodinfo *m,
         inlining_set_compiler_variables_fun(m, inline_env);
         inline_env->isinlinedmethod = 0;
        inline_env->cumjcodelength = m->jcodelength; /* for not inlining */
-        inline_env->cummaxstack = 0;
+        inline_env->cummaxstack = m->maxstack; /*why has here been 0 ? */
         inline_env->cumextablelength = 0;
         inline_env->cumlocals = m->maxlocals;
         inline_env->cummethods = 0;//co not global or static-used only here?
@@ -113,9 +113,11 @@ if (DEBUGi==true) {
     m->maxlocals, inline_env->cumlocals,
     m->maxstack,  inline_env->cummaxstack); fflush(stdout);
   }
+#if 0
+/*This looks wrong*/
         m->maxlocals = inline_env->cumlocals;   //orig not used
         m->maxstack = inline_env->cummaxstack;  //orig global maxstack var!!
-
+#endif
 //panic("TEMP so can test just inline init\n");
         }
 return inline_env;
index b5e423bcfb4fd0f8cbc4b5305b9e2786275658c0..9303d020cf9e2c6e36a057b122f9f6e12400228b 100644 (file)
--- a/jit/jit.c
+++ b/jit/jit.c
@@ -29,7 +29,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: jit.c 1420 2004-10-27 16:05:14Z twisti $
+   $Id: jit.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -1501,7 +1501,7 @@ t_inlining_globals *inline_env = NULL;
 
        EXTABLEN
 
-       reg_setup(m);
+       reg_setup(inline_env);
 
        /* setup the codegendata memory */
        codegen_setup(m,inline_env);
index 1308a091c998c9ba5ae74b02ae7d2d1fec1bcb72..5b2841cb48bd082df8ef2557c0235ee4dd3ccc2f 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Carolyn Oates
             Edwin Steiner
 
-   $Id: parse.c 1421 2004-10-28 14:39:49Z stefan $
+   $Id: parse.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -566,7 +566,7 @@ if (opt_rt) {
                if ((useinlining) && (gp == nextgp)) {
                        u1 *tptr;
                        bool *readonly = NULL;
-
+                       int argBlockIdx=0;
 
                        opcode = code_get_u1(p,inline_env->method);
                        nextp = p += jcommandsize[opcode];
@@ -577,6 +577,13 @@ if (opt_rt) {
                        label_index = tmpinlinf->label_index;
                        readonly = tmpinlinf->readonly;
 
+                       for (i=0,tptr=tmpinlinf->method->paramtypes;i<tmpinlinf->method->paramcount;i++,tptr++) {
+                               if ( ((*tptr)==TYPE_LNG) ||
+                                 ((*tptr)==TYPE_DBL) )
+                                       argBlockIdx+=2;
+                               else
+                                       argBlockIdx++;
+                       }
                        for (i = 0, tptr = tmpinlinf->method->paramtypes + tmpinlinf->method->paramcount - 1; i < tmpinlinf->method->paramcount; i++, tptr--) {
                                int op;
 
@@ -592,8 +599,15 @@ if (opt_rt) {
                                }
 
                                op += *tptr;
-                               OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
-
+                               if ( ((*tptr)==TYPE_LNG) ||
+                                 ((*tptr)==TYPE_DBL) )
+                                       argBlockIdx-=2;
+                               else
+                                       argBlockIdx--;
+
+                               OP1(op, firstlocal + argBlockIdx);
+                               //OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
+                       //printf("inline argument load operation for local: %ld\n",firstlocal + tmpinlinf->method->paramcount - 1 - i);
                                /*m->basicblockindex[gp] |= (ipc << 1);*/  /*FIXME: necessary ? */
                        }
 if (DEBUG==true) {
@@ -1021,6 +1035,13 @@ SHOWOPCODE
                                /*                                              OP(ICMD_NOP); */
                                /*                                              break; */
                                /*                                      } */
+                               if (nextp>inline_env->method->jcodelength-1) {
+                                  //OP1(ICMD_GOTO, inlinfo->stopgp);
+                                   //OP(ICMD_NOP);
+                                   //OP(ICMD_NOP);
+                                   blockend=true;
+                                   break;
+                                }//JJJJJJJ
                                blockend = true;
                                OP1(ICMD_GOTO, inlinfo->stopgp);
                                break;
@@ -1616,7 +1637,8 @@ if (DEBUG4==true)
                
                /* INLINING */
                  
-               if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+//             if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+               if (inline_env->isinlinedmethod && (nextp >= inline_env->method->jcodelength) ) { /* end of an inlined method */
                        /*                printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
                        gp = inlinfo->stopgp; 
                        inlining_restore_compiler_variables();
@@ -1639,9 +1661,10 @@ DEBUGMETH(inline_env->method);
        } /* end for */
 
 
-       if (p != m->jcodelength)
+       if (p != m->jcodelength) {
+               printf("p (%ld) != m->jcodelength (%ld)\n",p,m->jcodelength);
                panic("Command-sequence crosses code-boundary");
-
+       }
        if (!blockend) {
                *exceptionptr = new_verifyerror(m, "Falling off the end of the code");
                return NULL;
index 7b55ba3b481725d669b5dd0224c8cfd1f2fb9ec9..77bf1d7b20ff7ac2b673310a0ec0d4b4d4f386f6 100644 (file)
--- a/jit/reg.h
+++ b/jit/reg.h
@@ -27,7 +27,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: reg.h 1234 2004-06-30 19:49:37Z twisti $
+   $Id: reg.h 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -43,6 +43,8 @@
 typedef struct registerdata registerdata;
 typedef varinfo varinfo5[5];
 
+struct t_inlining_globals;
+
 
 struct registerdata {
        varinfo5 *locals;
@@ -117,7 +119,7 @@ struct registerdata {
 /* function prototypes */
 
 void reg_init(methodinfo *m);
-void reg_setup(methodinfo *m);
+void reg_setup(struct t_inlining_globals *e);
 void reg_close(methodinfo *m);
 void regalloc(methodinfo *m);
 
index ba0f7ccfc901577383d7a36e504a871765fc69ad..2ab7369487356eedf6d093c1d2925f7d90a64bc0 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Stefan Ring
             Christian Thalinger
 
-   $Id: reg.inc 1342 2004-07-21 16:10:17Z twisti $
+   $Id: reg.inc 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -204,16 +204,16 @@ void reg_init(methodinfo *m)
 }
 
 
-void reg_setup(methodinfo *m)
+void reg_setup(t_inlining_globals *e)
 {
        s4 i;
        varinfo5 *v;
+       methodinfo *m=e->method;
+       m->registerdata->freemem    = MNEW(s4, e->cummaxstack);
+       m->registerdata->locals     = MNEW(varinfo5, e->cumlocals);
+       m->registerdata->interfaces = MNEW(varinfo5, e->cummaxstack);
 
-       m->registerdata->freemem    = MNEW(s4, m->maxstack);
-       m->registerdata->locals     = MNEW(varinfo5, m->maxlocals);
-       m->registerdata->interfaces = MNEW(varinfo5, m->maxstack);
-
-       for (v = m->registerdata->locals, i = m->maxlocals; i > 0; v++, i--) {
+       for (v = m->registerdata->locals, i = e->cumlocals; i > 0; v++, i--) {
                v[0][TYPE_INT].type = -1;
                v[0][TYPE_LNG].type = -1;
                v[0][TYPE_FLT].type = -1;
@@ -221,7 +221,7 @@ void reg_setup(methodinfo *m)
                v[0][TYPE_ADR].type = -1;
        }
 
-       for (v = m->registerdata->interfaces, i = m->maxstack; i > 0; v++, i--) {
+       for (v = m->registerdata->interfaces, i = e->cummaxstack; i > 0; v++, i--) {
                v[0][TYPE_INT].type = -1;
                v[0][TYPE_INT].flags = 0;
                v[0][TYPE_LNG].type = -1;
@@ -267,9 +267,9 @@ void reg_close(methodinfo *m)
        if (r->secondregs) MFREE(r->secondregs, s4, r->intregsnum);
 #endif
 
-       if (r->freemem) MFREE(r->freemem, s4, m->maxstack);
-       if (r->locals)  MFREE(r->locals, varinfo5, m->maxlocals);
-       if (r->interfaces) MFREE(r->interfaces, varinfo5, m->maxstack);
+       if (r->freemem) MFREE(r->freemem, s4, m->codegendata->maxstack);
+       if (r->locals)  MFREE(r->locals, varinfo5, m->codegendata->maxlocals);
+       if (r->interfaces) MFREE(r->interfaces, varinfo5, m->codegendata->maxstack);
 
        FREE(m->registerdata, registerdata);
        m->registerdata = NULL;
@@ -343,7 +343,7 @@ static void interface_regalloc(methodinfo *m)
        r->iftmpfltregcnt = r->tmpfltregcnt;
        r->ifsavfltregcnt = r->savfltregcnt;
 
-       for (s = 0; s < m->maxstack; s++) {
+       for (s = 0; s < m->codegendata->maxstack; s++) {
                intalloc = -1; fltalloc = -1;
                saved = (r->interfaces[s][TYPE_INT].flags |
                                 r->interfaces[s][TYPE_LNG].flags |
@@ -495,7 +495,7 @@ static void local_regalloc(methodinfo *m)
 
                arg = 0, iargcnt = 0, fargcnt = 0;
                doublewordarg = 0;
-               for (s = 0; s < m->maxlocals; s++) {
+               for (s = 0; s < m->codegendata->maxlocals; s++) {
                        intalloc = -1; fltalloc = -1;
                        for (tt = 0; tt <= 4; tt++) {
                                t = typeloop[tt];
@@ -624,7 +624,7 @@ static void local_regalloc(methodinfo *m)
                return;
        }
 
-       for (s = 0; s < m->maxlocals; s++) {
+       for (s = 0; s < m->codegendata->maxlocals; s++) {
                intalloc = -1; fltalloc = -1;
                for (tt=0; tt<=4; tt++) {
                        t = typeloop[tt];
index da3ccbf6f3a42b05e9d57daac6b79607cd11c6f7..141025eadd49b468ef82121a7878e0f00d1c74f3 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: stack.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: stack.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -94,8 +94,8 @@ methodinfo *analyse_stack(codegendata *codegendata)
        s4 *argren;
        methodinfo *m=codegendata->method;
 
-       argren = DMNEW(s4, m->maxlocals);   /* table for argument renaming        */
-       for (i = 0; i < m->maxlocals; i++)
+       argren = DMNEW(s4, m->codegendata->maxlocals);   /* table for argument renaming        */
+       for (i = 0; i < m->codegendata->maxlocals; i++)
                argren[i] = i;
        
        m->registerdata->arguments_num = 0;
@@ -210,6 +210,7 @@ methodinfo *analyse_stack(codegendata *codegendata)
                                }
                                else if (bptr->indepth != stackdepth) {
                                        show_icmd_method(m);
+                                       printf("Block: %ld, required depth:%ld, current depth:%ld\n",bptr->debug_nr,bptr->indepth,stackdepth);
                                        panic("Stack depth mismatch");
                                        
                                }
@@ -1849,7 +1850,7 @@ methodinfo *analyse_stack(codegendata *codegendata)
                                                break;
 
                                        case ICMD_CLEAR_ARGREN:
-                                               for (i = iptr->op1; i<m->maxlocals; i++) 
+                                               for (i = iptr->op1; i<m->codegendata->maxlocals; i++) 
                                                        argren[i] = i;
                                                iptr->opc = opcode = ICMD_NOP;
                                                SETDST;
@@ -1984,14 +1985,14 @@ void icmd_print_stack(methodinfo *m, stackptr s)
        int i, j;
        stackptr t;
 
-       i = m->maxstack;
+       i = m->codegendata->maxstack;
        t = s;
        
        while (t) {
                i--;
                t = t->prev;
        }
-       j = m->maxstack - i;
+       j = m->codegendata->maxstack - i;
        while (--i >= 0)
                printf("    ");
        while (s) {
@@ -2128,8 +2129,8 @@ void show_icmd_method(methodinfo *m)
        printf(".");
        utf_fprint(stdout, m->name);
        utf_fprint_classname(stdout, m->descriptor);
-       printf ("\n\nMax locals: %d\n", (int) m->maxlocals);
-       printf ("Max stack:  %d\n", (int) m->maxstack);
+       printf ("\n\nMax locals: %d\n", (int) m->codegendata->maxlocals);
+       printf ("Max stack:  %d\n", (int) m->codegendata->maxstack);
 
        printf ("Line number table length: %d\n", m->linenumbercount);
 
@@ -2141,7 +2142,7 @@ void show_icmd_method(methodinfo *m)
        }
        
        printf ("Local Table:\n");
-       for (i = 0; i < m->maxlocals; i++) {
+       for (i = 0; i < m->codegendata->maxlocals; i++) {
                printf("   %3d: ", i);
                for (j = TYPE_INT; j <= TYPE_ADR; j++)
                        if (m->registerdata->locals[i][j].type >= 0) {
@@ -2159,7 +2160,7 @@ void show_icmd_method(methodinfo *m)
        printf("\n");
 
        printf ("Interface Table:\n");
-       for (i = 0; i < m->maxstack; i++) {
+       for (i = 0; i < m->codegendata->maxstack; i++) {
                if ((m->registerdata->interfaces[i][0].type >= 0) ||
                        (m->registerdata->interfaces[i][1].type >= 0) ||
                    (m->registerdata->interfaces[i][2].type >= 0) ||
@@ -2232,7 +2233,7 @@ void show_icmd_block(methodinfo *m, basicblock *bptr)
                deadcode = bptr->flags <= BBREACHED;
                printf("[");
                if (deadcode)
-                       for (j = m->maxstack; j > 0; j--)
+                       for (j = m->codegendata->maxstack; j > 0; j--)
                                printf(" ?  ");
                else
                        icmd_print_stack(m, bptr->instack);
@@ -2242,7 +2243,7 @@ void show_icmd_block(methodinfo *m, basicblock *bptr)
                for (i = 0; i < bptr->icount; i++, iptr++) {
                        printf("[");
                        if (deadcode) {
-                               for (j = m->maxstack; j > 0; j--)
+                               for (j = m->codegendata->maxstack; j > 0; j--)
                                        printf(" ?  ");
                        }
                        else
@@ -2617,9 +2618,10 @@ void show_icmd(instruction *iptr, bool deadcode)
                break;
        }
 /*     printf(" Line number: %d, method:",iptr->line); */
-/*     utf_display(iptr->method->class->name); */
-/*     printf("."); */
-/*     utf_display(iptr->method->name); */
+        printf("\t\t");
+       utf_display(iptr->method->class->name); 
+       printf("."); 
+       utf_display(iptr->method->name); 
 }
 
 
index 76be4259cc33b530fd312e9f0caaca311ec01a18..0674f0923ab1732ca20f013d250e8c1a056a5d40 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Edwin Steiner
 
-   $Id: typecheck.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: typecheck.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -678,23 +678,41 @@ is_accessible(int flags,classinfo *definingclass,classinfo *implementingclass, c
 #define STORE_TWOWORD(num,type)                                                                                \
        do {typevectorset_store_twoword(localset,num,type);} while(0)
 
+
+#define WORDCHECKFAULT \
+       do { \
+               show_icmd_method(m); \
+               dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n", \
+               iptr->op1,iptr->method->class->name->text, \
+                       iptr->method->name->text,m->class->name->text,m->name->text); \
+               show_icmd(iptr++, false); \
+               show_icmd(iptr, false); \
+       } while (0)
+
+
 #define CHECK_ONEWORD(num,tp)                                                                                  \
        do {TYPECHECK_COUNT(stat_ins_primload);                                                         \
                if (jsrencountered) {                                                                                   \
-                       if (!typevectorset_checktype(localset,num,tp))                          \
+                       if (!typevectorset_checktype(localset,num,tp)) {                                \
+                               WORDCHECKFAULT; \
                                panic("Variable type mismatch");                                                \
+                       }       \
                }                                                                                                                               \
                else {                                                                                                                  \
-                       if (localset->td[num].type != tp)                                                       \
+                       if (localset->td[num].type != tp) {                                                     \
                                panic("Variable type mismatch");                                                \
+                               WORDCHECKFAULT; \
+                       } \
                }                                                                                                                               \
                } while(0)
 
 #define CHECK_TWOWORD(num,type)                                                                                        \
        do {TYPECHECK_COUNT(stat_ins_primload);                                                         \
-               if (!typevectorset_checktype(localset,num,type))                \
-            panic("Variable type mismatch");                           \
-               } while(0)
+               if (!typevectorset_checktype(localset,num,type)) {                \
+                       WORDCHECKFAULT; \
+                       panic("Variable type mismatch");                                \
+               } \
+       } while(0)
 
 /****************************************************************************/
 /* MACROS FOR STACK TYPE CHECKING                                           */
@@ -826,7 +844,7 @@ methodinfo *typecheck(codegendata *codegendata)
 #ifdef TYPECHECK_STATISTICS
        int count_iterations = 0;
        TYPECHECK_COUNT(stat_typechecked);
-       TYPECHECK_COUNT_FREQ(stat_locals,m->maxlocals,STAT_LOCALS);
+       TYPECHECK_COUNT_FREQ(stat_locals,m->codegendata->maxlocals,STAT_LOCALS);
        TYPECHECK_COUNT_FREQ(stat_blocks,m->basicblockcount/10,STAT_BLOCKS);
 #endif
 
@@ -882,7 +900,7 @@ methodinfo *typecheck(codegendata *codegendata)
     
     /* In <init> methods we use an extra local variable to signal if
      * the 'this' reference has been initialized. */
-    numlocals = m->maxlocals;
+    numlocals = m->codegendata->maxlocals;
        validlocals = numlocals;
     if (initmethod) numlocals++;
 
@@ -1096,8 +1114,14 @@ methodinfo *typecheck(codegendata *codegendata)
                                                          typevectorset_copymergedtype(localset,iptr->op1,&(dst->typeinfo));
                                                  }
                                                  else {
-                                                         if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1]))
+                                                         if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1])) {
+                                                                 show_icmd_method(m);
+                                                                 dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n",
+                                                                       iptr->op1,iptr->method->class->name->text,
+                                                                       iptr->method->name->text,m->class->name->text,m->name->text);
+                                                                 show_icmd(iptr, false);
                                                                  panic("illegal instruction: ALOAD loading non-reference");
+                                                         }
                                                          TYPEINFO_COPY(localset->td[iptr->op1].info,dst->typeinfo);
                                                  }
                           break;
@@ -1648,9 +1672,9 @@ methodinfo *typecheck(codegendata *codegendata)
                                                                                          LOG("saving input stack types");
                                                                                          if (!savedstackbuf) {
                                                                                                  LOG("allocating savedstack buffer");
-                                                                                                 savedstackbuf = DMNEW(stackelement,m->maxstack);
+                                                                                                 savedstackbuf = DMNEW(stackelement,m->codegendata->maxstack);
                                                                                                  savedstackbuf->prev = NULL;
-                                                                                                 for (i=1; i<m->maxstack; ++i)
+                                                                                                 for (i=1; i<m->codegendata->maxstack; ++i)
                                                                                                          savedstackbuf[i].prev = savedstackbuf+(i-1);
                                                                                          }
                                                                                          sp = savedstack = bptr->instack;
index bdfe7d691199c80fdd3d742dc47a8b15bebc93da..e89dcbed23481ddd8e495edee6f7c29b19475811 100644 (file)
--- a/loader.c
+++ b/loader.c
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: loader.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: loader.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -1342,8 +1342,11 @@ static bool method_load(classbuffer *cb, classinfo *c, methodinfo *m)
                        method_display(m);
                }*/
                functionptr f = native_findfunction(c->name, m->name, m->descriptor, 
-                                                                                       (m->flags & ACC_STATIC) != 0);
-               if (f) {
+                                                       (m->flags & ACC_STATIC) != 0);
+#ifdef STATIC_CLASSPATH
+               if (f) 
+#endif
+                {
                        m->stubroutine = createnativestub(f, m);
                }
        }
index ad08458ecc598558674eeee7ea67f6e2feb19bf6..17daa91a6b8e9a1ae53b91f35fd2bc39c7ee4e42 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-# $Id: Makefile.am 1173 2004-06-16 14:56:18Z jowenn $
+# $Id: Makefile.am 1429 2004-11-02 08:58:26Z jowenn $
 
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/jit/@ARCH_DIR@
@@ -34,6 +34,15 @@ libnat_a_SOURCES = \
        GtkLabelPeer.c \
        GtkScrollPanePeer.c
 
+implementedNatives:
+       echo "">implementednatives.data
+       grep "JNICALL Java_" *.c | perl -p -i -e "s/.*JNICALL\s//" | perl -p -i -e"s/\(.*//"  | (\
+               while read line; do \
+                       grep $$line *.h >/dev/null ; \
+                       if test $$? == 0; then \
+                               echo $$line >>implementednatives.data ;\
+                       fi ;\
+               done )
 
 ## Local variables:
 ## mode: Makefile
index 5606ce4371667172c046ed7ef0cf17706cb346a2..42684cb49a5e823bed1899c2aad76363f0e57756 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: Runtime.c 1344 2004-07-21 17:12:53Z twisti $
+   $Id: Runtime.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
 #include "java_util_Properties.h"    /* needed for java_lang_Runtime.h */
 #include "java_lang_VMRuntime.h"
 
+#include "config.h"
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
 
 #define JOWENN_DEBUG
 
@@ -63,7 +67,7 @@ static s4 finalizeOnExit = false;
 
 #define MAXPROPS 100
 static bool shouldFinalizersBeRunOnExit=false;
-static int activeprops = 19;  
+static int activeprops = 20;  
    
 static char *proplist[MAXPROPS][2] = {
        { "java.class.path", NULL },
@@ -75,6 +79,7 @@ static char *proplist[MAXPROPS][2] = {
        { "os.arch", NULL },
        { "os.name", NULL },
        { "os.version", NULL },
+        { "java.library.path",NULL},
                                          
        { "java.class.version", "45.3" },
        { "java.version", PACKAGE":"VERSION },
@@ -249,7 +254,8 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
        char *buffer;
        int buffer_len;
        utf *data;
-       
+       int retVal=0;
+
        data = javastring_toutf(par1, 0);
        
        if (!data) {
@@ -261,16 +267,25 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
 
                
        buffer = MNEW(char, buffer_len);
-
+#ifndef STATIC_CLASSPATH
+       /*here it could be interesting to store the references in a list eg for nicely cleaning up or for certain platforms*/
+        if (dlopen(data->text,RTLD_NOW | RTLD_GLOBAL)) {
+               log_text("LIBLOADED");
+                retVal=1;
+        }
+#else
+       retVal=1;
+#endif
        strcpy(buffer, "Java_java_lang_VMRuntime_nativeLoad:");
        utf_sprint(buffer + strlen((char *) data), data);
        log_text(buffer);       
-
+        
+  
        MFREE(buffer, char, buffer_len);
 #endif
        log_text("Java_java_lang_VMRuntime_nativeLoad");
 
-       return 1;
+       return retVal;
 }
 
 
@@ -292,12 +307,12 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_nativeGetLibname(JN
                return 0;;
        }
        
-       buffer_len = utf_strlen(data) + 6/*lib .so*/ +1 /*0*/;
+       buffer_len = utf_strlen(data) + 3 /*lib*/ /*6 lib .so */ +1 /*0*/;
        buffer = MNEW(char, buffer_len);
        sprintf(buffer,"lib");
        utf_sprint(buffer+3,data);
-       strcat(buffer,".so");
-
+       /*strcat(buffer,".so");*/
+        log_text("nativeGetLibName:");
        log_text(buffer);
        
        resultString=javastring_new_char(buffer);       
@@ -334,6 +349,8 @@ JNIEXPORT void JNICALL Java_java_lang_VMRuntime_insertSystemProperties(JNIEnv *e
        proplist[6][1] = utsnamebuf.sysname;
        proplist[7][1] = utsnamebuf.release;
 
+       proplist[8][1]=getenv("LD_LIBRARY_PATH");
+
        if (!p) {
                *exceptionptr = new_exception(string_java_lang_NullPointerException);
                return;
index b1bfb5d9e63e5c0d4fab076921b0db90c105868a..32fbb228d830d972def8448aad1abf4bb0aae14e 100644 (file)
@@ -17,13 +17,5 @@ typedef struct gnu_java_nio_SelectorImpl {
    s4 unhandledWakeup;
 } gnu_java_nio_SelectorImpl;
 
-
-/*
- * Class:     gnu/java/nio/SelectorImpl
- * Method:    implSelect
- * Signature: ([I[I[IJ)I
- */
-JNIEXPORT s4 JNICALL Java_gnu_java_nio_SelectorImpl_implSelect(JNIEnv *env, jclass clazz, java_intarray* par1, java_intarray* par2, java_intarray* par3, s8 par4);
-
 #endif
 
diff --git a/nat/implementednatives.data b/nat/implementednatives.data
new file mode 100644 (file)
index 0000000..7bd892b
--- /dev/null
@@ -0,0 +1,100 @@
+Java_java_lang_reflect_Constructor_constructNative
+Java_java_lang_reflect_Constructor_getModifiers
+Java_java_lang_reflect_Field_get
+Java_java_lang_reflect_Field_getBoolean
+Java_java_lang_reflect_Field_getByte
+Java_java_lang_reflect_Field_getChar
+Java_java_lang_reflect_Field_getDouble
+Java_java_lang_reflect_Field_getFloat
+Java_java_lang_reflect_Field_getInt
+Java_java_lang_reflect_Field_getLong
+Java_java_lang_reflect_Field_getShort
+Java_java_lang_reflect_Field_set
+Java_java_lang_reflect_Field_setBoolean
+Java_java_lang_reflect_Field_setByte
+Java_java_lang_reflect_Field_setChar
+Java_java_lang_reflect_Field_setDouble
+Java_java_lang_reflect_Field_setFloat
+Java_java_lang_reflect_Field_setInt
+Java_java_lang_reflect_Field_setLong
+Java_java_lang_reflect_Field_setShort
+Java_java_lang_reflect_Field_getType
+Java_java_lang_reflect_Field_getModifiers
+Java_java_lang_JOWENNTest1_f1
+Java_java_lang_JOWENNTest1_f2
+Java_java_lang_JOWENNTest1_f3
+Java_java_lang_JOWENNTest1_f4
+Java_java_lang_JOWENNTest1_f5
+Java_java_lang_JOWENNTest1_f6
+Java_java_lang_JOWENNTest1_f7
+Java_java_lang_JOWENNTest1_f8
+Java_java_lang_JOWENNTest1_f9
+Java_java_lang_reflect_Method_getModifiers
+Java_java_lang_reflect_Method_getReturnType
+Java_java_lang_reflect_Method_getParameterTypes
+Java_java_lang_reflect_Method_getExceptionTypes
+Java_java_lang_reflect_Method_invokeNative
+Java_java_lang_reflect_Proxy_getProxyClass0
+Java_java_lang_reflect_Proxy_getProxyData0
+Java_java_lang_reflect_Proxy_generateProxyClass0
+Java_java_lang_VMRuntime_exit
+Java_java_lang_VMRuntime_freeMemory
+Java_java_lang_VMRuntime_gc
+Java_java_lang_VMRuntime_runFinalization
+Java_java_lang_VMRuntime_runFinalizersOnExit
+Java_java_lang_VMRuntime_runFinalizationForExit
+Java_java_lang_VMRuntime_totalMemory
+Java_java_lang_VMRuntime_traceInstructions
+Java_java_lang_VMRuntime_traceMethodCalls
+Java_java_lang_VMRuntime_availableProcessors
+Java_java_lang_VMRuntime_nativeLoad
+Java_java_lang_VMRuntime_nativeGetLibname
+Java_java_lang_VMRuntime_insertSystemProperties
+Java_java_lang_VMRuntime_maxMemory
+Java_java_lang_VMThread_currentThread
+Java_java_lang_VMThread_interrupt
+Java_java_lang_VMThread_isInterrupted
+Java_java_lang_VMThread_resume
+Java_java_lang_VMThread_nativeSetPriority
+Java_java_lang_VMThread_sleep
+Java_java_lang_VMThread_start
+Java_java_lang_VMThread_nativeStop
+Java_java_lang_VMThread_suspend
+Java_java_lang_VMThread_yield
+Java_java_lang_VMThread_interrupted
+Java_java_lang_VMThread_holdsLock
+Java_java_lang_VMClass_forName
+Java_java_lang_VMClass_getClassLoader
+Java_java_lang_VMClass_getComponentType
+Java_java_lang_VMClass_getDeclaredConstructors
+Java_java_lang_VMClass_getDeclaredClasses
+Java_java_lang_VMClass_getDeclaringClass
+Java_java_lang_VMClass_getDeclaredFields
+Java_java_lang_VMClass_getInterfaces
+Java_java_lang_VMClass_getDeclaredMethods
+Java_java_lang_VMClass_getModifiers
+Java_java_lang_VMClass_getName
+Java_java_lang_VMClass_getSuperclass
+Java_java_lang_VMClass_isArray
+Java_java_lang_VMClass_isAssignableFrom
+Java_java_lang_VMClass_isInstance
+Java_java_lang_VMClass_isInterface
+Java_java_lang_VMClass_isPrimitive
+Java_java_lang_VMClass_initialize
+Java_java_lang_VMClass_loadArrayClass
+Java_java_lang_VMClass_throwException
+Java_java_lang_VMClassLoader_defineClass
+Java_java_lang_VMClassLoader_getPrimitiveClass
+Java_java_lang_VMClassLoader_resolveClass
+Java_java_lang_VMClassLoader_loadClass
+Java_java_lang_VMObject_clone
+Java_java_lang_VMObject_notify
+Java_java_lang_VMObject_notifyAll
+Java_java_lang_VMObject_wait
+Java_java_lang_VMSecurityManager_currentClassLoader
+Java_java_lang_VMSecurityManager_getClassContext
+Java_java_lang_VMString_intern
+Java_java_lang_VMSystem_arraycopy
+Java_java_lang_VMSystem_identityHashCode
+Java_java_lang_VMThrowable_fillInStackTrace
+Java_java_lang_VMThrowable_getStackTrace
index ea6155a8d87396b7107e0ecdc53345da6fd27f9a..c863aa27296cd7c522eec09fe6dada3c29a509e6 100644 (file)
@@ -25,6 +25,7 @@ typedef struct java_io_ObjectInputStream {
    struct java_util_Vector* validators;
    struct java_util_Hashtable* classLookupTable;
    struct java_io_ObjectInputStream_GetField* prereadFields;
+   s4 depth;
 } java_io_ObjectInputStream;
 
 
index 3768af46ee5e845fb32d7695b18ddcde937cbd7b..a6ac2570db7f588de9f522290a8caac555fa05cf 100644 (file)
@@ -65,5 +65,13 @@ JNIEXPORT void JNICALL Java_java_lang_VMSystem_setErr(JNIEnv *env, jclass clazz,
  */
 JNIEXPORT s8 JNICALL Java_java_lang_VMSystem_currentTimeMillis(JNIEnv *env, jclass clazz);
 
+
+/*
+ * Class:     java/lang/VMSystem
+ * Method:    getenv
+ * Signature: (Ljava/lang/String;)Ljava/lang/String;
+ */
+JNIEXPORT struct java_lang_String* JNICALL Java_java_lang_VMSystem_getenv(JNIEnv *env, jclass clazz, struct java_lang_String* par1);
+
 #endif
 
index 2fede440c77fe407644be7da941af174ffacddc6..e16e6a9f12417b4eb53ae1e99ce64601fcce7d31 100644 (file)
@@ -10,13 +10,5 @@ typedef struct java_util_TimeZone {
    struct java_lang_String* ID;
 } java_util_TimeZone;
 
-
-/*
- * Class:     java/util/TimeZone
- * Method:    getDefaultTimeZoneId
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT struct java_lang_String* JNICALL Java_java_util_TimeZone_getDefaultTimeZoneId(JNIEnv *env, jclass clazz);
-
 #endif
 
index 93c2a260fe51b295fafb40e868619e373e08ffc6..68f3714924c78870b3e70e99f213519c8231875d 100644 (file)
--- a/native.c
+++ b/native.c
@@ -31,7 +31,7 @@
    The .hh files created with the header file generator are all
    included here as are the C functions implementing these methods.
 
-   $Id: native.c 1383 2004-08-02 07:27:00Z stefan $
+   $Id: native.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -143,6 +143,7 @@ void use_class_as_object(classinfo *c)
 #undef JOWENN_DEBUG
 #undef JOWENN_DEBUG1
 
+#ifdef STATIC_CLASSPATH
 #define NATIVETABLESIZE  (sizeof(nativetable)/sizeof(struct nativeref))
 
 /* table for fast string comparison */
@@ -150,7 +151,7 @@ static nativecompref nativecomptable[NATIVETABLESIZE];
 
 /* string comparsion table initialized */
 static bool nativecompdone = false;
-
+#endif
 
 /******************************************************************************/
 
@@ -269,6 +270,7 @@ void init_systemclassloader()
 functionptr native_findfunction(utf *cname, utf *mname, 
                                                                utf *desc, bool isstatic)
 {
+#ifdef STATIC_CLASSPATH
        int i;
        /* entry of table for fast string comparison */
        struct nativecompref *n;
@@ -366,6 +368,10 @@ functionptr native_findfunction(utf *cname, utf *mname,
 
        /* keep compiler happy */
        return NULL;
+#else
+/* dynamic classpath */
+  return 0;
+#endif
 }
 
 
index 93c2a260fe51b295fafb40e868619e373e08ffc6..68f3714924c78870b3e70e99f213519c8231875d 100644 (file)
@@ -31,7 +31,7 @@
    The .hh files created with the header file generator are all
    included here as are the C functions implementing these methods.
 
-   $Id: native.c 1383 2004-08-02 07:27:00Z stefan $
+   $Id: native.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -143,6 +143,7 @@ void use_class_as_object(classinfo *c)
 #undef JOWENN_DEBUG
 #undef JOWENN_DEBUG1
 
+#ifdef STATIC_CLASSPATH
 #define NATIVETABLESIZE  (sizeof(nativetable)/sizeof(struct nativeref))
 
 /* table for fast string comparison */
@@ -150,7 +151,7 @@ static nativecompref nativecomptable[NATIVETABLESIZE];
 
 /* string comparsion table initialized */
 static bool nativecompdone = false;
-
+#endif
 
 /******************************************************************************/
 
@@ -269,6 +270,7 @@ void init_systemclassloader()
 functionptr native_findfunction(utf *cname, utf *mname, 
                                                                utf *desc, bool isstatic)
 {
+#ifdef STATIC_CLASSPATH
        int i;
        /* entry of table for fast string comparison */
        struct nativecompref *n;
@@ -366,6 +368,10 @@ functionptr native_findfunction(utf *cname, utf *mname,
 
        /* keep compiler happy */
        return NULL;
+#else
+/* dynamic classpath */
+  return 0;
+#endif
 }
 
 
index 77acc2180a9172dcef7084d6c5da5bc8c7beeebf..66a5f511cb374cb417e70b343238c50e34818b39 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: gennativetable.c 1405 2004-08-17 09:25:01Z twisti $
+   $Id: gennativetable.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -160,9 +160,11 @@ int main(int argc, char **argv)
        if (!file)
                panic("Can not open file 'nativetable' to store native-link-table");
 
-       fprintf(file, "/* Table of native methods: nativetables.hh */\n");
+       fprintf(file, "/* Table of native methods: nativetables.inc */\n");
        fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n"); 
 
+        fprintf(file, "#include \"config.h\"\n");
+
        c = chain_first(nativeclass_chain);
        while (c) {
                gen_header_filename(classname, c->name);
@@ -172,6 +174,7 @@ int main(int argc, char **argv)
        chain_free(nativeclass_chain);
 
        fprintf(file, "\n\n#include \"native.h\"\n\n");
+        fprintf(file, "#ifdef STATIC_CLASSPATH\n\n");
        fprintf(file, "static nativeref nativetable[] = {\n");
 
        m = chain_first(nativemethod_chain);
@@ -182,9 +185,28 @@ int main(int argc, char **argv)
        chain_free(nativemethod_chain);
 
        fprintf(file, "};\n");
-
+        fprintf(file,"\n#else\n");
+        fprintf(file, "/*ensure that symbols for functions implemented within cacao are used and exported to dlopen*/\n");
+        fprintf(file, "static functionptr dummynativetable[]={\n");
+       {
+               FILE *implData=fopen("nat/implementednatives.data","r");
+                if (!implData) {fclose(file); exit(3);}
+               while (!feof(implData)) {
+                       char functionLine[1024];
+                        functionLine[0]='\0';
+                       fgets(functionLine,1024,implData);
+                        if (strlen(functionLine)<2) continue;
+                       if (functionLine[strlen(functionLine)-1]!='\n') { fclose(implData); fclose(file); exit(4);}
+                        functionLine[strlen(functionLine)-1]=',';
+                       fprintf(file,"\t(functionptr) %s\n",functionLine);
+               }
+               fprintf(file,"\t(functionptr)0");
+                fclose(implData);
+       }
+        fprintf(file, "};\n");
+        fprintf(file,"\n#endif\n");
        fclose(file);
-
+       
        /* release all resources */
 
        loader_close();
index ad08458ecc598558674eeee7ea67f6e2feb19bf6..17daa91a6b8e9a1ae53b91f35fd2bc39c7ee4e42 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-# $Id: Makefile.am 1173 2004-06-16 14:56:18Z jowenn $
+# $Id: Makefile.am 1429 2004-11-02 08:58:26Z jowenn $
 
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/jit/@ARCH_DIR@
@@ -34,6 +34,15 @@ libnat_a_SOURCES = \
        GtkLabelPeer.c \
        GtkScrollPanePeer.c
 
+implementedNatives:
+       echo "">implementednatives.data
+       grep "JNICALL Java_" *.c | perl -p -i -e "s/.*JNICALL\s//" | perl -p -i -e"s/\(.*//"  | (\
+               while read line; do \
+                       grep $$line *.h >/dev/null ; \
+                       if test $$? == 0; then \
+                               echo $$line >>implementednatives.data ;\
+                       fi ;\
+               done )
 
 ## Local variables:
 ## mode: Makefile
index 848c2edcac21af046d9ddaaf89cf7f458a8cebf5..1b4e35967b7df946e8b3cf040bcace08ff26e9bc 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: VMRuntime.c 1344 2004-07-21 17:12:53Z twisti $
+   $Id: VMRuntime.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
 #include "java_util_Properties.h"    /* needed for java_lang_Runtime.h */
 #include "java_lang_VMRuntime.h"
 
+#include "config.h"
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
 
 #define JOWENN_DEBUG
 
@@ -63,7 +67,7 @@ static s4 finalizeOnExit = false;
 
 #define MAXPROPS 100
 static bool shouldFinalizersBeRunOnExit=false;
-static int activeprops = 19;  
+static int activeprops = 20;  
    
 static char *proplist[MAXPROPS][2] = {
        { "java.class.path", NULL },
@@ -75,6 +79,7 @@ static char *proplist[MAXPROPS][2] = {
        { "os.arch", NULL },
        { "os.name", NULL },
        { "os.version", NULL },
+        { "java.library.path",NULL},
                                          
        { "java.class.version", "45.3" },
        { "java.version", PACKAGE":"VERSION },
@@ -249,7 +254,8 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
        char *buffer;
        int buffer_len;
        utf *data;
-       
+       int retVal=0;
+
        data = javastring_toutf(par1, 0);
        
        if (!data) {
@@ -261,16 +267,25 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass cla
 
                
        buffer = MNEW(char, buffer_len);
-
+#ifndef STATIC_CLASSPATH
+       /*here it could be interesting to store the references in a list eg for nicely cleaning up or for certain platforms*/
+        if (dlopen(data->text,RTLD_NOW | RTLD_GLOBAL)) {
+               log_text("LIBLOADED");
+                retVal=1;
+        }
+#else
+       retVal=1;
+#endif
        strcpy(buffer, "Java_java_lang_VMRuntime_nativeLoad:");
        utf_sprint(buffer + strlen((char *) data), data);
        log_text(buffer);       
-
+        
+  
        MFREE(buffer, char, buffer_len);
 #endif
        log_text("Java_java_lang_VMRuntime_nativeLoad");
 
-       return 1;
+       return retVal;
 }
 
 
@@ -292,12 +307,12 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_nativeGetLibname(JN
                return 0;;
        }
        
-       buffer_len = utf_strlen(data) + 6/*lib .so*/ +1 /*0*/;
+       buffer_len = utf_strlen(data) + 3 /*lib*/ /*6 lib .so */ +1 /*0*/;
        buffer = MNEW(char, buffer_len);
        sprintf(buffer,"lib");
        utf_sprint(buffer+3,data);
-       strcat(buffer,".so");
-
+       /*strcat(buffer,".so");*/
+        log_text("nativeGetLibName:");
        log_text(buffer);
        
        resultString=javastring_new_char(buffer);       
@@ -334,6 +349,8 @@ JNIEXPORT void JNICALL Java_java_lang_VMRuntime_insertSystemProperties(JNIEnv *e
        proplist[6][1] = utsnamebuf.sysname;
        proplist[7][1] = utsnamebuf.release;
 
+       proplist[8][1]=getenv("LD_LIBRARY_PATH");
+
        if (!p) {
                *exceptionptr = new_exception(string_java_lang_NullPointerException);
                return;
index 5bf3ec89a49b9b4fd6a1be4013a452f8c546a204..e34a4bfa4e17d046c73899de1676c44441db6fff 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: exceptions.c 1410 2004-08-17 13:01:24Z twisti $
+   $Id: exceptions.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -283,8 +283,9 @@ void throw_cacao_exception_exit(char *exception, char *message)
        s4 len;
 
        len = strlen(exception);
-       tmp = MNEW(char, len);
+       tmp = MNEW(char, len+1);
        strncpy(tmp, exception, len);
+        tmp[len]='\0';
 
        /* convert to classname */
 
index 6f127e4946161771a7c91fef51a169986f3058cf..e1038c05d594ad6c6177f22992c65a949052e19e 100644 (file)
@@ -48,7 +48,7 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen.inc 1420 2004-10-27 16:05:14Z twisti $
+   $Id: codegen.inc 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -63,7 +63,9 @@
 #include "toolbox/logging.h"
 #include "toolbox/avl.h"
 #include "threads/thread.h"
-
+#ifndef STATIC_CLASSPATH
+#include <dlfcn.h>
+#endif
 
 /* in this tree we store all method addresses */
 
@@ -156,7 +158,13 @@ void codegen_setup(methodinfo *m, t_inlining_globals * e)
                        cd->exceptiontablelength=m->exceptiontablelength;
                        cd->exceptiontable  = MNEW(exceptiontable, m->exceptiontablelength + 1);
        }
-
+        if (e) {
+          cd->maxstack=e->cummaxstack;
+          cd->maxlocals=e->cumlocals;
+        } else {
+          cd->maxstack=m->maxstack;
+          cd->maxlocals=m->maxlocals;
+        }
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
        cd->threadcritcurrent.next = NULL;
        cd->threadcritcount = 0;
@@ -878,6 +886,156 @@ static void codegen_threadcritstop(methodinfo *m, int offset)
 }
 #endif
 
+#ifndef STATIC_CLASSPATH
+static size_t codegen_overloadPartLen(utf *desc) {
+        char *utf_ptr=desc->text;
+        u2 c;
+       size_t len=2;
+        while ((c=utf_nextu2(&utf_ptr))!=')') {
+                switch (c) {
+                        case 'I':
+                        case 'S':
+                        case 'B':
+                        case 'C':
+                        case 'Z':
+                        case 'J':
+                        case 'F':
+                        case 'D':
+                               len ++;
+                               break;
+                        case '[':
+                                len = len+2;
+                                break;
+                        case 'L':
+                                len++;
+                                while ( (c=utf_nextu2(&utf_ptr)) != ';')
+                                        len++;
+                                len=len+2;
+                                break;
+                        case '(':
+                                break;
+                        default: panic ("invalid method descriptor");
+                }
+        }
+       return len;
+
+}
+
+static void codegen_fillInOverloadPart(char *target,utf *desc) {
+        char *utf_ptr=desc->text;
+        u2 c;
+       char* insertpos=&target[strlen(target)];
+       *(insertpos++)='_';
+       *(insertpos++)='_';
+        while ((c=utf_nextu2(&utf_ptr))!=')') {
+                switch (c) {
+                        case 'I':
+                        case 'S':
+                        case 'B':
+                        case 'C':
+                        case 'Z':
+                        case 'J':
+                        case 'F':
+                        case 'D':
+                                *(insertpos++)=c;
+                                break;
+                        case '[':
+                               *(insertpos++)='_';
+                               *(insertpos++)='3';
+                                break;
+                        case 'L':
+                               *(insertpos++)='L';
+                                while ( (c=utf_nextu2(&utf_ptr)) != ';')
+                                       if ( ((c>='a') && (c<='z'))  ||
+                                               ((c>='A') && (c<='Z')) ||
+                                               ((c>='0') && (c<='9')) )
+                                                       *(insertpos++)=c;
+                                       else *(insertpos++)='_';
+                               *(insertpos++)='_';
+                               *(insertpos++)='2';
+                                break;
+                        case '(':
+                                break;
+                        default: panic ("invalid method descriptor");
+                }
+        }
+       *insertpos='\0';
+
+}
+
+static void codegen_resolve_native(methodinfo *m,void **insertionPoint,void *jmpTarget,void **jmpPatchTarget) {
+  char *nativeName;
+  size_t nativeLen;
+  size_t i;
+
+  builtin_monitorenter((java_objectheader*) m);
+  if ((*jmpPatchTarget)==jmpTarget) {
+    builtin_monitorexit((java_objectheader*) m);
+    return;
+  }
+  log_text("trying to resolve a native method");
+  utf_display(m->class->name);
+  utf_display(m->name);
+  
+  void *lib=dlopen(0,RTLD_NOW | RTLD_GLOBAL);
+  if (lib) {
+    int ok=0;
+    /*generate the name of the native function in the form Java_package1_package2...._classname_methodname*/
+    nativeLen=/*Java_*/5+strlen(m->class->name->text)+/*_*/1+strlen(m->name->text)+/*\0*/1;
+    nativeName=MNEW(char,nativeLen);
+    sprintf(nativeName,"Java_%s_%s",m->class->name->text,m->name->text);
+    for (i=0;i<nativeLen;i++) {
+      if (nativeName[i]=='/') nativeName[i]='_';
+    } 
+
+
+    void *sym=dlsym(lib,nativeName);
+    if (sym) {
+      ok=1;
+      log_text("resolved");
+      MFREE(nativeName,char,nativeLen);
+    } else {
+      size_t overloadedNativeLen=nativeLen+codegen_overloadPartLen(m->descriptor);
+      char *overloadedNative=MNEW(char,overloadedNativeLen);
+      sprintf(overloadedNative,"%s",nativeName);
+      MFREE(nativeName,char,nativeLen);
+      codegen_fillInOverloadPart(overloadedNative,m->descriptor);
+      log_text("symbol not found,trying harder (overloaded member ?)");
+      sym=dlsym(lib,overloadedNative);
+      if (sym) {
+        MFREE(overloadedNative,char,overloadedNativeLen);
+        ok=1;
+        log_text("resolved");
+      } else { 
+         MFREE(overloadedNative,char,overloadedNativeLen);
+         log_text("It was not possible to find the native function implementation. Not even in overloading case");
+      }
+   }
+    if (ok) {
+      (*insertionPoint)=sym;
+      (*jmpPatchTarget)=jmpTarget;
+      builtin_monitorexit((java_objectheader *) m );
+      return;
+    }
+
+  } else log_text("library not found");
+  
+
+  {
+    char *info;
+    size_t slen;
+    slen=2+strlen(m->class->name->text)+strlen(m->name->text)+strlen(m->descriptor->text);
+    info=(char*)MNEW(char,slen);
+    sprintf(info,"%s.%s%s",m->class->name->text,m->name->text,m->descriptor->text);
+    
+    builtin_monitorexit((java_objectheader *) m );
+    throw_cacao_exception_exit(string_java_lang_LinkageError,
+                                                       info);
+  }
+  
+}
+#endif
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
index 6b57ed670a820441f6a42c69f1a0404a23f89bb3..18a1d5ee76a2d9598a1e5c4a198ba44e740bbc26 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: codegen.inc.h 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: codegen.inc.h 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -104,6 +104,8 @@ struct codegendata {
        threadcritnodetemp *threadcrit; /* List of critical code regions          */
        threadcritnodetemp threadcritcurrent;
        s4 threadcritcount;             /* Number of critical regions             */
+        int maxstack;
+        int maxlocals;
 };
 
 
index 94ab359b1ca6dc86263fe2b80b8d0e7a7a8f3544..e44a002fb147f8ed26dc62ffaeee862f20490f6a 100644 (file)
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: codegen.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
 #define _GNU_SOURCE
 
+#include "config.h"
 #include "global.h"
 #include <stdio.h>
 #include <signal.h>
@@ -51,7 +52,6 @@
 #include "jit/reg.h"
 #include "jit/i386/codegen.h"
 #include "jit/i386/emitfuncs.h"
-
 /* include independent code generation stuff */
 #include "jit/codegen.inc"
 #include "jit/reg.inc"
@@ -4833,6 +4833,9 @@ u1 *createnativestub(functionptr f, methodinfo *m)
     int p, t;
        codegendata *cd;
 
+    void**  callAddrPatchPos=0;
+    u1* jmpInstrPos=0;
+    void** jmpInstrPatchPos=0;
        /* setup codegendata structure */
        codegen_setup(m,0);
 
@@ -4994,6 +4997,41 @@ u1 *createnativestub(functionptr f, methodinfo *m)
 
 /* CREATE DYNAMIC STACK INFO -- END*/
 
+/* RESOLVE NATIVE METHOD -- BEGIN*/
+#ifndef STATIC_CLASSPATH
+   if (f==0) {
+     log_text("Dynamic classpath: preparing for delayed native function resolving");
+     i386_jmp_imm(cd,0);
+     jmpInstrPos=cd->mcodeptr-4;
+     /*patchposition*/
+     i386_mov_imm_reg(cd,jmpInstrPos,REG_ITMP1);
+     i386_push_reg(cd,REG_ITMP1);
+     /*jmp offset*/
+     i386_mov_imm_reg(cd,0,REG_ITMP1);
+     jmpInstrPatchPos=cd->mcodeptr-4;
+     i386_push_reg(cd,REG_ITMP1);
+     /*position of call address to patch*/
+     i386_mov_imm_reg(cd,0,REG_ITMP1);
+     callAddrPatchPos=(cd->mcodeptr-4);
+     i386_push_reg(cd,REG_ITMP1);
+     /*method info structure*/
+     i386_mov_imm_reg(cd,(s4) m, REG_ITMP1);
+     i386_push_reg(cd,REG_ITMP1);
+     /*call resolve functions*/
+     i386_mov_imm_reg(cd, (s4)codegen_resolve_native,REG_ITMP1);
+     i386_call_reg(cd,REG_ITMP1);
+     /*cleanup*/
+     i386_pop_reg(cd,REG_ITMP1);
+     i386_pop_reg(cd,REG_ITMP1);
+     i386_pop_reg(cd,REG_ITMP1);
+     i386_pop_reg(cd,REG_ITMP1);
+     /*fix jmp offset replacement*/
+     (*jmpInstrPatchPos)=cd->mcodeptr-jmpInstrPos-4;
+   } else log_text("Dynamic classpath: immediate native function resolution possible");
+#endif
+/* RESOLVE NATIVE METHOD -- END*/
+
+
 
     tptr = m->paramtypes;
     for (i = 0; i < m->paramcount; i++) {
@@ -5029,7 +5067,12 @@ u1 *createnativestub(functionptr f, methodinfo *m)
        i386_mov_imm_membase(cd, (s4) &env, REG_SP, 0);
 
     i386_mov_imm_reg(cd, (s4) f, REG_ITMP1);
+#ifndef STATIC_CLASSPATH
+    if (f==0)
+      (*callAddrPatchPos)=(cd->mcodeptr-4);
+#endif
     i386_call_reg(cd, REG_ITMP1);
+
 /*REMOVE DYNAMIC STACK INFO -BEGIN */
     i386_push_reg(cd, REG_RESULT2);
     i386_mov_membase_reg(cd, REG_SP,stackframesize-8,REG_ITMP2); /*old value*/
index 1f59f473b59202c6fd1d892c62d9b53bd5080838..4448bc7265fdbef460dd9aa45fd5b32b33016e7e 100644 (file)
@@ -28,7 +28,7 @@ globals moved to structure and passed as parameter
 
    Authors: Dieter Thuernbeck
 
-   $Id: inline.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: inline.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -73,7 +73,7 @@ t_inlining_globals *inlining_init0(methodinfo *m,
         inlining_set_compiler_variables_fun(m, inline_env);
         inline_env->isinlinedmethod = 0;
        inline_env->cumjcodelength = m->jcodelength; /* for not inlining */
-        inline_env->cummaxstack = 0;
+        inline_env->cummaxstack = m->maxstack; /*why has here been 0 ? */
         inline_env->cumextablelength = 0;
         inline_env->cumlocals = m->maxlocals;
         inline_env->cummethods = 0;//co not global or static-used only here?
@@ -113,9 +113,11 @@ if (DEBUGi==true) {
     m->maxlocals, inline_env->cumlocals,
     m->maxstack,  inline_env->cummaxstack); fflush(stdout);
   }
+#if 0
+/*This looks wrong*/
         m->maxlocals = inline_env->cumlocals;   //orig not used
         m->maxstack = inline_env->cummaxstack;  //orig global maxstack var!!
-
+#endif
 //panic("TEMP so can test just inline init\n");
         }
 return inline_env;
index b5e423bcfb4fd0f8cbc4b5305b9e2786275658c0..9303d020cf9e2c6e36a057b122f9f6e12400228b 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: jit.c 1420 2004-10-27 16:05:14Z twisti $
+   $Id: jit.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -1501,7 +1501,7 @@ t_inlining_globals *inline_env = NULL;
 
        EXTABLEN
 
-       reg_setup(m);
+       reg_setup(inline_env);
 
        /* setup the codegendata memory */
        codegen_setup(m,inline_env);
index 1308a091c998c9ba5ae74b02ae7d2d1fec1bcb72..5b2841cb48bd082df8ef2557c0235ee4dd3ccc2f 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Carolyn Oates
             Edwin Steiner
 
-   $Id: parse.c 1421 2004-10-28 14:39:49Z stefan $
+   $Id: parse.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -566,7 +566,7 @@ if (opt_rt) {
                if ((useinlining) && (gp == nextgp)) {
                        u1 *tptr;
                        bool *readonly = NULL;
-
+                       int argBlockIdx=0;
 
                        opcode = code_get_u1(p,inline_env->method);
                        nextp = p += jcommandsize[opcode];
@@ -577,6 +577,13 @@ if (opt_rt) {
                        label_index = tmpinlinf->label_index;
                        readonly = tmpinlinf->readonly;
 
+                       for (i=0,tptr=tmpinlinf->method->paramtypes;i<tmpinlinf->method->paramcount;i++,tptr++) {
+                               if ( ((*tptr)==TYPE_LNG) ||
+                                 ((*tptr)==TYPE_DBL) )
+                                       argBlockIdx+=2;
+                               else
+                                       argBlockIdx++;
+                       }
                        for (i = 0, tptr = tmpinlinf->method->paramtypes + tmpinlinf->method->paramcount - 1; i < tmpinlinf->method->paramcount; i++, tptr--) {
                                int op;
 
@@ -592,8 +599,15 @@ if (opt_rt) {
                                }
 
                                op += *tptr;
-                               OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
-
+                               if ( ((*tptr)==TYPE_LNG) ||
+                                 ((*tptr)==TYPE_DBL) )
+                                       argBlockIdx-=2;
+                               else
+                                       argBlockIdx--;
+
+                               OP1(op, firstlocal + argBlockIdx);
+                               //OP1(op, firstlocal + tmpinlinf->method->paramcount - 1 - i);
+                       //printf("inline argument load operation for local: %ld\n",firstlocal + tmpinlinf->method->paramcount - 1 - i);
                                /*m->basicblockindex[gp] |= (ipc << 1);*/  /*FIXME: necessary ? */
                        }
 if (DEBUG==true) {
@@ -1021,6 +1035,13 @@ SHOWOPCODE
                                /*                                              OP(ICMD_NOP); */
                                /*                                              break; */
                                /*                                      } */
+                               if (nextp>inline_env->method->jcodelength-1) {
+                                  //OP1(ICMD_GOTO, inlinfo->stopgp);
+                                   //OP(ICMD_NOP);
+                                   //OP(ICMD_NOP);
+                                   blockend=true;
+                                   break;
+                                }//JJJJJJJ
                                blockend = true;
                                OP1(ICMD_GOTO, inlinfo->stopgp);
                                break;
@@ -1616,7 +1637,8 @@ if (DEBUG4==true)
                
                /* INLINING */
                  
-               if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+//             if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { /* end of an inlined method */
+               if (inline_env->isinlinedmethod && (nextp >= inline_env->method->jcodelength) ) { /* end of an inlined method */
                        /*                printf("setting gp from %d to %d\n",gp, inlinfo->stopgp); */
                        gp = inlinfo->stopgp; 
                        inlining_restore_compiler_variables();
@@ -1639,9 +1661,10 @@ DEBUGMETH(inline_env->method);
        } /* end for */
 
 
-       if (p != m->jcodelength)
+       if (p != m->jcodelength) {
+               printf("p (%ld) != m->jcodelength (%ld)\n",p,m->jcodelength);
                panic("Command-sequence crosses code-boundary");
-
+       }
        if (!blockend) {
                *exceptionptr = new_verifyerror(m, "Falling off the end of the code");
                return NULL;
index 7b55ba3b481725d669b5dd0224c8cfd1f2fb9ec9..77bf1d7b20ff7ac2b673310a0ec0d4b4d4f386f6 100644 (file)
@@ -27,7 +27,7 @@
 
    Authors: Christian Thalinger
 
-   $Id: reg.h 1234 2004-06-30 19:49:37Z twisti $
+   $Id: reg.h 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -43,6 +43,8 @@
 typedef struct registerdata registerdata;
 typedef varinfo varinfo5[5];
 
+struct t_inlining_globals;
+
 
 struct registerdata {
        varinfo5 *locals;
@@ -117,7 +119,7 @@ struct registerdata {
 /* function prototypes */
 
 void reg_init(methodinfo *m);
-void reg_setup(methodinfo *m);
+void reg_setup(struct t_inlining_globals *e);
 void reg_close(methodinfo *m);
 void regalloc(methodinfo *m);
 
index ba0f7ccfc901577383d7a36e504a871765fc69ad..2ab7369487356eedf6d093c1d2925f7d90a64bc0 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Stefan Ring
             Christian Thalinger
 
-   $Id: reg.inc 1342 2004-07-21 16:10:17Z twisti $
+   $Id: reg.inc 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -204,16 +204,16 @@ void reg_init(methodinfo *m)
 }
 
 
-void reg_setup(methodinfo *m)
+void reg_setup(t_inlining_globals *e)
 {
        s4 i;
        varinfo5 *v;
+       methodinfo *m=e->method;
+       m->registerdata->freemem    = MNEW(s4, e->cummaxstack);
+       m->registerdata->locals     = MNEW(varinfo5, e->cumlocals);
+       m->registerdata->interfaces = MNEW(varinfo5, e->cummaxstack);
 
-       m->registerdata->freemem    = MNEW(s4, m->maxstack);
-       m->registerdata->locals     = MNEW(varinfo5, m->maxlocals);
-       m->registerdata->interfaces = MNEW(varinfo5, m->maxstack);
-
-       for (v = m->registerdata->locals, i = m->maxlocals; i > 0; v++, i--) {
+       for (v = m->registerdata->locals, i = e->cumlocals; i > 0; v++, i--) {
                v[0][TYPE_INT].type = -1;
                v[0][TYPE_LNG].type = -1;
                v[0][TYPE_FLT].type = -1;
@@ -221,7 +221,7 @@ void reg_setup(methodinfo *m)
                v[0][TYPE_ADR].type = -1;
        }
 
-       for (v = m->registerdata->interfaces, i = m->maxstack; i > 0; v++, i--) {
+       for (v = m->registerdata->interfaces, i = e->cummaxstack; i > 0; v++, i--) {
                v[0][TYPE_INT].type = -1;
                v[0][TYPE_INT].flags = 0;
                v[0][TYPE_LNG].type = -1;
@@ -267,9 +267,9 @@ void reg_close(methodinfo *m)
        if (r->secondregs) MFREE(r->secondregs, s4, r->intregsnum);
 #endif
 
-       if (r->freemem) MFREE(r->freemem, s4, m->maxstack);
-       if (r->locals)  MFREE(r->locals, varinfo5, m->maxlocals);
-       if (r->interfaces) MFREE(r->interfaces, varinfo5, m->maxstack);
+       if (r->freemem) MFREE(r->freemem, s4, m->codegendata->maxstack);
+       if (r->locals)  MFREE(r->locals, varinfo5, m->codegendata->maxlocals);
+       if (r->interfaces) MFREE(r->interfaces, varinfo5, m->codegendata->maxstack);
 
        FREE(m->registerdata, registerdata);
        m->registerdata = NULL;
@@ -343,7 +343,7 @@ static void interface_regalloc(methodinfo *m)
        r->iftmpfltregcnt = r->tmpfltregcnt;
        r->ifsavfltregcnt = r->savfltregcnt;
 
-       for (s = 0; s < m->maxstack; s++) {
+       for (s = 0; s < m->codegendata->maxstack; s++) {
                intalloc = -1; fltalloc = -1;
                saved = (r->interfaces[s][TYPE_INT].flags |
                                 r->interfaces[s][TYPE_LNG].flags |
@@ -495,7 +495,7 @@ static void local_regalloc(methodinfo *m)
 
                arg = 0, iargcnt = 0, fargcnt = 0;
                doublewordarg = 0;
-               for (s = 0; s < m->maxlocals; s++) {
+               for (s = 0; s < m->codegendata->maxlocals; s++) {
                        intalloc = -1; fltalloc = -1;
                        for (tt = 0; tt <= 4; tt++) {
                                t = typeloop[tt];
@@ -624,7 +624,7 @@ static void local_regalloc(methodinfo *m)
                return;
        }
 
-       for (s = 0; s < m->maxlocals; s++) {
+       for (s = 0; s < m->codegendata->maxlocals; s++) {
                intalloc = -1; fltalloc = -1;
                for (tt=0; tt<=4; tt++) {
                        t = typeloop[tt];
index da3ccbf6f3a42b05e9d57daac6b79607cd11c6f7..141025eadd49b468ef82121a7878e0f00d1c74f3 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: stack.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: stack.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -94,8 +94,8 @@ methodinfo *analyse_stack(codegendata *codegendata)
        s4 *argren;
        methodinfo *m=codegendata->method;
 
-       argren = DMNEW(s4, m->maxlocals);   /* table for argument renaming        */
-       for (i = 0; i < m->maxlocals; i++)
+       argren = DMNEW(s4, m->codegendata->maxlocals);   /* table for argument renaming        */
+       for (i = 0; i < m->codegendata->maxlocals; i++)
                argren[i] = i;
        
        m->registerdata->arguments_num = 0;
@@ -210,6 +210,7 @@ methodinfo *analyse_stack(codegendata *codegendata)
                                }
                                else if (bptr->indepth != stackdepth) {
                                        show_icmd_method(m);
+                                       printf("Block: %ld, required depth:%ld, current depth:%ld\n",bptr->debug_nr,bptr->indepth,stackdepth);
                                        panic("Stack depth mismatch");
                                        
                                }
@@ -1849,7 +1850,7 @@ methodinfo *analyse_stack(codegendata *codegendata)
                                                break;
 
                                        case ICMD_CLEAR_ARGREN:
-                                               for (i = iptr->op1; i<m->maxlocals; i++) 
+                                               for (i = iptr->op1; i<m->codegendata->maxlocals; i++) 
                                                        argren[i] = i;
                                                iptr->opc = opcode = ICMD_NOP;
                                                SETDST;
@@ -1984,14 +1985,14 @@ void icmd_print_stack(methodinfo *m, stackptr s)
        int i, j;
        stackptr t;
 
-       i = m->maxstack;
+       i = m->codegendata->maxstack;
        t = s;
        
        while (t) {
                i--;
                t = t->prev;
        }
-       j = m->maxstack - i;
+       j = m->codegendata->maxstack - i;
        while (--i >= 0)
                printf("    ");
        while (s) {
@@ -2128,8 +2129,8 @@ void show_icmd_method(methodinfo *m)
        printf(".");
        utf_fprint(stdout, m->name);
        utf_fprint_classname(stdout, m->descriptor);
-       printf ("\n\nMax locals: %d\n", (int) m->maxlocals);
-       printf ("Max stack:  %d\n", (int) m->maxstack);
+       printf ("\n\nMax locals: %d\n", (int) m->codegendata->maxlocals);
+       printf ("Max stack:  %d\n", (int) m->codegendata->maxstack);
 
        printf ("Line number table length: %d\n", m->linenumbercount);
 
@@ -2141,7 +2142,7 @@ void show_icmd_method(methodinfo *m)
        }
        
        printf ("Local Table:\n");
-       for (i = 0; i < m->maxlocals; i++) {
+       for (i = 0; i < m->codegendata->maxlocals; i++) {
                printf("   %3d: ", i);
                for (j = TYPE_INT; j <= TYPE_ADR; j++)
                        if (m->registerdata->locals[i][j].type >= 0) {
@@ -2159,7 +2160,7 @@ void show_icmd_method(methodinfo *m)
        printf("\n");
 
        printf ("Interface Table:\n");
-       for (i = 0; i < m->maxstack; i++) {
+       for (i = 0; i < m->codegendata->maxstack; i++) {
                if ((m->registerdata->interfaces[i][0].type >= 0) ||
                        (m->registerdata->interfaces[i][1].type >= 0) ||
                    (m->registerdata->interfaces[i][2].type >= 0) ||
@@ -2232,7 +2233,7 @@ void show_icmd_block(methodinfo *m, basicblock *bptr)
                deadcode = bptr->flags <= BBREACHED;
                printf("[");
                if (deadcode)
-                       for (j = m->maxstack; j > 0; j--)
+                       for (j = m->codegendata->maxstack; j > 0; j--)
                                printf(" ?  ");
                else
                        icmd_print_stack(m, bptr->instack);
@@ -2242,7 +2243,7 @@ void show_icmd_block(methodinfo *m, basicblock *bptr)
                for (i = 0; i < bptr->icount; i++, iptr++) {
                        printf("[");
                        if (deadcode) {
-                               for (j = m->maxstack; j > 0; j--)
+                               for (j = m->codegendata->maxstack; j > 0; j--)
                                        printf(" ?  ");
                        }
                        else
@@ -2617,9 +2618,10 @@ void show_icmd(instruction *iptr, bool deadcode)
                break;
        }
 /*     printf(" Line number: %d, method:",iptr->line); */
-/*     utf_display(iptr->method->class->name); */
-/*     printf("."); */
-/*     utf_display(iptr->method->name); */
+        printf("\t\t");
+       utf_display(iptr->method->class->name); 
+       printf("."); 
+       utf_display(iptr->method->name); 
 }
 
 
index 76be4259cc33b530fd312e9f0caaca311ec01a18..0674f0923ab1732ca20f013d250e8c1a056a5d40 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Edwin Steiner
 
-   $Id: typecheck.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: typecheck.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -678,23 +678,41 @@ is_accessible(int flags,classinfo *definingclass,classinfo *implementingclass, c
 #define STORE_TWOWORD(num,type)                                                                                \
        do {typevectorset_store_twoword(localset,num,type);} while(0)
 
+
+#define WORDCHECKFAULT \
+       do { \
+               show_icmd_method(m); \
+               dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n", \
+               iptr->op1,iptr->method->class->name->text, \
+                       iptr->method->name->text,m->class->name->text,m->name->text); \
+               show_icmd(iptr++, false); \
+               show_icmd(iptr, false); \
+       } while (0)
+
+
 #define CHECK_ONEWORD(num,tp)                                                                                  \
        do {TYPECHECK_COUNT(stat_ins_primload);                                                         \
                if (jsrencountered) {                                                                                   \
-                       if (!typevectorset_checktype(localset,num,tp))                          \
+                       if (!typevectorset_checktype(localset,num,tp)) {                                \
+                               WORDCHECKFAULT; \
                                panic("Variable type mismatch");                                                \
+                       }       \
                }                                                                                                                               \
                else {                                                                                                                  \
-                       if (localset->td[num].type != tp)                                                       \
+                       if (localset->td[num].type != tp) {                                                     \
                                panic("Variable type mismatch");                                                \
+                               WORDCHECKFAULT; \
+                       } \
                }                                                                                                                               \
                } while(0)
 
 #define CHECK_TWOWORD(num,type)                                                                                        \
        do {TYPECHECK_COUNT(stat_ins_primload);                                                         \
-               if (!typevectorset_checktype(localset,num,type))                \
-            panic("Variable type mismatch");                           \
-               } while(0)
+               if (!typevectorset_checktype(localset,num,type)) {                \
+                       WORDCHECKFAULT; \
+                       panic("Variable type mismatch");                                \
+               } \
+       } while(0)
 
 /****************************************************************************/
 /* MACROS FOR STACK TYPE CHECKING                                           */
@@ -826,7 +844,7 @@ methodinfo *typecheck(codegendata *codegendata)
 #ifdef TYPECHECK_STATISTICS
        int count_iterations = 0;
        TYPECHECK_COUNT(stat_typechecked);
-       TYPECHECK_COUNT_FREQ(stat_locals,m->maxlocals,STAT_LOCALS);
+       TYPECHECK_COUNT_FREQ(stat_locals,m->codegendata->maxlocals,STAT_LOCALS);
        TYPECHECK_COUNT_FREQ(stat_blocks,m->basicblockcount/10,STAT_BLOCKS);
 #endif
 
@@ -882,7 +900,7 @@ methodinfo *typecheck(codegendata *codegendata)
     
     /* In <init> methods we use an extra local variable to signal if
      * the 'this' reference has been initialized. */
-    numlocals = m->maxlocals;
+    numlocals = m->codegendata->maxlocals;
        validlocals = numlocals;
     if (initmethod) numlocals++;
 
@@ -1096,8 +1114,14 @@ methodinfo *typecheck(codegendata *codegendata)
                                                          typevectorset_copymergedtype(localset,iptr->op1,&(dst->typeinfo));
                                                  }
                                                  else {
-                                                         if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1]))
+                                                         if (!TYPEDESC_IS_REFERENCE(localset->td[iptr->op1])) {
+                                                                 show_icmd_method(m);
+                                                                 dolog("localset->td index: %ld\ninstruction belongs to:%s.%s, outermethod:%s.%s\n",
+                                                                       iptr->op1,iptr->method->class->name->text,
+                                                                       iptr->method->name->text,m->class->name->text,m->name->text);
+                                                                 show_icmd(iptr, false);
                                                                  panic("illegal instruction: ALOAD loading non-reference");
+                                                         }
                                                          TYPEINFO_COPY(localset->td[iptr->op1].info,dst->typeinfo);
                                                  }
                           break;
@@ -1648,9 +1672,9 @@ methodinfo *typecheck(codegendata *codegendata)
                                                                                          LOG("saving input stack types");
                                                                                          if (!savedstackbuf) {
                                                                                                  LOG("allocating savedstack buffer");
-                                                                                                 savedstackbuf = DMNEW(stackelement,m->maxstack);
+                                                                                                 savedstackbuf = DMNEW(stackelement,m->codegendata->maxstack);
                                                                                                  savedstackbuf->prev = NULL;
-                                                                                                 for (i=1; i<m->maxstack; ++i)
+                                                                                                 for (i=1; i<m->codegendata->maxstack; ++i)
                                                                                                          savedstackbuf[i].prev = savedstackbuf+(i-1);
                                                                                          }
                                                                                          sp = savedstack = bptr->instack;
index bdfe7d691199c80fdd3d742dc47a8b15bebc93da..e89dcbed23481ddd8e495edee6f7c29b19475811 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: loader.c 1415 2004-10-11 20:12:08Z jowenn $
+   $Id: loader.c 1429 2004-11-02 08:58:26Z jowenn $
 
 */
 
@@ -1342,8 +1342,11 @@ static bool method_load(classbuffer *cb, classinfo *c, methodinfo *m)
                        method_display(m);
                }*/
                functionptr f = native_findfunction(c->name, m->name, m->descriptor, 
-                                                                                       (m->flags & ACC_STATIC) != 0);
-               if (f) {
+                                                       (m->flags & ACC_STATIC) != 0);
+#ifdef STATIC_CLASSPATH
+               if (f) 
+#endif
+                {
                        m->stubroutine = createnativestub(f, m);
                }
        }