mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Revert changes to in_single_threaded_checker_stage
This commit is contained in:
+16
-16
@@ -1,7 +1,5 @@
|
|||||||
#define DEBUG_CHECK_ALL_PROCEDURES 1
|
#define DEBUG_CHECK_ALL_PROCEDURES 1
|
||||||
|
|
||||||
gb_global bool in_single_threaded_checker_stage = false;
|
|
||||||
|
|
||||||
#include "entity.cpp"
|
#include "entity.cpp"
|
||||||
#include "types.cpp"
|
#include "types.cpp"
|
||||||
|
|
||||||
@@ -164,10 +162,10 @@ gb_internal void import_graph_node_swap(ImportGraphNode **data, isize i, isize j
|
|||||||
gb_internal void init_decl_info(DeclInfo *d, Scope *scope, DeclInfo *parent) {
|
gb_internal void init_decl_info(DeclInfo *d, Scope *scope, DeclInfo *parent) {
|
||||||
gb_zero_item(d);
|
gb_zero_item(d);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
if (!in_single_threaded_checker_stage) mutex_lock(&parent->next_mutex);
|
mutex_lock(&parent->next_mutex);
|
||||||
d->next_sibling = parent->next_child;
|
d->next_sibling = parent->next_child;
|
||||||
parent->next_child = d;
|
parent->next_child = d;
|
||||||
if (!in_single_threaded_checker_stage) mutex_unlock(&parent->next_mutex);
|
mutex_unlock(&parent->next_mutex);
|
||||||
}
|
}
|
||||||
d->parent = parent;
|
d->parent = parent;
|
||||||
d->scope = scope;
|
d->scope = scope;
|
||||||
@@ -382,9 +380,9 @@ gb_internal void scope_lookup_parent(Scope *scope, String const &name, Scope **s
|
|||||||
StringHashKey key = string_hash_string(name);
|
StringHashKey key = string_hash_string(name);
|
||||||
for (Scope *s = scope; s != nullptr; s = s->parent) {
|
for (Scope *s = scope; s != nullptr; s = s->parent) {
|
||||||
Entity **found = nullptr;
|
Entity **found = nullptr;
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_shared_lock(&s->mutex);
|
rw_mutex_shared_lock(&s->mutex);
|
||||||
found = string_map_get(&s->elements, key);
|
found = string_map_get(&s->elements, key);
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_shared_unlock(&s->mutex);
|
rw_mutex_shared_unlock(&s->mutex);
|
||||||
if (found) {
|
if (found) {
|
||||||
Entity *e = *found;
|
Entity *e = *found;
|
||||||
if (gone_thru_proc) {
|
if (gone_thru_proc) {
|
||||||
@@ -502,6 +500,8 @@ end:;
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gb_global bool in_single_threaded_checker_stage = false;
|
||||||
|
|
||||||
gb_internal Entity *scope_insert(Scope *s, Entity *entity) {
|
gb_internal Entity *scope_insert(Scope *s, Entity *entity) {
|
||||||
String name = entity->token.string;
|
String name = entity->token.string;
|
||||||
if (in_single_threaded_checker_stage) {
|
if (in_single_threaded_checker_stage) {
|
||||||
@@ -762,17 +762,17 @@ gb_internal void check_scope_usage(Checker *c, Scope *scope, u64 vet_flags) {
|
|||||||
|
|
||||||
|
|
||||||
gb_internal void add_dependency(CheckerInfo *info, DeclInfo *d, Entity *e) {
|
gb_internal void add_dependency(CheckerInfo *info, DeclInfo *d, Entity *e) {
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_lock(&d->deps_mutex);
|
rw_mutex_lock(&d->deps_mutex);
|
||||||
ptr_set_add(&d->deps, e);
|
ptr_set_add(&d->deps, e);
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_unlock(&d->deps_mutex);
|
rw_mutex_unlock(&d->deps_mutex);
|
||||||
}
|
}
|
||||||
gb_internal void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type) {
|
gb_internal void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type) {
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_lock(&d->type_info_deps_mutex);
|
rw_mutex_lock(&d->type_info_deps_mutex);
|
||||||
ptr_set_add(&d->type_info_deps, type);
|
ptr_set_add(&d->type_info_deps, type);
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_unlock(&d->type_info_deps_mutex);
|
rw_mutex_unlock(&d->type_info_deps_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1383,7 +1383,7 @@ gb_internal void reset_checker_context(CheckerContext *ctx, AstFile *file, Untyp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GB_ASSERT(ctx->checker != nullptr);
|
GB_ASSERT(ctx->checker != nullptr);
|
||||||
if (!in_single_threaded_checker_stage) mutex_lock(&ctx->mutex);
|
mutex_lock(&ctx->mutex);
|
||||||
|
|
||||||
auto type_path = ctx->type_path;
|
auto type_path = ctx->type_path;
|
||||||
array_clear(type_path);
|
array_clear(type_path);
|
||||||
@@ -1402,7 +1402,7 @@ gb_internal void reset_checker_context(CheckerContext *ctx, AstFile *file, Untyp
|
|||||||
|
|
||||||
ctx->untyped = untyped;
|
ctx->untyped = untyped;
|
||||||
|
|
||||||
if (!in_single_threaded_checker_stage) mutex_unlock(&ctx->mutex);
|
mutex_unlock(&ctx->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1548,9 +1548,9 @@ gb_internal void check_set_expr_info(CheckerContext *c, Ast *expr, AddressingMod
|
|||||||
if (c->untyped != nullptr) {
|
if (c->untyped != nullptr) {
|
||||||
map_set(c->untyped, expr, make_expr_info(mode, type, value, false));
|
map_set(c->untyped, expr, make_expr_info(mode, type, value, false));
|
||||||
} else {
|
} else {
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_lock(&c->info->global_untyped_mutex);
|
rw_mutex_lock(&c->info->global_untyped_mutex);
|
||||||
map_set(&c->info->global_untyped, expr, make_expr_info(mode, type, value, false));
|
map_set(&c->info->global_untyped, expr, make_expr_info(mode, type, value, false));
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_unlock(&c->info->global_untyped_mutex);
|
rw_mutex_unlock(&c->info->global_untyped_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1560,10 +1560,10 @@ gb_internal void check_remove_expr_info(CheckerContext *c, Ast *e) {
|
|||||||
GB_ASSERT(map_get(c->untyped, e) == nullptr);
|
GB_ASSERT(map_get(c->untyped, e) == nullptr);
|
||||||
} else {
|
} else {
|
||||||
auto *untyped = &c->info->global_untyped;
|
auto *untyped = &c->info->global_untyped;
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_lock(&c->info->global_untyped_mutex);
|
rw_mutex_lock(&c->info->global_untyped_mutex);
|
||||||
map_remove(untyped, e);
|
map_remove(untyped, e);
|
||||||
GB_ASSERT(map_get(untyped, e) == nullptr);
|
GB_ASSERT(map_get(untyped, e) == nullptr);
|
||||||
if (!in_single_threaded_checker_stage) rw_mutex_unlock(&c->info->global_untyped_mutex);
|
rw_mutex_unlock(&c->info->global_untyped_mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -808,9 +808,9 @@ gb_internal void type_path_init(TypePath *tp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gb_internal void type_path_free(TypePath *tp) {
|
gb_internal void type_path_free(TypePath *tp) {
|
||||||
if (!in_single_threaded_checker_stage) mutex_lock(&tp->mutex);
|
mutex_lock(&tp->mutex);
|
||||||
array_free(&tp->path);
|
array_free(&tp->path);
|
||||||
if (!in_single_threaded_checker_stage) mutex_unlock(&tp->mutex);
|
mutex_unlock(&tp->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_internal void type_path_print_illegal_cycle(TypePath *tp, isize start_index) {
|
gb_internal void type_path_print_illegal_cycle(TypePath *tp, isize start_index) {
|
||||||
@@ -839,7 +839,7 @@ gb_internal bool type_path_push(TypePath *tp, Type *t) {
|
|||||||
}
|
}
|
||||||
Entity *e = t->Named.type_name;
|
Entity *e = t->Named.type_name;
|
||||||
|
|
||||||
if (!in_single_threaded_checker_stage) mutex_lock(&tp->mutex);
|
mutex_lock(&tp->mutex);
|
||||||
|
|
||||||
for (isize i = 0; i < tp->path.count; i++) {
|
for (isize i = 0; i < tp->path.count; i++) {
|
||||||
Entity *p = tp->path[i];
|
Entity *p = tp->path[i];
|
||||||
@@ -850,18 +850,18 @@ gb_internal bool type_path_push(TypePath *tp, Type *t) {
|
|||||||
|
|
||||||
array_add(&tp->path, e);
|
array_add(&tp->path, e);
|
||||||
|
|
||||||
if (!in_single_threaded_checker_stage) mutex_unlock(&tp->mutex);
|
mutex_unlock(&tp->mutex);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_internal void type_path_pop(TypePath *tp) {
|
gb_internal void type_path_pop(TypePath *tp) {
|
||||||
if (tp != nullptr) {
|
if (tp != nullptr) {
|
||||||
if (!in_single_threaded_checker_stage) mutex_lock(&tp->mutex);
|
mutex_lock(&tp->mutex);
|
||||||
if (tp->path.count > 0) {
|
if (tp->path.count > 0) {
|
||||||
array_pop(&tp->path);
|
array_pop(&tp->path);
|
||||||
}
|
}
|
||||||
if (!in_single_threaded_checker_stage) mutex_unlock(&tp->mutex);
|
mutex_unlock(&tp->mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3216,8 +3216,8 @@ gb_internal Selection lookup_field_with_selection(Type *type_, String field_name
|
|||||||
GB_ASSERT(e->kind == Entity_TypeName);
|
GB_ASSERT(e->kind == Entity_TypeName);
|
||||||
if (e->TypeName.objc_metadata) {
|
if (e->TypeName.objc_metadata) {
|
||||||
auto *md = e->TypeName.objc_metadata;
|
auto *md = e->TypeName.objc_metadata;
|
||||||
if (!in_single_threaded_checker_stage) mutex_lock(md->mutex);
|
mutex_lock(md->mutex);
|
||||||
defer (if (!in_single_threaded_checker_stage) mutex_unlock(md->mutex));
|
defer (mutex_unlock(md->mutex));
|
||||||
for (TypeNameObjCMetadataEntry const &entry : md->type_entries) {
|
for (TypeNameObjCMetadataEntry const &entry : md->type_entries) {
|
||||||
GB_ASSERT(entry.entity->kind == Entity_Procedure || entry.entity->kind == Entity_ProcGroup);
|
GB_ASSERT(entry.entity->kind == Entity_Procedure || entry.entity->kind == Entity_ProcGroup);
|
||||||
if (entry.name == field_name) {
|
if (entry.name == field_name) {
|
||||||
@@ -3294,8 +3294,8 @@ gb_internal Selection lookup_field_with_selection(Type *type_, String field_name
|
|||||||
GB_ASSERT(e->kind == Entity_TypeName);
|
GB_ASSERT(e->kind == Entity_TypeName);
|
||||||
if (e->TypeName.objc_metadata) {
|
if (e->TypeName.objc_metadata) {
|
||||||
auto *md = e->TypeName.objc_metadata;
|
auto *md = e->TypeName.objc_metadata;
|
||||||
if (!in_single_threaded_checker_stage) mutex_lock(md->mutex);
|
mutex_lock(md->mutex);
|
||||||
defer (if (!in_single_threaded_checker_stage) mutex_unlock(md->mutex));
|
defer (mutex_unlock(md->mutex));
|
||||||
for (TypeNameObjCMetadataEntry const &entry : md->value_entries) {
|
for (TypeNameObjCMetadataEntry const &entry : md->value_entries) {
|
||||||
GB_ASSERT(entry.entity->kind == Entity_Procedure || entry.entity->kind == Entity_ProcGroup);
|
GB_ASSERT(entry.entity->kind == Entity_Procedure || entry.entity->kind == Entity_ProcGroup);
|
||||||
if (entry.name == field_name) {
|
if (entry.name == field_name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user