This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GNU ObjC runtime class table rewritten

Nicola Pero wrote:
> [...]
> The long-term solution to this problem would be to modify the compiler
> to output tables of class pointers corresponding to all the class
> method invocations, and to add code to the runtime to update these
> tables - that should in the end allow class method invocations to
> perform precisely as fast as instance method invocations, because no
> class lookup would be involved.  I think the Apple Objective-C runtime
> uses this technique.  Doing this involves synchronized modifications
> in the runtime and in the compiler.  I have not yet looked at doing
> it.

That's right.  It would probably take a little cooperation from
binutils too.

> I took a more direct approach - I studied the way the runtime was
> performing class lookup, and I thought - hey, I can write code which
> does the same, but faster. :-)
> So - I have redesigned and rewritten the class table in the GNU
> Objective-C runtime to be faster (it took me four days in total I
> think).  This doesn't give as much speed as the other approach, but a
> class method invocation now takes approximately 4.5 times an instance
> method invocation on my machine.  That's a considerable improvement
> (it means the core class lookup now takes 1/3 of the original time).

This is great!  One of the advantages is that it's still compatible
with code compiled using the existing runtime.  There's not so many
ObjC libraries out there that this is a big issue currently, but 

> So - here is the new code.

This looks pretty good to me.  I would ask for one change before
putting it into the trunk - you have some very informative discussion
in your message, but it's not reflected in the code.  The chances are
that the next person to look at this code will not know about your
mail message.  So what I ask is that you take the details in your
message, cast them into an appropriate form for a comment block at
the top of class.c, and resubmit - I'll take that version and
install it as the new class.c in the trunk.

Thanks for working on this BTW, the numbers are very exciting!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]