mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-29 09:24:33 +00:00
Use RwMutex for DeclInfo `deps
This commit is contained in:
@@ -1584,19 +1584,26 @@ gb_internal bool check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *de
|
||||
// NOTE(bill): Add the dependencies from the procedure literal (lambda)
|
||||
// But only at the procedure level
|
||||
|
||||
MUTEX_GUARD_BLOCK(decl->deps_mutex)
|
||||
MUTEX_GUARD_BLOCK(decl->parent->deps_mutex) {
|
||||
for (Entity *e : decl->deps) {
|
||||
ptr_set_add(&decl->parent->deps, e);
|
||||
}
|
||||
rw_mutex_shared_lock(&decl->deps_mutex);
|
||||
rw_mutex_lock(&decl->parent->deps_mutex);
|
||||
|
||||
for (Entity *e : decl->deps) {
|
||||
ptr_set_add(&decl->parent->deps, e);
|
||||
}
|
||||
|
||||
MUTEX_GUARD_BLOCK(decl->type_info_deps_mutex)
|
||||
MUTEX_GUARD_BLOCK(decl->parent->type_info_deps_mutex) {
|
||||
for (Type *t : decl->type_info_deps) {
|
||||
ptr_set_add(&decl->parent->type_info_deps, t);
|
||||
}
|
||||
rw_mutex_unlock(&decl->parent->deps_mutex);
|
||||
rw_mutex_shared_unlock(&decl->deps_mutex);
|
||||
|
||||
|
||||
rw_mutex_shared_lock(&decl->type_info_deps_mutex);
|
||||
rw_mutex_lock(&decl->parent->type_info_deps_mutex);
|
||||
|
||||
for (Type *t : decl->type_info_deps) {
|
||||
ptr_set_add(&decl->parent->type_info_deps, t);
|
||||
}
|
||||
|
||||
rw_mutex_unlock(&decl->parent->type_info_deps_mutex);
|
||||
rw_mutex_shared_unlock(&decl->type_info_deps_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4928,21 +4928,23 @@ gb_internal bool check_identifier_exists(Scope *s, Ast *node, bool nested = fals
|
||||
|
||||
gb_internal isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) {
|
||||
if (lhs != nullptr && c->decl != nullptr) {
|
||||
mutex_lock(&c->info->deps_mutex);
|
||||
// mutex_lock(&c->info->deps_mutex);
|
||||
|
||||
for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) {
|
||||
Entity *e = lhs[tuple_index + j];
|
||||
if (e != nullptr) {
|
||||
DeclInfo *decl = decl_info_of_entity(e);
|
||||
if (decl != nullptr) {
|
||||
rw_mutex_lock(&c->decl->deps_mutex);
|
||||
for (Entity *dep : decl->deps) {
|
||||
ptr_set_add(&c->decl->deps, dep);
|
||||
}
|
||||
rw_mutex_unlock(&c->decl->deps_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&c->info->deps_mutex);
|
||||
// mutex_unlock(&c->info->deps_mutex);
|
||||
}
|
||||
return tuple_count;
|
||||
}
|
||||
|
||||
@@ -744,17 +744,17 @@ gb_internal void check_scope_usage(Checker *c, Scope *scope) {
|
||||
|
||||
|
||||
gb_internal void add_dependency(CheckerInfo *info, DeclInfo *d, Entity *e) {
|
||||
mutex_lock(&d->deps_mutex);
|
||||
rw_mutex_lock(&d->deps_mutex);
|
||||
ptr_set_add(&d->deps, e);
|
||||
mutex_unlock(&d->deps_mutex);
|
||||
rw_mutex_unlock(&d->deps_mutex);
|
||||
}
|
||||
gb_internal void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type) {
|
||||
if (d == nullptr) {
|
||||
return;
|
||||
}
|
||||
mutex_lock(&d->type_info_deps_mutex);
|
||||
rw_mutex_lock(&d->type_info_deps_mutex);
|
||||
ptr_set_add(&d->type_info_deps, type);
|
||||
mutex_unlock(&d->type_info_deps_mutex);
|
||||
rw_mutex_unlock(&d->type_info_deps_mutex);
|
||||
}
|
||||
|
||||
gb_internal AstPackage *get_core_package(CheckerInfo *info, String name) {
|
||||
|
||||
@@ -179,10 +179,10 @@ struct DeclInfo {
|
||||
CommentGroup *comment;
|
||||
CommentGroup *docs;
|
||||
|
||||
BlockingMutex deps_mutex;
|
||||
RwMutex deps_mutex;
|
||||
PtrSet<Entity *> deps;
|
||||
|
||||
BlockingMutex type_info_deps_mutex;
|
||||
RwMutex type_info_deps_mutex;
|
||||
PtrSet<Type *> type_info_deps;
|
||||
|
||||
Array<BlockLabel> labels;
|
||||
|
||||
Reference in New Issue
Block a user