On Mon, May 28, 2001 at 11:20:09PM +0200, Martin Atzmueller wrote:
> Attached is a patch ported from CMUCL, that allows SBCL to inline
> type-tests not only for structures, but also for other classes.
> I had some difficulties in getting this to work in SBCL-0.6.12.07 but as
> it turned out, these were other problems ...
> Anyway, here is the summary of what the patch does:
> - Enhance the compiler instance typep transform to generate inline
> type tests for hierarchical classes, not just for structures.
> - Simplify the direct-superclasses computation for the condition
> - Add support for computing class precedence lists, and use this to
> correctly calculate the CPL for the condition classes.
> - Add the new function order-layout-inherits to correctly order the
> layouts within the layout-inherits vector. This ensures that
> the compiler can generate inline type tests for hierarchical classes.
> - Modify the definition of the stream class to be hierarchical.
> - Have the condition classes correctly order their layout-inherits
> so that the hierarchical condition class is placed at its specified
> I have no simple test case for this, unfortunately. An automatic test
> seemed not that obvious.
> But it is possible to see that the type-test is inlined by looking at
> a trace file, for example after compiling the following:
> (in-package :cl-user)
> (defun f (x)
> (typep x 'sb-impl::stream))
> Hope this is useful.
Thank you. Looking at the code and the list of things it's supposed to
do, it looks good. However, it's a rather nontrivial set of changes.
And while I agree that it's not obvious how to write tests for the new
functionality, it's pretty easy to see how to test that it doesn't
break the old functionality. Until that's been done, I'm not good
enough at proof-reading to have much confidence that everything will
I'm not volunteering to write all the tests myself this time, at least
not any time soon, but I did write a few examples in type.impure.lisp:
;;; Pierre Mai rewrote the CMU CL type test system to allow inline
;;; type tests for CONDITIONs and STANDARD-OBJECTs, and generally be
;;; nicer, and Martin Atzmueller ported the patches. They look nice
;;; but they're nontrivial enough that it's not obvious from
;;; inspection that everything is OK. Let's make sure that things
;;; still basically work.
(defstruct (foo2 (:include foo1))
(defstruct (foo3 (:include foo2)))
(defstruct (foo4 (:include foo3))
(assert (typep (make-foo3) 'foo2))
(assert (not (typep (make-foo1) 'foo4))
(assert (null (ignore-errors (setf (foo2-x (make-foo1)) 11))))
;;; (More tests here would be nice before merging the patches. More
;;; tests for STRUCTURE-OBJECT, tests for CONDITION, tests for
;;; STANDARD-OBJECT, compiled tests to make sure that the inline
;;; versions of the tests work..)
William Harold Newman <william.newman@...>
"99 little bugs in the code, 99 bugs in the code,
fix one bug, compile it again...
101 little bugs in the code...."
-- bgarcia (garsh@...) on Tuesday November 02, @11:09AM EST on slashdot
PGP key fingerprint 85 CE 1C BA 79 8D 51 8C B9 25 FB EE E0 C3 E5 7C