3 // Context object count and identifiers must be kept in sync with:
4 // core/kernel/kernel.factor
6 static const cell context_object_count = 10;
15 /* When the callstack fills up (e.g by to deep recursion), a callstack
16 overflow error is triggered. So before continuing executing on it
17 in general_error(), we chop off this many bytes to have some space
19 static const cell stack_reserved = 4096;
23 // First 4 fields accessed directly by compiler. See basis/vm/vm.factor
25 /* Factor callstack pointers */
27 cell callstack_bottom;
29 /* current datastack top pointer */
32 /* current retain stack top pointer */
35 /* C callstack pointer */
38 segment* datastack_seg;
39 segment* retainstack_seg;
40 segment* callstack_seg;
42 /* context-specific special objects, accessed by context-object and
43 set-context-object primitives */
44 cell context_objects[context_object_count];
46 context(cell datastack_size, cell retainstack_size, cell callstack_size);
49 void reset_datastack();
50 void reset_retainstack();
51 void reset_callstack();
52 void reset_context_objects();
55 void fill_stack_seg(cell top_ptr, segment* seg, cell pattern);
56 vm_error_type address_to_error(cell addr);
58 cell peek() { return *(cell*)datastack; }
60 void replace(cell tagged) { *(cell*)datastack = tagged; }
64 datastack -= sizeof(cell);
68 void push(cell tagged) {
69 datastack += sizeof(cell);
74 VM_C_API context* new_context(factor_vm* parent);
75 VM_C_API void delete_context(factor_vm* parent);
76 VM_C_API void reset_context(factor_vm* parent);
77 VM_C_API cell begin_callback(factor_vm* parent, cell quot);
78 VM_C_API void end_callback(factor_vm* parent);