Differences From Artifact [0500525bf9]:
- File src/runtime/class.m — part of check-in [3780f1462e] at 2013-11-22 23:24:03 on branch trunk — runtime: Add support for non-fragile ivars. (user: js, size: 13227) [annotate] [blame] [check-ins using]
To Artifact [e9b6e354b6]:
- File
src/runtime/class.m
— part of check-in
[84a724dd4b]
at
2013-12-06 00:52:26
on branch trunk
— Add a fast path for objc_classname_to_class().
This should improve the performance for the GCC ABI, as
objc_classname_to_class() is used for all sorts of class lookups, e.g.
objc_lookup_class().As this performance improvement needs RAM, it is only used after 128
calls into objc_classname_to_class(), so that if the ObjFW ABI is used
and the user does not call into objc_getClass() or similar in a loop, no
memory is wasted.Runtime internal usage of objc_classname_to_class() does not use the
fast path and does not count as a call into objc_classname_to_class().
The reason for this is that if the runtime calls
objc_classname_to_class(), it already has the lock and thus the
performance gain would be small, but it would waste memory. (user: js, size: 15844) [annotate] [blame] [check-ins using]
︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | + + + + + + | #include <stdio.h> #include <stdlib.h> #include <string.h> #import "runtime.h" #import "runtime-private.h" struct sparsearray { void *next[256]; }; static struct objc_hashtable *classes = NULL; static Class *load_queue = NULL; static size_t load_queue_cnt = 0; static struct objc_sparsearray *empty_dtable = NULL; static unsigned lookups_till_fast_path = 128; static struct sparsearray *sparsearray = NULL; static void register_class(struct objc_abi_class *cls) { if (classes == NULL) classes = objc_hashtable_new(2); |
︙ | |||
63 64 65 66 67 68 69 | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | for (ml = cls->methodlist; ml != NULL; ml = ml->next) for (i = 0; i < ml->count; i++) objc_register_selector( (struct objc_abi_selector*)&ml->methods[i]); } inline Class |
︙ | |||
235 236 237 238 239 240 241 | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | - + | { const char *superclass; if (cls->info & OBJC_CLASS_INFO_SETUP) return; if ((superclass = ((struct objc_abi_class*)cls)->superclass) != NULL) { |
︙ | |||
379 380 381 382 383 384 385 | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | - + - + | } } } id objc_lookUpClass(const char *name) { |
︙ | |||
629 630 631 632 633 634 635 636 637 638 639 | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | + + + + + + + + + + + + + + - + + + + | rcls->dtable = NULL; if (rcls->superclass != Nil) cls->superclass = rcls->superclass->name; objc_hashtable_set(classes, cls->name, NULL); } static void free_sparsearray(struct sparsearray *sa, size_t depth) { uint_fast16_t i; if (sa == NULL || depth == 0) return; for (i = 0; i < 256; i++) free_sparsearray(sa->next[i], depth - 1); free(sa); } void objc_free_all_classes(void) { |