]> gitweb.factorcode.org Git - factor.git/blob - vm/objects.hpp
Merge remote-tracking branch 'abeaumont/master'
[factor.git] / vm / objects.hpp
1 namespace factor
2 {
3
4 static const cell special_object_count = 70;
5
6 enum special_object {
7         OBJ_WALKER_HOOK = 3,       /* non-local exit hook, used by library only */
8         OBJ_CALLCC_1,              /* used to pass the value in callcc1 */
9
10         ERROR_HANDLER_QUOT = 5,    /* quotation called when VM throws an error */
11         OBJ_ERROR,                 /* a marker consed onto kernel errors */
12
13         OBJ_CELL_SIZE = 7,         /* sizeof(cell) */
14         OBJ_CPU,                   /* CPU architecture */
15         OBJ_OS,                    /* operating system name */
16
17         OBJ_ARGS = 10,             /* command line arguments */
18         OBJ_STDIN,                 /* stdin FILE* handle */
19         OBJ_STDOUT,                /* stdout FILE* handle */
20
21         OBJ_IMAGE = 13,            /* image path name */
22         OBJ_EXECUTABLE,            /* runtime executable path name */
23
24         OBJ_EMBEDDED = 15,         /* are we embedded in another app? */
25         OBJ_EVAL_CALLBACK,         /* used when Factor is embedded in a C app */
26         OBJ_YIELD_CALLBACK,        /* used when Factor is embedded in a C app */
27         OBJ_SLEEP_CALLBACK,        /* used when Factor is embedded in a C app */
28
29         OBJ_STARTUP_QUOT = 20,     /* startup quotation */
30         OBJ_GLOBAL,                /* global namespace */
31         OBJ_SHUTDOWN_QUOT,         /* shutdown quotation */
32
33         /* Quotation compilation in quotations.c */
34         JIT_PROLOG = 23,
35         JIT_PRIMITIVE_WORD,
36         JIT_PRIMITIVE,
37         JIT_WORD_JUMP,
38         JIT_WORD_CALL,
39         JIT_IF_WORD,
40         JIT_IF,
41         JIT_EPILOG,
42         JIT_RETURN,
43         JIT_PROFILING,
44         JIT_PUSH_IMMEDIATE,
45         JIT_DIP_WORD,
46         JIT_DIP,
47         JIT_2DIP_WORD,
48         JIT_2DIP,
49         JIT_3DIP_WORD,
50         JIT_3DIP,
51         JIT_EXECUTE,
52         JIT_DECLARE_WORD,
53
54         /* External entry points */
55         C_TO_FACTOR_WORD,
56         LAZY_JIT_COMPILE_WORD,
57         UNWIND_NATIVE_FRAMES_WORD,
58         GET_FPU_STATE_WORD,
59         SET_FPU_STATE_WORD,
60
61         /* Incremented on every modify-code-heap call; invalidates call( inline
62         caching */
63         REDEFINITION_COUNTER = 47,
64
65         /* Callback stub generation in callbacks.c */
66         CALLBACK_STUB = 48,
67         
68         /* Polymorphic inline cache generation in inline_cache.c */
69         PIC_LOAD = 49,
70         PIC_TAG,
71         PIC_TUPLE,
72         PIC_CHECK_TAG,
73         PIC_CHECK_TUPLE,
74         PIC_HIT,
75         PIC_MISS_WORD,
76         PIC_MISS_TAIL_WORD,
77
78         /* Megamorphic cache generation in dispatch.c */
79         MEGA_LOOKUP = 57,
80         MEGA_LOOKUP_WORD,
81         MEGA_MISS_WORD,
82
83         OBJ_UNDEFINED = 60,       /* default quotation for undefined words */
84
85         OBJ_STDERR = 61,          /* stderr FILE* handle */
86
87         OBJ_STAGE2 = 62,          /* have we bootstrapped? */
88
89         OBJ_CURRENT_THREAD = 63,
90
91         OBJ_THREADS = 64,
92         OBJ_RUN_QUEUE = 65,
93         OBJ_SLEEP_QUEUE = 66,
94
95         OBJ_VM_COMPILER = 67,     /* version string of the compiler we were built with */
96
97         OBJ_WAITING_CALLBACKS = 68,
98 };
99
100 /* save-image-and-exit discards special objects that are filled in on startup
101 anyway, to reduce image size */
102 #define OBJ_FIRST_SAVE OBJ_STARTUP_QUOT
103 #define OBJ_LAST_SAVE OBJ_STAGE2
104
105 inline static bool save_special_p(cell i)
106 {
107         return (i >= OBJ_FIRST_SAVE && i <= OBJ_LAST_SAVE);
108 }
109
110 template<typename Iterator> void object::each_slot(Iterator &iter)
111 {
112         cell scan = (cell)this;
113         cell payload_start = binary_payload_start();
114         cell end = scan + payload_start;
115
116         scan += sizeof(cell);
117
118         while(scan < end)
119         {
120                 iter((cell *)scan);
121                 scan += sizeof(cell);
122         }
123 }
124
125 }