factor/vm/cpu-x86.h

36 lines
1007 B
C
Raw Normal View History

2009-04-28 04:48:37 -04:00
#include <assert.h>
2007-10-05 17:30:10 -04:00
#define FRAME_RETURN_ADDRESS(frame) *(XT *)(frame_successor(frame) + 1)
2007-09-20 18:09:08 -04:00
INLINE void flush_icache(CELL start, CELL len) {}
2007-09-27 16:10:37 -04:00
F_FASTCALL void c_to_factor(CELL quot);
F_FASTCALL void throw_impl(CELL quot, F_STACK_FRAME *rewind_to);
F_FASTCALL void lazy_jit_compile(CELL quot);
2007-09-22 00:44:27 -04:00
void set_callstack(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy);
2009-04-28 04:48:37 -04:00
INLINE void check_call_site(CELL return_address)
2009-04-28 04:48:37 -04:00
{
/* An x86 CALL instruction looks like so:
|e8|..|..|..|..|
where the ... are a PC-relative jump address.
The return_address points to right after the
instruction. */
#ifdef FACTOR_DEBUG
assert(*(unsigned char *)(return_address - 5) == 0xe8);
#endif
}
INLINE CELL get_call_target(CELL return_address)
{
check_call_site(return_address);
2009-04-30 19:00:49 -04:00
return *(int *)(return_address - 4) + return_address;
}
INLINE void set_call_target(CELL return_address, CELL target)
{
check_call_site(return_address);
2009-04-30 19:00:49 -04:00
*(int *)(return_address - 4) = (target - return_address);
2009-04-28 04:48:37 -04:00
}