0.8.21.46:
authorAlexey Dejneka <adejneka@comail.ru>
Sat, 16 Apr 2005 06:18:30 +0000 (06:18 +0000)
committerAlexey Dejneka <adejneka@comail.ru>
Sat, 16 Apr 2005 06:18:30 +0000 (06:18 +0000)
        * On X86 simple forms of MAKE-ARRAY can allocate result on
          stack.
        ... ALLOCATE-VECTOR is now a VOP on X86.

NEWS
doc/manual/efficiency.texinfo
src/assembly/x86/array.lisp
src/compiler/x86/alloc.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index c142eb1..d5d7f50 100644 (file)
--- 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
index fb20ff1..6931ed0 100644 (file)
@@ -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
index 7662427..c79c5de 100644 (file)
 
 (in-package "SB!VM")
 \f
-;;;; 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))
-\f
 ;;;; Note: CMU CL had assembly language primitives for hashing strings,
 ;;;; but SBCL doesn't.
index 03f9b9e..88c7af9 100644 (file)
   (:variant t))
 \f
 ;;;; 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)
index fe9e1d4..eeb1516 100644 (file)
@@ -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"