]> gitweb.factorcode.org Git - factor.git/blob - vm/cpu-arm.hpp
alien.c-types: not necessary to import `short` differently anymore
[factor.git] / vm / cpu-arm.hpp
1 namespace factor {
2
3 #define CALLSTACK_BOTTOM(ctx) (ctx->callstack_seg->end - sizeof(cell) * 5) // omg
4
5 // void c_to_factor(cell quot);
6 // void lazy_jit_compile(cell quot);
7
8 // static const fixnum xt_tail_pic_offset = 4 + 1; // or 4 or whatever else...
9
10
11 // omg
12 inline static unsigned char call_site_opcode(cell return_address) {
13   return *(unsigned char*)(return_address - 5);
14 }
15
16 // omg
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
21 }
22
23 // omg
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);
27 }
28
29 // omg
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);
33 }
34
35 inline static bool tail_call_site_p(cell return_address) {
36   switch (call_site_opcode(return_address)) {
37     case jmp_opcode:
38       return true;
39     case call_opcode:
40       return false;
41     default:
42       abort();
43       return false;
44   }
45 }
46
47 // inline static unsigned int fpu_status(unsigned int status) {
48 //   unsigned int r = 0;
49
50 //   if (status & 0x01)
51 //     r |= FP_TRAP_INVALID_OPERATION;
52 //   if (status & 0x04)
53 //     r |= FP_TRAP_ZERO_DIVIDE;
54 //   if (status & 0x08)
55 //     r |= FP_TRAP_OVERFLOW;
56 //   if (status & 0x10)
57 //     r |= FP_TRAP_UNDERFLOW;
58 //   if (status & 0x20)
59 //     r |= FP_TRAP_INEXACT;
60
61 //   return r;
62 // }
63
64 }