aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_utility.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2025-04-02 18:26:40 +0100
committergingerBill <bill@gingerbill.org>2025-04-02 18:26:40 +0100
commit5eaff20f4a672760b4d90d596dd46be132634f41 (patch)
treeebe2fb76769dba67bb7deb70a3fe6a0afac6ca12 /src/llvm_backend_utility.cpp
parentb615e772642c93602f34a8bcfb5298797d4b62ad (diff)
Add mutex for `lb_handle_objc_find_or_register_class`
Diffstat (limited to 'src/llvm_backend_utility.cpp')
-rw-r--r--src/llvm_backend_utility.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp
index a21039360..efe196e58 100644
--- a/src/llvm_backend_utility.cpp
+++ b/src/llvm_backend_utility.cpp
@@ -2165,6 +2165,9 @@ gb_internal lbValue lb_handle_objc_register_selector(lbProcedure *p, Ast *expr)
}
gb_internal lbAddr lb_handle_objc_find_or_register_class(lbProcedure *p, String const &name) {
+ mutex_lock(&p->module->objc_classes_mutex);
+ defer (mutex_unlock(&p->module->objc_classes_mutex));
+
lbObjcRef *found = string_map_get(&p->module->objc_classes, name);
if (found) {
return found->local_module_addr;
@@ -2187,7 +2190,10 @@ gb_internal lbAddr lb_handle_objc_find_or_register_class(lbProcedure *p, String
lbAddr default_addr = lb_add_global_generated_with_name(default_module, t_objc_Class, {},
make_string(cast(u8 const *)global_name, gb_string_length(global_name)),
&entity);
+
+ mutex_lock(&default_module->objc_classes_mutex);
string_map_set(&default_module->objc_classes, name, lbObjcRef{entity, default_addr});
+ mutex_unlock(&default_module->objc_classes_mutex);
}
lbValue ptr = lb_find_value_from_entity(p->module, entity);