* configure.ac (AC_CONFIG_FILES): Added
authortwisti <none@none>
Mon, 21 Aug 2006 15:17:48 +0000 (15:17 +0000)
committertwisti <none@none>
Mon, 21 Aug 2006 15:17:48 +0000 (15:17 +0000)
src/vm/jit/i386/darwin/Makefile.

* src/vm/jit/i386/codegen.c (createnativestub): Align stack to
16-bytes.

* src/vm/jit/i386/darwin/md-os.c: Darwin specific functions.
* src/vm/jit/i386/darwin/md-asm.h: Darwin specific assembler defines.
* src/vm/jit/i386/darwin/Makefile.am: New file.
* src/vm/jit/i386/darwin/.cvsignore: Likewise.

* src/vm/jit/i386/linux/md-asm.h: Linux specific assembler defines.
* src/vm/jit/i386/freebsd/md-asm.h: FreeBSD specific assembler defines.

* src/vm/jit/i386/md-asm.h: Removed.

* src/vm/jit/i386/asmpart.S (asm_handle_exception): Align stack to
16-bytes.
(asm_abstractmethoderror): Likewise.
(asm_patcher_wrapper): Likewise.
(asm_builtin_f2i, asm_builtin_d2i, asm_builtin_f2l, asm_builtin_d2l):
Likewise.

* src/vm/jit/i386/Makefile.am (DIST_SUBDIRS): Added darwin.
(AM_CPPFLAGS): Added OS_DIR as include.
(noinst_HEADERS): Removed md-asm.h.

* src/threads/native/threads.c (threads_cast_darwinstop): Use generic
defines and machine dependent structures.

12 files changed:
configure.ac
src/threads/native/threads.c
src/vm/jit/i386/Makefile.am
src/vm/jit/i386/asmpart.S
src/vm/jit/i386/codegen.c
src/vm/jit/i386/darwin/.cvsignore [new file with mode: 0644]
src/vm/jit/i386/darwin/Makefile.am [new file with mode: 0644]
src/vm/jit/i386/darwin/md-asm.h [new file with mode: 0644]
src/vm/jit/i386/darwin/md-os.c [new file with mode: 0644]
src/vm/jit/i386/freebsd/md-asm.h [new file with mode: 0644]
src/vm/jit/i386/linux/md-asm.h [new file with mode: 0644]
src/vm/jit/i386/md-asm.h [deleted file]

index ab355debcacce1946cc0474bc351ee6394bcd9cc..cc63d1c6c49685facbebf638345a60080c8d8690 100644 (file)
@@ -857,6 +857,7 @@ AC_CONFIG_FILES([Makefile]
                [src/vm/jit/alpha/freebsd/Makefile]
                [src/vm/jit/alpha/linux/Makefile]
                [src/vm/jit/i386/Makefile]
+               [src/vm/jit/i386/darwin/Makefile]
                [src/vm/jit/i386/freebsd/Makefile]
                [src/vm/jit/i386/linux/Makefile]
                [src/vm/jit/ifconv/Makefile]
index 8eb853a4f22f1755963624d982d1e6855e07120e..c43f0dd62b413a897dc768f229c55b46f9be6a08 100644 (file)
@@ -29,7 +29,7 @@
    Changes: Christian Thalinger
                        Edwin Steiner
 
-   $Id: threads.c 5195 2006-07-31 15:26:10Z twisti $
+   $Id: threads.c 5255 2006-08-21 15:17:48Z twisti $
 
 */
 
@@ -494,9 +494,13 @@ static void threads_cast_darwinstop(void)
        do {
                if (tobj != self)
                {
-                       thread_state_flavor_t flavor = PPC_THREAD_STATE;
-                       mach_msg_type_number_t thread_state_count = PPC_THREAD_STATE_COUNT;
+                       thread_state_flavor_t flavor = MACHINE_THREAD_STATE;
+                       mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
+#if defined(__I386__)
+                       i386_thread_state_t thread_state;
+#else
                        ppc_thread_state_t thread_state;
+#endif
                        mach_port_t thread = tobj->mach_thread;
                        kern_return_t r;
 
index 733fc2696f3fd38d2d37ef20ebd8468c40fa80c8..3ab62dd2cc51ec05d50876e228adc11c797921ad 100644 (file)
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4849 2006-04-26 14:09:15Z twisti $
+## $Id: Makefile.am 5255 2006-08-21 15:17:48Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
 DIST_SUBDIRS = \
+       darwin \
        freebsd \
        linux
 
 SUBDIRS = $(OS_DIR)
 
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir) -I$(top_builddir)/src
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir) -I$(top_builddir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR)
 AM_CCASFLAGS = $(AM_CPPFLAGS)
 
 LIBS =
@@ -50,11 +51,10 @@ CLEANFILES = offsets.h
 noinst_HEADERS = \
        arch.h \
        icmd_uses_reg_res.inc \
-       machine-instr.h \
-       \
-       md-asm.h
+       machine-instr.h
 
-noinst_LTLIBRARIES = libarch.la
+noinst_LTLIBRARIES = \
+       libarch.la
 
 if ENABLE_DISASSEMBLER
 DISASS_SOURCES = \
index 02e102ae57cdf0c567f87eb97d24410e3c35bbb1..c5f4904714ddbb3033bdedde5fe977a313badb32 100644 (file)
    Changes: Joseph Wenninger
             Edwin Steiner
 
-   $Id: asmpart.S 5247 2006-08-17 09:59:26Z twisti $
+   $Id: asmpart.S 5255 2006-08-21 15:17:48Z twisti $
 
 */
 
 
 #include "config.h"
 
+#include "md-asm.h"
+
 #include "vm/jit/i386/arch.h"
 #include "vm/jit/i386/md-abi.h"
-#include "vm/jit/i386/md-asm.h"
 #include "vm/jit/i386/offsets.h"
 
 #include "vm/jit/abi-asm.h"
@@ -265,7 +266,7 @@ asm_vm_call_method_exception_handler:
 
 asm_call_jit_compiler:
 L_asm_call_jit_compiler:                /* required for PIC code              */
-       sub     $(4*4),sp                   /* create stack frame                 */
+       sub     $(4*4),sp                   /* keep stack 16-byte aligned         */
 
        mov     itmp1,0*4(sp)               /* pass methodinfo pointer            */
        mov     mptr,1*4(sp)                /* pass method pointer                */
@@ -306,20 +307,20 @@ asm_handle_nat_exception:
                
 asm_handle_exception:
 L_asm_handle_exception:                 /* required for PIC code              */
-       sub     $((ARG_CNT+TMP_CNT)*4),sp   /* create maybe-leaf stackframe       */
+       sub     $((ARG_CNT+TMP_CNT+3)*4),sp /* keep stack 16-byte aligned         */
 
        SAVE_ARGUMENT_REGISTERS(0)          /* we save arg and temp registers in  */
        SAVE_TEMPORARY_REGISTERS(ARG_CNT)   /* case this is a leaf method         */
 
-       mov     $((ARG_CNT+TMP_CNT)*4),itmp3/* prepare a3 for handle_exception    */
+       mov     $((ARG_CNT+TMP_CNT+3)*4),itmp3 /* prepare a3 for handle_exception */
        mov     $1,t0                       /* set maybe-leaf flag                */
 
 L_asm_handle_exception_stack_loop:
-       sub     $(10*4),sp                  /* create stackframe                  */
+       sub     $(12*4),sp                  /* keep stack 16-byte aligned         */
        mov     xptr,4*4(sp)                /* save exception pointer             */
        mov     xpc,5*4(sp)                 /* save exception pc                  */
        add     sp,itmp3                    /* calculate Java sp into a3...       */
-       add     $(10*4),itmp3
+       add     $(12*4),itmp3
        mov     itmp3,7*4(sp)               /* ...and save it                     */
        mov     t0,8*4(sp)                  /* save maybe-leaf flag               */
 
@@ -342,7 +343,7 @@ L_asm_handle_exception_stack_loop:
        mov     v0,xpc                      /* move handlerpc into xpc            */
        mov     4*4(sp),xptr                /* restore exception pointer          */
        mov     8*4(sp),t0                  /* get maybe-leaf flag                */
-       add     $(10*4),sp                  /* free stackframe                    */
+       add     $(12*4),sp                  /* free stackframe                    */
 
        test    t0,t0                       /* test for maybe-leaf flag           */
        jz      L_asm_handle_exception_no_leaf
@@ -350,7 +351,7 @@ L_asm_handle_exception_stack_loop:
        RESTORE_ARGUMENT_REGISTERS(0)       /* if this is a leaf method, we have  */
        RESTORE_TEMPORARY_REGISTERS(ARG_CNT)/* to restore arg and temp registers  */
 
-       add     $((ARG_CNT+TMP_CNT)*4),sp   /* remove maybe-leaf stackframe       */
+       add     $((ARG_CNT+TMP_CNT+3)*4),sp /* remove maybe-leaf stackframe       */
 
 L_asm_handle_exception_no_leaf:
        jmp     *xpc                        /* jump to exception handler          */
@@ -359,12 +360,12 @@ L_asm_handle_exception_not_catched:
        mov     4*4(sp),xptr                /* restore exception pointer          */
        mov     6*4(sp),itmp3               /* restore data segment pointer       */
        mov     8*4(sp),t0                  /* get maybe-leaf flag                */
-       add     $(10*4),sp                  /* free stackframe                    */
+       add     $(12*4),sp                  /* free stackframe                    */
 
        test    t0,t0
        jz      L_asm_handle_exception_no_leaf_stack
 
-       add     $((ARG_CNT+TMP_CNT)*4),sp   /* remove maybe-leaf stackframe       */
+       add     $((ARG_CNT+TMP_CNT+3)*4),sp /* remove maybe-leaf stackframe       */
        xor     t0,t0                       /* clear the maybe-leaf flag          */
 
 L_asm_handle_exception_no_leaf_stack:
@@ -437,16 +438,16 @@ noflt:
 *******************************************************************************/
 
 asm_abstractmethoderror:
-       sub     $(2*4),sp                   /* create stack frame                 */
+       sub     $(3*4),sp                   /* keep stack 16-byte aligned         */
        mov     sp,itmp1                    /* pass java sp                       */
-       add     $((1+2)*4),itmp1
+       add     $((1+3)*4),itmp1
        mov     itmp1,0*4(sp)
-       mov     2*4(sp),itmp2               /* pass exception address             */
+       mov     3*4(sp),itmp2               /* pass exception address             */
        sub     $2,itmp2
        mov     itmp2,1*4(sp)
        call    exceptions_asm_new_abstractmethoderror
                                            /* exception pointer is return value  */
-       add     $(2*4),sp                   /* remove stack frame                 */
+       add     $(3*4),sp                   /* remove stack frame                 */
 
        pop     xpc                         /* get exception address              */
        sub     $2,xpc                      /* exception address is ra - 2        */
@@ -469,33 +470,33 @@ asm_abstractmethoderror:
 *******************************************************************************/
 
 asm_patcher_wrapper:
-       sub     $((2+4)*4),sp               /* create stack frame                 */
+       sub     $((1+4+4)*4),sp             /* keep stack 16-byte aligned         */
 
        mov     itmp1,(0+4)*4(sp)           /* save itmp1 and itmp2               */
        mov     itmp2,(1+4)*4(sp)
 
        mov     sp,itmp1                    /* pass SP of patcher stub            */
-       add     $((2+4)*4),itmp1
+       add     $((1+4+4)*4),itmp1
        mov     itmp1,0*4(sp)
        movl    $0,1*4(sp)                  /* pass PV (if NULL, use findmethod)  */
        movl    $0,2*4(sp)                  /* pass RA (it's on the stack)        */
        call    patcher_wrapper
-       mov     v0,0*4(sp)                  /* save return value                  */
+       mov     v0,itmp3                    /* save return value                  */
 
        mov     (0+4)*4(sp),itmp1           /* restore itmp1 and itmp2            */
        mov     (1+4)*4(sp),itmp2
 
-       mov     0*4(sp),itmp3               /* restore return value               */
        test    itmp3,itmp3                 /* exception thrown?                  */
        jne     L_asm_patcher_wrapper_exception
 
-       mov     (5+2+4)*4(sp),itmp3         /* restore REG_ITMP3                  */
-       add     $((6+2+4)*4),sp             /* remove stack frame, keep RA        */
+       mov     (5+1+4+4)*4(sp),itmp3       /* restore itmp3                      */
+       add     $((6+1+4+4)*4),sp           /* remove stack frame, keep RA        */
 
        ret                                 /* jump to new patched code           */
 
 L_asm_patcher_wrapper_exception:
        add     $((6+2+4)*4),sp             /* remove stack frame, keep RA        */
+       add     $((6+1+4+4)*4),sp           /* remove stack frame, keep RA        */
        mov     itmp3,xptr                  /* get exception                      */
        pop     xpc                         /* get and remove return address      */
        jmp     L_asm_handle_exception
@@ -559,7 +560,7 @@ asm_replacement_out:
     push    sp                          /* arg1: execution state              */
     push    itmp1                       /* arg0: replacement point            */
     call    replace_me                  /* call C function replace_me         */
-    call    abort                       /* NEVER REACHED                      */
+
 
 /* asm_replacement_in **********************************************************
 
@@ -595,6 +596,7 @@ asm_replacement_in:
        /* jump to new code */
        ret
 
+
 /************************ function asm_builtin_x2x *****************************
 *                                                                              *
 *   Wrapper functions for corner cases                                         *
@@ -602,31 +604,31 @@ asm_replacement_in:
 *******************************************************************************/
 
 asm_builtin_f2i:
-       sub     $4,%esp
+       sub     $(3*4),%esp
        fsts    (%esp)
        call    builtin_f2i
-       add     $4,%esp
+       add     $(3*4),%esp
        ret
 
 asm_builtin_d2i:
-       sub     $8,%esp
+       sub     $(3*4),%esp
        fstl    (%esp)
        call    builtin_d2i
-       add     $8,%esp
+       add     $(3*4),%esp
        ret
 
 asm_builtin_f2l:
-       sub     $4,%esp
+       sub     $(3*4),%esp
        fsts    (%esp)
        call    builtin_f2l
-       add     $4,%esp
+       add     $(3*4),%esp
        ret
 
 asm_builtin_d2l:
-       sub     $8,%esp
+       sub     $(3*4),%esp
        fstl    (%esp)
        call    builtin_d2l
-       add     $8,%esp
+       add     $(3*4),%esp
        ret
 
 
index 4cafff2d7a69e5f077d4ecc2f6b21ba5b87d7015..f375b4af7bb160f40de0279586152362626332ce 100644 (file)
@@ -31,7 +31,7 @@
             Christian Ullrich
                        Edwin Steiner
 
-   $Id: codegen.c 5237 2006-08-15 14:54:25Z christian $
+   $Id: codegen.c 5255 2006-08-21 15:17:48Z twisti $
 
 */
 
@@ -4654,6 +4654,10 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
                4 * 4 +                         /* 4 arguments (start_native_call)    */
                nmd->memuse;
 
+    /* keep stack 16-byte aligned */
+
+       stackframesize |= 0x3;
+
        /* create method header */
 
        (void) dseg_addaddress(cd, code);                      /* CodeinfoPointer */
@@ -4812,11 +4816,11 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
        /* if function is static, put class into second argument */
 
        if (m->flags & ACC_STATIC)
-               M_AST_IMM((ptrint) m->class, REG_SP, 1 * 4);
+               M_AST_IMM(m->class, REG_SP, 1 * 4);
 
        /* put env into first argument */
 
-       M_AST_IMM((ptrint) _Jv_env, REG_SP, 0 * 4);
+       M_AST_IMM(_Jv_env, REG_SP, 0 * 4);
 
        /* call the native function */
 
diff --git a/src/vm/jit/i386/darwin/.cvsignore b/src/vm/jit/i386/darwin/.cvsignore
new file mode 100644 (file)
index 0000000..8f719f9
--- /dev/null
@@ -0,0 +1,9 @@
+*.a
+*.o
+*.la
+*.lo
+.deps
+.libs
+Makefile
+Makefile.in
+TAGS
diff --git a/src/vm/jit/i386/darwin/Makefile.am b/src/vm/jit/i386/darwin/Makefile.am
new file mode 100644 (file)
index 0000000..27d1704
--- /dev/null
@@ -0,0 +1,55 @@
+## src/vm/jit/i386/linux/Makefile.am
+##
+## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+## J. Wenninger, Institut f. Computersprachen - TU Wien
+##
+## 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., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+##
+## Contact: cacao@cacaojvm.org
+##
+## Authors: Christian Thalinger
+##
+## Changes:
+##
+## $Id: Makefile.am 4563 2006-03-06 13:03:05Z twisti $
+
+## Process this file with automake to produce Makefile.in
+
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)
+
+LIBS =
+
+noinst_HEADERS = \
+       md-asm.h
+
+noinst_LTLIBRARIES = \
+       libmd.la
+
+libmd_la_SOURCES = \
+       md-os.c
+
+
+## Local variables:
+## mode: Makefile
+## indent-tabs-mode: t
+## c-basic-offset: 4
+## tab-width: 8
+## compile-command: "automake --add-missing"
+## End:
diff --git a/src/vm/jit/i386/darwin/md-asm.h b/src/vm/jit/i386/darwin/md-asm.h
new file mode 100644 (file)
index 0000000..b936705
--- /dev/null
@@ -0,0 +1,149 @@
+/* src/vm/jit/i386/darwin/md-asm.h - assembler defines for i386 Darwin ABI
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: md-asm.h 4357 2006-01-22 23:33:38Z twisti $
+
+*/
+
+
+#ifndef _MD_ASM_H
+#define _MD_ASM_H
+
+/* register defines ***********************************************************/
+
+#define v0       %eax
+#define itmp1    v0
+
+#define itmp2    %ecx
+#define itmp3    %edx
+
+#define t0       %ebx
+
+#define sp       %esp
+#define s0       %ebp
+#define s1       %esi
+#define s2       %edi
+
+#define bp       s0
+
+#define itmp1b   %al
+
+#define xptr     itmp1
+#define xpc      itmp2
+#define mptr     itmp2
+
+
+/* save and restore macros ****************************************************/
+
+#define SAVE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define SAVE_TEMPORARY_REGISTERS(off) \
+       mov     t0,(0+(off))*4(sp) ;
+
+
+#define RESTORE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define RESTORE_TEMPORARY_REGISTERS(off) \
+       mov     (0+(off))*4(sp),t0 ;
+
+
+/* defines for darwin's old gnu assembler *************************************/
+
+#define asm_md_init                           _asm_md_init
+
+#define asm_vm_call_method                    _asm_vm_call_method
+#define asm_vm_call_method_int                _asm_vm_call_method_int
+#define asm_vm_call_method_long               _asm_vm_call_method_long
+#define asm_vm_call_method_float              _asm_vm_call_method_float
+#define asm_vm_call_method_double             _asm_vm_call_method_double
+
+#define asm_vm_call_method_exception_handler  _asm_vm_call_method_exception_handler
+
+#define asm_call_jit_compiler                 _asm_call_jit_compiler
+
+#define asm_handle_nat_exception              _asm_handle_nat_exception
+#define asm_handle_exception                  _asm_handle_exception
+
+#define asm_abstractmethoderror               _asm_abstractmethoderror
+
+#define asm_patcher_wrapper                   _asm_patcher_wrapper
+
+#define asm_replacement_out                   _asm_replacement_out
+#define asm_replacement_in                    _asm_replacement_in
+
+#define asm_builtin_f2i                       _asm_builtin_f2i
+#define asm_builtin_f2l                       _asm_builtin_f2l
+#define asm_builtin_d2i                       _asm_builtin_d2i
+#define asm_builtin_d2l                       _asm_builtin_d2l
+
+#define asm_criticalsections                  _asm_criticalsections
+#define asm_getclassvalues_atomic             _asm_getclassvalues_atomic
+
+
+/* external defines ***********************************************************/
+
+#define exceptions_get_and_clear_exception    _exceptions_get_and_clear_exception
+
+#define builtin_throw_exception               _builtin_throw_exception
+#define codegen_get_pv_from_pc                _codegen_get_pv_from_pc
+#define exceptions_handle_exception           _exceptions_handle_exception
+#define jit_asm_compile                       _jit_asm_compile
+
+#define exceptions_asm_new_abstractmethoderror \
+    _exceptions_asm_new_abstractmethoderror
+
+#define patcher_wrapper                       _patcher_wrapper
+
+#define replace_me                            _replace_me
+
+#define abort                                 _abort
+
+#define builtin_f2i                           _builtin_f2i
+#define builtin_f2l                           _builtin_f2l
+#define builtin_d2i                           _builtin_d2i
+#define builtin_d2l                           _builtin_d2l
+
+#endif /* _MD_ASM_H */
+
+
+/*
+ * 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
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/i386/darwin/md-os.c b/src/vm/jit/i386/darwin/md-os.c
new file mode 100644 (file)
index 0000000..488e598
--- /dev/null
@@ -0,0 +1,176 @@
+/* src/vm/jit/i386/darwin/md-os.c - machine dependent i386 Darwin functions
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: md-os.c 5074 2006-07-04 16:05:35Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <signal.h>
+#include <ucontext.h>
+
+#include "vm/types.h"
+
+#include "vm/jit/i386/md-abi.h"
+
+#include "vm/exceptions.h"
+#include "vm/global.h"
+#include "vm/signallocal.h"
+#include "vm/stringlocal.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/stacktrace.h"
+
+
+/* md_signal_handler_sigsegv ***************************************************
+
+   NullPointerException signal handler for hardware null pointer
+   check.
+
+*******************************************************************************/
+
+void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t          *_uc;
+       mcontext_t           _mc;
+       i386_thread_state_t *_ss;
+       u1                  *sp;
+       u1                  *ra;
+       u1                  *xpc;
+
+       _uc = (ucontext_t *) _p;
+       _mc = _uc->uc_mcontext;
+       _ss = &_mc->ss;
+
+       sp  = (u1 *) _ss->esp;
+       xpc = (u1 *) _ss->eip;
+       ra  = xpc;                          /* return address is equal to xpc     */
+
+       _ss->eax =
+               (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
+
+       _ss->ecx = (ptrint) xpc;
+       _ss->eip = (ptrint) asm_handle_exception;
+}
+
+
+/* md_signal_handler_sigfpe ****************************************************
+
+   ArithmeticException signal handler for hardware divide by zero
+   check.
+
+*******************************************************************************/
+
+void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
+{
+       ucontext_t          *_uc;
+       mcontext_t           _mc;
+       i386_thread_state_t *_ss;
+       u1                  *sp;
+       u1                  *ra;
+       u1                  *xpc;
+
+       _uc = (ucontext_t *) _p;
+       _mc = _uc->uc_mcontext;
+       _ss = &_mc->ss;
+
+       sp  = (u1 *) _ss->esp;
+       xpc = (u1 *) _ss->eip;
+       ra  = xpc;                          /* return address is equal to xpc     */
+
+       _ss->eax =
+               (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
+
+       _ss->ecx = (ptrint) xpc;
+       _ss->eip = (ptrint) asm_handle_exception;
+}
+
+
+/* md_signal_handler_sigusr2 ***************************************************
+
+   Signal handler for profiling sampling.
+
+*******************************************************************************/
+
+void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
+{
+       threadobject        *t;
+       ucontext_t          *_uc;
+       mcontext_t           _mc;
+       i386_thread_state_t *_ss;
+       u1                  *pc;
+
+       t = THREADOBJECT;
+
+       _uc = (ucontext_t *) _p;
+       _mc = _uc->uc_mcontext;
+       _ss = &_mc->ss;
+
+       pc = (u1 *) _ss->eip;
+
+       t->pc = pc;
+}
+
+
+#if defined(ENABLE_THREADS)
+void thread_restartcriticalsection(ucontext_t *_uc)
+{
+       mcontext_t           _mc;
+       i386_thread_state_t *_ss;
+       u1                  *pc;
+       void                *rpc;
+
+       _mc = _uc->uc_mcontext;
+       _ss = &_mc->ss;
+
+       pc = (u1 *) _ss->eip;
+
+       rpc = critical_find_restart_point(pc);
+
+       if (rpc != NULL)
+               _ss->eip = (ptrint) rpc;
+}
+#endif
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/i386/freebsd/md-asm.h b/src/vm/jit/i386/freebsd/md-asm.h
new file mode 100644 (file)
index 0000000..2c9c5d5
--- /dev/null
@@ -0,0 +1,92 @@
+/* src/vm/jit/i386/md-asm.h - assembler defines for i386 ABI
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: md-asm.h 5107 2006-07-11 18:35:27Z twisti $
+
+*/
+
+
+#ifndef _MD_ASM_H
+#define _MD_ASM_H
+
+/* register defines ***********************************************************/
+
+#define v0       %eax
+#define itmp1    v0
+
+#define itmp2    %ecx
+#define itmp3    %edx
+
+#define t0       %ebx
+
+#define sp       %esp
+#define s0       %ebp
+#define s1       %esi
+#define s2       %edi
+
+#define bp       s0
+
+#define itmp1b   %al
+
+#define xptr     itmp1
+#define xpc      itmp2
+#define mptr     itmp2
+
+
+/* save and restore macros ****************************************************/
+
+#define SAVE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define SAVE_TEMPORARY_REGISTERS(off) \
+       mov     t0,(0+(off))*4(sp) ;
+
+
+#define RESTORE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define RESTORE_TEMPORARY_REGISTERS(off) \
+       mov     (0+(off))*4(sp),t0 ;
+
+#endif /* _MD_ASM_H */
+
+
+/*
+ * 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
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/i386/linux/md-asm.h b/src/vm/jit/i386/linux/md-asm.h
new file mode 100644 (file)
index 0000000..2c9c5d5
--- /dev/null
@@ -0,0 +1,92 @@
+/* src/vm/jit/i386/md-asm.h - assembler defines for i386 ABI
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Christian Thalinger
+
+   Changes:
+
+   $Id: md-asm.h 5107 2006-07-11 18:35:27Z twisti $
+
+*/
+
+
+#ifndef _MD_ASM_H
+#define _MD_ASM_H
+
+/* register defines ***********************************************************/
+
+#define v0       %eax
+#define itmp1    v0
+
+#define itmp2    %ecx
+#define itmp3    %edx
+
+#define t0       %ebx
+
+#define sp       %esp
+#define s0       %ebp
+#define s1       %esi
+#define s2       %edi
+
+#define bp       s0
+
+#define itmp1b   %al
+
+#define xptr     itmp1
+#define xpc      itmp2
+#define mptr     itmp2
+
+
+/* save and restore macros ****************************************************/
+
+#define SAVE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define SAVE_TEMPORARY_REGISTERS(off) \
+       mov     t0,(0+(off))*4(sp) ;
+
+
+#define RESTORE_ARGUMENT_REGISTERS(off) \
+    /* no argument registers */
+
+#define RESTORE_TEMPORARY_REGISTERS(off) \
+       mov     (0+(off))*4(sp),t0 ;
+
+#endif /* _MD_ASM_H */
+
+
+/*
+ * 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
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
diff --git a/src/vm/jit/i386/md-asm.h b/src/vm/jit/i386/md-asm.h
deleted file mode 100644 (file)
index 2c9c5d5..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/* src/vm/jit/i386/md-asm.h - assembler defines for i386 ABI
-
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   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., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: md-asm.h 5107 2006-07-11 18:35:27Z twisti $
-
-*/
-
-
-#ifndef _MD_ASM_H
-#define _MD_ASM_H
-
-/* register defines ***********************************************************/
-
-#define v0       %eax
-#define itmp1    v0
-
-#define itmp2    %ecx
-#define itmp3    %edx
-
-#define t0       %ebx
-
-#define sp       %esp
-#define s0       %ebp
-#define s1       %esi
-#define s2       %edi
-
-#define bp       s0
-
-#define itmp1b   %al
-
-#define xptr     itmp1
-#define xpc      itmp2
-#define mptr     itmp2
-
-
-/* save and restore macros ****************************************************/
-
-#define SAVE_ARGUMENT_REGISTERS(off) \
-    /* no argument registers */
-
-#define SAVE_TEMPORARY_REGISTERS(off) \
-       mov     t0,(0+(off))*4(sp) ;
-
-
-#define RESTORE_ARGUMENT_REGISTERS(off) \
-    /* no argument registers */
-
-#define RESTORE_TEMPORARY_REGISTERS(off) \
-       mov     (0+(off))*4(sp),t0 ;
-
-#endif /* _MD_ASM_H */
-
-
-/*
- * 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
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */