diff --git a/src/eval/eval_types.c b/src/eval/eval_types.c index 12bc425e..b88870c4 100644 --- a/src/eval/eval_types.c +++ b/src/eval/eval_types.c @@ -1309,6 +1309,7 @@ e_type_data_members_from_key(Arena *arena, E_TypeKey key) SLLQueuePush(members_list.first, members_list.last, n); members_list.count += 1; members_need_offset_sort = members_need_offset_sort || (type->members[member_idx].kind == E_MemberKind_DataField && n->v.off < last_member_off); + members_need_offset_sort = members_need_offset_sort || (type->members[member_idx].kind != E_MemberKind_DataField); last_member_off = n->v.off; } else if(type->members[member_idx].kind == E_MemberKind_Base) diff --git a/src/lib_rdi_format/rdi_format.c b/src/lib_rdi_format/rdi_format.c index 57f02162..387cbc18 100644 --- a/src/lib_rdi_format/rdi_format.c +++ b/src/lib_rdi_format/rdi_format.c @@ -10,7 +10,7 @@ #ifndef RDI_FORMAT_C #define RDI_FORMAT_C -RDI_U16 rdi_section_element_size_table[37] = +RDI_U16 rdi_section_element_size_table[40] = { sizeof(RDI_U8), sizeof(RDI_TopLevelInfo), @@ -37,6 +37,7 @@ sizeof(RDI_EnumMember), sizeof(RDI_GlobalVariable), sizeof(RDI_VMapEntry), sizeof(RDI_ThreadVariable), +sizeof(RDI_Constant), sizeof(RDI_Procedure), sizeof(RDI_Scope), sizeof(RDI_U64), @@ -45,13 +46,15 @@ sizeof(RDI_InlineSite), sizeof(RDI_Local), sizeof(RDI_LocationBlock), sizeof(RDI_U8), +sizeof(RDI_U8), +sizeof(RDI_U32), sizeof(RDI_NameMap), sizeof(RDI_NameMapBucket), sizeof(RDI_NameMapNode), sizeof(RDI_U8), }; -RDI_U8 rdi_section_is_required_table[37] = +RDI_U8 rdi_section_is_required_table[40] = { 0, 0, @@ -90,6 +93,9 @@ RDI_U8 rdi_section_is_required_table[37] = 0, 0, 0, +0, +0, +0, }; RDI_U16 rdi_eval_op_ctrlbits_table[52] = diff --git a/src/lib_rdi_format/rdi_format.h b/src/lib_rdi_format/rdi_format.h index 23149735..e327e9fc 100644 --- a/src/lib_rdi_format/rdi_format.h +++ b/src/lib_rdi_format/rdi_format.h @@ -52,7 +52,7 @@ typedef int64_t RDI_S64; // "raddbg\0\0" #define RDI_MAGIC_CONSTANT 0x0000676264646172 -#define RDI_ENCODING_VERSION 11 +#define RDI_ENCODING_VERSION 12 //////////////////////////////////////////////////////////////// //~ Format Types & Functions @@ -85,18 +85,21 @@ RDI_SectionKind_EnumMembers = 0x0015, RDI_SectionKind_GlobalVariables = 0x0016, RDI_SectionKind_GlobalVMap = 0x0017, RDI_SectionKind_ThreadVariables = 0x0018, -RDI_SectionKind_Procedures = 0x0019, -RDI_SectionKind_Scopes = 0x001A, -RDI_SectionKind_ScopeVOffData = 0x001B, -RDI_SectionKind_ScopeVMap = 0x001C, -RDI_SectionKind_InlineSites = 0x001D, -RDI_SectionKind_Locals = 0x001E, -RDI_SectionKind_LocationBlocks = 0x001F, -RDI_SectionKind_LocationData = 0x0020, -RDI_SectionKind_NameMaps = 0x0021, -RDI_SectionKind_NameMapBuckets = 0x0022, -RDI_SectionKind_NameMapNodes = 0x0023, -RDI_SectionKind_COUNT = 0x0024, +RDI_SectionKind_Constants = 0x0019, +RDI_SectionKind_Procedures = 0x001A, +RDI_SectionKind_Scopes = 0x001B, +RDI_SectionKind_ScopeVOffData = 0x001C, +RDI_SectionKind_ScopeVMap = 0x001D, +RDI_SectionKind_InlineSites = 0x001E, +RDI_SectionKind_Locals = 0x001F, +RDI_SectionKind_LocationBlocks = 0x0020, +RDI_SectionKind_LocationData = 0x0021, +RDI_SectionKind_ConstantValueData = 0x0022, +RDI_SectionKind_ConstantValueTable = 0x0023, +RDI_SectionKind_NameMaps = 0x0024, +RDI_SectionKind_NameMapBuckets = 0x0025, +RDI_SectionKind_NameMapNodes = 0x0026, +RDI_SectionKind_COUNT = 0x0027, } RDI_SectionKindEnum; typedef RDI_U32 RDI_SectionEncoding; @@ -561,6 +564,7 @@ X(EnumMembers, enum_members, RDI_EnumMember)\ X(GlobalVariables, global_variables, RDI_GlobalVariable)\ X(GlobalVMap, global_vmap, RDI_VMapEntry)\ X(ThreadVariables, thread_variables, RDI_ThreadVariable)\ +X(Constants, constants, RDI_Constant)\ X(Procedures, procedures, RDI_Procedure)\ X(Scopes, scopes, RDI_Scope)\ X(ScopeVOffData, scope_voff_data, RDI_U64)\ @@ -569,6 +573,8 @@ X(InlineSites, inline_sites, RDI_InlineSite)\ X(Locals, locals, RDI_Local)\ X(LocationBlocks, location_blocks, RDI_LocationBlock)\ X(LocationData, location_data, RDI_U8)\ +X(ConstantValueData, constant_value_data, RDI_U8)\ +X(ConstantValueTable, constant_value_table, RDI_U32)\ X(NameMaps, name_maps, RDI_NameMap)\ X(NameMapBuckets, name_map_buckets, RDI_NameMapBucket)\ X(NameMapNodes, name_map_nodes, RDI_NameMapNode)\ @@ -1132,6 +1138,7 @@ typedef struct RDI_U32_Members { RDI_U32 v; } RDI_U32_Member typedef struct RDI_U32_EnumMembers { RDI_U32 v; } RDI_U32_EnumMembers; typedef struct RDI_U32_GlobalVariables { RDI_U32 v; } RDI_U32_GlobalVariables; typedef struct RDI_U32_ThreadVariables { RDI_U32 v; } RDI_U32_ThreadVariables; +typedef struct RDI_U32_Constants { RDI_U32 v; } RDI_U32_Constants; typedef struct RDI_U32_Procedures { RDI_U32 v; } RDI_U32_Procedures; typedef struct RDI_U32_Scopes { RDI_U32 v; } RDI_U32_Scopes; typedef struct RDI_U32_ScopeVOffData { RDI_U32 v; } RDI_U32_ScopeVOffData; @@ -1139,6 +1146,8 @@ typedef struct RDI_U32_InlineSites { RDI_U32 v; } RDI_U32_Inline typedef struct RDI_U32_Locals { RDI_U32 v; } RDI_U32_Locals; typedef struct RDI_U32_LocationBlocks { RDI_U32 v; } RDI_U32_LocationBlocks; typedef struct RDI_U32_LocationData { RDI_U32 v; } RDI_U32_LocationData; +typedef struct RDI_U32_ConstantValueData { RDI_U32 v; } RDI_U32_ConstantValueData; +typedef struct RDI_U32_ConstantValueTable { RDI_U32 v; } RDI_U32_ConstantValueTable; typedef struct RDI_U32_NameMaps { RDI_U32 v; } RDI_U32_NameMaps; typedef struct RDI_U32_NameMapBuckets { RDI_U32 v; } RDI_U32_NameMapBuckets; typedef struct RDI_U32_NameMapNodes { RDI_U32 v; } RDI_U32_NameMapNodes; @@ -1165,6 +1174,7 @@ typedef RDI_U32_Table RDI_U32_Members; typedef RDI_U32_Table RDI_U32_EnumMembers; typedef RDI_U32_Table RDI_U32_GlobalVariables; typedef RDI_U32_Table RDI_U32_ThreadVariables; +typedef RDI_U32_Table RDI_U32_Constants; typedef RDI_U32_Table RDI_U32_Procedures; typedef RDI_U32_Table RDI_U32_Scopes; typedef RDI_U32_Table RDI_U32_ScopeVOffData; @@ -1172,6 +1182,8 @@ typedef RDI_U32_Table RDI_U32_InlineSites; typedef RDI_U32_Table RDI_U32_Locals; typedef RDI_U32_Table RDI_U32_LocationBlocks; typedef RDI_U32_Table RDI_U32_LocationData; +typedef RDI_U32_Table RDI_U32_ConstantValueData; +typedef RDI_U32_Table RDI_U32_ConstantValueTable; typedef RDI_U32_Table RDI_U32_NameMaps; typedef RDI_U32_Table RDI_U32_NameMapBuckets; typedef RDI_U32_Table RDI_U32_NameMapNodes; @@ -1396,6 +1408,14 @@ RDI_U32 type_idx; RDI_U32 container_idx; }; +typedef struct RDI_Constant RDI_Constant; +struct RDI_Constant +{ +RDI_U32 name_string_idx; +RDI_U32 type_idx; +RDI_U32 constant_value_idx; +}; + typedef struct RDI_Procedure RDI_Procedure; struct RDI_Procedure { @@ -1522,6 +1542,7 @@ typedef RDI_EnumMember RDI_SectionElementType_EnumMembers; typedef RDI_GlobalVariable RDI_SectionElementType_GlobalVariables; typedef RDI_VMapEntry RDI_SectionElementType_GlobalVMap; typedef RDI_ThreadVariable RDI_SectionElementType_ThreadVariables; +typedef RDI_Constant RDI_SectionElementType_Constants; typedef RDI_Procedure RDI_SectionElementType_Procedures; typedef RDI_Scope RDI_SectionElementType_Scopes; typedef RDI_U64 RDI_SectionElementType_ScopeVOffData; @@ -1530,6 +1551,8 @@ typedef RDI_InlineSite RDI_SectionElementType_InlineSites; typedef RDI_Local RDI_SectionElementType_Locals; typedef RDI_LocationBlock RDI_SectionElementType_LocationBlocks; typedef RDI_U8 RDI_SectionElementType_LocationData; +typedef RDI_U8 RDI_SectionElementType_ConstantValueData; +typedef RDI_U32 RDI_SectionElementType_ConstantValueTable; typedef RDI_NameMap RDI_SectionElementType_NameMaps; typedef RDI_NameMapBucket RDI_SectionElementType_NameMapBuckets; typedef RDI_NameMapNode RDI_SectionElementType_NameMapNodes; @@ -1542,8 +1565,8 @@ RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTyp RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out); RDI_PROC RDI_U8 *rdi_string_from_type_kind(RDI_TypeKind kind, RDI_U64 *size_out); -extern RDI_U16 rdi_section_element_size_table[37]; -extern RDI_U8 rdi_section_is_required_table[37]; +extern RDI_U16 rdi_section_element_size_table[40]; +extern RDI_U8 rdi_section_is_required_table[40]; extern RDI_U16 rdi_eval_op_ctrlbits_table[52]; #endif // RDI_FORMAT_H diff --git a/src/lib_rdi_make/rdi_make.c b/src/lib_rdi_make/rdi_make.c index afc1ef9f..a5d9650c 100644 --- a/src/lib_rdi_make/rdi_make.c +++ b/src/lib_rdi_make/rdi_make.c @@ -294,7 +294,7 @@ rdim_sort_key_array(RDIM_Arena *arena, RDIM_SortKey *keys, RDI_U64 count) // generate an ordered range node RDIM_OrderedRange *new_range = rdim_push_array(rdim_temp_arena(scratch), RDIM_OrderedRange, 1); - SLLQueuePush(ranges_first, ranges_last, new_range); + RDIM_SLLQueuePush(ranges_first, ranges_last, new_range); range_count += 1; new_range->first = first; new_range->opl = opl; @@ -330,7 +330,7 @@ rdim_sort_key_array(RDIM_Arena *arena, RDIM_SortKey *keys, RDI_U64 count) // get first range RDIM_OrderedRange *range1 = src_ranges; - SLLStackPop(src_ranges); + RDIM_SLLStackPop(src_ranges); // if this range is the whole array, we are done if(range1->first == 0 && range1->opl == count) @@ -344,15 +344,16 @@ rdim_sort_key_array(RDIM_Arena *arena, RDIM_SortKey *keys, RDI_U64 count) { RDI_U64 first = range1->first; rdim_memcpy(dst + first, src + first, sizeof(*src)*(range1->opl - first)); - SLLQueuePush(dst_ranges, dst_ranges_last, range1); + RDIM_SLLQueuePush(dst_ranges, dst_ranges_last, range1); break; } // get second range RDIM_OrderedRange *range2 = src_ranges; - SLLStackPop(src_ranges); - + RDIM_SLLStackPop(src_ranges); +#if 0 rdim_assert(range1->opl == range2->first); +#endif // merge these ranges RDI_U64 jd = range1->first; @@ -419,7 +420,7 @@ rdim_sort_key_array(RDIM_Arena *arena, RDIM_SortKey *keys, RDI_U64 count) } #endif - scratch_end(scratch); + rdim_scratch_end(scratch); return result; } @@ -994,6 +995,7 @@ rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst, RDIM_SymbolChu dst->last = to_push->last; dst->chunk_count += to_push->chunk_count; dst->total_count += to_push->total_count; + dst->total_value_data_size += to_push->total_value_data_size; } else if(dst->first == 0) { @@ -1002,6 +1004,13 @@ rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst, RDIM_SymbolChu rdim_memzero_struct(to_push); } +internal void +rdim_symbol_push_value_data(RDIM_Arena *arena, RDIM_SymbolChunkList *list, RDIM_Symbol *symbol, RDIM_String8 data) +{ + symbol->value_data = rdim_str8_copy(arena, data); + list->total_value_data_size += data.size; +} + //////////////////////////////// //~ rjf: [Building] Inline Site Info Building @@ -3497,6 +3506,39 @@ rdim_bake_thread_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, return result; } +RDI_PROC RDIM_ConstantsBakeResult +rdim_bake_constants(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src) +{ + RDI_Constant *constants = push_array(arena, RDI_Constant, src->total_count+1); + RDI_U32 *constant_values = push_array(arena, RDI_U32, src->total_count+1); + RDI_U8 *constant_value_data = push_array(arena, RDI_U8, src->total_value_data_size+1); + RDI_U32 dst_idx = 1; + RDI_U64 dst_constant_value_data_off = 1; + for(RDIM_SymbolChunkNode *n = src->first; n != 0; n = n->next) + { + for(RDI_U64 chunk_idx = 0; chunk_idx < n->count; chunk_idx += 1, dst_idx += 1) + { + RDIM_Symbol *src = &n->v[chunk_idx]; + RDI_Constant *dst = &constants[dst_idx]; + RDI_U32 *dst_value_idx = &constant_values[dst_idx]; + dst->name_string_idx = rdim_bake_idx_from_string(strings, src->name); + dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32 + dst->constant_value_idx = dst_idx; + dst_value_idx[0] = dst_constant_value_data_off; + rdim_memcpy(constant_value_data + dst_constant_value_data_off, src->value_data.str, src->value_data.size); + dst_constant_value_data_off += src->value_data.size; + } + } + RDIM_ConstantsBakeResult result = {0}; + result.constants = constants; + result.constants_count = src->total_count+1; + result.constant_values = constant_values; + result.constant_values_count = src->total_count+1; + result.constant_value_data = constant_value_data; + result.constant_value_data_size = dst_constant_value_data_off; + return result; +} + RDI_PROC U64 rdim_bake_location(RDIM_Arena *arena, RDIM_String8List *location_data_blobs, RDIM_Location *src_location) { @@ -3970,6 +4012,7 @@ rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results) bundle.sections[RDI_SectionKind_GlobalVariables] = rdim_serialized_section_make_unpacked_array(results->global_variables.global_variables, results->global_variables.global_variables_count); bundle.sections[RDI_SectionKind_GlobalVMap] = rdim_serialized_section_make_unpacked_array(results->global_vmap.vmap.vmap, results->global_vmap.vmap.count+1); bundle.sections[RDI_SectionKind_ThreadVariables] = rdim_serialized_section_make_unpacked_array(results->thread_variables.thread_variables, results->thread_variables.thread_variables_count); + bundle.sections[RDI_SectionKind_Constants] = rdim_serialized_section_make_unpacked_array(results->constants.constants, results->constants.constants_count); bundle.sections[RDI_SectionKind_Procedures] = rdim_serialized_section_make_unpacked_array(results->procedures.procedures, results->procedures.procedures_count); bundle.sections[RDI_SectionKind_Scopes] = rdim_serialized_section_make_unpacked_array(results->scopes.scopes, results->scopes.scopes_count); bundle.sections[RDI_SectionKind_ScopeVOffData] = rdim_serialized_section_make_unpacked_array(results->scopes.scope_voffs, results->scopes.scope_voffs_count); @@ -3978,6 +4021,8 @@ rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results) bundle.sections[RDI_SectionKind_Locals] = rdim_serialized_section_make_unpacked_array(results->scopes.locals, results->scopes.locals_count); bundle.sections[RDI_SectionKind_LocationBlocks] = rdim_serialized_section_make_unpacked_array(results->location_blocks.str, results->location_blocks.size); bundle.sections[RDI_SectionKind_LocationData] = rdim_serialized_section_make_unpacked_array(results->location_data.str, results->location_data.size); + bundle.sections[RDI_SectionKind_ConstantValueData] = rdim_serialized_section_make_unpacked_array(results->constants.constant_value_data, results->constants.constant_value_data_size); + bundle.sections[RDI_SectionKind_ConstantValueTable] = rdim_serialized_section_make_unpacked_array(results->constants.constant_values, results->constants.constant_values_count); bundle.sections[RDI_SectionKind_NameMaps] = rdim_serialized_section_make_unpacked_array(results->top_level_name_maps.name_maps, results->top_level_name_maps.name_maps_count); bundle.sections[RDI_SectionKind_NameMapBuckets] = rdim_serialized_section_make_unpacked_array(results->name_maps.buckets, results->name_maps.buckets_count); bundle.sections[RDI_SectionKind_NameMapNodes] = rdim_serialized_section_make_unpacked_array(results->name_maps.nodes, results->name_maps.nodes_count); diff --git a/src/lib_rdi_make/rdi_make.h b/src/lib_rdi_make/rdi_make.h index 74024ff2..e65b2e84 100644 --- a/src/lib_rdi_make/rdi_make.h +++ b/src/lib_rdi_make/rdi_make.h @@ -763,16 +763,6 @@ struct RDIM_LocationSet //////////////////////////////// //~ rjf: Symbol Info Types -typedef enum RDIM_SymbolKind -{ - RDIM_SymbolKind_NULL, - RDIM_SymbolKind_GlobalVariable, - RDIM_SymbolKind_ThreadVariable, - RDIM_SymbolKind_Procedure, - RDIM_SymbolKind_COUNT -} -RDIM_SymbolKind; - typedef struct RDIM_Symbol RDIM_Symbol; struct RDIM_Symbol { @@ -786,6 +776,7 @@ struct RDIM_Symbol RDIM_Type *container_type; struct RDIM_Scope *root_scope; RDIM_LocationSet frame_base; + RDIM_String8 value_data; }; typedef struct RDIM_SymbolChunkNode RDIM_SymbolChunkNode; @@ -805,6 +796,7 @@ struct RDIM_SymbolChunkList RDIM_SymbolChunkNode *last; RDI_U64 chunk_count; RDI_U64 total_count; + RDI_U64 total_value_data_size; }; //////////////////////////////// @@ -907,6 +899,7 @@ struct RDIM_BakeParams 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; @@ -1192,6 +1185,17 @@ struct RDIM_ThreadVariableBakeResult RDI_U64 thread_variables_count; }; +typedef struct RDIM_ConstantsBakeResult RDIM_ConstantsBakeResult; +struct RDIM_ConstantsBakeResult +{ + RDI_Constant *constants; + RDI_U64 constants_count; + RDI_U32 *constant_values; + RDI_U64 constant_values_count; + RDI_U8 *constant_value_data; + RDI_U64 constant_value_data_size; +}; + typedef struct RDIM_ProcedureBakeResult RDIM_ProcedureBakeResult; struct RDIM_ProcedureBakeResult { @@ -1276,6 +1280,7 @@ struct RDIM_BakeResults 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; @@ -1419,6 +1424,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); +internal void rdim_symbol_push_value_data(RDIM_Arena *arena, RDIM_SymbolChunkList *list, RDIM_Symbol *symbol, RDIM_String8 data); //////////////////////////////// //~ rjf: [Building] Inline Site Info Building @@ -1562,6 +1568,7 @@ RDI_PROC RDIM_UDTBakeResult rdim_bake_udts(RDIM_Arena *arena, RDIM_B RDI_PROC RDIM_GlobalVariableBakeResult rdim_bake_global_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src); RDI_PROC RDIM_GlobalVMapBakeResult rdim_bake_global_vmap(RDIM_Arena *arena, RDIM_SymbolChunkList *src); RDI_PROC RDIM_ThreadVariableBakeResult rdim_bake_thread_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src); +RDI_PROC RDIM_ConstantsBakeResult rdim_bake_constants(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src); RDI_PROC RDIM_ProcedureBakeResult rdim_bake_procedures(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_String8List *location_blocks, RDIM_String8List *location_data_blobs, RDIM_SymbolChunkList *src); RDI_PROC RDIM_ScopeBakeResult rdim_bake_scopes(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_String8List *location_blocks, RDIM_String8List *location_data_blobs, RDIM_ScopeChunkList *src); RDI_PROC RDIM_ScopeVMapBakeResult rdim_bake_scope_vmap(RDIM_Arena *arena, RDIM_ScopeChunkList *src); diff --git a/src/rdi_format/rdi_format.mdesk b/src/rdi_format/rdi_format.mdesk index aabc166d..99f44788 100644 --- a/src/rdi_format/rdi_format.mdesk +++ b/src/rdi_format/rdi_format.mdesk @@ -62,7 +62,7 @@ ""; "// \"raddbg\\0\\0\""; "#define RDI_MAGIC_CONSTANT 0x0000676264646172"; - "#define RDI_ENCODING_VERSION 11"; + "#define RDI_ENCODING_VERSION 12"; ""; "////////////////////////////////////////////////////////////////"; "//~ Format Types & Functions"; @@ -145,18 +145,21 @@ RDI_SectionTable: {GlobalVariables global_variables RDI_GlobalVariable 0x0016 - U32 ""} {GlobalVMap global_vmap RDI_VMapEntry 0x0017 - - ""} {ThreadVariables thread_variables RDI_ThreadVariable 0x0018 - U32 ""} - {Procedures procedures RDI_Procedure 0x0019 - U32 ""} - {Scopes scopes RDI_Scope 0x001A - U32 ""} - {ScopeVOffData scope_voff_data RDI_U64 0x001B - U32 ""} - {ScopeVMap scope_vmap RDI_VMapEntry 0x001C - - ""} - {InlineSites inline_sites RDI_InlineSite 0x001D - U32 ""} - {Locals locals RDI_Local 0x001E - U32 ""} - {LocationBlocks location_blocks RDI_LocationBlock 0x001F - U32 ""} - {LocationData location_data RDI_U8 0x0020 - U32 ""} - {NameMaps name_maps RDI_NameMap 0x0021 - U32 ""} - {NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0022 - U32 ""} - {NameMapNodes name_map_nodes RDI_NameMapNode 0x0023 - U32 ""} - {COUNT count RDI_U8 0x0024 - - ""} + {Constants constants RDI_Constant 0x0019 - U32 ""} + {Procedures procedures RDI_Procedure 0x001A - U32 ""} + {Scopes scopes RDI_Scope 0x001B - U32 ""} + {ScopeVOffData scope_voff_data RDI_U64 0x001C - U32 ""} + {ScopeVMap scope_vmap RDI_VMapEntry 0x001D - - ""} + {InlineSites inline_sites RDI_InlineSite 0x001E - U32 ""} + {Locals locals RDI_Local 0x001F - U32 ""} + {LocationBlocks location_blocks RDI_LocationBlock 0x0020 - U32 ""} + {LocationData location_data RDI_U8 0x0021 - U32 ""} + {ConstantValueData constant_value_data RDI_U8 0x0022 - U32 ""} + {ConstantValueTable constant_value_table RDI_U32 0x0023 - U32 ""} + {NameMaps name_maps RDI_NameMap 0x0024 - U32 ""} + {NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0025 - U32 ""} + {NameMapNodes name_map_nodes RDI_NameMapNode 0x0026 - U32 ""} + {COUNT count RDI_U8 0x0027 - - ""} } @table(name value) @@ -1024,6 +1027,14 @@ RDI_ThreadVariableMemberTable: {container_idx RDI_U32 ""} } +@table(name type desc) +RDI_ConstantMemberTable: +{ + {name_string_idx RDI_U32 ""} + {type_idx RDI_U32 ""} + {constant_value_idx RDI_U32 ""} +} + @table(name type desc) RDI_ProcedureMemberTable: { @@ -1199,6 +1210,11 @@ RDI_LocationRegMemberTable: @expand(RDI_ThreadVariableMemberTable a) `$(a.type) $(a.name)` } +@struct RDI_Constant: +{ + @expand(RDI_ConstantMemberTable a) `$(a.type) $(a.name)` +} + @struct RDI_Procedure: { @expand(RDI_ProcedureMemberTable a) `$(a.type) $(a.name)` diff --git a/src/rdi_from_pdb/rdi_from_pdb.c b/src/rdi_from_pdb/rdi_from_pdb.c index a15b21cb..bdb06581 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.c +++ b/src/rdi_from_pdb/rdi_from_pdb.c @@ -2112,6 +2112,7 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) RDIM_SymbolChunkList sym_procedures = {0}; RDIM_SymbolChunkList sym_global_variables = {0}; RDIM_SymbolChunkList sym_thread_variables = {0}; + RDIM_SymbolChunkList sym_constants = {0}; RDIM_ScopeChunkList sym_scopes = {0}; RDIM_InlineSiteChunkList sym_inline_sites = {0}; RDIM_TypeChunkList typedefs = {0}; @@ -2962,6 +2963,7 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) out->procedures = sym_procedures; out->global_variables = sym_global_variables; out->thread_variables = sym_thread_variables; + out->constants = sym_constants; out->scopes = sym_scopes; out->inline_sites = sym_inline_sites; out->typedefs = typedefs; @@ -4011,6 +4013,7 @@ p2r_convert(Arena *arena, P2R_User2Convert *in) 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}; ProfScope("produce symbols from all streams") @@ -4065,6 +4068,7 @@ p2r_convert(Arena *arena, P2R_User2Convert *in) rdim_symbol_chunk_list_concat_in_place(&all_procedures, &out->procedures); rdim_symbol_chunk_list_concat_in_place(&all_global_variables, &out->global_variables); rdim_symbol_chunk_list_concat_in_place(&all_thread_variables, &out->thread_variables); + rdim_symbol_chunk_list_concat_in_place(&all_constants, &out->constants); rdim_scope_chunk_list_concat_in_place(&all_scopes, &out->scopes); rdim_inline_site_chunk_list_concat_in_place(&all_inline_sites,&out->inline_sites); rdim_type_chunk_list_concat_in_place(&all_types, &out->typedefs); @@ -4096,6 +4100,7 @@ p2r_convert(Arena *arena, P2R_User2Convert *in) out->bake_params.line_tables = all_line_tables; out->bake_params.global_variables = all_global_variables; out->bake_params.thread_variables = all_thread_variables; + out->bake_params.constants = all_constants; out->bake_params.procedures = all_procedures; out->bake_params.scopes = all_scopes; out->bake_params.inline_sites = all_inline_sites; diff --git a/src/rdi_from_pdb/rdi_from_pdb.h b/src/rdi_from_pdb/rdi_from_pdb.h index e8642256..9db572df 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.h +++ b/src/rdi_from_pdb/rdi_from_pdb.h @@ -270,6 +270,7 @@ struct P2R_SymbolStreamConvertOut RDIM_SymbolChunkList procedures; RDIM_SymbolChunkList global_variables; RDIM_SymbolChunkList thread_variables; + RDIM_SymbolChunkList constants; RDIM_ScopeChunkList scopes; RDIM_InlineSiteChunkList inline_sites; RDIM_TypeChunkList typedefs; diff --git a/src/rdi_make/rdi_make_help.c b/src/rdi_make/rdi_make_help.c index 35ff0d9b..c3ec28fd 100644 --- a/src/rdi_make/rdi_make_help.c +++ b/src/rdi_make/rdi_make_help.c @@ -436,6 +436,7 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params) in_params->procedures.total_count*1 + in_params->global_variables.total_count*1 + in_params->thread_variables.total_count*1 + + in_params->constants.total_count*1 + in_params->types.total_count/2)}; RDIM_BakeStringMapLoose **bake_string_maps__in_progress = push_array(scratch.arena, RDIM_BakeStringMapLoose *, async_thread_count()); ASYNC_TaskList bake_string_map_build_tasks = {0}; @@ -531,6 +532,7 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params) { &in_params->global_variables, &in_params->thread_variables, + &in_params->constants, &in_params->procedures, }; for(U64 list_idx = 0; list_idx < ArrayCount(symbol_lists); list_idx += 1) diff --git a/src/rdi_make/rdi_make_local.c b/src/rdi_make/rdi_make_local.c index 01fa4949..23f6d741 100644 --- a/src/rdi_make/rdi_make_local.c +++ b/src/rdi_make/rdi_make_local.c @@ -332,6 +332,17 @@ ASYNC_WORK_DEF(rdim_bake_thread_variables_work) return out; } +ASYNC_WORK_DEF(rdim_bake_constants_work) +{ + ProfBeginFunction(); + Arena *arena = rdim_local_state->work_thread_arenas[thread_idx]; + RDIM_BakeConstantsIn *in = (RDIM_BakeConstantsIn *)input; + RDIM_ConstantsBakeResult *out = push_array(arena, RDIM_ConstantsBakeResult, 1); + ProfScope("bake constants") *out = rdim_bake_constants(arena, in->strings, in->constants); + ProfEnd(); + return out; +} + ASYNC_WORK_DEF(rdim_bake_procedures_work) { ProfBeginFunction(); @@ -983,30 +994,53 @@ rdim_bake(RDIM_LocalState *state, RDIM_BakeParams *in_params) ASYNC_Task *bake_file_paths_task = async_task_launch(scratch.arena, rdim_bake_file_paths_work, .input = &bake_file_paths_in); RDIM_BakeStringsIn bake_strings_in = {&bake_strings}; ASYNC_Task *bake_strings_task = async_task_launch(scratch.arena, rdim_bake_strings_work, .input = &bake_strings_in); + RDIM_BakeConstantsIn bake_constants_in = {&bake_strings, &in_params->constants}; + ASYNC_Task *bake_constants_task = async_task_launch(scratch.arena, rdim_bake_constants_work, .input = &bake_constants_in); + ////////////////////////////// + //- rjf: (GIANT SERIAL DEPENDENCY CHAIN HACK OF LOCATION BLOCK BUILDING) + // + // TODO(rjf): // TODO(rjf): // TODO(rjf): { + // + // This needs to be majorly cleaned up. We are doing this giant + // serial-dependency chain of async tasks (thus removing all async + // properties) because each async task here is secretly mutating + // the same input parameter (something which breaks the rules & + // style used everywhere else in the converter). + // + // Location blocks for each category of symbol should be built + // & arranged in parallel, then joined via a very thin operation + // after the fact. We should not ever be secretly mutating input + // parameters to async tasks, we need to be only returning new + // stuff. + // RDIM_String8List location_blocks = {0}; RDIM_String8List location_data_blobs = {0}; - - // reserve null location block for opl - rdim_location_block_chunk_list_push_array(state->arena, &location_blocks, 1); - - // TODO: export location instead of VOFF - RDIM_BakeThreadVariablesIn bake_thread_variables_in = {&bake_strings, &in_params->thread_variables}; - ASYNC_Task *bake_thread_variables_task = async_task_launch(scratch.arena, rdim_bake_thread_variables_work, .input = &bake_thread_variables_in); - ProfScope("thread variables") out.thread_variables = *async_task_join_struct(bake_thread_variables_task, RDIM_ThreadVariableBakeResult); - - // TODO: export location instead of VOFF - RDIM_BakeGlobalVariablesIn bake_global_variables_in = {&bake_strings, &in_params->global_variables}; - ASYNC_Task *bake_global_variables_task = async_task_launch(scratch.arena, rdim_bake_global_variables_work, .input = &bake_global_variables_in); - ProfScope("global variables") out.global_variables = *async_task_join_struct(bake_global_variables_task, RDIM_GlobalVariableBakeResult); - - RDIM_BakeScopesIn bake_scopes_in = {&bake_strings, &in_params->scopes, &location_blocks, &location_data_blobs}; - ASYNC_Task *bake_scopes_task = async_task_launch(scratch.arena, rdim_bake_scopes_work, .input = &bake_scopes_in); - ProfScope("scopes") out.scopes = *async_task_join_struct(bake_scopes_task, RDIM_ScopeBakeResult); - - RDIM_BakeProceduresIn bake_procedures_in = {&bake_strings, &in_params->procedures, &location_blocks, &location_data_blobs}; - ASYNC_Task *bake_procedures_task = async_task_launch(scratch.arena, rdim_bake_procedures_work, .input = &bake_procedures_in); - ProfScope("procedures") out.procedures = *async_task_join_struct(bake_procedures_task, RDIM_ProcedureBakeResult); + { + // reserve null location block for opl + rdim_location_block_chunk_list_push_array(state->arena, &location_blocks, 1); + + // TODO: export location instead of VOFF + RDIM_BakeGlobalVariablesIn bake_global_variables_in = {&bake_strings, &in_params->global_variables}; + ASYNC_Task *bake_global_variables_task = async_task_launch(scratch.arena, rdim_bake_global_variables_work, .input = &bake_global_variables_in); + ProfScope("global variables") out.global_variables = *async_task_join_struct(bake_global_variables_task, RDIM_GlobalVariableBakeResult); + + // TODO: export location instead of VOFF + RDIM_BakeThreadVariablesIn bake_thread_variables_in = {&bake_strings, &in_params->thread_variables}; + ASYNC_Task *bake_thread_variables_task = async_task_launch(scratch.arena, rdim_bake_thread_variables_work, .input = &bake_thread_variables_in); + ProfScope("thread variables") out.thread_variables = *async_task_join_struct(bake_thread_variables_task, RDIM_ThreadVariableBakeResult); + + RDIM_BakeScopesIn bake_scopes_in = {&bake_strings, &in_params->scopes, &location_blocks, &location_data_blobs}; + ASYNC_Task *bake_scopes_task = async_task_launch(scratch.arena, rdim_bake_scopes_work, .input = &bake_scopes_in); + ProfScope("scopes") out.scopes = *async_task_join_struct(bake_scopes_task, RDIM_ScopeBakeResult); + + RDIM_BakeProceduresIn bake_procedures_in = {&bake_strings, &in_params->procedures, &location_blocks, &location_data_blobs}; + ASYNC_Task *bake_procedures_task = async_task_launch(scratch.arena, rdim_bake_procedures_work, .input = &bake_procedures_in); + ProfScope("procedures") out.procedures = *async_task_join_struct(bake_procedures_task, RDIM_ProcedureBakeResult); + } + // + //- TODO(rjf): // TODO(rjf): // TODO(rjf): } + ////////////////////////////// ////////////////////////////// //- rjf: join name map building tasks @@ -1074,6 +1108,7 @@ rdim_bake(RDIM_LocalState *state, RDIM_BakeParams *in_params) ProfScope("inline sites") out.inline_sites = *async_task_join_struct(bake_inline_sites_task, RDIM_InlineSiteBakeResult); ProfScope("file paths") out.file_paths = *async_task_join_struct(bake_file_paths_task, RDIM_FilePathBakeResult); ProfScope("strings") out.strings = *async_task_join_struct(bake_strings_task, RDIM_StringBakeResult); + ProfScope("constants") out.constants = *async_task_join_struct(bake_constants_task, RDIM_ConstantsBakeResult); ProfScope("type nodes") out.type_nodes = *async_task_join_struct(bake_type_nodes_task, RDIM_TypeNodeBakeResult); ProfScope("idx runs") out.idx_runs = *async_task_join_struct(bake_idx_runs_task, RDIM_IndexRunBakeResult); ProfScope("line tables") out.line_tables = *async_task_join_struct(bake_line_tables_task, RDIM_LineTableBakeResult); diff --git a/src/rdi_make/rdi_make_local.h b/src/rdi_make/rdi_make_local.h index 5dc7ec6b..ac700478 100644 --- a/src/rdi_make/rdi_make_local.h +++ b/src/rdi_make/rdi_make_local.h @@ -238,6 +238,13 @@ struct RDIM_BakeGlobalVariablesIn RDIM_SymbolChunkList *global_variables; }; +typedef struct RDIM_BakeConstantsIn RDIM_BakeConstantsIn; +struct RDIM_BakeConstantsIn +{ + RDIM_BakeStringMapTight *strings; + RDIM_SymbolChunkList *constants; +}; + typedef struct RDIM_BakeGlobalVMapIn RDIM_BakeGlobalVMapIn; struct RDIM_BakeGlobalVMapIn { @@ -351,6 +358,7 @@ ASYNC_WORK_DEF(rdim_bake_udts_work); ASYNC_WORK_DEF(rdim_bake_global_variables_work); ASYNC_WORK_DEF(rdim_bake_global_vmap_work); ASYNC_WORK_DEF(rdim_bake_thread_variables_work); +ASYNC_WORK_DEF(rdim_bake_constants_work); ASYNC_WORK_DEF(rdim_bake_procedures_work); ASYNC_WORK_DEF(rdim_bake_scopes_work); ASYNC_WORK_DEF(rdim_bake_scope_vmap_work);