X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fbyte-interp.lisp;h=0895e5fdaf353b5fe2c85657c6062e80a1a3e00a;hb=bee53328c93be3433477821131ab805557476c8b;hp=214144724c73977113719b2a02479fe7a0fbc23b;hpb=fbe6e22af842835f7c70309f4d48064ca3984ad0;p=sbcl.git diff --git a/src/code/byte-interp.lisp b/src/code/byte-interp.lisp index 2141447..0895e5f 100644 --- a/src/code/byte-interp.lisp +++ b/src/code/byte-interp.lisp @@ -50,16 +50,13 @@ ((nil))) `(function ,(res) *)))))) -;;;; the evaluation stack +;;;; the 'evaluation stack' +;;;; +;;;; (The name dates back to CMU CL, when it was used for the IR1 +;;;; interpreted implementation of EVAL. In SBCL >=0.7.0, it's just +;;;; the byte interpreter stack.) -;;; the interpreter's evaluation stack (defvar *eval-stack* (make-array 100)) ; will grow as needed -;;; FIXME: This seems to be used by the ordinary (non-byte) interpreter -;;; too, judging from a crash I had when I removed byte-interp.lisp from -;;; the cold build sequence. It would probably be clearer to pull the -;;; shared interpreter machinery out of the byte interpreter and ordinary -;;; interpreter files and put them into their own file shared-interp.lisp -;;; or something. ;;; the index of the next free element of the interpreter's evaluation stack (defvar *eval-stack-top* 0) @@ -67,37 +64,37 @@ #!-sb-fluid (declaim (inline eval-stack-ref)) (defun eval-stack-ref (offset) (declare (type stack-pointer offset)) - (svref sb!eval::*eval-stack* offset)) + (svref sb!bytecode::*eval-stack* offset)) #!-sb-fluid (declaim (inline (setf eval-stack-ref))) (defun (setf eval-stack-ref) (new-value offset) (declare (type stack-pointer offset)) - (setf (svref sb!eval::*eval-stack* offset) new-value)) + (setf (svref sb!bytecode::*eval-stack* offset) new-value)) (defun push-eval-stack (value) - (let ((len (length (the simple-vector sb!eval::*eval-stack*))) + (let ((len (length (the simple-vector sb!bytecode::*eval-stack*))) (sp *eval-stack-top*)) (when (= len sp) (let ((new-stack (make-array (ash len 1)))) - (replace new-stack sb!eval::*eval-stack* :end1 len :end2 len) - (setf sb!eval::*eval-stack* new-stack))) + (replace new-stack sb!bytecode::*eval-stack* :end1 len :end2 len) + (setf sb!bytecode::*eval-stack* new-stack))) (setf *eval-stack-top* (1+ sp)) (setf (eval-stack-ref sp) value))) (defun allocate-eval-stack (amount) - (let* ((len (length (the simple-vector sb!eval::*eval-stack*))) + (let* ((len (length (the simple-vector sb!bytecode::*eval-stack*))) (sp *eval-stack-top*) (new-sp (+ sp amount))) (declare (type index sp new-sp)) (when (>= new-sp len) (let ((new-stack (make-array (ash new-sp 1)))) - (replace new-stack sb!eval::*eval-stack* :end1 len :end2 len) - (setf sb!eval::*eval-stack* new-stack))) + (replace new-stack sb!bytecode::*eval-stack* :end1 len :end2 len) + (setf sb!bytecode::*eval-stack* new-stack))) (setf *eval-stack-top* new-sp) - (let ((stack sb!eval::*eval-stack*)) - (do ((i sp (1+ i))) ; FIXME: DOTIMES? or just :INITIAL-ELEMENT in MAKE-ARRAY? + (let ((stack sb!bytecode::*eval-stack*)) + (do ((i sp (1+ i))) ; FIXME: Use CL:FILL. ((= i new-sp)) - (setf (svref stack i) '#:uninitialized)))) + (setf (svref stack i) '#:uninitialized-eval-stack-element)))) (values)) (defun pop-eval-stack () @@ -113,7 +110,9 @@ (new-sp-var (gensym "NEW-SP-")) (decls nil)) (loop - (unless (and (consp body) (consp (car body)) (eq (caar body) 'declare)) + (unless (and (consp body) + (consp (car body)) + (eq (caar body) 'declare)) (return)) (push (pop body) decls)) `(let ((,new-sp-var (- *eval-stack-top* ,num-vars))) @@ -398,17 +397,17 @@ ;;;; miscellaneous primitive stubs -(macrolet ((frob (name &optional (args '(x))) +(macrolet ((def-frob (name &optional (args '(x))) `(defun ,name ,args (,name ,@args)))) - (frob %CODE-CODE-SIZE) - (frob %CODE-DEBUG-INFO) - (frob %CODE-ENTRY-POINTS) - (frob %FUNCALLABLE-INSTANCE-FUNCTION) - (frob %FUNCALLABLE-INSTANCE-LAYOUT) - (frob %FUNCALLABLE-INSTANCE-LEXENV) - (frob %FUNCTION-NEXT) - (frob %FUNCTION-SELF) - (frob %SET-FUNCALLABLE-INSTANCE-FUNCTION (fin new-val))) + (def-frob %code-code-size) + (def-frob %code-debug-info) + (def-frob %code-entry-points) + (def-frob %funcallable-instance-function) + (def-frob %funcallable-instance-layout) + (def-frob %funcallable-instance-lexenv) + (def-frob %function-next) + (def-frob %function-self) + (def-frob %set-funcallable-instance-function (fin new-val))) ;;;; funny functions @@ -616,9 +615,9 @@ (type pc pc)) pc) -;;; This is exactly like THROW, except that the tag is the last thing on -;;; the stack instead of the first. This is used for RETURN-FROM (hence the -;;; name). +;;; This is exactly like THROW, except that the tag is the last thing +;;; on the stack instead of the first. This is used for RETURN-FROM +;;; (hence the name). (define-xop return-from (component old-pc pc fp) (declare (type code-component component) (type pc old-pc) @@ -837,7 +836,7 @@ (format *trace-output* "pc=~D, fp=~D, sp=~D, byte=#b~,'0X, frame:~% ~S~%" pc fp *eval-stack-top* byte - (subseq sb!eval::*eval-stack* fp *eval-stack-top*))))) + (subseq sb!bytecode::*eval-stack* fp *eval-stack-top*))))) (if (zerop (logand byte #x80)) ;; Some stack operation. No matter what, we need the operand, ;; so compute it.