mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-14 16:12:24 -07:00
pass over the make RDI library
- Handle type layout in the library so converts simply define type graph and let the library handle DAG layout. - Changed location baking. For now the library waits for scope, procs, global vars, and thread vars steps to serially finish because of common dependency on location sections, we need to parallel for each step. - Changed encoded offset size for RDI_EvalOp_FrameOff to 8 bytes (1 byte is not enough to cover all cases) - Added frame base location to RDI_Procedure (WASM encodes frame base as an index into a global array and so we have to resolve the base at runtime).
This commit is contained in:
@@ -101,7 +101,7 @@ RDI_EVAL_CTRLBITS(2, 0, 0),
|
||||
RDI_EVAL_CTRLBITS(1, 1, 1),
|
||||
RDI_EVAL_CTRLBITS(4, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(0, 1, 1),
|
||||
RDI_EVAL_CTRLBITS(1, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(8, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(4, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(4, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(0, 0, 0),
|
||||
|
||||
@@ -970,6 +970,8 @@ X(RDI_LinkFlags, link_flags)\
|
||||
X(RDI_U32, type_idx)\
|
||||
X(RDI_U32, root_scope_idx)\
|
||||
X(RDI_U32, container_idx)\
|
||||
X(RDI_U32, frame_base_location_first)\
|
||||
X(RDI_U32, frame_base_location_opl)\
|
||||
|
||||
#define RDI_Scope_XList \
|
||||
X(RDI_U32, proc_idx)\
|
||||
@@ -1397,6 +1399,8 @@ RDI_LinkFlags link_flags;
|
||||
RDI_U32 type_idx;
|
||||
RDI_U32 root_scope_idx;
|
||||
RDI_U32 container_idx;
|
||||
RDI_U32 frame_base_location_first;
|
||||
RDI_U32 frame_base_location_opl;
|
||||
};
|
||||
|
||||
typedef struct RDI_Scope RDI_Scope;
|
||||
|
||||
@@ -813,3 +813,25 @@ rdi_cstring_length(char *cstr)
|
||||
for(;cstr[result] != 0; result += 1){}
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdi_size_from_bytecode_stream(U8 *ptr, U8 *opl)
|
||||
{
|
||||
RDI_U64 bytecode_size = 0;
|
||||
RDI_U8 *off_first = ptr + sizeof(RDI_LocationKind);
|
||||
for(RDI_U8 *off = off_first, *next_off = opl; off < opl; off = next_off)
|
||||
{
|
||||
RDI_U8 op = *off;
|
||||
if(op == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
RDI_U16 ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
||||
RDI_U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
bytecode_size += (1 + p_size);
|
||||
next_off = (off + 1 + p_size);
|
||||
}
|
||||
return bytecode_size;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,5 +225,6 @@ RDI_PROC RDI_U8 *rdi_name_from_file_path_node(RDI_Parsed *rdi, RDI_FilePathNode
|
||||
|
||||
#define rdi_parse__min(a,b) (((a)<(b))?(a):(b))
|
||||
RDI_PROC RDI_U64 rdi_cstring_length(char *cstr);
|
||||
RDI_PROC RDI_U64 rdi_size_from_bytecode_stream(U8 *ptr, U8 *opl);
|
||||
|
||||
#endif // RDI_FORMAT_PARSE_H
|
||||
|
||||
+237
-139
@@ -705,6 +705,14 @@ rdim_idx_from_type(RDIM_Type *type)
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_final_idx_from_type(RDI_U64 *type_indices, RDIM_Type *type)
|
||||
{
|
||||
RDI_U64 pos = rdim_idx_from_type(type);
|
||||
RDI_U64 idx = type_indices[pos];
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_type_chunk_list_concat_in_place(RDIM_TypeChunkList *dst, RDIM_TypeChunkList *to_push)
|
||||
{
|
||||
@@ -1131,6 +1139,67 @@ rdim_location_set_push_case(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM
|
||||
scopes->location_count +=1;
|
||||
}
|
||||
|
||||
//- location block chunk list
|
||||
|
||||
RDI_PROC RDI_LocationBlock *
|
||||
rdim_location_block_chunk_list_push_array(RDIM_Arena *arena, RDIM_String8List *list, RDI_U32 count)
|
||||
{
|
||||
RDI_LocationBlock *result = rdim_push_array(arena, RDI_LocationBlock, count);
|
||||
RDIM_String8 string = rdim_str8((RDI_U8*)result, sizeof(result[0]) * count);
|
||||
rdim_str8_list_push(arena, list, string);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U32
|
||||
rdim_count_from_location_block_chunk_list(RDIM_String8List *list)
|
||||
{
|
||||
RDI_U32 count = list->total_size / sizeof(RDI_LocationBlock);
|
||||
return count;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
RDI_PROC void
|
||||
rdim_assign_type_index(RDIM_Type *type, U64 *type_indices, U64 *curr_type_idx)
|
||||
{
|
||||
RDI_U64 type_pos = rdim_idx_from_type(type);
|
||||
if(type_indices[type_pos] == 0)
|
||||
{
|
||||
if(type->param_types)
|
||||
{
|
||||
for(RDI_U64 param_idx = 0; param_idx < type->count; param_idx += 1)
|
||||
{
|
||||
rdim_assign_type_index(type->param_types[param_idx], type_indices, curr_type_idx);
|
||||
}
|
||||
}
|
||||
|
||||
if(type->direct_type)
|
||||
{
|
||||
rdim_assign_type_index(type->direct_type, type_indices, curr_type_idx);
|
||||
}
|
||||
|
||||
type_indices[type_pos] = *curr_type_idx;
|
||||
*curr_type_idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64 *
|
||||
rdim_make_type_indices(RDIM_Arena *arena, RDIM_TypeChunkList *types)
|
||||
{
|
||||
RDI_U64 *type_indices = rdim_push_array(arena, RDI_U64, types->total_count + 1);
|
||||
RDI_U64 type_indices_count = 1;
|
||||
|
||||
for(RDIM_TypeChunkNode *chunk = types->first; chunk != 0; chunk = chunk->next)
|
||||
{
|
||||
for(RDI_U64 i = 0; i < chunk->count; i += 1)
|
||||
{
|
||||
rdim_assign_type_index(&chunk->v[i], type_indices, &type_indices_count);
|
||||
}
|
||||
}
|
||||
|
||||
return type_indices;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked VMap Building
|
||||
|
||||
@@ -2070,7 +2139,7 @@ rdim_bake_string_map_loose_push_scopes(RDIM_Arena *arena, RDIM_BakeStringMapTopo
|
||||
//- rjf: bake name map building
|
||||
|
||||
RDI_PROC RDIM_BakeNameMap *
|
||||
rdim_bake_name_map_from_kind_params(RDIM_Arena *arena, RDI_NameMapKind kind, RDIM_BakeParams *params)
|
||||
rdim_bake_name_map_from_kind_params(RDIM_Arena *arena, RDI_NameMapKind kind, RDI_U64 *type_indices, RDIM_BakeParams *params)
|
||||
{
|
||||
RDIM_BakeNameMap *map = rdim_push_array(arena, RDIM_BakeNameMap, 1);
|
||||
switch(kind)
|
||||
@@ -2123,7 +2192,7 @@ rdim_bake_name_map_from_kind_params(RDIM_Arena *arena, RDI_NameMapKind kind, RDI
|
||||
{
|
||||
for(RDI_U64 idx = 0; idx < n->count; idx += 1)
|
||||
{
|
||||
RDI_U32 type_idx = (RDI_U32)rdim_idx_from_type(&n->v[idx]); // TODO(rjf): @u64_to_u32
|
||||
RDI_U32 type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, &n->v[idx]); // TODO(rjf): @u64_to_u32
|
||||
rdim_bake_name_map_push(arena, map, n->v[idx].name, type_idx);
|
||||
}
|
||||
}
|
||||
@@ -2162,7 +2231,7 @@ rdim_bake_name_map_from_kind_params(RDIM_Arena *arena, RDI_NameMapKind kind, RDI
|
||||
//- rjf: idx run map building
|
||||
|
||||
RDI_PROC RDIM_BakeIdxRunMap *
|
||||
rdim_bake_idx_run_map_from_params(RDIM_Arena *arena, RDIM_BakeNameMap *name_maps[RDI_NameMapKind_COUNT], RDIM_BakeParams *params)
|
||||
rdim_bake_idx_run_map_from_params(RDIM_Arena *arena, RDIM_BakeNameMap *name_maps[RDI_NameMapKind_COUNT], RDI_U64 *type_indices, RDIM_BakeParams *params)
|
||||
{
|
||||
//- rjf: set up map
|
||||
RDIM_BakeIdxRunMap *idx_runs = rdim_push_array(arena, RDIM_BakeIdxRunMap, 1);
|
||||
@@ -2182,7 +2251,7 @@ rdim_bake_idx_run_map_from_params(RDIM_Arena *arena, RDIM_BakeNameMap *name_maps
|
||||
RDI_U32 *param_idx_run = rdim_push_array_no_zero(arena, RDI_U32, param_idx_run_count);
|
||||
for(RDI_U32 idx = 0; idx < param_idx_run_count; idx += 1)
|
||||
{
|
||||
param_idx_run[idx] = (RDI_U32)rdim_idx_from_type(type->param_types[idx]); // TODO(rjf): @u64_to_u32
|
||||
param_idx_run[idx] = (RDI_U32)rdim_final_idx_from_type(type_indices, type->param_types[idx]); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
rdim_bake_idx_run_map_insert(arena, idx_runs, param_idx_run, param_idx_run_count);
|
||||
}
|
||||
@@ -2958,16 +3027,16 @@ rdim_bake_line_tables(RDIM_Arena *arena, RDIM_LineTableChunkList *src)
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_TypeNodeBakeResult
|
||||
rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeIdxRunMap *idx_runs, RDIM_TypeChunkList *src)
|
||||
rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeIdxRunMap *idx_runs, RDI_U64 *type_indices, RDIM_TypeChunkList *src)
|
||||
{
|
||||
RDI_TypeNode *type_nodes = push_array(arena, RDI_TypeNode, src->total_count+1);
|
||||
RDI_U32 dst_idx = 1;
|
||||
for(RDIM_TypeChunkNode *n = src->first; n != 0; n = n->next)
|
||||
{
|
||||
for(RDI_U64 chunk_idx = 0; chunk_idx < n->count; chunk_idx += 1, dst_idx += 1)
|
||||
for(RDI_U64 chunk_idx = 0; chunk_idx < n->count; chunk_idx += 1)
|
||||
{
|
||||
RDIM_Type *src = &n->v[chunk_idx];
|
||||
RDI_TypeNode *dst = &type_nodes[dst_idx];
|
||||
RDIM_Type *src = &n->v[chunk_idx];
|
||||
U64 dst_idx = rdim_final_idx_from_type(type_indices, src);
|
||||
RDI_TypeNode *dst = &type_nodes[dst_idx];
|
||||
|
||||
//- rjf: fill shared type node info
|
||||
dst->kind = src->kind;
|
||||
@@ -2980,10 +3049,21 @@ rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeId
|
||||
dst->built_in.name_string_idx = rdim_bake_idx_from_string(strings, src->name);
|
||||
}
|
||||
|
||||
else if(dst->kind == RDI_TypeKind_Array)
|
||||
{
|
||||
U64 direct_byte_size = 1;
|
||||
if(src->direct_type && src->direct_type->byte_size > 0)
|
||||
{
|
||||
direct_byte_size = src->direct_type->byte_size;
|
||||
}
|
||||
dst->constructed.direct_type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->direct_type);
|
||||
dst->constructed.count = src->byte_size / direct_byte_size;
|
||||
}
|
||||
|
||||
//- rjf: fill constructed type node info
|
||||
else if(RDI_TypeKind_FirstConstructed <= dst->kind && dst->kind <= RDI_TypeKind_LastConstructed)
|
||||
{
|
||||
dst->constructed.direct_type_idx = (RDI_U32)rdim_idx_from_type(src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
dst->constructed.direct_type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
dst->constructed.count = src->count;
|
||||
if(dst->kind == RDI_TypeKind_Function || dst->kind == RDI_TypeKind_Method)
|
||||
{
|
||||
@@ -2991,7 +3071,7 @@ rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeId
|
||||
RDI_U32 *param_idx_run = rdim_push_array_no_zero(arena, RDI_U32, param_idx_run_count);
|
||||
for(RDI_U32 idx = 0; idx < param_idx_run_count; idx += 1)
|
||||
{
|
||||
param_idx_run[idx] = (RDI_U32)rdim_idx_from_type(src->param_types[idx]); // TODO(rjf): @u64_to_u32
|
||||
param_idx_run[idx] = (RDI_U32)rdim_final_idx_from_type(type_indices, src->param_types[idx]); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
dst->constructed.param_idx_run_first = rdim_bake_idx_from_idx_run(idx_runs, param_idx_run, param_idx_run_count);
|
||||
}
|
||||
@@ -3006,13 +3086,13 @@ rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeId
|
||||
{
|
||||
dst->user_defined.name_string_idx = rdim_bake_idx_from_string(strings, src->name);
|
||||
dst->user_defined.udt_idx = (RDI_U32)rdim_idx_from_udt(src->udt); // TODO(rjf): @u64_to_u32
|
||||
dst->user_defined.direct_type_idx = (RDI_U32)rdim_idx_from_type(src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
dst->user_defined.direct_type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
|
||||
//- rjf: fill bitfield info
|
||||
else if(dst->kind == RDI_TypeKind_Bitfield)
|
||||
{
|
||||
dst->bitfield.direct_type_idx = (RDI_U32)rdim_idx_from_type(src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
dst->bitfield.direct_type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->direct_type); // TODO(rjf): @u64_to_u32
|
||||
dst->bitfield.off = src->off;
|
||||
dst->bitfield.size = src->count;
|
||||
}
|
||||
@@ -3025,7 +3105,7 @@ rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeId
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_UDTBakeResult
|
||||
rdim_bake_udts(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_UDTChunkList *src)
|
||||
rdim_bake_udts(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, RDIM_UDTChunkList *src)
|
||||
{
|
||||
//- rjf: build tables
|
||||
RDI_UDT * udts = push_array(arena, RDI_UDT, src->total_count+1);
|
||||
@@ -3043,7 +3123,7 @@ rdim_bake_udts(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_UDTChun
|
||||
RDI_UDT *dst_udt = &udts[dst_udt_idx];
|
||||
|
||||
//- rjf: fill basics
|
||||
dst_udt->self_type_idx = (RDI_U32)rdim_idx_from_type(src_udt->self_type); // TODO(rjf): @u64_to_u32
|
||||
dst_udt->self_type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src_udt->self_type); // TODO(rjf): @u64_to_u32
|
||||
dst_udt->file_idx = (RDI_U32)rdim_idx_from_src_file(src_udt->src_file); // TODO(rjf): @u64_to_u32
|
||||
dst_udt->line = src_udt->line;
|
||||
dst_udt->col = src_udt->col;
|
||||
@@ -3060,7 +3140,7 @@ rdim_bake_udts(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_UDTChun
|
||||
RDI_Member *dst_member = &members[dst_member_idx];
|
||||
dst_member->kind = src_member->kind;
|
||||
dst_member->name_string_idx = rdim_bake_idx_from_string(strings, src_member->name);
|
||||
dst_member->type_idx = (RDI_U32)rdim_idx_from_type(src_member->type); // TODO(rjf): @u64_to_u32
|
||||
dst_member->type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src_member->type); // TODO(rjf): @u64_to_u32
|
||||
dst_member->off = src_member->off;
|
||||
}
|
||||
}
|
||||
@@ -3098,7 +3178,7 @@ rdim_bake_udts(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_UDTChun
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_GlobalVariableBakeResult
|
||||
rdim_bake_global_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src)
|
||||
rdim_bake_global_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, RDIM_SymbolChunkList *src)
|
||||
{
|
||||
RDI_GlobalVariable *global_variables = push_array(arena, RDI_GlobalVariable, src->total_count+1);
|
||||
RDI_U32 dst_idx = 1;
|
||||
@@ -3110,7 +3190,7 @@ rdim_bake_global_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings,
|
||||
RDI_GlobalVariable *dst = &global_variables[dst_idx];
|
||||
dst->name_string_idx = rdim_bake_idx_from_string(strings, src->name);
|
||||
dst->voff = src->offset;
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
|
||||
dst->type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->type); // TODO(rjf): @u64_to_u32
|
||||
if(src->is_extern)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_External;
|
||||
@@ -3211,7 +3291,7 @@ 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)
|
||||
rdim_bake_thread_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, RDIM_SymbolChunkList *src)
|
||||
{
|
||||
RDI_ThreadVariable *thread_variables = push_array(arena, RDI_ThreadVariable, src->total_count+1);
|
||||
RDI_U32 dst_idx = 1;
|
||||
@@ -3223,7 +3303,7 @@ rdim_bake_thread_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings,
|
||||
RDI_ThreadVariable *dst = &thread_variables[dst_idx];
|
||||
dst->name_string_idx = rdim_bake_idx_from_string(strings, src->name);
|
||||
dst->tls_off = (RDI_U32)src->offset; // TODO(rjf): @u64_to_u32
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type);
|
||||
dst->type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->type);
|
||||
if(src->is_extern)
|
||||
{
|
||||
dst->link_flags |= RDI_LinkFlag_External;
|
||||
@@ -3246,8 +3326,104 @@ rdim_bake_thread_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings,
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC U64
|
||||
rdim_bake_location(Arena *arena, RDIM_String8List *location_data_blobs, RDIM_Location *src_location)
|
||||
{
|
||||
U64 location_data_off = location_data_blobs->total_size;
|
||||
|
||||
// rjf: nil location
|
||||
if(src_location == 0)
|
||||
{
|
||||
rdim_str8_list_push_align(arena, location_data_blobs, 8);
|
||||
rdim_str8_list_push(arena, location_data_blobs, rdim_str8_lit("\0"));
|
||||
}
|
||||
|
||||
// rjf: valid location
|
||||
else switch(src_location->kind)
|
||||
{
|
||||
// rjf: catchall unsupported case
|
||||
default:
|
||||
{
|
||||
rdim_str8_list_push_align(arena, location_data_blobs, 8);
|
||||
rdim_str8_list_push(arena, location_data_blobs, rdim_str8_lit("\0"));
|
||||
}break;
|
||||
|
||||
// rjf: bytecode streams
|
||||
case RDI_LocationKind_AddrBytecodeStream:
|
||||
case RDI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
rdim_str8_list_push(arena, location_data_blobs, rdim_str8_copy(arena, rdim_str8_struct(&src_location->kind)));
|
||||
for(RDIM_EvalBytecodeOp *op_node = src_location->bytecode.first_op;
|
||||
op_node != 0;
|
||||
op_node = op_node->next)
|
||||
{
|
||||
RDI_U8 op_data[9];
|
||||
op_data[0] = op_node->op;
|
||||
rdim_memcpy(op_data + 1, &op_node->p, op_node->p_size);
|
||||
RDIM_String8 op_data_str = rdim_str8(op_data, 1 + op_node->p_size);
|
||||
rdim_str8_list_push(arena, location_data_blobs, rdim_str8_copy(arena, op_data_str));
|
||||
}
|
||||
{
|
||||
RDI_U64 data = 0;
|
||||
RDIM_String8 data_str = rdim_str8((RDI_U8 *)&data, 1);
|
||||
rdim_str8_list_push(arena, location_data_blobs, rdim_str8_copy(arena, data_str));
|
||||
}
|
||||
}break;
|
||||
|
||||
// rjf: simple addr+off cases
|
||||
case RDI_LocationKind_AddrRegPlusU16:
|
||||
case RDI_LocationKind_AddrAddrRegPlusU16:
|
||||
{
|
||||
RDI_LocationRegPlusU16 loc = {0};
|
||||
loc.kind = src_location->kind;
|
||||
loc.reg_code = src_location->reg_code;
|
||||
loc.offset = src_location->offset;
|
||||
rdim_str8_list_push(arena, location_data_blobs, rdim_str8_copy(arena, rdim_str8_struct(&loc)));
|
||||
}break;
|
||||
|
||||
// rjf: register cases
|
||||
case RDI_LocationKind_ValReg:
|
||||
{
|
||||
RDI_LocationReg loc = {0};
|
||||
loc.kind = src_location->kind;
|
||||
loc.reg_code = src_location->reg_code;
|
||||
rdim_str8_list_push(arena, location_data_blobs, rdim_str8_copy(arena, rdim_str8_struct(&loc)));
|
||||
}break;
|
||||
}
|
||||
|
||||
return location_data_off;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U32
|
||||
rdim_bake_locset(RDIM_Arena *arena,
|
||||
RDIM_String8List *location_blocks,
|
||||
RDIM_String8List *location_data_blobs,
|
||||
RDIM_LocationSet locset)
|
||||
{
|
||||
RDI_U32 locset_idx = 0;
|
||||
if(locset.location_case_count > 0)
|
||||
{
|
||||
locset_idx = rdim_count_from_location_block_chunk_list(location_blocks);
|
||||
|
||||
RDI_LocationBlock *dst_arr = rdim_location_block_chunk_list_push_array(arena, location_blocks, locset.location_case_count);
|
||||
RDI_LocationBlock *dst = dst_arr;
|
||||
for(RDIM_LocationCase *src = locset.first_location_case; src != 0; src = src->next, ++dst)
|
||||
{
|
||||
dst->scope_off_first = src->voff_range.min;
|
||||
dst->scope_off_opl = src->voff_range.max;
|
||||
dst->location_data_off = rdim_bake_location(arena, location_data_blobs, src->location);
|
||||
}
|
||||
}
|
||||
return locset_idx;
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_ProcedureBakeResult
|
||||
rdim_bake_procedures(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src)
|
||||
rdim_bake_procedures(RDIM_Arena *arena,
|
||||
RDIM_BakeStringMapTight *strings,
|
||||
RDI_U64 *type_indices,
|
||||
RDIM_String8List *location_blocks,
|
||||
RDIM_String8List *location_data_blobs,
|
||||
RDIM_SymbolChunkList *src)
|
||||
{
|
||||
RDI_Procedure *procedures = push_array(arena, RDI_Procedure, src->total_count+1);
|
||||
RDI_U32 dst_idx = 1;
|
||||
@@ -3255,8 +3431,12 @@ rdim_bake_procedures(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_S
|
||||
{
|
||||
for(RDI_U64 chunk_idx = 0; chunk_idx < n->count; chunk_idx += 1, dst_idx += 1)
|
||||
{
|
||||
RDIM_Symbol *src = &n->v[chunk_idx];
|
||||
RDIM_Symbol *src = &n->v[chunk_idx];
|
||||
RDI_Procedure *dst = &procedures[dst_idx];
|
||||
|
||||
RDI_U32 frame_base_location_first = rdim_bake_locset(arena, location_blocks, location_data_blobs, src->frame_base);
|
||||
RDI_U32 frame_base_location_opl = frame_base_location_first + src->frame_base.location_case_count;
|
||||
|
||||
dst->name_string_idx = rdim_bake_idx_from_string(strings, src->name);
|
||||
dst->link_name_string_idx = rdim_bake_idx_from_string(strings, src->link_name);
|
||||
if(src->is_extern)
|
||||
@@ -3273,8 +3453,10 @@ rdim_bake_procedures(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_S
|
||||
dst->link_flags |= RDI_LinkFlag_ProcScoped;
|
||||
dst->container_idx = (RDI_U32)rdim_idx_from_symbol(src->container_symbol); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
dst->type_idx = (RDI_U32)rdim_idx_from_type(src->type); // TODO(rjf): @u64_to_u32
|
||||
dst->root_scope_idx = (RDI_U32)rdim_idx_from_scope(src->root_scope); // TODO(rjf): @u64_to_u32
|
||||
dst->type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->type); // TODO(rjf): @u64_to_u32
|
||||
dst->root_scope_idx = (RDI_U32)rdim_idx_from_scope(src->root_scope); // TODO(rjf): @u64_to_u32
|
||||
dst->frame_base_location_first = frame_base_location_first;
|
||||
dst->frame_base_location_opl = frame_base_location_opl;
|
||||
}
|
||||
}
|
||||
RDIM_ProcedureBakeResult result = {0};
|
||||
@@ -3284,30 +3466,33 @@ rdim_bake_procedures(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_S
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_ScopeBakeResult
|
||||
rdim_bake_scopes(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_ScopeChunkList *src)
|
||||
rdim_bake_scopes(RDIM_Arena *arena,
|
||||
RDIM_BakeStringMapTight *strings,
|
||||
RDI_U64 *type_indices,
|
||||
RDIM_String8List *location_blocks,
|
||||
RDIM_String8List *location_data_blobs,
|
||||
RDIM_ScopeChunkList *src)
|
||||
{
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: build all scopes, scope voffs, locals, and location blocks
|
||||
//
|
||||
RDI_Scope * scopes = rdim_push_array(arena, RDI_Scope, src->total_count+1);
|
||||
RDI_U64 * scope_voffs = rdim_push_array(arena, RDI_U64, src->scope_voff_count+1);
|
||||
RDI_Local * locals = rdim_push_array(arena, RDI_Local, src->local_count+1);
|
||||
RDI_LocationBlock * location_blocks = rdim_push_array(arena, RDI_LocationBlock, src->location_count+1);
|
||||
RDIM_String8List location_data_blobs = {0};
|
||||
RDI_Scope *scopes = rdim_push_array(arena, RDI_Scope, src->total_count+1);
|
||||
RDI_U64 *scope_voffs = rdim_push_array(arena, RDI_U64, src->scope_voff_count+1);
|
||||
RDI_Local *locals = rdim_push_array(arena, RDI_Local, src->local_count+1);
|
||||
|
||||
RDIM_ProfScope("build all scopes, scope voffs, locals, and location blocks")
|
||||
{
|
||||
RDI_U64 dst_scope_idx = 1;
|
||||
RDI_U64 dst_scope_idx = 1;
|
||||
RDI_U64 dst_scope_voff_idx = 1;
|
||||
RDI_U64 dst_local_idx = 1;
|
||||
RDI_U64 dst_location_block_idx = 1;
|
||||
RDI_U64 dst_local_idx = 1;
|
||||
for(RDIM_ScopeChunkNode *chunk_n = src->first; chunk_n != 0; chunk_n = chunk_n->next)
|
||||
{
|
||||
for(RDI_U64 chunk_idx = 0; chunk_idx < chunk_n->count; chunk_idx += 1, dst_scope_idx += 1)
|
||||
{
|
||||
RDIM_Scope *src_scope = &chunk_n->v[chunk_idx];
|
||||
RDI_Scope *dst_scope = &scopes[dst_scope_idx];
|
||||
RDI_Scope *dst_scope = &scopes[dst_scope_idx];
|
||||
|
||||
//- rjf: push scope's voffs
|
||||
RDI_U64 voff_idx_first = dst_scope_voff_idx;
|
||||
@@ -3328,91 +3513,17 @@ rdim_bake_scopes(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_Scope
|
||||
src_local != 0;
|
||||
src_local = src_local->next, dst_local_idx += 1)
|
||||
{
|
||||
//- rjf: push local's locations
|
||||
RDI_U64 location_block_idx_first = dst_location_block_idx;
|
||||
for(RDIM_LocationCase *loccase = src_local->locset.first_location_case;
|
||||
loccase != 0;
|
||||
loccase = loccase->next, dst_location_block_idx += 1)
|
||||
{
|
||||
// rjf: fill location block
|
||||
RDI_LocationBlock *dst_locblock = &location_blocks[dst_location_block_idx];
|
||||
dst_locblock->scope_off_first = loccase->voff_range.min;
|
||||
dst_locblock->scope_off_opl = loccase->voff_range.max;
|
||||
dst_locblock->location_data_off = location_data_blobs.total_size;
|
||||
|
||||
// rjf: serialize location into location data
|
||||
RDIM_Location *src_location = loccase->location;
|
||||
{
|
||||
// rjf: nil location
|
||||
if(src_location == 0)
|
||||
{
|
||||
rdim_str8_list_push_align(scratch.arena, &location_data_blobs, 8);
|
||||
rdim_str8_list_push(scratch.arena, &location_data_blobs, rdim_str8_lit("\0"));
|
||||
}
|
||||
|
||||
// rjf: valid location
|
||||
else switch(src_location->kind)
|
||||
{
|
||||
// rjf: catchall unsupported case
|
||||
default:
|
||||
{
|
||||
rdim_str8_list_push_align(scratch.arena, &location_data_blobs, 8);
|
||||
rdim_str8_list_push(scratch.arena, &location_data_blobs, rdim_str8_lit("\0"));
|
||||
}break;
|
||||
|
||||
// rjf: bytecode streams
|
||||
case RDI_LocationKind_AddrBytecodeStream:
|
||||
case RDI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
rdim_str8_list_push(scratch.arena, &location_data_blobs, rdim_str8_copy(scratch.arena, rdim_str8_struct(&src_location->kind)));
|
||||
for(RDIM_EvalBytecodeOp *op_node = src_location->bytecode.first_op;
|
||||
op_node != 0;
|
||||
op_node = op_node->next)
|
||||
{
|
||||
RDI_U8 op_data[9];
|
||||
op_data[0] = op_node->op;
|
||||
rdim_memcpy(op_data + 1, &op_node->p, op_node->p_size);
|
||||
RDIM_String8 op_data_str = rdim_str8(op_data, 1 + op_node->p_size);
|
||||
rdim_str8_list_push(scratch.arena, &location_data_blobs, rdim_str8_copy(scratch.arena, op_data_str));
|
||||
}
|
||||
{
|
||||
RDI_U64 data = 0;
|
||||
RDIM_String8 data_str = rdim_str8((RDI_U8 *)&data, 1);
|
||||
rdim_str8_list_push(scratch.arena, &location_data_blobs, rdim_str8_copy(scratch.arena, data_str));
|
||||
}
|
||||
}break;
|
||||
|
||||
// rjf: simple addr+off cases
|
||||
case RDI_LocationKind_AddrRegPlusU16:
|
||||
case RDI_LocationKind_AddrAddrRegPlusU16:
|
||||
{
|
||||
RDI_LocationRegPlusU16 loc = {0};
|
||||
loc.kind = src_location->kind;
|
||||
loc.reg_code = src_location->reg_code;
|
||||
loc.offset = src_location->offset;
|
||||
rdim_str8_list_push(scratch.arena, &location_data_blobs, rdim_str8_copy(scratch.arena, rdim_str8_struct(&loc)));
|
||||
}break;
|
||||
|
||||
// rjf: register cases
|
||||
case RDI_LocationKind_ValReg:
|
||||
{
|
||||
RDI_LocationReg loc = {0};
|
||||
loc.kind = src_location->kind;
|
||||
loc.reg_code = src_location->reg_code;
|
||||
rdim_str8_list_push(scratch.arena, &location_data_blobs, rdim_str8_copy(scratch.arena, rdim_str8_struct(&loc)));
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
RDI_U64 location_block_idx_opl = dst_location_block_idx;
|
||||
// bake location sets
|
||||
RDI_U32 location_block_idx_first = rdim_bake_locset(arena, location_blocks, location_data_blobs, src_local->locset);
|
||||
RDI_U32 location_block_idx_opl = location_block_idx_first + src_local->locset.location_case_count;
|
||||
|
||||
//- rjf: fill local
|
||||
RDI_Local *dst_local = &locals[dst_local_idx];
|
||||
RDI_Local *dst_local = &locals[dst_local_idx];
|
||||
dst_local->kind = src_local->kind;
|
||||
dst_local->name_string_idx = rdim_bake_idx_from_string(strings, src_local->name);
|
||||
dst_local->type_idx = (RDI_U32)rdim_idx_from_type(src_local->type); // TODO(rjf): @u64_to_u32
|
||||
dst_local->location_first = (RDI_U32)location_block_idx_first; // TODO(rjf): @u64_to_u32
|
||||
dst_local->location_opl = (RDI_U32)location_block_idx_opl; // TODO(rjf): @u64_to_u32
|
||||
dst_local->type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src_local->type); // TODO(rjf): @u64_to_u32
|
||||
dst_local->location_first = location_block_idx_first;
|
||||
dst_local->location_opl = location_block_idx_opl;
|
||||
}
|
||||
RDI_U64 local_idx_opl = dst_local_idx;
|
||||
|
||||
@@ -3430,29 +3541,16 @@ rdim_bake_scopes(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_Scope
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: build flattened location data
|
||||
//
|
||||
RDIM_String8 location_data_blob = {0};
|
||||
RDIM_ProfScope("build flattened location data")
|
||||
{
|
||||
location_data_blob = rdim_str8_list_join(arena, &location_data_blobs, rdim_str8_lit(""));
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: fill result
|
||||
//
|
||||
RDIM_ScopeBakeResult result = {0};
|
||||
result.scopes = scopes;
|
||||
result.scopes_count = src->total_count+1;
|
||||
result.scope_voffs = scope_voffs;
|
||||
result.scope_voffs_count = src->scope_voff_count+1;
|
||||
result.locals = locals;
|
||||
result.locals_count = src->local_count+1;
|
||||
result.location_blocks = location_blocks;
|
||||
result.location_blocks_count = src->location_count+1;
|
||||
result.location_data = location_data_blob.str;
|
||||
result.location_data_size = location_data_blob.size;
|
||||
result.scopes = scopes;
|
||||
result.scopes_count = src->total_count+1;
|
||||
result.scope_voffs = scope_voffs;
|
||||
result.scope_voffs_count = src->scope_voff_count+1;
|
||||
result.locals = locals;
|
||||
result.locals_count = src->local_count+1;
|
||||
rdim_scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
@@ -3508,7 +3606,7 @@ rdim_bake_scope_vmap(RDIM_Arena *arena, RDIM_ScopeChunkList *src)
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_InlineSiteBakeResult
|
||||
rdim_bake_inline_sites(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_InlineSiteChunkList *src)
|
||||
rdim_bake_inline_sites(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, RDIM_InlineSiteChunkList *src)
|
||||
{
|
||||
RDIM_InlineSiteBakeResult result = {0};
|
||||
{
|
||||
@@ -3522,8 +3620,8 @@ rdim_bake_inline_sites(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM
|
||||
RDI_InlineSite *dst = &result.inline_sites[dst_idx];
|
||||
RDIM_InlineSite *src = &n->v[chunk_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->owner_type_idx = (RDI_U32)rdim_idx_from_type(src->owner); // TODO(rjf): @u64_to_u32
|
||||
dst->type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->type); // TODO(rjf): @u64_to_u32
|
||||
dst->owner_type_idx = (RDI_U32)rdim_final_idx_from_type(type_indices, src->owner); // TODO(rjf): @u64_to_u32
|
||||
dst->line_table_idx = (RDI_U32)rdim_idx_from_line_table(src->line_table); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
@@ -3709,8 +3807,8 @@ rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results)
|
||||
bundle.sections[RDI_SectionKind_ScopeVMap] = rdim_serialized_section_make_unpacked_array(results->scope_vmap.vmap.vmap, results->scope_vmap.vmap.count+1);
|
||||
bundle.sections[RDI_SectionKind_InlineSites] = rdim_serialized_section_make_unpacked_array(results->inline_sites.inline_sites, results->inline_sites.inline_sites_count);
|
||||
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->scopes.location_blocks, results->scopes.location_blocks_count);
|
||||
bundle.sections[RDI_SectionKind_LocationData] = rdim_serialized_section_make_unpacked_array(results->scopes.location_data, results->scopes.location_data_size);
|
||||
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_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);
|
||||
|
||||
+24
-13
@@ -773,6 +773,7 @@ struct RDIM_Symbol
|
||||
RDIM_Symbol *container_symbol;
|
||||
RDIM_Type *container_type;
|
||||
struct RDIM_Scope *root_scope;
|
||||
RDIM_LocationSet frame_base;
|
||||
};
|
||||
|
||||
typedef struct RDIM_SymbolChunkNode RDIM_SymbolChunkNode;
|
||||
@@ -1195,10 +1196,6 @@ struct RDIM_ScopeBakeResult
|
||||
RDI_U64 scope_voffs_count;
|
||||
RDI_Local *locals;
|
||||
RDI_U64 locals_count;
|
||||
RDI_LocationBlock *location_blocks;
|
||||
RDI_U64 location_blocks_count;
|
||||
RDI_U8 *location_data;
|
||||
RDI_U64 location_data_size;
|
||||
};
|
||||
|
||||
typedef struct RDIM_ScopeVMapBakeResult RDIM_ScopeVMapBakeResult;
|
||||
@@ -1276,6 +1273,8 @@ struct RDIM_BakeResults
|
||||
RDIM_FilePathBakeResult file_paths;
|
||||
RDIM_StringBakeResult strings;
|
||||
RDIM_IndexRunBakeResult idx_runs;
|
||||
RDIM_String8 location_blocks;
|
||||
RDIM_String8 location_data;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -1382,6 +1381,7 @@ RDI_PROC void rdim_unit_chunk_list_concat_in_place(RDIM_UnitChunkList *dst, RDIM
|
||||
|
||||
RDI_PROC RDIM_Type *rdim_type_chunk_list_push(RDIM_Arena *arena, RDIM_TypeChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC RDI_U64 rdim_idx_from_type(RDIM_Type *type);
|
||||
RDI_PROC RDI_U64 rdim_final_idx_from_type(RDI_U64 *type_indices, RDIM_Type *type);
|
||||
RDI_PROC void rdim_type_chunk_list_concat_in_place(RDIM_TypeChunkList *dst, RDIM_TypeChunkList *to_push);
|
||||
RDI_PROC RDIM_UDT *rdim_udt_chunk_list_push(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC RDI_U64 rdim_idx_from_udt(RDIM_UDT *udt);
|
||||
@@ -1429,6 +1429,17 @@ RDI_PROC RDIM_Location *rdim_push_location_val_reg(RDIM_Arena *arena, RDI_U8 reg
|
||||
//- rjf: location sets
|
||||
RDI_PROC void rdim_location_set_push_case(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_LocationSet *locset, RDIM_Rng1U64 voff_range, RDIM_Location *location);
|
||||
|
||||
//- location block chunk list
|
||||
|
||||
RDI_PROC RDI_LocationBlock * rdim_location_block_chunk_list_push_array(RDIM_Arena *arena, RDIM_String8List *list, RDI_U32 count);
|
||||
RDI_PROC RDI_U32 rdim_count_from_location_block_chunk_list(RDIM_String8List *list);
|
||||
|
||||
////////////////////////////////
|
||||
// Type Index
|
||||
|
||||
RDI_PROC void rdim_assign_type_index(RDIM_Type *type, U64 *type_indices, U64 *curr_type_idx);
|
||||
RDI_PROC RDI_U64 * rdim_make_type_indices(RDIM_Arena *arena, RDIM_TypeChunkList *types);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked VMap Building
|
||||
|
||||
@@ -1499,10 +1510,10 @@ RDI_PROC void rdim_bake_string_map_loose_push_symbols(RDIM_Arena *arena, RDIM_Ba
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_scopes(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_ScopeChunkList *list);
|
||||
|
||||
//- rjf: bake name map building
|
||||
RDI_PROC RDIM_BakeNameMap *rdim_bake_name_map_from_kind_params(RDIM_Arena *arena, RDI_NameMapKind kind, RDIM_BakeParams *params);
|
||||
RDI_PROC RDIM_BakeNameMap *rdim_bake_name_map_from_kind_params(RDIM_Arena *arena, RDI_NameMapKind kind, RDI_U64 *type_indices, RDIM_BakeParams *params);
|
||||
|
||||
//- rjf: bake idx run map building
|
||||
RDI_PROC RDIM_BakeIdxRunMap *rdim_bake_idx_run_map_from_params(RDIM_Arena *arena, RDIM_BakeNameMap *name_maps[RDI_NameMapKind_COUNT], RDIM_BakeParams *params);
|
||||
RDI_PROC RDIM_BakeIdxRunMap *rdim_bake_idx_run_map_from_params(RDIM_Arena *arena, RDIM_BakeNameMap *name_maps[RDI_NameMapKind_COUNT], RDI_U64 *type_indices, RDIM_BakeParams *params);
|
||||
|
||||
//- rjf: bake path tree building
|
||||
RDI_PROC RDIM_BakePathTree *rdim_bake_path_tree_from_params(RDIM_Arena *arena, RDIM_BakeParams *params);
|
||||
@@ -1523,15 +1534,15 @@ RDI_PROC RDIM_UnitBakeResult rdim_bake_units(RDIM_Arena *arena, RDIM_
|
||||
RDI_PROC RDIM_UnitVMapBakeResult rdim_bake_unit_vmap(RDIM_Arena *arena, RDIM_UnitChunkList *units);
|
||||
RDI_PROC RDIM_SrcFileBakeResult rdim_bake_src_files(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakePathTree *path_tree, RDIM_SrcFileChunkList *src);
|
||||
RDI_PROC RDIM_LineTableBakeResult rdim_bake_line_tables(RDIM_Arena *arena, RDIM_LineTableChunkList *src);
|
||||
RDI_PROC RDIM_TypeNodeBakeResult rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeIdxRunMap *idx_runs, RDIM_TypeChunkList *src);
|
||||
RDI_PROC RDIM_UDTBakeResult rdim_bake_udts(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_UDTChunkList *src);
|
||||
RDI_PROC RDIM_GlobalVariableBakeResult rdim_bake_global_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src);
|
||||
RDI_PROC RDIM_TypeNodeBakeResult rdim_bake_types(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeIdxRunMap *idx_runs, RDI_U64 *type_indices, RDIM_TypeChunkList *src);
|
||||
RDI_PROC RDIM_UDTBakeResult rdim_bake_udts(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, RDIM_UDTChunkList *src);
|
||||
RDI_PROC RDIM_GlobalVariableBakeResult rdim_bake_global_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, 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_ProcedureBakeResult rdim_bake_procedures(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_SymbolChunkList *src);
|
||||
RDI_PROC RDIM_ScopeBakeResult rdim_bake_scopes(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_ScopeChunkList *src);
|
||||
RDI_PROC RDIM_ThreadVariableBakeResult rdim_bake_thread_variables(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, RDIM_SymbolChunkList *src);
|
||||
RDI_PROC RDIM_ProcedureBakeResult rdim_bake_procedures(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, 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, RDI_U64 *type_indices, 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);
|
||||
RDI_PROC RDIM_InlineSiteBakeResult rdim_bake_inline_sites(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_InlineSiteChunkList *src);
|
||||
RDI_PROC RDIM_InlineSiteBakeResult rdim_bake_inline_sites(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDI_U64 *type_indices, RDIM_InlineSiteChunkList *src);
|
||||
RDI_PROC RDIM_TopLevelNameMapBakeResult rdim_bake_name_maps_top_level(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakeIdxRunMap *idx_runs, RDIM_BakeNameMap *name_maps[RDI_NameMapKind_COUNT]);
|
||||
RDI_PROC RDIM_FilePathBakeResult rdim_bake_file_paths(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakePathTree *path_tree);
|
||||
RDI_PROC RDIM_StringBakeResult rdim_bake_strings(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings);
|
||||
|
||||
+98
-79
@@ -978,6 +978,7 @@ rdi_print_type_node(Arena *arena, String8List *out, String8 indent, RDI_Parsed *
|
||||
U32 *param_idx_array = rdi_idx_run_from_first_count(rdi, type->constructed.param_idx_run_first, type->constructed.count, ¶m_idx_count);
|
||||
String8 param_idx_str = rd_string_from_array_u32(scratch.arena, param_idx_array, param_idx_count);
|
||||
rd_printf("constructed.params =%S", param_idx_str);
|
||||
rd_printf("return type =%u", type->constructed.direct_type_idx);
|
||||
} else if (type->kind == RDI_TypeKind_Method) {
|
||||
U32 param_idx_count = 0;
|
||||
U32 *param_idx_array = rdi_idx_run_from_first_count(rdi, type->constructed.param_idx_run_first, type->constructed.count, ¶m_idx_count);
|
||||
@@ -990,6 +991,7 @@ rdi_print_type_node(Arena *arena, String8List *out, String8 indent, RDI_Parsed *
|
||||
String8 param_idx_str = rd_string_from_array_u32(scratch.arena, param_idx_array, param_idx_count);
|
||||
rd_printf("constructed.this_type =%S", this_type_str);
|
||||
rd_printf("constructed.params =%S", param_idx_str);
|
||||
rd_printf("return type =%u", type->constructed.direct_type_idx);
|
||||
} else if (RDI_TypeKind_FirstConstructed <= type->kind && type->kind <= RDI_TypeKind_LastConstructed) {
|
||||
|
||||
rd_printf("constructed.direct_type =%u", type->constructed.direct_type_idx);
|
||||
@@ -1058,6 +1060,86 @@ rdi_print_udt(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, R
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_print_locations(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, Arch arch, U64 block_lo, U64 block_hi)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
U64 location_block_count = 0;
|
||||
U64 location_data_size = 0;
|
||||
RDI_LocationBlock *location_block_array = rdi_table_from_name(rdi, LocationBlocks, &location_block_count);
|
||||
RDI_U8 *location_data = rdi_table_from_name(rdi, LocationData, &location_data_size);
|
||||
|
||||
block_lo = ClampTop(block_lo, location_block_count);
|
||||
block_hi = ClampTop(block_hi, location_block_count);
|
||||
|
||||
for (U32 block_idx = block_lo; block_idx < block_hi; ++block_idx) {
|
||||
RDI_LocationBlock *block_ptr = &location_block_array[block_idx];
|
||||
|
||||
if (block_ptr->scope_off_first == 0 && block_ptr->scope_off_opl == max_U32) {
|
||||
rd_printf("case *always*:");
|
||||
} else {
|
||||
rd_printf("case [%#08x, %#08x):", block_ptr->scope_off_first, block_ptr->scope_off_opl);
|
||||
}
|
||||
|
||||
if (block_ptr->location_data_off >= location_data_size) {
|
||||
rd_printf("<bad-location-data-offset %x>", block_ptr->location_data_off);
|
||||
} else {
|
||||
U8 *loc_data_opl = location_data + location_data_size;
|
||||
U8 *loc_base_ptr = location_data + block_ptr->location_data_off;
|
||||
RDI_LocationKind kind = *(RDI_LocationKind*)loc_base_ptr;
|
||||
switch (kind) {
|
||||
default: {
|
||||
rd_printf("\?\?\?: %u", kind);
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_AddrBytecodeStream: {
|
||||
Temp temp = temp_begin(scratch.arena);
|
||||
String8 raw_bytes = str8_cstring_capped(loc_base_ptr + 1, loc_data_opl);
|
||||
rd_printf("AddrBytecodeStream: %S", rd_format_hex_array(temp.arena, raw_bytes.str, raw_bytes.size));
|
||||
temp_end(temp);
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_ValBytecodeStream: {
|
||||
Temp temp = temp_begin(scratch.arena);
|
||||
String8 raw_bytes = str8_cstring_capped(loc_base_ptr + 1, loc_data_opl);
|
||||
rd_printf("ValBytecodeStream: %S", rd_format_hex_array(temp.arena, raw_bytes.str, raw_bytes.size));
|
||||
temp_end(temp);
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_AddrRegPlusU16: {
|
||||
if (loc_base_ptr + sizeof(RDI_LocationRegPlusU16) > loc_data_opl) {
|
||||
rd_printf("AddrRegPlusU16(\?\?\?)");
|
||||
} else {
|
||||
RDI_LocationRegPlusU16 *loc = (RDI_LocationRegPlusU16*)loc_base_ptr;
|
||||
rd_printf("AddrRegPlusU16(reg: %S, off: %u)", rdi_string_from_reg_code(scratch.arena, arch, loc->reg_code), loc->offset);
|
||||
}
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_AddrAddrRegPlusU16: {
|
||||
if (loc_base_ptr + sizeof(RDI_LocationRegPlusU16) > loc_data_opl){
|
||||
rd_printf("AddrAddrRegPlusU16(\?\?\?)");
|
||||
} else {
|
||||
RDI_LocationRegPlusU16 *loc = (RDI_LocationRegPlusU16 *)loc_base_ptr;
|
||||
rd_printf("AddrAddrRegisterPlusU16(reg: %S, off: %u)", rdi_string_from_reg_code(scratch.arena, arch, loc->reg_code), loc->offset);
|
||||
}
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_ValReg: {
|
||||
if (loc_base_ptr + sizeof(RDI_LocationReg) > loc_data_opl) {
|
||||
rd_printf("ValReg(\?\?\?)");
|
||||
} else {
|
||||
RDI_LocationReg *loc = (RDI_LocationReg*)loc_base_ptr;
|
||||
rd_printf("ValReg(reg: %S)", rdi_string_from_reg_code(scratch.arena, arch, loc->reg_code));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_print_global_variable(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, RDI_GlobalVariable *gvar)
|
||||
{
|
||||
@@ -1083,15 +1165,20 @@ rdi_print_thread_variable(Arena *arena, String8List *out, String8 indent, RDI_Pa
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_print_procedure(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, RDI_Procedure *proc)
|
||||
rdi_print_procedure(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, RDI_Procedure *proc, RDI_Arch arch)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
rd_printf("name ='%S'", str8_from_rdi_string_idx(rdi, proc->name_string_idx));
|
||||
rd_printf("link_name ='%S'", str8_from_rdi_string_idx(rdi, proc->link_name_string_idx));
|
||||
rd_printf("link_flags =%S", rdi_string_from_link_flags(scratch.arena, proc->link_flags));
|
||||
rd_printf("type_idx =%u", proc->type_idx);
|
||||
rd_printf("root_scope_idx=%u", proc->root_scope_idx);
|
||||
rd_printf("container_idx =%u", proc->container_idx);
|
||||
rd_printf("name ='%S'", str8_from_rdi_string_idx(rdi, proc->name_string_idx));
|
||||
rd_printf("link_name ='%S'", str8_from_rdi_string_idx(rdi, proc->link_name_string_idx));
|
||||
rd_printf("link_flags =%S", rdi_string_from_link_flags(scratch.arena, proc->link_flags));
|
||||
rd_printf("type_idx =%u", proc->type_idx);
|
||||
rd_printf("root_scope_idx =%u", proc->root_scope_idx);
|
||||
rd_printf("container_idx =%u", proc->container_idx);
|
||||
rd_printf("frame_base (first=%u, opl=%u)", proc->frame_base_location_first, proc->frame_base_location_opl);
|
||||
rd_indent();
|
||||
rdi_print_locations(arena, out, indent, rdi, arch, proc->frame_base_location_first, proc->frame_base_location_opl);
|
||||
rd_unindent();
|
||||
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
@@ -1103,19 +1190,15 @@ rdi_print_scope(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi,
|
||||
U64 scope_count = 0;
|
||||
U64 scope_voff_count = 0;
|
||||
U64 local_count = 0;
|
||||
U64 location_block_count = 0;
|
||||
U64 location_data_size = 0;
|
||||
U64 proc_count = 0;
|
||||
RDI_Scope *scope_array = rdi_table_from_name(rdi, Scopes, &scope_count);
|
||||
U64 *scope_voff_array = rdi_table_from_name(rdi, ScopeVOffData, &scope_voff_count);
|
||||
RDI_Local *local_array = rdi_table_from_name(rdi, Locals, &local_count);
|
||||
RDI_LocationBlock *location_block_array = rdi_table_from_name(rdi, LocationBlocks, &location_block_count);
|
||||
RDI_U8 *location_data = rdi_table_from_name(rdi, LocationData, &location_data_size);
|
||||
RDI_Procedure *proc_array = rdi_table_from_name(rdi, Procedures, &proc_count);
|
||||
|
||||
U32 voff_range_lo = ClampTop(scope->voff_range_first, scope_voff_count);
|
||||
U32 voff_range_hi = ClampTop(scope->voff_range_opl, scope_voff_count);
|
||||
U32 voff_range_count = (voff_range_hi - voff_range_lo) / 2;
|
||||
U32 voff_range_count = (voff_range_hi - voff_range_lo);
|
||||
U64 *voff_ptr = scope_voff_array + voff_range_lo;
|
||||
String8 voff_str = rd_string_from_range_array_u64_hex(scratch.arena, voff_ptr, voff_range_count);
|
||||
|
||||
@@ -1147,74 +1230,10 @@ rdi_print_scope(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi,
|
||||
rd_printf("name ='%S'", str8_from_rdi_string_idx(rdi, local_ptr->name_string_idx));
|
||||
rd_printf("type_idx=%u", local_ptr->type_idx);
|
||||
|
||||
U32 block_lo = ClampTop(local_ptr->location_first, location_block_count);
|
||||
U32 block_hi = ClampTop(local_ptr->location_opl, location_block_count);
|
||||
if (block_lo < block_hi) {
|
||||
if (local_ptr->location_first < local_ptr->location_opl) {
|
||||
rd_printf("locations:");
|
||||
rd_indent();
|
||||
for (U32 block_idx = block_lo; block_idx < block_hi; ++block_idx) {
|
||||
RDI_LocationBlock *block_ptr = &location_block_array[block_idx];
|
||||
|
||||
if (block_ptr->scope_off_first == 0 && block_ptr->scope_off_opl == max_U32) {
|
||||
rd_printf("case *always*:");
|
||||
} else {
|
||||
rd_printf("case [%#08x, %#08x):", block_ptr->scope_off_first, block_ptr->scope_off_opl);
|
||||
}
|
||||
|
||||
if (block_ptr->location_data_off >= location_data_size) {
|
||||
rd_printf("<bad-location-data-offset %x>", block_ptr->location_data_off);
|
||||
} else {
|
||||
U8 *loc_data_opl = location_data + location_data_size;
|
||||
U8 *loc_base_ptr = location_data + block_ptr->location_data_off;
|
||||
RDI_LocationKind kind = *(RDI_LocationKind*)loc_base_ptr;
|
||||
switch (kind) {
|
||||
default: {
|
||||
rd_printf("\?\?\?: %u", kind);
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_AddrBytecodeStream: {
|
||||
Temp temp = temp_begin(scratch.arena);
|
||||
String8 raw_bytes = str8_cstring_capped(loc_base_ptr + 1, loc_data_opl);
|
||||
rd_printf("AddrBytecodeStream: %S", rd_format_hex_array(temp.arena, raw_bytes.str, raw_bytes.size));
|
||||
temp_end(temp);
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_ValBytecodeStream: {
|
||||
Temp temp = temp_begin(scratch.arena);
|
||||
String8 raw_bytes = str8_cstring_capped(loc_base_ptr + 1, loc_data_opl);
|
||||
rd_printf("ValBytecodeStream: %S", rd_format_hex_array(temp.arena, raw_bytes.str, raw_bytes.size));
|
||||
temp_end(temp);
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_AddrRegPlusU16: {
|
||||
if (loc_base_ptr + sizeof(RDI_LocationRegPlusU16) > loc_data_opl) {
|
||||
rd_printf("AddrRegPlusU16(\?\?\?)");
|
||||
} else {
|
||||
RDI_LocationRegPlusU16 *loc = (RDI_LocationRegPlusU16*)loc_base_ptr;
|
||||
rd_printf("AddrRegPlusU16(reg: %S, off: %u)", rdi_string_from_reg_code(scratch.arena, arch, loc->reg_code), loc->offset);
|
||||
}
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_AddrAddrRegPlusU16: {
|
||||
if (loc_base_ptr + sizeof(RDI_LocationRegPlusU16) > loc_data_opl){
|
||||
rd_printf("AddrAddrRegPlusU16(\?\?\?)");
|
||||
} else {
|
||||
RDI_LocationRegPlusU16 *loc = (RDI_LocationRegPlusU16 *)loc_base_ptr;
|
||||
rd_printf("AddrAddrRegisterPlusU16(reg: %S, off: %u)", rdi_string_from_reg_code(scratch.arena, arch, loc->reg_code), loc->offset);
|
||||
}
|
||||
} break;
|
||||
|
||||
case RDI_LocationKind_ValReg: {
|
||||
if (loc_base_ptr + sizeof(RDI_LocationReg) > loc_data_opl) {
|
||||
rd_printf("ValReg(\?\?\?)");
|
||||
} else {
|
||||
RDI_LocationReg *loc = (RDI_LocationReg*)loc_base_ptr;
|
||||
rd_printf("ValReg(reg: %S)", rdi_string_from_reg_code(scratch.arena, arch, loc->reg_code));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rdi_print_locations(arena, out, indent, rdi, arch, local_ptr->location_first, local_ptr->location_opl);
|
||||
rd_unindent();
|
||||
}
|
||||
rd_unindent();
|
||||
@@ -1446,7 +1465,7 @@ rdi_print(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, RD_Op
|
||||
for (U64 i = 0; i < proc_count; ++i) {
|
||||
rd_printf("procedure[%llu]:", i);
|
||||
rd_indent();
|
||||
rdi_print_procedure(arena, out, indent, rdi, &proc_array[i]);
|
||||
rdi_print_procedure(arena, out, indent, rdi, &proc_array[i], tli->arch);
|
||||
rd_unindent();
|
||||
}
|
||||
rd_unindent();
|
||||
|
||||
@@ -1027,12 +1027,14 @@ RDI_ThreadVariableMemberTable:
|
||||
@table(name type desc)
|
||||
RDI_ProcedureMemberTable:
|
||||
{
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{root_scope_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{root_scope_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
{frame_base_location_first RDI_U32 ""}
|
||||
{frame_base_location_opl RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
@@ -1250,7 +1252,7 @@ RDI_EvalOpTable:
|
||||
{MemRead 4 1 1 1}
|
||||
{RegRead 5 4 0 1}
|
||||
{RegReadDyn 6 0 1 1}
|
||||
{FrameOff 7 1 0 1}
|
||||
{FrameOff 7 8 0 1}
|
||||
{ModuleOff 8 4 0 1}
|
||||
{TLSOff 9 4 0 1}
|
||||
{ObjectOff 10 0 0 0}
|
||||
|
||||
@@ -197,7 +197,7 @@ ASYNC_WORK_DEF(rdim_build_bake_name_map_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BuildBakeNameMapIn *in = (RDIM_BuildBakeNameMapIn *)input;
|
||||
RDIM_BakeNameMap *name_map = 0;
|
||||
ProfScope("build name map %i", in->k) name_map = rdim_bake_name_map_from_kind_params(arena, in->k, in->params);
|
||||
ProfScope("build name map %i", in->k) name_map = rdim_bake_name_map_from_kind_params(arena, in->k, in->type_indices, in->params);
|
||||
ProfEnd();
|
||||
return name_map;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ ASYNC_WORK_DEF(rdim_bake_udts_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BakeUDTsIn *in = (RDIM_BakeUDTsIn *)input;
|
||||
RDIM_UDTBakeResult *out = push_array(arena, RDIM_UDTBakeResult, 1);
|
||||
ProfScope("bake udts") *out = rdim_bake_udts(arena, in->strings, in->udts);
|
||||
ProfScope("bake udts") *out = rdim_bake_udts(arena, in->strings, in->type_indices, in->udts);
|
||||
ProfEnd();
|
||||
return out;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ ASYNC_WORK_DEF(rdim_bake_global_variables_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BakeGlobalVariablesIn *in = (RDIM_BakeGlobalVariablesIn *)input;
|
||||
RDIM_GlobalVariableBakeResult *out = push_array(arena, RDIM_GlobalVariableBakeResult, 1);
|
||||
ProfScope("bake global variables") *out = rdim_bake_global_variables(arena, in->strings, in->global_variables);
|
||||
ProfScope("bake global variables") *out = rdim_bake_global_variables(arena, in->strings, in->type_indices, in->global_variables);
|
||||
ProfEnd();
|
||||
return out;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ ASYNC_WORK_DEF(rdim_bake_thread_variables_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BakeThreadVariablesIn *in = (RDIM_BakeThreadVariablesIn *)input;
|
||||
RDIM_ThreadVariableBakeResult *out = push_array(arena, RDIM_ThreadVariableBakeResult, 1);
|
||||
ProfScope("bake thread variables") *out = rdim_bake_thread_variables(arena, in->strings, in->thread_variables);
|
||||
ProfScope("bake thread variables") *out = rdim_bake_thread_variables(arena, in->strings, in->type_indices, in->thread_variables);
|
||||
ProfEnd();
|
||||
return out;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ ASYNC_WORK_DEF(rdim_bake_procedures_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BakeProceduresIn *in = (RDIM_BakeProceduresIn *)input;
|
||||
RDIM_ProcedureBakeResult *out = push_array(arena, RDIM_ProcedureBakeResult, 1);
|
||||
ProfScope("bake procedures") *out = rdim_bake_procedures(arena, in->strings, in->procedures);
|
||||
ProfScope("bake procedures") *out = rdim_bake_procedures(arena, in->strings, in->type_indices, in->location_blocks, in->location_data_blobs, in->procedures);
|
||||
ProfEnd();
|
||||
return out;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ ASYNC_WORK_DEF(rdim_bake_scopes_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BakeScopesIn *in = (RDIM_BakeScopesIn *)input;
|
||||
RDIM_ScopeBakeResult *out = push_array(arena, RDIM_ScopeBakeResult, 1);
|
||||
ProfScope("bake scopes") *out = rdim_bake_scopes(arena, in->strings, in->scopes);
|
||||
ProfScope("bake scopes") *out = rdim_bake_scopes(arena, in->strings, in->type_indices, in->location_blocks, in->location_data_blobs, in->scopes);
|
||||
ProfEnd();
|
||||
return out;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ ASYNC_WORK_DEF(rdim_bake_inline_sites_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BakeInlineSitesIn *in = (RDIM_BakeInlineSitesIn *)input;
|
||||
RDIM_InlineSiteBakeResult *out = push_array(arena, RDIM_InlineSiteBakeResult, 1);
|
||||
ProfScope("bake inline sites") *out = rdim_bake_inline_sites(arena, in->strings, in->inline_sites);
|
||||
ProfScope("bake inline sites") *out = rdim_bake_inline_sites(arena, in->strings, in->type_indices, in->inline_sites);
|
||||
ProfEnd();
|
||||
return out;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ ASYNC_WORK_DEF(rdim_bake_type_nodes_work)
|
||||
Arena *arena = rdim_help_state->work_thread_arenas[thread_idx];
|
||||
RDIM_BakeTypeNodesIn *in = (RDIM_BakeTypeNodesIn *)input;
|
||||
RDIM_TypeNodeBakeResult *out = push_array(arena, RDIM_TypeNodeBakeResult, 1);
|
||||
ProfScope("bake type nodes") *out = rdim_bake_types(arena, in->strings, in->idx_runs, in->types);
|
||||
ProfScope("bake type nodes") *out = rdim_bake_types(arena, in->strings, in->idx_runs, in->type_indices, in->types);
|
||||
ProfEnd();
|
||||
return out;
|
||||
}
|
||||
@@ -404,6 +404,11 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params)
|
||||
RDIM_BakeResults out = {0};
|
||||
|
||||
rdim_help_state = state;
|
||||
|
||||
////////////////////////////////
|
||||
// compute type indices
|
||||
|
||||
RDI_U64 *type_indices = rdim_make_type_indices(scratch.arena, &in_params->types);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: kick off line tables baking
|
||||
@@ -634,6 +639,7 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params)
|
||||
k = (RDI_NameMapKind)(k+1))
|
||||
{
|
||||
build_bake_name_map_in[k].k = k;
|
||||
build_bake_name_map_in[k].type_indices = type_indices;
|
||||
build_bake_name_map_in[k].params = in_params;
|
||||
build_bake_name_map_task[k] = async_task_launch(scratch.arena, rdim_build_bake_name_map_work, .input = &build_bake_name_map_in[k]);
|
||||
}
|
||||
@@ -741,27 +747,43 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params)
|
||||
ASYNC_Task *bake_unit_vmap_task = async_task_launch(scratch.arena, rdim_bake_unit_vmap_work, .input = &bake_unit_vmap_in);
|
||||
RDIM_BakeSrcFilesIn bake_src_files_in = {&bake_strings, path_tree, &in_params->src_files};
|
||||
ASYNC_Task *bake_src_files_task = async_task_launch(scratch.arena, rdim_bake_src_files_work, .input = &bake_src_files_in);
|
||||
RDIM_BakeUDTsIn bake_udts_in = {&bake_strings, &in_params->udts};
|
||||
RDIM_BakeUDTsIn bake_udts_in = {&bake_strings, &in_params->udts, type_indices};
|
||||
ASYNC_Task *bake_udts_task = async_task_launch(scratch.arena, rdim_bake_udts_work, .input = &bake_udts_in);
|
||||
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);
|
||||
RDIM_BakeGlobalVMapIn bake_global_vmap_in = {&in_params->global_variables};
|
||||
ASYNC_Task *bake_global_vmap_task = async_task_launch(scratch.arena, rdim_bake_global_vmap_work, .input = &bake_global_vmap_in);
|
||||
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);
|
||||
RDIM_BakeProceduresIn bake_procedures_in = {&bake_strings, &in_params->procedures};
|
||||
ASYNC_Task *bake_procedures_task = async_task_launch(scratch.arena, rdim_bake_procedures_work, .input = &bake_procedures_in);
|
||||
RDIM_BakeScopesIn bake_scopes_in = {&bake_strings, &in_params->scopes};
|
||||
ASYNC_Task *bake_scopes_task = async_task_launch(scratch.arena, rdim_bake_scopes_work, .input = &bake_scopes_in);
|
||||
RDIM_BakeScopeVMapIn bake_scope_vmap_in = {&in_params->scopes};
|
||||
ASYNC_Task *bake_scope_vmap_task = async_task_launch(scratch.arena, rdim_bake_scope_vmap_work, .input = &bake_scope_vmap_in);
|
||||
RDIM_BakeInlineSitesIn bake_inline_sites_in = {&bake_strings, &in_params->inline_sites};
|
||||
RDIM_BakeInlineSitesIn bake_inline_sites_in = {&bake_strings, &in_params->inline_sites, type_indices};
|
||||
ASYNC_Task *bake_inline_sites_task = async_task_launch(scratch.arena, rdim_bake_inline_sites_work, .input = &bake_inline_sites_in);
|
||||
RDIM_BakeFilePathsIn bake_file_paths_in = {&bake_strings, path_tree};
|
||||
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_String8List location_blocks = {0};
|
||||
RDIM_String8List location_data_blobs = {0};
|
||||
|
||||
// reserve null location block for opl
|
||||
rdim_location_block_chunk_list_push_array(state->work_thread_arenas[0], &location_blocks, 1);
|
||||
|
||||
// TODO: export location instead of VOFF
|
||||
RDIM_BakeThreadVariablesIn bake_thread_variables_in = {&bake_strings, &in_params->thread_variables, type_indices};
|
||||
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, type_indices};
|
||||
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, type_indices, &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, type_indices, &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);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: join name map building tasks
|
||||
//
|
||||
@@ -782,7 +804,7 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params)
|
||||
RDIM_BakeIdxRunMap *idx_runs = 0;
|
||||
ProfScope("build interned idx run map")
|
||||
{
|
||||
idx_runs = rdim_bake_idx_run_map_from_params(state->work_thread_arenas[0], name_maps, in_params);
|
||||
idx_runs = rdim_bake_idx_run_map_from_params(state->work_thread_arenas[0], name_maps, type_indices, in_params);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@@ -795,7 +817,7 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params)
|
||||
//////////////////////////////
|
||||
//- rjf: kick off pass 3 tasks
|
||||
//
|
||||
RDIM_BakeTypeNodesIn bake_type_nodes_in = {&bake_strings, idx_runs, &in_params->types};
|
||||
RDIM_BakeTypeNodesIn bake_type_nodes_in = {&bake_strings, idx_runs, &in_params->types, type_indices};
|
||||
ASYNC_Task *bake_type_nodes_task = async_task_launch(scratch.arena, rdim_bake_type_nodes_work, .input = &bake_type_nodes_in);
|
||||
ASYNC_Task *bake_name_maps_tasks[RDI_NameMapKind_COUNT] = {0};
|
||||
{
|
||||
@@ -823,11 +845,7 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params)
|
||||
ProfScope("unit vmap") out.unit_vmap = *async_task_join_struct(bake_unit_vmap_task, RDIM_UnitVMapBakeResult);
|
||||
ProfScope("source files") out.src_files = *async_task_join_struct(bake_src_files_task, RDIM_SrcFileBakeResult);
|
||||
ProfScope("UDTs") out.udts = *async_task_join_struct(bake_udts_task, RDIM_UDTBakeResult);
|
||||
ProfScope("global variables") out.global_variables = *async_task_join_struct(bake_global_variables_task, RDIM_GlobalVariableBakeResult);
|
||||
ProfScope("global vmap") out.global_vmap = *async_task_join_struct(bake_global_vmap_task, RDIM_GlobalVMapBakeResult);
|
||||
ProfScope("thread variables") out.thread_variables = *async_task_join_struct(bake_thread_variables_task, RDIM_ThreadVariableBakeResult);
|
||||
ProfScope("procedures") out.procedures = *async_task_join_struct(bake_procedures_task, RDIM_ProcedureBakeResult);
|
||||
ProfScope("scopes") out.scopes = *async_task_join_struct(bake_scopes_task, RDIM_ScopeBakeResult);
|
||||
ProfScope("scope vmap") out.scope_vmap = *async_task_join_struct(bake_scope_vmap_task, RDIM_ScopeVMapBakeResult);
|
||||
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);
|
||||
@@ -860,6 +878,12 @@ rdim_bake(RDIM_HelpState *state, RDIM_BakeParams *in_params)
|
||||
out.name_maps = rdim_name_map_bake_results_combine(state->work_thread_arenas[0], name_map_bakes, ArrayCount(name_map_bakes));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
out.location_blocks = rdim_str8_list_join(state->work_thread_arenas[0], &location_blocks, rdim_str8(0,0));
|
||||
out.location_data = rdim_str8_list_join(state->work_thread_arenas[0], &location_data_blobs, rdim_str8(0,0));
|
||||
|
||||
rdim_help_state = 0;
|
||||
|
||||
scratch_end(scratch);
|
||||
|
||||
@@ -128,6 +128,7 @@ typedef struct RDIM_BuildBakeNameMapIn RDIM_BuildBakeNameMapIn;
|
||||
struct RDIM_BuildBakeNameMapIn
|
||||
{
|
||||
RDI_NameMapKind k;
|
||||
RDI_U64 *type_indices;
|
||||
RDIM_BakeParams *params;
|
||||
};
|
||||
|
||||
@@ -184,6 +185,7 @@ struct RDIM_BakeUDTsIn
|
||||
{
|
||||
RDIM_BakeStringMapTight *strings;
|
||||
RDIM_UDTChunkList *udts;
|
||||
RDI_U64 *type_indices;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeGlobalVariablesIn RDIM_BakeGlobalVariablesIn;
|
||||
@@ -191,6 +193,7 @@ struct RDIM_BakeGlobalVariablesIn
|
||||
{
|
||||
RDIM_BakeStringMapTight *strings;
|
||||
RDIM_SymbolChunkList *global_variables;
|
||||
RDI_U64 *type_indices;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeGlobalVMapIn RDIM_BakeGlobalVMapIn;
|
||||
@@ -204,6 +207,7 @@ struct RDIM_BakeThreadVariablesIn
|
||||
{
|
||||
RDIM_BakeStringMapTight *strings;
|
||||
RDIM_SymbolChunkList *thread_variables;
|
||||
RDI_U64 *type_indices;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeProceduresIn RDIM_BakeProceduresIn;
|
||||
@@ -211,6 +215,9 @@ struct RDIM_BakeProceduresIn
|
||||
{
|
||||
RDIM_BakeStringMapTight *strings;
|
||||
RDIM_SymbolChunkList *procedures;
|
||||
RDI_U64 *type_indices;
|
||||
RDIM_String8List *location_blocks;
|
||||
RDIM_String8List *location_data_blobs;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeScopesIn RDIM_BakeScopesIn;
|
||||
@@ -218,6 +225,9 @@ struct RDIM_BakeScopesIn
|
||||
{
|
||||
RDIM_BakeStringMapTight *strings;
|
||||
RDIM_ScopeChunkList *scopes;
|
||||
RDI_U64 *type_indices;
|
||||
RDIM_String8List *location_blocks;
|
||||
RDIM_String8List *location_data_blobs;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeScopeVMapIn RDIM_BakeScopeVMapIn;
|
||||
@@ -231,6 +241,7 @@ struct RDIM_BakeInlineSitesIn
|
||||
{
|
||||
RDIM_BakeStringMapTight *strings;
|
||||
RDIM_InlineSiteChunkList *inline_sites;
|
||||
RDI_U64 *type_indices;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeFilePathsIn RDIM_BakeFilePathsIn;
|
||||
@@ -252,6 +263,7 @@ struct RDIM_BakeTypeNodesIn
|
||||
RDIM_BakeStringMapTight *strings;
|
||||
RDIM_BakeIdxRunMap *idx_runs;
|
||||
RDIM_TypeChunkList *types;
|
||||
RDI_U64 *type_indices;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeNameMapIn RDIM_BakeNameMapIn;
|
||||
|
||||
Reference in New Issue
Block a user