vm: fix indentation in Joe's changes
parent
0cadfcd7eb
commit
83c992173e
|
@ -67,15 +67,15 @@ inline static unsigned int fpu_status(unsigned int status)
|
|||
unsigned int r = 0;
|
||||
|
||||
if (status & 0x20000000)
|
||||
r |= FP_TRAP_INVALID_OPERATION;
|
||||
r |= FP_TRAP_INVALID_OPERATION;
|
||||
if (status & 0x10000000)
|
||||
r |= FP_TRAP_OVERFLOW;
|
||||
r |= FP_TRAP_OVERFLOW;
|
||||
if (status & 0x08000000)
|
||||
r |= FP_TRAP_UNDERFLOW;
|
||||
r |= FP_TRAP_UNDERFLOW;
|
||||
if (status & 0x04000000)
|
||||
r |= FP_TRAP_ZERO_DIVIDE;
|
||||
r |= FP_TRAP_ZERO_DIVIDE;
|
||||
if (status & 0x02000000)
|
||||
r |= FP_TRAP_INEXACT;
|
||||
r |= FP_TRAP_INEXACT;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -53,17 +53,17 @@ inline static bool tail_call_site_p(cell return_address)
|
|||
inline static unsigned int fpu_status(unsigned int status)
|
||||
{
|
||||
unsigned int r = 0;
|
||||
|
||||
|
||||
if (status & 0x01)
|
||||
r |= FP_TRAP_INVALID_OPERATION;
|
||||
r |= FP_TRAP_INVALID_OPERATION;
|
||||
if (status & 0x04)
|
||||
r |= FP_TRAP_ZERO_DIVIDE;
|
||||
r |= FP_TRAP_ZERO_DIVIDE;
|
||||
if (status & 0x08)
|
||||
r |= FP_TRAP_OVERFLOW;
|
||||
r |= FP_TRAP_OVERFLOW;
|
||||
if (status & 0x10)
|
||||
r |= FP_TRAP_UNDERFLOW;
|
||||
r |= FP_TRAP_UNDERFLOW;
|
||||
if (status & 0x20)
|
||||
r |= FP_TRAP_INEXACT;
|
||||
r |= FP_TRAP_INEXACT;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace factor
|
|||
representations and vice versa */
|
||||
|
||||
union double_bits_pun {
|
||||
double x;
|
||||
u64 y;
|
||||
double x;
|
||||
u64 y;
|
||||
};
|
||||
|
||||
inline static u64 double_bits(double x)
|
||||
|
@ -24,8 +24,8 @@ inline static double bits_double(u64 y)
|
|||
}
|
||||
|
||||
union float_bits_pun {
|
||||
float x;
|
||||
u32 y;
|
||||
float x;
|
||||
u32 y;
|
||||
};
|
||||
|
||||
inline static u32 float_bits(float x)
|
||||
|
|
|
@ -70,11 +70,11 @@ inline static cell align8(cell a)
|
|||
/* Constants used when floating-point trap exceptions are thrown */
|
||||
enum
|
||||
{
|
||||
FP_TRAP_INVALID_OPERATION = 1 << 0,
|
||||
FP_TRAP_OVERFLOW = 1 << 1,
|
||||
FP_TRAP_UNDERFLOW = 1 << 2,
|
||||
FP_TRAP_ZERO_DIVIDE = 1 << 3,
|
||||
FP_TRAP_INEXACT = 1 << 4,
|
||||
FP_TRAP_INVALID_OPERATION = 1 << 0,
|
||||
FP_TRAP_OVERFLOW = 1 << 1,
|
||||
FP_TRAP_UNDERFLOW = 1 << 2,
|
||||
FP_TRAP_ZERO_DIVIDE = 1 << 3,
|
||||
FP_TRAP_INEXACT = 1 << 4,
|
||||
};
|
||||
|
||||
inline static bool immediate_p(cell obj)
|
||||
|
|
|
@ -13,26 +13,33 @@ inline static void *ucontext_stack_pointer(void *uap)
|
|||
inline static unsigned int uap_fpu_status(void *uap)
|
||||
{
|
||||
ucontext_t *ucontext = (ucontext_t *)uap;
|
||||
if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387) {
|
||||
struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
return x87->sv_env.en_sw;
|
||||
} else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
|
||||
} else
|
||||
return 0;
|
||||
if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_387)
|
||||
{
|
||||
struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
return x87->sv_env.en_sw;
|
||||
}
|
||||
else if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
|
||||
{
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline static void uap_clear_fpu_status(void *uap)
|
||||
{
|
||||
ucontext_t *ucontext = (ucontext_t *)uap;
|
||||
if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_387) {
|
||||
struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
x87->sv_env.en_sw = 0;
|
||||
} else if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
xmm->sv_env.en_sw = 0;
|
||||
xmm->sv_env.en_mxcsr &= 0xffffffc0;
|
||||
if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_387)
|
||||
{
|
||||
struct save87 *x87 = (struct save87 *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
x87->sv_env.en_sw = 0;
|
||||
}
|
||||
else if (uap->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
|
||||
{
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
xmm->sv_env.en_sw = 0;
|
||||
xmm->sv_env.en_mxcsr &= 0xffffffc0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,20 +13,23 @@ inline static void *ucontext_stack_pointer(void *uap)
|
|||
inline static unsigned int uap_fpu_status(void *uap)
|
||||
{
|
||||
ucontext_t *ucontext = (ucontext_t *)uap;
|
||||
if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
|
||||
} else
|
||||
return 0;
|
||||
if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
|
||||
{
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline static void uap_clear_fpu_status(void *uap)
|
||||
{
|
||||
ucontext_t *ucontext = (ucontext_t *)uap;
|
||||
if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) {
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
xmm->sv_env.en_sw = 0;
|
||||
xmm->sv_env.en_mxcsr &= 0xffffffc0;
|
||||
if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM)
|
||||
{
|
||||
struct savexmm *xmm = (struct savexmm *)(&ucontext->uc_mcontext.mc_fpstate);
|
||||
xmm->sv_env.en_sw = 0;
|
||||
xmm->sv_env.en_mxcsr &= 0xffffffc0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,27 +54,27 @@ Modified for Factor by Slava Pestov */
|
|||
|
||||
inline static unsigned int mach_fpu_status(ppc_float_state_t *float_state)
|
||||
{
|
||||
return FPSCR(float_state);
|
||||
return FPSCR(float_state);
|
||||
}
|
||||
|
||||
inline static unsigned int uap_fpu_status(void *uap)
|
||||
{
|
||||
return mach_fpu_status(UAP_FS(uap));
|
||||
return mach_fpu_status(UAP_FS(uap));
|
||||
}
|
||||
|
||||
inline static cell fix_stack_pointer(cell sp)
|
||||
{
|
||||
return sp;
|
||||
return sp;
|
||||
}
|
||||
|
||||
inline static void mach_clear_fpu_status(ppc_float_state_t *float_state)
|
||||
{
|
||||
FPSCR(float_state) &= 0x0007ffff;
|
||||
FPSCR(float_state) &= 0x0007ffff;
|
||||
}
|
||||
|
||||
inline static void uap_clear_fpu_status(void *uap)
|
||||
{
|
||||
mach_clear_fpu_status(UAP_FS(uap));
|
||||
mach_clear_fpu_status(UAP_FS(uap));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,14 +54,14 @@ Modified for Factor by Slava Pestov */
|
|||
|
||||
inline static unsigned int mach_fpu_status(i386_float_state_t *float_state)
|
||||
{
|
||||
unsigned short x87sw;
|
||||
memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
|
||||
return MXCSR(float_state) | x87sw;
|
||||
unsigned short x87sw;
|
||||
memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
|
||||
return MXCSR(float_state) | x87sw;
|
||||
}
|
||||
|
||||
inline static unsigned int uap_fpu_status(void *uap)
|
||||
{
|
||||
return mach_fpu_status(UAP_FS(uap));
|
||||
return mach_fpu_status(UAP_FS(uap));
|
||||
}
|
||||
|
||||
inline static cell fix_stack_pointer(cell sp)
|
||||
|
@ -77,7 +77,7 @@ inline static void mach_clear_fpu_status(i386_float_state_t *float_state)
|
|||
|
||||
inline static void uap_clear_fpu_status(void *uap)
|
||||
{
|
||||
mach_clear_fpu_status(UAP_FS(uap));
|
||||
mach_clear_fpu_status(UAP_FS(uap));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,30 +52,30 @@ Modified for Factor by Slava Pestov and Daniel Ehrenberg */
|
|||
|
||||
inline static unsigned int mach_fpu_status(x86_float_state64_t *float_state)
|
||||
{
|
||||
unsigned short x87sw;
|
||||
memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
|
||||
return MXCSR(float_state) | x87sw;
|
||||
unsigned short x87sw;
|
||||
memcpy(&x87sw, &X87SW(float_state), sizeof(x87sw));
|
||||
return MXCSR(float_state) | x87sw;
|
||||
}
|
||||
|
||||
inline static unsigned int uap_fpu_status(void *uap)
|
||||
{
|
||||
return mach_fpu_status(UAP_FS(uap));
|
||||
return mach_fpu_status(UAP_FS(uap));
|
||||
}
|
||||
|
||||
inline static cell fix_stack_pointer(cell sp)
|
||||
{
|
||||
return ((sp + 8) & ~15) - 8;
|
||||
return ((sp + 8) & ~15) - 8;
|
||||
}
|
||||
|
||||
inline static void mach_clear_fpu_status(x86_float_state64_t *float_state)
|
||||
{
|
||||
MXCSR(float_state) &= 0xffffffc0;
|
||||
memset(&X87SW(float_state), 0, sizeof(X87SW(float_state)));
|
||||
MXCSR(float_state) &= 0xffffffc0;
|
||||
memset(&X87SW(float_state), 0, sizeof(X87SW(float_state)));
|
||||
}
|
||||
|
||||
inline static void uap_clear_fpu_status(void *uap)
|
||||
{
|
||||
mach_clear_fpu_status(UAP_FS(uap));
|
||||
mach_clear_fpu_status(UAP_FS(uap));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,4 @@ namespace factor
|
|||
|
||||
#define UAP_PROGRAM_COUNTER(uap) _UC_MACHINE_PC((ucontext_t *)uap)
|
||||
|
||||
#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
|
||||
|
||||
}
|
||||
|
|
|
@ -21,40 +21,39 @@ FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
|
|||
else
|
||||
signal_callstack_top = NULL;
|
||||
|
||||
switch (e->ExceptionCode) {
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
switch (e->ExceptionCode)
|
||||
{
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
signal_fault_addr = e->ExceptionInformation[1];
|
||||
c->EIP = (cell)memory_signal_handler_impl;
|
||||
break;
|
||||
break;
|
||||
|
||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||
case EXCEPTION_FLT_OVERFLOW:
|
||||
case EXCEPTION_FLT_STACK_CHECK:
|
||||
case EXCEPTION_FLT_UNDERFLOW:
|
||||
/* XXX MxCsr is not available in CONTEXT structure on x86.32 */
|
||||
signal_fpu_status = c->FloatSave.StatusWord;
|
||||
c->FloatSave.StatusWord = 0;
|
||||
c->EIP = (cell)fp_signal_handler_impl;
|
||||
break;
|
||||
|
||||
/* If the Widcomm bluetooth stack is installed, the BTTray.exe process
|
||||
injects code into running programs. For some reason this results in
|
||||
random SEH exceptions with this (undocumented) exception code being
|
||||
raised. The workaround seems to be ignoring this altogether, since that
|
||||
is what happens if SEH is not enabled. Don't really have any idea what
|
||||
this exception means. */
|
||||
case 0x40010006:
|
||||
break;
|
||||
|
||||
default:
|
||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||
case EXCEPTION_FLT_OVERFLOW:
|
||||
case EXCEPTION_FLT_STACK_CHECK:
|
||||
case EXCEPTION_FLT_UNDERFLOW:
|
||||
/* XXX MxCsr is not available in CONTEXT structure on x86.32 */
|
||||
signal_fpu_status = c->FloatSave.StatusWord;
|
||||
c->FloatSave.StatusWord = 0;
|
||||
c->EIP = (cell)fp_signal_handler_impl;
|
||||
break;
|
||||
case 0x40010006:
|
||||
/* If the Widcomm bluetooth stack is installed, the BTTray.exe
|
||||
process injects code into running programs. For some reason this
|
||||
results in random SEH exceptions with this (undocumented)
|
||||
exception code being raised. The workaround seems to be ignoring
|
||||
this altogether, since that is what happens if SEH is not
|
||||
enabled. Don't really have any idea what this exception means. */
|
||||
break;
|
||||
default:
|
||||
signal_number = e->ExceptionCode;
|
||||
c->EIP = (cell)misc_signal_handler_impl;
|
||||
break;
|
||||
}
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
break;
|
||||
}
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
|
||||
void c_to_factor_toplevel(cell quot)
|
||||
|
|
Loading…
Reference in New Issue