Dan Corkill | 12 Feb 2012 13:57
Favicon

Re: Inlined TYPEP over-optimization issue with CHANGE-CLASS

Raymond Toy wrote:

> I placed your code in a file and compiled and loaded it with the 2012-02
> snapshot.  I get
> 
> CL-USER> (show-bug (make-instance 'foo))
> ;; Inlined TYPEP: NIL (incorrect)
> ;; Not-inlined TYPEP: NIL (correct)
> 
> What version exactly are you using and how did you run your example to
> get an incorrect result?

Ray,

With the 2012-02 snapshot, I also only see the issue with the DEFMETHOD
version.  Here is the newest test code that I ran:

(in-package :cl-user)

(defclass foo () ())
(defclass bar () ())

(defmethod no-issue ((instance foo))
  (%show-issue instance))

(defun %show-issue (instance)
  (change-class instance 'bar)
  (format t "~&;; Inlined TYPEP: ~s (~:*~:[correct~;incorrect~])~
             ~%;; Not-inlined TYPEP: ~s (~:*~:[correct~;incorrect~])~%"
          (typep instance 'foo)
(Continue reading)

Christophe Rhodes | 12 Feb 2012 14:58
Favicon

Re: Inlined TYPEP over-optimization issue with CHANGE-CLASS

Dan Corkill <corkill <at> GBBopen.org> writes:

> (defun %show-issue (instance)
>   (change-class instance 'bar)
>   (format t "~&;; Inlined TYPEP: ~s (~:*~:[correct~;incorrect~])~
>              ~%;; Not-inlined TYPEP: ~s (~:*~:[correct~;incorrect~])~%"
>           (typep instance 'foo)
>           (locally (declare (notinline typep))
>             (typep instance 'foo))))

Here's a related test case:

  (defun %show-issue (instance)
    (when (typep instance 'foo)
      (change-class instance 'bar)
      (format t "~&;; Inlined TYPEP: ~s (~:*~:[correct~;incorrect~])~
                 ~%;; Not-inlined TYPEP: ~s (~:*~:[correct~;incorrect~])~%"
              (typep instance 'foo)
              (locally (declare (notinline typep))
                (typep instance 'foo)))))
  (%show-issue (make-instance 'foo))

I don't know whether that passes or fails on CMUCL, but it does reveal
a too-optimistic inlining (or maybe constraint propagation) on SBCL --
so it might be worth checking.

Best,

Christophe
_______________________________________________
(Continue reading)


Gmane