Local function inlining works.
Charles Zhang <[email protected]> Fri, 13 Jul 2018 13:06:28 -0400
| Newsgroups | gmane.lisp.clisp.devel |
|---|---|
| Message-ID | <CAB=SSS=D7QrSf4RNPD9xc=aERutRWL4kQ1x=TwKAquRe8PDmNg@mail.gmail.com> |
Hello clisp, Bruno, Sam,
It is straightforward to do local inlining with the new compiler.
(There isn't policy to control this yet; its all or nothing).
A fancy example:
(cleavir-compile '(lambda ()
(let ((x 0))
(block a
(flet ((%f (y)
(flet ((%g (z)
(return-from a (+ x y z))))
(%g 10))
'bad))
(%f 14)
'badder)
'super-bad))))
CLEAVIR-CLISP> (disassemble *)
Disassembly of function NIL
(CONST 0) = 24
0 required arguments
0 optional arguments
No rest parameter
No keyword parameters
2 byte-code instructions:
0 (CONST 0) ; 24
1 (SKIP&RET 1)
And Sam's example from a long time ago:
(cleavir-compile '(lambda ()
(labels ((bar () t)) (bar))
(labels ((bar () nil)) (bar))))
Disassembly of function NIL
(CONST 0) = NIL
0 required arguments
0 optional arguments
No rest parameter
No keyword parameters
2 byte-code instructions:
0 (CONST 0) ; NIL
1 (SKIP&RET 1)
Local inlining triggers more optimizations and eliminates consing from
closure creation. So it is well worth it. This can also allow making
function-macro-let just an alias to labels. Local inlining can handle
inlining call-next-method et al.
Charles
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel