From 84747bda2fd9197226b0c67e074aaa770c799eb3 Mon Sep 17 00:00:00 2001 From: Alexey Dejneka Date: Sat, 16 Apr 2005 06:18:30 +0000 Subject: [PATCH] 0.8.21.46: * On X86 simple forms of MAKE-ARRAY can allocate result on stack. ... ALLOCATE-VECTOR is now a VOP on X86. --- NEWS | 2 ++ doc/manual/efficiency.texinfo | 9 +++++++++ src/assembly/x86/array.lisp | 24 ++---------------------- src/compiler/x86/alloc.lisp | 27 +++++++++++++++++++++++++++ version.lisp-expr | 2 +- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/NEWS b/NEWS index c142eb1..d5d7f50 100644 --- a/NEWS +++ b/NEWS @@ -53,6 +53,8 @@ changes in sbcl-0.8.22 relative to sbcl-0.8.21: * bug fix: redefining a class definition which failed due to a previous accessor / function clash now works (but see BUGS entry #380 for more problems in this area). (thanks to Zach Beane) + * on x86 compiler supports stack allocation of results of simple + calls of MAKE-ARRAY, bound to variables, declared DYNAMIC-EXTENT. * fixed some bugs related to Unicode integration: ** the restarts for recovering from input and output encoding errors only appear when there is in fact such an error to diff --git a/doc/manual/efficiency.texinfo b/doc/manual/efficiency.texinfo index fb20ff1..6931ed0 100644 --- a/doc/manual/efficiency.texinfo +++ b/doc/manual/efficiency.texinfo @@ -193,6 +193,15 @@ or @end lisp @item +Stack allocation of simple forms of @code{make-array}, whose result is +bound to a variable, declared @code{dynamic-extent}. The resulting +array should be one-dimensional, the only allowed keyword argument is +@code{:element-type}. + +Notice, that stack space is limited, so allocation of a large vector +may cause stack overflow and abnormal termination of the SBCL process. + +@item Stack allocation of closures, defined with @code{flet} or @code{labels} with a bound declaration @code{dynamic-extent}. Closed-over variables, which are assigned (either inside or outside diff --git a/src/assembly/x86/array.lisp b/src/assembly/x86/array.lisp index 7662427..c79c5de 100644 --- a/src/assembly/x86/array.lisp +++ b/src/assembly/x86/array.lisp @@ -12,28 +12,8 @@ (in-package "SB!VM") -;;;; allocation +;;;; Note: On other platforms ALLOCATE-VECTOR is an assembly routine, +;;;; but on X86 it is a VOP. -(define-assembly-routine (allocate-vector - (:policy :fast-safe) - (:translate allocate-vector) - (:arg-types positive-fixnum - positive-fixnum - positive-fixnum)) - ((:arg type unsigned-reg eax-offset) - (:arg length any-reg ebx-offset) - (:arg words any-reg ecx-offset) - (:res result descriptor-reg edx-offset)) - (inst mov result (+ (1- (ash 1 n-lowtag-bits)) - (* vector-data-offset n-word-bytes))) - (inst add result words) - (inst and result (lognot lowtag-mask)) - (pseudo-atomic - (allocation result result) - (inst lea result (make-ea :byte :base result :disp other-pointer-lowtag)) - (storew type result 0 other-pointer-lowtag) - (storew length result vector-length-slot other-pointer-lowtag)) - (inst ret)) - ;;;; Note: CMU CL had assembly language primitives for hashing strings, ;;;; but SBCL doesn't. diff --git a/src/compiler/x86/alloc.lisp b/src/compiler/x86/alloc.lisp index 03f9b9e..88c7af9 100644 --- a/src/compiler/x86/alloc.lisp +++ b/src/compiler/x86/alloc.lisp @@ -72,6 +72,33 @@ (:variant t)) ;;;; special-purpose inline allocators +(defoptimizer (allocate-vector stack-allocate-result) ((type length words)) + t) + +(define-vop (allocate-vector) + (:args (type :scs (unsigned-reg)) + (length :scs (any-reg)) + (words :scs (any-reg))) + (:results (result :scs (descriptor-reg) :from :load)) + (:arg-types positive-fixnum + positive-fixnum + positive-fixnum) + (:translate allocate-vector) + (:policy :fast-safe) + (:node-var node) + (:generator 100 + (inst lea result (make-ea :byte :base words :disp + (+ (1- (ash 1 n-lowtag-bits)) + (* vector-data-offset n-word-bytes)))) + (inst and result (lognot lowtag-mask)) + (let ((stack-allocate-p (awhen (sb!c::node-lvar node) + (sb!c::lvar-dynamic-extent it)))) + (maybe-pseudo-atomic stack-allocate-p + ;; FIXME: It would be good to check for stack overflow here. + (allocation result result node stack-allocate-p) + (inst lea result (make-ea :byte :base result :disp other-pointer-lowtag)) + (storew type result 0 other-pointer-lowtag) + (storew length result vector-length-slot other-pointer-lowtag))))) (define-vop (allocate-code-object) (:args (boxed-arg :scs (any-reg) :target boxed) diff --git a/version.lisp-expr b/version.lisp-expr index fe9e1d4..eeb1516 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; 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.8.21.45" +"0.8.21.46" -- 1.7.10.4