diff options
| author | gingerBill <bill@gingerbill.org> | 2023-01-02 19:39:35 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-01-02 19:39:35 +0000 |
| commit | 0d87b2e8db045b33cc6da18f5c53d8c3266c12b3 (patch) | |
| tree | e3cd46aa1a532348260fe91b850460b216fa602c /src/checker.cpp | |
| parent | 1568971732bd04a7f68a52277c0b2ab0cb5009c2 (diff) | |
Use local mutexes rather than a global one for the dependency insertion
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index c9e84a35b..daebe0d31 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -743,21 +743,17 @@ gb_internal void check_scope_usage(Checker *c, Scope *scope) { gb_internal void add_dependency(CheckerInfo *info, DeclInfo *d, Entity *e) { - mutex_lock(&info->deps_mutex); + mutex_lock(&d->deps_mutex); ptr_set_add(&d->deps, e); - mutex_unlock(&info->deps_mutex); + mutex_unlock(&d->deps_mutex); } -gb_internal void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type, bool require_mutex) { +gb_internal void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type) { if (d == nullptr) { return; } - if (require_mutex) { - mutex_lock(&info->deps_mutex); - } + mutex_lock(&d->type_info_deps_mutex); ptr_set_add(&d->type_info_deps, type); - if (require_mutex) { - mutex_unlock(&info->deps_mutex); - } + mutex_unlock(&d->type_info_deps_mutex); } gb_internal AstPackage *get_core_package(CheckerInfo *info, String name) { @@ -1157,13 +1153,6 @@ gb_internal void init_checker_info(CheckerInfo *i) { array_init(&i->required_foreign_imports_through_force, a, 0, 0); - - i->allow_identifier_uses = false; - if (i->allow_identifier_uses) { - array_init(&i->identifier_uses, a); - } - - TIME_SECTION("checker info: mpmc queues"); mpmc_init(&i->entity_queue, a, 1<<20); @@ -1194,7 +1183,6 @@ gb_internal void destroy_checker_info(CheckerInfo *i) { string_map_destroy(&i->files); string_map_destroy(&i->packages); array_free(&i->variable_init_order); - array_free(&i->identifier_uses); array_free(&i->required_foreign_imports_through_force); mpmc_destroy(&i->entity_queue); @@ -1597,12 +1585,6 @@ gb_internal void add_entity_use(CheckerContext *c, Ast *identifier, Entity *enti identifier->Ident.entity = entity; - if (c->info->allow_identifier_uses) { - mutex_lock(&c->info->identifier_uses_mutex); - array_add(&c->info->identifier_uses, identifier); - mutex_unlock(&c->info->identifier_uses_mutex); - } - String dmsg = entity->deprecated_message; if (dmsg.len > 0) { warning(identifier, "%.*s is deprecated: %.*s", LIT(entity->token.string), LIT(dmsg)); @@ -1767,7 +1749,7 @@ gb_internal void add_type_info_type_internal(CheckerContext *c, Type *t) { return; } - add_type_info_dependency(c->info, c->decl, t, false); + add_type_info_dependency(c->info, c->decl, t); auto found = map_get(&c->info->type_info_map, t); if (found != nullptr) { |