DoIts and selector removal

Stephan Rudlof sr at evolgo.de
Sun Dec 9 22:29:05 UTC 2001


Dear Stephen,

I think you are asking for an answer with a deeper explanation (which I'm
not able to give (without looking into the system at least ;-) )), but I
have a question, too:

Have you tried your proposed change? With which results (correctness,
speed)?

Greetings,

Stephan


Stephen Pair wrote:
> 
> I've noticed that doits appear to be taking a long time to run (I
> recently had a process that seemed to take much longer than it
> should...it involved a number of calls to Compiler>>evaluate:).  After
> investigating, I realized that every DoIt invokes a #become: operation
> to atomically swap out the method dictionary with a copy that has the
> #DoIt method removed.  Ah...
> 
> So, the question:  Is this really necessary?  Can't we just store the
> new method dictionary in the methodDict slot of the class?
> 
> Can we safely change the following method:
> 
> Behavior>>removeSelectorSimply: selector
>         "Assuming that the argument, selector (a Symbol), is a message
> selector
>         in my method dictionary, remove it and its method."
> 
>         | oldMethod |
>         oldMethod _ self methodDict at: selector ifAbsent: [^ self].
>         self methodDict removeKey: selector.
> 
>         "Now flush Squeak's method cache, either by selector or by
> method"
>         oldMethod flushCache.
>         selector flushCache.
> 
> To be:
> 
> Behavior>>removeSelectorSimply: selector
>         "Assuming that the argument, selector (a Symbol), is a message
> selector
>         in my method dictionary, remove it and its method."
> 
>         | oldMethod newDict |
>         oldMethod _ self methodDict at: selector ifAbsent: [^ self].
>         newDict _ self methodDict removeKeyNoBecome: selector.
>         methodDict _ newDict.
> 
>         "Now flush Squeak's method cache, either by selector or by
> method"
>         oldMethod flushCache.
>         selector flushCache.
> 
> This should also make fileIns a bit faster, as well as removing methods
> in general.
> 
> - Stephen

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3




More information about the Squeak-dev mailing list