Skip to content
Snippets Groups Projects
  1. Jan 14, 2016
  2. Jan 13, 2016
    • Raymond Toy's avatar
      Restore the FPU state before exiting. · d7850f57
      Raymond Toy authored
      Put an unwind-protect around the error calls.  The cleanup form
      restores the floating-point modes from the sigcontext so that the mode
      is restored.  This is needed, I think, because we throw so that the
      signal handler doesn't return so the sigcontext isn't restored.  If we
      don't restore the fpu state, it's set to the default processor state.
      We want the default state when calling error.
      
      In this way, things like (* 1d300 1d300) signals an overflow, and when
      we throw to top-level, the floating-point modes are restored to their
      original values they had before.
      d7850f57
  3. Jan 10, 2016
    • Raymond Toy's avatar
      In WITH-FLOAT-TRAPS-*, remove the unused junk modifying the state. · d9763e90
      Raymond Toy authored
      We just want to return the original modes, so remove all the old
      commented out stuff that was modifying the original modes to some
      strange state.  This makes a lot more sense to me if
      WITH-FLOAT-TRAPS-* actually restored the modes exactly as they were
      before running the body.
      d9763e90
    • Raymond Toy's avatar
      Handle FPU exceptions better. · da2ff74d
      Raymond Toy authored
      In sigfpe-handler, don't modify the modes; just use whatever they
      are. (They should be the default values.)
      
      In with-float-traps-*, actually just restore the floating-point mode
      to the exact original mode instead of trying to mask things out.
      da2ff74d
    • Raymond Toy's avatar
      Handle FP exceptions better. · e63bc1e9
      Raymond Toy authored
      Don't restore the fpu state from the context in the interrupt handler
      code (interrupt_handle_now) because that just makes the fpu state the
      same as the sigcontext that received the exception.  I think this was
      done to reset the x87 fpu precision to 53-bit so that lisp can
      continue with default double-float rounding.  This isn't needed
      anymore since lisp doesn't use x87 anymore.
      
      In SIGFPE-HANDLER, don't modify the current fp state based on the
      state from the sigcontext.
      
      These two items cause the arithmetic-error exception printer to
      trigger inexact when printing out the args.  We add a few debugging
      prints for now so we can see what the FP state is in the handler.
      Remove them later.
      e63bc1e9
  4. Dec 31, 2015
  5. Dec 30, 2015
    • Raymond Toy's avatar
      WITH-FLOAT-TRAPS-ENABLED was incorrectly setting accrued exceptions. · edb5af9b
      Raymond Toy authored
      Fix issue #14.
      
      WITH-FLOAT-TRAPS-ENABLED was leaving the accrued (and current)
      exceptions unchanged, but it should have cleared out any values there
      that matched the exceptions to be enabled.  Without this, the next x87
      operation would signal an exception if an accrued exception matched
      an enabled exception.  This was the cause of issue #14.  (Note that
      for x87, the accrued exception is the same as current exception.)
      edb5af9b
    • Raymond Toy's avatar
      Add %SET-FLOATING-POINT-MODES and %GET-FLOATING-POINT-MODES functions. · b4771d76
      Raymond Toy authored
      To aid in debugging floating point modes, add two new functions:
      
      o %SET-FLOATING-POINT-MODES is like SET-FLOATING-POINT-MODES but
        applies the result to a specified mode value, returning the new mode
        value (as an integer).  This is useful for investigating different
        mode values without modifying the actual hardware mode.
      o %GET-FLOATING-POINT-MODES is like GET-FLOATING-POINT-MODES but uses
        an integer argument instead of the actual floating-point mode.
        Useful when used with %SET-FLOATING-POINT-MODE or on its own.
      b4771d76
  6. Dec 28, 2015
    • Raymond Toy's avatar
      Clean up with-float-traps macro. · 90b9651b
      Raymond Toy authored
       * Add some comments.
       * Change x86 (setf floating-point-modes) to accept (unsigned-byte
         32).
       * Remove unneeded x86 conditionalization on the byte size.
      90b9651b
  7. Dec 26, 2015
    • Raymond Toy's avatar
      Fix bug on sparc and clean up. · 38e8ce5c
      Raymond Toy authored
      On sparc and ppc (setf vm:floating-point-modes) takes an
      (unsigned-byte 32) arg, so adjust the ldb byte appopriately. 
      
      Clean up code by putting the docstring into the macro.
      38e8ce5c
  8. Dec 25, 2015
  9. Dec 24, 2015
  10. Nov 30, 2014
    • Raymond Toy's avatar
      Partially addresses ticket:91 by allowing the test suite to finish. · 70181ee7
      Raymond Toy authored
      The tests still fail (along with others), but the test suite will
      finish.
      
       * code/float-trap.lisp:
         * Update SET-FLOATING-POINT-MODES:
           * When we clear out bits in float-invalid-op-1-byte, clear out the
             float-invalid-op-2-byte.  Not necessary for this fix, but those
             bits signal other invalid operations from sqrt and such.
           * When clearing the exceptions, clear the sticky exceptions
             summary bit too.
         * Fix SIGFPE-HANDLER:
           * As above, clear out the bit in float-invalid-op-2-byte and the
             exceptions summary bit.
           * Only clear out the new exception bits, as done for SSE2.
           * Mask out the float-invalid-op-2-byte and the summary bit before
             setting the new modes.
      
       * compiler/ppc/parms.lisp
         * Define float-exceptions-summary-byte.
      
       * code/exports.lisp:
         * Export FLOAT-INVALID-OP-2-BYTE
      70181ee7
  11. Aug 23, 2014
  12. Aug 22, 2014
    • Raymond Toy's avatar
      On x86/darwin, we want and only need the sse2 mode bits. Darwin · 1626be46
      Raymond Toy authored
      doesn't use x87.
      1626be46
    • Raymond Toy's avatar
      Re-enable the x87 floating-point mode stuff. · 2c4a13af
      Raymond Toy authored
      On 32-bit linux, we can still get FP exceptions using x87 because
      32-bit linux can still use x87 instructions for arithmetic.  Because
      of this, we need to re-enable the support x87 floating-point modes,
      including getting and setting the modes and also extracting the modes
      from a sigcontext.
      
       * src/code/float-trap.lisp:
         * Put back support for getting and setting the x87 FP modes. 
       * src/compiler/x86/float.lisp:
         * Add comment on the layout of the status and control words for
           x87. 
       * src/lisp/Linux-os.c:
         * Put back support for getting the x87 (and sse2) FP modes. Needed
           in the sigfpe-handler in float-trap.lisp.
      
      Some of this needs to be cleaned up because we always require sse2
      now.
      2c4a13af
  13. Apr 29, 2014
  14. May 15, 2013
    • Raymond Toy's avatar
      Wrap exports in eval-when. · ba06f21f
      Raymond Toy authored
       src/compiler/generic/objdef.lisp::
       src/compiler/generic/utils.lisp:;
       src/compiler/generic/vm-macs.lisp::
       src/compiler/sparc/c-callback.lisp::
       src/compiler/sparc/parms.lisp::
      
        When export lost its compile-time effects and became a normal
        function, the exports in many files no longer took affect while
        compiling the file.  This change makes the compile-time effects
        happen as before in selected files. With this change, the sparc port
        can be cross-compiled from x86 again.
      
       src/tools/cross-scripts/cross-x86-sparc.lisp::
        Need to frob CHAR-BYTES, which is needed by BYTE-BASH-COPY. .
      ba06f21f
  15. Feb 02, 2013
  16. Feb 01, 2013
    • Raymond Toy's avatar
      Fix ticket:72 : SIGFPE with no exceptions enabled · 0174bfeb
      Raymond Toy authored
       code/float-trap.lisp::
        * In the default case, check FOP to see if it's defined.  This means
          it's a divide exception.
      
       code/x86-vm.lisp::
        * Also check to see if the offending instruction is a DIV or IDIV,
          which means we got an integer overflow.  Return the appropriate
          values in this case.
      0174bfeb
  17. May 25, 2012
  18. Jan 06, 2012
  19. Nov 04, 2011
  20. Oct 15, 2011
    • Raymond Toy's avatar
      Properly handle a denormal operand exception. This should get rid of · 7b6eb217
      Raymond Toy authored
      the occasional problem about SIGFPE's with no exceptions enabled.
      
      error.lisp:
      o Add floating-point-denormal-operand arithmetic error.
      
      exports.lisp:
      o Export the new arithmetic error type.
      
      float-trap.lisp:
      o Check the denormal trap bit and signal the appropriate error.
      
      release-20c.txt:
      o Update.
      7b6eb217
  21. Sep 25, 2011
  22. Dec 22, 2010
  23. Apr 20, 2010
  24. Apr 19, 2010
  25. Mar 19, 2010
  26. Jul 06, 2009
    • rtoy's avatar
      Fix precision bug. On x87 builds, the precision was set to 64 bits · d22e97ab
      rtoy authored
      instead of 53 bits.  This causes the incorrect result (found by Paul):
      
      (ffloor 1.1605184953130993d26 12622780800d0) ->
      
      9.193841782573768d15
      -8.05306368d8
      
      The correct result should have a remainder of zero.
      
      Force the precision to be 53 bits (double-float).
      d22e97ab
  27. Jan 05, 2009
    • rtoy's avatar
      Fix for handling arithmetic errors with x87. · 9edd3c4b
      rtoy authored
      Use bootstrap-2009-01-1.lisp to bootstrap this change.
      
      code/float-trap.lisp:
      o FLOATING-POINT-MODES for :X87 needs to massage the results into the
        expected format (SSE2 MXCSR order).
      o Update for changed VOP names too.
      
      compiler/x86/float.lisp:
      o Rename the floating-point-modes and set-floating-point-modes VOPS to
        x87-floating-point-modes and set-x87-floating-point-modes.  Change
        the translations accordingly too.
      
      compiler/x86/parms.lisp:
      o The float property bytes have been updated to match the SSE2 MXCSR
        register for both SSE2 and X87 builds because the code assumes SSE2
        format.
      
      lisp/Linux-os.c:
      o Don't OR in the SSE2 modes if we're not running an SSE2 build.
        Doing this can erroneously mask out exceptions because the Lisp code
        didn't set up the sse2 modes.  (This happens if you select the x87
        core on a chip that supports sse2.)
      
      lisp/globals.h:
      o Declare fpu_mode.
      
      lisp/lisp.c:
      o Set fpu_mode to be the mode determined from the core file.  Needed
        in Linux-os.c to process the SSE2 modes correctly with an x87 core
        on a sse2-capable chip.
      9edd3c4b
  28. Nov 12, 2008
  29. Jan 03, 2008
    • cshapiro's avatar
      Switch the FreeBSD port to use the common floating point trap handling · 9495c516
      cshapiro authored
      code.  Rather than introduce a new FreeBSD case to the x86 sigcontext
      member accessor routines, collapse all of the system specific routines
      down to a common set of routines.
      
      * code/debug-int.lisp - Disable some Darwin-specific code to debug
        NULL mcontext pointers.
      
      * code/float-trap.lisp - Remove ancient FreeBSD-specific code for
        handling floating point signals.
      
      * code/macros.lisp, code/sap.lisp, compiler/saptran.lisp - Include the
        SAP-REF-LONG setter by default on the x86.
      
      * code/x86-vm.lisp - Remove operating system specific sigcontext
        definitions and sigcontext accessors.  Define the alien sigcontext
        as a system area pointer.  Replace the sigcontext accessors with
        foreign function calls that mask the complexity of the underlying
        sigcontext member access.
      
      * compiler/x86/float.lisp - Unconditionally define STORE-LONG-FLOAT.
        This function is used by the %SET-SAP-REF-LONG VOP that underlies
        the SAP-REF-LONG setter.
      
      * compiler/x86/sap.lisp - Unconditionally define %SET-SAP-REF-LONG.
        In the case where there is not a distinct LONG-FLOAT type, admit
        DOUBLE-FLOAT values instead.  The x87 automatically widens values
        pushed onto stack.  This mirrors the behavior of the SAP-REF-LONG
        VOP.
      
      * lisp/Darwin-os.c, lisp/Linux-os.c - Define functions to access
        sigcontext members of interest to Lisp.  Delete the sc_reg function
        and replace its uses with os_sigcontext_reg which is more suitably
        typed.
      
      * lisp/FreeBSD-os.c - Define functions to access sigcontext members of
        interest to Lisp.  We need to be careful about the SSE and non-SSE
        cases for retrieving x87 registers from the saved machine state.
        Define a low-level SIGFPE handler to intercept floating point traps
        and restore the cleared status word bits based on the signal code.
        Get rid of sc_reg for the reasons noted above.
      
      * lisp/Darwin-os.h, lisp/FreeBSD-os.h - Declare the restore_fpu
        function and define a specialized RESTORE_FPU macro.  Remove the
        sc_reg prototype.
      
      * lisp/Linux-os.h - Remove the sc_reg prototype.
      
      * lisp/os.h - Add prototypes for the new os_sigcontext functions.
      
      * lisp/x86-lispregs.h - Redefine SC_REG and SC_PC to expand out to the
        new os_sigcontext functions.  Redfine SC_SP to expand out to SC_REG.
        Eliminate all platform-specific defintions of SC_PC and SC_SP.
      9495c516
  30. Nov 14, 2007
    • cshapiro's avatar
      * Change the way the x87 precision control is managed. While in Lisp, · 1440af76
      cshapiro authored
        the precision control will always be set to double precision.  For
        the duration of calls into C, the precision control will be set to
        the ABI default.  On Linux and Darwin this is double extended
        precision.  On all other platforms the precision control is left as
        double precision.  The specious FLOAT-ACCURACY declaration has been
        eliminated.
      
      * Shorten the precision control field to 24-bits by disposing of the
        unexamined high order eight bits of the status word.  This compacts
        the code generated around floating point mode changes and reduces
        consing.
      
      * Eliminate unnecessary uses of FLDENV and FSTENV.  We can substitute a
        use of FSTENV with FSTSW in FLOATING-POINT-MODES.  This reduces the
        number of cycles to access the relevant mode bits by a factor of
        thirty.  We cannot eliminate FLDENV in SET-FLOATING-POINT-MODES, but
        the common case does not require an update to the status word.  A
        fast path has been added to the VOP that improves the execution time
        by at least a factor of fifteen.
      
      * Remove the precision control option to SET-FLOATING-POINT-MODES.  It
        is the responsibility of the compiler to generating code that yields
        correctly rounded results in double and single precision.
      1440af76
  31. Jul 06, 2007
  32. Dec 02, 2006
    • rtoy's avatar
      code/float-trap.lisp: · 896812b8
      rtoy authored
      o Need to clear out the individual invalid operation bits when
        clearing the invalid exception bit.
      
      code/exports.lisp:
      compiler/ppc/parms.lisp:
      o Export FLOAT-INVALID-OP-1-BYTE.  (Needs a better name.)
      896812b8
  33. Nov 16, 2006
    • rtoy's avatar
      code/float-trap.lisp: · 6f968a58
      rtoy authored
      o Pass the modes to GET-FP-OPERANDS
      
      compiler/ppc/float.lisp:
      o If the destination register is the same as one of the source
        registers, an overflow or underflow exception will have replaced the
        source register with the result.  In that case, replace the source
        value with NIL to indicate we don't know.  (We could recompute the
        source from the result, but there would be a round-off error.)
      6f968a58
  34. Nov 14, 2006
    • rtoy's avatar
      Floating-point fixes for ppc. · a94b4291
      rtoy authored
      code/float-trap.lisp:
      o Set FP modes now.
      o Clear out sticky bits in SIGFPE handler
      
      code/ppc-vm.lisp:
      o Add (setf sigcontext-floating-point-modes) to set the FP mode.
      
      compiler/ppc/parms.lisp:
      o Add fields for various invalid operations bits.
      o Fix float-fast-bit
      a94b4291
Loading