more stacktraces
authorjowenn <none@none>
Sun, 24 Apr 2005 13:07:57 +0000 (13:07 +0000)
committerjowenn <none@none>
Sun, 24 Apr 2005 13:07:57 +0000 (13:07 +0000)
src/native/vm/VMThrowable.c
src/threads/native/threads.h
src/vm/builtin.h
src/vm/exceptions.c
src/vm/exceptions.h
src/vm/jit/helper.c
src/vm/jit/helper.h
src/vm/jit/stacktrace.h
src/vm/jit/x86_64/asmpart.S
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/patcher.c

index 773fc190c18c90911551c3c0587270c95e8a5423..a03aa4a4528c338b1fe23f9b1d3ed3c4c69f4a1a 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: VMThrowable.c 2358 2005-04-22 22:01:51Z jowenn $
+   $Id: VMThrowable.c 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -46,6 +46,7 @@
 #include "vm/tables.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/exceptions.h"
 
 
 /*
@@ -57,6 +58,11 @@ JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackT
 {
        java_lang_VMThrowable *vmthrow;
 
+       if ((*dontfillinexceptionstacktrace) == true) {
+               /*log_text("dontfillinexceptionstacktrace");*/
+               return 0;
+       }
+
        vmthrow = (java_lang_VMThrowable *) native_new_and_init(class_java_lang_VMThrowable);
 
        if (!vmthrow)
index 1e7e85698562829a14acbe0d03cc80b0b10978d5..6cad01a3a0716804c0c092446f24a4da9d61070c 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Stefan Ring
 
-   $Id: threads.h 1923 2005-02-10 10:43:41Z twisti $
+   $Id: threads.h 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -98,6 +98,7 @@ struct nativethread {
        threadobject      *next;
        threadobject      *prev;
        java_objectheader *_exceptionptr;
+        u1                _dontfillinexceptionstacktrace;
        methodinfo        *_threadrootmethod;
        void              *_stackframeinfo;
        pthread_t          tid;
index 233c6bc949313b2dd716878ac64239b56cb63397..28107298f9d83c0d89975dcd88a0a3fb03457e4e 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Edwin Steiner
             Christian Thalinger
 
-   $Id: builtin.h 2357 2005-04-22 17:37:57Z christian $
+   $Id: builtin.h 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -371,6 +371,7 @@ java_objectheader **builtin_asm_get_exceptionptrptr(void);
 
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 static inline java_objectheader **builtin_get_exceptionptrptr(void);
+static inline u1 *builtin_get_dontfillinexceptionstacktrace(void);
 /* NOT AN OP */
 static inline methodinfo **builtin_get_threadrootmethod(void);
 /* NOT AN OP */
@@ -380,6 +381,11 @@ inline java_objectheader **builtin_get_exceptionptrptr(void)
        return &THREADINFO->_exceptionptr;
 }
 
+inline u1 *builtin_get_dontfillinexceptionstacktrace(void)
+{
+       return &THREADINFO->_dontfillinexceptionstacktrace;
+}
+
 inline methodinfo **builtin_get_threadrootmethod(void)
 {
        return &THREADINFO->_threadrootmethod;
index c5f8068565d341f986b23bf1697aefa54f225177..1d4639939d8d5650b61110cefe7be69b93b6daaf 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: exceptions.c 2276 2005-04-12 19:47:33Z twisti $
+   $Id: exceptions.c 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -60,6 +60,7 @@
 
 #if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
 java_objectheader* _exceptionptr = NULL;
+u1 _dontfillinexceptionstacktrace = false;
 #endif
 
 
index df6d65f4f718321aece9002aaaab2d0f033dcdac..f5d0bc3aea212ffc084c4d3239646498f6a88328 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: exceptions.h 2276 2005-04-12 19:47:33Z twisti $
+   $Id: exceptions.h 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
 
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 
-#define exceptionptr        builtin_get_exceptionptrptr()
-#define threadrootmethod    builtin_get_threadrootmethod()
+#define exceptionptr                     builtin_get_exceptionptrptr()
+#define dontfillinexceptionstacktrace    builtin_get_dontfillinexceptionstacktrace()
+#define threadrootmethod                 builtin_get_threadrootmethod()
 
 #else /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
 
 #define exceptionptr        (&_exceptionptr)
+#define dontfillinexceptionstacktrace (&_dontfillinexceptionstacktrace)
 #define threadrootmethod    (&_threadrootmethod)
 
 #endif /* defined(USE_THREADS) && defined(NATIVE_THREADS) */
 
 #if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
 extern java_objectheader *_exceptionptr;
+extern u1 _dontfillinexceptionstacktrace;
 extern methodinfo* _threadrootmethod;
 #endif /* !defined(USE_THREADS) || !defined(NATIVE_THREADS) */
 
index 03e353137bf153d24b4002307c8425be1e509852..523c4a9b49f4399b132a380c464ea94485d2d858 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: helper.c 2332 2005-04-22 13:21:02Z twisti $
+   $Id: helper.c 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -39,6 +39,7 @@
 #include "vm/method.h"
 #include "vm/references.h"
 #include "vm/resolve.h"
+#include "vm/linker.h"
 
 /* XXX class_resolveclassmethod */
 #include "vm/loader.h"
@@ -201,6 +202,43 @@ void *helper_resolve_fieldinfo(unresolved_field *uf)
 }
 
 
+/* helper_fillin_stacktrace  ****************************************************
+
+   This function returns the exception given as parameter with a filled in stacktrace
+
+*******************************************************************************/
+
+java_objectheader *helper_fillin_stacktrace(java_objectheader* exc)
+{
+       classinfo *c;
+       methodinfo *m;
+        /*log_text("helper_fillin_stacktrace has beenentered");*/
+       /* these are panics, since this are sever problems, which must never happen*/
+       if (exc==0) panic("Exception must not be null in helper_fillin_stacktrace");
+       if ( ((java_lang_Throwable *) exc)->vmState!=0) return exc;
+       if (exc->vftbl==0) panic ("Exception vftbl must not be null in helper_fillin_stacktrace");
+       /*get classinfo from object instance*/
+       c=exc->vftbl->class;
+       if (c==0) panic("Exception class must not be null in helper_fillin_stacktrace");
+       /*find the fillInStackTrace method*/
+       m=class_resolvemethod(c,utf_fillInStackTrace,utf_void__java_lang_Throwable);
+       if (m==0) panic ("Exception does not have a fillInStackTrace method");
+
+       /*log_text("helper_fillin_stacktrace doing it's work now");*/
+       asm_calljavafunction(m,exc,0,0,0);
+
+       /*return exception back to asmpart*/
+       return exc;
+}
+
+java_objectheader *helper_fillin_stacktrace_always(java_objectheader* exc) {
+       if (exc==0) panic("Exception must not be null in helper_fillin_stacktrace");
+       ((java_lang_Throwable *) exc)->vmState=0;
+       return helper_fillin_stacktrace(exc);
+}
+
+
+
 /*
  * 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 f0bc9e39fc9bfb1a86252098266ead24d955c909..5938dde167e2cad090c5c179ae15546abdbc7f1a 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: helper.h 2355 2005-04-22 14:57:47Z twisti $
+   $Id: helper.h 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -47,6 +47,8 @@
 classinfo  *helper_resolve_classinfo(constant_classref *cr);
 methodinfo *helper_resolve_methodinfo(unresolved_method *um);
 fieldinfo  *helper_resolve_fieldinfo(unresolved_field *uf);
+java_objectheader *helper_fillin_stacktrace(java_objectheader*);
+java_objectheader *helper_fillin_stacktrace_always(java_objectheader*);
 
 #endif /* _HELPER_H */
 
index c7533cf5987297704145c68bc691f1b68ba5c35c..dea999750c10b5a7f645823783ea3fd3d6034882 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: stacktrace.h 2123 2005-03-29 22:12:32Z twisti $
+   $Id: stacktrace.h 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -55,7 +55,7 @@ struct native_stackframeinfo {
 #ifdef __ALPHA__
        void *savedpv;
 #endif
-       void *beginOfJavaStackframe; /*only used if != 0*/
+       void *beginOfJavaStackframe; /*only used if != 0*/ /* on i386 and x86_64 this points to the return addres stored directly below the stackframe*/
        void *returnToFromNative;
 
 #if 0
index a6ddc08f8c9f0a54a496e85adfe8a6389b8587ea..a63518d0d119fbd9d896079f02915e4083c4d9ba 100644 (file)
@@ -28,7 +28,7 @@
             Reinhard Grafl
             Christian Thalinger
 
-   $Id: asmpart.S 2358 2005-04-22 22:01:51Z jowenn $
+   $Id: asmpart.S 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -891,15 +891,27 @@ asm_wrapper_patcher:
         ret                                 /* call new patched code              */
 
 L_asm_wrapper_patcher_exception:
+        /*stack bottom is xpc and it is directly below the last java stackframe*/
+        push $0
+        push $0
+       push $0 /*padding*/
+        call asm_prepare_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
+
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
         call    builtin_asm_get_exceptionptrptr
         mov     v0,itmp2
 #else
         lea     _exceptionptr,itmp2
 #endif
-        mov     (itmp2),xptr                /* get the exception pointer          */
-        movl    $0,(itmp2)                  /* clear the exception pointer        */
+        mov     (itmp2),a0                /* get the exception pointer          */
+        movl    $0,(itmp2)                  /* clear exception pointer */
+       call    helper_fillin_stacktrace
+
+       mov     v0,xptr
+
+        call    asm_remove_native_stackinfo /* be aware of the stack effect and calling convention explained above*/
 
+       pop     xpc
         pop     xpc                         /* get and remove return address      */
         jmp     asm_handle_exception
 
@@ -1134,11 +1146,22 @@ nb_aastore_null:
        jmp    asm_throw_and_handle_exception
 
 nb_aastore_bound:
-       mov     %rsi,%rdi               /* move index into a0                     */
+       add     $24,%rsp
+       push    $0 /*directly below return address*/
+       push    $0 /*internal*/
+       push    $0 /*padding*/
+       mov     %rsi,itmp1
+       
+       call    asm_prepare_native_stackinfo
+
+       mov     itmp1,%rdi               /* move index into a0                     */
        call    new_arrayindexoutofboundsexception
-       add     $24,%rsp
-       pop     %r10                    /* delete return address                  */
-       sub     $3,%r10                 /* faulting address is return adress - 3  */
+
+       call    asm_remove_native_stackinfo
+
+       pop     xpc                    /* just remove one quadword                  */
+       pop     xpc                    /* delete return address                  */
+       sub     $3,xpc                 /* faulting address is return adress - 3  */
        jmp     asm_handle_exception
                
 nb_aastore_throw:
index 8b0678178d2e27d0f5accaa6e5bbdb241a409d85..80fef91ea515338de3f60b167bc5cd6509607ac8 100644 (file)
@@ -27,7 +27,7 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 2358 2005-04-22 22:01:51Z jowenn $
+   $Id: codegen.c 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -53,7 +53,7 @@
 #include "vm/jit/x86_64/emitfuncs.h"
 #include "vm/jit/x86_64/types.h"
 #include "vm/jit/x86_64/asmoffsets.h"
-
+#include "vm/jit/helper.h"
 
 /* register descripton - array ************************************************/
 
@@ -90,7 +90,7 @@ static int nregdescfloat[] = {
 #endif
 
 
-void dummy_func() { }
+void codegen_dummy_func() { log_text("codegen_dummy_func"); }
 
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 void thread_restartcriticalsection(ucontext_t *uc)
@@ -3983,21 +3983,40 @@ gen_method: {
                } else {
                        xcodeptr = cd->mcodeptr;
 
+
+
+                       x86_64_alu_imm_reg(cd, X86_64_SUB, 4*8, REG_SP);
+                       x86_64_mov_reg_membase(cd, REG_ITMP2_XPC, REG_SP, 3*8);
+                       x86_64_mov_imm_membase(cd, 0, REG_SP, 2*8);
+                       x86_64_mov_imm_membase(cd, 0, REG_SP, 1*8);
+                       x86_64_mov_imm_membase(cd, 0, REG_SP, 0*8);
+                       x86_64_mov_imm_reg(cd,(u8) asm_prepare_native_stackinfo,REG_ITMP1);
+                       x86_64_call_reg(cd,REG_ITMP1);
+                       
+
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                       x86_64_alu_imm_reg(cd, X86_64_SUB, 8, REG_SP);
-                       x86_64_mov_reg_membase(cd, REG_ITMP2_XPC, REG_SP, 0);
                        x86_64_mov_imm_reg(cd, (u8) &builtin_get_exceptionptrptr, REG_ITMP1);
                        x86_64_call_reg(cd, REG_ITMP1);
                        x86_64_mov_membase_reg(cd, REG_RESULT, 0, REG_ITMP3);
                        x86_64_mov_imm_membase(cd, 0, REG_RESULT, 0);
                        x86_64_mov_reg_reg(cd, REG_ITMP3, REG_ITMP1_XPTR);
-                       x86_64_mov_membase_reg(cd, REG_SP, 0, REG_ITMP2_XPC);
-                       x86_64_alu_imm_reg(cd, X86_64_ADD, 8, REG_SP);
 #else
                        x86_64_mov_imm_reg(cd, (u8) &_exceptionptr, REG_ITMP3);
                        x86_64_mov_membase_reg(cd, REG_ITMP3, 0, REG_ITMP1_XPTR);
                        x86_64_mov_imm_membase(cd, 0, REG_ITMP3, 0);
 #endif
+                       x86_64_mov_reg_reg(cd,REG_ITMP1_XPTR,RDI);
+                       x86_64_mov_imm_reg(cd,(u8) helper_fillin_stacktrace_always,REG_ITMP1);
+                       x86_64_call_reg(cd,REG_ITMP1);
+                       x86_64_mov_reg_reg(cd,REG_RESULT,REG_ITMP1_XPTR);
+
+                       x86_64_mov_imm_reg(cd,(u8) asm_remove_native_stackinfo,REG_ITMP2);
+                       x86_64_call_reg(cd,REG_ITMP2);
+                       
+                       x86_64_alu_imm_reg(cd, X86_64_ADD, 8, REG_SP);
+                       x86_64_mov_membase_reg(cd, REG_SP, 0, REG_ITMP2_XPC);
+                       x86_64_alu_imm_reg(cd, X86_64_ADD, 8, REG_SP);
+
 
                        x86_64_mov_imm_reg(cd, (u8) asm_handle_exception, REG_ITMP3);
                        x86_64_jmp_reg(cd, REG_ITMP3);
@@ -4164,7 +4183,6 @@ void removecompilerstub(u1 *stub)
 
 u1 *createnativestub(functionptr f, methodinfo *m)
 {
-       int gg;
        u1                 *s;              /* pointer to stub memory             */
        codegendata        *cd;
        registerdata       *rd;
index c5286215c300d0117d39e94d8b1a7b21fa40d0cf..1b599291f49ce6b6891ebe92c6be31853a79b5f4 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.c 2355 2005-04-22 14:57:47Z twisti $
+   $Id: patcher.c 2360 2005-04-24 13:07:57Z jowenn $
 
 */
 
@@ -39,7 +39,7 @@
 #include "vm/initialize.h"
 #include "vm/references.h"
 #include "vm/jit/helper.h"
-
+#include "vm/exceptions.h"
 
 /* patcher_get_putstatic *******************************************************
 
@@ -59,28 +59,58 @@ bool patcher_get_putstatic(u1 *sp)
        fieldinfo        *fi;
        ptrint           *dataaddress;
        s4                ripoffset;
-
+       void             *beginJavaStack;
        /* get stuff from the stack */
 
        ra    = (u1 *)               *((ptrint *) (sp + 2 * 8));
        mcode =                      *((u8 *)     (sp + 1 * 8));
        uf    = (unresolved_field *) *((ptrint *) (sp + 0 * 8));
-
+       beginJavaStack=              (void*)(sp+2*8);
        /* calculate and set the new return address */
 
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
        /* get the fieldinfo */
-
        if (!(fi = helper_resolve_fieldinfo(uf)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* check if the field's class is initialized */
-
-       if (!fi->class->initialized)
-               if (!initialize_class(fi->class))
+       *dontfillinexceptionstacktrace=false;
+       if (!fi->class->initialized) {
+               bool init;
+               {
+                       /*struct native_stackframeinfo {
+                               void *oldThreadspecificHeadValue;
+                               void **addressOfThreadspecificHead;
+                               methodinfo *method;
+                               void *beginOfJavaStackframe; only used if != 0
+                               void *returnToFromNative;
+                       }*/
+                       /* more or less the same as the above sfi setup is done in the assembler code by the prepare/remove functions*/
+                       native_stackframeinfo sfi;
+                       sfi.returnToFromNative=(void*)ra;
+                       sfi.beginOfJavaStackframe=beginJavaStack;
+                       sfi.method=0; /*internal*/
+                       sfi.addressOfThreadspecificHead=builtin_asm_get_stackframeinfo();
+                       sfi.oldThreadspecificHeadValue=*(sfi.addressOfThreadspecificHead);
+                       *(sfi.addressOfThreadspecificHead)=&sfi;
+
+                       init=initialize_class(fi->class);
+
+                       *(sfi.addressOfThreadspecificHead)=sfi.oldThreadspecificHeadValue;
+               }
+               if (!init)
+               {
                        return false;
+               }
+       }
+
+       *dontfillinexceptionstacktrace=false;
 
        /* patch back original code */
 
@@ -130,10 +160,16 @@ bool patcher_get_putfield(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
+
        /* get the fieldinfo */
 
        if (!(fi = helper_resolve_fieldinfo(uf)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch back original code */
 
@@ -158,6 +194,7 @@ bool patcher_get_putfield(u1 *sp)
                        *((u4 *) (ra + 3)) = (u4) (fi->offset);
        }
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -184,10 +221,15 @@ bool patcher_builtin_new(constant_classref *cr, u1 *sp)
        ra = ra - (10 + 10 + 3);
        *((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the classinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch the classinfo pointer */
 
@@ -197,6 +239,7 @@ bool patcher_builtin_new(constant_classref *cr, u1 *sp)
 
        *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_new;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -223,11 +266,17 @@ bool patcher_builtin_newarray(u1 *sp, constant_classref *cr)
        ra = ra - (10 + 10 + 3);
        *((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
 
+
+       *dontfillinexceptionstacktrace=true;
+
+
        /* get the classinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
-
+       }
        /* patch the class' vftbl pointer */
 
        *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
@@ -236,6 +285,7 @@ bool patcher_builtin_newarray(u1 *sp, constant_classref *cr)
 
        *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_newarray;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -262,11 +312,14 @@ bool patcher_builtin_multianewarray(u1 *sp, constant_classref *cr)
        ra = ra - (10 + 10 + 3 + 10 + 3);
        *((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the classinfo */
 
-       if (!(c = helper_resolve_classinfo(cr)))
+       if (!(c = helper_resolve_classinfo(cr))) {
+               *dontfillinexceptionstacktrace=false;
                return false;
-
+       }
        /* patch the class' vftbl pointer */
 
        *((ptrint *) (ra + 10 + 2)) = (ptrint) c->vftbl;
@@ -275,6 +328,7 @@ bool patcher_builtin_multianewarray(u1 *sp, constant_classref *cr)
 
        *((ptrint *) (ra + 10 + 10 + 3 + 2)) = (ptrint) BUILTIN_multianewarray;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -301,10 +355,15 @@ bool patcher_builtin_checkarraycast(u1 *sp, constant_classref *cr)
        ra = ra - (10 + 10 + 3);
        *((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the classinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch the class' vftbl pointer */
 
@@ -314,6 +373,7 @@ bool patcher_builtin_checkarraycast(u1 *sp, constant_classref *cr)
 
        *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_checkarraycast;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -340,10 +400,17 @@ bool patcher_builtin_arrayinstanceof(u1 *sp, constant_classref *cr)
        ra = ra - (10 + 10 + 3);
        *((ptrint *) (sp + 0 * 8)) = (ptrint) ra;
 
+
+       *dontfillinexceptionstacktrace=true;
+
+
        /* get the classinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch the class' vftbl pointer */
 
@@ -353,6 +420,7 @@ bool patcher_builtin_arrayinstanceof(u1 *sp, constant_classref *cr)
 
        *((ptrint *) (ra + 10 + 2)) = (ptrint) BUILTIN_arrayinstanceof;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -381,11 +449,16 @@ bool patcher_invokestatic_special(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
+
        /* get the fieldinfo */
 
        if (!(m = helper_resolve_methodinfo(um)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
-
+       }
        /* patch back original code */
 
        *((u8 *) ra) = mcode;
@@ -394,6 +467,7 @@ bool patcher_invokestatic_special(u1 *sp)
 
        *((ptrint *) (ra + 2)) = (ptrint) m->stubroutine;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -422,10 +496,15 @@ bool patcher_invokevirtual(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the fieldinfo */
 
        if (!(m = helper_resolve_methodinfo(um)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch back original code */
 
@@ -436,6 +515,7 @@ bool patcher_invokevirtual(u1 *sp)
        *((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, table[0]) +
                                                                   sizeof(methodptr) * m->vftblindex);
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -464,10 +544,15 @@ bool patcher_invokeinterface(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the fieldinfo */
 
        if (!(m = helper_resolve_methodinfo(um)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch back original code */
 
@@ -483,6 +568,7 @@ bool patcher_invokeinterface(u1 *sp)
        *((s4 *) (ra + 3 + 7 + 3)) =
                (s4) (sizeof(methodptr) * (m - m->class->methods));
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -511,11 +597,15 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the fieldinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
-
+       }
        /* patch back original code */
 
        *((u8 *) ra) = mcode;
@@ -524,6 +614,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 
        *((s4 *) (ra + 2)) = (s4) c->flags;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -552,10 +643,16 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+
+       *dontfillinexceptionstacktrace=true;
+
        /* get the fieldinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch back original code */
 
@@ -569,6 +666,7 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
                (s4) (OFFSET(vftbl_t, interfacetable[0]) -
                          c->index * sizeof(methodptr*));
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -597,10 +695,15 @@ bool patcher_checkcast_class(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the fieldinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch back original code */
 
@@ -611,6 +714,7 @@ bool patcher_checkcast_class(u1 *sp)
        *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
        *((ptrint *) (ra + 10 + 7 + 7 + 3 + 2)) = (ptrint) c->vftbl;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -639,10 +743,15 @@ bool patcher_instanceof_class(u1 *sp)
        ra = ra - 5;
        *((ptrint *) (sp + 2 * 8)) = (ptrint) ra;
 
+       *dontfillinexceptionstacktrace=true;
+
        /* get the fieldinfo */
 
        if (!(c = helper_resolve_classinfo(cr)))
+       {
+               *dontfillinexceptionstacktrace=false;
                return false;
+       }
 
        /* patch back original code */
 
@@ -652,6 +761,7 @@ bool patcher_instanceof_class(u1 *sp)
 
        *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
 
+       *dontfillinexceptionstacktrace=false;
        return true;
 }
 
@@ -667,12 +777,14 @@ bool patcher_clinit(u1 *sp)
        u1        *ra;
        u8         mcode;
        classinfo *c;
+       void      *beginJavaStack;
 
        /* get stuff from the stack */
 
        ra    = (u1 *)        *((ptrint *) (sp + 2 * 8));
        mcode =               *((u8 *)     (sp + 1 * 8));
        c     = (classinfo *) *((ptrint *) (sp + 0 * 8));
+       beginJavaStack =      (void*) (sp+2*8);
 
        /* calculate and set the new return address */
 
@@ -682,8 +794,34 @@ bool patcher_clinit(u1 *sp)
        /* check if the class is initialized */
 
        if (!c->initialized)
-               if (!initialize_class(c))
+       {
+               bool init;
+               {
+                       /*struct native_stackframeinfo {
+                               void *oldThreadspecificHeadValue;
+                               void **addressOfThreadspecificHead;
+                               methodinfo *method;
+                               void *beginOfJavaStackframe; only used if != 0
+                               void *returnToFromNative;
+                       }*/
+                       /* more or less the same as the above sfi setup is done in the assembler code by the prepare/remove functions*/
+                       native_stackframeinfo sfi;
+                       sfi.returnToFromNative=(void*)ra;
+                       sfi.beginOfJavaStackframe=beginJavaStack;
+                       sfi.method=0; /*internal*/
+                       sfi.addressOfThreadspecificHead=builtin_asm_get_stackframeinfo();
+                       sfi.oldThreadspecificHeadValue=*(sfi.addressOfThreadspecificHead);
+                       *(sfi.addressOfThreadspecificHead)=&sfi;
+
+                       init=initialize_class(c);
+
+                       *(sfi.addressOfThreadspecificHead)=sfi.oldThreadspecificHeadValue;
+               }
+               if (!init)
+               {
                        return false;
+               }
+       }
 
        /* patch back original code */