]> gitweb.factorcode.org Git - factor.git/blob - native/run.h
all-tests now pass without out of memory errors
[factor.git] / native / run.h
1 #define USER_ENV 16
2
3 #define CARD_OFF_ENV   1 /* for compiling set-slot */
4 #define UNUSED_ENV     2
5 #define NAMESTACK_ENV  3 /* used by library only */
6 #define GLOBAL_ENV     4
7 #define BREAK_ENV      5
8 #define CATCHSTACK_ENV 6 /* used by library only */
9 #define CPU_ENV        7
10 #define BOOT_ENV       8
11 #define RUNQUEUE_ENV   9 /* used by library only */
12 #define ARGS_ENV       10
13 #define OS_ENV         11
14 #define ERROR_ENV      12 /* a marker consed onto kernel errors */
15 #define IN_ENV         13
16 #define OUT_ENV        14
17 #define GEN_ENV        15 /* set to GC_GENERATIONS constant */
18
19 /* TAGGED user environment data; see getenv/setenv prims */
20 DLLEXPORT CELL userenv[USER_ENV];
21
22 /* Profiling timer */
23 #ifndef WIN32
24 struct itimerval prof_timer;
25 #endif
26
27 /* Error handlers restore this */
28 #ifdef WIN32
29 jmp_buf toplevel;
30 #else
31 sigjmp_buf toplevel;
32 #endif
33
34 /* Call stack depth to start profile counter from */
35 /* This ensures that words in the user's interpreter do not count */
36 CELL profile_depth;
37
38 INLINE CELL dpop(void)
39 {
40         CELL value = get(ds);
41         ds -= CELLS;
42         return value;
43 }
44
45 INLINE void drepl(CELL top)
46 {
47         put(ds,top);
48 }
49
50 INLINE void dpush(CELL top)
51 {
52         ds += CELLS;
53         put(ds,top);
54 }
55
56 INLINE CELL dpeek(void)
57 {
58         return get(ds);
59 }
60
61 INLINE CELL dpeek2(void)
62 {
63         return get(ds - CELLS);
64 }
65
66 INLINE CELL cpop(void)
67 {
68         CELL value = get(cs);
69         cs -= CELLS;
70         return value;
71 }
72
73 INLINE void cpush(CELL top)
74 {
75         cs += CELLS;
76         put(cs,top);
77 }
78
79 INLINE void call(CELL quot)
80 {
81         /* tail call optimization */
82         if(callframe == F)
83                 /* put(cs - CELLS,executing) */;
84         else
85         {
86                 cpush(executing);
87                 cpush(callframe);
88         }
89
90         callframe = quot;
91 }
92
93 void run(void);
94 void platform_run(void);
95 void undefined(F_WORD* word);
96 void docol(F_WORD* word);
97 void dosym(F_WORD* word);
98 void primitive_execute(void);
99 void primitive_call(void);
100 void primitive_ifte(void);
101 void primitive_dispatch(void);
102 void primitive_getenv(void);
103 void primitive_setenv(void);