almost all stacktraces do now really work.
authorjowenn <none@none>
Sun, 5 Dec 2004 21:33:36 +0000 (21:33 +0000)
committerjowenn <none@none>
Sun, 5 Dec 2004 21:33:36 +0000 (21:33 +0000)
14 files changed:
contrib/debugSetPathes
src/native/vm/VMSecurityManager.c
src/native/vm/VMThrowable.c
src/vm/global.h
src/vm/jit/alpha/asmoffsets.h [new file with mode: 0644]
src/vm/jit/alpha/asmpart.S
src/vm/jit/alpha/codegen.c
src/vm/jit/asmpart.h
src/vm/jit/codegen.inc
src/vm/jit/i386/asmpart.S
src/vm/jit/i386/codegen.c
src/vm/jit/parse.c
src/vm/jit/stacktrace.c
tests/extest.java

index f06b2ee5aec2b2bf49936c718303ff798c12ff15..5dc44e15fba2762338733782095c63d15203a45e 100644 (file)
@@ -2,6 +2,6 @@ export LD_LIBRARY_PATH=$PWD/classpath/native/jni/java-lang/.libs:$PWD/classpath/
 $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 CLASSPATH=.:$PWD/classpath/lib/glibj.zip:$PWD/classpath/lib/rt.jar:$CLASSPATH
 export PATH=$PWD/cacao:$PATH
 
index a4e2df869cfae882b3cdca5f840f5055c80e865e..228def9703ce249cbbc4b88fa52ce09bf42bf03a 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Joseph Wenninger
 
-   $Id: VMSecurityManager.c 1680 2004-12-04 12:02:08Z jowenn $
+   $Id: VMSecurityManager.c 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
@@ -51,7 +51,7 @@ JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMSecurityManager_curren
        if (cacao_initializing)
                return NULL;
 
-#ifdef __I386__
+#if defined(__I386__) || defined(__ALPHA__)
        return cacao_currentClassLoader();
 #else
        return 0;
@@ -71,7 +71,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMSecurityManager_getClassCon
 {
        log_text("Java_java_lang_VMSecurityManager_getClassContext  called");
        if (cacao_initializing) return 0;
-#ifdef __I386__
+#if defined(__I386__) || defined(__ALPHA__)
        return cacao_createClassContextArray();
 #else
        return 0;
index 3a7ad0b670367896c1a9751de6d48072e82a4e87..2bb812ec433d7a1397ca8f8beca0764702c8b199 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Joseph Wenninger
 
-   $Id: VMThrowable.c 1680 2004-12-04 12:02:08Z jowenn $
+   $Id: VMThrowable.c 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
@@ -63,7 +63,7 @@ JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackT
        if (vmthrow == NULL)
                panic("Needed instance of class  java.lang.VMThrowable could not be created");
 
-#ifdef __I386__
+#if defined(__I386__) || defined(__ALPHA__)
        cacao_stacktrace_NormalTrace(&(vmthrow->vmData));
 #endif
        return vmthrow;
@@ -156,7 +156,7 @@ java_objectarray* generateStackTraceArray(JNIEnv *env,stacktraceelement *el,long
  */
 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *this, java_lang_Throwable *par1)
 {
-#ifdef __I386__
+#if defined(__I386__) || defined(__ALPHA__)
        stackTraceBuffer *buf=(stackTraceBuffer*)this->vmData;
        u8 size;
        stacktraceelement *el;
index 8f5f2c63b99bd23e6428be21cdf933d3fc481b45..81a9f35bce134bdc1eeea93bbf6193db1470977f 100644 (file)
@@ -30,8 +30,9 @@
    Changes: Mark Probst
             Philipp Tomsich
                        Edwin Steiner
+            Joseph Wenninger
 
-   $Id: global.h 1680 2004-12-04 12:02:08Z jowenn $
+   $Id: global.h 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
@@ -303,6 +304,9 @@ struct native_stackframeinfo {
        void *oldThreadspecificHeadValue;
        void **addressOfThreadspecificHead;
        methodinfo *method;
+#ifdef __ALPHA__
+       void *savedpv;
+#endif
        void *beginOfJavaStackframe; /*only used if != 0*/
        void *returnToFromNative;
 
diff --git a/src/vm/jit/alpha/asmoffsets.h b/src/vm/jit/alpha/asmoffsets.h
new file mode 100644 (file)
index 0000000..736f835
--- /dev/null
@@ -0,0 +1,55 @@
+/* vm/jit/alpha/asmoffsets.h - machine code generator for alpha
+
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Institut f. Computersprachen, TU Wien
+   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
+   S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
+   J. Wenninger
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.
+
+   Contact: cacao@complang.tuwien.ac.at
+
+   Authors: Joseph Wenninger
+
+   $Id: asmoffsets.h 1683 2004-12-05 21:33:36Z jowenn $
+
+*/
+
+#ifndef _ASM_OFFSETS_H_
+#define _ASM_OFFSETS_H_
+
+#define     MethodPointer   -8
+#define     FrameSize       -12
+#define     IsSync          -16
+#define     IsLeaf          -20
+#define     IntSave         -24
+#define     FltSave         -28
+#define     LineNumberTableSize -40
+#define     LineNumberTableStart -48
+/* DEFINE LINE NUMBER STUFF HERE */
+#define     ExTableSize     -56
+#define     ExTableStart    -56
+
+#define     ExEntrySize     -32
+#define     ExStartPC       -8
+#define     ExEndPC         -16
+#define     ExHandlerPC     -24
+#define     ExCatchType     -32
+
+#endif
index 0df624481510e237b2a7bbe5bd93af4834df5d89..e5971550546b040713d14116063ac88668fc1fb0 100644 (file)
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: asmpart.S 1624 2004-11-30 14:49:45Z twisti $
+   Changes: Joseph Wenninger
+
+   $Id: asmpart.S 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
 
 #include "config.h"        
 #include "vm/jit/alpha/offsets.h"
-
-
-#define        MethodPointer   -8
-#define        FrameSize       -12
-#define     IsSync          -16
-#define     IsLeaf          -20
-#define     IntSave         -24
-#define     FltSave         -28
-/* DEFINE LINE NUMBER STUFF HERE */
-#define     ExTableSize     -56
-#define     ExTableStart    -56
-
-#define     ExEntrySize     -32
-#define     ExStartPC       -8
-#define     ExEndPC         -16
-#define     ExHandlerPC     -24
-#define     ExCatchType     -32
-
+#include "vm/jit/alpha/asmoffsets.h"
 
 #define v0      $0
 
        .globl asm_calljavafunction2double
        .globl asm_calljavafunction2long
        .globl asm_call_jit_compiler
+       .globl asm_throw_and_handle_exception
+       .globl asm_throw_and_handle_nat_exception
+       .globl asm_throw_and_handle_arithmetic_exception
+       .globl asm_throw_and_handle_arrayindexoutofbounds_exception
        .globl asm_handle_exception
        .globl asm_handle_nat_exception
        .globl asm_check_clinit
        .globl asm_builtin_exittrace
        .globl asm_criticalsections
        .globl asm_getclassvalues_atomic
+       .globl asm_prepare_native_stackinfo
+       .globl asm_remove_native_stackinfo
+       .globl asm_refillin_and_handle_exception
 
 /*************************** imported functions *******************************/
 
@@ -456,6 +448,237 @@ noregchange:
        .end    asm_call_jit_compiler
 
 
+/**************** function asm_refillin_and_handle_exception *******************
+*                                                                              *
+*   This function handles an exception. It does not use the usual calling      *
+*   conventions. The exception is passed in REG_ITMP1 and the                  *
+*   pc from the exception raising position is passed in REG_ITMP2.             *
+*   a0 contains the PV of the function causing the problem                     *
+*                                                                              *
+*   void asm_handle_arithmetic_exception (exceptionclass, exceptionpc);        *
+*                                                                              *
+*******************************************************************************/
+       .ent asm_refillin_and_handle_exception
+asm_refillin_and_handle_exception:
+       ldgp    gp,0(pv)
+        ldl     t0,0(ra)              /* load instruction LDA PV,xxx(RA)          */
+        sll     t0,48,t0
+        sra     t0,48,t0              /* isolate offset                           */
+        addq    t0,ra,pv              /* compute update address                   */
+        ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+        srl     t0,16,t0              /* isolate instruction code                 */
+        lda     t0,-0x177b(t0)        /* test for LDAH                            */
+        bne     t0, asm_refillin_and_handle_exception_cont
+        ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+        sll     t0,16,t0              /* compute high offset                      */
+        addl    t0,0,t0               /* sign extend high offset                  */
+        addq    t0,pv,pv              /* compute update address                   */
+
+asm_refillin_and_handle_exception_cont:
+
+       mov     sp,t0
+       lda     sp,-6*8(sp) /* prepare stackframe*/
+       stq     pv,5*8(sp) /* store pv of caller */
+       stq     xptr,4*8(sp) /*exception ptr*/
+       stq     xpc,3*8(sp) /*address of failure*/
+       stq     t0,2*8(sp) /*begin of java stack frame*/
+       stq     pv,1*8(sp) /* store pv of caller */
+       stq     zero,0*8(sp)    /*builtin (invisible) function */
+       jsr     ra,asm_prepare_native_stackinfo /* puts 2 additional quadwords on stack */
+       ldgp    gp,0(ra)
+
+       ldq     a2,utf_fillInStackTrace_desc
+       ldq     a1,utf_fillInStackTrace_name
+       ldq     t0,6*8(sp)
+       ldq     t1,offobjvftbl(t0)      
+       ldq     a0,offclass(t1)
+       jsr     ra,class_resolvemethod
+       ldgp    gp,0(ra)
+       /* now we have the method */
+
+       /*refillin */
+       mov     v0,a0
+       ldq     a1,6*8(sp)
+       jsr     ra,asm_calljavafunction
+       ldgp    gp,0(ra)
+
+       /*remove frame*/
+       jsr ra,asm_remove_native_stackinfo
+       ldgp    gp,0(ra)
+
+
+       /*finish*/
+       ldq     xpc,0(sp)       
+       ldq     xptr,1*8(sp)
+        ldq    pv,2*8(sp)
+       lda sp,3*8(sp)
+       br asm_handle_exception
+
+       .end asm_refillin_and_handle_exception
+
+/****** function asm_throw_and_handle_arrayindexoutofbounds_exception **********
+*                                                                              *
+*   This function handles an exception. It does not use the usual calling      *
+*   conventions. The integer parameter is passed in REG_ITMP1 and the          *
+*   pc from the exception raising position is passed in REG_ITMP2.             *
+*                                                                              *
+*   void asm_handle_arithmetic_exception (exceptionclass, exceptionpc);        *
+*                                                                              *
+*******************************************************************************/
+
+       .ent asm_throw_and_handle_arrayindexoutofbounds_exception
+asm_throw_and_handle_arrayindexoutofbounds_exception:
+       ldgp    gp,0(pv)
+       ldl     t0,0(ra)              /* load instruction LDA PV,xxx(RA)          */
+       sll     t0,48,t0
+       sra     t0,48,t0              /* isolate offset                           */
+       addq    t0,ra,pv              /* compute update address                   */
+       ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+       srl     t0,16,t0              /* isolate instruction code                 */
+       lda     t0,-0x177b(t0)        /* test for LDAH                            */
+       bne     t0,asm_throw_and_handle_arrayindexoutofbounds_exception_cont
+       ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+       sll     t0,16,t0              /* compute high offset                      */
+       addl    t0,0,t0               /* sign extend high offset                  */
+       addq    t0,pv,pv              /* compute update address                   */
+
+asm_throw_and_handle_arrayindexoutofbounds_exception_cont:
+       mov     sp,t0
+       lda     sp,-6*8(sp) /*prepare stackframe*/
+        stq     pv,5*8(sp)  /*pv of failure*/
+       stq     itmp1,4*8(sp) /*int parameter  of the exception*/
+       stq     xpc,3*8(sp) /*address of failure */
+       stq     t0,2*8(sp) /*store begin of java stack frame*/
+       stq     pv,1*8(sp) /*store pv of caller in structure*/
+       stq     zero,0*8(sp) /*builtin (invisible function)*/
+       jsr     ra,asm_prepare_native_stackinfo /* puts 2 additional quadwords on stack */
+       ldgp    gp,0(ra)
+
+       ldq     a0,string_java_lang_ArrayIndexOutOfBoundsException
+       ldq     a1,6*8(sp)  /*int  of exception*/
+       jsr ra,new_exception_int
+       ldgp    gp,0(ra)
+
+       mov v0,itmp1 /*itmp1 is not touched in asm_remove_native_stackinfo*/
+
+       jsr ra,asm_remove_native_stackinfo
+       ldgp    gp,0(ra)
+
+       ldq itmp2,0(sp) 
+        ldq    pv,2*8(sp)
+       lda sp,3*8(sp)
+       br asm_handle_exception
+
+       .end asm_throw_and_handle_arrayindexoutofbounds_exception
+
+/**************** function asm_throw_and_handle_arithmetic_exception ***********
+*                                                                              *
+*   This function handles an exception. It does not use the usual calling      *
+*   conventions. The exception string  is passed in REG_ITMP1 and the          *
+*   pc from the exception raising position is passed in REG_ITMP2.             *
+*                                                                              *
+*   void asm_handle_arithmetic_exception (exceptionclass, exceptionpc);        *
+*                                                                              *
+*******************************************************************************/
+
+       .ent asm_throw_and_handle_arithmetic_exception
+asm_throw_and_handle_arithmetic_exception:
+       ldl     t0,0(ra)              /* load instruction LDA PV,xxx(RA)          */
+       sll     t0,48,t0
+       sra     t0,48,t0              /* isolate offset                           */
+       addq    t0,ra,pv              /* compute update address                   */
+       ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+       srl     t0,16,t0              /* isolate instruction code                 */
+       lda     t0,-0x177b(t0)        /* test for LDAH                            */
+       bne     t0,asm_throw_and_handle_arithmetic_exception_cont
+       ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+       sll     t0,16,t0              /* compute high offset                      */
+       addl    t0,0,t0               /* sign extend high offset                  */
+       addq    t0,pv,pv              /* compute update address                   */
+
+asm_throw_and_handle_arithmetic_exception_cont:
+       mov     sp,t0
+       lda     sp,-6*8(sp) /*prepare stackframe*/
+        stq     pv,5*8(sp)  /*pv of failure*/
+       stq     itmp1,4*8(sp) /*exception string of the exception*/
+       stq     xpc,3*8(sp) /*address of failure */
+       stq     t0,2*8(sp) /*store begin of java stack frame*/
+       stq     pv,1*8(sp) /*store pv of caller in structure*/
+       stq     zero,0*8(sp) /*builtin (invisible function)*/
+       jsr     ra,asm_prepare_native_stackinfo /* puts 2 additional quadwords on stack */
+       ldgp    gp,0(ra)
+
+       ldq     a0,string_java_lang_ArithmeticException
+       ldq     a1,6*8(sp)  /*string  of exception*/
+       jsr ra,new_exception_message
+       ldgp    gp,0(ra)
+       mov v0,itmp1 /*itmp1 is not touched in asm_remove_native_stackinfo*/
+
+       jsr ra,asm_remove_native_stackinfo
+       ldgp    gp,0(ra)
+
+       ldq itmp2,0(sp) 
+        ldq    pv,2*8(sp)
+       lda sp,3*8(sp)
+       br asm_handle_exception
+
+       .end asm_throw_and_handle_arithmetic_exception
+
+
+/**************** function asm_throw_and_handle_exception **********************
+*                                                                              *
+*   This function handles an exception. It does not use the usual calling      *
+*   conventions. The exception class name is passed in REG_ITMP1 and the       *
+*   pc from the exception raising position is passed in REG_ITMP2.             *
+*                                                                              *
+*   void asm_handle_exception (exceptionclass, exceptionpc);                   *
+*                                                                              *
+*******************************************************************************/
+       .ent asm_throw_and_handle_nat_exception
+asm_throw_and_handle_nat_exception:
+       ldgp    gp,0(pv)
+       ldl     t0,0(ra)              /* load instruction LDA PV,xxx(RA)          */
+       sll     t0,48,t0
+       sra     t0,48,t0              /* isolate offset                           */
+       addq    t0,ra,pv              /* compute update address                   */
+       ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+       srl     t0,16,t0              /* isolate instruction code                 */
+       lda     t0,-0x177b(t0)        /* test for LDAH                            */
+       bne     t0,asm_throw_and_handle_exception
+       ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+       sll     t0,16,t0              /* compute high offset                      */
+       addl    t0,0,t0               /* sign extend high offset                  */
+       addq    t0,pv,pv              /* compute update address                   */
+
+       .aent asm_throw_and_handle_exception
+asm_throw_and_handle_exception:
+       mov     sp,t0
+       lda     sp,-6*8(sp) /*prepare stackframe*/
+        stq     pv,5*8(sp)  /*pv of failure*/
+       stq     itmp1,4*8(sp) /*classname of the exception*/
+       stq     xpc,3*8(sp) /*address of failure */
+       stq     t0,2*8(sp) /*store begin of java stack frame*/
+       stq     pv,1*8(sp) /*store pv of caller in structure*/
+       stq     zero,0*8(sp) /*builtin (invisible function)*/
+       jsr     ra,asm_prepare_native_stackinfo /* puts 2 additional quadwords on stack */
+       ldgp    gp,0(ra)
+
+       ldq a0,6*8(sp)  /*classname of exception*/
+       jsr ra,new_exception
+       ldgp    gp,0(ra)
+
+       mov v0,itmp1 /*itmp1 is not touched in asm_remove_native_stackinfo*/
+
+       jsr ra,asm_remove_native_stackinfo
+       ldgp    gp,0(ra)
+
+       ldq itmp2,0(sp) 
+        ldq    pv,2*8(sp)
+       lda sp,3*8(sp)
+       br asm_handle_exception
+       .end asm_throw_and_handle_nat_exception
+
+
 /********************* function asm_handle_exception ***************************
 *                                                                              *
 *   This function handles an exception. It does not use the usual calling      *
@@ -845,6 +1068,10 @@ asm_builtin_monitorenter:
        jmp     zero,(pv)                 /* else call builtin_monitorenter       */
 
 nb_monitorenter:
+       lda xpc,-4(ra)
+       ldq xptr,string_java_lang_NullPointerException
+       jmp zero,asm_throw_and_handle_nat_exception
+#if 0
        subq    sp,8,sp
     stq     ra,0(sp)
        ldq     a0,string_java_lang_NullPointerException
@@ -856,7 +1083,7 @@ nb_monitorenter:
        
        lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
        br      asm_handle_nat_exception
-
+#endif
        .end    asm_builtin_monitorenter
 
 
@@ -875,6 +1102,10 @@ asm_builtin_monitorexit:
        jmp     zero,(pv)                 /* else call builtin_monitorexit        */
 
 nb_monitorexit:
+       lda     xpc,-4(ra)
+       ldq     xptr,string_java_lang_NullPointerException
+       jmp     zero,asm_throw_and_handle_nat_exception
+#if 0
        subq    sp,8,sp
     stq     ra,0(sp)
        ldq     a0,string_java_lang_NullPointerException
@@ -886,7 +1117,7 @@ nb_monitorexit:
        
        lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
        br      asm_handle_nat_exception
-
+#endif
        .end    asm_builtin_monitorexit
 
 
@@ -905,18 +1136,9 @@ asm_builtin_idiv:
        jmp     zero,(pv)                 /* else call builtin_idiv               */
 
 nb_idiv:
-       subq    sp,8,sp
-       stq     ra,0(sp)
-       ldq     a0,string_java_lang_ArithmeticException
-       ldq     a1,string_java_lang_ArithmeticException_message
-       jsr     ra,new_exception_message
-       ldgp    gp,0(ra)
-       mov     v0,xptr
-       ldq     ra,0(sp)
-       addq    sp,8,sp
-       
+       ldq     xptr,string_java_lang_ArithmeticException_message
        lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
-       br      asm_handle_nat_exception
+       br      asm_throw_and_handle_arithmetic_exception
 
        .end    asm_builtin_idiv
 
@@ -936,18 +1158,9 @@ asm_builtin_ldiv:
        jmp     zero,(pv)                 /* else call builtin_ldiv               */
 
 nb_ldiv:
-       subq    sp,8,sp
-       stq     ra,0(sp)
-       ldq     a0,string_java_lang_ArithmeticException
-       ldq     a1,string_java_lang_ArithmeticException_message
-       jsr     ra,new_exception_message
-       ldgp    gp,0(ra)
-       mov     v0,xptr
-       ldq     ra,0(sp)
-       addq    sp,8,sp
-
+       ldq     xptr,string_java_lang_ArithmeticException_message
        lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
-       br      asm_handle_nat_exception
+       br      asm_throw_and_handle_arithmetic_exception
 
        .end    asm_builtin_ldiv
 
@@ -967,18 +1180,9 @@ asm_builtin_irem:
        jmp     zero,(pv)                 /* else call builtin_irem               */
 
 nb_irem:
-       subq    sp,8,sp
-       stq     ra,0(sp)
-       ldq     a0,string_java_lang_ArithmeticException
-       ldq     a1,string_java_lang_ArithmeticException_message
-       jsr     ra,new_exception_message
-       ldgp    gp,0(ra)
-       mov     v0,xptr
-       ldq     ra,0(sp)
-       addq    sp,8,sp
-
+       ldq     xptr,string_java_lang_ArithmeticException_message
        lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
-       br      asm_handle_nat_exception
+       br      asm_throw_and_handle_arithmetic_exception
 
        .end    asm_builtin_irem
 
@@ -998,18 +1202,9 @@ asm_builtin_lrem:
        jmp     zero,(pv)                 /* else call builtin_lrem               */
 
 nb_lrem:
-       subq    sp,8,sp
-       stq     ra,0(sp)
-       ldq     a0,string_java_lang_ArithmeticException
-       ldq     a1,string_java_lang_ArithmeticException_message
-       jsr     ra,new_exception_message
-       ldgp    gp,0(ra)
-       mov     v0,xptr
-       ldq     ra,0(sp)
-       addq    sp,8,sp
-
+       ldq     xptr,string_java_lang_ArithmeticException_message
        lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
-       br      asm_handle_nat_exception
+       br      asm_throw_and_handle_arithmetic_exception
 
        .end    asm_builtin_lrem
 
@@ -1036,6 +1231,12 @@ asm_builtin_checkarraycast:
        jmp     zero,(ra)
 
 nb_carray_throw:
+       ldq     ra,0(sp)
+       lda     sp,16(sp)
+       lda     xpc,-4(ra)
+       ldq     xptr,string_java_lang_ClassCastException
+       jmp     zero,asm_throw_and_handle_nat_exception
+#if 0
        ldq     a0,string_java_lang_ClassCastException
     jsr     ra,new_exception
     ldgp    gp,0(ra)
@@ -1045,6 +1246,7 @@ nb_carray_throw:
        lda     sp,16(sp)                 /* free stack space                     */
        lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
        br      asm_handle_nat_exception
+#endif
 
        .end    asm_builtin_checkarraycast
 
@@ -1079,7 +1281,11 @@ asm_builtin_aastore:
        stq     a1,offobjarrdata(a0)      /* store objectptr in array             */
        jmp     zero,(ra)
 
-nb_aastore_null:       
+nb_aastore_null:
+       ldq     xptr,string_java_lang_NullPointerException
+       mov     ra,xpc
+       jmp     zero,asm_throw_and_handle_nat_exception
+#if 0  
        subq    sp,8,sp                   /* allocate stack space                 */
        stq     ra,0(sp)                  /* save return address                  */
        ldq     a0,string_java_lang_NullPointerException
@@ -1091,8 +1297,14 @@ nb_aastore_null:
 
        mov     ra,xpc                    /* faulting address is return adress    */
        br      asm_handle_nat_exception
-
+#endif
 nb_aastore_bound:
+       ldq     ra,0(sp)
+       lda     sp,24(sp)
+       mov     ra,xpc
+       mov     a1,xptr
+       jmp     zero,asm_throw_and_handle_arrayindexoutofbounds_exception
+#if 0
        ldq     a0,string_java_lang_ArrayIndexOutOfBoundsException
     jsr     ra,new_exception_int      /* a1 already contains the index        */
     ldgp    gp,0(ra)
@@ -1102,8 +1314,12 @@ nb_aastore_bound:
        lda     sp,24(sp)                 /* free stack space                     */
        mov     ra,xpc                    /* faulting address is return adress    */
        br      asm_handle_nat_exception
-
+#endif
 nb_aastore_throw:
+       mov     ra,xpc
+       ldq     xptr,string_java_lang_ArrayStoreException
+       jmp     zero,asm_throw_and_handle_nat_exception
+#if 0
        subq    sp,8,sp                   /* allocate stack space                 */
        stq     ra,0(sp)                  /* save return address                  */
        ldq     a0,string_java_lang_ArrayStoreException
@@ -1115,7 +1331,7 @@ nb_aastore_throw:
 
        mov     ra,xpc                    /* faulting address is return adress    */
        br      asm_handle_nat_exception
-
+#endif
        .end    asm_builtin_aastore
 
 
@@ -1269,6 +1485,29 @@ asm_criticalsections:
     .quad   0
 
 
+       .ent asm_prepare_native_stackinfo
+asm_prepare_native_stackinfo:
+       lda sp,-24(sp)
+       stq ra,0(sp)
+       jsr ra,builtin_asm_get_stackframeinfo
+       stq v0,16(sp)
+       ldq t0,0(v0)
+       stq t0,8(sp)
+       ldq ra,0(sp)
+       lda sp,8(sp)
+       stq sp,0(v0)
+       ret
+       .end asm_prepare_native_stackinfo
+
+       .end asm_remove_native_stackinfo
+asm_remove_native_stackinfo:
+       ldq t0,0(sp)
+       ldq t1,8(sp)
+       stq t0,0(t1)
+       lda sp,40(sp)
+       ret
+       .end asm_prepare_native_stackinfo
+
 /*
  * 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 baecc3bb66e24735256604b3b7387f63404cbdf8..523aad8c3fa4949609828bd054f03530eedce524 100644 (file)
@@ -28,7 +28,9 @@
    Authors: Andreas Krall
             Reinhard Grafl
 
-   $Id: codegen.c 1641 2004-12-01 13:13:31Z christian $
+   Changes: Joseph Wenninger
+
+   $Id: codegen.c 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
@@ -36,6 +38,7 @@
 #include <stdio.h>
 #include <signal.h>
 
+#include "vm/jit/alpha/arch.h"
 #include "native/native.h"
 #include "vm/builtin.h"
 #include "vm/global.h"
@@ -49,9 +52,9 @@
 #include "vm/jit/parse.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/alpha/codegen.h"
-#include "vm/jit/alpha/arch.h"
 #include "vm/jit/alpha/types.h"
-
+#include "vm/jit/alpha/asmoffsets.h"
+#include "vm/jit/stacktrace.inc"
 
 /* *****************************************************************************
 
@@ -173,11 +176,13 @@ void catch_NullPointerException(int sig, int code, sigctx_struct *sigctx)
                sigaddset(&nsig, sig);
                sigprocmask(SIG_UNBLOCK, &nsig, NULL);           /* unblock signal    */
 
-               xptr = new_nullpointerexception();
+               /*xptr = new_nullpointerexception();
+               sigctx->sc_regs[REG_ITMP1_XPTR] = (u8) xptr;*/
 
-               sigctx->sc_regs[REG_ITMP1_XPTR] = (u8) xptr;
+               sigctx->sc_regs[REG_ITMP1_XPTR]=string_java_lang_NullPointerException;
                sigctx->sc_regs[REG_ITMP2_XPC] = sigctx->sc_pc;
-               sigctx->sc_pc = (u8) asm_handle_exception;
+               /*sigctx->sc_pc = (u8) asm_handle_exception;*/
+               sigctx->sc_pc = (u8) asm_throw_and_handle_exception;
                return;
 
        } else {
@@ -247,7 +252,7 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
        basicblock     *bptr;
        instruction    *iptr;
        exceptiontable *ex;
-
+       u2 currentline=0;
        {
        s4 i, p, pa, t, l;
        s4 savedregs_num;
@@ -568,6 +573,11 @@ void codegen(methodinfo *m, codegendata *cd, registerdata *rd)
                    len > 0;
                    src = iptr->dst, len--, iptr++) {
 
+               if (iptr->line!=currentline) {
+                       dseg_addlinenumber(cd,iptr->line,mcodeptr);
+                       currentline=iptr->line;
+               }
+
        MCODECHECK(64);           /* an instruction usually needs < 64 words      */
        switch (iptr->opc) {
 
@@ -3513,6 +3523,8 @@ gen_method: {
        } /* if (bptr -> flags >= BBREACHED) */
        } /* for basic block */
 
+       codegen_createlinenumbertable(cd);
+
        {
        /* generate bound check stubs */
 
@@ -3536,36 +3548,20 @@ gen_method: {
                } else {
                        xcodeptr = mcodeptr;
 
-                       M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
-                       M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                        a = dseg_addaddress(cd, asm_throw_and_handle_arrayindexoutofbounds_exception);
+                        M_ALD(REG_PV, REG_PV, a);
 
-                       a = dseg_addaddress(cd, string_java_lang_ArrayIndexOutOfBoundsException);
-                       M_ALD(rd->argintregs[0], REG_PV, a);
-                       M_MOV(REG_ITMP1, rd->argintregs[1]);
-
-                       a = dseg_addaddress(cd, new_exception_int);
-                       M_ALD(REG_PV, REG_PV, a);
-                       M_JSR(REG_RA, REG_PV);
+                        M_JSR(REG_RA, REG_PV);
 
-                       /* recompute pv */
-                       s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
-                       if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
-                       else {
-                               s4 ml = -s1, mh = 0;
-                               while (ml < -32768) { ml += 65536; mh--; }
-                               M_LDA(REG_PV, REG_RA, ml);
-                               M_LDAH(REG_PV, REG_PV, mh);
-                       }
-
-                       M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
-                       M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
-                       M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
-
-                       a = dseg_addaddress(cd, asm_handle_exception);
-                       M_ALD(REG_ITMP3, REG_PV, a);
-
-                       M_JMP(REG_ZERO, REG_ITMP3);
+                        /* recompute pv */
+                        s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+                        if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+                        else {
+                                s4 ml = -s1, mh = 0;
+                                while (ml < -32768) { ml += 65536; mh--; }
+                                M_LDA(REG_PV, REG_RA, ml);
+                                M_LDAH(REG_PV, REG_PV, mh);
+                        }
                }
        }
 
@@ -3595,16 +3591,15 @@ gen_method: {
                } else {
                        xcodeptr = mcodeptr;
 
-                       M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
-                       M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
+                       
                        a = dseg_addaddress(cd, string_java_lang_NegativeArraySizeException);
-                       M_ALD(rd->argintregs[0], REG_PV, a);
+                       M_ALD(REG_ITMP1_XPTR,REG_PV,a);
 
-                       a = dseg_addaddress(cd, new_exception);
+                       a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception);
                        M_ALD(REG_PV, REG_PV, a);
-                       M_JSR(REG_RA, REG_PV);
 
+                       M_JSR(REG_RA, REG_PV);
+               
                        /* recompute pv */
                        s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
                        if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
@@ -3615,15 +3610,7 @@ gen_method: {
                                M_LDAH(REG_PV, REG_PV, mh);
                        }
 
-                       M_MOV(REG_RESULT, REG_ITMP1_XPTR);
 
-                       M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
-                       M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
-
-                       a = dseg_addaddress(cd, asm_handle_exception);
-                       M_ALD(REG_ITMP3, REG_PV, a);
-
-                       M_JMP(REG_ZERO, REG_ITMP3);
                }
        }
 
@@ -3653,35 +3640,24 @@ gen_method: {
                } else {
                        xcodeptr = mcodeptr;
 
-                       M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
-                       M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
                        a = dseg_addaddress(cd, string_java_lang_ClassCastException);
-                       M_ALD(rd->argintregs[0], REG_PV, a);
+                        M_ALD(REG_ITMP1_XPTR,REG_PV,a);
 
-                       a = dseg_addaddress(cd, new_exception);
-                       M_ALD(REG_PV, REG_PV, a);
-                       M_JSR(REG_RA, REG_PV);
+                        a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception);
+                        M_ALD(REG_PV, REG_PV, a);
 
-                       /* recompute pv */
-                       s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
-                       if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
-                       else {
-                               s4 ml = -s1, mh = 0;
-                               while (ml < -32768) { ml += 65536; mh--; }
-                               M_LDA(REG_PV, REG_RA, ml);
-                               M_LDAH(REG_PV, REG_PV, mh);
-                       }
+                        M_JSR(REG_RA, REG_PV);
 
-                       M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+                        /* recompute pv */
+                        s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+                        if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+                        else {
+                                s4 ml = -s1, mh = 0;
+                                while (ml < -32768) { ml += 65536; mh--; }
+                                M_LDA(REG_PV, REG_RA, ml);
+                                M_LDAH(REG_PV, REG_PV, mh);
+                        }
 
-                       M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
-                       M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
-
-                       a = dseg_addaddress(cd, asm_handle_exception);
-                       M_ALD(REG_ITMP3, REG_PV, a);
-
-                       M_JMP(REG_ZERO, REG_ITMP3);
                }
        }
 
@@ -3741,10 +3717,21 @@ gen_method: {
                        M_AST(REG_ZERO, REG_ITMP3, 0);
 #endif
 
-                       a = dseg_addaddress(cd, asm_handle_exception);
-                       M_ALD(REG_ITMP3, REG_PV, a);
+                       a = dseg_addaddress(cd, asm_refillin_and_handle_exception);
+                       M_ALD(REG_PV, REG_PV, a);
+
+                       M_JMP(REG_RA, REG_PV);
+               
+                       /* recompute pv */
+                       s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+                       if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+                       else {
+                               s4 ml = -s1, mh = 0;
+                               while (ml < -32768) { ml += 65536; mh--; }
+                               M_LDA(REG_PV, REG_RA, ml);
+                               M_LDAH(REG_PV, REG_PV, mh);
+                       }
 
-                       M_JMP(REG_ZERO, REG_ITMP3);
                }
        }
 
@@ -3774,35 +3761,24 @@ gen_method: {
                } else {
                        xcodeptr = mcodeptr;
 
-                       M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
-                       M_LST(REG_ITMP2_XPC, REG_SP, 0 * 8);
-
                        a = dseg_addaddress(cd, string_java_lang_NullPointerException);
-                       M_ALD(rd->argintregs[0], REG_PV, a);
-
-                       a = dseg_addaddress(cd, new_exception);
-                       M_ALD(REG_PV, REG_PV, a);
-                       M_JSR(REG_RA, REG_PV);
-
-                       /* recompute pv */
-                       s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
-                       if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
-                       else {
-                               s4 ml = -s1, mh = 0;
-                               while (ml < -32768) { ml += 65536; mh--; }
-                               M_LDA(REG_PV, REG_RA, ml);
-                               M_LDAH(REG_PV, REG_PV, mh);
-                       }
+                        M_ALD(REG_ITMP1_XPTR,REG_PV,a);
 
-                       M_MOV(REG_RESULT, REG_ITMP1_XPTR);
+                        a = dseg_addaddress(cd, asm_throw_and_handle_nat_exception);
+                        M_ALD(REG_PV, REG_PV, a);
 
-                       M_LLD(REG_ITMP2_XPC, REG_SP, 0 * 8);
-                       M_LADD_IMM(REG_SP, 1 * 8, REG_SP);
+                        M_JSR(REG_RA, REG_PV);
 
-                       a = dseg_addaddress(cd, asm_handle_exception);
-                       M_ALD(REG_ITMP3, REG_PV, a);
+                        /* recompute pv */
+                        s1 = (s4) ((u1 *) mcodeptr - cd->mcodebase);
+                        if (s1 <= 32768) M_LDA(REG_PV, REG_RA, -s1);
+                        else {
+                                s4 ml = -s1, mh = 0;
+                                while (ml < -32768) { ml += 65536; mh--; }
+                                M_LDA(REG_PV, REG_RA, ml);
+                                M_LDAH(REG_PV, REG_PV, mh);
+                        }
 
-                       M_JMP(REG_ZERO, REG_ITMP3);
                }
        }
 
@@ -3899,6 +3875,23 @@ void removecompilerstub(u1 *stub)
 
 *******************************************************************************/
 
+
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#define NATIVESTUB_STACK          8/*ra,native result, oldThreadspecificHeadValue, addressOfThreadspecificHead, method, 0,0,ra*/
+#define NATIVESTUB_THREAD_EXTRA    (6 + 20) /*20 for additional frame creation*/
+#define NATIVESTUB_STACKTRACE_OFFSET   1
+#else
+#define NATIVESTUB_STACK          7/*ra,oldThreadspecificHeadValue, addressOfThreadspecificHead, method, 0,0,ra*/
+#define NATIVESTUB_THREAD_EXTRA    (1 + 20) /*20 for additional frame creation*/
+#define NATIVESTUB_STACKTRACE_OFFSET   0
+#endif
+
+#define NATIVESTUB_SIZE           (44 + NATIVESTUB_THREAD_EXTRA - 1)
+#define NATIVESTUB_STATIC_SIZE         5
+#define NATIVESTUB_VERBOSE_SIZE        (39 + 13)
+#define NATIVESTUB_OFFSET         11
+
+#if 0
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 #define NATIVESTUB_STACK           2
 #define NATIVESTUB_THREAD_EXTRA    6
@@ -3911,6 +3904,7 @@ void removecompilerstub(u1 *stub)
 #define NATIVESTUB_STATIC_SIZE     4
 #define NATIVESTUB_VERBOSE_SIZE    (39 + 13)
 #define NATIVESTUB_OFFSET          10
+#endif
 
 u1 *createnativestub(functionptr f, methodinfo *m)
 {
@@ -3969,11 +3963,14 @@ u1 *createnativestub(functionptr f, methodinfo *m)
        *(cs-7)  = (u8) builtin_displaymethodstop;
        *(cs-8)  = (u8) m->class;
        *(cs-9)  = (u8) asm_check_clinit;
-       *(cs-10) = (u8) NULL;               /* filled with machine code           */
+       *(cs-10) = (u8) &builtin_asm_get_stackframeinfo;
+       *(cs-11) = (u8) NULL;               /* filled with machine code           */
 
        M_LDA(REG_SP, REG_SP, -NATIVESTUB_STACK * 8);     /* build up stackframe  */
        M_AST(REG_RA, REG_SP, 0 * 8);       /* store return address               */
 
+       M_AST(REG_RA, REG_SP, (6+NATIVESTUB_STACKTRACE_OFFSET) * 8);       /* store return address  in stackinfo helper*/
+
        /* if function is static, check for initialized */
 
        if (m->flags & ACC_STATIC) {
@@ -3983,8 +3980,8 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                }
        }
 
-       /* max. 39 instructions */
-       if (runverbose) {
+       /* max. 39 +9 instructions */
+       {
                s4 p;
                s4 t;
                M_LDA(REG_SP, REG_SP, -((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
@@ -4014,12 +4011,38 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                        }
                }
 
-               M_ALD(REG_ITMP1, REG_PV, -6 * 8);
-               M_AST(REG_ITMP1, REG_SP, 0 * 8);
-               M_ALD(REG_PV, REG_PV, -5 * 8);
-               M_JSR(REG_RA, REG_PV);
-               disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
-               M_LDA(REG_PV, REG_RA, disp);
+               if (runverbose) {
+                       M_ALD(REG_ITMP1, REG_PV, -6 * 8);
+                       M_AST(REG_ITMP1, REG_SP, 0 * 8);
+                       M_ALD(REG_PV, REG_PV, -5 * 8);
+                       M_JSR(REG_RA, REG_PV);
+                       disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
+                       M_LDA(REG_PV, REG_RA, disp);
+               }
+
+
+/*stack info */
+                M_ALD(REG_PV, REG_PV, -10 * 8);      /* builtin_asm_get_stackframeinfo        */
+                M_JSR(REG_RA, REG_PV);
+                disp = -(s4) (mcodeptr - (s4 *) cs) * 4;
+                M_LDA(REG_PV, REG_RA, disp);
+
+#if 0
+                M_MOV(REG_RESULT,REG_ITMP3);
+                M_LST(REG_RESULT,REG_ITMP3,0);
+#endif
+                M_LST(REG_RESULT,REG_SP, ((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8)+(2+NATIVESTUB_STACKTRACE_OFFSET)*8);/*save adress of pointer*/
+                M_LLD(REG_ITMP3,REG_RESULT,0); /* get pointer*/
+                M_LST(REG_ITMP3,REG_SP,(1+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8)); /*save old value*/
+                M_LDA(REG_ITMP3,REG_SP,(1+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8)); /*calculate new value*/
+                M_LLD(REG_ITMP2,REG_ITMP3,8);
+                M_LST(REG_ITMP3,REG_ITMP2,0); /*store new value*/
+                M_LLD(REG_ITMP2,REG_PV,-6*8);
+                M_LST(REG_ITMP2,REG_SP,(3+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
+                M_LST(REG_ZERO,REG_SP,(4+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
+                M_LST(REG_ZERO,REG_SP,(5+NATIVESTUB_STACKTRACE_OFFSET)*8+((INT_ARG_CNT + FLT_ARG_CNT + 2) * 8));
+/*stack info -end */
+
 
                for (p = 0; p < m->paramcount && p < INT_ARG_CNT; p++) {
                        M_LLD(rd->argintregs[p], REG_SP, (2 + p) * 8);
@@ -4140,6 +4163,10 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                M_LDA(REG_SP, REG_SP, 2 * 8);
        }
 
+        M_LLD(REG_ITMP3,REG_SP,(2+NATIVESTUB_STACKTRACE_OFFSET)*8); /*get address of stacktrace helper pointer*/
+        M_LLD(REG_ITMP1,REG_SP,(1+NATIVESTUB_STACKTRACE_OFFSET)*8); /*get old value*/
+        M_LST(REG_ITMP1,REG_ITMP3,0); /*set old value*/
+
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
        if (IS_FLT_DBL_TYPE(m->returntype))
                M_DST(REG_FRESULT, REG_SP, 1 * 8);
@@ -4186,7 +4213,7 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                        /* Get machine code which is patched back in later. The call is   */
                        /* 1 instruction word long.                                       */
                        xcodeptr = (s4 *) (cd->mcodebase + cref->branchpos);
-                       *(cs-10) = (u4) *xcodeptr;
+                       *(cs-11) = (u4) *xcodeptr;
 
                        /* patch in the call to call the following code (done at compile  */
                        /* time)                                                          */
@@ -4202,7 +4229,7 @@ u1 *createnativestub(functionptr f, methodinfo *m)
                        M_ALD(REG_ITMP1, REG_PV, -8 * 8);     /* class                    */
 
                        /* move machine code into REG_ITMP3                               */
-                       M_ILD(REG_ITMP3, REG_PV, -10 * 8);    /* machine code             */
+                       M_ILD(REG_ITMP3, REG_PV, -11 * 8);    /* machine code             */
                        M_LSUB_IMM(REG_SP, 1 * 8, REG_SP);
                        M_IST(REG_ITMP3, REG_SP, 0);
 
index 9ed1690355dea6d1b2a19d92ab6032708a1fd443..e5a1e57a7732ec55999a3cace835fe45844aa8ea 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: asmpart.h 1680 2004-12-04 12:02:08Z jowenn $
+   $Id: asmpart.h 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
@@ -110,6 +110,11 @@ void asm_check_clinit();
 
 void asm_handle_builtin_exception(classinfo *);
 void asm_throw_and_handle_exception();
+#ifdef __ALPHA__
+void asm_throw_and_handle_nat_exception();
+void asm_refillin_and_handle_exception();
+void asm_throw_and_handle_arrayindexoutofbounds_exception();
+#endif
 void asm_throw_and_handle_hardware_arithmetic_exception();
 
 java_objectarray* Java_java_lang_VMSecurityManager_getClassContext(JNIEnv *env, jclass clazz);
index a2300e621348f624d2e5c61d010db077d0561045..999c347b1c1fd7c805a27df9e8beebb28ddc6dba 100644 (file)
@@ -29,6 +29,7 @@
             Andreas  Krall
 
    Changes: Christian Thalinger
+            Joseph Wenninger
 
    All functions assume the following code area / data area layout:
 
@@ -47,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 1680 2004-12-04 12:02:08Z jowenn $
+   $Id: codegen.inc 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
@@ -550,7 +551,7 @@ static void codegen_addclinitref(codegendata *cd,
 
 static void codegen_createlinenumbertable(codegendata *cd)
 {
-#ifdef __I386__
+#if defined(__I386__) || defined(__ALPHA__)
        linenumberref *lr;
 
        for (lr = cd->linenumberreferences; lr != NULL; lr = lr->next) {
@@ -680,6 +681,46 @@ functionptr codegen_findmethod(functionptr pc)
 }
 #endif
 
+#if defined(__ALPHA__)
+/*perhaps in the end I'll have to go for the tree version on alpha too, since this is insecure for eg segfault signals in native code,
+since it will still return an adress of a datasegment, but which will not be a valid one of a java method. This version is faster though (jowenn)*/
+void *codegen_findmethod(void *returnAdress)
+ {
+        void *result;
+        s8 d;
+        void *dataseg;
+        d=*((s4*)returnAdress);
+        d=d<<48;
+        d=d>>48;
+        dataseg=returnAdress+d;
+        d=*(((s4*)returnAdress)+1);
+        d=d>>16;
+        d=d-0x177b;
+        if (d==0) {
+                d=*(((s4*)returnAdress)+1);
+                d=d<<16;
+                dataseg=dataseg+d;
+        }
+        return dataseg;
+#if 0
+        ldl     t0,0(ra)              /* load instruction LDA PV,xxx(RA)          */
+        sll     t0,48,t0
+        sra     t0,48,t0              /* isolate offset                           */
+        addq    t0,ra,pv              /* compute update address                   */
+        ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(PV)         */
+        srl     t0,16,t0              /* isolate instruction code                 */
+        lda     t0,-0x177b(t0)        /* test for LDAH                            */
+        bne     t0,ex_stack_loop
+        ldl     t0,4(ra)              /* load instruction LDAH PV,xxx(RA)         */
+        sll     t0,16,t0              /* compute high offset                      */
+        addl    t0,0,t0               /* sign extend high offset                  */
+        addq    t0,pv,pv              /* compute update address                   */
+        br      ex_stack_loop
+#endif
+}
+
+#endif
+
 
 static void codegen_finish(methodinfo *m, codegendata *cd, s4 mcodelen)
 {
@@ -720,7 +761,7 @@ static void codegen_finish(methodinfo *m, codegendata *cd, s4 mcodelen)
                jr = jr->next;
        }
 
-#ifdef __I386__
+#if defined(__I386__) || defined(__ALPHA__)
        /* line number table resolving */
        {
                linenumberref *lr;
index 0908b73c68500b62659ddab49d9218942c791609..3669b2f25ed345aeb8465fd213ab0d97367a28f8 100644 (file)
@@ -29,7 +29,9 @@
             Reinhard Grafl
             Christian Thalinger
 
-   $Id: asmpart.S 1680 2004-12-04 12:02:08Z jowenn $
+   Changes: Joseph Wenninger
+
+   $Id: asmpart.S 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
index 00be85b017e1ced23cd57b288ed9dc44b20eb08c..de22fa4903ee03ec7122c5d3dc0798ff528c0541 100644 (file)
@@ -28,7 +28,9 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.c 1680 2004-12-04 12:02:08Z jowenn $
+   Changes: Joseph Wenninger
+
+   $Id: codegen.c 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
index 2f5446d321fb95251f7fc779c77024278844d616..e503c112fa48835321fb673ad7acaaea7294d7c6 100644 (file)
@@ -28,8 +28,9 @@
 
    Changes: Carolyn Oates
             Edwin Steiner
+            Joseph Wenninger
 
-   $Id: parse.c 1630 2004-11-30 19:33:41Z carolyn $
+   $Id: parse.c 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
index 8f6746fbaacbb33c137ced3e7e0f48fa5fa94b4b..1641133ab499a343df8cd44f407a08da0dbaae65 100644 (file)
@@ -26,7 +26,7 @@
 
    Authors: Joseph Wenninger
 
-   $Id: stacktrace.c 1680 2004-12-04 12:02:08Z jowenn $
+   $Id: stacktrace.c 1683 2004-12-05 21:33:36Z jowenn $
 
 */
 
@@ -213,17 +213,33 @@ void  cacao_stacktrace_fillInStackTrace(void **target,CacaoStackTraceCollector c
                                                utf_display(currentMethod->name);*/
                                                addEntry(&buffer,currentMethod,0);
                                        }
+#ifdef __ALPHA__
+                                       if (info->savedpv!=0)
+                                               dataseg=info->savedpv;
+                                       else
+                                               dataseg=codegen_findmethod(returnAdress);
+#else
                                        dataseg=codegen_findmethod(returnAdress);
+#endif
                                        currentMethod=(*((methodinfo**)(dataseg+MethodPointer)));
                                        if (info->beginOfJavaStackframe==0)
                                                stackPtr=((char*)info)+sizeof(native_stackframeinfo);
                                        else
+#ifdef __ALPHA__
+                                               stackPtr=(char*)(info->beginOfJavaStackframe);
+#else
                                                stackPtr=(char*)(info->beginOfJavaStackframe)+sizeof(void*);
+#endif
                                        info=info->oldThreadspecificHeadValue;
                                } else { /*method created by jit*/
                                        u4 frameSize;
                                        /*log_text("JIT");*/
-                                       if (currentMethod->isleafmethod) panic("How could that happen ??? A leaf method in the middle of a stacktrace ??");
+                                       if (currentMethod->isleafmethod) {
+#ifdef JWDEBUG
+                                               printf("class.method:%s.%s\n",currentMethod->class->name->text,currentMethod->name->text);
+#endif
+                                               panic("How could that happen ??? A leaf method in the middle of a stacktrace ??");
+                                       }
                                        /*utf_display(currentMethod->class->name);
                                        utf_display(currentMethod->name);*/
                                        fillInStackTrace_method(&buffer,currentMethod,dataseg,returnAdress);
index c1fb5abaf119b8fe52f1310e68febde7b143aa56..c4ca584a1f32b0d1d72e16ce6a5ab32956564287 100644 (file)
@@ -69,7 +69,7 @@ public class extest {
 
            if (msg == null || !msg.equals(String.valueOf(0xcafebabe))) {
                pln("FAILED: wrong index: " + msg + ", should be: " + 0xcafebabe);
-
+               pstacktrace(e);
            } else {
                pln("OK");
                pstacktrace(e);
@@ -86,7 +86,7 @@ public class extest {
 
            if (msg == null || !msg.equals(String.valueOf(0xbabecafe))) {
                pln("FAILED: wrong index: " + msg + ", should be: " + 0xbabecafe);
-
+               pstacktrace(e);
            } else {
                pln("OK");
                pstacktrace(e);
@@ -144,7 +144,7 @@ public class extest {
 
            if (msg == null || !msg.equals("/ by zero")) {
                pln("FAILED: wrong message: " + msg + ", should be: / by zero");
-
+               pstacktrace(e);
            } else {
                 pln("OK");
                 pstacktrace(e);