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