DX for sparc.
David Lichteblau)
* optimization: DYNAMIC-EXTENT declarations for lists and closures
are treated as requests for stack allocation on the x86-64,
- Alpha-32, and PPC platforms.
+ Alpha-32, PPC and SPARC platforms.
* contrib improvement: it's harder to cause SOCKET-CLOSE to close()
the wrong file descriptor; implementation of SOCKET-OPEN-P.
(thanks to Tony Martinez)
if [ "$sbcl_os" = "sunos" ] || [ "$sbcl_os" = "linux" ]; then
printf ' :linkage-table' >> $ltf
fi
+ printf ' :stack-allocatable-closures' >> $ltf
elif [ "$sbcl_arch" = "alpha" ]; then
printf ' :stack-allocatable-closures' >> $ltf
else
(in-package "SB!VM")
\f
;;;; LIST and LIST*
+(defoptimizer (list stack-allocate-result) ((&rest args))
+ (not (null args)))
+(defoptimizer (list* stack-allocate-result) ((&rest args))
+ (not (null (rest args))))
(define-vop (list-or-list*)
(:args (things :more t))
(:results (result :scs (descriptor-reg)))
(:variant-vars star)
(:policy :safe)
+ (:node-var node)
(:generator 0
(cond ((zerop num)
(move result null-tn))
(control-stack
(load-stack-tn temp ,tn)
temp)))))
- (let* ((cons-cells (if star (1- num) num))
+ (let* ((dx-p (node-stack-allocate-p node))
+ (cons-cells (if star (1- num) num))
(alloc (* (pad-data-block cons-size) cons-cells)))
- (pseudo-atomic (:extra alloc)
- (inst andn res alloc-tn lowtag-mask)
- (inst or res list-pointer-lowtag)
+ (pseudo-atomic (:extra (if dx-p 0 alloc))
+ (let ((allocation-area-tn (if dx-p csp-tn alloc-tn)))
+ (when dx-p
+ (align-csp res))
+ (inst andn res allocation-area-tn lowtag-mask)
+ (inst or res list-pointer-lowtag)
+ (when dx-p
+ (inst add csp-tn csp-tn alloc)))
(move ptr res)
(dotimes (i (1- cons-cells))
(storew (maybe-load (tn-ref-tn things)) ptr
(define-vop (make-closure)
(:args (function :to :save :scs (descriptor-reg)))
(:info length stack-allocate-p)
- (:ignore stack-allocate-p)
(:temporary (:scs (non-descriptor-reg)) temp)
(:results (result :scs (descriptor-reg)))
(:generator 10
- (let ((size (+ length closure-info-offset)))
- (pseudo-atomic (:extra (pad-data-block size))
- (inst andn result alloc-tn lowtag-mask)
- (inst or result fun-pointer-lowtag)
+ (let* ((size (+ length closure-info-offset))
+ (alloc-size (pad-data-block size)))
+ (pseudo-atomic (:extra (if stack-allocate-p 0 alloc-size))
+ (cond (stack-allocate-p
+ (align-csp temp)
+ (inst andn result csp-tn lowtag-mask)
+ (inst or result fun-pointer-lowtag)
+ (inst add csp-tn alloc-size))
+ (t
+ (inst andn result alloc-tn lowtag-mask)
+ (inst or result fun-pointer-lowtag)))
(inst li temp (logior (ash (1- size) n-widetag-bits) closure-header-widetag))
- (storew temp result 0 fun-pointer-lowtag)))
- (storew function result closure-fun-slot fun-pointer-lowtag)))
+ (storew temp result 0 fun-pointer-lowtag))
+ (storew function result closure-fun-slot fun-pointer-lowtag))))
;;; The compiler likes to be able to directly make value cells.
(define-vop (make-value-cell)
(:variant 0 0)
(:translate %more-arg))
-
;;; Turn more arg (context, count) into a list.
+(defoptimizer (%listify-rest-args stack-allocate-result) ((&rest args))
+ t)
+
(define-vop (listify-rest-args)
(:args (context-arg :target context :scs (descriptor-reg))
(count-arg :target count :scs (any-reg)))
(:results (result :scs (descriptor-reg)))
(:translate %listify-rest-args)
(:policy :safe)
+ (:node-var node)
(:generator 20
- (move context context-arg)
- (move count count-arg)
- ;; Check to see if there are any arguments.
- (inst cmp count)
- (inst b :eq done)
- (move result null-tn)
-
- ;; We need to do this atomically.
- (pseudo-atomic ()
- (assemble ()
+ (let* ((enter (gen-label))
+ (loop (gen-label))
+ (done (gen-label))
+ (dx-p (node-stack-allocate-p node))
+ (alloc-area-tn (if dx-p csp-tn alloc-tn)))
+ (move context context-arg)
+ (move count count-arg)
+ ;; Check to see if there are any arguments.
+ (inst cmp count)
+ (inst b :eq done)
+ (move result null-tn)
+
+ ;; We need to do this atomically.
+ (pseudo-atomic ()
+ (when dx-p
+ (align-csp temp))
;; Allocate a cons (2 words) for each item.
- (inst andn result alloc-tn lowtag-mask)
+ (inst andn result alloc-area-tn lowtag-mask)
(inst or result list-pointer-lowtag)
(move dst result)
(inst sll temp count 1)
(inst b enter)
- (inst add alloc-tn temp)
+ (inst add alloc-area-tn temp)
;; Compute the next cons and store it in the current one.
- LOOP
+ (emit-label loop)
(inst add dst dst (* 2 n-word-bytes))
(storew dst dst -1 list-pointer-lowtag)
;; Grab one value.
- ENTER
+ (emit-label enter)
(loadw temp context)
(inst add context context n-word-bytes)
(storew temp dst 0 list-pointer-lowtag)
;; NIL out the last cons.
- (storew null-tn dst 1 list-pointer-lowtag)))
- DONE))
+ (storew null-tn dst 1 list-pointer-lowtag))
+ (emit-label done))))
;;; Return the location and size of the more arg glob created by Copy-More-Arg.
(storew ,temp-tn ,result-tn 0 other-pointer-lowtag)
,@body)))
+(defun align-csp (temp)
+ (let ((aligned (gen-label)))
+ ;; FIXME: why use a TEMP? Why not just ZERO-TN?
+ (inst andcc temp csp-tn lowtag-mask)
+ (if (member :sparc-v9 *backend-subfeatures*)
+ (inst b :eq aligned :pt)
+ (inst b :eq aligned))
+ (storew zero-tn csp-tn 0) ; sneaky use of delay slot
+ (inst add csp-tn csp-tn n-word-bytes)
+ (emit-label aligned)))
\f
;;;; Error Code
(eval-when (:compile-toplevel :load-toplevel :execute)
(funcall thunk))
(assert (< (- (get-bytes-consed) before) times))))
-#+(or x86 x86-64 alpha ppc)
+#+(or x86 x86-64 alpha ppc sparc)
(progn
(assert-no-consing (dxclosure 42))
(assert-no-consing (dxlength 1 2 3))
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.1.62"
+"0.9.1.63"