discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objective-c: how slow ?


From: Nicola Pero
Subject: Re: objective-c: how slow ?
Date: Sat, 1 Sep 2001 22:28:40 +0200 (CEST)

> > you would modify the compiler so that instead of compiling
> >
> >  [receiver message];
> >
> > into
> >
> >  {
> >    IMP __imp = objc_msg_lookup(receiver, @selector(message));
> >    __imp (receiver, @selector(message));
> >  }
> >
> > it would compile it into
> >
> >  {
> >    static Class __class = Nil;
> >    static IMP __imp = NULL;
> >
> >    if (receiver->isa != __class)
> >      {
> >         __class = receiver->isa;
> >         __imp = objc_msg_lookup(receiver, @selector(message));
> >      }
> >
> >    __imp (receiver, @selector(message));
> >  }
> >
> > it's a rough sketch, but I suppose something like this might actually
> > work! :-)
> >
> 
> As you know, the above is not thread safe.  Furthermore, the above is likely
> SLOWER.  

I actually agree with you ... it was a tentative try to imagine how you
could implement inline caching in Objective-C ... it's interesting to try
importing ideas ... and it is definitely an interesting sets of ideas to
optimize OO language messaging ... thanks Marko for pointing this out ...
but I agree with you that it looks like an optimization
designed/appropriate for different environments/languages ... in the
context of ObjC, it doesn't seem to make as much sense as it does in other
environments (where it migth definitely be a great idea) ... the gain in
speed (if any and if positive :-)) looks like it would normally be so
little that it's not probably worth the effort. 

Btw - because of poseAs:, the above code - which uses a locally cached
static IMP and Class, can't be used - the compiler would rather need to
generate a table per file, where to store the cached IMPs and Classes for
all method invocations in the file, so that when poseAs:  is called, we
would loop through the files and update the cache tables ...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]