[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/slime 1bad2ceff8 1/2: Don't use CLOS in stream-fresh-line.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/slime 1bad2ceff8 1/2: Don't use CLOS in stream-fresh-line. |
Date: |
Mon, 9 Dec 2024 13:01:28 -0500 (EST) |
branch: elpa/slime
commit 1bad2ceff8e8bdc8638a3dc159bad81693387a21
Author: Stas Boukarev <stassats@gmail.com>
Commit: Stas Boukarev <stassats@gmail.com>
Don't use CLOS in stream-fresh-line.
Due to the world-lock in SBCL.
---
slime.el | 2 +-
swank/gray.lisp | 30 +++++++++++++++++++++++++-----
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/slime.el b/slime.el
index dcca696ff7..f2ef380616 100644
--- a/slime.el
+++ b/slime.el
@@ -3,7 +3,7 @@
;; URL: https://github.com/slime/slime
;; Package-Requires: ((emacs "24.3") (macrostep "0.9"))
;; Keywords: languages, lisp, slime
-;; Version: 2.31
+;; Version: 2.31.git
;;;; License and Commentary
diff --git a/swank/gray.lisp b/swank/gray.lisp
index 5e7f8a3bb8..9e868b6255 100644
--- a/swank/gray.lisp
+++ b/swank/gray.lisp
@@ -70,8 +70,23 @@
`(let ((data (data ,stream)))
(with-stream-data data ,@body)))
+(defmacro with-stream-data-no-lock (data &body body)
+ `(with-accessors ((output-fn stream-data-output-fn)
+ (buffer stream-data-buffer)
+ (fill-pointer stream-data-fill-pointer)
+ (column stream-data-column)
+ (flush-thread stream-data-flush-thread)
+ (flush-scheduled stream-data-flush-scheduled))
+ ,data
+ ,@body))
+
+;;; No locking
+(defmacro with-slime-output-stream-no-lock (stream &body body)
+ `(let ((data (data ,stream)))
+ (with-stream-data-no-lock data ,@body)))
+
(defun maybe-schedule-flush (data)
- (with-stream-data data
+ (with-stream-data-no-lock data
(when flush-thread
(or flush-scheduled
(progn
@@ -79,8 +94,9 @@
(send flush-thread t)
t)))))
-(defmethod stream-write-char ((stream slime-output-stream) char)
- (with-slime-output-stream stream
+;;; A non-method write-char due to locking inside CLOS.
+(defun write-char* (stream char)
+ (with-slime-output-stream-no-lock stream
(setf (schar buffer fill-pointer) char)
(incf fill-pointer)
(incf column)
@@ -88,7 +104,11 @@
(setf column 0))
(if (= fill-pointer (length buffer))
(%stream-finish-output data)
- (maybe-schedule-flush data)))
+ (maybe-schedule-flush data))))
+
+(defmethod stream-write-char ((stream slime-output-stream) char)
+ (with-slime-output-stream stream
+ (write-char* stream char))
char)
(defmethod stream-write-string ((stream slime-output-stream) string
@@ -140,7 +160,7 @@
(defmethod stream-fresh-line ((stream slime-output-stream))
(with-slime-output-stream stream
(cond ((zerop column) nil)
- (t (terpri stream) t))))
+ (t (write-char* stream #\Newline) t))))
#+sbcl
(defmethod stream-file-position ((stream slime-output-stream) &optional
position)