X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fgeneric%2Futils.lisp;h=bbe98d24e3ffa878b529eaa759d13b10f7d2bbcd;hb=b63c4fb9b98fa8188e17ba926e150ba417a74635;hp=b63b3c66bd87eb4c45e680f06456873350bb33e7;hpb=1bfc464c657a8f4ad24ef612f76a38d8f6f1bbad;p=sbcl.git diff --git a/src/compiler/generic/utils.lisp b/src/compiler/generic/utils.lisp index b63b3c6..bbe98d2 100644 --- a/src/compiler/generic/utils.lisp +++ b/src/compiler/generic/utils.lisp @@ -1,4 +1,5 @@ -;;;; utility functions needed by the back end to generate code +;;;; utility functions and macros needed by the back end to generate +;;;; code ;;;; This software is part of the SBCL system. See the README file for ;;;; more information. @@ -13,8 +14,8 @@ ;;; Make a fixnum out of NUM. (I.e. shift by two bits if it will fit.) (defun fixnumize (num) - (if (<= #x-20000000 num #x1fffffff) - (ash num 2) + (if (fixnump num) + (ash num (1- n-lowtag-bits)) (error "~W is too big for a fixnum." num))) ;;;; routines for dealing with static symbols @@ -58,3 +59,19 @@ (- list-pointer-lowtag) (* static-fun-index (pad-data-block fdefn-size)) (* fdefn-raw-addr-slot n-word-bytes)))) + +;;; Various error-code generating helpers +(defvar *adjustable-vectors* nil) + +(defmacro with-adjustable-vector ((var) &rest body) + `(let ((,var (or (pop *adjustable-vectors*) + (make-array 16 + :element-type '(unsigned-byte 8) + :fill-pointer 0 + :adjustable t)))) + (declare (type (vector (unsigned-byte 8) 16) ,var)) + (setf (fill-pointer ,var) 0) + (unwind-protect + (progn + ,@body) + (push ,var *adjustable-vectors*))))