Marco Antoniotti | 1 Feb 2012 14:11
Picon

ELS 2012, Zadar, Croatia

Apologies for the multiple postings. 

PAPER SUBMISSION DEADLINE EXTENDED 

European Lisp Symposium 2012, Zadar, Croatia, April 30th - May 1st, 2012 

http://european-lisp-symposium.org 

The purpose of the European Lisp Symposium is to provide a forum for 
the discussion and dissemination of all aspects of design, 
implementation and application of any of the Lisp and Lisp-inspired 
dialects, including Common Lisp, Scheme, Emacs Lisp, AutoLisp, ISLISP, 
Dylan, Clojure, ACL2, ECMAScript, Racket, SKILL, and so on. We 
encourage everyone interested in Lisp to participate. 

The main theme of the 2012 European Lisp Conference is 
"Interoperability: Systems, Libraries, Workflows".  Lisp based and 
functional-languages based systems have grown a variety of solutions 
to become more and more integrated with the wider world of Information 
and Communication Technologies in current use.  There are several 
dimensions to the scope of the solutions proposed, ranging from 
"embedding" of interpreters in C-based systems, to the development of 
abstractions levels that facilitate the expression of complex context 
dependent tasks, to the construction of exchange formats handling 
libraries, to the construction of theorem-provers for the "Semantic 
Web".  The European Lisp Symposium 2012 solicits the submission of 
papers with this specific theme in mind, alongside the more 
traditional tracks which have appeared in the past editions. 

We invite submissions in the following forms: 
(Continue reading)

Dan Corkill | 5 Feb 2012 12:18
Favicon

Inlined TYPEP over-optimization bug with CHANGE-CLASS

Recent CMUCL releases (including the current one), incorrectly over-optimize TYPEP and
miss the class change resulting from CHANGE-CLASS. 

The following example, when placed in a file and compiled, shows the issue:

(in-package :cl-user)

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

(defmethod show-bug ((instance foo))
 (change-class instance 'bar)
 (format t "~&;; Inlined TYPEP: ~s (incorrect)~%;; Not-inlined TYPEP: ~s (correct)~%"
         (typep instance 'foo)
         (locally (declare (notinline typep))
           (typep instance 'foo))))

(show-bug (make-instance 'foo))

-- Dan

_______________________________________________
cmucl-help mailing list
cmucl-help <at> cmucl.cons.org
http://lists.zs64.net/mailman/listinfo/cmucl-help

Christophe Rhodes | 5 Feb 2012 12:57
Favicon

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

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

> Recent CMUCL releases (including the current one), incorrectly over-optimize TYPEP and
> miss the class change resulting from CHANGE-CLASS. 

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

Changing the class of an instance within a method specializing on that
instance to a class where the method would no longer have been called is
one of the things that the CLHS description of change-class calls
"semantic difficulties".

Not speaking for CMUCL developers, I would call it a downright bad idea
to mess with the classes of specialized instances in methods -- allowing
the programmer to do invalidates whole classes of CLOS optimizations.
The CLHS specifically calls out slot access, but that's just one case of
a general problem: after you issue the change-class, the method
currently running is no longer an applicable method to the instance, so
all the compiler assumptions have just been invalidated, and all the
run-time calculations of next methods also (though they're not present
in your example).

Best,

Christophe
(Continue reading)

Dan Corkill | 5 Feb 2012 15:57
Favicon

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

>> Recent CMUCL releases (including the current one), incorrectly over-optimize TYPEP and
>> miss the class change resulting from CHANGE-CLASS. 
> 
>> (defmethod show-bug ((instance foo))
>> (change-class instance 'bar)
>> (format t "~&;; Inlined TYPEP: ~s (incorrect)~%;; Not-inlined TYPEP: ~s (correct)~%"
>>         (typep instance 'foo)
>>         (locally (declare (notinline typep))
>>           (typep instance 'foo))))
> 
> Changing the class of an instance within a method specializing on that
> instance to a class where the method would no longer have been called is
> one of the things that the CLHS description of change-class calls
> "semantic difficulties".
> 
> Not speaking for CMUCL developers, I would call it a downright bad idea
> to mess with the classes of specialized instances in methods -- allowing
> the programmer to do invalidates whole classes of CLOS optimizations.
> The CLHS specifically calls out slot access, but that's just one case of
> a general problem: after you issue the change-class, the method
> currently running is no longer an applicable method to the instance, so
> all the compiler assumptions have just been invalidated, and all the
> run-time calculations of next methods also (though they're not present
> in your example).
> 
> Best,
> 
> Christophe

I fully agree (and apologies for the confusion caused by my quick-and-dirty 
(Continue reading)

Raymond Toy | 12 Feb 2012 06:29
Picon

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

On 2/5/12 6:57 AM, Dan Corkill wrote:
>>> I fully agree (and apologies for the confusion caused by my quick-and-dirty 
>>> example).
>>>
>>> The issue doesn't require being within an instance method--as the following
>>> vanilla-function example shows.
>>>
>>> (in-package :cl-user)
>>>
>>> (defclass foo () ())
>>> (defclass bar () ())
>>>
>>> (defun show-bug (instance)
>>>   (change-class instance 'bar)
>>>   (format t "~&;; Inlined TYPEP: ~s (incorrect)~%;; Not-inlined TYPEP: ~s (correct)~%"
>>>           (typep instance 'foo)
>>>           (locally (declare (notinline typep))
>>>             (typep instance 'foo))))
>>>
>>> (show-bug (make-instance 'foo))
>>>
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?
(Continue reading)

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