2009-12-28

translating to stackless c

9.9: adda/translating to stackless c:

. translating to stackless c means that adda is in control of the user stack,
except that trusted code can be called from c.

. untrusted functions are defined as labeled sections of main,
. for each call:
( stack arg
, goto label
, have macros translate each symbol into stack/rec/trailer ptr expression
, end of routine has a return routine
that unloads arg and goes to stacked return address .
)
. can c do all of that?
need to store address of a label .

label: ptr = &label . test .

. stackless could thwart the c`compiler's usual optimizations,
so adda may balance control with efficiency
by just putting a limit on recursion depth .

. to watch and limit recursion depth,
adda builds a call tree,
and if there are any cycles in the tree
(indicating direct or indirect recursion
-- potentially endless stack usage)
then routines in the cycling groups
open by incr'ing a global"[call depth],
and close by decr'ing it .
. the open or close must also test whether
[call depth] > [max depth];
if so, then it returns .