From 0051cd12e22d03b5442df98d82d9b8a586362082 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 16 Aug 2021 16:30:49 +0100 Subject: [PATCH] Make flags atomic for `Entity` and `Type` --- src/check_expr.cpp | 2 +- src/entity.cpp | 4 ++-- src/types.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index e0eb5a954..581021ac7 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -923,7 +923,7 @@ bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, poly->kind = Type_EnumeratedArray; poly->cached_size = -1; poly->cached_align = -1; - poly->flags = source->flags; + poly->flags.exchange(source->flags); poly->failure = false; poly->EnumeratedArray.elem = source->EnumeratedArray.elem; poly->EnumeratedArray.index = source->EnumeratedArray.index; diff --git a/src/entity.cpp b/src/entity.cpp index e7b888365..fb65bc3a8 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -115,8 +115,8 @@ enum ProcedureOptimizationMode : u32 { struct Entity { EntityKind kind; u64 id; - u64 flags; - EntityState state; + std::atomic flags; + std::atomic state; Token token; Scope * scope; Type * type; diff --git a/src/types.cpp b/src/types.cpp index f497e9509..fd5bdbc6d 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -306,9 +306,9 @@ struct Type { }; // NOTE(bill): These need to be at the end to not affect the unionized data - i64 cached_size; - i64 cached_align; - u32 flags; // TypeFlag + std::atomic cached_size; + std::atomic cached_align; + std::atomic flags; // TypeFlag bool failure; };