DX structs with raw slots only allowed on conservative gencgc.
authorAlastair Bridgewater <nyef@virtdev-1.lisphacker.com>
Thu, 27 Oct 2011 13:16:08 +0000 (09:16 -0400)
committerAlastair Bridgewater <nyef@arisu.lisphacker.com>
Thu, 15 Dec 2011 14:41:53 +0000 (09:41 -0500)
  * Unless the control stack is conservatively scavenged, any
unboxed data could lead the GC to either corrupt the stack,
corrupt the heap, or just die screaming.

  * Thus, all unboxed data must be stored on the number stack
on such systems.  However, the number stack isn't scavenged
for boxed data, so we can't store any object that contains
both boxed and unboxed words if the unboxed words can appear
to the GC as anything other than a FIXNUM (thus, aligned
pointers are safe to store on the control stack).

  * All INSTANCE objects have a boxed slot, the LAYOUT slot.
If an instance also has raw slots then it cannot go on either
stack, and must be heap-allocated.

  * And none of this applies if the stack is conservatively
scavenged, which means (and gencgc c-stack-is-control-stack).
On such targets, we can dump whatever we want to the control
stack, and the GC won't complain at all.

src/compiler/generic/vm-ir2tran.lisp

index 7a0a1ee..420b129 100644 (file)
            nil)
 
 #!+stack-allocatable-fixed-objects
-(defoptimizer (%make-structure-instance stack-allocate-result) ((&rest args) node dx)
+(defoptimizer (%make-structure-instance stack-allocate-result) ((defstruct-description &rest args) node dx)
+  (aver (constant-lvar-p defstruct-description))
+  ;; A structure instance can be stack-allocated if it has no raw
+  ;; slots, or if we're on a target with a conservatively-scavenged
+  ;; stack.  We have no reader conditional for stack conservation, but
+  ;; it turns out that the only time stack conservation is in play is
+  ;; when we're on GENCGC (since CHENEYGC doesn't have conservation)
+  ;; and C-STACK-IS-CONTROL-STACK (otherwise, the C stack is the
+  ;; number stack, and we precisely-scavenge the control stack).
+  #!-(and :gencgc :c-stack-is-control-stack)
+  (zerop (sb!kernel::dd-raw-length (lvar-value defstruct-description)))
+  #!+(and :gencgc :c-stack-is-control-stack)
   t)
 
 (defoptimizer ir2-convert-reffer ((object) node block name offset lowtag)