checkpoint on new simplified location info baking. plug in constant data baking, bytecode baking

This commit is contained in:
Ryan Fleury
2026-04-20 09:57:30 -07:00
parent 4db9a47d46
commit 4ea7f86d92
7 changed files with 103 additions and 229 deletions
+1 -69
View File
@@ -976,8 +976,6 @@ rdim_inline_site_chunk_list_concat_in_place(RDIM_InlineSiteChunkList *dst, RDIM_
////////////////////////////////
//~ rjf: [Building] Location Info Building
//- rjf: bytecode
RDI_PROC RDIM_EvalBytecodeOp *
rdim_bytecode_push_op(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_EvalOp op, RDI_U64 p)
{
@@ -1082,71 +1080,6 @@ rdim_is_bytecode_tls_dependent(RDIM_EvalBytecode bytecode)
return result;
}
//- rjf: locations
RDI_PROC RDI_U64
rdim_encoded_size_from_location_info(RDIM_LocationInfo *info)
{
RDI_U64 result = 0;
switch((RDI_LocationKindEnum)info->kind)
{
case RDI_LocationKind_NULL:{}break;
case RDI_LocationKind_AddrBytecodeStream:
case RDI_LocationKind_ValBytecodeStream:
{
result = sizeof(RDI_LocationBytecodeStream) + info->bytecode.encoded_size + 1;
}break;
case RDI_LocationKind_AddrRegPlusU16:
case RDI_LocationKind_AddrAddrRegPlusU16:
{
result = sizeof(RDI_LocationRegPlusU16);
}break;
case RDI_LocationKind_ValReg:
{
result = sizeof(RDI_LocationReg);
}break;
}
return result;
}
RDI_PROC RDIM_Location *
rdim_location_chunk_list_push_new(RDIM_Arena *arena, RDIM_LocationChunkList *list, RDI_U64 cap, RDIM_LocationInfo *info)
{
RDIM_IdxedChunkListPush(arena, list, RDIM_LocationChunkNode, RDIM_Location, cap, result, n->base_encoding_off = list->total_encoded_size);
{
RDI_U64 encoded_size = rdim_encoded_size_from_location_info(info);
rdim_memcpy_struct(&result->info, info);
result->relative_encoding_off = list->last->encoded_size;
list->last->encoded_size += encoded_size;
list->total_encoded_size += encoded_size;
}
return result;
}
RDI_PROC RDI_U64
rdim_off_from_location(RDIM_Location *location)
{
RDI_U64 off = 0;
if(location != 0 && location->chunk != 0)
{
off = location->chunk->base_encoding_off + location->relative_encoding_off + 1;
}
return off;
}
RDI_PROC void
rdim_location_chunk_list_concat_in_place(RDIM_LocationChunkList *dst, RDIM_LocationChunkList *to_push)
{
for(RDIM_LocationChunkNode *n = to_push->first; n != 0; n = n->next)
{
n->base_encoding_off += dst->total_encoded_size;
}
RDIM_IdxedChunkListConcatInPlace(RDIM_LocationChunkNode, dst, to_push, dst->total_encoded_size += to_push->total_encoded_size);
}
////////////////////////////////
//~ rjf: [Building] Scope Info Building
@@ -1196,7 +1129,7 @@ rdim_push_location_case(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Loc
RDIM_LocationCase *n = rdim_push_array(arena, RDIM_LocationCase, 1);
RDIM_SLLQueuePush(list->first, list->last, n);
list->count += 1;
n->location = location;
n->location = *location;
n->voff_range = voff_range;
scopes->location_case_count += 1;
return n;
@@ -1287,7 +1220,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_location_chunk_list_concat_in_place(&dst->locations, &src->locations);
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);
+5 -44
View File
@@ -850,52 +850,21 @@ struct RDIM_EvalBytecode
//- rjf: location types
typedef struct RDIM_LocationInfo RDIM_LocationInfo;
struct RDIM_LocationInfo
typedef struct RDIM_Location RDIM_Location;
struct RDIM_Location
{
RDI_LocationKind kind;
RDI_U8 reg_code;
RDI_U64 offset;
RDIM_EvalBytecode bytecode;
String8 value_data;
};
typedef struct RDIM_Location RDIM_Location;
struct RDIM_Location
{
struct RDIM_LocationChunkNode *chunk;
RDIM_LocationInfo info;
RDI_U64 relative_encoding_off;
};
typedef struct RDIM_LocationChunkNode RDIM_LocationChunkNode;
struct RDIM_LocationChunkNode
{
RDIM_LocationChunkNode *next;
RDIM_Location *v;
RDI_U64 count;
RDI_U64 cap;
RDI_U64 base_idx;
RDI_U64 base_encoding_off;
RDI_U64 encoded_size;
};
typedef struct RDIM_LocationChunkList RDIM_LocationChunkList;
struct RDIM_LocationChunkList
{
RDIM_LocationChunkNode *first;
RDIM_LocationChunkNode *last;
RDI_U64 chunk_count;
RDI_U64 total_count;
RDI_U64 total_encoded_size;
};
//- rjf: location cases
typedef struct RDIM_LocationCase RDIM_LocationCase;
struct RDIM_LocationCase
{
RDIM_LocationCase *next;
RDIM_Location *location;
RDIM_Location location;
RDIM_Rng1U64 voff_range;
};
@@ -1047,7 +1016,6 @@ struct RDIM_BakeParams
RDIM_UDTChunkList udts;
RDIM_SrcFileChunkList src_files;
RDIM_LineTableChunkList line_tables;
RDIM_LocationChunkList locations;
RDIM_SymbolChunkList global_variables;
RDIM_SymbolChunkList thread_variables;
RDIM_SymbolChunkList constants;
@@ -1707,20 +1675,13 @@ RDI_PROC void rdim_inline_site_chunk_list_concat_in_place(RDIM_InlineSiteChunkLi
////////////////////////////////
//~ rjf: [Building] Location Info Building
//- rjf: bytecode
RDI_PROC RDIM_EvalBytecodeOp * rdim_bytecode_push_op(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_EvalOp op, RDI_U64 p);
RDI_PROC RDIM_EvalBytecodeOp *rdim_bytecode_push_op(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_EvalOp op, RDI_U64 p);
RDI_PROC void rdim_bytecode_push_uconst(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_U64 x);
RDI_PROC void rdim_bytecode_push_sconst(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_S64 x);
RDI_PROC void rdim_bytecode_push_convert(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_EvalTypeGroup in, RDI_EvalTypeGroup out);
RDI_PROC void rdim_bytecode_concat_in_place(RDIM_EvalBytecode *left_dst, RDIM_EvalBytecode *right_destroyed);
RDI_PROC B32 rdim_is_bytecode_tls_dependent(RDIM_EvalBytecode bytecode);
//- rjf: locations
RDI_PROC RDI_U64 rdim_encoded_size_from_location_info(RDIM_LocationInfo *info);
RDI_PROC RDIM_Location *rdim_location_chunk_list_push_new(RDIM_Arena *arena, RDIM_LocationChunkList *list, RDI_U64 cap, RDIM_LocationInfo *info);
RDI_PROC RDI_U64 rdim_off_from_location(RDIM_Location *location);
RDI_PROC void rdim_location_chunk_list_concat_in_place(RDIM_LocationChunkList *dst, RDIM_LocationChunkList *to_push);
////////////////////////////////
//~ rjf: [Building] Scope Info Building
+21 -29
View File
@@ -1311,28 +1311,24 @@ d2r_bytecode_from_expression(Arena *arena,
return bc;
}
internal RDIM_Location *
d2r_transpile_expression(Arena *arena, RDIM_LocationChunkList *locations, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr)
internal RDIM_Location
d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr)
{
RDIM_Location *loc = 0;
RDIM_Location loc = {0};
if (expr.size) {
D2R_ValueType result_type = 0;
RDIM_EvalBytecode bytecode = d2r_bytecode_from_expression(arena, input, image_base, arch, addr_lu, expr, cu, &result_type);
RDIM_LocationInfo *loc_info = push_array(arena, RDIM_LocationInfo, 1);
loc_info->kind = result_type == D2R_ValueType_Address ? RDI_LocationKind_AddrBytecodeStream : RDI_LocationKind_ValBytecodeStream;
loc_info->bytecode = bytecode;
loc = rdim_location_chunk_list_push_new(arena, locations, D2R_LOCATIONS_CAP, loc_info);
loc.kind = result_type == D2R_ValueType_Address ? RDI_LocationKind_AddrBytecodeStream : RDI_LocationKind_ValBytecodeStream;
loc.bytecode = bytecode;
}
return loc;
}
internal RDIM_Location *
d2r_location_from_attrib(Arena *arena, RDIM_LocationChunkList *locations, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind)
internal RDIM_Location
d2r_location_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind)
{
String8 expr = dw_exprloc_from_tag_attrib_kind(input, cu, tag, kind);
RDIM_Location *location = d2r_transpile_expression(arena, locations, input, image_base, arch, cu->addr_lu, cu, expr);
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, expr);
return location;
}
@@ -1340,7 +1336,6 @@ internal RDIM_LocationCaseList
d2r_locset_from_attrib(Arena *arena,
RDIM_ScopeChunkList *scopes,
RDIM_Scope *curr_scope,
RDIM_LocationChunkList *locations,
DW_Input *input,
DW_CompUnit *cu,
U64 image_base,
@@ -1362,9 +1357,9 @@ d2r_locset_from_attrib(Arena *arena,
// convert location list to RDIM location set
for EachNode(loc_n, DW_LocNode, loclist.first) {
RDIM_Location *location = d2r_transpile_expression(arena, locations, input, image_base, arch, cu->addr_lu, cu, loc_n->v.expr);
RDIM_Rng1U64 voff_range = { .min = loc_n->v.range.min - image_base, .max = loc_n->v.range.max - image_base };
rdim_push_location_case(arena, scopes, &locset, location, voff_range);
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, loc_n->v.expr);
RDIM_Rng1U64 voff_range = { .min = loc_n->v.range.min - image_base, .max = loc_n->v.range.max - image_base };
rdim_push_location_case(arena, scopes, &locset, &location, voff_range);
}
scratch_end(scratch);
@@ -1373,9 +1368,9 @@ d2r_locset_from_attrib(Arena *arena,
String8 expr = dw_exprloc_from_attrib(input, cu, attrib);
// convert expression and inherit life-time ranges from enclosed scope
RDIM_Location *location = d2r_transpile_expression(arena, locations, input, image_base, arch, cu->addr_lu, cu, expr);
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, expr);
for EachNode(range_n, RDIM_Rng1U64Node, curr_scope->voff_ranges.first) {
rdim_push_location_case(arena, scopes, &locset, location, range_n->v);
rdim_push_location_case(arena, scopes, &locset, &location, range_n->v);
}
} else if (attrib_class != DW_AttribClass_Null) {
log_user_errorf("unexpected attrib class @ .debug_info+%llx", tag.info_off);
@@ -1388,7 +1383,6 @@ internal RDIM_LocationCaseList
d2r_var_locset_from_tag(Arena *arena,
RDIM_ScopeChunkList *scopes,
RDIM_Scope *curr_scope,
RDIM_LocationChunkList *locations,
DW_Input *input,
DW_CompUnit *cu,
U64 image_base,
@@ -1414,17 +1408,16 @@ d2r_var_locset_from_tag(Arena *arena,
rdim_bytecode_push_uconst(arena, &bc, const_value);
// fill out location
RDIM_LocationInfo *loc_info = push_array(arena, RDIM_LocationInfo, 1);
loc_info->kind = RDI_LocationKind_ValBytecodeStream;
loc_info->bytecode = bc;
RDIM_Location *loc = rdim_location_chunk_list_push_new(arena, locations, D2R_LOCATIONS_CAP, loc_info);
RDIM_Location loc = {0};
loc.kind = RDI_LocationKind_ValBytecodeStream;
loc.bytecode = bc;
// push location cases
for EachNode(range_n, RDIM_Rng1U64Node, curr_scope->voff_ranges.first) {
rdim_push_location_case(arena, scopes, &locset, loc, range_n->v);
rdim_push_location_case(arena, scopes, &locset, &loc, range_n->v);
}
} else if (has_location) {
locset = d2r_locset_from_attrib(arena, scopes, curr_scope, locations, input, cu, image_base, arch, tag, DW_AttribKind_Location);
locset = d2r_locset_from_attrib(arena, scopes, curr_scope, input, cu, image_base, arch, tag, DW_AttribKind_Location);
}
return locset;
@@ -2395,7 +2388,7 @@ d2r_convert_symbols(Arena *arena,
proc->container_scope = 0;
proc->container_type = container_type;
proc->root_scope = root_scope;
proc->location_cases = d2r_locset_from_attrib(arena, &g_d2r_shared.scopes, root_scope, &g_d2r_shared.locations, input, cu, image_base, arch, tag, DW_AttribKind_FrameBase);
proc->location_cases = d2r_locset_from_attrib(arena, &g_d2r_shared.scopes, root_scope, input, cu, image_base, arch, tag, DW_AttribKind_FrameBase);
// sub program with user-defined parent tag is a method
DW_Tag parent_tag = d2r_tag_iterator_parent_tag(it);
@@ -2479,7 +2472,7 @@ d2r_convert_symbols(Arena *arena,
local->kind = RDI_LocalKind_Variable;
local->name = name;
local->type = type;
local->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, &g_d2r_shared.locations, input, cu, image_base, arch, tag);
local->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, input, cu, image_base, arch, tag);
} else {
// NOTE: due to a bug in clang in stb_sprintf.h local variables
@@ -2540,7 +2533,7 @@ d2r_convert_symbols(Arena *arena,
param->kind = RDI_LocalKind_Parameter;
param->name = dw_string_from_tag_attrib_kind(input, cu, tag, DW_AttribKind_Name);
param->type = d2r_type_from_attrib(type_table, input, cu, tag, DW_AttribKind_Type);
param->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, &g_d2r_shared.locations, input, cu, image_base, arch, tag);
param->location_cases = d2r_var_locset_from_tag(arena, &g_d2r_shared.scopes, scope, input, cu, image_base, arch, tag);
} else {
Assert(!"this is a local variable");
log_user_errorf(".debug_info+%llx out of scope formal parameter", tag.info_off);
@@ -3118,7 +3111,6 @@ d2r_convert(Arena *arena, D2R_ConvertParams *params)
bake_params.udts = g_d2r_shared.udts;
bake_params.src_files = g_d2r_shared.src_files;
bake_params.line_tables = g_d2r_shared.line_tables;
bake_params.locations = g_d2r_shared.locations;
bake_params.global_variables = g_d2r_shared.gvars;
bake_params.thread_variables = g_d2r_shared.tvars;
bake_params.procedures = g_d2r_shared.procs;
+31 -32
View File
@@ -40,7 +40,6 @@ typedef struct D2R_Shared
RDIM_TypeChunkList types;
RDIM_SrcFileChunkList src_files;
RDIM_LineTableChunkList line_tables;
RDIM_LocationChunkList locations;
RDIM_SymbolChunkList gvars;
RDIM_SymbolChunkList tvars;
RDIM_SymbolChunkList procs;
@@ -60,39 +59,39 @@ typedef enum
} D2R_ArithmeticType;
#define D2R_ValueType_Signed_XList \
X(S8, Signed, 1 ) \
X(S16, Signed, 2 ) \
X(S32, Signed, 4 ) \
X(S64, Signed, 8 ) \
X(S128, Signed, 16) \
X(S256, Signed, 32) \
X(S512, Signed, 64)
X(S8, Signed, 1 ) \
X(S16, Signed, 2 ) \
X(S32, Signed, 4 ) \
X(S64, Signed, 8 ) \
X(S128, Signed, 16) \
X(S256, Signed, 32) \
X(S512, Signed, 64)
#define D2R_ValueType_Unsigned_XList \
X(U8, Unsigned, 1 ) \
X(U16, Unsigned, 2 ) \
X(U32, Unsigned, 4 ) \
X(U64, Unsigned, 8 ) \
X(U128, Unsigned, 16) \
X(U256, Unsigned, 32) \
X(U512, Unsigned, 64)
X(U8, Unsigned, 1 ) \
X(U16, Unsigned, 2 ) \
X(U32, Unsigned, 4 ) \
X(U64, Unsigned, 8 ) \
X(U128, Unsigned, 16) \
X(U256, Unsigned, 32) \
X(U512, Unsigned, 64)
#define D2R_ValueType_Float_XList \
X(F16, Float, 2 ) \
X(F32, Float, 4 ) \
X(F48, Float, 6 ) \
X(F64, Float, 8 ) \
X(F80, Float, 10) \
X(F96, Float, 12) \
X(F128, Float, 16)
X(F16, Float, 2 ) \
X(F32, Float, 4 ) \
X(F48, Float, 6 ) \
X(F64, Float, 8 ) \
X(F80, Float, 10) \
X(F96, Float, 12) \
X(F128, Float, 16)
#define D2R_ValueType_XList \
X(Generic, Null, 0 ) \
X(ImplicitValue, Null, 0 ) \
X(Address, Unsigned, 0 ) \
D2R_ValueType_Signed_XList \
D2R_ValueType_Unsigned_XList \
D2R_ValueType_Float_XList
X(Generic, Null, 0 ) \
X(ImplicitValue, Null, 0 ) \
X(Address, Unsigned, 0 ) \
D2R_ValueType_Signed_XList \
D2R_ValueType_Unsigned_XList \
D2R_ValueType_Float_XList
typedef enum
{
@@ -214,10 +213,10 @@ internal void d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *
//~ Expression Conversion
internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, String8 expr, DW_CompUnit *cu, D2R_ValueType *result_type_out);
internal RDIM_Location * d2r_transpile_expression (Arena *arena, RDIM_LocationChunkList *locations, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr);
internal RDIM_Location * d2r_location_from_attrib (Arena *arena, RDIM_LocationChunkList *locations, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
internal RDIM_LocationCaseList d2r_locset_from_attrib (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, RDIM_LocationChunkList *locations, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, RDIM_LocationChunkList *locations, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag);
internal RDIM_Location d2r_transpile_expression (Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr);
internal RDIM_Location d2r_location_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
internal RDIM_LocationCaseList d2r_locset_from_attrib (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag);
////////////////////////////////
//~ Type Table
+16 -39
View File
@@ -297,13 +297,13 @@ p2r_reg_code_from_arch_encoded_fp_reg(RDI_Arch arch, CV_EncodedFramePtrReg encod
}
}break;
}
return(result);
return result;
}
internal RDIM_LocationInfo
p2r_location_info_from_addr_reg_off(Arena *arena, RDI_Arch arch, RDI_RegCode reg_code, U32 reg_byte_size, U32 reg_byte_pos, S64 offset, B32 extra_indirection)
internal RDIM_Location
p2r_location_from_addr_reg_off(Arena *arena, RDI_Arch arch, RDI_RegCode reg_code, U32 reg_byte_size, U32 reg_byte_pos, S64 offset, B32 extra_indirection)
{
RDIM_LocationInfo result = {0};
RDIM_Location result = {0};
if(0 <= offset && offset <= (S64)max_U16)
{
if(extra_indirection)
@@ -3226,7 +3226,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//////////////////////////////////////////////////////////////
//- rjf: produce symbols from all streams
//
RDIM_LocationChunkList *syms_locations = 0;
RDIM_SymbolChunkList *syms_procedures = 0;
RDIM_SymbolChunkList *syms_global_variables = 0;
RDIM_SymbolChunkList *syms_thread_variables = 0;
@@ -3243,7 +3242,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//
if(lane_idx() == 0)
{
syms_locations = push_array(arena, RDIM_LocationChunkList, all_syms_count);
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);
@@ -3252,7 +3250,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
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_locations, 0);
lane_sync_u64(&syms_procedures, 0);
lane_sync_u64(&syms_global_variables, 0);
lane_sync_u64(&syms_thread_variables, 0);
@@ -3297,7 +3294,6 @@ 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_LocationChunkList *sym_locations = &syms_locations[sym_idx];
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];
@@ -3684,10 +3680,9 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
U32 byte_pos = 0;
// rjf: build location
RDIM_LocationInfo loc_info = p2r_location_info_from_addr_reg_off(arena, arch, reg_code, byte_size, byte_pos, (S64)(S32)var_off, extra_indirection_to_value);
RDIM_Location *loc2 = rdim_location_chunk_list_push_new(arena, sym_locations, sym_locations_chunk_cap, &loc_info);
RDIM_Location loc = p2r_location_from_addr_reg_off(arena, arch, reg_code, byte_size, byte_pos, (S64)(S32)var_off, extra_indirection_to_value);
RDIM_Rng1U64 voff_range = {0, max_U64};
rdim_local_push_location_case(arena, sym_scopes, local, loc2, voff_range);
rdim_local_push_location_case(arena, sym_scopes, local, &loc, voff_range);
}
}
@@ -3807,11 +3802,10 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
RDI_RegCode reg_code = p2r_rdi_reg_code_from_cv_reg_code(arch, cv_reg);
// rjf: build location
RDIM_LocationInfo loc_info = {RDI_LocationKind_ValReg, reg_code};
RDIM_Location *loc = rdim_location_chunk_list_push_new(arena, sym_locations, sym_locations_chunk_cap, &loc_info);
RDIM_Location loc = {RDI_LocationKind_ValReg, reg_code};
// rjf: emit locations over ranges
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, loc, range, range_section, gaps, gap_count);
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &loc, range, range_section, gaps, gap_count);
}break;
//- rjf: DEFRANGE_FRAMEPOINTER_REL
@@ -3854,11 +3848,10 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
U32 byte_size = rdi_addr_size_from_arch(arch);
U32 byte_pos = 0;
S64 var_off = (S64)defrange_fprel->off;
RDIM_LocationInfo location_info = p2r_location_info_from_addr_reg_off(arena, arch, fp_register_code, byte_size, byte_pos, var_off, extra_indirection);
RDIM_Location *location = rdim_location_chunk_list_push_new(arena, sym_locations, sym_locations_chunk_cap, &location_info);
RDIM_Location location = p2r_location_from_addr_reg_off(arena, arch, fp_register_code, byte_size, byte_pos, var_off, extra_indirection);
// rjf: emit locations over ranges
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, location, range, range_section, gaps, gap_count);
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &location, range, range_section, gaps, gap_count);
}break;
//- rjf: DEFRANGE_SUBFIELD_REGISTER
@@ -3887,11 +3880,10 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
}
// rjf: build location
RDIM_LocationInfo loc_info = {RDI_LocationKind_ValReg, reg_code};
RDIM_Location *loc = rdim_location_chunk_list_push_new(arena, sym_locations, sym_locations_chunk_cap, &loc_info);
RDIM_Location loc = {RDI_LocationKind_ValReg, reg_code};
// rjf: emit locations over ranges
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, loc, range, range_section, gaps, gap_count);
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &loc, range, range_section, gaps, gap_count);
}break;
//- rjf: DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE
@@ -3928,12 +3920,11 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
U32 byte_size = rdi_addr_size_from_arch(arch);
U32 byte_pos = 0;
S64 var_off = (S64)defrange_fprel_full_scope->off;
RDIM_LocationInfo loc_info = p2r_location_info_from_addr_reg_off(arena, arch, fp_register_code, byte_size, byte_pos, var_off, extra_indirection);
RDIM_Location *loc = rdim_location_chunk_list_push_new(arena, sym_locations, sym_locations_chunk_cap, &loc_info);
RDIM_Location loc = p2r_location_from_addr_reg_off(arena, arch, fp_register_code, byte_size, byte_pos, var_off, extra_indirection);
// rjf: emit location over ranges
RDIM_Rng1U64 voff_range = {0, max_U64};
rdim_local_push_location_case(arena, sym_scopes, defrange_target, loc, voff_range);
rdim_local_push_location_case(arena, sym_scopes, defrange_target, &loc, voff_range);
}break;
//- rjf: DEFRANGE_REGISTER_REL
@@ -3961,11 +3952,10 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
U32 byte_pos = 0;
B32 extra_indirection_to_value = 0;
S64 var_off = defrange_register_rel->reg_off;
RDIM_LocationInfo loc_info = p2r_location_info_from_addr_reg_off(arena, arch, reg_code, byte_size, byte_pos, var_off, extra_indirection_to_value);
RDIM_Location *loc = rdim_location_chunk_list_push_new(arena, sym_locations, sym_locations_chunk_cap, &loc_info);
RDIM_Location loc = p2r_location_from_addr_reg_off(arena, arch, reg_code, byte_size, byte_pos, var_off, extra_indirection_to_value);
// rjf: emit locations over ranges
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, loc, range, range_section, gaps, gap_count);
p2r_local_push_location_cases_over_lvar_addr_range(arena, sym_scopes, defrange_target, &loc, range, range_section, gaps, gap_count);
}break;
//- rjf: FILESTATIC
@@ -4159,7 +4149,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//////////////////////////////////////////////////////////////
//- rjf: join all lane symbols
//
RDIM_LocationChunkList all_locations = {0};
RDIM_SymbolChunkList all_procedures = {0};
RDIM_SymbolChunkList all_global_variables = {0};
RDIM_SymbolChunkList all_thread_variables = {0};
@@ -4168,7 +4157,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
RDIM_InlineSiteChunkList all_inline_sites = {0};
RDIM_TypeChunkList all_types = {0};
{
RDIM_LocationChunkList *all_locations_ptr = 0;
RDIM_SymbolChunkList *all_procedures_ptr = 0;
RDIM_SymbolChunkList *all_global_variables_ptr = 0;
RDIM_SymbolChunkList *all_thread_variables_ptr = 0;
@@ -4178,7 +4166,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
RDIM_TypeChunkList *all_types_ptr = 0;
if(lane_idx() == 0)
{
all_locations_ptr = push_array(scratch.arena, RDIM_LocationChunkList, 1);
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);
@@ -4187,7 +4174,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
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_locations_ptr, 0);
lane_sync_u64(&all_procedures_ptr, 0);
lane_sync_u64(&all_global_variables_ptr, 0);
lane_sync_u64(&all_thread_variables_ptr, 0);
@@ -4195,13 +4181,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
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(0)) ProfScope("join locations")
{
for EachIndex(idx, all_syms_count)
{
rdim_location_chunk_list_concat_in_place(all_locations_ptr, &syms_locations[idx]);
}
}
if(lane_idx() == lane_from_task_idx(1)) ProfScope("join procedures")
{
for EachIndex(idx, all_syms_count)
@@ -4253,7 +4232,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
*all_types_ptr = *all_types__pre_typedefs_ptr;
}
lane_sync();
all_locations = *all_locations_ptr;
all_procedures = *all_procedures_ptr;
all_global_variables = *all_global_variables_ptr;
all_thread_variables = *all_thread_variables_ptr;
@@ -4312,7 +4290,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.locations = all_locations;
result.global_variables = all_global_variables;
result.thread_variables = all_thread_variables;
result.constants = all_constants;
+1 -1
View File
@@ -111,7 +111,7 @@ internal RDI_ChecksumKind p2r_rdi_from_cv_c13_checksum_kind(CV_C13ChecksumKind k
//~ rjf: Location Info Building Helpers
internal RDI_RegCode p2r_reg_code_from_arch_encoded_fp_reg(RDI_Arch arch, CV_EncodedFramePtrReg encoded_reg);
internal RDIM_LocationInfo p2r_location_info_from_addr_reg_off(Arena *arena, RDI_Arch arch, RDI_RegCode reg_code, U32 reg_byte_size, U32 reg_byte_pos, S64 offset, B32 extra_indirection);
internal RDIM_Location p2r_location_from_addr_reg_off(Arena *arena, RDI_Arch arch, RDI_RegCode reg_code, U32 reg_byte_size, U32 reg_byte_pos, S64 offset, B32 extra_indirection);
internal void p2r_local_push_location_cases_over_lvar_addr_range(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Local *local, RDIM_Location *loc, CV_LvarAddrRange *range, COFF_SectionHeader *section, CV_LvarAddrGap *gaps, U64 gap_count);
////////////////////////////////
+28 -15
View File
@@ -2700,6 +2700,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake location blocks
//
#if 0 // TODO(rjf): @locpass
RDIM_LocationBlockBakeResult *baked_location_blocks = 0;
ProfScope("bake location blocks")
{
@@ -2762,10 +2763,12 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
}
}
}
#endif
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage bake locations
//- rjf: @rdim_bake_stage bake locations (OLD)
//
#if 0 // TODO(rjf): @locpass
RDIM_LocationBakeResult *baked_locations = 0;
ProfScope("bake locations")
{
@@ -2815,6 +2818,7 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
}
}
}
#endif
//////////////////////////////////////////////////////////////
//- rjf: @rdim_bake_stage compute layout for scope sub-lists (locals / voffs)
@@ -3426,10 +3430,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
{
lane_chunk_set_element_counts[slot_idx] += s->location_cases.count;
}
lane_chunk_constant_data_counts[slot_idx] += s->value_data.size;
for EachNode(case_n, RDIM_LocationCase, s->location_cases.first)
{
lane_chunk_bytecode_data_counts[slot_idx] += case_n->location->info.bytecode.encoded_size;
lane_chunk_constant_data_counts[slot_idx] += case_n->location.value_data.size;
lane_chunk_bytecode_data_counts[slot_idx] += case_n->location.bytecode.encoded_size;
}
}
chunk_idx += 1;
@@ -3586,38 +3590,45 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
RDI_Location *dst_loc = dst_loc_first;
for EachNode(c, RDIM_LocationCase, src->location_cases.first)
{
RDIM_Location *src_loc = c->location;
dst_loc[0] |= ((U64)src_loc->info.kind << RDI_Location_KindShift) & RDI_Location_KindMask;
switch(src_loc->info.kind)
RDIM_Location *src_loc = &c->location;
dst_loc[0] |= ((U64)src_loc->kind << RDI_Location_KindShift) & RDI_Location_KindMask;
switch(src_loc->kind)
{
default:{}break;
case RDI_LocationKind_AddrRegPlusU16:
case RDI_LocationKind_AddrAddrRegPlusU16:
{
dst_loc[0] |= ((U64)src_loc->info.reg_code << RDI_Location_RegCodeShift) & RDI_Location_RegCodeMask;
dst_loc[0] |= ((U64)src_loc->info.offset << RDI_Location_RegOffShift) & RDI_Location_RegOffMask;
dst_loc[0] |= ((U64)src_loc->reg_code << RDI_Location_RegCodeShift) & RDI_Location_RegCodeMask;
dst_loc[0] |= ((U64)src_loc->offset << RDI_Location_RegOffShift) & RDI_Location_RegOffMask;
}break;
case RDI_LocationKind_ValReg:
{
dst_loc[0] |= ((U64)src_loc->info.reg_code << RDI_Location_RegCodeShift) & RDI_Location_RegCodeMask;
dst_loc[0] |= ((U64)src_loc->reg_code << RDI_Location_RegCodeShift) & RDI_Location_RegCodeMask;
}break;
case RDI_LocationKind_AddrBytecodeStream:
case RDI_LocationKind_ValBytecodeStream:
{
dst_loc[0] |= ((U64)dst_bytecode_off << RDI_Location_OffShift) & RDI_Location_OffMask;
dst_bytecode_off += src_loc->info.bytecode.encoded_size;
// TODO(rjf): serialize bytecode
for EachNode(op_node, RDIM_EvalBytecodeOp, src_loc->bytecode.first_op)
{
MemoryCopy(loc_bytecode_data + dst_bytecode_off, &op_node->op, 1);
dst_bytecode_off += 1;
MemoryCopy(loc_bytecode_data + dst_bytecode_off, &op_node->p, op_node->p_size);
dst_bytecode_off += op_node->p_size;
}
loc_bytecode_data[dst_bytecode_off] = 0;
dst_bytecode_off += 1;
}break;
case RDI_LocationKind_ModuleOff:
case RDI_LocationKind_TLSOff:
{
dst_loc[0] |= ((U64)src_loc->info.offset << RDI_Location_OffShift) & RDI_Location_OffMask;
dst_loc[0] |= ((U64)src_loc->offset << RDI_Location_OffShift) & RDI_Location_OffMask;
}break;
case RDI_LocationKind_ConstantDataOff:
{
dst_loc[0] |= ((U64)src_loc->info.offset << RDI_Location_OffShift) & RDI_Location_OffMask;
// TODO(rjf): need to move constant data, currently called "value_data", into
// location cases, to make this case work...
dst_loc[0] |= ((U64)dst_constant_off << RDI_Location_OffShift) & RDI_Location_OffMask;
MemoryCopy(loc_constant_data + dst_constant_off, src_loc->value_data.str, src_loc->value_data.size);
dst_constant_off += src_loc->value_data.size;
}break;
}
if(c->next != 0)
@@ -3756,8 +3767,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
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
}
lane_sync();