Overview
Comment: | Sequential selectors to reduce fragmentation.
This way, the sparsearrays for the dtables should be smaller. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | runtime |
Files: | files | file ages | folders |
SHA3-256: |
3f0b9df79338d76caba37584aa9da46a |
User & Date: | js on 2012-05-10 18:38:52 |
Other Links: | branch diff | manifest | tags |
Context
2012-05-12
| ||
10:22 | Add ASM for AMD64/Mach-O. (check-in: 965b8afeef user: js tags: runtime) | |
2012-05-10
| ||
18:38 | Sequential selectors to reduce fragmentation. (check-in: 3f0b9df793 user: js tags: runtime) | |
18:38 | Return objects as void* instead of const void*. (check-in: bc531024f5 user: js tags: runtime) | |
Changes
Modified src/runtime/selector.m from [d31a7805ef] to [ce39c495db].
︙ | ︙ | |||
25 26 27 28 29 30 31 | #ifndef OF_SELUID16 # define SEL_MAX 0xFFFFFF #else # define SEL_MAX 0xFFFF #endif | > > | < | | | < | < < < < | | < < | < < | < < | > | < | | < < < < | | | | < > > > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #ifndef OF_SELUID16 # define SEL_MAX 0xFFFFFF #else # define SEL_MAX 0xFFFF #endif static struct objc_hashtable *selectors = NULL; static uint32_t selectors_cnt = 0; static struct objc_sparsearray *selector_names = NULL; void objc_register_selector(struct objc_abi_selector *sel) { struct objc_selector *rsel; const char *name; if (selectors == NULL) selectors = objc_hashtable_new(2); else if ((rsel = objc_hashtable_get(selectors, sel->name)) != NULL) { ((struct objc_selector*)sel)->uid = rsel->uid; return; } if (selector_names == NULL) selector_names = objc_sparsearray_new(); name = sel->name; rsel = (struct objc_selector*)sel; rsel->uid = selectors_cnt++; if (selectors_cnt > SEL_MAX) ERROR("Out of selector slots!"); objc_hashtable_set(selectors, name, rsel); objc_sparsearray_set(selector_names, (uint32_t)rsel->uid, name); } SEL sel_registerName(const char *name) { const struct objc_abi_selector *rsel; struct objc_abi_selector *sel; if ((rsel = objc_hashtable_get(selectors, name)) != NULL) return (SEL)rsel; /* FIXME: Free on objc_exit() */ if ((sel = malloc(sizeof(struct objc_abi_selector))) == NULL) ERROR("Not enough memory to allocate selector!"); if ((sel->name = strdup(name)) == NULL) ERROR("Not enough memory to allocate selector!"); |
︙ | ︙ | |||
110 111 112 113 114 115 116 | const char* sel_getName(SEL sel) { const char *ret; objc_global_mutex_lock(); | | > | > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | const char* sel_getName(SEL sel) { const char *ret; objc_global_mutex_lock(); ret = objc_sparsearray_get(selector_names, (uint32_t)sel->uid); objc_global_mutex_unlock(); return ret; } BOOL sel_isEqual(SEL sel1, SEL sel2) { return sel1->uid == sel2->uid; } void objc_free_all_selectors(void) { objc_hashtable_free(selectors); objc_sparsearray_free(selector_names); selectors = NULL; selectors_cnt = 0; selector_names = NULL; } |