summaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2019-06-06 16:20:20 +0200
committerAndy Wingo <wingo@pobox.com>2019-06-06 16:36:32 +0200
commit9fd978ed7eebe32ceff7762eb87bba5d56a0743c (patch)
treee2b7e28c42924c1c5aced9f56cdbdec525c5146c /module
parent12d6e4317657e4334306b1345a09a11b0e256fa3 (diff)
downloadguile-9fd978ed7eebe32ceff7762eb87bba5d56a0743c.tar.gz
Add bind-optionals instruction
* doc/ref/vm.texi (Function Prologue Instructions): Document new instruction. * libguile/jit.c (compile_bind_optionals): New compiler. * libguile/vm-engine.c (VM_NAME): New interpreter. * module/system/vm/assembler.scm (opt-prelude): Emit bind-optionals as appropriate. * module/system/vm/disassembler.scm (define-stack-effect-parser) (code-annotation): Handle bind-optionals.
Diffstat (limited to 'module')
-rw-r--r--module/system/vm/assembler.scm13
-rw-r--r--module/system/vm/disassembler.scm6
2 files changed, 13 insertions, 6 deletions
diff --git a/module/system/vm/assembler.scm b/module/system/vm/assembler.scm
index f3682f7e8..9477cb932 100644
--- a/module/system/vm/assembler.scm
+++ b/module/system/vm/assembler.scm
@@ -1,6 +1,6 @@
;;; Guile bytecode assembler
-;;; Copyright (C) 2001, 2009, 2010, 2012, 2013, 2014, 2015, 2017, 2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2001, 2009-2019 Free Software Foundation, Inc.
;;;
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public
@@ -246,7 +246,6 @@
emit-assert-nargs-ee
emit-assert-nargs-ge
emit-assert-nargs-le
- emit-alloc-frame
emit-reset-frame
emit-assert-nargs-ee/locals
emit-bind-kwargs
@@ -1478,6 +1477,8 @@ returned instead."
(emit-assert-nargs-ge asm nreq))
(cond
(rest?
+ (unless (zero? nopt)
+ (emit-bind-optionals asm (+ nreq nopt)))
(emit-bind-rest asm (+ nreq nopt)))
(alternate
(emit-arguments<=? asm (+ nreq nopt))
@@ -1485,9 +1486,13 @@ returned instead."
;; whereas for <, NONE usually indicates greater-than-or-equal,
;; hence the name jge. Perhaps we just need to rename jge to
;; br-if-none.
- (emit-jge asm alternate))
+ (emit-jge asm alternate)
+ (unless (zero? nopt)
+ (emit-bind-optionals asm (+ nreq nopt))))
(else
- (emit-assert-nargs-le asm (+ nreq nopt))))
+ (emit-assert-nargs-le asm (+ nreq nopt))
+ (unless (zero? nopt)
+ (emit-bind-optionals asm (+ nreq nopt)))))
(emit-alloc-frame asm nlocals))
(define-macro-assembler (kw-prelude asm nreq nopt rest? kw-indices
diff --git a/module/system/vm/disassembler.scm b/module/system/vm/disassembler.scm
index 83499333c..73910fda0 100644
--- a/module/system/vm/disassembler.scm
+++ b/module/system/vm/disassembler.scm
@@ -1,6 +1,6 @@
;;; Guile bytecode disassembler
-;;; Copyright (C) 2001, 2009-2010, 2012-2015, 2017-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2001, 2009-2010, 2012-2015, 2017-2019 Free Software Foundation, Inc.
;;;
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public
@@ -231,6 +231,8 @@ address of that offset."
(('assert-nargs-ee/locals nargs locals)
;; The nargs includes the procedure.
(list "~a slot~:p (~a arg~:p)" (+ locals nargs) (1- nargs)))
+ (('bind-optionals nargs)
+ (list "~a args~:p" (1- nargs)))
(('alloc-frame nlocals)
(list "~a slot~:p" nlocals))
(('reset-frame nlocals)
@@ -546,7 +548,7 @@ address of that offset."
#'(lambda (code pos size)
(let ((count (ash (bytevector-u32-native-ref code pos) -8)))
(and size (- size count)))))
- ((alloc-frame reset-frame)
+ ((alloc-frame reset-frame bind-optionals)
#'(lambda (code pos size)
(let ((nlocals (ash (bytevector-u32-native-ref code pos) -8)))
nlocals)))