Changeset 10496


Ignore:
Timestamp:
Aug 19, 2008, 12:24:21 PM (11 years ago)
Author:
gb
Message:

There were 2 versions of X862-LONG-CONSTANT-P. The one that we in
effect (the second one defined in this file) was leftover from MCL,
and allowed strings of length 4 (and symbols whose pnames were of
length 4) to be interpreted as "long" constants (this was leftover
support for "OSTypes"); it also allowed integer constants of unspecified
width and signedness.

Replace that with (and change the one caller to use) X862-INTEGER-CONSTANT-P,
which takes an acode form and a mode name and returns an integer if the
form represents an constant integer of the indicated type.

(In other words:

? (#_malloc :four)

Error: value :FOUR is not of the expected type (UNSIGNED-BYTE 64).

? (defun foo ()

(#_malloc :four))

FOO

shouldn't work (in compiled code) as an obscure way to allocate
#x666F7572 bytes, and

? (defun foo ()

(#_malloc -10))

  • and other cases involving integer constants of the wrong width/

signedness - shouldn't work at all.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/X86/x862.lisp

    r10451 r10496  
    29722972
    29732973 
    2974 (defun x862-long-constant-p (form)
    2975   (setq form (acode-unwrapped-form form))
    2976   (or (acode-fixnum-form-p form)
    2977       (and (acode-p form)
    2978            (eq (acode-operator form) (%nx1-operator immediate))
    2979            (setq form (%cadr form))
    2980            (if (integerp form)
    2981              form))))
     2974(defun x862-integer-constant-p (form mode)
     2975  (let* ((val
     2976         (or (acode-fixnum-form-p (setq form (acode-unwrapped-form form)))
     2977             (and (acode-p form)
     2978                  (eq (acode-operator form) (%nx1-operator immediate))
     2979                  (setq form (%cadr form))
     2980                  (if (typep form 'integer)
     2981                    form)))))
     2982    (and val (%typep val (mode-specifier-type mode)) val)))
     2983         
    29822984
    29832985
     
    30323034
    30333035
    3034 
    3035 
    3036 ;;; treat form as a 32-bit immediate value and load it into immreg.
    3037 ;;; This is the "lenient" version of 32-bit-ness; OSTYPEs and chars
    3038 ;;; count, and we don't care about the integer's sign.
    3039 
    30403036(defun x862-unboxed-integer-arg-to-reg (seg form immreg &optional ffi-arg-type)
    30413037  (let* ((mode (ecase ffi-arg-type
     
    30513047         (modeval (gpr-mode-name-value mode)))
    30523048    (with-x86-local-vinsn-macros (seg)
    3053       (let* ((value (x862-long-constant-p form)))
     3049      (let* ((value (x862-integer-constant-p form mode)))
    30543050        (if value
    30553051          (progn
    30563052            (unless (typep immreg 'lreg)
    30573053              (setq immreg (make-unwired-lreg immreg :mode modeval)))
    3058             (x862-lri seg immreg value)
     3054            (if (< value 0)
     3055              (x862-lri seg immreg value)
     3056              (x862-lriu seg immreg value))
    30593057            immreg)
    30603058          (progn
     
    51545152    cd))
    51555153
    5156 (defun x862-long-constant-p (form)
    5157   (setq form (acode-unwrapped-form form))
    5158   (or (acode-fixnum-form-p form)
    5159       (and (acode-p form)
    5160            (eq (acode-operator form) (%nx1-operator immediate))
    5161            (setq form (%cadr form))
    5162            (if (integerp form)
    5163              form
    5164              (progn
    5165                (if (symbolp form) (setq form (symbol-name form)))
    5166                (if (and (stringp form) (eql (length form) 4))
    5167                  (logior (ash (%char-code (char form 0)) 24)
    5168                          (ash (%char-code (char form 1)) 16)
    5169                          (ash (%char-code (char form 2)) 8)
    5170                          (%char-code (char form 3)))
    5171                  (if (characterp form) (%char-code form))))))))
     5154
    51725155
    51735156;;; execute body, cleanup afterwards (if need to)
Note: See TracChangeset for help on using the changeset viewer.