value push_stack_fragment(value ekfragment) { const mlsize_t size = Wosize_val(ekfragment); value *p, *new_sp, *new_trapsp; /* print_gl_stack("push_stack_fragment"); print_exc_trace("push_stack_fragment: before"); */ myassert(caml_extern_sp >= caml_stack_low); myassert(caml_extern_sp <= caml_stack_high); myassert(caml_trapsp < caml_stack_high); myassert(caml_trapsp > caml_extern_sp); if( caml_extern_sp - size < caml_stack_threshold ) { print_gl_stack("push_stack_fregment: no stack space! Have I forgotten" " to call ensure_stack_space?"); myassert(0); #if 0 /* Old way, pre 3.11: */ print_gl_stack("Reallocating OCaml stack!"); caml_realloc_stack(Stack_threshold / sizeof(value)); */ return push_stack_fragment(ekfragment); /* Redo */ #endif }
void caml_maybe_expand_stack (value* gc_regs) { CAMLparamN(gc_regs, 5); uintnat stack_available; Assert(Tag_val(caml_current_stack) == Stack_tag); stack_available = Bosize_val(caml_current_stack) - (Stack_sp(caml_current_stack) + Stack_ctx_words * sizeof(value)); if (stack_available < 2 * Stack_threshold) caml_realloc_stack (); CAMLreturn0; }
CAMLprim value caml_ensure_stack_capacity(value required_space) { asize_t req = Long_val(required_space); if (caml_extern_sp - req < caml_stack_low) caml_realloc_stack(req); return Val_unit; }