<!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&nbsp;superclasses, unless the class in question does actually 
override all relevant inherited methods...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</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>&lt;<A 
  href="mailto:gazzaguru2@btinternet.com">gazzaguru2@btinternet.com</A>&gt;</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. &nbsp;One wants the property to be of the receiver, 
  not of the sending context. &nbsp;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. &nbsp;Alas this idea doesn't 
  work.</DIV>
  <DIV>&nbsp;</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" &lt;<A 
    href="mailto:siguctua@gmail.com" 
    target=_blank>siguctua@gmail.com</A>&gt;<BR>To: "The general-purpose Squeak 
    developers list" &lt;<A href="mailto:squeak-dev@lists.squeakfoundation.org" 
    target=_blank>squeak-dev@lists.squeakfoundation.org</A>&gt;<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 &lt;<A href="mailto:eliot.miranda@gmail.com" 
      target=_blank>eliot.miranda@gmail.com</A>&gt;:<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 &lt;<A 
        href="mailto:siguctua@gmail.com" 
        target=_blank>siguctua@gmail.com</A>&gt; 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 &lt;<A href="mailto:hernan.morales@gmail.com" 
          target=_blank>hernan.morales@gmail.com</A>&gt;:<BR>&gt; Dear 
          all,<BR>&gt; &nbsp; In the attachment you will find an implementation 
          of Lightweight<BR>&gt; Classes<BR>&gt; for Squeak that follows the 
          original paper "Debugging Objects" of &gt; Hinkle<BR>&gt; et<BR>&gt; 
          al. However I was unable to set up the #class method in the<BR>&gt; 
          LightweightClass<BR>&gt; to answer the real class of the lightwighted 
          object, is this possible<BR>&gt; currently in Squeak?.<BR>&gt;<BR>&gt; 
          What I did:<BR>&gt; -Created the LightweightClass as in the old 
          VisualWorks &gt; implementation.<BR>&gt; The<BR>&gt; only difference 
          here was CompiledMethod's cannot be copied, so I used<BR>&gt; 
          #clone.<BR>&gt; -Created and installed an UnstoredMethod (a 
          CompiledMethod subclass) &gt; in<BR>&gt; the<BR>&gt; 
          LightweightClass's methodDictionary. Since I want to store the 
          source<BR>&gt; code<BR>&gt; but not through the changes log, I 
          borrowed the MethodWrappers idea of<BR>&gt; storing the state 
          (sourceCode) in a class instance variable, and &gt; compile<BR>&gt; 
          without logging. The methods I borrowed from MW are:<BR>&gt;<BR>&gt; 
          -#copyWithTrailerBytes: - I think the superimplementor in &gt; 
          CompiledMethod<BR>&gt; could use "self class" to avoid 
          reimplementors.<BR>&gt; -#tweakClassFormat - which set the format but 
          I don't know why and<BR>&gt; cannot<BR>&gt; find documentation on 
          this.<BR>&gt; -#objectAt: I suspected the class literal was stored in 
          the literal<BR>&gt; frame<BR>&gt; everytime I accepted a method, but 
          for the simple test below still<BR>&gt; answer<BR>&gt; the 
          LightweightClass and not the real class.<BR>&gt;<BR>&gt; Here is the 
          test:<BR>&gt;<BR>&gt; | aDate |<BR>&gt; aDate := Date today.<BR>&gt; 
          aDate becomeLightweight.<BR>&gt; aDate dispatchingClass compile: 'day 
          ^43' notifying: nil.<BR>&gt; aDate day. " 43 (works) "<BR>&gt; aDate 
          perform: #class. " Date ------&gt; (works) "<BR>&gt; aDate class. " 
          {Date} ------&gt; LightweightClass (wrong) "<BR>&gt;<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. &nbsp;The 
        compiler generates bytecode 199, the special<BR>selector class send. 
        &nbsp;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. &nbsp;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. &nbsp;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. &nbsp;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. &nbsp;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 &nbsp;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">&gt; 
          Any hint would be appreciated.<BR>&gt; Best regards.<BR>&gt;<BR>&gt; 
          Hernán<BR>&gt;<BR>&gt; PS: Just to avoid duplicate efforts, I wrote a 
          LightweightClasses<BR>&gt; Browser<BR>&gt; which will be available as 
          soon as I find a solution to the problem<BR>&gt; 
          above.<BR>&gt;<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>