- ((extra &rest args) node block name words type lowtag inits)
- (let* ((cont (node-cont node))
- (locs (continuation-result-tns cont
- (list *backend-t-primitive-type*)))
- (result (first locs)))
- (if (constant-continuation-p extra)
- (let ((words (+ (continuation-value extra) words)))
- (do-fixed-alloc node block name words type lowtag result))
- (vop var-alloc node block (continuation-tn node block extra) name words
- type lowtag result))
- (do-inits node block name result lowtag inits args)
- (move-continuation-result node block locs cont)))
-
-;;; KLUDGE: this is set up automatically in #!-SB-THREAD builds by the
-;;; :SET-TRANS thing in objdef.lisp. However, for #!+SB-THREAD builds
-;;; we need to use a special VOP, so we have to do this by hand.
-;;; -- CSR, 2003-05-08
-#!+sb-thread
+ ((extra &rest args) node block name words type lowtag inits)
+ (let* ((lvar (node-lvar node))
+ (locs (lvar-result-tns lvar (list *backend-t-primitive-type*)))
+ (result (first locs)))
+ (if (constant-lvar-p extra)
+ (let ((words (+ (lvar-value extra) words)))
+ (emit-fixed-alloc node block name words type lowtag result lvar))
+ (vop var-alloc node block (lvar-tn node block extra) name words
+ type lowtag result))
+ (emit-inits node block name result lowtag nil inits args)
+ (move-lvar-result node block locs lvar)))
+
+(defoptimizer ir2-convert-structure-allocation
+ ((dd slot-specs &rest args) node block name words type lowtag inits)
+ (let* ((lvar (node-lvar node))
+ (locs (lvar-result-tns lvar (list *backend-t-primitive-type*)))
+ (result (first locs)))
+ (aver (constant-lvar-p dd))
+ (aver (constant-lvar-p slot-specs))
+ (let* ((c-dd (lvar-value dd))
+ (c-slot-specs (lvar-value slot-specs))
+ (words (+ (sb!kernel::dd-instance-length c-dd) words)))
+ (emit-fixed-alloc node block name words type lowtag result lvar)
+ (emit-inits node block name result lowtag words `((:dd . ,c-dd) ,@c-slot-specs) args)
+ (move-lvar-result node block locs lvar))))
+
+(defoptimizer (initialize-vector ir2-convert)
+ ((vector &rest initial-contents) node block)
+ (let* ((vector-ctype (lvar-type vector))
+ (elt-ctype (if (array-type-p vector-ctype)
+ (array-type-specialized-element-type vector-ctype)
+ (bug "Unknow vector type in IR2 conversion for ~S."
+ 'initialize-vector)))
+ (saetp (find-saetp-by-ctype elt-ctype))
+ (lvar (node-lvar node))
+ (locs (lvar-result-tns lvar (list (primitive-type vector-ctype))))
+ (result (first locs))
+ (elt-ptype (primitive-type elt-ctype))
+ (tmp (make-normal-tn elt-ptype)))
+ (emit-move node block (lvar-tn node block vector) result)
+ (flet ((compute-setter ()
+ (macrolet
+ ((frob ()
+ (let ((*package* (find-package :sb!vm))
+ (clauses nil))
+ (map nil (lambda (s)
+ (when (sb!vm:saetp-specifier s)
+ (push
+ `(,(sb!vm:saetp-typecode s)
+ (lambda (index tn)
+ #!+(or x86 x86-64)
+ (vop ,(symbolicate "DATA-VECTOR-SET-WITH-OFFSET/"
+ (sb!vm:saetp-primitive-type-name s))
+ node block result index tn 0 tn)
+ #!-(or x86 x86-64)
+ (vop ,(symbolicate "DATA-VECTOR-SET/"
+ (sb!vm:saetp-primitive-type-name s))
+ node block result index tn tn)))
+ clauses)))
+ sb!vm:*specialized-array-element-type-properties*)
+ `(ecase (sb!vm:saetp-typecode saetp)
+ ,@(nreverse clauses)))))
+ (frob)))
+ (tnify (index)
+ (emit-constant index)))
+ (let ((setter (compute-setter))
+ (length (length initial-contents)))
+ (dotimes (i length)
+ (emit-move node block (lvar-tn node block (pop initial-contents)) tmp)
+ (funcall setter (tnify i) tmp))))
+ (move-lvar-result node block locs lvar)))
+
+;;; :SET-TRANS (in objdef.lisp DEFINE-PRIMITIVE-OBJECT) doesn't quite
+;;; cut it for symbols, where under certain compilation options
+;;; (e.g. #!+SB-THREAD) we have to do something complicated, rather
+;;; than simply set the slot. So we build the IR2 converting function
+;;; by hand. -- CSR, 2003-05-08