This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: procedure optimization
- To: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Subject: Re: procedure optimization
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 25 Aug 2000 18:35:50 +0200
- Cc: guile at sourceware dot cygnus dot com
- Cc: djurfeldt at nada dot kth dot se
- References: <m3r97dnwb1.fsf@indy.STUDENT.CWRU.Edu>
- Reply-To: djurfeldt at nada dot kth dot se
Keisuke Nishida <kxn30@po.cwru.edu> writes:
> 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?
We'll allow for efficient code by letting most top-level bindings
imported from other modules be read-only. In the module system, there
also is hooks for reverting things to "uncompiled state" when bindings
change.