MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_parallel_resolve

Function cbm_parallel_resolve

src/pipeline/pass_parallel.c:4422–4734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4420}
4421
4422int cbm_parallel_resolve(cbm_pipeline_ctx_t *ctx, const cbm_file_info_t *files, int file_count,
4423 CBMFileResult **result_cache, _Atomic int64_t *shared_ids,
4424 int worker_count, CBMLSPDef *all_defs, int def_count,
4425 char *const *def_modules, struct CBMModuleDefIndex *module_def_index,
4426 void *cross_registries_v) {
4427 /* See header: typed as void* across the TU boundary; cast back here. */
4428 CBMCrossLspRegistries *cross_registries = (CBMCrossLspRegistries *)cross_registries_v;
4429 if (file_count == 0) {
4430 return 0;
4431 }
4432
4433 /* Preparation or an opt-out cannot erase owners already found by
4434 * extraction, including results currently parked in the spill store. */
4435 if (atomic_load(&ctx->test_declarations_failed) ||
4436 (atomic_load(&ctx->test_definition_owners_seen) && (!all_defs || def_count <= 0))) {
4437 atomic_store(&ctx->test_declarations_failed, 1);
4438 return CBM_PIPELINE_ABORT_PRESERVE_DB;
4439 }
4440
4441 if (file_count < 0 || (size_t)file_count > SIZE_MAX / sizeof(const char *)) {
4442 return CBM_NOT_FOUND;
4443 }
4444
4445 cbm_log_info("parallel.resolve.start", "files", itoa_log(file_count), "workers",
4446 itoa_log(worker_count));
4447
4448 resolve_worker_state_t *workers = NULL;
4449 if (cbm_aligned_alloc((void **)&workers, CBM_CACHE_LINE,
4450 (size_t)worker_count * sizeof(resolve_worker_state_t)) != 0) {
4451 return CBM_NOT_FOUND;
4452 }
4453 memset(workers, 0, (size_t)worker_count * sizeof(resolve_worker_state_t));
4454 const char **lsp_failures =
4455 cbm_calloc(CBM_MEM_CLASS_OTHER, (size_t)file_count * sizeof(*lsp_failures));
4456 if (!lsp_failures) {
4457 cbm_aligned_free(workers);
4458 return CBM_NOT_FOUND;
4459 }
4460
4461 bool have_rust = false;
4462 for (int i = 0; i < file_count; i++) {
4463 if (files[i].language == CBM_LANG_RUST &&
4464 (result_cache[i] || (ctx->spill && cbm_result_spill_has(ctx->spill, i)))) {
4465 have_rust = true;
4466 break;
4467 }
4468 }
4469 CBMArena rust_manifest_arena;
4470 CBMCargoManifest rust_manifest;
4471 bool rust_manifest_arena_live = false;
4472 const CBMCargoManifest *rust_manifest_ptr = NULL;
4473 if (have_rust) {
4474 cbm_arena_init(&rust_manifest_arena);
4475 rust_manifest_arena_live = true;
4476 if (cbm_pxc_build_rust_manifest(ctx, &rust_manifest_arena, &rust_manifest)) {
4477 rust_manifest_ptr = &rust_manifest;
4478 }
4479 }

Callers 3

run_extract_resolveFunction · 0.85
run_parallel_pipelineFunction · 0.85

Calls 15

cbm_aligned_allocFunction · 0.85
cbm_callocFunction · 0.85
cbm_aligned_freeFunction · 0.85
cbm_result_spill_hasFunction · 0.85
cbm_mutex_initFunction · 0.85
cbm_scale_beginFunction · 0.85
cbm_parallel_forFunction · 0.85
cbm_scale_endFunction · 0.85
cbm_freeFunction · 0.85
cbm_mutex_destroyFunction · 0.85