GCC/ObjC enhancements, comments requested
Ovidiu Predescu
ovidiu@aracnet.com
Tue Feb 10 10:58:00 GMT 1998
On Mon, 9 Feb 1998 22:37:17, Richard Henderson wrote:
> On Sun, Feb 08, 1998 at 10:32:37PM -0800, Ovidiu Predescu wrote:
> > What we're trying to build is a system that allows us to build a function
> > call at _runtime_, knowing the address of the function, the argument
> > types and the return value.
>
> Why?
Objective-C has a special facility called forwarding, which allows you to send a message to an object that does not implement it. A special method is invoked that has as arguments the selector of the original method (a special identifier which represents the message) and the arguments passed to the original message.
This capability is used heavily by Objective-C libraries to implement Distributed Objects, which allow you to have proxies in your application, objects that act for remote objects in another application. Sending a message to a proxy is caught by that special message that sends the selector and the arguments to the remote server application. Note that the server application can run on a different architecture so is essential for the client to identify the arguments and send them one by one to the server. The server creates a frame for __builtin_apply() which contains those arguments, the selector and the object to invoke the message on and eventually invokes the method.
> > GCC currently implements only half
> > of this support with the __builtin_apply() and __builtin_return()
> > pseudo-functions.
>
> GCC doesn't even pretend to get even these right for targets that
> don't pass all arguments on the stack. Certainly it doesn't work
> on the Alpha, which is one of the simpler examples.
The above mechanism is hidden inside a class called NSInvocation which is implemented (or at least how I implemented it) by accessing the frame passed to __builtin_apply(). This frame contains information on both stack arguments and register arguments. It is supposed to hide the details of where the compiler puts a specific argument and it should work on all the systems. I'm surprised if this is broken under Alpha since Objective-C relies heavily on these two pseudo-functions.
Ovidiu
--
Ovidiu Predescu <ovidiu@net-community.com> (NeXTMail, MIME)
http://www.net-community.com/Users/~ovidiu
More information about the Gcc
mailing list