4 // Context object count and identifiers must be kept in sync with:
5 // core/kernel/kernel.factor
7 static const cell context_object_count = 10;
16 static const cell stack_reserved = 1024;
20 // First 4 fields accessed directly by compiler. See basis/vm/vm.factor
22 /* Factor callstack pointers */
23 stack_frame *callstack_top;
24 stack_frame *callstack_bottom;
26 /* current datastack top pointer */
29 /* current retain stack top pointer */
32 /* C callstack pointer */
35 segment *datastack_seg;
36 segment *retainstack_seg;
37 segment *callstack_seg;
39 /* context-specific special objects, accessed by context-object and
40 set-context-object primitives */
41 cell context_objects[context_object_count];
43 context(cell datastack_size, cell retainstack_size, cell callstack_size);
46 void reset_datastack();
47 void reset_retainstack();
48 void reset_callstack();
49 void reset_context_objects();
52 void scrub_stacks(gc_info *info, cell index);
56 return *(cell *)datastack;
59 void replace(cell tagged)
61 *(cell *)datastack = tagged;
67 datastack -= sizeof(cell);
71 void push(cell tagged)
73 datastack += sizeof(cell);
77 stack_frame *bottom_frame()
79 return callstack_bottom - 1;
83 VM_C_API context *new_context(factor_vm *parent);
84 VM_C_API void delete_context(factor_vm *parent, context *old_context);
85 VM_C_API void reset_context(factor_vm *parent, context *ctx);
86 VM_C_API cell begin_callback(factor_vm *parent, cell quot);
87 VM_C_API void end_callback(factor_vm *parent);