<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6001.18148" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Seems it can't happen then without breaking desired
beahaviour of superclasses, unless the class in question does actually
override all relevant inherited methods...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Seems one must make a decision to (at compile time)
universally inline certain selectors or not.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards, Gary.</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=eliot.miranda@gmail.com href="mailto:eliot.miranda@gmail.com">Eliot
Miranda</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=squeak-dev@lists.squeakfoundation.org
href="mailto:squeak-dev@lists.squeakfoundation.org">The general-purpose Squeak
developers list</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, November 19, 2008 8:31
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [squeak-dev] Lightweight
Classes</DIV>
<DIV><BR></DIV><BR><BR>
<DIV class=gmail_quote>On Wed, Nov 19, 2008 at 12:13 PM, Gary Chambers <SPAN
dir=ltr><<A
href="mailto:gazzaguru2@btinternet.com">gazzaguru2@btinternet.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Perhaps
the compiler could ask the class (or meta) of the method being compiled as
to whether to inline a selector. All after the fact until a full recompile
of the class, of course...</BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>Doesn't really help. One wants the property to be of the receiver,
not of the sending context. Inheritance gets in the way also since a
subclass that overrides the setting would need to reimplement all methods that
send class to get its own setting, and even then super sends could invoke
inherited code compiled with the wrong setting. Alas this idea doesn't
work.</DIV>
<DIV> </DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><BR><BR>Regards,
Gary.<BR><BR>----- Original Message ----- From: "Igor Stasenko" <<A
href="mailto:siguctua@gmail.com"
target=_blank>siguctua@gmail.com</A>><BR>To: "The general-purpose Squeak
developers list" <<A href="mailto:squeak-dev@lists.squeakfoundation.org"
target=_blank>squeak-dev@lists.squeakfoundation.org</A>><BR>Sent:
Wednesday, November 19, 2008 8:03 PM<BR>Subject: Re: [squeak-dev]
Lightweight Classes
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c><BR><BR><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">2008/11/19
Eliot Miranda <<A href="mailto:eliot.miranda@gmail.com"
target=_blank>eliot.miranda@gmail.com</A>>:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><BR><BR>On
Sun, Nov 16, 2008 at 7:11 PM, Igor Stasenko <<A
href="mailto:siguctua@gmail.com"
target=_blank>siguctua@gmail.com</A>> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><BR>2008/11/17
Hernán Morales Durand <<A href="mailto:hernan.morales@gmail.com"
target=_blank>hernan.morales@gmail.com</A>>:<BR>> Dear
all,<BR>> In the attachment you will find an implementation
of Lightweight<BR>> Classes<BR>> for Squeak that follows the
original paper "Debugging Objects" of > Hinkle<BR>> et<BR>>
al. However I was unable to set up the #class method in the<BR>>
LightweightClass<BR>> to answer the real class of the lightwighted
object, is this possible<BR>> currently in Squeak?.<BR>><BR>>
What I did:<BR>> -Created the LightweightClass as in the old
VisualWorks > implementation.<BR>> The<BR>> only difference
here was CompiledMethod's cannot be copied, so I used<BR>>
#clone.<BR>> -Created and installed an UnstoredMethod (a
CompiledMethod subclass) > in<BR>> the<BR>>
LightweightClass's methodDictionary. Since I want to store the
source<BR>> code<BR>> but not through the changes log, I
borrowed the MethodWrappers idea of<BR>> storing the state
(sourceCode) in a class instance variable, and > compile<BR>>
without logging. The methods I borrowed from MW are:<BR>><BR>>
-#copyWithTrailerBytes: - I think the superimplementor in >
CompiledMethod<BR>> could use "self class" to avoid
reimplementors.<BR>> -#tweakClassFormat - which set the format but
I don't know why and<BR>> cannot<BR>> find documentation on
this.<BR>> -#objectAt: I suspected the class literal was stored in
the literal<BR>> frame<BR>> everytime I accepted a method, but
for the simple test below still<BR>> answer<BR>> the
LightweightClass and not the real class.<BR>><BR>> Here is the
test:<BR>><BR>> | aDate |<BR>> aDate := Date today.<BR>>
aDate becomeLightweight.<BR>> aDate dispatchingClass compile: 'day
^43' notifying: nil.<BR>> aDate day. " 43 (works) "<BR>> aDate
perform: #class. " Date ------> (works) "<BR>> aDate class. "
{Date} ------> LightweightClass (wrong) "<BR>><BR><BR>The only
cause of this can be compiler.<BR>Instead of generating an instruction
for sending #class message, it<BR>generates a bytecode to fetch the
class from receiver oop , instead of<BR>sending real
message.<BR></BLOCKQUOTE><BR>IMO the bug is in the VM. The
compiler generates bytecode 199, the special<BR>selector class send.
But it is the VM that decides to short-cut this send<BR>and
implement it by accessing the receiver's class directly instead
of<BR>actually sending the message. I doubt very much this
short-circuiting has<BR>any impact on performance (VisualWorks has never
inlined this special<BR>selector send), and it is very easy to fix in
the VM. A number of other<BR>special selector bytecodes become
ordinary sends (e.g. next nextPut: etc).<BR>If class were important for
performance one could implement something<BR>analogous to the at cache
that speeds up at:, at:put: and size for special<BR>selectors. The
special selector bytecode would check that the receiver of<BR>the class
message had the standard implementation (primitive in Object)
and<BR>answer the class directly. But this isn't going to save
significant time.<BR>To fix this change<BR>bytecodePrimClass<BR>| rcvr
|<BR>rcvr := self internalStackTop.<BR>self internalPop: 1 thenPush:
(self fetchClassOf: rcvr).<BR>self
fetchNextBytecode.<BR>to<BR>bytecodePrimClass<BR>messageSelector := self
specialSelector: 23.<BR>argumentCount := 0.<BR>self
normalSend.<BR><BR></BLOCKQUOTE><BR>Agreed, it seem a VM feature, kind of
:)<BR>As temporary workaround, one could modify compiler to generate
a<BR>normal send bytecode instead of using a short bytecode for
special<BR>selector which #class is. I'm not sure how easy/hard such
modification<BR>could be made.<BR><BR>And i agree, that such optimization
buys a little. I didn't seen a<BR>code which does a heavy numerical
crunching, where speed is essential,<BR>and at same time needs a #class
sends. To my sense a #class appears in<BR>places where we need to deal
with polymorphism or doing something on<BR>meta levels - but in such
areas, a correctess is far more important<BR>than speed.<BR><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">>
Any hint would be appreciated.<BR>> Best regards.<BR>><BR>>
Hernán<BR>><BR>> PS: Just to avoid duplicate efforts, I wrote a
LightweightClasses<BR>> Browser<BR>> which will be available as
soon as I find a solution to the problem<BR>>
above.<BR>><BR><BR>--<BR>Best regards,<BR>Igor Stasenko AKA
sig.<BR><BR></BLOCKQUOTE></BLOCKQUOTE><BR><BR>-- <BR>Best regards,<BR>Igor
Stasenko AKA
sig.<BR><BR></BLOCKQUOTE><BR><BR></DIV></DIV>--------------------------------------------------------------------------------<BR><BR><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><BR><BR></BLOCKQUOTE><BR><BR></BLOCKQUOTE></DIV><BR>
<P>
<HR>
<P></P><BR></BLOCKQUOTE></BODY></HTML>