From 2608f92fee1656ff11f4487667eb72df256eadc7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 2 Feb 2026 10:46:57 +0000 Subject: [PATCH] Use `std::atomic` for `Ast.viral_state_flags` and `Ast_Ident.entity` --- src/check_builtin.cpp | 4 ++-- src/llvm_backend_utility.cpp | 2 +- src/parser.hpp | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index e732d8ec3..e2428576e 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -534,12 +534,12 @@ gb_internal bool check_builtin_objc_procedure(CheckerContext *c, Operand *operan return false; } - if (ident.entity->kind != Entity_Procedure) { + if (ident.entity.load()->kind != Entity_Procedure) { gbString e = expr_to_string(handler_node); ERROR_BLOCK(); error(handler.expr, "'%.*s' expected a direct reference to a procedure", LIT(builtin_name)); - if(ident.entity->kind == Entity_Variable) { + if(ident.entity.load()->kind == Entity_Variable) { error_line("\tSuggestion: Variables referencing a procedure are not allowed, they are not a direct procedure reference."); } else { error_line("\tSuggestion: Ensure '%s' is not a runtime-evaluated expression.", e); // NOTE(harold): Is this case possible to hit? diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index 929239486..367e7be75 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -2419,7 +2419,7 @@ gb_internal lbValue lb_handle_objc_block(lbProcedure *p, Ast *expr) { Ast *proc_lit = unparen_expr(ce->args[capture_arg_count]); if (proc_lit->kind == Ast_Ident) { - proc_lit = proc_lit->Ident.entity->decl_info->proc_lit; + proc_lit = proc_lit->Ident.entity.load()->decl_info->proc_lit; } GB_ASSERT(proc_lit->kind == Ast_ProcLit); diff --git a/src/parser.hpp b/src/parser.hpp index 39f56ffae..1026433d0 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -425,7 +425,7 @@ struct AstSplitArgs { #define AST_KINDS \ AST_KIND(Ident, "identifier", struct { \ Token token; \ - Entity *entity; \ + std::atomic entity; \ u32 hash; \ }) \ AST_KIND(Implicit, "implicit", Token) \ @@ -856,19 +856,19 @@ gb_global isize const ast_variant_sizes[] = { }; struct AstCommonStuff { - AstKind kind; // u16 - u8 state_flags; - u8 viral_state_flags; - i32 file_id; - TypeAndValue tav; // NOTE(bill): Making this a pointer is slower + AstKind kind; // u16 + u8 state_flags; + std::atomic viral_state_flags; + i32 file_id; + TypeAndValue tav; // NOTE(bill): Making this a pointer is slower }; struct Ast { - AstKind kind; // u16 - u8 state_flags; - u8 viral_state_flags; - i32 file_id; - TypeAndValue tav; // NOTE(bill): Making this a pointer is slower + AstKind kind; // u16 + u8 state_flags; + std::atomic viral_state_flags; + i32 file_id; + TypeAndValue tav; // NOTE(bill): Making this a pointer is slower // IMPORTANT NOTE(bill): This must be at the end since the AST is allocated to be size of the variant union {