Implements tail call analysis, as well as synthesis of procedures needed for portable tail-call elimination (refer to this document for how it works).
The apply helper procedure is synthesized during semantic analysis already, as sem is best equipped to create new global symbols. The synthesized procedures are attached to their originating ones via the misc slot.
Procs
proc genApply(c: PContext; s: PSym) {....raises: [Exception, ERecoverableError, KeyError], tags: [RootEffect, ReadDirEffect].}
-
Generates the 'apply' procedure for routine s. The apply procedure adapts s to the signature expected by the Continuation object.
Also makes sure that the tuple for storing the parameter doesn't exceed the maximum allowed space; an error is reported if it does.
Source Edit proc verifyTailCalls(g: ModuleGraph; owner: PSym; body: PNode) {. ...raises: [Exception, ERecoverableError], tags: [RootEffect].}
- Source Edit