Next: , Previous: , Up: compiler   [Index]


17.24 Inserting stack overflow checks

This compiler pass traverses all the function bodies and: if a ?body contains code that will cause further use of the Scheme stack, it transforms it as follows:

(seq
  (primopcall $stack-overflow-check ())
  ?body)

so that, right after entering the execution of a function, the call to the primitive operation $stack-overflow-check checks if the current Scheme stack is about to be exhausted. If a ?body does not make further use of the stack: its function execution is a “stack tail”.

The following bindings are exported by the library (vicare compiler).

Function: pass-insert-stack-overflow-check input

Perform code transformation traversing the whole hierarchy in input, which must be a codes struct representing recordised code; build and return a new codes struct.

Insert calls to the primitive operation $stack-overflow-check when appropriate.