factor/vmpp/cpu-x86.hpp

46 lines
1.3 KiB
C++
Executable File

#include <assert.h>
#define FRAME_RETURN_ADDRESS(frame) *(XT *)(frame_successor(frame) + 1)
INLINE void flush_icache(CELL start, CELL len) {}
INLINE void check_call_site(CELL return_address)
{
/* 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);
return *(int *)(return_address - 4) + return_address;
}
INLINE void set_call_target(CELL return_address, CELL target)
{
check_call_site(return_address);
*(int *)(return_address - 4) = (target - return_address);
}
/* Defined in assembly */
extern "C" void primitive_fixnum_add(void);
extern "C" void primitive_fixnum_subtract(void);
extern "C" void primitive_fixnum_multiply(void);
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);
extern "C" void set_callstack(F_STACK_FRAME *to,
F_STACK_FRAME *from,
CELL length,
void *(*memcpy)(void*,const void*, size_t));
extern "C" void primitive_inline_cache_miss(void);