From 57e4b69e644517258a08a0bac17d859b9847b8e8 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 18 Mar 2026 22:46:34 -0700 Subject: [PATCH] adjust rdi make to keep per-unit info organization - flatten / join in baker, to ensure unit-sorted order --- src/lib_rdi_make/rdi_make.c | 29 ++++-- src/lib_rdi_make/rdi_make.h | 87 ++++++++--------- src/rdi_from_pdb/rdi_from_pdb.c | 117 +++------------------- src/rdi_make/rdi_make_local.c | 165 ++++++++++++++++++++------------ 4 files changed, 181 insertions(+), 217 deletions(-) diff --git a/src/lib_rdi_make/rdi_make.c b/src/lib_rdi_make/rdi_make.c index ba585674..a61f7583 100644 --- a/src/lib_rdi_make/rdi_make.c +++ b/src/lib_rdi_make/rdi_make.c @@ -51,6 +51,23 @@ rdim_memcpy_struct(dst, to_push); \ } \ rdim_memzero_struct(to_push); +#define RDIM_IdxedChunkListShallowCopy(list_type, chunk_type, src, ...) \ +list_type dst = {0};\ +RDI_U64 base_idx = 0;\ +for(chunk_type *src_n = src->first; src_n != 0; src_n = src_n->next)\ +{\ +chunk_type *dst_n = rdim_push_array(arena, chunk_type, 1);\ +RDIM_SLLQueuePush(dst.first, dst.last, dst_n);\ +dst.total_count += src_n->count;\ +dst.chunk_count += 1;\ +dst_n->count = src_n->count;\ +dst_n->cap = dst_n->count;\ +dst_n->base_idx = base_idx;\ +dst_n->v = src_n->v;\ +base_idx += dst_n->count;\ +}\ +return dst; + //////////////////////////////// //~ rjf: Basic Helpers @@ -943,6 +960,12 @@ rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst, RDIM_SymbolChu RDIM_IdxedChunkListConcatInPlace(RDIM_SymbolChunkNode, dst, to_push); } +RDI_PROC RDIM_SymbolChunkList +rdim_symbol_chunk_list_shallow_copy(RDIM_Arena *arena, RDIM_SymbolChunkList *src) +{ + RDIM_IdxedChunkListShallowCopy(RDIM_SymbolChunkList, RDIM_SymbolChunkNode, src); +} + //////////////////////////////// //~ rjf: [Building] Inline Site Info Building @@ -1223,12 +1246,6 @@ rdim_bake_params_concat_in_place(RDIM_BakeParams *dst, RDIM_BakeParams *src) rdim_udt_chunk_list_concat_in_place(&dst->udts, &src->udts); rdim_src_file_chunk_list_concat_in_place(&dst->src_files, &src->src_files); rdim_line_table_chunk_list_concat_in_place(&dst->line_tables, &src->line_tables); - rdim_symbol_chunk_list_concat_in_place(&dst->global_variables, &src->global_variables); - rdim_symbol_chunk_list_concat_in_place(&dst->thread_variables, &src->thread_variables); - rdim_symbol_chunk_list_concat_in_place(&dst->constants, &src->constants); - rdim_symbol_chunk_list_concat_in_place(&dst->procedures, &src->procedures); - rdim_scope_chunk_list_concat_in_place(&dst->scopes, &src->scopes); - rdim_inline_site_chunk_list_concat_in_place(&dst->inline_sites, &src->inline_sites); } } diff --git a/src/lib_rdi_make/rdi_make.h b/src/lib_rdi_make/rdi_make.h index 01914b08..9af381b5 100644 --- a/src/lib_rdi_make/rdi_make.h +++ b/src/lib_rdi_make/rdi_make.h @@ -628,43 +628,6 @@ struct RDIM_LineTableChunkList RDI_U64 total_col_count; }; -//////////////////////////////// -//~ rjf: Per-Compilation-Unit Info Types - -typedef struct RDIM_Unit RDIM_Unit; -struct RDIM_Unit -{ - struct RDIM_UnitChunkNode *chunk; - RDIM_String8 unit_name; - RDIM_String8 compiler_name; - RDIM_String8 source_file; - RDIM_String8 object_file; - RDIM_String8 archive_file; - RDIM_String8 build_path; - RDI_Language language; - RDIM_LineTable *line_table; - RDIM_Rng1U64ChunkList voff_ranges; -}; - -typedef struct RDIM_UnitChunkNode RDIM_UnitChunkNode; -struct RDIM_UnitChunkNode -{ - RDIM_UnitChunkNode *next; - RDIM_Unit *v; - RDI_U64 count; - RDI_U64 cap; - RDI_U64 base_idx; -}; - -typedef struct RDIM_UnitChunkList RDIM_UnitChunkList; -struct RDIM_UnitChunkList -{ - RDIM_UnitChunkNode *first; - RDIM_UnitChunkNode *last; - RDI_U64 chunk_count; - RDI_U64 total_count; -}; - //////////////////////////////// //~ rjf: Namespace Types @@ -999,6 +962,49 @@ struct RDIM_ScopeChunkList RDI_U64 local_count; }; +//////////////////////////////// +//~ rjf: Per-Compilation-Unit Info Types + +typedef struct RDIM_Unit RDIM_Unit; +struct RDIM_Unit +{ + struct RDIM_UnitChunkNode *chunk; + RDIM_String8 unit_name; + RDIM_String8 compiler_name; + RDIM_String8 source_file; + RDIM_String8 object_file; + RDIM_String8 archive_file; + RDIM_String8 build_path; + RDI_Language language; + RDIM_LineTable *line_table; + RDIM_Rng1U64ChunkList voff_ranges; + RDIM_SymbolChunkList global_variables; + RDIM_SymbolChunkList thread_variables; + RDIM_SymbolChunkList constants; + RDIM_SymbolChunkList procedures; + RDIM_ScopeChunkList scopes; + RDIM_InlineSiteChunkList inline_sites; +}; + +typedef struct RDIM_UnitChunkNode RDIM_UnitChunkNode; +struct RDIM_UnitChunkNode +{ + RDIM_UnitChunkNode *next; + RDIM_Unit *v; + RDI_U64 count; + RDI_U64 cap; + RDI_U64 base_idx; +}; + +typedef struct RDIM_UnitChunkList RDIM_UnitChunkList; +struct RDIM_UnitChunkList +{ + RDIM_UnitChunkNode *first; + RDIM_UnitChunkNode *last; + RDI_U64 chunk_count; + RDI_U64 total_count; +}; + //////////////////////////////// //~ rjf: Baking Types @@ -1016,12 +1022,6 @@ struct RDIM_BakeParams RDIM_UDTChunkList udts; RDIM_SrcFileChunkList src_files; RDIM_LineTableChunkList line_tables; - RDIM_SymbolChunkList global_variables; - RDIM_SymbolChunkList thread_variables; - RDIM_SymbolChunkList constants; - RDIM_SymbolChunkList procedures; - RDIM_ScopeChunkList scopes; - RDIM_InlineSiteChunkList inline_sites; }; //- rjf: data sections @@ -1475,6 +1475,7 @@ RDI_PROC RDIM_UDTEnumVal *rdim_udt_push_enum_val(RDIM_Arena *arena, RDIM_UDTChun RDI_PROC RDIM_Symbol *rdim_symbol_chunk_list_push(RDIM_Arena *arena, RDIM_SymbolChunkList *list, RDI_U64 cap); RDI_PROC RDI_U64 rdim_idx_from_symbol(RDIM_Symbol *symbol); RDI_PROC void rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst, RDIM_SymbolChunkList *to_push); +RDI_PROC RDIM_SymbolChunkList rdim_symbol_chunk_list_shallow_copy(RDIM_Arena *arena, RDIM_SymbolChunkList *src); //////////////////////////////// //~ rjf: [Building] Inline Site Info Building diff --git a/src/rdi_from_pdb/rdi_from_pdb.c b/src/rdi_from_pdb/rdi_from_pdb.c index 45c50949..4484b78c 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.c +++ b/src/rdi_from_pdb/rdi_from_pdb.c @@ -1173,12 +1173,12 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) lane_sync_u64(&src_file_map, 0); ////////////////////////////////////////////////////////////// - //- rjf: convert unit info + //- rjf: convert unit header info // RDIM_UnitChunkList *all_units_ptr = 0; RDIM_LineTableChunkList *units_line_tables = 0; RDIM_LineTable **units_first_inline_site_line_tables = 0; - ProfScope("convert unit info") + ProfScope("convert unit header info") { //- rjf: set up outputs ProfScope("set up outputs") if(lane_idx() == 0) @@ -3259,14 +3259,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) all_udts = *all_udts_ptr; ////////////////////////////////////////////////////////////// - //- rjf: produce symbols from all streams + //- rjf: convert symbols from all units // - RDIM_SymbolChunkList *syms_procedures = 0; - RDIM_SymbolChunkList *syms_global_variables = 0; - RDIM_SymbolChunkList *syms_thread_variables = 0; - RDIM_SymbolChunkList *syms_constants = 0; - RDIM_ScopeChunkList *syms_scopes = 0; - RDIM_InlineSiteChunkList *syms_inline_sites = 0; RDIM_TypeChunkList *syms_typedefs = 0; ProfScope("produce symbols from all streams") { @@ -3277,20 +3271,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) // if(lane_idx() == 0) { - syms_procedures = push_array(arena, RDIM_SymbolChunkList, all_syms_count); - syms_global_variables = push_array(arena, RDIM_SymbolChunkList, all_syms_count); - syms_thread_variables = push_array(arena, RDIM_SymbolChunkList, all_syms_count); - syms_constants = push_array(arena, RDIM_SymbolChunkList, all_syms_count); - syms_scopes = push_array(arena, RDIM_ScopeChunkList, all_syms_count); - syms_inline_sites = push_array(arena, RDIM_InlineSiteChunkList, all_syms_count); syms_typedefs = push_array(arena, RDIM_TypeChunkList, all_syms_count); } - lane_sync_u64(&syms_procedures, 0); - lane_sync_u64(&syms_global_variables, 0); - lane_sync_u64(&syms_thread_variables, 0); - lane_sync_u64(&syms_constants, 0); - lane_sync_u64(&syms_scopes, 0); - lane_sync_u64(&syms_inline_sites, 0); lane_sync_u64(&syms_typedefs, 0); //////////////////////////// @@ -3329,12 +3311,13 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) U64 sym_constants_chunk_cap = 2048; U64 sym_scopes_chunk_cap = 4096; U64 sym_inline_sites_chunk_cap = 2048; - RDIM_SymbolChunkList *sym_procedures = &syms_procedures[sym_idx]; - RDIM_SymbolChunkList *sym_global_variables = &syms_global_variables[sym_idx]; - RDIM_SymbolChunkList *sym_thread_variables = &syms_thread_variables[sym_idx]; - RDIM_SymbolChunkList *sym_constants = &syms_constants[sym_idx]; - RDIM_ScopeChunkList *sym_scopes = &syms_scopes[sym_idx]; - RDIM_InlineSiteChunkList *sym_inline_sites = &syms_inline_sites[sym_idx]; + RDIM_Unit *sym_unit = &all_units_ptr->first->v[sym_idx]; + RDIM_SymbolChunkList *sym_procedures = &sym_unit->procedures; + RDIM_SymbolChunkList *sym_global_variables = &sym_unit->global_variables; + RDIM_SymbolChunkList *sym_thread_variables = &sym_unit->thread_variables; + RDIM_SymbolChunkList *sym_constants = &sym_unit->constants; + RDIM_ScopeChunkList *sym_scopes = &sym_unit->scopes; + RDIM_InlineSiteChunkList *sym_inline_sites = &sym_unit->inline_sites; RDIM_TypeChunkList *typedefs = &syms_typedefs[sym_idx]; ////////////////////////// @@ -4219,82 +4202,16 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) lane_sync(); ////////////////////////////////////////////////////////////// - //- rjf: join all lane symbols + //- rjf: join extra types from units // - RDIM_SymbolChunkList all_procedures = {0}; - RDIM_SymbolChunkList all_global_variables = {0}; - RDIM_SymbolChunkList all_thread_variables = {0}; - RDIM_SymbolChunkList all_constants = {0}; - RDIM_ScopeChunkList all_scopes = {0}; - RDIM_InlineSiteChunkList all_inline_sites = {0}; RDIM_TypeChunkList all_types = {0}; { - RDIM_SymbolChunkList *all_procedures_ptr = 0; - RDIM_SymbolChunkList *all_global_variables_ptr = 0; - RDIM_SymbolChunkList *all_thread_variables_ptr = 0; - RDIM_SymbolChunkList *all_constants_ptr = 0; - RDIM_ScopeChunkList *all_scopes_ptr = 0; - RDIM_InlineSiteChunkList *all_inline_sites_ptr = 0; RDIM_TypeChunkList *all_types_ptr = 0; if(lane_idx() == 0) { - all_procedures_ptr = push_array(scratch.arena, RDIM_SymbolChunkList, 1); - all_global_variables_ptr = push_array(scratch.arena, RDIM_SymbolChunkList, 1); - all_thread_variables_ptr = push_array(scratch.arena, RDIM_SymbolChunkList, 1); - all_constants_ptr = push_array(scratch.arena, RDIM_SymbolChunkList, 1); - all_scopes_ptr = push_array(scratch.arena, RDIM_ScopeChunkList, 1); - all_inline_sites_ptr = push_array(scratch.arena, RDIM_InlineSiteChunkList, 1); all_types_ptr = push_array(scratch.arena, RDIM_TypeChunkList, 1); } - lane_sync_u64(&all_procedures_ptr, 0); - lane_sync_u64(&all_global_variables_ptr, 0); - lane_sync_u64(&all_thread_variables_ptr, 0); - lane_sync_u64(&all_constants_ptr, 0); - lane_sync_u64(&all_scopes_ptr, 0); - lane_sync_u64(&all_inline_sites_ptr, 0); lane_sync_u64(&all_types_ptr, 0); - if(lane_idx() == lane_from_task_idx(1)) ProfScope("join procedures") - { - for EachIndex(idx, all_syms_count) - { - rdim_symbol_chunk_list_concat_in_place(all_procedures_ptr, &syms_procedures[idx]); - } - } - if(lane_idx() == lane_from_task_idx(2)) ProfScope("join global variables") - { - for EachIndex(idx, all_syms_count) - { - rdim_symbol_chunk_list_concat_in_place(all_global_variables_ptr, &syms_global_variables[idx]); - } - } - if(lane_idx() == lane_from_task_idx(3)) ProfScope("join thread variables") - { - for EachIndex(idx, all_syms_count) - { - rdim_symbol_chunk_list_concat_in_place(all_thread_variables_ptr, &syms_thread_variables[idx]); - } - } - if(lane_idx() == lane_from_task_idx(4)) ProfScope("join constants") - { - for EachIndex(idx, all_syms_count) - { - rdim_symbol_chunk_list_concat_in_place(all_constants_ptr, &syms_constants[idx]); - } - } - if(lane_idx() == lane_from_task_idx(5)) ProfScope("join scopes") - { - for EachIndex(idx, all_syms_count) - { - rdim_scope_chunk_list_concat_in_place(all_scopes_ptr, &syms_scopes[idx]); - } - } - if(lane_idx() == lane_from_task_idx(6)) ProfScope("join inline sites") - { - for EachIndex(idx, all_syms_count) - { - rdim_inline_site_chunk_list_concat_in_place(all_inline_sites_ptr, &syms_inline_sites[idx]); - } - } if(lane_idx() == lane_from_task_idx(7)) ProfScope("join typedefs") { for EachIndex(idx, all_syms_count) @@ -4304,12 +4221,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) *all_types_ptr = *all_types__pre_typedefs_ptr; } lane_sync(); - all_procedures = *all_procedures_ptr; - all_global_variables = *all_global_variables_ptr; - all_thread_variables = *all_thread_variables_ptr; - all_constants = *all_constants_ptr; - all_scopes = *all_scopes_ptr; - all_inline_sites = *all_inline_sites_ptr; all_types = *all_types_ptr; } lane_sync(); @@ -4362,12 +4273,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) result.udts = all_udts; result.src_files = all_src_files; result.line_tables = all_line_tables; - result.global_variables = all_global_variables; - result.thread_variables = all_thread_variables; - result.constants = all_constants; - result.procedures = all_procedures; - result.scopes = all_scopes; - result.inline_sites = all_inline_sites; } scratch_end(scratch); diff --git a/src/rdi_make/rdi_make_local.c b/src/rdi_make/rdi_make_local.c index eb955b23..771d0e7f 100644 --- a/src/rdi_make/rdi_make_local.c +++ b/src/rdi_make/rdi_make_local.c @@ -281,6 +281,47 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) { Temp scratch = scratch_begin(&arena, 1); + ////////////////////////////////////////////////////////////// + //- rjf: @rdim_bake_stage form joined symbol lists, from all units + // + RDIM_SymbolChunkList *all_global_variables = 0; + RDIM_SymbolChunkList *all_thread_variables = 0; + RDIM_SymbolChunkList *all_constants = 0; + RDIM_SymbolChunkList *all_procedures = 0; + RDIM_ScopeChunkList *all_scopes = 0; + RDIM_InlineSiteChunkList *all_inline_sites = 0; + if(lane_idx() == 0) + { + all_global_variables = push_array(scratch.arena, RDIM_SymbolChunkList, 1); + all_thread_variables = push_array(scratch.arena, RDIM_SymbolChunkList, 1); + all_constants = push_array(scratch.arena, RDIM_SymbolChunkList, 1); + all_procedures = push_array(scratch.arena, RDIM_SymbolChunkList, 1); + all_scopes = push_array(scratch.arena, RDIM_ScopeChunkList, 1); + all_inline_sites = push_array(scratch.arena, RDIM_InlineSiteChunkList, 1); + for EachNode(unit_n, RDIM_UnitChunkNode, params->units.first) + { + for EachIndex(unit_n_idx, unit_n->count) + { + RDIM_Unit *unit = &unit_n->v[unit_n_idx]; + RDIM_SymbolChunkList global_variables_shallow_copy = rdim_symbol_chunk_list_shallow_copy(scratch.arena, &unit->global_variables); + RDIM_SymbolChunkList thread_variables_shallow_copy = rdim_symbol_chunk_list_shallow_copy(scratch.arena, &unit->thread_variables); + RDIM_SymbolChunkList constants_shallow_copy = rdim_symbol_chunk_list_shallow_copy(scratch.arena, &unit->constants); + RDIM_SymbolChunkList procedures_shallow_copy = rdim_symbol_chunk_list_shallow_copy(scratch.arena, &unit->procedures); + rdim_symbol_chunk_list_concat_in_place(all_global_variables, &global_variables_shallow_copy); + rdim_symbol_chunk_list_concat_in_place(all_thread_variables, &thread_variables_shallow_copy); + rdim_symbol_chunk_list_concat_in_place(all_constants, &constants_shallow_copy); + rdim_symbol_chunk_list_concat_in_place(all_procedures, &procedures_shallow_copy); + // TODO(rjf): @locpass scopes, inline sites + } + } + } + lane_sync_u64(&all_global_variables, 0); + lane_sync_u64(&all_thread_variables, 0); + lane_sync_u64(&all_constants, 0); + lane_sync_u64(&all_procedures, 0); + lane_sync_u64(&all_scopes, 0); + lane_sync_u64(&all_inline_sites, 0); + ////////////////////////////////////////////////////////////// //- rjf: @rdim_bake_stage bake vmaps // @@ -328,14 +369,14 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) U64 *lane_chunk_range_counts = 0; if(lane_idx() == 0) { - lane_chunk_range_counts = push_array(scratch.arena, U64, params->scopes.chunk_count * lane_count()); + lane_chunk_range_counts = push_array(scratch.arena, U64, all_scopes->chunk_count * lane_count()); } lane_sync_u64(&lane_chunk_range_counts, 0); { U64 chunk_idx = 0; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { - U64 slot_idx = lane_idx()*params->scopes.chunk_count + chunk_idx; + U64 slot_idx = lane_idx()*all_scopes->chunk_count + chunk_idx; Rng1U64 range = lane_range(n->count); for EachInRange(n_idx, range) { @@ -351,14 +392,14 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) U64 total_range_count = 0; if(lane_idx() == 0) { - lane_chunk_range_offs = push_array(scratch.arena, U64, params->scopes.chunk_count * lane_count()); + lane_chunk_range_offs = push_array(scratch.arena, U64, all_scopes->chunk_count * lane_count()); U64 off = 0; U64 chunk_idx = 0; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { for EachIndex(l_idx, lane_count()) { - U64 slot_idx = l_idx*params->scopes.chunk_count + chunk_idx; + U64 slot_idx = l_idx*all_scopes->chunk_count + chunk_idx; lane_chunk_range_offs[slot_idx] = off; off += lane_chunk_range_counts[slot_idx]; } @@ -381,9 +422,9 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) //- rjf: fill records { U64 chunk_idx = 0; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { - U64 slot_idx = lane_idx()*params->scopes.chunk_count + chunk_idx; + U64 slot_idx = lane_idx()*all_scopes->chunk_count + chunk_idx; U64 off = lane_chunk_range_offs[slot_idx]; Rng1U64 range = lane_range(n->count); for EachInRange(n_idx, range) @@ -414,14 +455,14 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) U64 *lane_chunk_range_counts = 0; if(lane_idx() == 0) { - lane_chunk_range_counts = push_array(scratch.arena, U64, params->global_variables.chunk_count * lane_count()); + lane_chunk_range_counts = push_array(scratch.arena, U64, all_global_variables->chunk_count * lane_count()); } lane_sync_u64(&lane_chunk_range_counts, 0); { U64 chunk_idx = 0; - for EachNode(n, RDIM_SymbolChunkNode, params->global_variables.first) + for EachNode(n, RDIM_SymbolChunkNode, all_global_variables->first) { - U64 slot_idx = lane_idx()*params->global_variables.chunk_count + chunk_idx; + U64 slot_idx = lane_idx()*all_global_variables->chunk_count + chunk_idx; Rng1U64 range = lane_range(n->count); for EachIndex(n_idx, n->count) { @@ -441,14 +482,14 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) U64 total_range_count = 0; if(lane_idx() == 0) { - lane_chunk_range_offs = push_array(scratch.arena, U64, params->global_variables.chunk_count * lane_count()); + lane_chunk_range_offs = push_array(scratch.arena, U64, all_global_variables->chunk_count * lane_count()); U64 off = 0; U64 chunk_idx = 0; - for EachNode(n, RDIM_SymbolChunkNode, params->global_variables.first) + for EachNode(n, RDIM_SymbolChunkNode, all_global_variables->first) { for EachIndex(l_idx, lane_count()) { - U64 slot_idx = l_idx*params->global_variables.chunk_count + chunk_idx; + U64 slot_idx = l_idx*all_global_variables->chunk_count + chunk_idx; lane_chunk_range_offs[slot_idx] = off; off += lane_chunk_range_counts[slot_idx]; } @@ -471,9 +512,9 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) //- rjf: fill records { U64 chunk_idx = 0; - for EachNode(n, RDIM_SymbolChunkNode, params->global_variables.first) + for EachNode(n, RDIM_SymbolChunkNode, all_global_variables->first) { - U64 slot_idx = lane_idx()*params->global_variables.chunk_count + chunk_idx; + U64 slot_idx = lane_idx()*all_global_variables->chunk_count + chunk_idx; U64 off = lane_chunk_range_offs[slot_idx]; Rng1U64 range = lane_range(n->count); for EachInRange(n_idx, range) @@ -1076,9 +1117,9 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) bake_strings = push_array(scratch.arena, RDIM_BakeStringMapTight, 1); top = push_array(scratch2.arena, RDIM_BakeStringMapTopology, 1); top->slots_count = (64 + - params->procedures.total_count*1 + - params->global_variables.total_count*1 + - params->thread_variables.total_count*1 + + all_procedures->total_count*1 + + all_global_variables->total_count*1 + + all_thread_variables->total_count*1 + params->types.total_count/2); lane_maps__loose = push_array(scratch2.arena, RDIM_BakeStringMapLoose *, lane_count()); map__loose = rdim_bake_string_map_loose_make(scratch2.arena, top); @@ -1194,10 +1235,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) // rjf: push strings from symbols RDIM_SymbolChunkList *symbol_lists[] = { - ¶ms->global_variables, - ¶ms->thread_variables, - ¶ms->procedures, - ¶ms->constants, + all_global_variables, + all_thread_variables, + all_procedures, + all_constants, }; ProfScope("symbols") { @@ -1218,7 +1259,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) //- rjf: push strings from inline sites ProfScope("inline sites") { - for EachNode(n, RDIM_InlineSiteChunkNode, params->inline_sites.first) + for EachNode(n, RDIM_InlineSiteChunkNode, all_inline_sites->first) { Rng1U64 range = lane_range(n->count); for EachInRange(n_idx, range) @@ -1231,7 +1272,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) //- rjf: push strings from scopes ProfScope("scopes") { - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { Rng1U64 range = lane_range(n->count); for EachInRange(n_idx, range) @@ -1352,11 +1393,11 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) case RDI_NameMapKind_COUNT: {}break; #define Case(name, total_count) case RDI_NameMapKind_##name:{slot_count = ((total_count) + (total_count)/4);}break - Case(GlobalVariables, params->global_variables.total_count); - Case(ThreadVariables, params->thread_variables.total_count); - Case(Constants, params->constants.total_count); - Case(Procedures, params->procedures.total_count); - Case(LinkNameProcedures, params->procedures.total_count); + Case(GlobalVariables, all_global_variables->total_count); + Case(ThreadVariables, all_thread_variables->total_count); + Case(Constants, all_constants->total_count); + Case(Procedures, all_procedures->total_count); + Case(LinkNameProcedures, all_procedures->total_count); Case(Types, params->types.total_count); Case(NormalSourcePaths, params->src_files.total_count); #undef Case @@ -1383,11 +1424,11 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) case RDI_NameMapKind_NULL: case RDI_NameMapKind_COUNT: {}break; - case RDI_NameMapKind_GlobalVariables: {symbols = ¶ms->global_variables;}goto symbol_name_map_build; - case RDI_NameMapKind_ThreadVariables: {symbols = ¶ms->thread_variables;}goto symbol_name_map_build; - case RDI_NameMapKind_Constants: {symbols = ¶ms->constants;}goto symbol_name_map_build; - case RDI_NameMapKind_Procedures: {symbols = ¶ms->procedures;}goto symbol_name_map_build; - case RDI_NameMapKind_LinkNameProcedures:{symbols = ¶ms->procedures; link_names = 1;}goto symbol_name_map_build; + case RDI_NameMapKind_GlobalVariables: {symbols = all_global_variables;}goto symbol_name_map_build; + case RDI_NameMapKind_ThreadVariables: {symbols = all_thread_variables;}goto symbol_name_map_build; + case RDI_NameMapKind_Constants: {symbols = all_constants;}goto symbol_name_map_build; + case RDI_NameMapKind_Procedures: {symbols = all_procedures;}goto symbol_name_map_build; + case RDI_NameMapKind_LinkNameProcedures:{symbols = all_procedures; link_names = 1;}goto symbol_name_map_build; symbol_name_map_build:; { for EachNode(n, RDIM_SymbolChunkNode, symbols->first) @@ -1512,9 +1553,9 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) if(lane_idx() == 0) ProfScope("set up per-lane outputs") { top = push_array(scratch.arena, RDIM_BakeIdxRunMapTopology, 1); - top->slots_count = 64 + ((params->procedures.total_count + - params->global_variables.total_count + - params->thread_variables.total_count + + top->slots_count = 64 + ((all_procedures->total_count + + all_global_variables->total_count + + all_thread_variables->total_count + params->udts.total_count) * 3) / 4; lane_maps__loose = push_array(scratch.arena, RDIM_BakeIdxRunMapLoose *, lane_count()); map__loose = rdim_bake_idx_run_map_loose_make(scratch.arena, top); @@ -2713,7 +2754,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) RDI_U64 total_location_case_count; }; LocLayout *loc_layout = 0; - U64 total_location_case_chunk_count = (params->scopes.chunk_count + params->procedures.chunk_count); + U64 total_location_case_chunk_count = (all_scopes->chunk_count + params->procedures.chunk_count); ProfScope("compute lane location block layout") { // rjf: set up @@ -2729,7 +2770,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) { // rjf: count location cases in scopes U64 chunk_idx = 0; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { U64 slot_idx = lane_idx() * total_location_case_chunk_count + chunk_idx; Rng1U64 range = lane_range(n->count); @@ -2762,7 +2803,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) { U64 chunk_idx = 0; U64 location_case_layout_off = 1; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { for EachIndex(l_idx, lane_count()) { @@ -2808,7 +2849,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) U64 chunk_idx = 0; ProfScope("wide fill from scopes") { - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { U64 layout_slot_idx = lane_idx() * total_location_case_chunk_count + chunk_idx; U64 layout_off = loc_layout->location_case_chunk_lane_offs[layout_slot_idx]; @@ -2929,17 +2970,17 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) if(lane_idx() == 0) { scope_layout = push_array(scratch.arena, ScopeLayout, 1); - scope_layout->scope_local_chunk_lane_counts = push_array(arena, RDI_U64, lane_count() * params->scopes.chunk_count); - scope_layout->scope_local_chunk_lane_offs = push_array(arena, RDI_U64, lane_count() * params->scopes.chunk_count); - scope_layout->scope_voff_chunk_lane_counts = push_array(arena, RDI_U64, lane_count() * params->scopes.chunk_count); - scope_layout->scope_voff_chunk_lane_offs = push_array(arena, RDI_U64, lane_count() * params->scopes.chunk_count); + scope_layout->scope_local_chunk_lane_counts = push_array(arena, RDI_U64, lane_count() * all_scopes->chunk_count); + scope_layout->scope_local_chunk_lane_offs = push_array(arena, RDI_U64, lane_count() * all_scopes->chunk_count); + scope_layout->scope_voff_chunk_lane_counts = push_array(arena, RDI_U64, lane_count() * all_scopes->chunk_count); + scope_layout->scope_voff_chunk_lane_offs = push_array(arena, RDI_U64, lane_count() * all_scopes->chunk_count); } lane_sync_u64(&scope_layout, 0); // rjf: count per-lane-chunk { U64 chunk_idx = 0; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { U64 num_locals_in_this_lane_and_node = 0; U64 num_voffs_in_this_lane_and_node = 0; @@ -2949,8 +2990,8 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) num_locals_in_this_lane_and_node += n->v[n_idx].locals.total_count; num_voffs_in_this_lane_and_node += n->v[n_idx].voff_ranges.count*2; } - scope_layout->scope_local_chunk_lane_counts[lane_idx()*params->scopes.chunk_count + chunk_idx] = num_locals_in_this_lane_and_node; - scope_layout->scope_voff_chunk_lane_counts[lane_idx()*params->scopes.chunk_count + chunk_idx] = num_voffs_in_this_lane_and_node; + scope_layout->scope_local_chunk_lane_counts[lane_idx()*all_scopes->chunk_count + chunk_idx] = num_locals_in_this_lane_and_node; + scope_layout->scope_voff_chunk_lane_counts[lane_idx()*all_scopes->chunk_count + chunk_idx] = num_voffs_in_this_lane_and_node; chunk_idx += 1; } } @@ -2962,11 +3003,11 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) U64 local_layout_off = 1; U64 voff_layout_off = 1; U64 chunk_idx = 0; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { for EachIndex(l_idx, lane_count()) { - U64 slot_idx = l_idx*params->scopes.chunk_count + chunk_idx; + U64 slot_idx = l_idx*all_scopes->chunk_count + chunk_idx; scope_layout->scope_local_chunk_lane_offs[slot_idx] = local_layout_off; scope_layout->scope_voff_chunk_lane_offs[slot_idx] = voff_layout_off; local_layout_off += scope_layout->scope_local_chunk_lane_counts[slot_idx]; @@ -3002,12 +3043,12 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) lane_sync_u64(&baked_scopes, 0); if(lane_idx() == lane_from_task_idx(0)) { - baked_scopes->scopes_count = params->scopes.total_count+1; + baked_scopes->scopes_count = all_scopes->total_count+1; baked_scopes->scopes = push_array(arena, RDI_Scope, baked_scopes->scopes_count); } if(lane_idx() == lane_from_task_idx(1)) { - baked_scopes->scope_voffs_count = params->scopes.scope_voff_count+1; + baked_scopes->scope_voffs_count = all_scopes->scope_voff_count+1; baked_scopes->scope_voffs = push_array(arena, RDI_U64, baked_scopes->scope_voffs_count); } lane_sync(); @@ -3015,10 +3056,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) //- rjf: wide fill { U64 chunk_idx = 0; - for EachNode(n, RDIM_ScopeChunkNode, params->scopes.first) + for EachNode(n, RDIM_ScopeChunkNode, all_scopes->first) { Rng1U64 range = lane_range(n->count); - U64 scope_chunk_lane_slot_idx = lane_idx()*params->scopes.chunk_count + chunk_idx; + U64 scope_chunk_lane_slot_idx = lane_idx()*all_scopes->chunk_count + chunk_idx; U64 chunk_local_off = scope_layout->scope_local_chunk_lane_offs[scope_chunk_lane_slot_idx]; U64 chunk_voff_off = scope_layout->scope_voff_chunk_lane_offs[scope_chunk_lane_slot_idx]; for EachInRange(n_idx, range) @@ -3096,7 +3137,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) U64 chunk_idx = 0; for EachNode(n, RDIM_SymbolChunkNode, params->procedures.first) { - U64 location_block_layout_slot_idx = lane_idx()*total_location_case_chunk_count + params->scopes.chunk_count + chunk_idx; + U64 location_block_layout_slot_idx = lane_idx()*total_location_case_chunk_count + all_scopes->chunk_count + chunk_idx; U64 location_block_off = loc_layout->location_case_chunk_lane_offs[location_block_layout_slot_idx]; Rng1U64 range = lane_range(n->count); for EachInRange(n_idx, range) @@ -3272,7 +3313,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) } if(lane_idx() == lane_from_task_idx(2)) { - baked_inline_sites_count = params->inline_sites.total_count+1; + baked_inline_sites_count = all_inline_sites->total_count+1; baked_inline_sites = push_array(arena, RDI_InlineSite, baked_inline_sites_count); } lane_sync_u64(&baked_units, lane_from_task_idx(0)); @@ -3447,7 +3488,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) //- rjf: bake inline sites ProfScope("bake inline sites") { - for EachNode(n, RDIM_InlineSiteChunkNode, params->inline_sites.first) + for EachNode(n, RDIM_InlineSiteChunkNode, all_inline_sites->first) { Rng1U64 range = lane_range(n->count); for EachInRange(n_idx, range) @@ -3485,10 +3526,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) } symbol_table_lists[] = { - {¶ms->global_variables, &baked_global_variables, &baked_global_variables_count}, - {¶ms->thread_variables, &baked_thread_variables, &baked_thread_variables_count}, - {¶ms->procedures, &baked_procedures, &baked_procedures_count}, - {¶ms->constants, &baked_constants, &baked_constants_count}, + {all_global_variables, &baked_global_variables, &baked_global_variables_count}, + {all_thread_variables, &baked_thread_variables, &baked_thread_variables_count}, + {all_procedures, &baked_procedures, &baked_procedures_count}, + {all_constants, &baked_constants, &baked_constants_count}, {&baked_scopes->arranged_locals, &baked_locals, &baked_locals_count}, };