mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-30 15:00:21 +02:00
Beginnings of local variable information
* module/system/vm/assembler.scm (<arity>, begin-kw-arity, end-arity): (definition): Add definition macro-instruction. Arrange to record variable definitions. * module/language/cps/compile-bytecode.scm (compile-fun): Emit definition macro-instructions as appropriate.
This commit is contained in:
parent
863034a8ac
commit
78351d1065
2 changed files with 16 additions and 4 deletions
|
@ -153,8 +153,13 @@
|
||||||
label
|
label
|
||||||
(match (lookup-cont label dfg)
|
(match (lookup-cont label dfg)
|
||||||
(($ $kclause) label)
|
(($ $kclause) label)
|
||||||
(($ $kargs _ _ term)
|
(($ $kargs names vars term)
|
||||||
(emit-label asm label)
|
(emit-label asm label)
|
||||||
|
(for-each (lambda (name var)
|
||||||
|
(let ((slot (maybe-slot var)))
|
||||||
|
(when slot
|
||||||
|
(emit-definition asm name slot))))
|
||||||
|
names vars)
|
||||||
(let find-exp ((term term))
|
(let find-exp ((term term))
|
||||||
(match term
|
(match term
|
||||||
(($ $letk conts term)
|
(($ $letk conts term)
|
||||||
|
|
|
@ -163,7 +163,7 @@
|
||||||
;; Metadata for one <lambda-case>.
|
;; Metadata for one <lambda-case>.
|
||||||
(define-record-type <arity>
|
(define-record-type <arity>
|
||||||
(make-arity req opt rest kw-indices allow-other-keys?
|
(make-arity req opt rest kw-indices allow-other-keys?
|
||||||
low-pc high-pc)
|
low-pc high-pc definitions)
|
||||||
arity?
|
arity?
|
||||||
(req arity-req)
|
(req arity-req)
|
||||||
(opt arity-opt)
|
(opt arity-opt)
|
||||||
|
@ -171,7 +171,8 @@
|
||||||
(kw-indices arity-kw-indices)
|
(kw-indices arity-kw-indices)
|
||||||
(allow-other-keys? arity-allow-other-keys?)
|
(allow-other-keys? arity-allow-other-keys?)
|
||||||
(low-pc arity-low-pc)
|
(low-pc arity-low-pc)
|
||||||
(high-pc arity-high-pc set-arity-high-pc!))
|
(high-pc arity-high-pc set-arity-high-pc!)
|
||||||
|
(definitions arity-definitions set-arity-definitions!))
|
||||||
|
|
||||||
(define-syntax *block-size* (identifier-syntax 32))
|
(define-syntax *block-size* (identifier-syntax 32))
|
||||||
|
|
||||||
|
@ -753,7 +754,7 @@ returned instead."
|
||||||
(assert-match alternate (or #f (? exact-integer?) (? symbol?)) "#f or symbol")
|
(assert-match alternate (or #f (? exact-integer?) (? symbol?)) "#f or symbol")
|
||||||
(let* ((meta (car (asm-meta asm)))
|
(let* ((meta (car (asm-meta asm)))
|
||||||
(arity (make-arity req opt rest kw-indices allow-other-keys?
|
(arity (make-arity req opt rest kw-indices allow-other-keys?
|
||||||
(asm-start asm) #f))
|
(asm-start asm) #f '()))
|
||||||
;; The procedure itself is in slot 0, in the standard calling
|
;; The procedure itself is in slot 0, in the standard calling
|
||||||
;; convention. For procedure prologues, nreq includes the
|
;; convention. For procedure prologues, nreq includes the
|
||||||
;; procedure, so here we add 1.
|
;; procedure, so here we add 1.
|
||||||
|
@ -772,6 +773,7 @@ returned instead."
|
||||||
|
|
||||||
(define-macro-assembler (end-arity asm)
|
(define-macro-assembler (end-arity asm)
|
||||||
(let ((arity (car (meta-arities (car (asm-meta asm))))))
|
(let ((arity (car (meta-arities (car (asm-meta asm))))))
|
||||||
|
(set-arity-definitions! arity (reverse (arity-definitions arity)))
|
||||||
(set-arity-high-pc! arity (asm-start asm))))
|
(set-arity-high-pc! arity (asm-start asm))))
|
||||||
|
|
||||||
(define-macro-assembler (standard-prelude asm nreq nlocals alternate)
|
(define-macro-assembler (standard-prelude asm nreq nlocals alternate)
|
||||||
|
@ -825,6 +827,11 @@ returned instead."
|
||||||
(define-macro-assembler (source asm source)
|
(define-macro-assembler (source asm source)
|
||||||
(set-asm-sources! asm (acons (asm-start asm) source (asm-sources asm))))
|
(set-asm-sources! asm (acons (asm-start asm) source (asm-sources asm))))
|
||||||
|
|
||||||
|
(define-macro-assembler (definition asm name slot)
|
||||||
|
(let* ((arity (car (meta-arities (car (asm-meta asm)))))
|
||||||
|
(def (vector name slot (- (asm-start asm) (arity-low-pc arity)))))
|
||||||
|
(set-arity-definitions! arity (cons def (arity-definitions arity)))))
|
||||||
|
|
||||||
(define-macro-assembler (cache-current-module! asm module scope)
|
(define-macro-assembler (cache-current-module! asm module scope)
|
||||||
(let ((mod-label (intern-module-cache-cell asm scope)))
|
(let ((mod-label (intern-module-cache-cell asm scope)))
|
||||||
(emit-static-set! asm module mod-label 0)))
|
(emit-static-set! asm module mod-label 0)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue