mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-31 18:32:12 +00:00
Convert minimum_dependency_type_info_set to use a PtrMap
This commit is contained in:
@@ -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) { \
|
||||
|
||||
@@ -336,7 +336,7 @@ struct CheckerInfo {
|
||||
Scope * init_scope;
|
||||
Entity * entry_point;
|
||||
PtrSet<Entity *> minimum_dependency_set;
|
||||
PtrSet<isize> minimum_dependency_type_info_set;
|
||||
PtrMap</*type info index*/isize, /*min dep index*/isize> minimum_dependency_type_info_set;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -229,7 +229,6 @@ gb_internal void map_set(PtrMap<K, V> *h, K key, V const &value) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
gb_internal void map__erase(PtrMap<K, V> *h, MapFindResult const &fr) {
|
||||
MapFindResult last;
|
||||
|
||||
@@ -12,7 +12,6 @@ struct PtrSetEntry {
|
||||
|
||||
template <typename T>
|
||||
struct PtrSet {
|
||||
|
||||
Slice<MapIndex> hashes;
|
||||
Array<PtrSetEntry<T>> entries;
|
||||
};
|
||||
@@ -154,15 +153,6 @@ gb_internal gb_inline bool ptr_set_exists(PtrSet<T> *s, T ptr) {
|
||||
return index != MAP_SENTINEL;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
gb_internal gb_inline isize ptr_set_entry_index(PtrSet<T> *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 <typename T>
|
||||
gb_internal T ptr_set_add(PtrSet<T> *s, T ptr) {
|
||||
|
||||
Reference in New Issue
Block a user