|
@@ -366,8 +366,6 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
|
|
GB_ASSERT(dst == nullptr);
|
|
GB_ASSERT(dst == nullptr);
|
|
}
|
|
}
|
|
|
|
|
|
- // MUTEX_GUARD(&info->gen_procs_mutex);
|
|
|
|
-
|
|
|
|
if (!src->Proc.is_polymorphic || src->Proc.is_poly_specialized) {
|
|
if (!src->Proc.is_polymorphic || src->Proc.is_poly_specialized) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -434,20 +432,21 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
|
|
|
|
|
|
GenProcsData *gen_procs = nullptr;
|
|
GenProcsData *gen_procs = nullptr;
|
|
|
|
|
|
- // @@GPM //////////////////////////
|
|
|
|
- mutex_lock(&info->gen_procs_mutex);
|
|
|
|
- ///////////////////////////////////
|
|
|
|
- auto *found = map_get(&info->gen_procs, base_entity->identifier.load());
|
|
|
|
- if (found) {
|
|
|
|
- gen_procs = *found;
|
|
|
|
|
|
+ GB_ASSERT(base_entity->identifier.load()->kind == Ast_Ident);
|
|
|
|
+ GB_ASSERT(base_entity->kind == Entity_Procedure);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ mutex_lock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
|
|
|
|
+
|
|
|
|
+ gen_procs = base_entity->Procedure.gen_procs;
|
|
|
|
+ if (gen_procs) {
|
|
rw_mutex_shared_lock(&gen_procs->mutex); // @local-mutex
|
|
rw_mutex_shared_lock(&gen_procs->mutex); // @local-mutex
|
|
|
|
+
|
|
for (Entity *other : gen_procs->procs) {
|
|
for (Entity *other : gen_procs->procs) {
|
|
Type *pt = base_type(other->type);
|
|
Type *pt = base_type(other->type);
|
|
if (are_types_identical(pt, final_proc_type)) {
|
|
if (are_types_identical(pt, final_proc_type)) {
|
|
rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex
|
|
rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex
|
|
- // @@GPM ////////////////////////////
|
|
|
|
- mutex_unlock(&info->gen_procs_mutex);
|
|
|
|
- /////////////////////////////////////
|
|
|
|
|
|
+ mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
|
|
|
|
|
|
if (poly_proc_data) {
|
|
if (poly_proc_data) {
|
|
poly_proc_data->gen_entity = other;
|
|
poly_proc_data->gen_entity = other;
|
|
@@ -455,15 +454,15 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex
|
|
rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex
|
|
} else {
|
|
} else {
|
|
gen_procs = gb_alloc_item(permanent_allocator(), GenProcsData);
|
|
gen_procs = gb_alloc_item(permanent_allocator(), GenProcsData);
|
|
gen_procs->procs.allocator = heap_allocator();
|
|
gen_procs->procs.allocator = heap_allocator();
|
|
- map_set(&info->gen_procs, base_entity->identifier.load(), gen_procs);
|
|
|
|
|
|
+ base_entity->Procedure.gen_procs = gen_procs;
|
|
}
|
|
}
|
|
- // @@GPM ////////////////////////////
|
|
|
|
- mutex_unlock(&info->gen_procs_mutex);
|
|
|
|
- /////////////////////////////////////
|
|
|
|
|
|
+
|
|
|
|
+ mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
|
|
|
|
|
|
{
|
|
{
|
|
// LEAK TODO(bill): This is technically a memory leak as it has to generate the type twice
|
|
// LEAK TODO(bill): This is technically a memory leak as it has to generate the type twice
|