Update of /cvsroot/sbcl/sbcl/src/compiler/generic
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv27440/src/compiler/generic
Modified Files:
vm-fndb.lisp vm-ir2tran.lisp vm-macs.lisp
Log Message:
1.0.17.4: support for dynamic-extent structures
* Replace %MAKE-INSTANCE-WITH-LAYOUT with %MAKE-STRUCTURE-INSTANCE,
which has an IR2 transform that can handle both initialization and
allocation of the structure. On x86 and x86-64 it can initialize
all slots, whereas on other platforms it only does the layout and
non-raw slots. (See RAW-INSTANCE-INIT/* below.)
* EMIT-INITS needs two new kinds of inits to handle: :SLOT for
instance slots, and :DD for the defstruct-description/layout.
* DEF-ALLOC doesn't anymore use a simple boolean for denoting
variable length allocation, but instead a keyword: either
:VAR-ALLOC, :FIXED-ALLOC, or :STRUCTURE-ALLOC.
* New VOPs: RAW-INSTANCE-INIT/* for all raw slot types, which are
almost identical to RAW-INSTANCE-SET[-C]/* VOPs, except that they
always have a constant index and do not return a result. Structures
with raw slots can be stack allocated only on platforms that
implement these VOPs, denoted in make-config.sh by the
:RAW-INSTANCE-INIT-VOPS feature. ...we really could use a
*VM-FEATURES* or something.
Index: vm-fndb.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/compiler/generic/vm-fndb.lisp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- vm-fndb.lisp 14 Feb 2008 16:40:47 -0000 1.45
+++ vm-fndb.lisp 28 May 2008 22:32:28 -0000 1.46
@@ -111,7 +111,9 @@
(flushable))
(defknown %make-instance (index) instance
- (unsafe))
+ (flushable))
+(defknown %make-structure-instance (defstruct-description list &rest t) instance
+ (flushable always-translatable))
(defknown %instance-layout (instance) layout
(foldable flushable))
(defknown %set-instance-layout (instance layout) layout
Index: vm-ir2tran.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/compiler/generic/vm-ir2tran.lisp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- vm-ir2tran.lisp 26 Sep 2007 15:44:23 -0000 1.13
+++ vm-ir2tran.lisp 28 May 2008 22:32:28 -0000 1.14
@@ -9,6 +9,13 @@
(in-package "SB!C")
+(def-alloc %make-structure-instance 1 :structure-alloc
+ sb!vm:instance-header-widetag sb!vm:instance-pointer-lowtag
+ nil)
+
+(defoptimizer (%make-structure-instance stack-allocate-result) ((&rest args))
+ t)
+
(defoptimizer ir2-convert-reffer ((object) node block name offset lowtag)
(let* ((lvar (node-lvar node))
(locs (lvar-result-tns lvar
@@ -46,37 +53,62 @@
res)
(move-lvar-result node block locs lvar)))
-(defun emit-inits (node block name result lowtag inits args)
+(defun emit-inits (node block name object lowtag inits args)
(let ((unbound-marker-tn nil)
(funcallable-instance-tramp-tn nil))
(dolist (init inits)
(let ((kind (car init))
(slot (cdr init)))
- (vop set-slot node block result
- (ecase kind
- (:arg
- (aver args)
- (lvar-tn node block (pop args)))
- (:unbound
- (or unbound-marker-tn
- (setf unbound-marker-tn
- (let ((tn (make-restricted-tn
- nil
- (sc-number-or-lose 'sb!vm::any-reg))))
- (vop make-unbound-marker node block tn)
- tn))))
- (:null
- (emit-constant nil))
- (:funcallable-instance-tramp
- (or funcallable-instance-tramp-tn
- (setf funcallable-instance-tramp-tn
- (let ((tn (make-restricted-tn
- nil
- (sc-number-or-lose 'sb!vm::any-reg))))
- (vop make-funcallable-instance-tramp node block tn)
- tn)))))
- name slot lowtag))))
- (aver (null args)))
+ (case kind
+ (:slot
+ (let ((raw-type (pop slot))
+ (arg-tn (lvar-tn node block (pop args))))
+ (macrolet ((make-case ()
+ `(ecase raw-type
+ ((t)
+ (vop set-slot node block object arg-tn
+ name (+ sb!vm:instance-slots-offset slot) lowtag))
+ ,@(mapcar (lambda (rsd)
+ `(,(sb!kernel::raw-slot-data-raw-type rsd)
+ (vop ,(sb!kernel::raw-slot-data-init-vop rsd)
+ node block
+ object arg-tn slot)))
+ #!+raw-instance-init-vops
+ sb!kernel::*raw-slot-data-list*
+ #!-raw-instance-init-vops
+ nil))))
+ (make-case))))
+ (:dd
+ (vop set-slot node block object
+ (emit-constant (sb!kernel::dd-layout-or-lose slot))
+ name sb!vm:instance-slots-offset lowtag))
+ (otherwise
+ (vop set-slot node block object
+ (ecase kind
+ (:arg
+ (aver args)
+ (lvar-tn node block (pop args)))
+ (:unbound
+ (or unbound-marker-tn
+ (setf unbound-marker-tn
+ (let ((tn (make-restricted-tn
+ nil
+ (sc-number-or-lose 'sb!vm::any-reg))))
+ (vop make-unbound-marker node block tn)
+ tn))))
+ (:null
+ (emit-constant nil))
+ (:funcallable-instance-tramp
+ (or funcallable-instance-tramp-tn
+ (setf funcallable-instance-tramp-tn
+ (let ((tn (make-restricted-tn
+ nil
+ (sc-number-or-lose 'sb!vm::any-reg))))
+ (vop make-funcallable-instance-tramp node block tn)
+ tn)))))
+ name slot lowtag))))))
+ (unless (null args)
+ (bug "Leftover args: ~S" args)))
(defun emit-fixed-alloc (node block name words type lowtag result lvar)
(let ((stack-allocate-p (and lvar (lvar-dynamic-extent lvar))))
@@ -107,6 +139,20 @@
(emit-inits node block name result lowtag 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 `((:dd . ,c-dd) ,@c-slot-specs) args)
+ (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
Index: vm-macs.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/compiler/generic/vm-macs.lisp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- vm-macs.lisp 23 Apr 2008 21:43:59 -0000 1.22
+++ vm-macs.lisp 28 May 2008 22:32:28 -0000 1.23
@@ -119,8 +119,10 @@
(constants `(def!constant ,size ,offset))
(exports size)))
(when alloc-trans
- (forms `(def-alloc ,alloc-trans ,offset ,variable-length-p ,widetag
- ,lowtag ',(inits))))
+ (forms `(def-alloc ,alloc-trans ,offset
+ ,(if variable-length-p :var-alloc :fixed-alloc)
+ ,widetag
+ ,lowtag ',(inits))))
`(progn
(eval-when (:compile-toplevel :load-toplevel :execute)
(%define-primitive-object
@@ -141,8 +143,8 @@
`(%def-reffer ',name ,offset ,lowtag))
(defmacro def-setter (name offset lowtag)
`(%def-setter ',name ,offset ,lowtag))
-(defmacro def-alloc (name words variable-length-p header lowtag inits)
- `(%def-alloc ',name ,words ,variable-length-p ,header ,lowtag ,inits))
+(defmacro def-alloc (name words alloc-style header lowtag inits)
+ `(%def-alloc ',name ,words ,alloc-style ,header ,lowtag ,inits))
#!+compare-and-swap-vops
(defmacro def-casser (name offset lowtag)
`(%def-casser ',name ,offset ,lowtag))
|