diff --git a/src/checker.cpp b/src/checker.cpp index 11e0dfa47..78f96e47f 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1153,6 +1153,9 @@ gb_internal void init_checker_info(CheckerInfo *i) { array_init(&i->init_procedures, a, 0, 0); array_init(&i->required_foreign_imports_through_force, a, 0, 0); + map_init(&i->objc_msgSend_types); + string_map_init(&i->load_file_cache); + array_init(&i->all_procedures, heap_allocator()); TIME_SECTION("checker info: mpmc queues"); @@ -1160,16 +1163,7 @@ gb_internal void init_checker_info(CheckerInfo *i) { mpmc_init(&i->definition_queue, a, 1<<20); mpmc_init(&i->required_global_variable_queue, a, 1<<10); mpmc_init(&i->required_foreign_imports_through_force_queue, a, 1<<10); - - TIME_SECTION("checker info: mutexes"); - mpmc_init(&i->intrinsics_entry_point_usage, a, 1<<10); // just waste some memory here, even if it probably never used - - map_init(&i->objc_msgSend_types); - string_map_init(&i->load_file_cache); - - array_init(&i->all_procedures, heap_allocator()); - } gb_internal void destroy_checker_info(CheckerInfo *i) { @@ -2031,10 +2025,11 @@ gb_internal void add_min_dep_type_info(Checker *c, Type *t) { ti_index = type_info_index(&c->info, t, false); } GB_ASSERT(ti_index >= 0); - if (ptr_set_update(set, ti_index)) { - // Type Already exists + if (map_get(set, ti_index)) { + // Type already exists; return; } + map_set(set, ti_index, set->entries.count); // Add nested types if (t->kind == Type_Named) { @@ -2275,7 +2270,7 @@ gb_internal void generate_minimum_dependency_set(Checker *c, Entity *start) { isize min_dep_set_cap = next_pow2_isize(entity_count*4); // empirically determined factor ptr_set_init(&c->info.minimum_dependency_set, min_dep_set_cap); - ptr_set_init(&c->info.minimum_dependency_type_info_set); + map_init(&c->info.minimum_dependency_type_info_set); #define FORCE_ADD_RUNTIME_ENTITIES(condition, ...) do { \ if (condition) { \ diff --git a/src/checker.hpp b/src/checker.hpp index 60800349b..bb870e077 100644 --- a/src/checker.hpp +++ b/src/checker.hpp @@ -336,7 +336,7 @@ struct CheckerInfo { Scope * init_scope; Entity * entry_point; PtrSet minimum_dependency_set; - PtrSet minimum_dependency_type_info_set; + PtrMap minimum_dependency_type_info_set; diff --git a/src/llvm_backend_type.cpp b/src/llvm_backend_type.cpp index c306cdead..b9b450404 100644 --- a/src/llvm_backend_type.cpp +++ b/src/llvm_backend_type.cpp @@ -2,9 +2,10 @@ gb_internal isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_ auto *set = &info->minimum_dependency_type_info_set; isize index = type_info_index(info, type, err_on_not_found); if (index >= 0) { - isize i = ptr_set_entry_index(set, index); - if (i >= 0) { - return i+1; + auto *found = map_get(set, index); + if (found) { + GB_ASSERT(*found >= 0); + return *found + 1; } } if (err_on_not_found) { diff --git a/src/ptr_map.cpp b/src/ptr_map.cpp index 264136881..ae3cd4b40 100644 --- a/src/ptr_map.cpp +++ b/src/ptr_map.cpp @@ -229,7 +229,6 @@ gb_internal void map_set(PtrMap *h, K key, V const &value) { } } - template gb_internal void map__erase(PtrMap *h, MapFindResult const &fr) { MapFindResult last; diff --git a/src/ptr_set.cpp b/src/ptr_set.cpp index 9b8b678f8..f730a47ff 100644 --- a/src/ptr_set.cpp +++ b/src/ptr_set.cpp @@ -12,7 +12,6 @@ struct PtrSetEntry { template struct PtrSet { - Slice hashes; Array> entries; }; @@ -154,15 +153,6 @@ gb_internal gb_inline bool ptr_set_exists(PtrSet *s, T ptr) { return index != MAP_SENTINEL; } -template -gb_internal gb_inline isize ptr_set_entry_index(PtrSet *s, T ptr) { - isize index = ptr_set__find(s, ptr).entry_index; - if (index != MAP_SENTINEL) { - return index; - } - return -1; -} - // Returns true if it already exists template gb_internal T ptr_set_add(PtrSet *s, T ptr) {