This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
procedure optimization
- To: guile at sourceware dot cygnus dot com
- Subject: procedure optimization
- From: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Date: 25 Aug 2000 12:24:18 -0400
Hello,
My current compiler optimizes some procedures by using VM builtin
functions:
(define (foo x) (1+ x)) ->
%make-program .prog2
%savet foo
%load-unspecified
%return
.prog2
%loadl:0
inc ;; 1+ is replaced by a builtin function
%return
However, if the binding of `1+' is changed after the above program is
created, the program is no longer correct; I need to rebuild it.
One way to avoid this problem is to always use top level variables:
.prog2
%pushl:0
%loadt 1+ ;; 1+ is a top level variable
%tail-call 1 ;; use procedure call
This approach will slow down the program significantly.
How should I solve this? Maybe I need to add a compiler option that
allows this optimization. In that case, rebinding top level variables
should be probably prohibited...