checkpoint on new symbol serialization

This commit is contained in:
Ryan Fleury
2026-04-20 09:57:30 -07:00
parent cff7a786b3
commit a190051d61
7 changed files with 205 additions and 264 deletions
+1 -1
View File
@@ -40,7 +40,6 @@ sizeof(RDI_ThreadVariable),
sizeof(RDI_Constant),
sizeof(RDI_Procedure),
sizeof(RDI_Local),
sizeof(RDI_VMapEntry),
sizeof(RDI_Scope),
sizeof(RDI_U64),
sizeof(RDI_VMapEntry),
@@ -48,6 +47,7 @@ sizeof(RDI_InlineSite),
sizeof(RDI_LocationBlock),
sizeof(RDI_U8),
sizeof(RDI_Symbol),
sizeof(RDI_VMapEntry),
sizeof(RDI_Symbol),
sizeof(RDI_Symbol),
sizeof(RDI_Symbol),
+3 -3
View File
@@ -103,7 +103,6 @@ RDI_SectionKind_ThreadVariables = 0x0018,
RDI_SectionKind_Constants = 0x0019,
RDI_SectionKind_Procedures = 0x001A,
RDI_SectionKind_Locals = 0x001B,
RDI_SectionKind_GlobalVMap = 0x001C,
RDI_SectionKind_Scopes = 0x001D,
RDI_SectionKind_ScopeVOffData = 0x001E,
RDI_SectionKind_ScopeVMap = 0x001F,
@@ -111,6 +110,7 @@ RDI_SectionKind_InlineSites = 0x0020,
RDI_SectionKind_LocationBlocks = 0x0021,
RDI_SectionKind_LocationData = 0x0022,
RDI_SectionKind_GlobalVariableSymbols = 0x0023,
RDI_SectionKind_GlobalVMap = 0x001C,
RDI_SectionKind_ThreadVariableSymbols = 0x0024,
RDI_SectionKind_ConstantSymbols = 0x0025,
RDI_SectionKind_ProcedureSymbols = 0x0026,
@@ -568,7 +568,6 @@ X(ThreadVariables, thread_variables, RDI_ThreadVariable)\
X(Constants, constants, RDI_Constant)\
X(Procedures, procedures, RDI_Procedure)\
X(Locals, locals, RDI_Local)\
X(GlobalVMap, global_vmap, RDI_VMapEntry)\
X(Scopes, scopes, RDI_Scope)\
X(ScopeVOffData, scope_voff_data, RDI_U64)\
X(ScopeVMap, scope_vmap, RDI_VMapEntry)\
@@ -576,6 +575,7 @@ X(InlineSites, inline_sites, RDI_InlineSite)\
X(LocationBlocks, location_blocks, RDI_LocationBlock)\
X(LocationData, location_data, RDI_U8)\
X(GlobalVariableSymbols, global_variable_symbols, RDI_Symbol)\
X(GlobalVMap, global_vmap, RDI_VMapEntry)\
X(ThreadVariableSymbols, thread_variable_symbols, RDI_Symbol)\
X(ConstantSymbols, constant_symbols, RDI_Symbol)\
X(ProcedureSymbols, procedure_symbols, RDI_Symbol)\
@@ -1627,7 +1627,6 @@ typedef RDI_ThreadVariable RDI_SectionElementType_ThreadVariables;
typedef RDI_Constant RDI_SectionElementType_Constants;
typedef RDI_Procedure RDI_SectionElementType_Procedures;
typedef RDI_Local RDI_SectionElementType_Locals;
typedef RDI_VMapEntry RDI_SectionElementType_GlobalVMap;
typedef RDI_Scope RDI_SectionElementType_Scopes;
typedef RDI_U64 RDI_SectionElementType_ScopeVOffData;
typedef RDI_VMapEntry RDI_SectionElementType_ScopeVMap;
@@ -1635,6 +1634,7 @@ typedef RDI_InlineSite RDI_SectionElementType_InlineSites;
typedef RDI_LocationBlock RDI_SectionElementType_LocationBlocks;
typedef RDI_U8 RDI_SectionElementType_LocationData;
typedef RDI_Symbol RDI_SectionElementType_GlobalVariableSymbols;
typedef RDI_VMapEntry RDI_SectionElementType_GlobalVMap;
typedef RDI_Symbol RDI_SectionElementType_ThreadVariableSymbols;
typedef RDI_Symbol RDI_SectionElementType_ConstantSymbols;
typedef RDI_Symbol RDI_SectionElementType_ProcedureSymbols;
+2
View File
@@ -2096,6 +2096,7 @@ rdim_serialized_section_make_unpacked(void *data, RDI_U64 size)
return s;
}
#if 0 // TODO(rjf): @locpass
RDI_PROC RDIM_SerializedSectionBundle
rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results)
{
@@ -2145,6 +2146,7 @@ rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results)
bundle.sections[RDI_SectionKind_NameMapNodes] = rdim_serialized_section_make_unpacked_array(results->name_maps.nodes, results->name_maps.nodes_count);
return bundle;
}
#endif
RDI_PROC RDIM_String8List
rdim_file_blobs_from_section_bundle(RDIM_Arena *arena, RDIM_SerializedSectionBundle *bundle)
+8 -159
View File
@@ -1279,47 +1279,6 @@ struct RDIM_LineRec
//- rjf: baking results
typedef struct RDIM_TopLevelInfoBakeResult RDIM_TopLevelInfoBakeResult;
struct RDIM_TopLevelInfoBakeResult
{
RDI_TopLevelInfo *top_level_info;
};
typedef struct RDIM_BinarySectionBakeResult RDIM_BinarySectionBakeResult;
struct RDIM_BinarySectionBakeResult
{
RDI_BinarySection *binary_sections;
RDI_U64 binary_sections_count;
};
typedef struct RDIM_UnitBakeResult RDIM_UnitBakeResult;
struct RDIM_UnitBakeResult
{
RDI_Unit *units;
RDI_U64 units_count;
};
typedef struct RDIM_UnitVMapBakeResult RDIM_UnitVMapBakeResult;
struct RDIM_UnitVMapBakeResult
{
RDIM_BakeVMap vmap;
};
typedef struct RDIM_SrcFileBakeResult RDIM_SrcFileBakeResult;
struct RDIM_SrcFileBakeResult
{
RDI_SourceFile *source_files;
RDI_U64 source_files_count;
RDI_SourceLineMap *source_line_maps;
RDI_U64 source_line_maps_count;
RDI_U32 *source_line_map_nums;
RDI_U32 *source_line_map_rngs;
RDI_U64 *source_line_map_voffs;
RDI_U64 source_line_map_nums_count;
RDI_U64 source_line_map_rngs_count;
RDI_U64 source_line_map_voffs_count;
};
typedef struct RDIM_ChecksumBakeResult RDIM_ChecksumBakeResult;
struct RDIM_ChecksumBakeResult
{
@@ -1333,44 +1292,6 @@ struct RDIM_ChecksumBakeResult
RDI_U64 timestamps_count;
};
typedef struct RDIM_LineTableBakeResult RDIM_LineTableBakeResult;
struct RDIM_LineTableBakeResult
{
RDI_LineTable *line_tables;
RDI_U64 line_tables_count;
RDI_U64 *line_table_voffs;
RDI_U64 line_table_voffs_count;
RDI_Line *line_table_lines;
RDI_U64 line_table_lines_count;
RDI_Column *line_table_columns;
RDI_U64 line_table_columns_count;
};
typedef struct RDIM_NamespaceBakeResult RDIM_NamespaceBakeResult;
struct RDIM_NamespaceBakeResult
{
RDI_Namespace *namespaces;
RDI_U64 namespaces_count;
};
typedef struct RDIM_TypeNodeBakeResult RDIM_TypeNodeBakeResult;
struct RDIM_TypeNodeBakeResult
{
RDI_TypeNode *type_nodes;
RDI_U64 type_nodes_count;
};
typedef struct RDIM_UDTBakeResult RDIM_UDTBakeResult;
struct RDIM_UDTBakeResult
{
RDI_UDT *udts;
RDI_U64 udts_count;
RDI_Member *members;
RDI_U64 members_count;
RDI_EnumMember *enum_members;
RDI_U64 enum_members_count;
};
typedef struct RDIM_LocationBakeResult RDIM_LocationBakeResult;
struct RDIM_LocationBakeResult
{
@@ -1423,30 +1344,6 @@ struct RDIM_ProcedureBakeResult
RDI_U64 procedures_count;
};
typedef struct RDIM_ScopeBakeResult RDIM_ScopeBakeResult;
struct RDIM_ScopeBakeResult
{
RDI_Scope *scopes;
RDI_U64 scopes_count;
RDI_U64 *scope_voffs;
RDI_U64 scope_voffs_count;
RDI_Local *locals;
RDI_U64 locals_count;
};
typedef struct RDIM_ScopeVMapBakeResult RDIM_ScopeVMapBakeResult;
struct RDIM_ScopeVMapBakeResult
{
RDIM_BakeVMap vmap;
};
typedef struct RDIM_InlineSiteBakeResult RDIM_InlineSiteBakeResult;
struct RDIM_InlineSiteBakeResult
{
RDI_InlineSite *inline_sites;
RDI_U64 inline_sites_count;
};
typedef struct RDIM_TopLevelNameMapBakeResult RDIM_TopLevelNameMapBakeResult;
struct RDIM_TopLevelNameMapBakeResult
{
@@ -1463,62 +1360,6 @@ struct RDIM_NameMapBakeResult
RDI_U64 nodes_count;
};
typedef struct RDIM_FilePathBakeResult RDIM_FilePathBakeResult;
struct RDIM_FilePathBakeResult
{
RDI_FilePathNode *nodes;
RDI_U64 nodes_count;
};
typedef struct RDIM_StringBakeResult RDIM_StringBakeResult;
struct RDIM_StringBakeResult
{
RDI_U32 *string_offs;
RDI_U64 string_offs_count;
RDI_U8 *string_data;
RDI_U64 string_data_size;
};
typedef struct RDIM_IndexRunBakeResult RDIM_IndexRunBakeResult;
struct RDIM_IndexRunBakeResult
{
RDI_U32 *idx_runs;
RDI_U64 idx_count;
};
typedef struct RDIM_BakeResults RDIM_BakeResults;
struct RDIM_BakeResults
{
RDIM_TopLevelInfoBakeResult top_level_info;
RDIM_BinarySectionBakeResult binary_sections;
RDIM_UnitBakeResult units;
RDIM_UnitVMapBakeResult unit_vmap;
RDIM_SrcFileBakeResult src_files;
RDIM_ChecksumBakeResult checksums;
RDIM_LineTableBakeResult line_tables;
RDIM_NamespaceBakeResult namespaces;
RDIM_TypeNodeBakeResult type_nodes;
RDIM_UDTBakeResult udts;
RDIM_GlobalVariableBakeResult global_variables;
RDIM_GlobalVMapBakeResult global_vmap;
RDIM_ThreadVariableBakeResult thread_variables;
RDIM_ConstantsBakeResult constants;
RDIM_ProcedureBakeResult procedures;
RDIM_ScopeBakeResult scopes;
RDIM_InlineSiteBakeResult inline_sites;
RDIM_ScopeVMapBakeResult scope_vmap;
RDIM_TopLevelNameMapBakeResult top_level_name_maps;
RDIM_NameMapBakeResult name_maps;
RDIM_FilePathBakeResult file_paths;
RDIM_StringBakeResult strings;
RDIM_IndexRunBakeResult idx_runs;
RDIM_LocationBakeResult locations;
RDIM_LocationBlockBakeResult location_blocks;
};
////////////////////////////////
//~ rjf: Serialization Types
typedef struct RDIM_SerializedSection RDIM_SerializedSection;
struct RDIM_SerializedSection
{
@@ -1534,6 +1375,12 @@ struct RDIM_SerializedSectionBundle
RDIM_SerializedSection sections[RDI_SectionKind_COUNT];
};
typedef struct RDIM_BakeResults RDIM_BakeResults;
struct RDIM_BakeResults
{
RDIM_SerializedSectionBundle section_bundle;
};
////////////////////////////////
//~ rjf: Basic Helpers
@@ -1759,7 +1606,9 @@ RDI_PROC void rdim_bake_section_list_concat_in_place(RDIM_BakeSectionList *dst,
RDI_PROC RDIM_SerializedSection rdim_serialized_section_make_unpacked(void *data, RDI_U64 size);
#define rdim_serialized_section_make_unpacked_struct(ptr) rdim_serialized_section_make_unpacked((ptr), sizeof(*(ptr)))
#define rdim_serialized_section_make_unpacked_array(ptr, count) rdim_serialized_section_make_unpacked((ptr), sizeof(*(ptr))*(count))
#if 0 // TODO(rjf): @locpass
RDI_PROC RDIM_SerializedSectionBundle rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results);
#endif
RDI_PROC RDIM_String8List rdim_file_blobs_from_section_bundle(RDIM_Arena *arena, RDIM_SerializedSectionBundle *bundle);
#endif // RDI_MAKE_H
+1 -1
View File
@@ -883,7 +883,7 @@ rb_thread_entry_point(void *p)
ProfScope("serialize") if(lane_idx() == 0)
{
serialized_section_bundle = push_array(arena, RDIM_SerializedSectionBundle, 1);
serialized_section_bundle[0] = rdim_serialized_section_bundle_from_bake_results(&bake_results);
serialized_section_bundle[0] = bake_results.section_bundle;
}
lane_sync_u64(&serialized_section_bundle, 0);
+2 -1
View File
@@ -185,7 +185,7 @@ RDI_SectionTable:
{Constants constants RDI_Constant 0x0019 U32 ""}
{Procedures procedures RDI_Procedure 0x001A U32 ""}
{Locals locals RDI_Local 0x001B U32 ""}
{GlobalVMap global_vmap RDI_VMapEntry 0x001C - ""}
//- rjf: scope info
{Scopes scopes RDI_Scope 0x001D U32 ""}
@@ -199,6 +199,7 @@ RDI_SectionTable:
//- NOTE(rjf): vvv new story for symbols
{GlobalVariableSymbols global_variable_symbols RDI_Symbol 0x0023 U32 ""}
{GlobalVMap global_vmap RDI_VMapEntry 0x001C - ""}
{ThreadVariableSymbols thread_variable_symbols RDI_Symbol 0x0024 U32 ""}
{ConstantSymbols constant_symbols RDI_Symbol 0x0025 U32 ""}
{ProcedureSymbols procedure_symbols RDI_Symbol 0x0026 U32 ""}
+188 -99
View File
@@ -284,13 +284,13 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake vmaps
//
RDIM_ScopeVMapBakeResult *baked_scope_vmap = 0;
RDIM_UnitVMapBakeResult *baked_unit_vmap = 0;
RDIM_BakeVMap *baked_scope_vmap = 0;
RDIM_BakeVMap *baked_unit_vmap = 0;
RDIM_GlobalVMapBakeResult *baked_global_vmap = 0;
if(lane_idx() == 0)
{
baked_scope_vmap = push_array(scratch.arena, RDIM_ScopeVMapBakeResult, 1);
baked_unit_vmap = push_array(scratch.arena, RDIM_UnitVMapBakeResult, 1);
baked_scope_vmap = push_array(scratch.arena, RDIM_BakeVMap, 1);
baked_unit_vmap = push_array(scratch.arena, RDIM_BakeVMap, 1);
baked_global_vmap = push_array(scratch.arena, RDIM_GlobalVMapBakeResult, 1);
}
lane_sync_u64(&baked_scope_vmap, 0);
@@ -598,9 +598,9 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
}
vmap_tasks[] =
{
{str8_lit_comp("scopes"), scope_vmap_records, scope_vmap_records_count, &baked_scope_vmap->vmap.vmap, &baked_scope_vmap->vmap.count},
{str8_lit_comp("scopes"), scope_vmap_records, scope_vmap_records_count, &baked_scope_vmap->vmap, &baked_scope_vmap->count},
{str8_lit_comp("globals"), global_vmap_records, global_vmap_records_count, &baked_global_vmap->vmap.vmap, &baked_global_vmap->vmap.count},
{str8_lit_comp("units"), unit_vmap_records, unit_vmap_records_count, &baked_unit_vmap->vmap.vmap, &baked_unit_vmap->vmap.count},
{str8_lit_comp("units"), unit_vmap_records, unit_vmap_records_count, &baked_unit_vmap->vmap, &baked_unit_vmap->count},
};
ProfScope("sort & bake all vmaps")
{
@@ -866,11 +866,23 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage gather all unsorted, joined, line table info; & sort
//
typedef struct BakedLineTables BakedLineTables;
struct BakedLineTables
{
RDI_LineTable *line_tables;
RDI_U64 line_tables_count;
RDI_U64 *line_table_voffs;
RDI_U64 line_table_voffs_count;
RDI_Line *line_table_lines;
RDI_U64 line_table_lines_count;
RDI_Column *line_table_columns;
RDI_U64 line_table_columns_count;
};
U64 line_tables_count = 0;
RDIM_LineTable **src_line_tables = 0;
RDIM_UnsortedJoinedLineTable *unsorted_joined_line_tables = 0;
RDIM_SortKey **sorted_line_table_keys = 0;
RDIM_LineTableBakeResult *baked_line_tables = 0;
BakedLineTables *baked_line_tables = 0;
ProfScope("gather all unsorted, joined, line table info; & sort")
{
//- rjf: set up outputs
@@ -893,7 +905,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
}
}
}
baked_line_tables = push_array(scratch.arena, RDIM_LineTableBakeResult, 1);
baked_line_tables = push_array(scratch.arena, BakedLineTables, 1);
baked_line_tables->line_tables_count = params->line_tables.total_count + 1;
baked_line_tables->line_table_voffs_count = params->line_tables.total_line_count + 2*params->line_tables.total_seq_count;
baked_line_tables->line_table_lines_count = params->line_tables.total_line_count + params->line_tables.total_seq_count;
@@ -1734,13 +1746,21 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake strings
//
RDIM_StringBakeResult *baked_strings = 0;
typedef struct BakedStrings BakedStrings;
struct BakedStrings
{
RDI_U32 *string_offs;
RDI_U64 string_offs_count;
RDI_U8 *string_data;
RDI_U64 string_data_size;
};
BakedStrings *baked_strings = 0;
ProfScope("bake strings")
{
// rjf: set up
if(lane_idx() == 0) ProfScope("set up; lay out strings")
{
baked_strings = push_array(scratch.arena, RDIM_StringBakeResult, 1);
baked_strings = push_array(scratch.arena, BakedStrings, 1);
baked_strings->string_offs_count = bake_strings->total_count + 1;
baked_strings->string_offs = rdim_push_array(arena, RDI_U32, baked_strings->string_offs_count);
RDI_U64 off_cursor = 0;
@@ -1786,10 +1806,16 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake idx runs
//
RDIM_IndexRunBakeResult *baked_idx_runs = 0;
typedef struct BakedIdxRuns BakedIdxRuns;
struct BakedIdxRuns
{
RDI_U32 *idx_runs;
RDI_U64 idx_count;
};
BakedIdxRuns *baked_idx_runs = 0;
if(lane_idx() == 0)
{
baked_idx_runs = push_array(scratch.arena, RDIM_IndexRunBakeResult, 1);
baked_idx_runs = push_array(scratch.arena, BakedIdxRuns, 1);
}
lane_sync_u64(&baked_idx_runs, 0);
if(need_index_runs) ProfScope("bake idx runs")
@@ -2262,13 +2288,27 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake src files
//
RDIM_SrcFileBakeResult *baked_src_files = 0;
typedef struct BakedSrcFiles BakedSrcFiles;
struct BakedSrcFiles
{
RDI_SourceFile *source_files;
RDI_U64 source_files_count;
RDI_SourceLineMap *source_line_maps;
RDI_U64 source_line_maps_count;
RDI_U32 *source_line_map_nums;
RDI_U32 *source_line_map_rngs;
RDI_U64 *source_line_map_voffs;
RDI_U64 source_line_map_nums_count;
RDI_U64 source_line_map_rngs_count;
RDI_U64 source_line_map_voffs_count;
};
BakedSrcFiles *baked_src_files = 0;
ProfScope("bake src files")
{
//- rjf: set up
if(lane_idx() == 0)
{
baked_src_files = push_array(scratch.arena, RDIM_SrcFileBakeResult, 1);
baked_src_files = push_array(scratch.arena, BakedSrcFiles, 1);
baked_src_files->source_files_count = params->src_files.total_count+1;
baked_src_files->source_files = push_array(arena, RDI_SourceFile, baked_src_files->source_files_count);
baked_src_files->source_line_maps_count = params->src_files.source_line_map_count+1;
@@ -2424,13 +2464,19 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake namespaces
//
RDIM_NamespaceBakeResult *baked_namespaces = 0;
typedef struct BakedNamespaces BakedNamespaces;
struct BakedNamespaces
{
RDI_Namespace *namespaces;
RDI_U64 namespaces_count;
};
BakedNamespaces *baked_namespaces = 0;
ProfScope("bake namespaces")
{
// rjf: allocate
if(lane_idx() == 0)
{
baked_namespaces = push_array(scratch.arena, RDIM_NamespaceBakeResult, 1);
baked_namespaces = push_array(scratch.arena, BakedNamespaces, 1);
baked_namespaces->namespaces_count = params->namespaces.total_count + 1;
baked_namespaces->namespaces = push_array(arena, RDI_Namespace, baked_namespaces->namespaces_count);
}
@@ -2532,7 +2578,17 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake UDTs
//
RDIM_UDTBakeResult *baked_udts = 0;
typedef struct BakedUDTs BakedUDTs;
struct BakedUDTs
{
RDI_UDT *udts;
RDI_U64 udts_count;
RDI_Member *members;
RDI_U64 members_count;
RDI_EnumMember *enum_members;
RDI_U64 enum_members_count;
};
BakedUDTs *baked_udts = 0;
ProfScope("bake UDTs")
{
//- rjf: set up
@@ -2540,7 +2596,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
{
if(lane_idx() == 0)
{
baked_udts = push_array(scratch.arena, RDIM_UDTBakeResult, 1);
baked_udts = push_array(scratch.arena, BakedUDTs, 1);
}
lane_sync_u64(&baked_udts, 0);
if(lane_idx() == lane_from_task_idx(0))
@@ -2902,13 +2958,23 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake scopes
//
RDIM_ScopeBakeResult *baked_scopes = 0;
typedef struct BakedScopes BakedScopes;
struct BakedScopes
{
RDI_Scope *scopes;
RDI_U64 scopes_count;
RDI_U64 *scope_voffs;
RDI_U64 scope_voffs_count;
RDI_Local *locals;
RDI_U64 locals_count;
};
BakedScopes *baked_scopes = 0;
ProfScope("bake scopes")
{
//- rjf: setup outputs
if(lane_idx() == 0)
{
baked_scopes = push_array(scratch.arena, RDIM_ScopeBakeResult, 1);
baked_scopes = push_array(scratch.arena, BakedScopes, 1);
}
lane_sync_u64(&baked_scopes, 0);
if(lane_idx() == lane_from_task_idx(0))
@@ -2993,6 +3059,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake procedures
//
#if 0 // TODO(rjf): @locpass
RDIM_ProcedureBakeResult *baked_procedures = 0;
ProfScope("bake procedures")
{
@@ -3043,6 +3110,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
}
}
}
#endif
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage compute layout for constant data
@@ -3163,48 +3231,35 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake units, symbols, types, UDTs
//
RDIM_UnitBakeResult *baked_units = 0;
RDIM_TypeNodeBakeResult *baked_type_nodes = 0;
RDIM_GlobalVariableBakeResult *baked_global_variables = 0;
RDIM_ThreadVariableBakeResult *baked_thread_variables = 0;
RDIM_InlineSiteBakeResult *baked_inline_sites = 0;
RDI_Unit *baked_units = 0;
U64 baked_units_count = 0;
RDI_TypeNode *baked_type_nodes = 0;
U64 baked_type_nodes_count = 0;
RDI_InlineSite *baked_inline_sites = 0;
RDI_U64 baked_inline_sites_count = 0;
{
//- rjf: setup outputs
if(lane_idx() == lane_from_task_idx(0))
{
baked_units = push_array(scratch.arena, RDIM_UnitBakeResult, 1);
baked_units->units_count = params->units.total_count+1;
baked_units->units = push_array(arena, RDI_Unit, baked_units->units_count);
baked_units_count = params->units.total_count+1;
baked_units = push_array(arena, RDI_Unit, baked_units_count);
}
if(lane_idx() == lane_from_task_idx(1))
{
baked_type_nodes = push_array(scratch.arena, RDIM_TypeNodeBakeResult, 1);
baked_type_nodes->type_nodes_count = params->types.total_count+1;
baked_type_nodes->type_nodes = push_array(arena, RDI_TypeNode, baked_type_nodes->type_nodes_count);
baked_type_nodes_count = params->types.total_count+1;
baked_type_nodes = push_array(arena, RDI_TypeNode, baked_type_nodes_count);
}
if(lane_idx() == lane_from_task_idx(2))
{
baked_global_variables = push_array(scratch.arena, RDIM_GlobalVariableBakeResult, 1);
baked_global_variables->global_variables_count = params->global_variables.total_count+1;
baked_global_variables->global_variables = push_array(arena, RDI_GlobalVariable, baked_global_variables->global_variables_count);
}
if(lane_idx() == lane_from_task_idx(3))
{
baked_thread_variables = push_array(scratch.arena, RDIM_ThreadVariableBakeResult, 1);
baked_thread_variables->thread_variables_count = params->thread_variables.total_count+1;
baked_thread_variables->thread_variables = push_array(arena, RDI_ThreadVariable, baked_thread_variables->thread_variables_count);
}
if(lane_idx() == lane_from_task_idx(4))
{
baked_inline_sites = push_array(scratch.arena, RDIM_InlineSiteBakeResult, 1);
baked_inline_sites->inline_sites_count = params->inline_sites.total_count+1;
baked_inline_sites->inline_sites = push_array(arena, RDI_InlineSite, baked_inline_sites->inline_sites_count);
baked_inline_sites_count = params->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));
lane_sync_u64(&baked_units_count, lane_from_task_idx(0));
lane_sync_u64(&baked_type_nodes, lane_from_task_idx(1));
lane_sync_u64(&baked_global_variables, lane_from_task_idx(2));
lane_sync_u64(&baked_thread_variables, lane_from_task_idx(3));
lane_sync_u64(&baked_inline_sites, lane_from_task_idx(4));
lane_sync_u64(&baked_type_nodes_count, lane_from_task_idx(1));
lane_sync_u64(&baked_inline_sites, lane_from_task_idx(2));
lane_sync_u64(&baked_inline_sites_count, lane_from_task_idx(2));
//- rjf: bake units
ProfScope("bake units")
@@ -3215,7 +3270,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
for EachInRange(n_idx, range)
{
RDIM_Unit *src = &n->v[n_idx];
RDI_Unit *dst = &baked_units->units[n->base_idx + n_idx + 1];
RDI_Unit *dst = &baked_units[n->base_idx + n_idx + 1];
dst->unit_name_string_idx = rdim_bake_idx_from_string(bake_strings, src->unit_name);
dst->compiler_name_string_idx = rdim_bake_idx_from_string(bake_strings, src->compiler_name);
dst->source_file_path_node = rdim_bake_path_node_idx_from_string(path_tree, src->source_file);
@@ -3237,7 +3292,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
for EachInRange(n_idx, range)
{
RDIM_Type *src = &n->v[n_idx];
RDI_TypeNode *dst = &baked_type_nodes->type_nodes[n->base_idx + n_idx + 1];
RDI_TypeNode *dst = &baked_type_nodes[n->base_idx + n_idx + 1];
//- rjf: fill shared type node info
dst->kind = src->kind;
@@ -3376,7 +3431,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
Rng1U64 range = lane_range(n->count);
for EachInRange(n_idx, range)
{
RDI_InlineSite *dst = &baked_inline_sites->inline_sites[n->base_idx + n_idx + 1];
RDI_InlineSite *dst = &baked_inline_sites[n->base_idx + n_idx + 1];
RDIM_InlineSite *src = &n->v[n_idx];
dst->name_string_idx = rdim_bake_idx_from_string(bake_strings, src->name);
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
@@ -3391,16 +3446,26 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////
//- rjf: gather all lists which form symbol tables
//
RDI_Symbol *baked_global_variables = 0;
U64 baked_global_variables_count = 0;
RDI_Symbol *baked_thread_variables = 0;
U64 baked_thread_variables_count = 0;
RDI_Symbol *baked_procedures = 0;
U64 baked_procedures_count = 0;
RDI_Symbol *baked_constants = 0;
U64 baked_constants_count = 0;
struct
{
RDIM_SymbolChunkList *symbols;
RDI_Symbol **baked_symbols_out;
U64 *baked_symbols_count_out;
}
symbol_table_lists[] =
{
{&params->global_variables},
{&params->thread_variables},
{&params->procedures},
{&params->constants},
{&params->global_variables, &baked_global_variables, &baked_global_variables_count},
{&params->thread_variables, &baked_thread_variables, &baked_thread_variables_count},
{&params->procedures, &baked_procedures, &baked_procedures_count},
{&params->constants, &baked_constants, &baked_constants_count},
};
//////////////////////////////////////////////////////////////
@@ -3537,6 +3602,8 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
dst_symbols = push_array(arena, RDI_Symbol, dst_symbols_count);
}
lane_sync_u64(&dst_symbols, 0);
symbol_table_lists[symbol_table_list_idx].baked_symbols_out[0] = dst_symbols;
symbol_table_lists[symbol_table_list_idx].baked_symbols_count_out[0] = dst_symbols_count;
for EachNode(n, RDIM_SymbolChunkNode, src_symbols->first)
{
U64 slot_idx = lane_idx()*chunk_count + chunk_idx;
@@ -3668,14 +3735,20 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake file paths
//
RDIM_FilePathBakeResult *baked_file_paths = 0;
typedef struct BakedFilePaths BakedFilePaths;
struct BakedFilePaths
{
RDI_FilePathNode *nodes;
RDI_U64 nodes_count;
};
BakedFilePaths *baked_file_paths = 0;
RDIM_BakePathNode **baked_file_path_src_nodes = 0;
ProfScope("bake file paths")
{
// rjf: set up
if(lane_idx() == 0)
{
baked_file_paths = push_array(scratch.arena, RDIM_FilePathBakeResult, 1);
baked_file_paths = push_array(scratch.arena, BakedFilePaths, 1);
baked_file_paths->nodes_count = path_tree->count;
baked_file_paths->nodes = push_array(arena, RDI_FilePathNode, baked_file_paths->nodes_count);
baked_file_path_src_nodes = push_array(arena, RDIM_BakePathNode *, baked_file_paths->nodes_count);
@@ -3720,24 +3793,23 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage do small final baking tasks
//
RDIM_TopLevelInfoBakeResult *baked_top_level_info = 0;
RDIM_BinarySectionBakeResult *baked_binary_sections = 0;
RDI_TopLevelInfo *baked_top_level_info = 0;
RDI_BinarySection *baked_binary_sections = 0;
U64 baked_binary_sections_count = 0;
ProfScope("do small final baking tasks")
{
if(lane_idx() == lane_from_task_idx(0)) ProfScope("bake top level info")
{
baked_top_level_info = push_array(scratch.arena, RDIM_TopLevelInfoBakeResult, 1);
baked_top_level_info->top_level_info = push_array(arena, RDI_TopLevelInfo, 1);
baked_top_level_info->top_level_info->arch = params->top_level_info.arch;
baked_top_level_info->top_level_info->exe_name_string_idx = rdim_bake_idx_from_string(bake_strings, params->top_level_info.exe_name);
baked_top_level_info->top_level_info->exe_hash = params->top_level_info.exe_hash;
baked_top_level_info->top_level_info->voff_max = params->top_level_info.voff_max;
baked_top_level_info->top_level_info->guid = params->top_level_info.guid;
baked_top_level_info->top_level_info->producer_name_string_idx = rdim_bake_idx_from_string(bake_strings, params->top_level_info.producer_name);
baked_top_level_info = push_array(arena, RDI_TopLevelInfo, 1);
baked_top_level_info->arch = params->top_level_info.arch;
baked_top_level_info->exe_name_string_idx = rdim_bake_idx_from_string(bake_strings, params->top_level_info.exe_name);
baked_top_level_info->exe_hash = params->top_level_info.exe_hash;
baked_top_level_info->voff_max = params->top_level_info.voff_max;
baked_top_level_info->guid = params->top_level_info.guid;
baked_top_level_info->producer_name_string_idx = rdim_bake_idx_from_string(bake_strings, params->top_level_info.producer_name);
}
if(lane_idx() == lane_from_task_idx(1)) ProfScope("bake binary sections")
{
baked_binary_sections = push_array(scratch.arena, RDIM_BinarySectionBakeResult, 1);
RDIM_BinarySectionList *src = &params->binary_sections;
RDI_BinarySection *dst_base = rdim_push_array(arena, RDI_BinarySection, src->count+1);
U64 dst_idx = 1;
@@ -3752,46 +3824,63 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
dst->foff_first = src->foff_first;
dst->foff_opl = src->foff_opl;
}
baked_binary_sections->binary_sections = dst_base;
baked_binary_sections->binary_sections_count = dst_idx;
baked_binary_sections = dst_base;
baked_binary_sections_count = dst_idx;
}
}
lane_sync_u64(&baked_top_level_info, lane_from_task_idx(0));
lane_sync_u64(&baked_binary_sections, lane_from_task_idx(1));
lane_sync_u64(&baked_binary_sections_count, lane_from_task_idx(1));
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage package results
//
RDIM_BakeResults result = {0};
{
result.top_level_info = *baked_top_level_info;
result.binary_sections = *baked_binary_sections;
result.units = *baked_units;
result.unit_vmap = *baked_unit_vmap;
result.src_files = *baked_src_files;
result.checksums = *baked_checksums;
result.line_tables = *baked_line_tables;
result.type_nodes = *baked_type_nodes;
result.udts = *baked_udts;
result.global_variables = *baked_global_variables;
result.global_vmap = *baked_global_vmap;
result.thread_variables = *baked_thread_variables;
#if 0 // TODO(rjf): @locpass
result.constants = *baked_constants;
#endif
result.procedures = *baked_procedures;
result.scopes = *baked_scopes;
result.inline_sites = *baked_inline_sites;
result.scope_vmap = *baked_scope_vmap;
result.top_level_name_maps = *baked_top_level_name_maps;
result.name_maps = *baked_name_maps;
result.file_paths = *baked_file_paths;
result.strings = *baked_strings;
result.idx_runs = *baked_idx_runs;
#if 0 // TODO(rjf): @locpass
result.locations = *baked_locations;
result.location_blocks = *baked_location_blocks;
#endif
#define Map(kind, ptr, count) result.section_bundle.sections[RDI_SectionKind_##kind] = rdim_serialized_section_make_unpacked_array((ptr), (count))
Map(TopLevelInfo, baked_top_level_info, 1);
Map(StringData, baked_strings->string_data, baked_strings->string_data_size);
Map(StringTable, baked_strings->string_offs, baked_strings->string_offs_count);
Map(IndexRuns, baked_idx_runs->idx_runs, baked_idx_runs->idx_count);
Map(BinarySections, baked_binary_sections, baked_binary_sections_count);
Map(FilePathNodes, baked_file_paths->nodes, baked_file_paths->nodes_count);
Map(SourceFiles, baked_src_files->source_files, baked_src_files->source_files_count);
Map(LineTables, baked_line_tables->line_tables, baked_line_tables->line_tables_count);
Map(LineInfoVOffs, baked_line_tables->line_table_voffs, baked_line_tables->line_table_voffs_count);
Map(LineInfoLines, baked_line_tables->line_table_lines, baked_line_tables->line_table_lines_count);
Map(LineInfoColumns, baked_line_tables->line_table_columns, baked_line_tables->line_table_columns_count);
Map(SourceLineMaps, baked_src_files->source_line_maps, baked_src_files->source_line_maps_count);
Map(SourceLineMapNumbers, baked_src_files->source_line_map_nums, baked_src_files->source_line_map_nums_count);
Map(SourceLineMapRanges, baked_src_files->source_line_map_rngs, baked_src_files->source_line_map_rngs_count);
Map(SourceLineMapVOffs, baked_src_files->source_line_map_voffs, baked_src_files->source_line_map_voffs_count);
Map(Units, baked_units, baked_units_count);
Map(UnitVMap, baked_unit_vmap->vmap, baked_unit_vmap->count);
Map(Namespaces, baked_namespaces->namespaces, baked_namespaces->namespaces_count);
Map(TypeNodes, baked_type_nodes, baked_type_nodes_count);
Map(UDTs, baked_udts->udts, baked_udts->udts_count);
Map(Members, baked_udts->members, baked_udts->members_count);
Map(EnumMembers, baked_udts->enum_members, baked_udts->enum_members_count);
Map(Scopes, baked_scopes->scopes, baked_scopes->scopes_count);
Map(ScopeVOffData, baked_scopes->scope_voffs, baked_scopes->scope_voffs_count);
Map(ScopeVMap, baked_scope_vmap->vmap, baked_scope_vmap->count);
Map(InlineSites, baked_inline_sites, baked_inline_sites_count);
Map(GlobalVariableSymbols, baked_global_variables, baked_global_variables_count);
// Map(GlobalVMap, );
Map(ThreadVariableSymbols, baked_thread_variables, baked_thread_variables_count);
Map(ConstantSymbols, baked_constants, baked_constants_count);
Map(ProcedureSymbols, baked_procedures, baked_procedures_count);
// Map(LocalVariableSymbols, );
// Map(LocationsBytecodeData, );
// Map(LocationsConstantData, );
// Map(LocationsSetElements, );
// Map(MD5Checksums, );
// Map(SHA1Checksums, );
// Map(SHA256Checksums, );
// Map(Timestamps, );
// Map(NameMaps, );
// Map(NameMapBuckets, );
// Map(NameMapNodes, );
#undef Map
}
lane_sync();