0.8.16.25:
[sbcl.git] / src / compiler / x86 / vm.lisp
index 6c3cec9..377b196 100644 (file)
 
 ;;; the size of an INTEGER representation of a SYSTEM-AREA-POINTER, i.e.
 ;;; size of a native memory address
-(deftype sap-int-type () '(unsigned-byte 32))
-;;; FIXME: This should just named be SAP-INT, not SAP-INT-TYPE. And
-;;; grep for SAPINT in the code and replace it with SAP-INT as
-;;; appropriate.
+(deftype sap-int () '(unsigned-byte 32))
 \f
 ;;;; register specs
 
@@ -34,7 +31,7 @@
                     ;; EVAL-WHEN is necessary because stuff like #.EAX-OFFSET
                     ;; (in the same file) depends on compile-time evaluation
                     ;; of the DEFCONSTANT. -- AL 20010224
-                   (defconstant ,offset-sym ,offset))
+                   (def!constant ,offset-sym ,offset))
                  (setf (svref ,names-vector ,offset-sym)
                        ,(symbol-name name)))))
           ;; FIXME: It looks to me as though DEFREGSET should also
@@ -97,7 +94,7 @@
   ;; registers used to pass arguments
   ;;
   ;; the number of arguments/return values passed in registers
-  (defconstant  register-arg-count 3)
+  (def!constant  register-arg-count 3)
   ;; names and offsets for registers used to pass arguments
   (eval-when (:compile-toplevel :load-toplevel :execute)
     (defparameter *register-arg-names* '(edx edi esi)))
 ;;; a handy macro so we don't have to keep changing all the numbers whenever
 ;;; we insert a new storage class
 ;;;
-;;; FIXME: This macro is not needed in the runtime target.
-(defmacro define-storage-classes (&rest classes)
+(defmacro !define-storage-classes (&rest classes)
   (collect ((forms))
     (let ((index 0))
       (dolist (class classes)
               (constant-name (symbolicate sc-name "-SC-NUMBER")))
          (forms `(define-storage-class ,sc-name ,index
                    ,@(cdr class)))
-         (forms `(defconstant ,constant-name ,index))
+         (forms `(def!constant ,constant-name ,index))
          (incf index))))
     `(progn
        ,@(forms))))
 ;;;
 ;;; (What a KLUDGE! Anyone who wants to come in and clean up this mess
 ;;; has my gratitude.) (FIXME: Maybe this should be me..)
-(defconstant sb!vm::kludge-nondeterministic-catch-block-size 6)
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (def!constant kludge-nondeterministic-catch-block-size 6))
 
-(define-storage-classes
+(!define-storage-classes
 
-  ;; non-immediate contstants in the constant pool
+  ;; non-immediate constants in the constant pool
   (constant constant)
 
   ;; some FP constants can be generated in the i387 silicon
   ;; the non-descriptor stacks
   (signed-stack stack)                 ; (signed-byte 32)
   (unsigned-stack stack)               ; (unsigned-byte 32)
-  (base-char-stack stack)              ; non-descriptor characters.
+  (character-stack stack)              ; non-descriptor characters.
   (sap-stack stack)                    ; System area pointers.
   (single-stack stack)                 ; single-floats
   (double-stack stack :element-size 2) ; double-floats.
                  :alternate-scs (control-stack))
 
   ;; non-descriptor characters
-  (base-char-reg registers
-                :locations #.*byte-regs*
+  (character-reg registers
+                :locations #!-sb-unicode #.*byte-regs*
+                            #!+sb-unicode #.*dword-regs*
+                 #!-sb-unicode #!-sb-unicode
                 :reserve-locations (#.ah-offset #.al-offset)
                 :constant-scs (immediate)
                 :save-p t
-                :alternate-scs (base-char-stack))
+                :alternate-scs (character-stack))
 
   ;; non-descriptor SAPs (arbitrary pointers into address space)
   (sap-reg registers
                    :alternate-scs (complex-long-stack))
 
   ;; a catch or unwind block
-  (catch-block stack
-              :element-size sb!vm::kludge-nondeterministic-catch-block-size))
+  (catch-block stack :element-size kludge-nondeterministic-catch-block-size))
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
-(defparameter *byte-sc-names* '(base-char-reg byte-reg base-char-stack))
+(defparameter *byte-sc-names*
+  '(#!-sb-unicode character-reg byte-reg #!-sb-unicode character-stack))
 (defparameter *word-sc-names* '(word-reg))
 (defparameter *dword-sc-names*
   '(any-reg descriptor-reg sap-reg signed-reg unsigned-reg control-stack
-    signed-stack unsigned-stack sap-stack single-stack constant))
+    signed-stack unsigned-stack sap-stack single-stack
+    #!+sb-unicode character-reg #!+sb-unicode character-stack constant))
 ;;; added by jrd. I guess the right thing to do is to treat floats
 ;;; as a separate size...
 ;;;
 ;;; the appropriate SC number, otherwise return NIL.
 (!def-vm-support-routine immediate-constant-sc (value)
   (typecase value
-    ((or fixnum #-sb-xc-host system-area-pointer character)
+    ((or (integer #.sb!xc:most-negative-fixnum #.sb!xc:most-positive-fixnum)
+        #-sb-xc-host system-area-pointer character)
      (sc-number-or-lose 'immediate))
     (symbol
      (when (static-symbol-p value)
 ;;;; miscellaneous function call parameters
 
 ;;; offsets of special stack frame locations
-(defconstant ocfp-save-offset 0)
-(defconstant return-pc-save-offset 1)
-(defconstant code-save-offset 2)
+(def!constant ocfp-save-offset 0)
+(def!constant return-pc-save-offset 1)
+(def!constant code-save-offset 2)
 
 ;;; FIXME: This is a bad comment (changed since when?) and there are others
 ;;; like it in this file. It'd be nice to clarify them. Failing that deleting
 ;;; them or flagging them with KLUDGE might be better than nothing.
 ;;;
 ;;; names of these things seem to have changed. these aliases by jrd
-(defconstant lra-save-offset return-pc-save-offset)
+(def!constant lra-save-offset return-pc-save-offset)
 
-(defconstant cfp-offset ebp-offset)    ; pfw - needed by stuff in /code
+(def!constant cfp-offset ebp-offset)   ; pfw - needed by stuff in /code
                                        ; related to signal context stuff
 
 ;;; This is used by the debugger.
-(defconstant single-value-return-byte-offset 2)
+(def!constant single-value-return-byte-offset 2)
 \f
 ;;; This function is called by debug output routines that want a pretty name
 ;;; for a TN's location. It returns a thing that can be printed with PRINC.
                  (< -1 offset (length name-vec))
                  (svref name-vec offset))
             ;; FIXME: Shouldn't this be an ERROR?
-            (format nil "<unknown reg: off=~D, sc=~A>" offset sc-name))))
+            (format nil "<unknown reg: off=~W, sc=~A>" offset sc-name))))
       (float-registers (format nil "FR~D" offset))
       (stack (format nil "S~D" offset))
       (constant (format nil "Const~D" offset))
       (immediate-constant "Immed")
       (noise (symbol-name (sc-name sc))))))
 ;;; FIXME: Could this, and everything that uses it, be made #!+SB-SHOW?
+
 \f
 ;;; The loader uses this to convert alien names to the form they need in
 ;;; the symbol table (for example, prepending an underscore).
 (defun extern-alien-name (name)
-  (declare (type simple-string name))
-  name)
+  (declare (type string name))
+  ;; ELF ports currently don't need any prefix
+  (typecase name
+    (simple-base-string name)
+    (base-string (coerce name 'simple-base-string))
+    (t (handler-case (coerce name 'simple-base-string)
+        (type-error () (error "invalid external alien name: ~S" name))))))