mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-12 22:31:25 -07:00
Remove global PtrMap<Type *, GenTypesData *> and store on the TypeNamed directly
This commit is contained in:
+9
-9
@@ -267,19 +267,19 @@ gb_internal bool check_custom_align(CheckerContext *ctx, Ast *node, i64 *align_,
|
||||
|
||||
|
||||
gb_internal GenTypesData *ensure_polymorphic_record_entity_has_gen_types(CheckerContext *ctx, Type *original_type) {
|
||||
mutex_lock(&ctx->info->gen_types_mutex); // @@global
|
||||
|
||||
GenTypesData *found_gen_types = nullptr;
|
||||
auto *found_gen_types_ptr = map_get(&ctx->info->gen_types, original_type);
|
||||
if (found_gen_types_ptr == nullptr) {
|
||||
|
||||
GB_ASSERT(original_type->kind == Type_Named);
|
||||
mutex_lock(&original_type->Named.gen_types_data_mutex);
|
||||
if (original_type->Named.gen_types_data == nullptr) {
|
||||
GenTypesData *gen_types = gb_alloc_item(permanent_allocator(), GenTypesData);
|
||||
gen_types->types = array_make<Entity *>(heap_allocator());
|
||||
map_set(&ctx->info->gen_types, original_type, gen_types);
|
||||
found_gen_types_ptr = map_get(&ctx->info->gen_types, original_type);
|
||||
original_type->Named.gen_types_data = gen_types;
|
||||
}
|
||||
found_gen_types = *found_gen_types_ptr;
|
||||
GB_ASSERT(found_gen_types != nullptr);
|
||||
mutex_unlock(&ctx->info->gen_types_mutex); // @@global
|
||||
found_gen_types = original_type->Named.gen_types_data;
|
||||
|
||||
mutex_unlock(&original_type->Named.gen_types_data_mutex);
|
||||
|
||||
return found_gen_types;
|
||||
}
|
||||
|
||||
|
||||
@@ -1420,13 +1420,10 @@ gb_internal void init_checker_info(CheckerInfo *i) {
|
||||
array_init(&i->entities, a);
|
||||
map_init(&i->global_untyped);
|
||||
string_map_init(&i->foreigns);
|
||||
// map_init(&i->gen_procs);
|
||||
map_init(&i->gen_types);
|
||||
|
||||
type_set_init(&i->min_dep_type_info_set);
|
||||
map_init(&i->min_dep_type_info_index_map);
|
||||
|
||||
// map_init(&i->type_info_map);
|
||||
string_map_init(&i->files);
|
||||
string_map_init(&i->packages);
|
||||
array_init(&i->variable_init_order, a);
|
||||
@@ -1465,8 +1462,6 @@ gb_internal void destroy_checker_info(CheckerInfo *i) {
|
||||
array_free(&i->entities);
|
||||
map_destroy(&i->global_untyped);
|
||||
string_map_destroy(&i->foreigns);
|
||||
// map_destroy(&i->gen_procs);
|
||||
map_destroy(&i->gen_types);
|
||||
|
||||
type_set_destroy(&i->min_dep_type_info_set);
|
||||
map_destroy(&i->min_dep_type_info_index_map);
|
||||
|
||||
@@ -480,8 +480,6 @@ struct CheckerInfo {
|
||||
|
||||
RecursiveMutex lazy_mutex; // Mutex required for lazy type checking of specific files
|
||||
|
||||
BlockingMutex gen_types_mutex;
|
||||
PtrMap<Type *, GenTypesData *> gen_types;
|
||||
|
||||
// BlockingMutex type_info_mutex; // NOT recursive
|
||||
// Array<TypeInfoPair> type_info_types;
|
||||
|
||||
+10
-5
@@ -206,13 +206,18 @@ struct TypeProc {
|
||||
bool optional_ok;
|
||||
};
|
||||
|
||||
struct TypeNamed {
|
||||
String name;
|
||||
Type * base;
|
||||
Entity *type_name; /* Entity_TypeName */
|
||||
|
||||
BlockingMutex gen_types_data_mutex;
|
||||
GenTypesData *gen_types_data;
|
||||
};
|
||||
|
||||
#define TYPE_KINDS \
|
||||
TYPE_KIND(Basic, BasicType) \
|
||||
TYPE_KIND(Named, struct { \
|
||||
String name; \
|
||||
Type * base; \
|
||||
Entity *type_name; /* Entity_TypeName */ \
|
||||
}) \
|
||||
TYPE_KIND(Named, TypeNamed) \
|
||||
TYPE_KIND(Generic, struct { \
|
||||
i64 id; \
|
||||
String name; \
|
||||
|
||||
Reference in New Issue
Block a user