X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fexhaust.lisp;h=f35ac45c645ae9a69e5c120f8fc3ae451b610306;hb=cee8ef591040db9a79cdd19297867672a9529051;hp=218843a26606f8974af5c408d49f5453785aaa9a;hpb=2481b0d0f223640c43032f75b689608f8fa332db;p=sbcl.git diff --git a/src/code/exhaust.lisp b/src/code/exhaust.lisp index 218843a..f35ac45 100644 --- a/src/code/exhaust.lisp +++ b/src/code/exhaust.lisp @@ -11,55 +11,4 @@ ;;;; files for more information. (in-package "SB!KERNEL") - -;;; a soft limit on stack overflow; the boundary beyond which the -;;; control stack will be considered to've overflowed -;;; -;;; When stack overflow is detected, this soft limit is to be bound to -;;; a new value closer to the hard limit (allowing some more space for -;;; error handling) around the call to ERROR. -;;; -;;; FIXME: Maybe (probably?) this should be in SB!VM. And maybe the -;;; size of the buffer zone should be set in src/compiler/cpu/parms.lisp -;;; instead of constantly 1Mb for all CPU architectures? -(defvar *stack-exhaustion-sap* - ;; (initialized in cold init) - ) -(defun !exhaust-cold-init () - (let (;; initial difference between soft limit and hard limit - (initial-slack (expt 2 20))) - (setf *stack-exhaustion-sap* - (int-sap #!+stack-grows-downward (+ sb!vm:control-stack-start - initial-slack) - #!+stack-grows-upward (- sb!vm:control-stack-end - initial-slack))))) - -;;; FIXME: Even though this is only called when (> SAFETY (MAX SPEED SPACE)) -;;; it's still annoyingly wasteful for it to be a full function call. -;;; It should probably be a VOP calling an assembly routine or something -;;; like that. -(defun %detect-stack-exhaustion () - (when (#!+stack-grows-upward sap>= - #!+stack-grows-downward sap<= - (current-sp) - *stack-exhaustion-sap*) - (let ((*stack-exhaustion-sap* (revised-stack-exhaustion-sap))) - (warn "~@") - (error "The system control stack was exhausted.")))) - -;;; Return a revised value for the *STACK-EXHAUSTION-SAP* soft limit, -;;; allocating half the remaining space up to the hard limit in order -;;; to allow interactive debugging to be used around the point of a -;;; stack overflow failure without immediately failing again from the -;;; (continuing) stack overflow. -(defun revised-stack-exhaustion-sap () - (let* ((old-slack - #!+stack-grows-upward (- sb!vm:control-stack-end - (sap-int *stack-exhaustion-sap*)) - #!+stack-grows-downward (- (sap-int *stack-exhaustion-sap*) - sb!vm:control-stack-start)) - (new-slack (ash old-slack -1))) - (int-sap - #!+stack-grows-upward (- sb!vm:control-stack-end new-slack) - #!+stack-grows-downward (+ sb!vm:control-stack-start new-slack)))) +(define-alien-routine reset-control-stack-guard-page sb!alien:void)