mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-29 17:34:34 +00:00
Minimize contention on the deps for decls
This commit is contained in:
@@ -1608,7 +1608,10 @@ gb_internal bool check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *de
|
||||
|
||||
check_scope_usage(ctx->checker, ctx->scope);
|
||||
|
||||
add_deps_from_child_to_parent(decl);
|
||||
if (decl->entity == nullptr) {
|
||||
// Only care about nested procedure literals
|
||||
add_deps_from_child_to_parent(decl);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9455,6 +9455,9 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast
|
||||
|
||||
pl->decl = decl;
|
||||
check_procedure_later(ctx.checker, ctx.file, empty_token, decl, type, pl->body, pl->tags);
|
||||
mutex_lock(&ctx.checker->nested_proc_lits_mutex);
|
||||
array_add(&ctx.checker->nested_proc_lits, decl);
|
||||
mutex_unlock(&ctx.checker->nested_proc_lits_mutex);
|
||||
}
|
||||
check_close_scope(&ctx);
|
||||
|
||||
|
||||
@@ -1256,6 +1256,7 @@ gb_internal void init_checker(Checker *c) {
|
||||
|
||||
// NOTE(bill): 1 Mi elements should be enough on average
|
||||
array_init(&c->procs_to_check, heap_allocator(), 0, 1<<20);
|
||||
array_init(&c->nested_proc_lits, heap_allocator(), 0, 1<<20);
|
||||
|
||||
mpsc_init(&c->global_untyped_queue, a); // , 1<<20);
|
||||
|
||||
@@ -1267,6 +1268,7 @@ gb_internal void destroy_checker(Checker *c) {
|
||||
|
||||
destroy_checker_context(&c->builtin_ctx);
|
||||
|
||||
array_free(&c->nested_proc_lits);
|
||||
array_free(&c->procs_to_check);
|
||||
mpsc_destroy(&c->global_untyped_queue);
|
||||
}
|
||||
@@ -5657,6 +5659,11 @@ gb_internal void check_walk_all_dependencies(DeclInfo *decl) {
|
||||
}
|
||||
|
||||
gb_internal void check_update_dependency_tree_for_procedures(Checker *c) {
|
||||
mutex_lock(&c->nested_proc_lits_mutex);
|
||||
for (DeclInfo *decl : c->nested_proc_lits) {
|
||||
check_walk_all_dependencies(decl);
|
||||
}
|
||||
mutex_unlock(&c->nested_proc_lits_mutex);
|
||||
for (Entity *e : c->info.entities) {
|
||||
DeclInfo *decl = e->decl_info;
|
||||
check_walk_all_dependencies(decl);
|
||||
|
||||
@@ -449,6 +449,10 @@ struct Checker {
|
||||
MPSCQueue<Entity *> procs_with_deferred_to_check;
|
||||
Array<ProcInfo *> procs_to_check;
|
||||
|
||||
BlockingMutex nested_proc_lits_mutex;
|
||||
Array<DeclInfo *> nested_proc_lits;
|
||||
|
||||
|
||||
MPSCQueue<UntypedExprInfo> global_untyped_queue;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user