mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Add mutex for lb_handle_objc_find_or_register_class
This commit is contained in:
@@ -165,7 +165,6 @@ struct lbModule {
|
|||||||
PtrMap<u64/*type hash*/, LLVMTypeRef> func_raw_types; // mutex: func_raw_types_mutex
|
PtrMap<u64/*type hash*/, LLVMTypeRef> func_raw_types; // mutex: func_raw_types_mutex
|
||||||
RecursiveMutex types_mutex;
|
RecursiveMutex types_mutex;
|
||||||
RecursiveMutex func_raw_types_mutex;
|
RecursiveMutex func_raw_types_mutex;
|
||||||
RecursiveMutex objc_selectors_mutex;
|
|
||||||
i32 internal_type_level;
|
i32 internal_type_level;
|
||||||
|
|
||||||
RwMutex values_mutex;
|
RwMutex values_mutex;
|
||||||
@@ -199,6 +198,10 @@ struct lbModule {
|
|||||||
RecursiveMutex debug_values_mutex;
|
RecursiveMutex debug_values_mutex;
|
||||||
PtrMap<void *, LLVMMetadataRef> debug_values;
|
PtrMap<void *, LLVMMetadataRef> debug_values;
|
||||||
|
|
||||||
|
|
||||||
|
RecursiveMutex objc_classes_mutex;
|
||||||
|
RecursiveMutex objc_selectors_mutex;
|
||||||
|
|
||||||
StringMap<lbObjcRef> objc_classes;
|
StringMap<lbObjcRef> objc_classes;
|
||||||
StringMap<lbObjcRef> objc_selectors;
|
StringMap<lbObjcRef> objc_selectors;
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
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);
|
lbObjcRef *found = string_map_get(&p->module->objc_classes, name);
|
||||||
if (found) {
|
if (found) {
|
||||||
return found->local_module_addr;
|
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, {},
|
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)),
|
make_string(cast(u8 const *)global_name, gb_string_length(global_name)),
|
||||||
&entity);
|
&entity);
|
||||||
|
|
||||||
|
mutex_lock(&default_module->objc_classes_mutex);
|
||||||
string_map_set(&default_module->objc_classes, name, lbObjcRef{entity, default_addr});
|
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);
|
lbValue ptr = lb_find_value_from_entity(p->module, entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user