Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4179984

(porting) OpenVMS platform mods - added functions to fix floating point bugs

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      For the JDK 116 release on the OpenVMS platform running on DIGITAL's
      hardware, DIGITAL has changed, the following JDK 116 source file
      in the shared part of the JDK.

      - The following files were modified because of differences in the Alpha
      hardware on which OpenVMS runs:

      diff -c -r JDK116/src/share/java/runtime/executeJava.c
      sun_JDK116/src/share/java/runtime/executeJava.c
      *** JDK116/src/share/java/runtime/executeJava.c Wed Apr 8 14:33:11 1998
      --- sun_JDK116/src/share/java/runtime/executeJava.c Thu Apr 16 13:50:02 1998
      ***************
      *** 31,40 ****
        #include <sys/types.h>
        #include <string.h>
        #include <stdarg.h>
      - #ifdef __VMS
      - #include <fp.h>
      - /* include the math functions MPH*/
      - #endif
        
        #include "bool.h"
        #include "memory.h"
      --- 31,36 ----
      ***************
      *** 118,194 ****
        
        #endif /* BREAKPTS */
        
      - /*
      - * OSF comments
      - * the following functions fix floating point bugs on some systems
      - */
      - #define MAX_LONGLONG ((int64_t) (~ (((uint64_t) 1) << 63)))
      - #define MIN_LONGLONG ((int64_t) (((int64_t) 1) << 63))
      -
      - #define float2i(f) (double2i((double)f))
      - #include <limits.h>
      -
      - int64_t
      - double2i(double f)
      - {
      - if (f == 0.0) {
      - return 0;
      - } else {
      - int negative;
      - double mant;
      - int exp;
      - uint32_t low;
      - if (f < 0) {
      - negative = 1;
      - f = -f;
      - } else {
      - negative = 0;
      - }
      - mant = frexp(f, &exp);
      -
      - if (exp > 31) {
      - if (negative) {
      - return INT_MIN;
      - } else {
      - return INT_MAX;
      - }
      - } else {
      - low = (uint32_t) f;
      - if (negative) {
      - return (-((int64_t) low));
      - } else {
      - return ((int64_t) low);
      - }
      - }
      - }
      - }
      -
      -
      - /*** cds - return -0.0, NaN as defined by JVM spec for drem/frem ***/
      - double drem_local (double d1, double d2)
      - {
      - double ret;
      -
      - if (!finite(d1) || (d2 == 0.0)) {
      - ret = DBL_QNAN;
      - } else {
      - ret = DREM (d1, d2);
      - /* printf ("drem_local: drem (%g, %g) = %g\n", d1, d2, ret); */
      - if (ret == 0.0) {
      - /* make sure the sign is correct for a 0.0 result */
      - if ((d1 < 0.0) || IS_NEG0(d1))
      - ret = -0.0;
      - }
      - }
      -
      - return ret;
      - }
      -
        /* Execute bytecodes at "pc" in the specified execution environment.
           Returns TRUE if completed OK, FALSE if finished because of some
           uncaught exception. */
        
      -
        bool_t ExecuteJava(unsigned char *initial_pc, ExecEnv *ee)
        {
        /* This is ugly. Some machines (and compilers) produce better code from
      --- 114,123 ----
      ***************
      *** 496,530 ****
         SIZE_AND_STACK(1, 1);
        
         case opc_f2i: /* Convert top of stack float to int */
      ! /*** OSF/cds - OSF bug fix for correct NaN handling ***/
      ! /*** cds - was: S_INT(-1) = float2l(S_FLOAT(-1)); ***/
      ! {
      ! float f;
      ! f = S_FLOAT(-1);
      ! /* bug : infinity not translated as specified */
      ! S_INT(-1) = finite(f) ?
      ! float2i(f) :
      ! isnan(f) ? 0 :
      ! (f < 0) ? (int32_t) 0x80000000 :
      ! (int32_t) 0x7fffffff;
         TRACE(("\tf2i => %d\n", S_INT(-1)));
         SIZE_AND_STACK(1, 0);
      ! }
         case opc_f2l: /* convert top of stack float to long */
      ! /*** OSF/cds - bug fix for correct NaN handling ***/
      ! /*** cds - was: SET_S_LONG(-1, float2ll(S_FLOAT(-1))); ***/
      ! {
      ! float f;
      ! f = S_FLOAT(-1);
      ! /* bug : infinity not translated as specified */
      ! SET_S_LONG(-1, (finite(f) ?
      ! float2ll(f) :
      ! isnan(f) ? int2ll(0) :
      ! (f < 0) ? MIN_LONGLONG :
      ! MAX_LONGLONG));
         TRACE(("\tf2l => %s\n", S_LONGSTRING(-1)));
         SIZE_AND_STACK(1, 1);
      - }
        
         case opc_f2d: /* convert top of stack float to double */
         SET_S_DOUBLE(-1, S_FLOAT(-1));
      --- 425,438 ----
         SIZE_AND_STACK(1, 1);
        
         case opc_f2i: /* Convert top of stack float to int */
      ! S_INT(-1) = float2l(S_FLOAT(-1));
         TRACE(("\tf2i => %d\n", S_INT(-1)));
         SIZE_AND_STACK(1, 0);
      !
         case opc_f2l: /* convert top of stack float to long */
      ! SET_S_LONG(-1, float2ll(S_FLOAT(-1)));
         TRACE(("\tf2l => %s\n", S_LONGSTRING(-1)));
         SIZE_AND_STACK(1, 1);
        
         case opc_f2d: /* convert top of stack float to double */
         SET_S_DOUBLE(-1, S_FLOAT(-1));
      ***************
      *** 549,570 ****
         SIZE_AND_STACK(1, 0);
        
         case opc_d2i:
      ! /*** OSF/cds - bug fix for correct NaN handling ***/
      ! /*** cds - was: S_INT(-2) = double2l(S_DOUBLE(-2)); ***/
      ! {
      ! double d;
      !
      ! d = S_DOUBLE(-2);
      ! /* bug : infinity not translated as specified */
      ! S_INT(-2) = finite(d) ?
      ! double2i(d) :
      ! isnan(d) ? 0 :
      ! (d < 0) ? (int32_t) 0x80000000 :
      ! (int32_t) 0x7fffffff;
      !
         TRACE(("\td2i => %d\n", S_INT(-2)));
         SIZE_AND_STACK(1, -1);
      - }
        
         case opc_d2f:
         S_FLOAT(-2) = S_DOUBLE(-2);
      --- 457,465 ----
         SIZE_AND_STACK(1, 0);
        
         case opc_d2i:
      ! S_INT(-2) = double2l(S_DOUBLE(-2));
         TRACE(("\td2i => %d\n", S_INT(-2)));
         SIZE_AND_STACK(1, -1);
        
         case opc_d2f:
         S_FLOAT(-2) = S_DOUBLE(-2);
      ***************
      *** 573,592 ****
         SIZE_AND_STACK(1, -1);
        
         case opc_d2l:
      ! /*** OSF/cds - bug fix for correct NaN handling ***/
      ! /*** cds - was: SET_S_LONG(-2, double2ll(S_DOUBLE(-2))); ***/
      ! {
      ! double d;
      ! d = S_DOUBLE(-2);
      ! /* bug : infinity not translated as specified */
      ! SET_S_LONG(-2, (finite(d) ?
      ! double2ll(d) :
      ! isnan(d) ? int2ll(0) :
      ! (d < 0) ? MIN_LONGLONG :
      ! MAX_LONGLONG));
         TRACE(("\td2l => %s\n", S_LONGSTRING(-2)));
         SIZE_AND_STACK(1, 0);
      - }
        
         case opc_i2b:
         S_INT(-1) = (signed char) S_INT(-1);
      --- 468,476 ----
         SIZE_AND_STACK(1, -1);
        
         case opc_d2l:
      ! SET_S_LONG(-2, double2ll(S_DOUBLE(-2)));
         TRACE(("\td2l => %s\n", S_LONGSTRING(-2)));
         SIZE_AND_STACK(1, 0);
        
         case opc_i2b:
         S_INT(-1) = (signed char) S_INT(-1);
      ***************
      *** 821,834 ****
         BINARY_FLOAT_OP(div, /)
        
         case opc_frem:
      ! /*** cds - was DREM ***/
      ! S_FLOAT(-2) = drem_local(S_FLOAT(-2), S_FLOAT(-1));
         TRACE(("\t%s => %g\n", opnames[opcode], S_FLOAT(-2)));
         SIZE_AND_STACK(1, -1);
        
         case opc_drem:
      ! /*** cds - was DREM ***/
      ! SET_S_DOUBLE(-4, drem_local(S_DOUBLE(-4), S_DOUBLE2(-2)));
         TRACE(("\t%s => %g\n", opnames[opcode], S_DOUBLE(-4)));
         SIZE_AND_STACK(1, -2);
        
      --- 705,716 ----
         BINARY_FLOAT_OP(div, /)
        
         case opc_frem:
      ! S_FLOAT(-2) = DREM(S_FLOAT(-2), S_FLOAT(-1));
         TRACE(("\t%s => %g\n", opnames[opcode], S_FLOAT(-2)));
         SIZE_AND_STACK(1, -1);
        
         case opc_drem:
      ! SET_S_DOUBLE(-4, DREM(S_DOUBLE(-4), S_DOUBLE2(-2)));
         TRACE(("\t%s => %g\n", opnames[opcode], S_DOUBLE(-4)));
         SIZE_AND_STACK(1, -2);
        

      Attachments

        Activity

          People

            apalanissunw Anand Palaniswamy (Inactive)
            jbenoit Jonathan Benoit (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: