-/* Store the passed selector name in the selector record and return its
- selector value (value returned by sel_get_uid).
- Assumes that the calling function has locked down __objc_runtime_mutex. */
-/* is_const parameter tells us if the name and types parameters
- are really constant or not. If YES then they are constant and
- we can just store the pointers. If NO then we need to copy
- name and types because the pointers may disappear later on. */
-SEL
+/* The uninstalled dispatch table. */
+extern struct sarray *__objc_uninstalled_dtable;
+
+/* __sel_register_typed_name allocates lots of struct objc_selector:s
+ of 8 (16, if pointers are 64 bits) bytes at startup. To reduce the
+ number of malloc calls and memory lost to malloc overhead, we
+ allocate objc_selector:s in blocks here. This is only called from
+ __sel_register_typed_name, and __sel_register_typed_name may only
+ be called when __objc_runtime_mutex is locked.
+
+ Note that the objc_selector:s allocated from
+ __sel_register_typed_name are never freed.
+
+ 62 because 62 * sizeof (struct objc_selector) = 496 (992). This
+ should let malloc add some overhead and use a nice, round 512
+ (1024) byte chunk. */
+#define SELECTOR_POOL_SIZE 62
+static struct objc_selector *selector_pool;
+static int selector_pool_left;
+
+static struct objc_selector *
+pool_alloc_selector(void)
+{
+ if (!selector_pool_left)
+ {
+ selector_pool = objc_malloc (sizeof (struct objc_selector)
+ * SELECTOR_POOL_SIZE);
+ selector_pool_left = SELECTOR_POOL_SIZE;
+ }
+ return &selector_pool[--selector_pool_left];
+}
+
+/* Store the passed selector name in the selector record and return
+ its selector value (value returned by sel_get_uid). Assume that
+ the calling function has locked down __objc_runtime_mutex. The
+ 'is_const' parameter tells us if the name and types parameters are
+ really constant or not. If YES then they are constant and we can
+ just store the pointers. If NO then we need to copy name and types
+ because the pointers may disappear later on. If the 'orig'
+ parameter is not NULL, then we are registering a selector from a
+ module, and 'orig' is that selector. In this case, we can put the
+ selector in the tables if needed, and orig->sel_id is updated with
+ the selector ID of the registered selector, and 'orig' is
+ returned. */
+static SEL