| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | namespace factor { | 
					
						
							| 
									
										
										
										
											2009-11-05 20:03:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-05 08:44:37 -04:00
										 |  |  | // Special object count and identifiers must be kept in sync with:
 | 
					
						
							|  |  |  | //   core/kernel/kernel.factor
 | 
					
						
							|  |  |  | //   basis/bootstrap/image/image.factor
 | 
					
						
							| 
									
										
										
										
											2011-11-02 15:54:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-09 15:31:13 -05:00
										 |  |  | static const cell special_object_count = 85; | 
					
						
							| 
									
										
										
										
											2009-11-05 20:03:51 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum special_object { | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_WALKER_HOOK = 3, // non-local exit hook, used by library only
 | 
					
						
							|  |  |  |   OBJ_CALLCC_1,        // used to pass the value in callcc1
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   ERROR_HANDLER_QUOT = 5, // quotation called when VM throws an error
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_CELL_SIZE = 7, // sizeof(cell)
 | 
					
						
							|  |  |  |   OBJ_CPU,           // CPU architecture
 | 
					
						
							|  |  |  |   OBJ_OS,            // operating system name
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_ARGS = 10, // command line arguments
 | 
					
						
							|  |  |  |   OBJ_STDIN,     // stdin FILE* handle
 | 
					
						
							|  |  |  |   OBJ_STDOUT,    // stdout FILE* handle
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_IMAGE = 13, // image path name
 | 
					
						
							|  |  |  |   OBJ_EXECUTABLE, // runtime executable path name
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_EMBEDDED = 15,  // are we embedded in another app?
 | 
					
						
							|  |  |  |   OBJ_EVAL_CALLBACK,  // used when Factor is embedded in a C app
 | 
					
						
							|  |  |  |   OBJ_YIELD_CALLBACK, // used when Factor is embedded in a C app
 | 
					
						
							|  |  |  |   OBJ_SLEEP_CALLBACK, // used when Factor is embedded in a C app
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_STARTUP_QUOT = 20, // startup quotation
 | 
					
						
							|  |  |  |   OBJ_GLOBAL,            // global namespace
 | 
					
						
							|  |  |  |   OBJ_SHUTDOWN_QUOT,     // shutdown quotation
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Quotation compilation in quotations.cpp
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   JIT_PROLOG = 23, | 
					
						
							|  |  |  |   JIT_PRIMITIVE_WORD, | 
					
						
							|  |  |  |   JIT_PRIMITIVE, | 
					
						
							|  |  |  |   JIT_WORD_JUMP, | 
					
						
							|  |  |  |   JIT_WORD_CALL, | 
					
						
							|  |  |  |   JIT_IF_WORD, | 
					
						
							|  |  |  |   JIT_IF, | 
					
						
							|  |  |  |   JIT_SAFEPOINT, | 
					
						
							|  |  |  |   JIT_EPILOG, | 
					
						
							|  |  |  |   JIT_RETURN, | 
					
						
							| 
									
										
										
										
											2015-08-11 21:22:24 -04:00
										 |  |  |   JIT_UNUSED, | 
					
						
							| 
									
										
										
										
											2016-06-07 08:54:23 -04:00
										 |  |  |   JIT_PUSH_LITERAL, | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   JIT_DIP_WORD, | 
					
						
							|  |  |  |   JIT_DIP, | 
					
						
							|  |  |  |   JIT_2DIP_WORD, | 
					
						
							|  |  |  |   JIT_2DIP, | 
					
						
							|  |  |  |   JIT_3DIP_WORD, | 
					
						
							|  |  |  |   JIT_3DIP, | 
					
						
							|  |  |  |   JIT_EXECUTE, | 
					
						
							|  |  |  |   JIT_DECLARE_WORD, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // External entry points. These are defined in the files in
 | 
					
						
							|  |  |  |   // bootstrap/assembler/
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   C_TO_FACTOR_WORD = 43, | 
					
						
							|  |  |  |   LAZY_JIT_COMPILE_WORD, | 
					
						
							|  |  |  |   UNWIND_NATIVE_FRAMES_WORD, | 
					
						
							|  |  |  |   GET_FPU_STATE_WORD, | 
					
						
							|  |  |  |   SET_FPU_STATE_WORD, | 
					
						
							|  |  |  |   SIGNAL_HANDLER_WORD, | 
					
						
							|  |  |  |   LEAF_SIGNAL_HANDLER_WORD, | 
					
						
							| 
									
										
										
										
											2015-08-30 06:44:33 -04:00
										 |  |  |   WIN_EXCEPTION_HANDLER, | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-23 03:44:17 -05:00
										 |  |  |   // Vector used by the sampling profiler to store collected call
 | 
					
						
							|  |  |  |   // frames.
 | 
					
						
							|  |  |  |   OBJ_SAMPLE_CALLSTACKS = 51, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Incremented on every modify-code-heap call; invalidates call(
 | 
					
						
							|  |  |  |   // inline caching
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   REDEFINITION_COUNTER = 52, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Callback stub generation in callbacks.cpp
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   CALLBACK_STUB = 53, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Polymorphic inline cache generation in inline_cache.cpp
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   PIC_LOAD = 54, | 
					
						
							|  |  |  |   PIC_TAG, | 
					
						
							|  |  |  |   PIC_TUPLE, | 
					
						
							|  |  |  |   PIC_CHECK_TAG, | 
					
						
							|  |  |  |   PIC_CHECK_TUPLE, | 
					
						
							|  |  |  |   PIC_HIT, | 
					
						
							|  |  |  |   PIC_MISS_WORD, | 
					
						
							|  |  |  |   PIC_MISS_TAIL_WORD, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Megamorphic cache generation in dispatch.cpp
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   MEGA_LOOKUP = 62, | 
					
						
							|  |  |  |   MEGA_LOOKUP_WORD, | 
					
						
							|  |  |  |   MEGA_MISS_WORD, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_UNDEFINED = 65, // default quotation for undefined words
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_STDERR = 66, // stderr FILE* handle
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_STAGE2 = 67, // have we bootstrapped?
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   OBJ_CURRENT_THREAD = 68, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   OBJ_THREADS = 69, | 
					
						
							|  |  |  |   OBJ_RUN_QUEUE = 70, | 
					
						
							|  |  |  |   OBJ_SLEEP_QUEUE = 71, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_VM_COMPILER = 72, // version string of the compiler we were built with
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   OBJ_WAITING_CALLBACKS = 73, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   OBJ_SIGNAL_PIPE = 74, // file descriptor for pipe used to communicate signals
 | 
					
						
							|  |  |  |                         //  only used on unix
 | 
					
						
							|  |  |  |   OBJ_VM_COMPILE_TIME = 75, // when the binary was built
 | 
					
						
							|  |  |  |   OBJ_VM_VERSION = 76, // factor version
 | 
					
						
							|  |  |  |   OBJ_VM_GIT_LABEL = 77, // git label (git describe --all --long)
 | 
					
						
							| 
									
										
										
										
											2015-12-09 15:31:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Canonical truth value. In Factor, 't'
 | 
					
						
							| 
									
										
										
										
											2015-12-09 15:31:13 -05:00
										 |  |  |   OBJ_CANONICAL_TRUE = 78, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Canonical bignums. These needs to be kept in the image in case
 | 
					
						
							|  |  |  |   // some heap objects refer to them.
 | 
					
						
							| 
									
										
										
										
											2015-12-09 15:31:13 -05:00
										 |  |  |   OBJ_BIGNUM_ZERO, | 
					
						
							|  |  |  |   OBJ_BIGNUM_POS_ONE, | 
					
						
							|  |  |  |   OBJ_BIGNUM_NEG_ONE = 81, | 
					
						
							| 
									
										
										
										
											2009-11-05 20:03:51 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  | // save-image-and-exit discards special objects that are filled in on startup
 | 
					
						
							|  |  |  | // anyway, to reduce image size
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | inline static bool save_special_p(cell i) { | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Need to fix the order here.
 | 
					
						
							| 
									
										
										
										
											2015-12-13 02:10:36 -05:00
										 |  |  |   return (i >= OBJ_STARTUP_QUOT && i <= LEAF_SIGNAL_HANDLER_WORD) || | 
					
						
							|  |  |  |       (i >= REDEFINITION_COUNTER && i <= OBJ_UNDEFINED) || | 
					
						
							|  |  |  |       i == OBJ_STAGE2 || | 
					
						
							|  |  |  |       (i >= OBJ_CANONICAL_TRUE && i <= OBJ_BIGNUM_NEG_ONE); | 
					
						
							| 
									
										
										
										
											2009-11-05 20:03:51 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  | template <typename Iterator> void object::each_slot(Iterator& iter) { | 
					
						
							| 
									
										
										
										
											2015-07-04 14:57:02 -04:00
										 |  |  |   cell* start = (cell*)this + 1; | 
					
						
							|  |  |  |   cell* end = start + slot_count(); | 
					
						
							| 
									
										
										
										
											2009-11-11 20:31:18 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-04 14:57:02 -04:00
										 |  |  |   while (start < end) { | 
					
						
							|  |  |  |     iter(start); | 
					
						
							|  |  |  |     start++; | 
					
						
							| 
									
										
										
										
											2013-05-11 22:17:38 -04:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2009-11-11 20:31:18 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-05 20:03:51 -05:00
										 |  |  | } |