diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-10 13:26:07 +0100 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-10 13:26:07 +0100 |
| commit | 70d396c8ad7b79e3e3676cfbb732565653f0d627 (patch) | |
| tree | 2a5edc3c5a963dd90e239fe41dd2096b9bab2add /src | |
| parent | 629777b988da50ab347b6309ac07821acfd1ee59 (diff) | |
Split type and inline cycles into separate loops
Diffstat (limited to 'src')
| -rw-r--r-- | src/checker.cpp | 41 | ||||
| -rw-r--r-- | src/checker.hpp | 3 |
2 files changed, 29 insertions, 15 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index c43175230..441c7fa6a 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2552,14 +2552,12 @@ gb_internal void add_min_dep_type_info(Checker *c, Type *t) { } } - gb_internal void add_dependency_to_set(Checker *c, Entity *entity) { if (entity == nullptr) { return; } CheckerInfo *info = &c->info; - auto *set = &info->minimum_dependency_set; if (entity->type != nullptr && is_type_polymorphic(entity->type)) { @@ -2569,8 +2567,11 @@ gb_internal void add_dependency_to_set(Checker *c, Entity *entity) { } } - if (ptr_set_update(set, entity)) { - return; + { + MUTEX_GUARD(&info->minimum_dependency_type_info_mutex); + if (ptr_set_update(&info->minimum_dependency_set, entity)) { + return; + } } DeclInfo *decl = decl_info_of_entity(entity); @@ -7173,25 +7174,35 @@ gb_internal void check_parsed_files(Checker *c) { } check_merge_queues_into_arrays(c); - TIME_SECTION("check for type cycles and inline cycles"); + TIME_SECTION("check for type cycles"); // NOTE(bill): Check for illegal cyclic type declarations for_array(i, c->info.definitions) { Entity *e = c->info.definitions[i]; - if (e->kind == Entity_TypeName && e->type != nullptr && is_type_typed(e->type)) { + if (e->kind != Entity_TypeName) { + continue; + } + if (e->type != nullptr && is_type_typed(e->type)) { if (e->TypeName.is_type_alias) { // Ignore for the time being } else { (void)type_align_of(e->type); } - } else if (e->kind == Entity_Procedure) { - DeclInfo *decl = e->decl_info; - ast_node(pl, ProcLit, decl->proc_lit); - if (pl->inlining == ProcInlining_inline) { - for (Entity *dep : decl->deps) { - if (dep == e) { - error(e->token, "Cannot inline recursive procedure '%.*s'", LIT(e->token.string)); - break; - } + } + } + + TIME_SECTION("check for inline cycles"); + for_array(i, c->info.definitions) { + Entity *e = c->info.definitions[i]; + if (e->kind != Entity_Procedure) { + continue; + } + DeclInfo *decl = e->decl_info; + ast_node(pl, ProcLit, decl->proc_lit); + if (pl->inlining == ProcInlining_inline) { + for (Entity *dep : decl->deps) { + if (dep == e) { + error(e->token, "Cannot inline recursive procedure '%.*s'", LIT(e->token.string)); + break; } } } diff --git a/src/checker.hpp b/src/checker.hpp index 58ac8beb5..1da46b74a 100644 --- a/src/checker.hpp +++ b/src/checker.hpp @@ -448,7 +448,10 @@ struct CheckerInfo { AstPackage * init_package; Scope * init_scope; Entity * entry_point; + + BlockingMutex minimum_dependency_set_mutex; PtrSet<Entity *> minimum_dependency_set; + BlockingMutex minimum_dependency_type_info_mutex; PtrMap</*type info hash*/u64, /*min dep index*/isize> min_dep_type_info_index_map; TypeSet min_dep_type_info_set; |