Name: Anonymous 2012-02-28 16:56
Notation: a { b c }
calling a
entering a
calling b
calling c
leaving a
Example: a { b { c1{d{e}} c2{d{e@}} } c { d { c { d { c { f i{a} i{a@} b{c1} } f } f } f } f } c {df} }
Stack at first @: (e_locals)(d)(d_locals)(c2)(c2_locals)(b)(b2_locals)(a)(a_locals)
Stack at second @: top(a_locals)(i)(i_locals)(c)(c_locals)(d)(d_locals)(c)(c_locals)(d)(d_locals)(c)(c_locals)(a)(a_locals)
Problems: Stack grows even when local variables take up 0 bytes because return addresses take up space too.
Proposed solution: One returnstack with RLE for each function.
At first @:
b: (a)x1
c2: (b)x1
d: (c2)x1
e: (d)x1
At second @:
a: (i)x1
c: (d)x2 (a)x1
d: (c)x2
i: (c)x1
Result: Tailcall that's not at the tail.
Variation: The per-function stack can be fixed-sized. In that case old entries that fall off the per-function stack go into the main-stack.
Discuss.
calling a
entering a
calling b
calling c
leaving a
Example: a { b { c1{d{e}} c2{d{e@}} } c { d { c { d { c { f i{a} i{a@} b{c1} } f } f } f } f } c {df} }
Stack at first @: (e_locals)(d)(d_locals)(c2)(c2_locals)(b)(b2_locals)(a)(a_locals)
Stack at second @: top(a_locals)(i)(i_locals)(c)(c_locals)(d)(d_locals)(c)(c_locals)(d)(d_locals)(c)(c_locals)(a)(a_locals)
Problems: Stack grows even when local variables take up 0 bytes because return addresses take up space too.
Proposed solution: One returnstack with RLE for each function.
At first @:
b: (a)x1
c2: (b)x1
d: (c2)x1
e: (d)x1
At second @:
a: (i)x1
c: (d)x2 (a)x1
d: (c)x2
i: (c)x1
Result: Tailcall that's not at the tail.
Variation: The per-function stack can be fixed-sized. In that case old entries that fall off the per-function stack go into the main-stack.
Discuss.