mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 03:40:08 +00:00
BODGE for finding procedure symbols
Related to a dependency graph race condition bug (THIS NEEDS TO BE FIXED)
This commit is contained in:
+25
-21
@@ -5112,27 +5112,6 @@ gb_internal bool check_identifier_exists(Scope *s, Ast *node, bool nested = fals
|
||||
return false;
|
||||
}
|
||||
|
||||
gb_internal isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) {
|
||||
if (lhs != nullptr && c->decl != nullptr) {
|
||||
for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) {
|
||||
Entity *e = lhs[tuple_index + j];
|
||||
if (e != nullptr) {
|
||||
DeclInfo *decl = decl_info_of_entity(e);
|
||||
if (decl != nullptr) {
|
||||
rw_mutex_shared_lock(&decl->deps_mutex);
|
||||
rw_mutex_lock(&c->decl->deps_mutex);
|
||||
for (Entity *dep : decl->deps) {
|
||||
ptr_set_add(&c->decl->deps, dep);
|
||||
}
|
||||
rw_mutex_unlock(&c->decl->deps_mutex);
|
||||
rw_mutex_shared_unlock(&decl->deps_mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tuple_count;
|
||||
}
|
||||
|
||||
gb_internal bool check_no_copy_assignment(Operand const &o, String const &context) {
|
||||
if (o.type && is_type_no_copy(o.type)) {
|
||||
Ast *expr = unparen_expr(o.expr);
|
||||
@@ -5240,6 +5219,31 @@ enum UnpackFlag : u32 {
|
||||
|
||||
|
||||
gb_internal bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array<Operand> *operands, Slice<Ast *> const &rhs_arguments, UnpackFlags flags) {
|
||||
auto const &add_dependencies_from_unpacking = [](CheckerContext *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) -> isize {
|
||||
if (lhs == nullptr || c->decl == nullptr) {
|
||||
return tuple_count;
|
||||
}
|
||||
for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) {
|
||||
Entity *e = lhs[tuple_index + j];
|
||||
if (e == nullptr) {
|
||||
continue;
|
||||
}
|
||||
DeclInfo *decl = decl_info_of_entity(e);
|
||||
if (decl == nullptr) {
|
||||
continue;
|
||||
}
|
||||
rw_mutex_shared_lock(&decl->deps_mutex);
|
||||
rw_mutex_lock(&c->decl->deps_mutex);
|
||||
for (Entity *dep : decl->deps) {
|
||||
ptr_set_add(&c->decl->deps, dep);
|
||||
}
|
||||
rw_mutex_unlock(&c->decl->deps_mutex);
|
||||
rw_mutex_shared_unlock(&decl->deps_mutex);
|
||||
}
|
||||
return tuple_count;
|
||||
};
|
||||
|
||||
|
||||
bool allow_ok = (flags & UnpackFlag_AllowOk) != 0;
|
||||
bool is_variadic = (flags & UnpackFlag_IsVariadic) != 0;
|
||||
bool allow_undef = (flags & UnpackFlag_AllowUndef) != 0;
|
||||
|
||||
+19
-1
@@ -241,9 +241,9 @@ gb_internal TB_Symbol *cg_find_symbol_from_entity(cgModule *m, Entity *e) {
|
||||
GB_ASSERT(e != nullptr);
|
||||
|
||||
rw_mutex_lock(&m->values_mutex);
|
||||
defer (rw_mutex_unlock(&m->values_mutex));
|
||||
TB_Symbol **found = map_get(&m->symbols, e);
|
||||
if (found) {
|
||||
rw_mutex_unlock(&m->values_mutex);
|
||||
return *found;
|
||||
}
|
||||
|
||||
@@ -252,8 +252,23 @@ gb_internal TB_Symbol *cg_find_symbol_from_entity(cgModule *m, Entity *e) {
|
||||
if (proc_found) {
|
||||
TB_Symbol *symbol = (*proc_found)->symbol;
|
||||
map_set(&m->symbols, e, symbol);
|
||||
rw_mutex_unlock(&m->values_mutex);
|
||||
return symbol;
|
||||
}
|
||||
rw_mutex_unlock(&m->values_mutex);
|
||||
|
||||
if (e->kind == Entity_Procedure) {
|
||||
debugf("[Tilde] try to generate procedure %.*s as it was not in the minimum_dependency_set", LIT(e->token.string));
|
||||
// IMPORTANT TODO(bill): This is an utter bodge, try and fix this shit
|
||||
cgProcedure *p = cg_procedure_create(m, e);
|
||||
if (p != nullptr) {
|
||||
GB_ASSERT(p->symbol != nullptr);
|
||||
cg_add_procedure_to_queue(p);
|
||||
return p->symbol;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GB_PANIC("could not find entity's symbol %.*s", LIT(e->token.string));
|
||||
return nullptr;
|
||||
}
|
||||
@@ -662,6 +677,9 @@ gb_internal WORKER_TASK_PROC(cg_procedure_generate_worker_proc) {
|
||||
}
|
||||
|
||||
gb_internal void cg_add_procedure_to_queue(cgProcedure *p) {
|
||||
if (p == nullptr) {
|
||||
return;
|
||||
}
|
||||
cgModule *m = p->module;
|
||||
if (m->do_threading) {
|
||||
thread_pool_add_task(cg_procedure_generate_worker_proc, p);
|
||||
|
||||
@@ -264,6 +264,7 @@ gb_global cgProcedure *cg_cleanup_runtime_proc = nullptr;
|
||||
|
||||
gb_internal TB_Arena *cg_arena(void);
|
||||
|
||||
gb_internal cgProcedure *cg_procedure_create(cgModule *m, Entity *entity, bool ignore_body=false);
|
||||
gb_internal void cg_add_procedure_to_queue(cgProcedure *p);
|
||||
gb_internal void cg_setup_type_info_data(cgModule *m);
|
||||
gb_internal cgProcedure *cg_procedure_generate_anonymous(cgModule *m, Ast *expr, cgProcedure *parent);
|
||||
|
||||
Binary file not shown.
+4
-3
@@ -18,7 +18,7 @@ gb_internal TB_FunctionPrototype *cg_procedure_type_as_prototype(cgModule *m, Ty
|
||||
return proto;
|
||||
}
|
||||
|
||||
gb_internal cgProcedure *cg_procedure_create(cgModule *m, Entity *entity, bool ignore_body=false) {
|
||||
gb_internal cgProcedure *cg_procedure_create(cgModule *m, Entity *entity, bool ignore_body) {
|
||||
GB_ASSERT(entity != nullptr);
|
||||
GB_ASSERT(entity->kind == Entity_Procedure);
|
||||
if (!entity->Procedure.is_foreign) {
|
||||
@@ -385,7 +385,7 @@ gb_internal WORKER_TASK_PROC(cg_procedure_compile_worker_proc) {
|
||||
|
||||
|
||||
if (
|
||||
// string_starts_with(p->name, str_lit("bug@main")) ||
|
||||
// string_starts_with(p->name, str_lit("runtime@_windows_default_alloc_or_resize")) ||
|
||||
false
|
||||
) {
|
||||
emit_asm = true;
|
||||
@@ -434,7 +434,8 @@ gb_internal void cg_procedure_generate(cgProcedure *p) {
|
||||
|
||||
|
||||
if (
|
||||
// string_starts_with(p->name, str_lit("bug@main")) ||
|
||||
// string_starts_with(p->name, str_lit("runtime@_windows_default_alloc")) ||
|
||||
// p->name == str_lit("runtime@_windows_default_alloc_or_resize") ||
|
||||
false
|
||||
) { // IR Printing
|
||||
TB_Arena *arena = tb_default_arena();
|
||||
|
||||
Reference in New Issue
Block a user