[Openmcl-cvs-notifications] r14805 - /trunk/source/lisp-kernel/x86-spentry64.s

gb at clozure.com gb at clozure.com
Fri May 20 04:59:00 CDT 2011


Author: gb
Date: Fri May 20 04:59:00 2011
New Revision: 14805

Log:
In _SPcallback, save the caller's mxcsr on and restore it from the
stack, not in tcr.foreign_mxcsr.  Different callers can legitimately
have different mxcsr values (as long as they save/restore the mxcsr
before changing its value), and we want callbacks to restore the caller's
value (not that of the most recent callback on the thread.)

callback_to_lisp() in the CCL kernel is an example of a C function that
calls into lisp with an atypical value in the mxcsr.  It's not clear
that that's a useful value, but callback_to_lisp() saves/restores the
mxcsr before setting it to that value. =


Reported problems which are symptoms of the mxcsr getting trashed in
the IDE seem to stem from the fact that callback_to_lisp() invokes a
callback with this atypical mxcsr value when unresolved EEPs are used
from callbacks.  We might want to change callback_to_lisp() to not do
that, but the problem is and always has been that callbacks don't
restore the mxcsr that they were called with.  The treatment of =

the mxcsr by _SPffcall (and the behavior of callback_to_lisp()) just
exposed that problem.

Modified:
    trunk/source/lisp-kernel/x86-spentry64.s

Modified: trunk/source/lisp-kernel/x86-spentry64.s
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/x86-spentry64.s (original)
+++ trunk/source/lisp-kernel/x86-spentry64.s Fri May 20 04:59:00 2011
@@ -4616,6 +4616,10 @@
 	__endif
 	__ifndef(`WINDOWS')
 	__endif
+        /* Save caller's mxcsr */
+        __(subq $16,%rsp)
+        __(stmxcsr (%rsp))
+        __(andb $~mxcsr_all_exceptions,(%rsp))
 	/* C NVRs   */
 	__(push %csave0)
 	__(push %csave1)
@@ -4684,8 +4688,6 @@
         __ifndef(`TCR_IN_GPR')
          __(movq 24(%rsp),%save3)
         __endif
-        __(stmxcsr rcontext(tcr.foreign_mxcsr))
-        __(andb $~mxcsr_all_exceptions,rcontext(tcr.foreign_mxcsr))
 	__(ldmxcsr rcontext(tcr.lisp_mxcsr))
 	__(movq $nrs.callbacks,%fname)
 	__(lea local_label(back_from_callback)(%rip),%ra0)
@@ -4716,6 +4718,8 @@
 	__(pop %csave2)
 	__(pop %csave1)
 	__(pop %csave0)
+        __(ldmxcsr (%rsp))
+        __(addq $16,%rsp)
 	__(movq -8(%rbp),%rax)
         __(movq -16(%rbp),%rdx)
 	__(movq -24(%rbp),%xmm0)



More information about the Openmcl-cvs-notifications mailing list