Make defer_use_checked and where_clauses_evaluated atomic

This commit is contained in:
gingerBill
2026-02-02 10:54:49 +00:00
parent 74347f3069
commit 8a92ba74fc
3 changed files with 11 additions and 11 deletions

View File

@@ -2155,7 +2155,7 @@ gb_internal bool check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *de
rw_mutex_unlock(&ctx->scope->mutex);
bool where_clause_ok = evaluate_where_clauses(ctx, nullptr, decl->scope, &decl->proc_lit->ProcLit.where_clauses, !decl->where_clauses_evaluated);
bool where_clause_ok = evaluate_where_clauses(ctx, nullptr, decl->scope, &decl->proc_lit->ProcLit.where_clauses, !decl->where_clauses_evaluated.load(std::memory_order_relaxed));
if (!where_clause_ok) {
// NOTE(bill, 2019-08-31): Don't check the body as the where clauses failed
return false;
@@ -2173,15 +2173,15 @@ gb_internal bool check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *de
}
GB_ASSERT(decl->proc_checked_state != ProcCheckedState_Checked);
if (decl->defer_use_checked) {
if (decl->defer_use_checked.load(std::memory_order_relaxed)) {
GB_ASSERT(is_type_polymorphic(type, true));
error(token, "Defer Use Checked: %.*s", LIT(decl->entity.load()->token.string));
GB_ASSERT(decl->defer_use_checked == false);
GB_ASSERT(decl->defer_use_checked.load(std::memory_order_relaxed) == false);
}
check_stmt_list(ctx, bs->stmts, Stmt_CheckScopeDecls);
decl->defer_use_checked = true;
decl->defer_use_checked.store(true, std::memory_order_relaxed);
for (Ast *stmt : bs->stmts) {
if (stmt->kind == Ast_ValueDecl) {

View File

@@ -221,14 +221,14 @@ struct DeclInfo {
Entity * para_poly_original;
bool is_using;
bool where_clauses_evaluated;
bool foreign_require_results;
bool is_using;
bool foreign_require_results;
std::atomic<bool> where_clauses_evaluated;
std::atomic<ProcCheckedState> proc_checked_state;
BlockingMutex proc_checked_mutex;
isize defer_used;
bool defer_use_checked;
BlockingMutex proc_checked_mutex;
isize defer_used;
std::atomic<bool> defer_use_checked;
CommentGroup *comment;
CommentGroup *docs;

View File

@@ -676,7 +676,7 @@ gb_internal void lb_begin_procedure_body(lbProcedure *p) {
lbAddr res = {};
if (p->entity && p->entity->decl_info &&
p->entity->decl_info->defer_use_checked &&
p->entity->decl_info->defer_use_checked.load(std::memory_order_relaxed) &&
p->entity->decl_info->defer_used == 0) {
// NOTE(bill): this is a bodge to get around the issue of the problem BELOW