gencgc: More precise conservatism for pointers to boxed pages.
authorAlastair Bridgewater <nyef@kana.lisphacker.com>
Tue, 31 Dec 2013 16:27:18 +0000 (11:27 -0500)
committerAlastair Bridgewater <nyef@kana.lisphacker.com>
Tue, 31 Dec 2013 17:23:39 +0000 (12:23 -0500)
  * The commentary for possibly_valid_dynamic_space_pointer()
claims that it matches unboxed return addresses (to within code
objects), but this turns out not to be the case.

  * Fix the code to match the comment, at least somewhat, by
checking to see if the object found is a code object and
shortcutting the full validation if it is.

  * And, now that we have a version of p_v_d_s_p() that does the
"right thing", or at least close to it with respect to the only
truly unboxed interior pointers that we should have to deal with,
call it straight up instead of only for unboxed pages when we have
a true pointer type.

  * Overall, this can be expected to be slower than the prior
version, but more precise in terms of rogue integers in the heap
range.  The remaining conservation effects would be due to the
fact that we can't move ANYTHING that's a conservative root and
stale pointers within our active area (truly precise ports are
less affected by this because they can relocate objects pointed to
by stale pointers).

NEWS
src/runtime/gencgc.c

diff --git a/NEWS b/NEWS
index 083bbc4..ab625a0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,9 +15,9 @@ changes relative to sbcl-1.1.14:
     :application-type argument, which can be :console or :gui. :gui allows
     having GUI applications without an automatically appearing console window.
   * enhancement: reduced conservativism on GENCGC platforms:
-    conservative roots that point to unboxed pages must be tagged
-    pointers to the start of a valid-looking object, not merely point
-    to within the allocated part of the page, in order to pin the page.
+    conservative roots must be valid-looking tagged pointers or point
+    within a code object, not merely point to within the allocated part
+    of a page, in order to pin a page.
   * bug fix: Windows applications without the console window no longer misbehave.
     (patch by Wilfredo Velazquez, lp#1256034).
   * bug fix: modular arithmetic optimizations do not stumble on dead branches
index f23d83e..e4ed81b 100644 (file)
@@ -2069,6 +2069,12 @@ possibly_valid_dynamic_space_pointer(lispobj *pointer)
         return 0;
     }
 
+    /* If the containing object is a code object, presume that the
+     * pointer is valid, simply because it could be an unboxed return
+     * address. */
+    if (widetag_of(*start_addr) == CODE_HEADER_WIDETAG)
+        return 1;
+
     return looks_like_valid_lisp_pointer_p(pointer, start_addr);
 }
 
@@ -2110,9 +2116,7 @@ valid_conservative_root_p(void *addr, page_index_t addr_page_index)
      * expensive but important, since it vastly reduces the
      * probability that random garbage will be bogusly interpreted as
      * a pointer which prevents a page from moving. */
-    if (!(code_page_p(addr_page_index)
-          || (is_lisp_pointer((lispobj)addr) &&
-              possibly_valid_dynamic_space_pointer(addr))))
+    if (!possibly_valid_dynamic_space_pointer(addr))
         return 0;
 #endif