Commit 698a261f authored by rtoy's avatar rtoy
Browse files

First set of changes to add new slots to lisp-stream so we can

implement a faster external formats by converting all buffered input
at one step instead of a character at a time.

code/struct.lisp:
o Add new slots:  string-buffer, string-index, string-buffer-len

code/sysmacs.lisp:
o Update PREPARE-FOR-FAST-READ-CHAR, DONE-WITH-FAST-READ-CHAR, and
  FAST-READ-CHAR to use the new slots.

code/fd-stream.lisp:
o Don't allocate the in-buffer array since the fast read char stuff no
  longer handles the in-buffer.

bootfiles/20a/boot-2009-10-1-cross.lisp:
o New file.  Use this to cross-compile this change.
parent efe5c26a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
;;; Cross-compile script to add new slots to lisp-stream so we can
;;; have faster external formats.

;; Nothing special needed; use standard scripts

(load #+x86 "target:tools/cross-scripts/cross-x86-x86"
      #+sparc "target:tools/cross-scripts/cross-sparc-sparc"
      #+ppc "target:tools/cross-scripts/cross-ppc-ppc-darwin")
+2 −1
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/fd-stream.lisp,v 1.91 2009/09/09 15:51:27 rtoy Rel $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fd-stream.lisp,v 1.91.2.1 2009/09/19 14:44:52 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -1387,6 +1387,7 @@
	    ;; format of :iso8859-1.  Because there's no buffer, the
	    ;; other element-types will dispatch to the appropriate
	    ;; input (output) routine in fast-read-byte/fast-read-char.
	    #+nil
	    (setf (lisp-stream-in-buffer stream)
		  (make-array in-buffer-length
			      :element-type '(unsigned-byte 8)))))
+17 −2
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/struct.lisp,v 1.21 2002/02/04 17:22:15 toy Rel $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/struct.lisp,v 1.21.48.1 2009/09/19 14:44:52 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -37,7 +37,22 @@
  (out #'ill-out :type function)		; Write-Char function
  (bout #'ill-bout :type function)		; Byte output function
  (sout #'ill-out :type function)		; String output function
  (misc #'do-nothing :type function))		; Less used methods
  (misc #'do-nothing :type function)		; Less used methods
  ;;
  ;; A string to hold characters that have been converted from
  ;; in-buffer.
  #+unicode
  (string-buffer nil :type (or null simple-string))
  ;;
  ;; Index into string-buffer where the next character should be read from
  #+unicode
  (string-index 0 :type index)
  ;;
  ;; Number of characters in string-buffer.  (This isn't the length of
  ;; string-buffer, but the number of characters in the buffer, since
  ;; many octets may be consumed to produce one character.)
  #+unicode
  (string-buffer-len 0 :type index))

(declaim (inline streamp))
(defun streamp (stream)
+27 −7
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/sysmacs.lisp,v 1.30 2006/02/03 13:51:28 rtoy Rel $")
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/sysmacs.lisp,v 1.30.26.1 2009/09/19 14:44:52 rtoy Exp $")
;;;
;;; **********************************************************************
;;;
@@ -149,9 +149,13 @@ and also the CMUCL C runtime."
(defmacro prepare-for-fast-read-char (stream &body forms)
  `(let* ((%frc-stream% ,stream)
	  (%frc-method% (lisp-stream-in %frc-stream%))
	  (%frc-buffer% (lisp-stream-in-buffer %frc-stream%))
	  (%frc-index% (lisp-stream-in-index %frc-stream%)))
     (declare (type index %frc-index%)
	  ;;(%frc-buffer% (lisp-stream-in-buffer %frc-stream%))
	  ;;(%frc-index% (lisp-stream-in-index %frc-stream%))
	  (%frc-string-buffer% (lisp-stream-string-buffer %frc-stream%))
	  (%frc-string-index% (lisp-stream-string-index %frc-stream%))
	  (%frc-string-length% (lisp-stream-string-buffer-len %frc-stream%)))
     (declare (type index %frc-string-index% %frc-string-length%)
	      (type (or null simple-string) %frc-string-buffer%)
	      (type lisp-stream %frc-stream%))
     ,@forms))

@@ -161,13 +165,15 @@ and also the CMUCL C runtime."
;;; inside it's scope to decache the lisp-stream-in-index.
;;;
(defmacro done-with-fast-read-char ()
  `(setf (lisp-stream-in-index %frc-stream%) %frc-index%))
  `(progn
     (setf (lisp-stream-string-index %frc-stream%) %frc-string-index%)))

;;; Fast-Read-Char  --  Internal
;;;
;;;    This macro can be used instead of Read-Char within the scope of
;;; a Prepare-For-Fast-Read-Char.
;;;
#-unicode
(defmacro fast-read-char (&optional (eof-errorp t) (eof-value ()))
  `(cond
    ((not %frc-buffer%)
@@ -179,6 +185,19 @@ and also the CMUCL C runtime."
     (prog1 (code-char (aref %frc-buffer% %frc-index%))
       (incf %frc-index%)))))

#+unicode
(defmacro fast-read-char (&optional (eof-errorp t) (eof-value ()))
  `(cond
     ((not %frc-string-buffer%)
      (funcall %frc-method% %frc-stream% ,eof-errorp ,eof-value))
     ((>= %frc-string-index% %frc-string-length%)
      (prog1 (fast-read-char-string-refill %frc-stream% ,eof-errorp ,eof-value)
	(setf %frc-string-index% (lisp-stream-string-index %frc-stream%))
	(setf %frc-string-length% (lisp-stream-string-buffer-len %frc-stream%))))
     (t
      (prog1 (aref %frc-string-buffer% %frc-string-index%)
	(incf %frc-string-index%)))))

;;;; And these for the fasloader...

;;; Prepare-For-Fast-Read-Byte  --  Internal
@@ -215,4 +234,5 @@ and also the CMUCL C runtime."
	(incf %frc-index%))))))
;;;
(defmacro done-with-fast-read-byte ()
  `(done-with-fast-read-char))
  `(progn
     (setf (lisp-stream-in-index %frc-stream%) %frc-index%)))