factor/vm/cpu-x86.32.S

105 lines
2.4 KiB
ArmAsm
Raw Normal View History

2007-09-21 22:56:01 -04:00
#include "asm.h"
#define ARG0 %eax
#define ARG1 %edx
#define STACK_REG %esp
2007-09-22 00:44:27 -04:00
#define DS_REG %esi
2007-09-26 00:34:37 -04:00
#define RETURN_REG %eax
2007-09-21 22:56:01 -04:00
#define NV_TEMP_REG %ebx
2008-11-08 21:32:23 -05:00
#define ARITH_TEMP_1 %ebp
#define ARITH_TEMP_2 %ebx
#define DIV_RESULT %eax
2007-09-21 22:56:01 -04:00
#define CELL_SIZE 4
2008-11-07 21:33:32 -05:00
#define STACK_PADDING 12
2007-09-21 22:56:01 -04:00
#define PUSH_NONVOLATILE \
2007-09-22 00:44:27 -04:00
push %ebx ; \
2008-11-08 21:32:23 -05:00
push %ebp ; \
2007-09-21 22:56:01 -04:00
push %ebp
#define POP_NONVOLATILE \
2008-11-08 21:32:23 -05:00
pop %ebp ; \
2007-09-22 00:44:27 -04:00
pop %ebp ; \
2007-09-21 22:56:01 -04:00
pop %ebx
#define QUOT_XT_OFFSET 12
2007-09-21 22:56:01 -04:00
2007-09-22 02:28:49 -04:00
/* We pass a function pointer to memcpy to work around a Mac OS X
2007-09-21 22:56:01 -04:00
ABI limitation which would otherwise require us to do a bizzaro PC-relative
trampoline to retrieve the function address */
DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
mov 4(%esp),%ebp /* to */
mov 8(%esp),%edx /* from */
mov 12(%esp),%ecx /* length */
mov 16(%esp),%eax /* memcpy */
sub %ecx,%ebp /* compute new stack pointer */
mov %ebp,%esp
push %ecx /* pass length */
push %edx /* pass src */
push %ebp /* pass dst */
call *%eax /* call memcpy */
add $12,%esp /* pop args from the stack */
ret /* return _with new stack_ */
DEF(long long,read_timestamp_counter,(void)):
rdtsc
ret
2009-05-07 13:33:31 -04:00
DEF(void,primitive_inline_cache_miss,(void)):
mov (%esp),%ebx
2009-05-07 13:33:31 -04:00
DEF(void,primitive_inline_cache_miss_tail,(void)):
sub $8,%esp
push %ebx
call MANGLE(inline_cache_miss)
add $12,%esp
2009-04-29 00:05:18 -04:00
jmp *%eax
DEF(void,get_sse_env,(void*)):
2009-09-14 04:14:48 -04:00
movl 4(%esp), %eax
stmxcsr (%eax)
ret
DEF(void,set_sse_env,(const void*)):
2009-09-14 04:14:48 -04:00
movl 4(%esp), %eax
ldmxcsr (%eax)
ret
DEF(void,get_x87_env,(void*)):
2009-09-14 04:14:48 -04:00
movl 4(%esp), %eax
fnstsw (%eax)
fnstcw 2(%eax)
ret
DEF(void,set_x87_env,(const void*)):
2009-09-14 04:14:48 -04:00
movl 4(%esp), %eax
fnclex
fldcw 2(%eax)
ret
2009-08-19 14:40:09 -04:00
DEF(F_FASTCALL void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to, void *vm)):
mov CELL_SIZE(STACK_REG),NV_TEMP_REG /* stash vm ptr */
/* clear x87 stack, but preserve rounding mode and exception flags */
sub $2,STACK_REG
fnstcw (STACK_REG)
fninit
fldcw (STACK_REG)
/* rewind_to */
mov ARG1,STACK_REG
mov NV_TEMP_REG,ARG1
jmp *QUOT_XT_OFFSET(ARG0)
2007-09-21 22:56:01 -04:00
#include "cpu-x86.S"
#ifdef WINDOWS
.section .drectve
2009-05-31 16:16:40 -04:00
.ascii " -export:read_timestamp_counter"
.ascii " -export:get_sse_env"
.ascii " -export:set_sse_env"
.ascii " -export:get_x87_env"
.ascii " -export:set_x87_env"
#endif