mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
slight optimization in transform-record, note in optimize*
* module/language/ghil/compile-glil.scm (optimize*): Add a note. * module/system/base/syntax.scm (transform-record): Access the common slots once at the beginning. Cuts down on the number of toplevel refs needed by the generated code.
This commit is contained in:
parent
89522052e2
commit
3ca8401113
2 changed files with 9 additions and 3 deletions
|
@ -45,6 +45,10 @@
|
|||
(ghil-env-add! parent-env v))
|
||||
(ghil-env-variables env))))
|
||||
|
||||
;; The premise of this, unused, approach to optimization is that you can
|
||||
;; determine the environment of a variable lexically, because they have
|
||||
;; been alpha-renamed. It makes the transformations *much* easier.
|
||||
;; Unfortunately it doesn't work yet.
|
||||
(define (optimize* x)
|
||||
(transform-record (<ghil> env loc) x
|
||||
((quasiquote exp)
|
||||
|
|
|
@ -272,13 +272,15 @@
|
|||
(let ((record-type (symbol-append '< (make-stem stem) '>)))
|
||||
`((and (eq? ,rtd ,record-type)
|
||||
,@(reverse (further-predicates r stem slots)))
|
||||
(let ,(reverse (let-clauses r stem (append (cdr type-and-common)
|
||||
slots)))
|
||||
(let ,(reverse (let-clauses r stem slots))
|
||||
,@(if (pair? body)
|
||||
(map transform-expr body)
|
||||
'((if #f #f)))))))))
|
||||
`(let* ((,r ,record)
|
||||
(,rtd (struct-vtable ,r)))
|
||||
(,rtd (struct-vtable ,r))
|
||||
,@(map (lambda (slot)
|
||||
`(,slot (,(make-stem slot) ,r)))
|
||||
(cdr type-and-common)))
|
||||
(cond ,@(let ((clauses (map process-clause clauses)))
|
||||
(if (assq 'else clauses)
|
||||
clauses
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue