mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-08 19:44:20 +00:00
Use a RwMutex instead of BlockingMutex
This commit is contained in:
@@ -5101,7 +5101,6 @@ gb_internal ExactValue get_constant_field_single(CheckerContext *c, ExactValue v
|
||||
ast_node(fv, FieldValue, elem);
|
||||
String name = fv->field->Ident.token.string;
|
||||
Selection sub_sel = lookup_field(node->tav.type, name, false);
|
||||
defer (array_free(&sub_sel.index));
|
||||
if (sub_sel.index.count > 0 &&
|
||||
sub_sel.index[0] == index) {
|
||||
value = fv->value->tav.value;
|
||||
@@ -7885,9 +7884,9 @@ gb_internal CallArgumentError check_polymorphic_record_type(CheckerContext *c, O
|
||||
{
|
||||
GenTypesData *found_gen_types = ensure_polymorphic_record_entity_has_gen_types(c, original_type);
|
||||
|
||||
mutex_lock(&found_gen_types->mutex);
|
||||
rw_mutex_shared_lock(&found_gen_types->mutex);
|
||||
Entity *found_entity = find_polymorphic_record_entity(found_gen_types, param_count, ordered_operands);
|
||||
mutex_unlock(&found_gen_types->mutex);
|
||||
rw_mutex_shared_unlock(&found_gen_types->mutex);
|
||||
|
||||
if (found_entity) {
|
||||
operand->mode = Addressing_Type;
|
||||
|
||||
@@ -321,8 +321,8 @@ gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, T
|
||||
e->TypeName.objc_metadata = original_type->Named.type_name->TypeName.objc_metadata;
|
||||
|
||||
auto *found_gen_types = ensure_polymorphic_record_entity_has_gen_types(ctx, original_type);
|
||||
mutex_lock(&found_gen_types->mutex);
|
||||
defer (mutex_unlock(&found_gen_types->mutex));
|
||||
rw_mutex_lock(&found_gen_types->mutex);
|
||||
defer (rw_mutex_unlock(&found_gen_types->mutex));
|
||||
|
||||
for (Entity *prev : found_gen_types->types) {
|
||||
if (prev == e) {
|
||||
|
||||
@@ -417,7 +417,7 @@ struct GenProcsData {
|
||||
|
||||
struct GenTypesData {
|
||||
Array<Entity *> types;
|
||||
BlockingMutex mutex;
|
||||
RwMutex mutex;
|
||||
};
|
||||
|
||||
struct Defineable {
|
||||
|
||||
@@ -2563,10 +2563,11 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) {
|
||||
|
||||
Type *dt = t;
|
||||
|
||||
TEMPORARY_ALLOCATOR_GUARD();
|
||||
|
||||
GB_ASSERT(is_type_struct(st) || is_type_raw_union(st));
|
||||
Selection sel = {};
|
||||
sel.index.allocator = heap_allocator();
|
||||
defer (array_free(&sel.index));
|
||||
sel.index.allocator = temporary_allocator();
|
||||
if (lookup_subtype_polymorphic_selection(t, src_type, &sel)) {
|
||||
if (sel.entity == nullptr) {
|
||||
GB_PANIC("invalid subtype cast %s -> ", type_to_string(src_type), type_to_string(t));
|
||||
|
||||
@@ -435,11 +435,8 @@ gb_internal Selection make_selection(Entity *entity, Array<i32> index, bool indi
|
||||
}
|
||||
|
||||
gb_internal void selection_add_index(Selection *s, isize index) {
|
||||
// IMPORTANT NOTE(bill): this requires a stretchy buffer/dynamic array so it requires some form
|
||||
// of heap allocation
|
||||
// TODO(bill): Find a way to use a backing buffer for initial use as the general case is probably .count<3
|
||||
if (s->index.data == nullptr) {
|
||||
array_init(&s->index, heap_allocator());
|
||||
array_init(&s->index, permanent_allocator());
|
||||
}
|
||||
array_add(&s->index, cast(i32)index);
|
||||
}
|
||||
@@ -447,7 +444,7 @@ gb_internal void selection_add_index(Selection *s, isize index) {
|
||||
gb_internal Selection selection_combine(Selection const &lhs, Selection const &rhs) {
|
||||
Selection new_sel = lhs;
|
||||
new_sel.indirect = lhs.indirect || rhs.indirect;
|
||||
new_sel.index = array_make<i32>(heap_allocator(), lhs.index.count+rhs.index.count);
|
||||
new_sel.index = array_make<i32>(permanent_allocator(), lhs.index.count+rhs.index.count);
|
||||
array_copy(&new_sel.index, lhs.index, 0);
|
||||
array_copy(&new_sel.index, rhs.index, lhs.index.count);
|
||||
return new_sel;
|
||||
@@ -3958,7 +3955,7 @@ gb_internal i64 type_size_of(Type *t) {
|
||||
TypePath path{};
|
||||
type_path_init(&path);
|
||||
{
|
||||
MUTEX_GUARD(&g_type_mutex);
|
||||
// MUTEX_GUARD(&g_type_mutex);
|
||||
size = type_size_of_internal(t, &path);
|
||||
t->cached_size.store(size);
|
||||
}
|
||||
@@ -3978,7 +3975,7 @@ gb_internal i64 type_align_of(Type *t) {
|
||||
TypePath path{};
|
||||
type_path_init(&path);
|
||||
{
|
||||
MUTEX_GUARD(&g_type_mutex);
|
||||
// MUTEX_GUARD(&g_type_mutex);
|
||||
t->cached_align.store(type_align_of_internal(t, &path));
|
||||
}
|
||||
type_path_free(&path);
|
||||
@@ -4704,7 +4701,7 @@ gb_internal Type *alloc_type_tuple_from_field_types(Type **field_types, isize fi
|
||||
}
|
||||
|
||||
Type *t = alloc_type_tuple();
|
||||
t->Tuple.variables = slice_make<Entity *>(heap_allocator(), field_count);
|
||||
t->Tuple.variables = slice_make<Entity *>(permanent_allocator(), field_count);
|
||||
|
||||
Scope *scope = nullptr;
|
||||
for_array(i, t->Tuple.variables) {
|
||||
|
||||
Reference in New Issue
Block a user