mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Convert minimum_dependency_type_info_set to use a PtrMap
This commit is contained in:
+7
-12
@@ -1153,6 +1153,9 @@ gb_internal void init_checker_info(CheckerInfo *i) {
|
|||||||
array_init(&i->init_procedures, a, 0, 0);
|
array_init(&i->init_procedures, a, 0, 0);
|
||||||
array_init(&i->required_foreign_imports_through_force, 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");
|
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->definition_queue, a, 1<<20);
|
||||||
mpmc_init(&i->required_global_variable_queue, a, 1<<10);
|
mpmc_init(&i->required_global_variable_queue, a, 1<<10);
|
||||||
mpmc_init(&i->required_foreign_imports_through_force_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
|
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) {
|
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);
|
ti_index = type_info_index(&c->info, t, false);
|
||||||
}
|
}
|
||||||
GB_ASSERT(ti_index >= 0);
|
GB_ASSERT(ti_index >= 0);
|
||||||
if (ptr_set_update(set, ti_index)) {
|
if (map_get(set, ti_index)) {
|
||||||
// Type Already exists
|
// Type already exists;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
map_set(set, ti_index, set->entries.count);
|
||||||
|
|
||||||
// Add nested types
|
// Add nested types
|
||||||
if (t->kind == Type_Named) {
|
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
|
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_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 { \
|
#define FORCE_ADD_RUNTIME_ENTITIES(condition, ...) do { \
|
||||||
if (condition) { \
|
if (condition) { \
|
||||||
|
|||||||
+1
-1
@@ -336,7 +336,7 @@ struct CheckerInfo {
|
|||||||
Scope * init_scope;
|
Scope * init_scope;
|
||||||
Entity * entry_point;
|
Entity * entry_point;
|
||||||
PtrSet<Entity *> minimum_dependency_set;
|
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;
|
auto *set = &info->minimum_dependency_type_info_set;
|
||||||
isize index = type_info_index(info, type, err_on_not_found);
|
isize index = type_info_index(info, type, err_on_not_found);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
isize i = ptr_set_entry_index(set, index);
|
auto *found = map_get(set, index);
|
||||||
if (i >= 0) {
|
if (found) {
|
||||||
return i+1;
|
GB_ASSERT(*found >= 0);
|
||||||
|
return *found + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (err_on_not_found) {
|
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>
|
template <typename K, typename V>
|
||||||
gb_internal void map__erase(PtrMap<K, V> *h, MapFindResult const &fr) {
|
gb_internal void map__erase(PtrMap<K, V> *h, MapFindResult const &fr) {
|
||||||
MapFindResult last;
|
MapFindResult last;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ struct PtrSetEntry {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct PtrSet {
|
struct PtrSet {
|
||||||
|
|
||||||
Slice<MapIndex> hashes;
|
Slice<MapIndex> hashes;
|
||||||
Array<PtrSetEntry<T>> entries;
|
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;
|
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
|
// Returns true if it already exists
|
||||||
template <typename T>
|
template <typename T>
|
||||||
gb_internal T ptr_set_add(PtrSet<T> *s, T ptr) {
|
gb_internal T ptr_set_add(PtrSet<T> *s, T ptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user