Commit 772fa04a by Kresten Krab Thorup

(objc_msg_sendv): Use new encoding facilities.

(__objc_update_dispatch_table_for_class):
        Don't free dtable... (memory leak to make posing work)
(__objc_update_dispatch_table_for_class):
        Free old dispatch table and install a new.

From-SVN: r5205
parent 2224b8cc
...@@ -26,6 +26,7 @@ You should have received a copy of the GNU General Public License along with ...@@ -26,6 +26,7 @@ You should have received a copy of the GNU General Public License along with
#include "runtime.h" #include "runtime.h"
#include "sarray.h" #include "sarray.h"
#include "encoding.h"
/* The uninstalled dispatch table */ /* The uninstalled dispatch table */
struct sarray* __objc_uninstalled_dtable = 0; struct sarray* __objc_uninstalled_dtable = 0;
...@@ -87,20 +88,15 @@ objc_msg_lookup_super (Super_t super, SEL sel) ...@@ -87,20 +88,15 @@ objc_msg_lookup_super (Super_t super, SEL sel)
} }
retval_t retval_t
objc_msg_sendv(id object, SEL op, size_t frame_size, arglist_t arg_frame) objc_msg_sendv(id object, SEL op, arglist_t arg_frame)
{ {
#ifdef __objc_frame_receiver Method* m = class_get_instance_method(object->class_pointer, op);
__objc_frame_receiver(arg_frame) = object; const char *type;
__objc_frame_selector(arg_frame) = op; *((id*)method_get_first_argument (m, arg_frame, &type)) = object;
return __builtin_apply((apply_t)get_imp(object->class_pointer, op), *((SEL*)method_get_next_argument (arg_frame, &type)) = op;
return __builtin_apply((apply_t)m->method_imp,
arg_frame, arg_frame,
frame_size); method_get_sizeof_arguments (m));
#else
#warning performv:: will not work
va_list nothing;
(*_objc_error)(object, "objc_msg_sendv (performv::) not supported\n", nothing);
return 0;
#endif
} }
void __objc_init_dispatch_tables() void __objc_init_dispatch_tables()
...@@ -247,9 +243,9 @@ __objc_install_dispatch_table_for_class (Class* class) ...@@ -247,9 +243,9 @@ __objc_install_dispatch_table_for_class (Class* class)
while (counter >= 0) while (counter >= 0)
{ {
Method_t method = &(mlist->method_list[counter]); Method_t method = &(mlist->method_list[counter]);
sarray_at_put (class->dtable, sarray_at_put_safe (class->dtable,
(sidx) method->method_name, (sidx) method->method_name,
method->method_imp); method->method_imp);
counter -= 1; counter -= 1;
} }
} }
...@@ -264,14 +260,14 @@ void __objc_update_dispatch_table_for_class (Class* class) ...@@ -264,14 +260,14 @@ void __objc_update_dispatch_table_for_class (Class* class)
if (class->dtable == __objc_uninstalled_dtable) if (class->dtable == __objc_uninstalled_dtable)
return; return;
save = class->dtable; sarray_free (class->dtable); /* release memory */
__objc_install_premature_dtable (class); __objc_install_premature_dtable (class); /* someone might require it... */
sarray_free (save); __objc_install_dispatch_table_for_class (class); /* could have been lazy... */
if (class->subclass_list) /* Traverse subclasses */ if (class->subclass_list) /* Traverse subclasses */
for (next = class->subclass_list; next; next = next->sibling_class) for (next = class->subclass_list; next; next = next->sibling_class)
__objc_update_dispatch_table_for_class (next); __objc_update_dispatch_table_for_class (next);
} }
......
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