;;; If there is any CHECK-xxx template for TYPE, then return it,
;;; otherwise return NIL.
+;;; The second value is T if the template needs TYPE to be passed
(defun type-check-template (type)
(declare (type ctype type))
(multiple-value-bind (check-ptype exact) (primitive-type type)
(if exact
(primitive-type-check check-ptype)
- (let ((name (hairy-type-check-template-name type)))
+ (multiple-value-bind (name type-needed)
+ (hairy-type-check-template-name type)
(if name
- (template-or-lose name)
+ (values (template-or-lose name) type-needed)
nil)))))
;;; Emit code in BLOCK to check that VALUE is of the specified TYPE,
(defun emit-type-check (node block value result type)
(declare (type tn value result) (type node node) (type ir2-block block)
(type ctype type))
- (emit-move-template node block (type-check-template type) value result)
+ (multiple-value-bind (template type-needed) (type-check-template type)
+ (if type-needed
+ (emit-load-template node block template value result (list type))
+ (emit-move-template node block template value result)))
(values))
;;; Allocate an indirect value cell.
(vop fast-symbol-global-value node block name-tn res)
(vop symbol-global-value node block name-tn res))))
(:global-function
- (let ((fdefn-tn (make-load-time-constant-tn :fdefinition name)))
- (if unsafe
- (vop fdefn-fun node block fdefn-tn res)
- (vop safe-fdefn-fun node block fdefn-tn res)))))))
+ (cond #-sb-xc-host
+ ((and (info :function :definition name)
+ (info :function :info name))
+ ;; Known functions can be saved without going through fdefns,
+ ;; except during cross-compilation
+ (emit-move node block (make-load-time-constant-tn :known-fun name)
+ res))
+ (t
+ (let ((fdefn-tn (make-load-time-constant-tn :fdefinition name)))
+ (if unsafe
+ (vop fdefn-fun node block fdefn-tn res)
+ (vop safe-fdefn-fun node block fdefn-tn res)))))))))
;;; some sanity checks for a CLAMBDA passed to IR2-CONVERT-CLOSURE
(defun assertions-on-ir2-converted-clambda (clambda)
\f
(defoptimizer (mask-signed-field ir2-convert) ((width x) node block)
(block nil
+ (when (template-p (basic-combination-info node))
+ (ir2-convert-template node block)
+ (return))
(when (constant-lvar-p width)
(case (lvar-value width)
(#.(- sb!vm:n-word-bits sb!vm:n-fixnum-tag-bits)