From 4b19efed9aaf7c0c7aedea20d8359e3bebd3d44f Mon Sep 17 00:00:00 2001 From: Alastair Bridgewater Date: Thu, 27 Oct 2011 09:16:08 -0400 Subject: [PATCH] DX structs with raw slots only allowed on conservative gencgc. * 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/generic/vm-ir2tran.lisp b/src/compiler/generic/vm-ir2tran.lisp index 7a0a1ee..420b129 100644 --- a/src/compiler/generic/vm-ir2tran.lisp +++ b/src/compiler/generic/vm-ir2tran.lisp @@ -14,7 +14,18 @@ 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) -- 1.7.10.4