3 #define CALLSTACK_BOTTOM(ctx) (ctx->callstack_seg->end - sizeof(cell) * 5) // omg
5 // void c_to_factor(cell quot);
6 // void lazy_jit_compile(cell quot);
8 // static const fixnum xt_tail_pic_offset = 4 + 1; // or 4 or whatever else...
12 inline static unsigned char call_site_opcode(cell return_address) {
13 return *(unsigned char*)(return_address - 5);
17 inline static void check_call_site(cell return_address) {
18 unsigned char opcode = call_site_opcode(return_address);
19 FACTOR_ASSERT(opcode == call_opcode || opcode == jmp_opcode);
20 (void)opcode; // suppress warning when compiling without assertions
24 inline static void* get_call_target(cell return_address) {
25 check_call_site(return_address);
26 return (void*)(*(int*)(return_address - 4) + return_address);
30 inline static void set_call_target(cell return_address, cell target) {
31 check_call_site(return_address);
32 *(int*)(return_address - 4) = (uint32_t)(target - return_address);
35 inline static bool tail_call_site_p(cell return_address) {
36 switch (call_site_opcode(return_address)) {
47 // inline static unsigned int fpu_status(unsigned int status) {
48 // unsigned int r = 0;
51 // r |= FP_TRAP_INVALID_OPERATION;
53 // r |= FP_TRAP_ZERO_DIVIDE;
55 // r |= FP_TRAP_OVERFLOW;
57 // r |= FP_TRAP_UNDERFLOW;
59 // r |= FP_TRAP_INEXACT;