Commit 88a53c80 authored by gerd's avatar gerd
Browse files

DYNAMIC-EXTENT rest args. Currently for x86 only. Speed must be

	greater than safety for stack-allocation to actually happen, which
	is what ACL defaults to.  Use boot15.lisp to bootstrap.

	* src/bootfiles/18e/boot15.lisp: New file.

	* src/compiler/node.lisp (leaf): Add slot dynamic-extent.

	* src/compiler/x86/macros.lisp (load-size, inline-allocation)
	(not-inline-allocation): Extract from function allocation.
	(stack-allocation): New function.
	(allocation): Add arg dynamic-extent.  Call stack-allocation
	if dynamic-extent is true, and speed > safety.

	* src/compiler/x86/call.lisp (listify-rest-args): Add
	constant third arg, and pass it to allocation.

	* src/code/class.lisp (find-layout): Put part in
	#-bootstrap-dynamic-extent.

	* src/compiler/ir1tran.lisp (process-dynamic-extent-declaration):
	New function.
	(*suppress-dynamic-extent-declaration*): New variable.
	(process-1-declaration): Call process-dynamic-extent-declaration.
	(convert-more-entry) [#+x86]: Call %listify-rest-args with
	third arg dynamic-extent.

	* src/compiler/eval-comp.lisp (%listify-rest-args) [#+x86]:
	* src/compiler/fndb.lisp (%listify-rest-args) [#+x86]: Add
	third arg for dynamic-extent.

	Possibly temporary workaround for SBCL build problems caused by a
	situation like

	  (defvar *foo*)
	  (declaim (type foo *foo*))
	  (defstruct foo)
	  (defun foo ()
	    (let ((*foo* (some-unknown-function)))
	       ...))

	When a type check is being generated for the local binding of
	*foo*, *foo*'s type in the info database is still an unknown-type.
	The typep transform generates a call to %instance-typep, because
	it knows that foo is an instance.  The deftransform for
	%instance-typep does not run, so an actual call to %instance-typep
	is being generated.  A function %instance-typep doesn't exist at
	run time, though.

	* src/compiler/ir1tran.lisp (find-free-variable): If the
	variable's type is an unknown-type, reparse it, and change the
	type in the info database.
parent 0de8456c
Loading
Loading
Loading
Loading
+21 −0
Changes for bootfiles/18e/boot15.lisp: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
;;;
;;; Bootstrap file for adding dynamic-extent rest args.
;;;

(in-package :cl-user)
(use-package :fwrappers)

;;;
;;; Prevent structure redefinition dialogs.
;;;
(define-fwrapper return-nil (&rest args) (call-next-function) nil)
(fwrap 'kernel::redefine-layout-warning #'return-nil)
(push :bootstrap-dynamic-extent *features*)

;;;
;;; Make compiler-layouts known to the compiler, for the change
;;; in the struct C::LEAF, which gets a new slot.
;;;
(compile-file "target:compiler/node")

;;; End of file.
+2 −1
Changes for code/class.lisp: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/class.lisp,v 1.56 2003/06/06 16:23:45 toy Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/class.lisp,v 1.57 2003/08/05 14:04:53 gerd Exp $")
;;;
;;; **********************************************************************
;;;
@@ -1171,6 +1171,7 @@
	  ((not *type-system-initialized*)
	   (setf (layout-class old) class)
	   old)
	  #-bootstrap-dynamic-extent
	  ((redefine-layout-warning old "current" res "compile time")
	   (restart-case
	       (error "Loading a reference to class ~S when the compile~
+3 −3
Changes for compiler/eval-comp.lisp: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/eval-comp.lisp,v 1.33 2003/01/21 16:51:09 toy Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/eval-comp.lisp,v 1.34 2003/08/05 14:04:52 gerd Exp $")
;;;
;;; **********************************************************************
;;;
@@ -285,8 +285,8 @@
(defun %more-arg (args index)
  (nth index args))

(defun %listify-rest-args (ptr count)
  (declare (ignore count))
(defun %listify-rest-args (ptr count #+x86 dynamic-extent)
  (declare (ignore count #+x86 dynamic-extent))
  ptr)

(defun %more-arg-values (args start count)
+2 −2
Changes for compiler/fndb.lisp: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/fndb.lisp,v 1.121 2003/08/02 11:52:15 gerd Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/fndb.lisp,v 1.122 2003/08/05 14:04:52 gerd Exp $")
;;;
;;; **********************************************************************
;;;
@@ -1146,7 +1146,7 @@
(defknown %cleanup-point () void)
(defknown %special-bind (t t) void)
(defknown %special-unbind (t) void)
(defknown %listify-rest-args (t index) list (flushable))
(defknown %listify-rest-args (t index #+x86 t) list (flushable))
(defknown %more-arg-context (t t) (values t index) (flushable))
(defknown %more-arg (t index) t)
(defknown %more-arg-values (t index index) * (flushable))
+47 −15
Changes for compiler/ir1tran.lisp: 47 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/ir1tran.lisp,v 1.157 2003/06/11 12:58:08 emarsden Exp $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/ir1tran.lisp,v 1.158 2003/08/05 14:04:52 gerd Exp $")
;;;
;;; **********************************************************************
;;;
@@ -273,25 +273,32 @@
	    (where-from (info variable where-from name)))
	(when (and (eq where-from :assumed) (eq kind :global))
	  (note-undefined-reference name :variable))
	;;
	;; Paper over the fact that unknown types aren't removed
	;; from the info database when a types gets defined.
	(when (unknown-type-p type)
	  (setq type (specifier-type (type-specifier type)))
	  (setf (info variable type name) type))

	(setf (gethash name *free-variables*)
	      (cond ((eq kind :alien)
	      (case kind
		(:alien
		 (info variable alien-info name))
		    ((eq kind :macro)
		     (let ((expansion (info variable macro-expansion name))
			   (type (type-specifier (info variable type name))))
		       `(MACRO . (the ,type ,expansion))))
		    (t
		     (multiple-value-bind
			   (val valp)
		(:macro
		 (let ((expansion (info variable macro-expansion name)))
		   `(MACRO . (the ,(type-specifier type) ,expansion))))
		(:constant
		 (multiple-value-bind (val valp)
		     (info variable constant-value name)
		       (if (and (eq kind :constant) valp)
		   (if valp
		       (make-constant :value val :name name
				      :type (ctype-of val)
				      :where-from where-from)
		       (make-global-var :kind kind :name name :type type
					    :where-from where-from)))))))))

					:where-from where-from))))
		(t
		 (make-global-var :kind kind :name name :type type
				  :where-from where-from)))))))


;;; MAYBE-EMIT-MAKE-LOAD-FORMS  --  internal
@@ -1134,10 +1141,33 @@
	(setf (lambda-var-ignorep var) t)))))
  (undefined-value))

(defun process-dynamic-extent-declaration (spec vars fvars)
  (declare (list spec vars fvars))
  (dolist (name (cdr spec))
    (let ((var (find-in-bindings-or-fbindings name vars fvars)))
      (cond ((null var)
	     (if (or (lexenv-find name variables) (lexenv-find-function name))
		 (compiler-note
		  "Ignoring free dynamic-extent declaration for ~S." name)
		 (compiler-warning
		  "Dynamic-extent declaration for unknown variable ~S." name)))
	    (t
	     (when (or (not (lambda-var-p var))
		       (let ((arg-info (lambda-var-arg-info var)))
			 (or (null arg-info)
			     (not (eq :rest (arg-info-kind arg-info))))))
	       (compiler-note
		"~@<Ignoring the dynamic-extent declaration of ~s.  ~
                  Dynamic-extent is currently only implemented for ~
                  rest args.~@:>" name))
	     (setf (leaf-dynamic-extent var) t)))))
  (values))

(defvar *suppress-values-declaration* nil
  "If true, processing of the VALUES declaration is inhibited.")

(defvar *suppress-dynamic-extent-declaration* nil
  "If true, processing of dynamic-extent declarations is inhibited.")

;;; PROCESS-1-DECLARATION  --  Internal
;;;
@@ -1191,8 +1221,8 @@
						    `(values ,@types)))
			 cont res 'values))))
    (dynamic-extent
     (when (policy nil (> speed brevity))
       (compiler-note "DYNAMIC-EXTENT declaration not implemented."))
     (unless *suppress-dynamic-extent-declaration*
       (process-dynamic-extent-declaration spec vars fvars))
     res)
    (t
     (let ((what (first spec)))
@@ -1709,7 +1739,9 @@
      (arg-vars context-temp count-temp)

      (when rest
	(arg-vals `(%listify-rest-args ,n-context ,n-count)))
	(arg-vals `(%listify-rest-args ,n-context ,n-count
				       #+x86
				       ,(leaf-dynamic-extent rest))))
      (when morep
	(arg-vals n-context)
	(arg-vals n-count))
Loading