aboutsummaryrefslogtreecommitdiff
path: root/src/checker.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-03 15:47:25 +0000
committergingerBill <bill@gingerbill.org>2023-01-03 15:47:25 +0000
commit774fea1e63941473b9899a50585e0f171184a147 (patch)
tree261802cb3215cd1cc637e2f2a7e4516e08789811 /src/checker.cpp
parent485c6066724b374de5b94115411f529493f799f7 (diff)
Use `RwMutex` for `gen_procs`
Diffstat (limited to 'src/checker.cpp')
-rw-r--r--src/checker.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index fd80d07de..3f5c2892f 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -1356,9 +1356,9 @@ gb_internal ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) {
}
return nullptr;
} else {
- mutex_lock(&c->info->global_untyped_mutex);
- defer (mutex_unlock(&c->info->global_untyped_mutex));
+ rw_mutex_shared_lock(&c->info->global_untyped_mutex);
ExprInfo **found = map_get(&c->info->global_untyped, expr);
+ rw_mutex_shared_unlock(&c->info->global_untyped_mutex);
if (found) {
return *found;
}
@@ -1370,9 +1370,9 @@ gb_internal void check_set_expr_info(CheckerContext *c, Ast *expr, AddressingMod
if (c->untyped != nullptr) {
map_set(c->untyped, expr, make_expr_info(mode, type, value, false));
} else {
- mutex_lock(&c->info->global_untyped_mutex);
+ rw_mutex_lock(&c->info->global_untyped_mutex);
map_set(&c->info->global_untyped, expr, make_expr_info(mode, type, value, false));
- mutex_unlock(&c->info->global_untyped_mutex);
+ rw_mutex_unlock(&c->info->global_untyped_mutex);
}
}
@@ -1382,10 +1382,10 @@ gb_internal void check_remove_expr_info(CheckerContext *c, Ast *e) {
GB_ASSERT(map_get(c->untyped, e) == nullptr);
} else {
auto *untyped = &c->info->global_untyped;
- mutex_lock(&c->info->global_untyped_mutex);
+ rw_mutex_lock(&c->info->global_untyped_mutex);
map_remove(untyped, e);
GB_ASSERT(map_get(untyped, e) == nullptr);
- mutex_unlock(&c->info->global_untyped_mutex);
+ rw_mutex_unlock(&c->info->global_untyped_mutex);
}
}
@@ -1454,6 +1454,7 @@ gb_internal void add_type_and_value(CheckerContext *ctx, Ast *expr, AddressingMo
BlockingMutex *mutex = &ctx->info->type_and_value_mutex;
if (ctx->pkg) {
+ // TODO(bill): is a per package mutex is a good idea here?
mutex = &ctx->pkg->type_and_value_mutex;
}