- Timestamp:
- Jul 7, 2010, 12:59:31 PM (14 years ago)
- Location:
- branches/rme-fpe/lisp-kernel
- Files:
-
- 3 edited
-
x86-exceptions.c (modified) (4 diffs)
-
x86-spentry32.s (modified) (4 diffs)
-
x86-spentry64.s (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/rme-fpe/lisp-kernel/x86-exceptions.c
r13882 r13937 942 942 943 943 Boolean 944 handle_floating_point_exception(TCR *tcr, ExceptionInformation *xp, siginfo_t *info )944 handle_floating_point_exception(TCR *tcr, ExceptionInformation *xp, siginfo_t *info, int old_valence) 945 945 { 946 946 int code,skip; … … 954 954 #endif 955 955 956 if ((fulltag_of(cmain) == fulltag_misc) && 957 (header_subtag(header_of(cmain)) == subtag_macptr)) { 956 if (old_valence == TCR_STATE_FOREIGN) { 957 /* We got a floating point exception in foreign code. Set a flag 958 in the TCR to indicate this, and resume with FP exceptions 959 disabled. .SPffcall will check the flag, and if it's set, 960 will save the FP status and re-enable exceptions. */ 961 962 /* 963 * We might get multiple foreign FP exceptions, so take care 964 * to preseve lisp's original MXCSR. 965 */ 966 if (! (tcr->flags & (1<<TCR_FLAG_BIT_FOREIGN_FPE))) { 967 tcr->lisp_mxcsr = xpMXCSR(xp) & ~MXCSR_STATUS_MASK; 968 tcr->flags |= (1<<TCR_FLAG_BIT_FOREIGN_FPE); 969 } 970 xpMXCSR(xp) &= ~MXCSR_STATUS_MASK; 971 xpMXCSR(xp) |= MXCSR_CONTROL_MASK; 972 return true; 973 } else if ((fulltag_of(cmain) == fulltag_misc) && 974 (header_subtag(header_of(cmain)) == subtag_macptr)) { 958 975 xcf = create_exception_callback_frame(xp, tcr); 959 976 skip = callback_to_lisp(tcr, cmain, xp, xcf, SIGFPE, code, 0, 0); … … 1078 1095 pc program_counter = (pc)xpPC(context); 1079 1096 1080 if ( old_valence != TCR_STATE_LISP) {1097 if ((old_valence != TCR_STATE_LISP) && signum != SIGFPE) { 1081 1098 return false; 1082 1099 } … … 1237 1254 #endif 1238 1255 1239 return handle_floating_point_exception(tcr, context, info );1256 return handle_floating_point_exception(tcr, context, info, old_valence); 1240 1257 1241 1258 #if SIGBUS != SIGNUM_FOR_INTN_TRAP -
branches/rme-fpe/lisp-kernel/x86-spentry32.s
r13561 r13937 4184 4184 __(popl rcontext(tcr.save_eflags)) 4185 4185 __(cld) 4186 __(stmxcsr rcontext(tcr.lisp_mxcsr))4187 4186 __(emms) 4188 __(ldmxcsr rcontext(tcr.foreign_mxcsr))4189 4187 __(movl (%esp),%ebp) 4190 4188 LocalLabelPrefix`'ffcall_setup: … … 4215 4213 __(clr %fn) 4216 4214 __(pxor %fpzero,%fpzero) 4215 /* If we got a floating-point exception during the ff-call, 4216 our handler will have set a flag, preserved lisp's MXCSR, 4217 and resumed execution with fp exceptions masked. */ 4218 __(btrq $TCR_FLAG_BIT_FOREIGN_FPE,rcontext(tcr.flags)) 4219 __(jnc 1f) 4217 4220 __(cmpb $0,C(bogus_fp_exceptions)) 4218 4221 __(je 0f) … … 4222 4225 __ifdef(`SSE2_MATH_LIB') 4223 4226 __(stmxcsr rcontext(tcr.ffi_exception)) 4227 __(ldmxcsr rcontext(tcr.lisp_mxcsr)) /* preserved by the handler */ 4224 4228 __else 4225 4229 __(fnstsw rcontext(tcr.ffi_exception)) … … 4235 4239 __(pop %arg_y) 4236 4240 __(pop %temp1) 4237 __(ldmxcsr rcontext(tcr.lisp_mxcsr))4238 4241 __(check_pending_interrupt(%temp0)) 4239 4242 __(pop %temp0) -
branches/rme-fpe/lisp-kernel/x86-spentry64.s
r13561 r13937 3991 3991 __(movq $TCR_STATE_FOREIGN,rcontext(tcr.valence)) 3992 3992 __(movq rcontext(tcr.foreign_sp),%rsp) 3993 __(stmxcsr rcontext(tcr.lisp_mxcsr))3994 3993 __(emms) 3995 __(ldmxcsr rcontext(tcr.foreign_mxcsr))3996 3994 __(movq (%rsp),%rbp) 3997 3995 __ifdef(`DARWIN_GS_HACK') … … 4070 4068 __(clr %fn) 4071 4069 __(pxor %fpzero,%fpzero) 4070 4071 /* If we got a floating-point exception during the ff-call, 4072 our handler will have set a flag, preserved lisp's MXCSR, 4073 and resumed execution with fp exceptions masked. */ 4074 __(btrq $TCR_FLAG_BIT_FOREIGN_FPE,rcontext(tcr.flags)) 4075 __(jnc 1f) 4072 4076 __(cmpb $0,C(bogus_fp_exceptions)(%rip)) 4073 4077 __(je 0f) … … 4075 4079 __(jmp 1f) 4076 4080 0: __(stmxcsr rcontext(tcr.ffi_exception)) 4081 __(ldmxcsr rcontext(tcr.lisp_mxcsr)) /* preserved by the handler */ 4077 4082 1: __(movq rcontext(tcr.save_vsp),%rsp) 4078 4083 __(movq rcontext(tcr.save_rbp),%rbp) … … 4090 4095 __(pop %temp2) 4091 4096 __(pop %temp1) 4092 __(ldmxcsr rcontext(tcr.lisp_mxcsr))4093 4097 __(check_pending_interrupt(%temp0)) 4094 4098 __(pop %temp0) … … 4211 4215 __(movq $TCR_STATE_FOREIGN,rcontext(tcr.valence)) 4212 4216 __(movq rcontext(tcr.foreign_sp),%rsp) 4213 __(stmxcsr rcontext(tcr.lisp_mxcsr))4214 4217 __(emms) 4215 __(ldmxcsr rcontext(tcr.foreign_mxcsr))4216 4218 __(movq (%rsp),%rbp) 4217 4219 __ifdef(`DARWIN_GS_HACK') … … 4290 4292 __(clr %fn) 4291 4293 __(pxor %fpzero,%fpzero) 4294 /* Check for fp exceptions as in .SPffcall, above. */ 4295 __(btrq $TCR_FLAG_BIT_FOREIGN_FPE,rcontext(tcr.flags)) 4296 __(jnc 1f) 4292 4297 __(cmpb $0,C(bogus_fp_exceptions)(%rip)) 4293 4298 __(je 0f) … … 4295 4300 __(jmp 1f) 4296 4301 0: __(stmxcsr rcontext(tcr.ffi_exception)) 4302 __(ldmxcsr rcontext(tcr.lisp_mxcsr)) 4297 4303 1: __(movq rcontext(tcr.save_vsp),%rsp) 4298 4304 __(movq rcontext(tcr.save_rbp),%rbp) … … 4310 4316 __(pop %temp2) 4311 4317 __(pop %temp1) 4312 __(ldmxcsr rcontext(tcr.lisp_mxcsr))4313 4318 __(check_pending_interrupt(%temp0)) 4314 4319 __(pop %temp0)
Note:
See TracChangeset
for help on using the changeset viewer.
