* Newer, simpler, smaller stacktrace system
authortwisti <none@none>
Mon, 11 Jul 2005 21:25:31 +0000 (21:25 +0000)
committertwisti <none@none>
Mon, 11 Jul 2005 21:25:31 +0000 (21:25 +0000)
src/vm/jit/x86_64/asmpart.S
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/md.c

index 1d0048641bdd8fc632247fb9f0f999d8bafb5f74..1086062f5349913fcda4ef7dc7e75b813a1261af 100644 (file)
@@ -28,7 +28,7 @@
             Reinhard Grafl
             Christian Thalinger
 
-   $Id: asmpart.S 2956 2005-07-09 14:04:34Z twisti $
+   $Id: asmpart.S 2991 2005-07-11 21:25:31Z twisti $
 
 */
 
@@ -440,18 +440,15 @@ L_call_method:
        jmp     *%rax                   /* ...and now call the new method         */
 
 L_asm_call_jit_compiler_exception:
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-       call    builtin_asm_get_exceptionptrptr
-       mov     %rax,itmp2
-#else
-       lea     _exceptionptr,itmp2
-#endif
-       mov     (itmp2),xptr                /* get the exception pointer          */
-       movl    $0,(itmp2)                  /* clear the exception pointer        */
+       xor     a0,a0                       /* we don't have pv handy             */
+       mov     sp,a1                       /* pass java sp                       */
+       add     $8,a1
+       mov     0*8(sp),a2                  /* pass ra to parent Java function    */
+       mov     a2,a3                       /* xpc is the same as ra              */
+       call    stacktrace_extern_fillInStackTrace
 
        pop     xpc                         /* delete return address              */
        sub     $5,xpc                      /* faulting address is ra - 5         */
-
        jmp     asm_handle_exception
 
 
@@ -740,10 +737,11 @@ asm_wrapper_patcher:
        mov     sp,a0                       /* create stackframe info             */
        add     $(19*8),a0
        xor     a1,a1                       /* if pv is NULL, use findmethod      */
-       mov     sp,a2
+       mov     sp,a2                       /* pass java sp                       */
        add     $((5+19)*8+sizestackframeinfo),a2
-       mov     ((4+19)*8+sizestackframeinfo)(sp),a3
-       call    stacktrace_create_inline_stackframeinfo
+       mov     ((4+19)*8+sizestackframeinfo)(sp),a3 /* pass ra to java function  */
+       mov     a3,a4                       /* xpc is equal to ra                 */
+       call    stacktrace_create_extern_stackframeinfo
 
        mov     sp,a0                       /* pass stack pointer                 */
        add     $((1+19)*8+sizestackframeinfo),a0   /* skip function pointer      */
@@ -965,7 +963,7 @@ asm_criticalsections:
 #endif
        .quad 0
 
-               
+
 /*
  * 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 a97cc3598aa43b498924df3b7280f05736385389..2e2712add404603235d61fe0aa32d81533838ab6 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Ullrich
 
-   $Id: codegen.c 2956 2005-07-09 14:04:34Z twisti $
+   $Id: codegen.c 2991 2005-07-11 21:25:31Z twisti $
 
 */
 
@@ -3768,149 +3768,108 @@ gen_method:
 
        {
 
-       /* generate ArrayIndexOutOfBoundsException stubs */
-
-       u1 *xcodeptr = NULL;
+       u1        *xcodeptr;
        branchref *bref;
 
-       for (bref = cd->xboundrefs; bref != NULL; bref = bref->next) {
+       /* generate ArithmeticException stubs */
+
+       xcodeptr = NULL;
+       
+       for (bref = cd->xdivrefs; bref != NULL; bref = bref->next) {
+               if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
+                       gen_resolvebranch(cd->mcodebase + bref->branchpos, 
+                                                         bref->branchpos,
+                                                         xcodeptr - cd->mcodebase - (10 + 7));
+                       continue;
+               }
+
                gen_resolvebranch(cd->mcodebase + bref->branchpos, 
                                  bref->branchpos,
                                                  cd->mcodeptr - cd->mcodebase);
 
                MCODECHECK(512);
 
-               /* move index register into REG_ITMP1 */
-
-               M_MOV(bref->reg, REG_ITMP1);                              /* 3 bytes  */
-
-               x86_64_mov_imm_reg(cd, 0, REG_ITMP2_XPC);                 /* 10 bytes */
+               M_MOV_IMM(0, REG_ITMP2_XPC);                              /* 10 bytes */
                dseg_adddata(cd, cd->mcodeptr);
                M_AADD_IMM32(bref->branchpos - 6, REG_ITMP2_XPC);         /* 7 bytes  */
 
                if (xcodeptr != NULL) {
-                       x86_64_jmp_imm(cd, xcodeptr - cd->mcodeptr - 5);
-
+                       M_JMP_IMM(xcodeptr - cd->mcodeptr - 5);
+               
                } else {
                        xcodeptr = cd->mcodeptr;
 
-                       M_ASUB_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-                       M_IST(REG_ITMP1, REG_SP, 0 * 8);
-                       M_AST(REG_ITMP2_XPC, REG_SP, 1 * 8);
-
-                       /* create stackframe info */
-
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-
-                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[1]);
-
-                       M_MOV(REG_SP, rd->argintregs[2]);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), rd->argintregs[2]);
+                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[0]);
+                       M_MOV(REG_SP, rd->argintregs[1]);
+                       M_ALD(rd->argintregs[2], REG_SP, parentargs_base * 8);
                        M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_create_inline_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-                       /* create exception */
 
-                       M_ILD(rd->argintregs[0], REG_SP, 0 * 8);
-                       x86_64_mov_imm_reg(cd, (ptrint) new_arrayindexoutofboundsexception,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-                       M_AST(REG_RESULT, REG_SP, 0 * 8);
+                       M_ASUB_IMM(2 * 8, REG_SP);
+                       M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       /* removed stackframe info */
+                       M_MOV_IMM((ptrint) stacktrace_inline_arithmeticexception,
+                                         REG_ITMP3);
+                       M_CALL(REG_ITMP3);
 
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_remove_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
+                       M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                       M_AADD_IMM(2 * 8, REG_SP);
 
-                       M_ALD(REG_ITMP1_XPTR, REG_SP, 0 * 8);
-                       M_ALD(REG_ITMP2_XPC, REG_SP, 1 * 8);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_handle_exception, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_handle_exception, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
 
-       /* generate ArrayStoreException stubs */
+       /* generate ArrayIndexOutOfBoundsException stubs */
 
        xcodeptr = NULL;
-       
-       for (bref = cd->xstorerefs; bref != NULL; bref = bref->next) {
-               if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
-                       gen_resolvebranch(cd->mcodebase + bref->branchpos, 
-                                                         bref->branchpos,
-                                                         xcodeptr - cd->mcodebase - (10 + 7));
-                       continue;
-               }
 
+       for (bref = cd->xboundrefs; bref != NULL; bref = bref->next) {
                gen_resolvebranch(cd->mcodebase + bref->branchpos, 
                                  bref->branchpos,
                                                  cd->mcodeptr - cd->mcodebase);
 
                MCODECHECK(512);
 
-               x86_64_mov_imm_reg(cd, 0, REG_ITMP2_XPC);                 /* 10 bytes */
+               /* move index register into REG_ITMP1 */
+
+               M_MOV(bref->reg, REG_ITMP1);                              /* 3 bytes  */
+
+               M_MOV_IMM(0, REG_ITMP2_XPC);                              /* 10 bytes */
                dseg_adddata(cd, cd->mcodeptr);
                M_AADD_IMM32(bref->branchpos - 6, REG_ITMP2_XPC);         /* 7 bytes  */
 
                if (xcodeptr != NULL) {
-                       x86_64_jmp_imm(cd, xcodeptr - cd->mcodeptr - 5);
+                       M_JMP_IMM(xcodeptr - cd->mcodeptr - 5);
 
                } else {
                        xcodeptr = cd->mcodeptr;
 
-                       M_ASUB_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-                       M_AST(REG_ITMP2_XPC, REG_SP, 1 * 8);
-
-                       /* create stackframe info */
-
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-
-                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[1]);
-
-                       M_MOV(REG_SP, rd->argintregs[2]);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), rd->argintregs[2]);
+                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[0]);
+                       M_MOV(REG_SP, rd->argintregs[1]);
+                       M_ALD(rd->argintregs[2], REG_SP, parentargs_base * 8);
                        M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_create_inline_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
+                       M_MOV(REG_ITMP1, rd->argintregs[4]);
 
-                       /* create exception */
+                       M_ASUB_IMM(2 * 8, REG_SP);
+                       M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       x86_64_mov_imm_reg(cd, (ptrint) new_arraystoreexception,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-                       M_AST(REG_RESULT, REG_SP, 0 * 8);
+                       M_MOV_IMM((ptrint) stacktrace_inline_arrayindexoutofboundsexception,
+                                         REG_ITMP3);
+                       M_CALL(REG_ITMP3);
 
-                       /* removed stackframe info */
+                       M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                       M_AADD_IMM(2 * 8, REG_SP);
 
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_remove_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-                       M_ALD(REG_ITMP1_XPTR, REG_SP, 0 * 8);
-                       M_ALD(REG_ITMP2_XPC, REG_SP, 1 * 8);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_handle_exception, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_handle_exception, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
 
-       /* generate NegativeArraySizeException stubs */
+       /* generate ArrayStoreException stubs */
 
        xcodeptr = NULL;
        
-       for (bref = cd->xcheckarefs; bref != NULL; bref = bref->next) {
+       for (bref = cd->xstorerefs; bref != NULL; bref = bref->next) {
                if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
                        gen_resolvebranch(cd->mcodebase + bref->branchpos, 
                                                          bref->branchpos,
@@ -3924,54 +3883,33 @@ gen_method:
 
                MCODECHECK(512);
 
-               x86_64_mov_imm_reg(cd, 0, REG_ITMP2_XPC);                 /* 10 bytes */
+               M_MOV_IMM(0, REG_ITMP2_XPC);                              /* 10 bytes */
                dseg_adddata(cd, cd->mcodeptr);
                M_AADD_IMM32(bref->branchpos - 6, REG_ITMP2_XPC);         /* 7 bytes  */
 
                if (xcodeptr != NULL) {
-                       x86_64_jmp_imm(cd, xcodeptr - cd->mcodeptr - 5);
+                       M_JMP_IMM(xcodeptr - cd->mcodeptr - 5);
 
                } else {
                        xcodeptr = cd->mcodeptr;
 
-                       M_ASUB_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-                       M_AST(REG_ITMP2_XPC, REG_SP, 1 * 8);
-
-                       /* create stackframe info */
-
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-
-                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[1]);
-
-                       M_MOV(REG_SP, rd->argintregs[2]);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), rd->argintregs[2]);
+                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[0]);
+                       M_MOV(REG_SP, rd->argintregs[1]);
+                       M_ALD(rd->argintregs[2], REG_SP, parentargs_base * 8);
                        M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_create_inline_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-                       /* create exception */
 
-                       x86_64_mov_imm_reg(cd, (ptrint) new_negativearraysizeexception,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-                       M_AST(REG_RESULT, REG_SP, 0 * 8);
+                       M_ASUB_IMM(2 * 8, REG_SP);
+                       M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       /* removed stackframe info */
+                       M_MOV_IMM((ptrint) stacktrace_inline_arraystoreexception,
+                                         REG_ITMP3);
+                       M_CALL(REG_ITMP3);
 
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_remove_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
+                       M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                       M_AADD_IMM(2 * 8, REG_SP);
 
-                       M_ALD(REG_ITMP1_XPTR, REG_SP, 0 * 8);
-                       M_ALD(REG_ITMP2_XPC, REG_SP, 1 * 8);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_handle_exception, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_handle_exception, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
 
@@ -3993,61 +3931,40 @@ gen_method:
 
                MCODECHECK(512);
 
-               x86_64_mov_imm_reg(cd, 0, REG_ITMP2_XPC);                 /* 10 bytes */
+               M_MOV_IMM(0, REG_ITMP2_XPC);                              /* 10 bytes */
                dseg_adddata(cd, cd->mcodeptr);
                M_AADD_IMM32(bref->branchpos - 6, REG_ITMP2_XPC);         /* 7 bytes  */
 
                if (xcodeptr != NULL) {
-                       x86_64_jmp_imm(cd, xcodeptr - cd->mcodeptr - 5);
+                       M_JMP_IMM(xcodeptr - cd->mcodeptr - 5);
                
                } else {
                        xcodeptr = cd->mcodeptr;
 
-                       M_ASUB_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-                       M_AST(REG_ITMP2_XPC, REG_SP, 1 * 8);
-
-                       /* create stackframe info */
-
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-
-                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[1]);
-
-                       M_MOV(REG_SP, rd->argintregs[2]);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), rd->argintregs[2]);
+                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[0]);
+                       M_MOV(REG_SP, rd->argintregs[1]);
+                       M_ALD(rd->argintregs[2], REG_SP, parentargs_base * 8);
                        M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_create_inline_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-                       /* create exception */
 
-                       x86_64_mov_imm_reg(cd, (ptrint) new_classcastexception, REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-                       M_AST(REG_RESULT, REG_SP, 0 * 8);
+                       M_ASUB_IMM(2 * 8, REG_SP);
+                       M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       /* removed stackframe info */
+                       M_MOV_IMM((ptrint) stacktrace_inline_classcastexception, REG_ITMP3);
+                       M_CALL(REG_ITMP3);
 
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_remove_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
+                       M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                       M_AADD_IMM(2 * 8, REG_SP);
 
-                       M_ALD(REG_ITMP1_XPTR, REG_SP, 0 * 8);
-                       M_ALD(REG_ITMP2_XPC, REG_SP, 1 * 8);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_handle_exception, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_handle_exception, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
 
-       /* generate ArithmeticException stubs */
+       /* generate NegativeArraySizeException stubs */
 
        xcodeptr = NULL;
        
-       for (bref = cd->xdivrefs; bref != NULL; bref = bref->next) {
+       for (bref = cd->xcheckarefs; bref != NULL; bref = bref->next) {
                if ((cd->exceptiontablelength == 0) && (xcodeptr != NULL)) {
                        gen_resolvebranch(cd->mcodebase + bref->branchpos, 
                                                          bref->branchpos,
@@ -4061,53 +3978,33 @@ gen_method:
 
                MCODECHECK(512);
 
-               x86_64_mov_imm_reg(cd, 0, REG_ITMP2_XPC);                 /* 10 bytes */
+               M_MOV_IMM(0, REG_ITMP2_XPC);                              /* 10 bytes */
                dseg_adddata(cd, cd->mcodeptr);
                M_AADD_IMM32(bref->branchpos - 6, REG_ITMP2_XPC);         /* 7 bytes  */
 
                if (xcodeptr != NULL) {
-                       x86_64_jmp_imm(cd, xcodeptr - cd->mcodeptr - 5);
-               
+                       M_JMP_IMM(xcodeptr - cd->mcodeptr - 5);
+
                } else {
                        xcodeptr = cd->mcodeptr;
 
-                       M_ASUB_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-                       M_AST(REG_ITMP2_XPC, REG_SP, 1 * 8);
-
-                       /* create stackframe info */
-
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-
-                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[1]);
-
-                       M_MOV(REG_SP, rd->argintregs[2]);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), rd->argintregs[2]);
+                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[0]);
+                       M_MOV(REG_SP, rd->argintregs[1]);
+                       M_ALD(rd->argintregs[2], REG_SP, parentargs_base * 8);
                        M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_create_inline_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
 
-                       /* create exception */
+                       M_ASUB_IMM(2 * 8, REG_SP);
+                       M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       x86_64_mov_imm_reg(cd, (ptrint) new_arithmeticexception, REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-                       M_AST(REG_RESULT, REG_SP, 0 * 8);
+                       M_MOV_IMM((ptrint) stacktrace_inline_negativearraysizeexception,
+                                         REG_ITMP3);
+                       M_CALL(REG_ITMP3);
 
-                       /* removed stackframe info */
+                       M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                       M_AADD_IMM(2 * 8, REG_SP);
 
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_remove_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-                       M_ALD(REG_ITMP1_XPTR, REG_SP, 0 * 8);
-                       M_ALD(REG_ITMP2_XPC, REG_SP, 1 * 8);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_handle_exception, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_handle_exception, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
 
@@ -4129,54 +4026,33 @@ gen_method:
 
                MCODECHECK(512);
 
-               x86_64_mov_imm_reg(cd, 0, REG_ITMP2_XPC);                 /* 10 bytes */
+               M_MOV_IMM(0, REG_ITMP2_XPC);                              /* 10 bytes */
                dseg_adddata(cd, cd->mcodeptr);
                M_AADD_IMM32(bref->branchpos - 6, REG_ITMP2_XPC);         /* 7 bytes  */
 
                if (xcodeptr != NULL) {
-                       x86_64_jmp_imm(cd, xcodeptr - cd->mcodeptr - 5);
+                       M_JMP_IMM(xcodeptr - cd->mcodeptr - 5);
                
                } else {
                        xcodeptr = cd->mcodeptr;
 
-                       M_ASUB_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-                       M_AST(REG_ITMP2_XPC, REG_SP, 1 * 8);
-
-                       /* create stackframe info */
-
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-
-                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[1]);
-
-                       M_MOV(REG_SP, rd->argintregs[2]);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), rd->argintregs[2]);
+                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[0]);
+                       M_MOV(REG_SP, rd->argintregs[1]);
+                       M_ALD(rd->argintregs[2], REG_SP, parentargs_base * 8);
                        M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_create_inline_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
 
-                       /* create exception */
+                       M_ASUB_IMM(2 * 8, REG_SP);
+                       M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       x86_64_mov_imm_reg(cd, (ptrint) new_nullpointerexception,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-                       M_AST(REG_RESULT, REG_SP, 0 * 8);
+                       M_MOV_IMM((ptrint) stacktrace_inline_nullpointerexception,
+                                         REG_ITMP3);
+                       M_CALL(REG_ITMP3);
 
-                       /* removed stackframe info */
+                       M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                       M_AADD_IMM(2 * 8, REG_SP);
 
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_remove_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-                       M_ALD(REG_ITMP1_XPTR, REG_SP, 0 * 8);
-                       M_ALD(REG_ITMP2_XPC, REG_SP, 1 * 8);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_handle_exception, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_handle_exception, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
 
@@ -4198,70 +4074,32 @@ gen_method:
 
                MCODECHECK(512);
 
-               x86_64_mov_imm_reg(cd, 0, REG_ITMP2_XPC);                 /* 10 bytes */
+               M_MOV_IMM(0, REG_ITMP2_XPC);                              /* 10 bytes */
                dseg_adddata(cd, cd->mcodeptr);
                M_AADD_IMM32(bref->branchpos - 6, REG_ITMP2_XPC);         /* 7 bytes  */
 
                if (xcodeptr != NULL) {
-                       x86_64_jmp_imm(cd, xcodeptr - cd->mcodeptr - 5);
+                       M_JMP_IMM(xcodeptr - cd->mcodeptr - 5);
                
                } else {
                        xcodeptr = cd->mcodeptr;
 
-                       M_ASUB_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-                       M_AST(REG_ITMP2_XPC, REG_SP, 1 * 8);
-
-                       /* create stackframe info */
-
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-
-                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[1]);
-
-                       M_MOV(REG_SP, rd->argintregs[2]);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), rd->argintregs[2]);
+                       x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase), rd->argintregs[0]);
+                       M_MOV(REG_SP, rd->argintregs[1]);
+                       M_ALD(rd->argintregs[2], REG_SP, parentargs_base * 8);
                        M_MOV(REG_ITMP2_XPC, rd->argintregs[3]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_create_inline_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-                       x86_64_mov_imm_reg(cd, (ptrint) &builtin_get_exceptionptrptr,
-                                                          REG_ITMP1);
-                       x86_64_call_reg(cd, REG_ITMP1);
-
-                       M_ALD(REG_ITMP3, REG_RESULT, 0);
-                       x86_64_mov_imm_membase(cd, 0, REG_RESULT, 0);
-                       M_MOV(REG_ITMP3, REG_ITMP1_XPTR);
-#else
-                       x86_64_mov_imm_reg(cd, (ptrint) &_exceptionptr, REG_ITMP3);
-                       M_ALD(REG_ITMP1_XPTR, REG_ITMP3, 0);
-                       x86_64_mov_imm_membase(cd, 0, REG_ITMP3, 0);
-#endif
-
-                       M_AST(REG_ITMP1_XPTR, REG_SP, 0 * 8);
 
-                       /* call fillInStackTrace */
+                       M_ASUB_IMM(2 * 8, REG_SP);
+                       M_AST(REG_ITMP2_XPC, REG_SP, 0 * 8);
 
-                       M_MOV(REG_ITMP1_XPTR, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_call_fillInStackTrace,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) stacktrace_inline_fillInStackTrace, REG_ITMP3);
+                       M_CALL(REG_ITMP3);
 
-                       /* removed stackframe info */
+                       M_ALD(REG_ITMP2_XPC, REG_SP, 0 * 8);
+                       M_AADD_IMM(2 * 8, REG_SP);
 
-                       M_MOV(REG_SP, rd->argintregs[0]);
-                       M_AADD_IMM(2 * 8, rd->argintregs[0]);
-                       x86_64_mov_imm_reg(cd, (ptrint) stacktrace_remove_stackframeinfo,
-                                                          REG_ITMP3);
-                       x86_64_call_reg(cd, REG_ITMP3);
-
-                       M_ALD(REG_ITMP1_XPTR, REG_SP, 0 * 8);
-                       M_ALD(REG_ITMP2_XPC, REG_SP, 1 * 8);
-                       M_AADD_IMM(2 * 8 + sizeof(stackframeinfo), REG_SP);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_handle_exception, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_handle_exception, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
 
@@ -4299,23 +4137,22 @@ gen_method:
                        a = dseg_addaddress(cd, NULL);                      /* vftbl      */
 
                        x86_64_lea_membase_reg(cd, RIP, -(((ptrint) cd->mcodeptr + 7) - (ptrint) cd->mcodebase) + a, REG_ITMP3);
-                       x86_64_push_reg(cd, REG_ITMP3);
+                       M_PUSH(REG_ITMP3);
 #else
-                       x86_64_push_imm(cd, 0);
+                       M_PUSH_IMM(0);
 #endif
 
                        /* move machine code bytes and classinfo pointer into registers */
 
-                       x86_64_mov_imm_reg(cd, (ptrint) mcode, REG_ITMP3);
-                       x86_64_push_reg(cd, REG_ITMP3);
-                       x86_64_mov_imm_reg(cd, (ptrint) pref->ref, REG_ITMP3);
-                       x86_64_push_reg(cd, REG_ITMP3);
-
-                       x86_64_mov_imm_reg(cd, (ptrint) pref->patcher, REG_ITMP3);
-                       x86_64_push_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) mcode, REG_ITMP3);
+                       M_PUSH(REG_ITMP3);
+                       M_MOV_IMM((ptrint) pref->ref, REG_ITMP3);
+                       M_PUSH(REG_ITMP3);
+                       M_MOV_IMM((ptrint) pref->patcher, REG_ITMP3);
+                       M_PUSH(REG_ITMP3);
 
-                       x86_64_mov_imm_reg(cd, (ptrint) asm_wrapper_patcher, REG_ITMP3);
-                       x86_64_jmp_reg(cd, REG_ITMP3);
+                       M_MOV_IMM((ptrint) asm_wrapper_patcher, REG_ITMP3);
+                       M_JMP(REG_ITMP3);
                }
        }
        }
index c143c19745867c8be4cdb39450ced3afff993aad..46d105a3371d68ab566f06fc84027aa0d5f043a4 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md.c 2977 2005-07-10 22:21:36Z twisti $
+   $Id: md.c 2991 2005-07-11 21:25:31Z twisti $
 
 */
 
@@ -71,6 +71,7 @@ void signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        mcontext_t  *_mc;
        u1          *sp;
        functionptr  ra;
+       functionptr  xpc;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -79,12 +80,13 @@ void signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        /* different to the ones in <ucontext.h>                                  */
 
        sp = (u1 *) _mc->gregs[REG_RSP];
-       ra = (functionptr) _mc->gregs[REG_RIP];
+       xpc = (functionptr) _mc->gregs[REG_RIP];
+       ra = xpc;                           /* return address is equal to xpc     */
 
        _mc->gregs[REG_RAX] =
-               (ptrint) stacktrace_new_nullpointerexception(NULL, sp, ra);
+               (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
 
-       _mc->gregs[REG_R10] = _mc->gregs[REG_RIP];               /* REG_ITMP2_XPC */
+       _mc->gregs[REG_R10] = (ptrint) xpc;                      /* REG_ITMP2_XPC */
        _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
 }
 
@@ -101,6 +103,7 @@ void signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        mcontext_t  *_mc;
        u1          *sp;
        functionptr  ra;
+       functionptr  xpc;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
@@ -109,12 +112,13 @@ void signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
        /* different to the ones in <ucontext.h>                                  */
 
        sp = (u1 *) _mc->gregs[REG_RSP];
-       ra = (functionptr) _mc->gregs[REG_RIP];
+       xpc = (functionptr) _mc->gregs[REG_RIP];
+       ra = xpc;                           /* return address is equal to xpc     */
 
        _mc->gregs[REG_RAX] =
-               (ptrint) stacktrace_new_arithmeticexception(NULL, sp, ra);
+               (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
 
-       _mc->gregs[REG_R10] = _mc->gregs[REG_RIP];               /* REG_ITMP2_XPC */
+       _mc->gregs[REG_R10] = (ptrint) xpc;                      /* REG_ITMP2_XPC */
        _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
 }