mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-12 06:18:39 +00:00
Merge pull request #6217 from odin-lang/bill/threading-fixes-2026-02
Fix to frontend threading bugs
This commit is contained in:
@@ -495,15 +495,18 @@ gb_internal Entity *scope_insert_with_name(Scope *s, String const &name, Entity
|
||||
goto end;
|
||||
}
|
||||
if (s->parent != nullptr && (s->parent->flags & ScopeFlag_Proc) != 0) {
|
||||
rw_mutex_shared_lock(&s->parent->mutex);
|
||||
found = string_map_get(&s->parent->elements, key);
|
||||
if (found) {
|
||||
if ((*found)->flags & EntityFlag_Result) {
|
||||
if (entity != *found) {
|
||||
result = *found;
|
||||
}
|
||||
rw_mutex_shared_unlock(&s->parent->mutex);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
rw_mutex_shared_unlock(&s->parent->mutex);
|
||||
}
|
||||
|
||||
string_map_set(&s->elements, key, entity);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
gb_global BlockingMutex hash_exact_value_mutex;
|
||||
|
||||
struct Ast;
|
||||
struct HashKey;
|
||||
struct Type;
|
||||
@@ -54,9 +52,6 @@ struct ExactValue {
|
||||
gb_global ExactValue const empty_exact_value = {};
|
||||
|
||||
gb_internal uintptr hash_exact_value(ExactValue v) {
|
||||
mutex_lock(&hash_exact_value_mutex);
|
||||
defer (mutex_unlock(&hash_exact_value_mutex));
|
||||
|
||||
uintptr res = 0;
|
||||
|
||||
switch (v.kind) {
|
||||
|
||||
@@ -4308,17 +4308,17 @@ gb_internal i64 *type_set_offsets_of(Slice<Entity *> const &fields, bool is_pack
|
||||
gb_internal bool type_set_offsets(Type *t) {
|
||||
t = base_type(t);
|
||||
if (t->kind == Type_Struct) {
|
||||
if (t->Struct.are_offsets_being_processed.load()) {
|
||||
return true;
|
||||
}
|
||||
// if (t->Struct.are_offsets_being_processed.load()) {
|
||||
// return true;
|
||||
// }
|
||||
MUTEX_GUARD(&t->Struct.offset_mutex);
|
||||
if (!t->Struct.are_offsets_set) {
|
||||
t->Struct.are_offsets_being_processed.store(true);
|
||||
t->Struct.offsets = type_set_offsets_of(t->Struct.fields, t->Struct.is_packed, t->Struct.is_raw_union, t->Struct.custom_min_field_align, t->Struct.custom_max_field_align);
|
||||
t->Struct.are_offsets_being_processed.store(false);
|
||||
t->Struct.are_offsets_set = true;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else if (is_type_tuple(t)) {
|
||||
MUTEX_GUARD(&t->Tuple.mutex);
|
||||
if (!t->Tuple.are_offsets_set) {
|
||||
@@ -4326,8 +4326,8 @@ gb_internal bool type_set_offsets(Type *t) {
|
||||
t->Tuple.offsets = type_set_offsets_of(t->Tuple.variables, t->Tuple.is_packed, false, 1, 0);
|
||||
t->Tuple.are_offsets_being_processed.store(false);
|
||||
t->Tuple.are_offsets_set = true;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
GB_PANIC("Invalid type for setting offsets");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user