Move the selector table to being protected by a mutex for reads so that we can

recover memory from the smaller ones.  Selector lookups are not on the critical
path for message sends, so the cost of the extra memory is likely to be larger
than the cost of acquiring a lock in sel_getName().
main
theraven 13 years ago
parent eb234ea26a
commit d7df8c415b

@ -199,6 +199,7 @@ static int PREFIX(_table_resize)(PREFIX(_table) *table)
__sync_synchronize();
table->old = NULL;
# if !defined(ENABLE_GC) && defined(MAP_TABLE_SINGLE_THREAD)
free(copy->table);
free(copy);
# endif
return 1;

@ -211,6 +211,7 @@ static inline uint32_t hash_selector(const void *s)
}
#define MAP_TABLE_NAME selector
#define MAP_TABLE_SINGLE_THREAD
#define MAP_TABLE_COMPARE_FUNCTION selector_identical
#define MAP_TABLE_HASH_KEY hash_selector
#define MAP_TABLE_HASH_VALUE hash_selector
@ -245,6 +246,7 @@ PRIVATE void init_selector_tables()
static SEL selector_lookup(const char *name, const char *types)
{
struct objc_selector sel = {{name}, types};
LOCK_FOR_SCOPE(&selector_table_lock);
return selector_table_get(sel_table, &sel);
}
static inline void add_selector_to_table(SEL aSel, int32_t uid, uint32_t idx)

Loading…
Cancel
Save