]> gitweb.factorcode.org Git - factor.git/blob - vm/contexts.hpp
Moved PRIMITIVE and PRIMITIVE_FORWARDs to primitives.[ch]pp
[factor.git] / vm / contexts.hpp
1 namespace factor
2 {
3
4 /* Assembly code makes assumptions about the layout of this struct:
5    - callstack_top field is 0
6    - callstack_bottom field is 1
7    - datastack field is 2
8    - retainstack field is 3 */
9 struct context {
10         /* C stack pointer on entry */
11         stack_frame *callstack_top;
12         stack_frame *callstack_bottom;
13
14         /* current datastack top pointer */
15         cell datastack;
16
17         /* current retain stack top pointer */
18         cell retainstack;
19
20         /* saved contents of ds register on entry to callback */
21         cell datastack_save;
22
23         /* saved contents of rs register on entry to callback */
24         cell retainstack_save;
25
26         /* memory region holding current datastack */
27         segment *datastack_region;
28
29         /* memory region holding current retain stack */
30         segment *retainstack_region;
31
32         /* saved userenv slots on entry to callback */
33         cell catchstack_save;
34         cell current_callback_save;
35
36         context *next;
37 };
38
39 #define ds_bot (stack_chain->datastack_region->start)
40 #define ds_top (stack_chain->datastack_region->end)
41 #define rs_bot (stack_chain->retainstack_region->start)
42 #define rs_top (stack_chain->retainstack_region->end)
43
44 DEFPUSHPOP(d,ds)
45 DEFPUSHPOP(r,rs)
46
47 struct factor_vm;
48 VM_C_API void nest_stacks(factor_vm *vm);
49 VM_C_API void unnest_stacks(factor_vm *vm);
50
51 }
52