factor/vm/cpu-x86.hpp

40 lines
1.1 KiB
C++
Raw Normal View History

2009-05-02 05:04:19 -04:00
#include <assert.h>
#define FRAME_RETURN_ADDRESS(frame) *(XT *)(frame_successor(frame) + 1)
inline static void flush_icache(CELL start, CELL len) {}
2009-05-02 05:04:19 -04:00
inline static void check_call_site(CELL return_address)
2009-05-02 05:04:19 -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 static CELL get_call_target(CELL return_address)
2009-05-02 05:04:19 -04:00
{
check_call_site(return_address);
return *(int *)(return_address - 4) + return_address;
}
inline static void set_call_target(CELL return_address, CELL target)
2009-05-02 05:04:19 -04:00
{
check_call_site(return_address);
*(int *)(return_address - 4) = (target - return_address);
}
/* Defined in assembly */
VM_ASM_API void c_to_factor(CELL quot);
VM_ASM_API void throw_impl(CELL quot, F_STACK_FRAME *rewind_to);
VM_ASM_API void lazy_jit_compile(CELL quot);
2009-05-02 05:04:19 -04:00
VM_C_API void set_callstack(F_STACK_FRAME *to,
2009-05-02 05:04:19 -04:00
F_STACK_FRAME *from,
CELL length,
void *(*memcpy)(void*,const void*, size_t));