Browse Source

Make flags atomic for `Entity` and `Type`

gingerBill 4 years ago
parent
commit
0051cd12e2
3 changed files with 6 additions and 6 deletions
  1. 1 1
      src/check_expr.cpp
  2. 2 2
      src/entity.cpp
  3. 3 3
      src/types.cpp

+ 1 - 1
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;

+ 2 - 2
src/entity.cpp

@@ -115,8 +115,8 @@ enum ProcedureOptimizationMode : u32 {
 struct Entity {
 	EntityKind  kind;
 	u64         id;
-	u64         flags;
-	EntityState state;
+	std::atomic<u64>         flags;
+	std::atomic<EntityState> state;
 	Token       token;
 	Scope *     scope;
 	Type *      type;

+ 3 - 3
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<i64> cached_size;
+	std::atomic<i64> cached_align;
+	std::atomic<u32> flags; // TypeFlag
 	bool failure;
 };