#doesNotUndertand: method lookup

Hernan Wilkinson h.wilkinson at mercapsoftware.com
Thu Dec 16 13:38:41 UTC 2004


Hi,
    looking at the method lookup algorithm I found that when a message 
is not understood by an object, the search for the #doesNotUnderstand: 
does not uses the global cache.
    Currently, in the method Interpreter>>lookupMethodInClass: class, 
after doing the search in the method dictionaries of the hole class 
hierarchy does:

    .... [ code that searchs on the method dictionaries.... ]
    "Cound not find a normal message -- raise exception #doesNotUnderstand:"
    self pushRemappableOop: class.  "may cause GC!"
    self createActualMessageTo: class.
    rclass _ self popRemappableOop.
    messageSelector _ self splObj: SelectorDoesNotUnderstand.
    ^ self lookupMethodInClass: rclass

    The last line shows that it looks for the #doesNotUnderstand: using 
the "lookupMethodInClass:". It means that the search will start directly 
on the method dictionaries, not the global lookup cache. Just changing 
that line for:

    (self lookupInMethodCacheSel: messageSelector class: rclass) 
ifFalse: [ self lookupMethodInClass: rclass ]. "(No return needed, it is 
not used...)"

    will double the search speed.
    I've try the change on the InterpreterSimulator (I have an old 
version were it still works) and everything works as usual but the 
search for #doesNotUnderstand: is much faster.
    I could not try the change on a compiled VM because I don't have a C 
compiler with me right now, but for sure it is an easy change that the 
VM's guys can try.

    On the current version, after it looks for the #doesNotUnderstand: 
method, it store the result on the global lookup cache, but it never 
uses it!! (unless an explicit #doesNotUnderstand: is sent). With the 
change I suggest, it uses the cache not matter if the send is implicit 
or explicit.

    Well, I hope it helps.

    Bye,
    Hernan.

-- 
______________________________
Lic. Hernán A. Wilkinson
Gerente de Desarrollo y Tecnología
Mercap S.R.L.
Tacuari 202 - 7mo Piso - Tel: 54-11-4878-1118
Buenos Aires - Argentina
http://www.mercapsoftware.com
--------------------------------------------------------------------- 
Este mensaje es confidencial. Puede contener informacion amparada 
por el secreto profesional. Si usted ha recibido este e-mail por error, 
por favor comuniquenoslo inmediatamente via e-mail y tenga la 
amabilidad de eliminarlo de su sistema; no debera copiar el mensaje 
ni divulgar su contenido a ninguna persona. Muchas gracias. 
 
This message is confidential. It may also contain information that is 
privileged or otherwise legally exempt from disclosure. If you have 
received it by mistake please let us know by e-mail immediately and 
delete it from your system; you should also not copy the message nor 
disclose its contents to anyone. Thanks. 
 --------------------------------------------------------------------- 





More information about the Squeak-dev mailing list