mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 07:26:40 -04:00
* DEFCLASS did not teach TYPEP to emit code optimized for testing a classoid until the class was LOADed. That's easily fixed. [This is *not* the same issue as lp#310120, which asks that compile-time recognize the new class as a legal argument to FIND-CLASS as well.] * When converting TYPEP to CACHED-TYPEP, always issue a compiler-note regardless of the INHIBIT-WARNINGS policy (which should go away fwiw) Most uses of DEFINE-PROTOCOL-CLASS in sb-posix silently suffered from suboptimality, as did bsd-sockets.
25 lines
800 B
Common Lisp
25 lines
800 B
Common Lisp
(declaim (muffle-conditions compiler-note style-warning))
|
|
|
|
(defclass myclass () ())
|
|
|
|
(defun control (x)
|
|
(declare (type (or null otherclass) x))
|
|
(funcall 'f2 x))
|
|
|
|
(defun experiment (x)
|
|
(declare (type (or null myclass) x))
|
|
(funcall 'f2 x))
|
|
|
|
(defun uses-cached-typep (f)
|
|
(let ((c (sb-kernel:fun-code-header f)))
|
|
(loop for i from sb-vm:code-constants-offset
|
|
below (sb-kernel:code-header-words c)
|
|
thereis (let ((const (sb-kernel:code-header-ref c i)))
|
|
(and (consp const)
|
|
(eq (car const) #'sb-kernel::cached-typep))))))
|
|
|
|
(with-test (:name :typep-of-a-class)
|
|
;; Check that we know how to detect that a function used inefficient TYPEP
|
|
(assert (uses-cached-typep #'control))
|
|
(assert (not (uses-cached-typep #'experiment))))
|