0.8.0.78.vector-nil-string.1:
[sbcl.git] / src / compiler / array-tran.lisp
index 3384b9f..e7aec41 100644 (file)
 (defoptimizer (%with-array-data derive-type) ((array start end))
   (let ((atype (continuation-type array)))
     (when (array-type-p atype)
-      (values-specifier-type
-       `(values (simple-array ,(type-specifier
-                               (array-type-specialized-element-type atype))
-                             (*))
-               index index index)))))
+      (specifier-type
+       `(simple-array ,(type-specifier
+                       (array-type-specialized-element-type atype))
+                     (*))))))
 
 (defoptimizer (array-row-major-index derive-type) ((array &rest indices))
   (assert-array-rank array (length indices))
                     (continuation-value element-type))
                    (t
                     '*))
-            ,(cond ((not simple)
-                    '*)
-                   ((constant-continuation-p dims)
-                    (let ((val (continuation-value dims)))
-                      (if (listp val) val (list val))))
+            ,(cond ((constant-continuation-p dims)
+                    (let* ((val (continuation-value dims))
+                          (cdims (if (listp val) val (list val))))
+                     (if simple
+                         cdims
+                         (length cdims))))
                    ((csubtypep (continuation-type dims)
                                (specifier-type 'integer))
                     '(*))
        `(;; Erm.  Yeah.  There aren't a lot of things that make sense
         ;; for an initial element for (ARRAY NIL). -- CSR, 2002-03-07
         (nil '#:mu 0 ,sb!vm:simple-array-nil-widetag)
-        (base-char ,(code-char 0) 8 ,sb!vm:simple-string-widetag
+        (base-char ,(code-char 0) 8 ,sb!vm:simple-base-string-widetag
                    ;; (SIMPLE-STRINGs are stored with an extra trailing
                    ;; #\NULL for convenience in calling out to C.)
                    :n-pad-elements 1)
           (when (constant-continuation-p initial-element)
             (let ((value (continuation-value initial-element)))
               (cond
-                ((not (csubtypep (ctype-of value)
-                                 (saetp-ctype saetp)))
+                ((not (ctypep value (saetp-ctype saetp)))
                  ;; this case will cause an error at runtime, so we'd
                  ;; better WARN about it now.
                  (compiler-warn "~@<~S is not a ~S (which is the ~
                                 value
                                 (type-specifier (saetp-ctype saetp))
                                 eltype))
-                ((not (csubtypep (ctype-of value) eltype-type))
+                ((not (ctypep value eltype-type))
                  ;; this case will not cause an error at runtime, but
                  ;; it's still worth STYLE-WARNing about.
                  (compiler-style-warn "~S is not a ~S."
 
 ;;; If a simple array with known dimensions, then VECTOR-LENGTH is a
 ;;; compile-time constant.
-(deftransform vector-length ((vector) ((simple-array * (*))))
+(deftransform vector-length ((vector))
   (let ((vtype (continuation-type vector)))
-    (if (array-type-p vtype)
+    (if (and (array-type-p vtype)
+            (not (array-type-complexp vtype)))
        (let ((dim (first (array-type-dimensions vtype))))
          (when (eq dim '*) (give-up-ir1-transform))
          dim)
 ;;; Primitive used to verify indices into arrays. If we can tell at
 ;;; compile-time or we are generating unsafe code, don't bother with
 ;;; the VOP.
-(deftransform %check-bound ((array dimension index))
-  (unless (constant-continuation-p dimension)
-    (give-up-ir1-transform))
-  (let ((dim (continuation-value dimension)))
-    `(the (integer 0 ,dim) index)))
-(deftransform %check-bound ((array dimension index) * *
-                           :policy (and (> speed safety) (= safety 0)))
-  'index)
+(deftransform %check-bound ((array dimension index) * * :node node)
+  (cond ((policy node (and (> speed safety) (= safety 0)))
+         'index)
+        ((not (constant-continuation-p dimension))
+         (give-up-ir1-transform))
+        (t
+         (let ((dim (continuation-value dimension)))
+           `(the (integer 0 ,dim) index)))))
 \f
 ;;;; WITH-ARRAY-DATA