changeset 512:07b7530c9f18

. Fix the signal handling code for 64 bit builds on Mac OS X. . Change a comment to make sense.
author glewis@misty.eyesbeyond.com
date Mon, 29 Dec 2008 09:49:15 -0800
parents 897a4fb539b6
children 7799fd334445
files src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp
diffstat 1 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Sun Dec 28 18:19:15 2008 -0800
+++ b/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Mon Dec 29 09:49:15 2008 -0800
@@ -459,7 +459,7 @@
       }
       else
 
-#if defined(AMD64) && !defined(__APPLE__)
+#ifdef AMD64
       if (sig == SIGFPE  &&
           (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
         stub =
@@ -468,18 +468,32 @@
                                               pc,
                                               SharedRuntime::
                                               IMPLICIT_DIVIDE_BY_ZERO);
+#ifdef __APPLE__
+      } else if (sig == SIGFPE && info->si_code == FPE_NOOP) {
+        int op = pc[0];
+
+        // Skip REX
+        if ((pc[0] & 0xf0) == 0x40) {
+          op = pc[1];
+        } else {
+          op = pc[0];
+        }
+
+        // Check for IDIV
+        if (op == 0xF7) {
+          stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime:: IMPLICIT_DIVIDE_BY_ZERO);
+        } else {
+          // TODO: handle more cases if we are using other x86 instructions
+          //   that can generate SIGFPE signal.
+          tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);
+          fatal("please update this code.");
+        }
+#endif /* __APPLE__ */
 
 #else
       if (sig == SIGFPE /* && info->si_code == FPE_INTDIV */) {
-        // HACK: si_code does not work on bsd 2.2.12-20!!!
+        // HACK: si_code does not work on linux 2.2.12-20!!!
         int op = pc[0];
-        
-#  ifdef AMD64
-        // Skip REX
-        if ((pc[0] & 0xf0) == 0x40) {
-          op = pc[1];
-#  endif
-        
         if (op == 0xDB) {
           // FIST
           // TODO: The encoding of D2I in i486.ad can cause an exception