run-program: support I/O redirection to binary streams on win32.
[sbcl.git] / src / code / restart.lisp
blobc1e77d1c4cc38471ba046b56f23c70000c21cfda
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
10 (in-package "SB!KERNEL")
12 ;;; A comment formerly here about "for DX allocation" was incredibly misleading.
13 ;;; We (apparently) never want DX allocation of restarts, except in
14 ;;; INITIAL-THREAD-FUNCTION-TRAMPOLINE where we do, but only "accidentally".
15 ;;; The accident is that if there is exactly ONE escape point, or there is more
16 ;;; than one and they all return the same fixed number of values,
17 ;;; then the generated code is right. If they don't, there's a problem.
19 ;;; So, following this DEFSTRUCT was a NOTINLINE proclamation, which we need,
20 ;;; because now that the compiler is smart enough to inline any structure
21 ;;; constructor anywhere, it can and does. I'm puzzled why, because I thought
22 ;;; the way this worked was that a local INLINE declaration would always
23 ;;; "succeed" in finding an inline expansion, but I didn't think that the
24 ;;; compiler would actually choose of its own free will to do local inlining,
25 ;;; even though the standard says that's what it *can* do unless told not to.
27 ;;; Then, if it does inline MAKE-RESTART, a problem occurs in RESTART-BIND
28 ;;; with a TRULY-DYNAMIC-EXTENT declaration, because restarts go on the stack
29 ;;; that can't. But I think that itself is a bug. They *should* go on the stack,
30 ;;; because the chain of cons cells pointing to them is on the stack.
31 ;;; The restarts are otherwise inaccessible. I'm pretty sure this
32 ;;; is actually a compiler bug.
34 ;;; So in a nutshell, there are 2 issues:
35 ;;; (1) DX seems legitimate, but there may be a compiler bug.
36 ;;; (2) The logic about when to assume that a structure constructor
37 ;;; can automatically be inlined is tricker than its author understands.
39 (declaim (notinline make-restart))
41 ;;;; This defstruct should appear before any use of WITH-CONDITION-RESTARTS
42 ;;;; so that the slot accessors are transformed.
44 (defstruct (restart (:constructor make-restart
45 ;; Having TEST-FUNCTION at the end allows
46 ;; to not replicate its default value in RESTART-BIND.
47 (name function
48 &optional report-function
49 interactive-function
50 test-function))
51 (:copier nil) (:predicate nil))
52 (name (missing-arg) :type symbol :read-only t)
53 (function (missing-arg) :type function :read-only t)
54 (report-function nil :type (or null function) :read-only t)
55 (interactive-function nil :type (or null function) :read-only t)
56 (test-function (lambda (cond) (declare (ignore cond)) t) :type function :read-only t)
57 ;; the list of conditions which are currently associated to the
58 ;; restart. maintained by WITH-CONDITION-RESTARTS in a neither
59 ;; thread- nor interrupt-safe way. This should not be a problem
60 ;; however, since safe uses of restarts have to assume dynamic
61 ;; extent.
62 (associated-conditions '() :type list))
64 #!-sb-fluid (declaim (freeze-type restart))