Преглед на файлове

Clarify `RwLock`s for `add_dependenies_from_unpacking`

gingerBill преди 2 години
родител
ревизия
485c606672
променени са 2 файла, в които са добавени 2 реда и са изтрити 10 реда
  1. 2 4
      src/check_expr.cpp
  2. 0 6
      src/checker.hpp

+ 2 - 4
src/check_expr.cpp

@@ -4928,23 +4928,21 @@ 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);
-
 		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_shared_lock(&decl->deps_mutex);
 					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);
+					rw_mutex_shared_unlock(&decl->deps_mutex);
 				}
 			}
 		}
-
-		// mutex_unlock(&c->info->deps_mutex);
 	}
 	return tuple_count;
 }

+ 0 - 6
src/checker.hpp

@@ -357,12 +357,6 @@ struct CheckerInfo {
 	BlockingMutex global_untyped_mutex;
 	BlockingMutex builtin_mutex;
 
-	// NOT recursive & only used at the end of `check_proc_body`
-	// and in `add_dependency`.
-	// This is a possible source of contention but probably not
-	// too much of a problem in practice
-	BlockingMutex deps_mutex;
-
 	BlockingMutex type_and_value_mutex;
 
 	RecursiveMutex lazy_mutex; // Mutex required for lazy type checking of specific files