Commit 8235e418 by Richard Kenner

(__objc_block_return): New function.

(__objc_word_return, __objc_double_return): New functions.
(__objc_init_install_dtable): Call appropriate return function
based upon method type.

From-SVN: r13715
parent 74775c7a
...@@ -166,6 +166,46 @@ void __objc_init_dispatch_tables() ...@@ -166,6 +166,46 @@ void __objc_init_dispatch_tables()
= sarray_new(200, __objc_init_install_dtable); = sarray_new(200, __objc_init_install_dtable);
} }
/* Various return functions that are used based upon the
return type for the selector.
__objc_block_return for structures.
__objc_double_return for floats/doubles.
__objc_word_return for pointers or types that fit in registers.
*/
#if INVISIBLE_STRUCT_RETURN
static __big
#else
static id
#endif
__objc_block_return(IMP imp, void * args)
{
void * result = __builtin_apply((apply_t)imp, args, 96);
if (result)
__builtin_return (result);
else
return;
}
static id
__objc_word_return(IMP imp, void * args)
{
void * result = __builtin_apply((apply_t)imp, args, 96);
if (result)
__builtin_return (result);
else
return;
}
static double
__objc_double_return(IMP imp, void * args)
{
void * result = __builtin_apply((apply_t)imp, args, 96);
if (result)
__builtin_return (result);
else
return;
}
/* This one is a bit hairy. This function is installed in the /* This one is a bit hairy. This function is installed in the
premature dispatch table, and thus called once for each class, premature dispatch table, and thus called once for each class,
namely when the very first message is send to it. */ namely when the very first message is send to it. */
...@@ -176,6 +216,7 @@ static void __objc_init_install_dtable(id receiver, SEL op) ...@@ -176,6 +216,7 @@ static void __objc_init_install_dtable(id receiver, SEL op)
IMP imp; IMP imp;
void* args; void* args;
void* result; void* result;
const char *t;
/* This may happen, if the programmer has taken the address of a /* This may happen, if the programmer has taken the address of a
method before the dtable was initialized... too bad for him! */ method before the dtable was initialized... too bad for him! */
...@@ -217,13 +258,15 @@ already_initialized: ...@@ -217,13 +258,15 @@ already_initialized:
/* Get real method for this in newly installed dtable */ /* Get real method for this in newly installed dtable */
imp = get_imp(receiver->class_pointer, op); imp = get_imp(receiver->class_pointer, op);
/* Perform the appropriate return based upon the method return type */
args = __builtin_apply_args(); args = __builtin_apply_args();
result = __builtin_apply((apply_t)imp, args, 96); t = op->sel_types;
if (result) if (t && (*t == '[' || *t == '(' || *t == '{'))
__builtin_return (result); ((id(*)())__objc_block_return)(imp, args);
else if (t && (*t == 'f' || *t == 'd'))
((id(*)())__objc_double_return)(imp, args);
else else
return; __objc_word_return(imp, args);
} }
/* Install dummy table for class which causes the first message to /* Install dummy table for class which causes the first message to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment