0.9.18.71: fix build on Darwin 7.9.0 (OS X 10.3)
[sbcl.git] / src / code / interr.lisp
index 9a42a0c..d07f23d 100644 (file)
          :operands (list this that)))
 
 (deferr object-not-type-error (object type)
-  (error (if (and (typep object 'instance)
+  (error (if (and (%instancep object)
                   (layout-invalid (%instance-layout object)))
              'layout-invalid
              'type-error)
           (values "<error finding caller name -- trapped debug-condition>"
                   nil)))))
 
-(defun find-interrupted-name ()
-  (/show0 "entering FIND-INTERRUPTED-NAME")
+(defun find-interrupted-name-and-frame ()
+  (/show0 "entering FIND-INTERRUPTED-NAME-AND-FRAME")
   (if *finding-name*
       (values "<error finding interrupted name -- already finding name>" nil)
       (handler-case
 \f
 ;;;; INTERNAL-ERROR signal handler
 
-(defvar *internal-error-args*)
-
 (defun internal-error (context continuable)
   (declare (type system-area-pointer context))
   (declare (ignore continuable))
          (%primitive sb!c:halt))
 
        (multiple-value-bind (name sb!debug:*stack-top-hint*)
-           (find-interrupted-name)
+           (find-interrupted-name-and-frame)
          (/show0 "back from FIND-INTERRUPTED-NAME")
          (let ((fp (int-sap (sb!vm:context-register alien-context
                                                     sb!vm::cfp-offset)))
              "Control stack guard page temporarily disabled: proceed with caution~%")
      (error 'control-stack-exhausted))))
 
+;;; KLUDGE: we keep a single HEAP-EXHAUSTED-ERROR object around, so
+;;; that we don't need to allocate it when running out of memory. Similarly
+;;; we pass the amounts in special variables as there may be multiple threads
+;;; running into trouble at the same time. The condition is created by GC-REINIT.
+(defvar *heap-exhausted-error-condition*)
+(defvar *heap-exhausted-error-available-bytes*)
+(defvar *heap-exhausted-error-requested-bytes*)
+
+(defun heap-exhausted-error (available requested)
+  (infinite-error-protect
+   (let ((*heap-exhausted-error-available-bytes* available)
+         (*heap-exhausted-error-requested-bytes* requested))
+     (error *heap-exhausted-error-condition*))))
+
 (defun undefined-alien-variable-error ()
   (error 'undefined-alien-variable-error))