diff options
author | Andy Wingo <wingo@pobox.com> | 2019-06-07 15:37:20 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-06-07 17:01:37 +0200 |
commit | f6c07e4eb2212656fc6acb6c031b74237847eb42 (patch) | |
tree | 330ac8507238321e3b58e4d17c113d453224b429 /module/system/vm/assembler.scm | |
parent | f07fadc72e148d13bb4b42a3d9ecde6ab7a2296c (diff) | |
download | guile-f6c07e4eb2212656fc6acb6c031b74237847eb42.tar.gz |
Add compiler support for eliding closure bindings
* module/language/cps/closure-conversion.scm (compute-elidable-closures):
New function.
(convert-one, convert-closures): Add ability to set "self" variable of
$kfun to $f, hopefully avoiding passing that argument in some cases.
* module/language/cps/compile-bytecode.scm (compile-function): Pass the
has-closure? bit on through to the assembler.
* module/system/vm/assembler.scm (begin-standard-arity)
(begin-opt-arity, begin-kw-arity): Only reserve space for the closure
as appropriate.
* module/language/cps/slot-allocation.scm (allocate-args)
(compute-defs-and-uses, compute-needs-slot)
(compute-var-representations): Allow for closure slot allocation
differences.
* module/language/cps/cse.scm (compute-defs):
* module/language/cps/dce.scm (compute-live-code):
* module/language/cps/renumber.scm (renumber, compute-renaming):
(allocate-args):
* module/language/cps/specialize-numbers.scm (compute-significant-bits):
(compute-defs):
* module/language/cps/split-rec.scm (compute-free-vars):
* module/language/cps/types.scm (infer-types):
* module/language/cps/utils.scm (compute-max-label-and-var):
* module/language/cps/verify.scm (check-distinct-vars):
(compute-available-definitions): Allow closure to be #f.
Diffstat (limited to 'module/system/vm/assembler.scm')
-rw-r--r-- | module/system/vm/assembler.scm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/module/system/vm/assembler.scm b/module/system/vm/assembler.scm index 9477cb932..c9e9f5f7b 100644 --- a/module/system/vm/assembler.scm +++ b/module/system/vm/assembler.scm @@ -1412,13 +1412,15 @@ returned instead." (meta-jit-data-label meta) (asm-constants asm))))) -(define-macro-assembler (begin-standard-arity asm req nlocals alternate) - (emit-begin-opt-arity asm req '() #f nlocals alternate)) +(define-macro-assembler (begin-standard-arity asm has-closure? req nlocals + alternate) + (emit-begin-opt-arity asm has-closure? req '() #f nlocals alternate)) -(define-macro-assembler (begin-opt-arity asm req opt rest nlocals alternate) - (emit-begin-kw-arity asm req opt rest '() #f nlocals alternate)) +(define-macro-assembler (begin-opt-arity asm has-closure? req opt rest nlocals + alternate) + (emit-begin-kw-arity asm has-closure? req opt rest '() #f nlocals alternate)) -(define-macro-assembler (begin-kw-arity asm req opt rest kw-indices +(define-macro-assembler (begin-kw-arity asm has-closure? req opt rest kw-indices allow-other-keys? nlocals alternate) (assert-match req ((? symbol?) ...) "list of symbols") (assert-match opt ((? symbol?) ...) "list of symbols") @@ -1439,7 +1441,8 @@ returned instead." ;; The procedure itself is in slot 0, in the standard calling ;; convention. For procedure prologues, nreq includes the ;; procedure, so here we add 1. - (nreq (1+ (length req))) + (nclosure (if has-closure? 1 0)) + (nreq (+ nclosure (length req))) (nopt (length opt)) (rest? (->bool rest))) (set-meta-arities! meta (cons arity (meta-arities meta))) |