Skip to content

Commit

Permalink
Remove static-vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Oct 17, 2024
1 parent 0df344d commit 3555a00
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 110 deletions.
4 changes: 2 additions & 2 deletions common-lisp-jupyter.asd
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"pzmq"
"puri"
"shasht"
(:feature (:or :abcl :allegro :ccl :clasp :cmu :ecl :lispworks :sbcl) "static-vectors")
#+(or)(:feature (:or :abcl :allegro :ccl :clasp :cmu :ecl :lispworks :sbcl) "static-vectors")
"trivial-do"
"trivial-garbage"
#+(or)"trivial-garbage"
"trivial-mimes"
"trivial-features")
:components
Expand Down
25 changes: 13 additions & 12 deletions src/heartbeat.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
(with-slots (socket thread) hb
(setf thread
(bordeaux-threads:make-thread
(lambda ()
(inform :info hb "Starting thread")
#-cmucl (pzmq:proxy socket socket (cffi:null-pointer))
#+cmucl
(pzmq:with-poll-items items ((socket :pollin))
(prog ()
poll
(unless (zerop (pzmq:poll items +zmq-poll-timeout+))
(send-heartbeat hb (recv-heartbeat hb)))
(bordeaux-threads:thread-yield)
(go poll))))
:name "Jupyter Heartbeat"))))
(lambda ()
(with-debugger (:control t)
(inform :info hb "Starting thread")
#-cmucl (pzmq:proxy socket socket (cffi:null-pointer))
#+cmucl
(pzmq:with-poll-items items ((socket :pollin))
(prog ()
poll
(unless (zerop (pzmq:poll items +zmq-poll-timeout+))
(send-heartbeat hb (recv-heartbeat hb)))
(bordeaux-threads:thread-yield)
(go poll)))))
:name "Jupyter Heartbeat"))))
90 changes: 0 additions & 90 deletions src/kernel.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -672,96 +672,6 @@
(values))))


(defun control-debugger-hook (condition me-or-my-encapsulation)
(declare (ignore me-or-my-encapsulation))
(cond ((typep condition 'warning)
(inform :warning "[~S] ~A~%" (type-of condition) condition)
(muffle-warning))
(t
(inform :error "[~S] ~A~%" (type-of condition) condition)
(abort))))

(defun shell-debugger-hook (condition me-or-my-encapsulation)
(declare (ignore me-or-my-encapsulation))
(cond ((typep condition 'warning)
(format *standard-output* "[~S] ~A~%" (type-of condition) condition)
(finish-output *standard-output*)
(muffle-warning))
(t
(let ((env (dissect:capture-environment condition)))
(format *error-output* "[~S] ~A~%" (type-of condition) condition)
(finish-output *error-output*)
(throw 'debug-error
(make-eval-error condition (format nil "~A" condition)
(mapcar (lambda (frame)
(dissect:present frame nil))
(dissect:environment-stack env))))))))

(defun debugger-type ()
(cond ((or (not *enable-debugger*)
#+clasp (core:debugger-disabled-p)
#+sbcl (eq sb-ext:*invoke-debugger-hook* 'sb-debug::debugger-disabled-hook))
:none)
#+abcl
(sys::*invoke-debugger-hook* :external)
#+allegro
(excl::*break-hook* :external)
#+ccl
(ccl:*break-hook* :external)
#+clisp
(sys::*break-driver* :external)
#+clasp
(ext:*invoke-debugger-hook* :external)
#+ecl
(ext:*invoke-debugger-hook* :external)
#+lispworks
(dbg::*debugger-wrapper-list* :external)
#+mezzano
(mezzano.debug:*global-debugger* :external)
#+sbcl
(sb-ext:*invoke-debugger-hook* :external)
(*enable-internal-debugger* :internal)
(t :none)))

(defmacro with-debugger ((&key control internal) &body body)
(let ((debugger-hook (if control
'control-debugger-hook
'shell-debugger-hook)))
`(flet ((body-func ()
(catch 'debug-error
(with-simple-restart
(abort "Exit debugger, returning to top level.")
,@body))))
(case (debugger-type)
(:external
(body-func))
,@(when internal
#+clasp
`((:internal
(catch sys::*quit-tag*
(body-func))))
#-clasp
`((:internal
(body-func))))
(otherwise
(let ((*debugger-hook* ',debugger-hook)
#+sbcl (sb-ext:*invoke-debugger-hook* ',debugger-hook)
#+ccl (ccl:*break-hook* ',debugger-hook)
#+ecl (ext:*invoke-debugger-hook* ',debugger-hook)
#+clasp (ext:*invoke-debugger-hook* ',debugger-hook)
#+abcl (sys::*invoke-debugger-hook* ',debugger-hook)
#+clisp (sys::*break-driver* (lambda (continuable &optional condition print)
(declare (ignore continuable print))
(,debugger-hook condition nil)))
#+allegro (excl::*break-hook* (lambda (&rest args)
(,debugger-hook (fifth args))))
#+lispworks (dbg::*debugger-wrapper-list* (lambda (function condition)
(declare (ignore function))
(,debugger-hook condition nil)))
#+mezzano (mezzano.debug:*global-debugger* (lambda (condition)
(,debugger-hook condition nil))))
(body-func)))))))

(defun debug-enter-loop ()
"Re-enter the debug loop after a restart which implements a debugger command."
(throw 'enter-loop t))
Expand Down
8 changes: 4 additions & 4 deletions src/message.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
(:documentation "Representation of IPython messages"))


#+(or abcl allegro ccl clasp cmu ecl lispworks sbcl)
#+(or); abcl allegro ccl clasp cmu ecl lispworks sbcl)
(defmethod initialize-instance :after ((instance message) &rest initargs &key &allow-other-keys)
(declare (ignore initargs))
(let ((buffers (message-buffers instance)))
Expand Down Expand Up @@ -149,7 +149,7 @@
; explicitly defined element type is needed for CLISP
:element-type '(unsigned-byte 8)))

#+(or abcl allegro ccl clasp cmu ecl lispworks sbcl)
#+(or); abcl allegro ccl clasp cmu ecl lispworks sbcl)
(defun read-buffer-part (ch msg)
(pzmq:msg-recv msg (channel-socket ch))
(let* ((size (pzmq:msg-size msg))
Expand Down Expand Up @@ -204,8 +204,8 @@
(unless (more-parts ch msg)
(return (nreverse parts)))
(push
#-(or abcl allegro ccl clasp cmu ecl lispworks sbcl) (read-binary-part ch msg)
#+(or abcl allegro ccl clasp cmu ecl lispworks sbcl) (read-buffer-part ch msg)
#-(or)#| abcl allegro ccl clasp cmu ecl lispworks sbcl)|# (read-binary-part ch msg)
#+(or)#| abcl allegro ccl clasp cmu ecl lispworks sbcl)|# (read-buffer-part ch msg)
parts)
(go next)))))))

Expand Down
90 changes: 90 additions & 0 deletions src/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,93 @@
(defmethod close ((stream closed-input-stream) &key abort)
(declare (ignore abort))
nil)

(defun control-debugger-hook (condition me-or-my-encapsulation)
(declare (ignore me-or-my-encapsulation))
(cond ((typep condition 'warning)
(inform :warning "[~S] ~A~%" (type-of condition) condition)
(muffle-warning))
(t
(inform :error "[~S] ~A~%" (type-of condition) condition)
(abort))))

(defun shell-debugger-hook (condition me-or-my-encapsulation)
(declare (ignore me-or-my-encapsulation))
(cond ((typep condition 'warning)
(format *standard-output* "[~S] ~A~%" (type-of condition) condition)
(finish-output *standard-output*)
(muffle-warning))
(t
(let ((env (dissect:capture-environment condition)))
(format *error-output* "[~S] ~A~%" (type-of condition) condition)
(finish-output *error-output*)
(throw 'debug-error
(make-eval-error condition (format nil "~A" condition)
(mapcar (lambda (frame)
(dissect:present frame nil))
(dissect:environment-stack env))))))))

(defun debugger-type ()
(cond ((or (not *enable-debugger*)
#+clasp (core:debugger-disabled-p)
#+sbcl (eq sb-ext:*invoke-debugger-hook* 'sb-debug::debugger-disabled-hook))
:none)
#+abcl
(sys::*invoke-debugger-hook* :external)
#+allegro
(excl::*break-hook* :external)
#+ccl
(ccl:*break-hook* :external)
#+clisp
(sys::*break-driver* :external)
#+clasp
(ext:*invoke-debugger-hook* :external)
#+ecl
(ext:*invoke-debugger-hook* :external)
#+lispworks
(dbg::*debugger-wrapper-list* :external)
#+mezzano
(mezzano.debug:*global-debugger* :external)
#+sbcl
(sb-ext:*invoke-debugger-hook* :external)
(*enable-internal-debugger* :internal)
(t :none)))

(defmacro with-debugger ((&key control internal) &body body)
(let ((debugger-hook (if control
'control-debugger-hook
'shell-debugger-hook)))
`(flet ((body-func ()
(catch 'debug-error
(with-simple-restart
(abort "Exit debugger, returning to top level.")
,@body))))
(case (debugger-type)
(:external
(body-func))
,@(when internal
#+clasp
`((:internal
(catch sys::*quit-tag*
(body-func))))
#-clasp
`((:internal
(body-func))))
(otherwise
(let ((*debugger-hook* ',debugger-hook)
#+sbcl (sb-ext:*invoke-debugger-hook* ',debugger-hook)
#+ccl (ccl:*break-hook* ',debugger-hook)
#+ecl (ext:*invoke-debugger-hook* ',debugger-hook)
#+clasp (ext:*invoke-debugger-hook* ',debugger-hook)
#+abcl (sys::*invoke-debugger-hook* ',debugger-hook)
#+clisp (sys::*break-driver* (lambda (continuable &optional condition print)
(declare (ignore continuable print))
(,debugger-hook condition nil)))
#+allegro (excl::*break-hook* (lambda (&rest args)
(,debugger-hook (fifth args))))
#+lispworks (dbg::*debugger-wrapper-list* (lambda (function condition)
(declare (ignore function))
(,debugger-hook condition nil)))
#+mezzano (mezzano.debug:*global-debugger* (lambda (condition)
(,debugger-hook condition nil))))
(body-func)))))))
4 changes: 2 additions & 2 deletions src/widgets/trait-types.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(declare (ignore object type name))
(values :null (list nil) (list value)))

#+(or abcl allegro ccl clasp cmu ecl lispworks sbcl)
#+(or); abcl allegro ccl clasp cmu ecl lispworks sbcl)
(defmethod deserialize-trait (object (type (eql :buffer)) name (value vector))
(declare (ignore type name))
(if (binary-value-p value)
Expand Down Expand Up @@ -217,7 +217,7 @@
(declare (ignore object type name))
(values :null (list nil) (list value)))

#+(or abcl allegro ccl clasp cmu ecl lispworks sbcl)
#+(or); abcl allegro ccl clasp cmu ecl lispworks sbcl)
(defmethod deserialize-trait (object (type (eql :single-float-buffer)) name (value vector))
(declare (ignore type name))
(if (binary-value-p value)
Expand Down

0 comments on commit 3555a00

Please sign in to comment.