3 // Special object count and identifiers must be kept in sync with:
4 // core/kernel/kernel.factor
5 // basis/bootstrap/image/image.factor
7 static const cell special_object_count = 85;
10 OBJ_WALKER_HOOK = 3, // non-local exit hook, used by library only
11 OBJ_CALLCC_1, // used to pass the value in callcc1
13 ERROR_HANDLER_QUOT = 5, // quotation called when VM throws an error
15 OBJ_CELL_SIZE = 7, // sizeof(cell)
16 OBJ_CPU, // CPU architecture
17 OBJ_OS, // operating system name
19 OBJ_ARGS = 10, // command line arguments
20 OBJ_STDIN, // stdin FILE* handle
21 OBJ_STDOUT, // stdout FILE* handle
23 OBJ_IMAGE = 13, // image path name
24 OBJ_EXECUTABLE, // runtime executable path name
26 OBJ_EMBEDDED = 15, // are we embedded in another app?
27 OBJ_EVAL_CALLBACK, // used when Factor is embedded in a C app
28 OBJ_YIELD_CALLBACK, // used when Factor is embedded in a C app
29 OBJ_SLEEP_CALLBACK, // used when Factor is embedded in a C app
31 OBJ_STARTUP_QUOT = 20, // startup quotation
32 OBJ_GLOBAL, // global namespace
33 OBJ_SHUTDOWN_QUOT, // shutdown quotation
35 // Quotation compilation in quotations.cpp
57 // External entry points. These are defined in the files in
58 // bootstrap/assembler/
59 C_TO_FACTOR_WORD = 43,
60 LAZY_JIT_COMPILE_WORD,
61 UNWIND_NATIVE_FRAMES_WORD,
65 LEAF_SIGNAL_HANDLER_WORD,
66 WIN_EXCEPTION_HANDLER,
68 // Vector used by the sampling profiler to store collected call
70 OBJ_SAMPLE_CALLSTACKS = 51,
72 // Incremented on every modify-code-heap call; invalidates call(
74 REDEFINITION_COUNTER = 52,
76 // Callback stub generation in callbacks.cpp
79 // Polymorphic inline cache generation in inline_cache.cpp
89 // Megamorphic cache generation in dispatch.cpp
94 OBJ_UNDEFINED = 65, // default quotation for undefined words
96 OBJ_STDERR = 66, // stderr FILE* handle
98 OBJ_STAGE2 = 67, // have we bootstrapped?
100 OBJ_CURRENT_THREAD = 68,
104 OBJ_SLEEP_QUEUE = 71,
106 OBJ_VM_COMPILER = 72, // version string of the compiler we were built with
108 OBJ_WAITING_CALLBACKS = 73,
110 OBJ_SIGNAL_PIPE = 74, // file descriptor for pipe used to communicate signals
112 OBJ_VM_COMPILE_TIME = 75, // when the binary was built
113 OBJ_VM_VERSION = 76, // factor version
114 OBJ_VM_GIT_LABEL = 77, // git label (git describe --all --long)
116 // Canonical truth value. In Factor, 't'
117 OBJ_CANONICAL_TRUE = 78,
119 // Canonical bignums. These needs to be kept in the image in case
120 // some heap objects refer to them.
123 OBJ_BIGNUM_NEG_ONE = 81,
126 // save-image-and-exit discards special objects that are filled in on startup
127 // anyway, to reduce image size
128 inline static bool save_special_p(cell i) {
129 // Need to fix the order here.
130 return (i >= OBJ_STARTUP_QUOT && i <= LEAF_SIGNAL_HANDLER_WORD) ||
131 (i >= REDEFINITION_COUNTER && i <= OBJ_UNDEFINED) ||
133 (i >= OBJ_CANONICAL_TRUE && i <= OBJ_BIGNUM_NEG_ONE);
136 template <typename Iterator> void object::each_slot(Iterator& iter) {
137 cell* start = (cell*)this + 1;
138 cell* end = start + slot_count();
140 while (start < end) {