1.0.28.58: more MAKE-ARRAY goodness
[sbcl.git] / tests / compiler.impure.lisp
index 151f400..26b12ce 100644 (file)
 (setf *mystery* :mystery)
 (assert (eq :ok (test-mystery (make-thing :slot :mystery))))
 
+;;; optimizing make-array
+(defun count-code-callees (f)
+  (let ((code (sb-kernel:fun-code-header f))
+        (n 0))
+    (loop for i from sb-vm::code-constants-offset below (sb-kernel:get-header-data code)
+          for c = (sb-kernel:code-header-ref code i)
+          do (when (typep c 'fdefn)
+               (print c)
+               (incf n)))
+    n))
+(assert (zerop (count-code-callees
+                (compile nil
+                         `(lambda (x y z)
+                            (make-array '(3) :initial-contents (list x y z)))))))
+(assert (zerop (count-code-callees
+                (compile nil
+                         `(lambda (x y z)
+                            (make-array '3 :initial-contents (vector x y z)))))))
+(assert (zerop (count-code-callees
+                (compile nil
+                         `(lambda (x y z)
+                            (make-array '3 :initial-contents `(,x ,y ,z)))))))
+
 ;;; success