Article 3.2: IMP Cacheing Deluxe
Posted: Wed Sep 01, 2004 12:20 am
Discusssion thread for this specific optimization article.
Forum for Optimizations around Cocoa and Mac OS X
http://www.mulle-kybernetik.com/forum/Optimization/
http://www.mulle-kybernetik.com/forum/Optimization/viewtopic.php?f=14&t=7
znek wrote:The requested URL /artikel/Optimization/opti-imp-autorelease.source.tgz was not found on this server.
whitenoise wrote:I agree, but can it be done without breaking binary compatibility?
Code: Select all
lis r12,0x1234
ori r12,r12,0x5678
mtspr ctr,r12
bctr
Code: Select all
// our IMP cacheing thing
thisIsa = _isa( p);
index = ((unsigned long) thisIsa >> 4) & 15;
if( lastIsa[ index] != thisIsa)
{
extern id _objc_msgForward( id, SEL, ...);
imp = class_lookupMethod( thisIsa, sel);
/* the problem is, that we don't preserve r11, but objc_msgForward
* explicitly expects r11 to be set by objc_msgSend
*/
if( imp == _objc_msgForward)
imp = objc_msgSend;
/* otherwise continue as planned */
lastSelIMP[ index] = imp;
lastIsa[ index] = thisIsa;
}
(*lastSelIMP[ index])( p, sel, argument);
}