Fixes Debian bug #350729
authortwisti <none@none>
Tue, 31 Jan 2006 15:35:22 +0000 (15:35 +0000)
committertwisti <none@none>
Tue, 31 Jan 2006 15:35:22 +0000 (15:35 +0000)
* src/vm/jit/i386/asmpart.S (asm_md_init): Added, puts the FPU to
64-bit precision mode.
* src/vm/jit/i386/md.c (md_init): Call asm_md_init.

* src/vm/jit/asmpart.h (asm_md_init): Added.
(has_no_x_instr_set): Removed.
* src/vm/options.c, src/vm/options.h (has_ext_instr_set): Removed.
* src/vm/jit/jit.c (jit_init): Removed has_no_x_instr_set call.
* src/vm/jit/alpha/asmpart.S (has_no_x_instr_set): Renamed to
asm_md_init.
* src/vm/jit/alpha/md.c (has_ext_instr_set): Added.
(md_init): Call asm_md_init.
* src/vm/jit/alpha/md.h (has_ext_instr_set): Added.

src/vm/jit/alpha/asmpart.S
src/vm/jit/alpha/md.c
src/vm/jit/alpha/md.h
src/vm/jit/asmpart.h
src/vm/jit/i386/asmpart.S
src/vm/jit/i386/md.c
src/vm/jit/jit.c
src/vm/options.c
src/vm/options.h

index 9255cc8b0150080813bd1ce63ceca020a7a087a8..6689f6896e74586346e78eaf24371f701d9a5362 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: asmpart.S 4357 2006-01-22 23:33:38Z twisti $
+   $Id: asmpart.S 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -52,8 +52,9 @@
 
 /********************* exported functions and variables ***********************/
 
+       .globl asm_md_init
+
        .globl asm_sync_instruction_cache
-       .globl has_no_x_instr_set
 
        .globl asm_calljavafunction
        .globl asm_calljavafunction_int
@@ -91,20 +92,24 @@ asm_sync_instruction_cache:
 
        .end    asm_sync_instruction_cache
 
-/*********************** function has_no_x_instr_set ***************************
-*                                                                              *
-*   determines if the byte support instruction set (21164a and higher)         *
-*   is available.                                                              *
-*                                                                              *
+
+/* asm_md_init *****************************************************************
+
+   Initialize machine dependent stuff.
+
+   Determines if the byte support instruction set (21164a and higher)
+   is available.
+
 *******************************************************************************/
 
-       .ent    has_no_x_instr_set
-has_no_x_instr_set:
+       .ent    asm_md_init
+
+asm_md_init:
 
-       .long   0x47e03c20                /* amask   1,v0                         */
-       jmp     zero,(ra)                 /* return                               */
+       .long   0x47e03c20                  /* amask   1,v0                       */
+       jmp     zero,(ra)                   /* return                             */
 
-       .end    has_no_x_instr_set
+       .end    asm_md_init
 
 
 /********************* function asm_calljavafunction ***************************
index dce3afd558c534c02a6b2167425643ab013a4f36..cdd5fea5ba1259bd83cf68eb6fc0498af450d865 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Joseph Wenninger
             Christian Thalinger
 
-   $Id: md.c 4357 2006-01-22 23:33:38Z twisti $
+   $Id: md.c 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -57,6 +57,11 @@ extern void ieee_set_fp_control(unsigned long fp_control);
 #include "vm/jit/stacktrace.h"
 
 
+/* global variables ***********************************************************/
+
+bool has_ext_instr_set = false;             /* has instruction set extensions */
+
+
 /* md_init *********************************************************************
 
    Do some machine dependent initialization.
@@ -65,7 +70,9 @@ extern void ieee_set_fp_control(unsigned long fp_control);
 
 void md_init(void)
 {
-       /* XXX TWISTI: do we really need this? fptest's seem to work fine */
+       /* check for extended instruction set */
+
+       has_ext_instr_set = !asm_md_init();
 
 #if defined(__LINUX__)
        /* Linux on Digital Alpha needs an initialisation of the ieee
index 804cf3ecf9cb0904efeaaa7d8b59674a3dcd45e2..80200715f81b54668962279d395e73ffeda3e9e7 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: md.h 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
 #ifndef _MD_H
 #define _MD_H
 
+#include "config.h"
+#include "vm/global.h"
+
+
+/* global variables ***********************************************************/
+
+extern bool has_ext_instr_set;
+
 /* function prototypes ********************************************************/
 
 #endif /* _MD_H_ */
index 23936504c8878bdd5d208133d521e06aae599af6..97172917e061e23111dcb9e5f59321baa23e90ca 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: asmpart.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: asmpart.h 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -224,14 +224,12 @@ struct castinfo {
 };
 
 
-#if defined(__ALPHA__)
-/* 
-   determines if the byte support instruction set (21164a and higher)
-   is available.
-*/
-int has_no_x_instr_set(void);
+/* function prototypes ********************************************************/
+
+/* machine dependent initialization */
+s4 asm_md_init(void);
+
 void asm_sync_instruction_cache(void);
-#endif
 
 
 /* 
index f90743898e81527ed13abd67f48decff826cb6c2..63c23d53aadcc33350da64f6c62e5403eb676fe3 100644 (file)
@@ -30,7 +30,7 @@
 
    Changes: Joseph Wenninger
 
-   $Id: asmpart.S 4357 2006-01-22 23:33:38Z twisti $
+   $Id: asmpart.S 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -50,6 +50,8 @@
 
 /* exported functions and variables *******************************************/
 
+       .globl asm_md_init
+
        .globl asm_calljavafunction
        .globl asm_calljavafunction_int
 
        .globl asm_getclassvalues_atomic
 
 
+/* asm_md_init *****************************************************************
+
+   Initialize machine dependent stuff.
+
+   See: http://www.srware.com/linux_numerics.txt
+
+   This puts the X86 FPU in 64-bit precision mode.  The default under
+   Linux is to use 80-bit mode, which produces subtle differences from
+   FreeBSD and other systems, eg, (int)(1000*atof("0.3")) is 300 in
+   64-bit mode, 299 in 80-bit mode.
+
+   Fixes: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=350729
+
+*******************************************************************************/
+
+asm_md_init:
+       sub     $4,sp                       /* allocate space for the FPU state   */
+       fnstcw  (sp)                        /* get the FPU state                  */
+       mov     (sp),%eax
+       and     $0xfcff,%ax                 /* remove the extended mode flag      */
+       or      $0x0200,%ax                 /* put the double mode flag           */
+       mov     %eax,(sp)                   /* store new FPU state                */
+       fldcw   (sp)                        /* setup new FPU state                */
+       add     $4,sp
+       ret
+
+
 /********************* function asm_calljavafunction ***************************
 *                                                                              *
 *   This function calls a Java-method (which possibly needs compilation)       *
index cd50dbd6198e2d18d2984ea324fe6f58f1d45fb2..a9fcf7c540334c361177364c78c97f54df1f3f5f 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md.c 4357 2006-01-22 23:33:38Z twisti $
+   $Id: md.c 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -37,6 +37,7 @@
 #include "vm/types.h"
 
 #include "vm/global.h"
+#include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
 
 
@@ -48,7 +49,7 @@
 
 void md_init(void)
 {
-       /* nothing to do */
+       (void) asm_md_init();
 }
 
 
index 0b145d6c390294baef503cf882f0e31142659290..2f6ae63649793a7df3d87045314592371fac76d7 100644 (file)
@@ -31,7 +31,7 @@
             Christian Thalinger
             Christian Ullrich
 
-   $Id: jit.c 4381 2006-01-28 14:18:06Z twisti $
+   $Id: jit.c 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -1203,10 +1203,6 @@ void jit_init(void)
 {
        s4 i;
 
-#if defined(__ALPHA__)
-       has_ext_instr_set = ! has_no_x_instr_set();
-#endif
-
        for (i = 0; i < 256; i++)
                stackreq[i] = 1;
 
index c56d464afae8b5e26ae52822506ad14a7f50ce63..90b602dc0f0fd73fb4fb339a44436845400b2852 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: options.c 4388 2006-01-30 15:44:52Z twisti $
+   $Id: options.c 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -104,8 +104,6 @@ bool makeinitializations = true;
 bool getloadingtime = false;   /* to measure the runtime                     */
 bool getcompilingtime = false; /* compute compile time                       */
 
-int has_ext_instr_set = 0;     /* has instruction set extensions */
-
 bool opt_stat = false;
 bool opt_verify = true;        /* true if classfiles should be verified      */
 bool opt_eager = false;
index 75cbd09d178764438acf8e8950aa54eb4f83a11c..e6a2605fd1a81578a418790c2d8c780465815e23 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: options.h 4388 2006-01-30 15:44:52Z twisti $
+   $Id: options.h 4392 2006-01-31 15:35:22Z twisti $
 
 */
 
@@ -118,8 +118,6 @@ extern bool makeinitializations;
 extern bool getloadingtime;
 extern bool getcompilingtime;
 
-extern int has_ext_instr_set;
-
 extern bool opt_stat;
 extern bool opt_verify;
 extern bool opt_eager;