mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-26 01:13:44 +00:00
remove old section requirement part of rdi, since all sections are now fixed; unit/scope/global vmap baking; collapse chunk list impls
This commit is contained in:
@@ -54,50 +54,6 @@ sizeof(RDI_NameMapNode),
|
||||
sizeof(RDI_U8),
|
||||
};
|
||||
|
||||
RDI_U8 rdi_section_is_required_table[40] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
RDI_U16 rdi_eval_op_ctrlbits_table[52] =
|
||||
{
|
||||
RDI_EVAL_CTRLBITS(0, 0, 0),
|
||||
|
||||
@@ -1572,7 +1572,6 @@ RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTyp
|
||||
RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out);
|
||||
|
||||
extern RDI_U16 rdi_section_element_size_table[40];
|
||||
extern RDI_U8 rdi_section_is_required_table[40];
|
||||
extern RDI_U16 rdi_eval_op_ctrlbits_table[52];
|
||||
|
||||
#endif // RDI_H
|
||||
|
||||
@@ -214,27 +214,6 @@ rdi_parse(RDI_U8 *data, RDI_U64 size, RDI_Parsed *out)
|
||||
out->sections_count = dsec_count;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: validate results
|
||||
//
|
||||
if(result == RDI_ParseStatus_Good)
|
||||
{
|
||||
for(RDI_SectionKind k = (RDI_SectionKind)(RDI_SectionKind_NULL+1); k < RDI_SectionKind_COUNT; k = (RDI_SectionKind)(k+1))
|
||||
{
|
||||
if(rdi_section_is_required_table[k])
|
||||
{
|
||||
RDI_U64 data_size = 0;
|
||||
RDI_SectionEncoding encoding = 0;
|
||||
void *data = rdi_section_raw_data_from_kind(out, k, &encoding, &data_size);
|
||||
if(data == 0 || data == &rdi_nil_element_union || data_size == 0)
|
||||
{
|
||||
result = RDI_ParseStatus_MissingRequiredSection;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ typedef enum RDI_ParseStatus
|
||||
RDI_ParseStatus_HeaderDoesNotMatch = 1,
|
||||
RDI_ParseStatus_UnsupportedVersionNumber = 2,
|
||||
RDI_ParseStatus_InvalidDataSecionLayout = 3,
|
||||
RDI_ParseStatus_MissingRequiredSection = 4,
|
||||
}
|
||||
RDI_ParseStatus;
|
||||
|
||||
|
||||
+131
-366
@@ -4,8 +4,51 @@
|
||||
////////////////////////////////
|
||||
//~ rjf: API Implementation Helper Macros
|
||||
|
||||
#define rdim_require(root, b32, else_code, error_msg) do { if(!(b32)) {rdim_push_msg((root), (error_msg)); else_code;} }while(0)
|
||||
#define rdim_requiref(root, b32, else_code, fmt, ...) do { if(!(b32)) {rdim_push_msgf((root), (fmt), __VA_ARGS__); else_code;} }while(0)
|
||||
#define RDIM_IdxedChunkListPush(arena, list, chunk_type, element_type, cap_value, result) \
|
||||
element_type *result = 0;\
|
||||
do\
|
||||
{\
|
||||
chunk_type *n = list->last;\
|
||||
if(n == 0 || n->count >= n->cap)\
|
||||
{\
|
||||
n = rdim_push_array(arena, chunk_type, 1);\
|
||||
n->cap = cap_value;\
|
||||
n->base_idx = list->total_count;\
|
||||
n->v = rdim_push_array_no_zero(arena, element_type, n->cap);\
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);\
|
||||
list->chunk_count += 1;\
|
||||
}\
|
||||
result = &n->v[n->count];\
|
||||
result->chunk = n;\
|
||||
n->count += 1;\
|
||||
list->total_count += 1;\
|
||||
}while(0)
|
||||
|
||||
#define RDIM_IdxedChunkListElementGetIdx(ptr, result) \
|
||||
RDI_U64 idx = 0;\
|
||||
if(ptr != 0 && ptr->chunk != 0)\
|
||||
{\
|
||||
idx = ptr->chunk->base_idx + (ptr - ptr->chunk->v) + 1;\
|
||||
}
|
||||
|
||||
#define RDIM_IdxedChunkListConcatInPlace(chunk_type, dst, to_push, ...) \
|
||||
for(chunk_type *n = to_push->first; n != 0; n = n->next)\
|
||||
{\
|
||||
n->base_idx += dst->total_count;\
|
||||
}\
|
||||
if(dst->last != 0 && to_push->first != 0)\
|
||||
{\
|
||||
dst->last->next = to_push->first;\
|
||||
dst->last = to_push->last;\
|
||||
dst->chunk_count += to_push->chunk_count;\
|
||||
dst->total_count += to_push->total_count;\
|
||||
__VA_ARGS__;\
|
||||
}\
|
||||
else if(dst->first == 0)\
|
||||
{\
|
||||
rdim_memcpy_struct(dst, to_push);\
|
||||
}\
|
||||
rdim_memzero_struct(to_push);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helpers
|
||||
@@ -277,6 +320,12 @@ rdim_str8_list_join(RDIM_Arena *arena, RDIM_String8List *list, RDIM_String8 sep)
|
||||
|
||||
//- rjf: sortable range sorting
|
||||
|
||||
RSFORCEINLINE int
|
||||
rdim_sort_key_is_before(void *l, void *r)
|
||||
{
|
||||
return ((RDIM_SortKey *)l)->key < ((RDIM_SortKey *)r)->key;
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_SortKey *
|
||||
rdim_sort_key_array(RDIM_Arena *arena, RDIM_SortKey *keys, RDI_U64 count)
|
||||
{
|
||||
@@ -286,6 +335,7 @@ rdim_sort_key_array(RDIM_Arena *arena, RDIM_SortKey *keys, RDI_U64 count)
|
||||
// Also - this sort should be a "stable" sort. In the use case of sorting vmap
|
||||
// ranges, we want to be able to rely on order, so it needs to be preserved here.
|
||||
|
||||
RDIM_ProfBegin("rdim_sort_key_array");
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
RDIM_SortKey *result = 0;
|
||||
|
||||
@@ -436,6 +486,7 @@ rdim_sort_key_array(RDIM_Arena *arena, RDIM_SortKey *keys, RDI_U64 count)
|
||||
#endif
|
||||
|
||||
rdim_scratch_end(scratch);
|
||||
RDIM_ProfEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -641,55 +692,23 @@ rdim_binary_section_list_push(RDIM_Arena *arena, RDIM_BinarySectionList *list)
|
||||
RDI_PROC RDIM_SrcFile *
|
||||
rdim_src_file_chunk_list_push(RDIM_Arena *arena, RDIM_SrcFileChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_SrcFileChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_SrcFileChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_SrcFile, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_SrcFile *src_file = &n->v[n->count];
|
||||
src_file->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return src_file;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_SrcFileChunkNode, RDIM_SrcFile, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_src_file(RDIM_SrcFile *src_file)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(src_file != 0 && src_file->chunk != 0)
|
||||
{
|
||||
idx = (src_file->chunk->base_idx + (src_file - src_file->chunk->v) + 1);
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(src_file, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_src_file_chunk_list_concat_in_place(RDIM_SrcFileChunkList *dst, RDIM_SrcFileChunkList *to_push)
|
||||
{
|
||||
for(RDIM_SrcFileChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
dst->source_line_map_count += to_push->source_line_map_count;
|
||||
dst->total_line_count += to_push->total_line_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_SrcFileChunkNode, dst, to_push,
|
||||
dst->source_line_map_count += to_push->source_line_map_count,
|
||||
dst->total_line_count += to_push->total_line_count);
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
@@ -711,56 +730,24 @@ rdim_src_file_push_line_sequence(RDIM_Arena *arena, RDIM_SrcFileChunkList *src_f
|
||||
RDI_PROC RDIM_LineTable *
|
||||
rdim_line_table_chunk_list_push(RDIM_Arena *arena, RDIM_LineTableChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_LineTableChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_LineTableChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_LineTable, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_LineTable *line_table = &n->v[n->count];
|
||||
line_table->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return line_table;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_LineTableChunkNode, RDIM_LineTable, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_line_table(RDIM_LineTable *line_table)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(line_table != 0 && line_table->chunk != 0)
|
||||
{
|
||||
idx = line_table->chunk->base_idx + (line_table - line_table->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(line_table, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_line_table_chunk_list_concat_in_place(RDIM_LineTableChunkList *dst, RDIM_LineTableChunkList *to_push)
|
||||
{
|
||||
for(RDIM_LineTableChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
dst->total_seq_count += to_push->total_seq_count;
|
||||
dst->total_line_count += to_push->total_line_count;
|
||||
dst->total_col_count += to_push->total_col_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_LineTableChunkNode, dst, to_push,
|
||||
dst->total_seq_count += to_push->total_seq_count,
|
||||
dst->total_line_count += to_push->total_line_count,
|
||||
dst->total_col_count += to_push->total_col_count);
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_LineSequence *
|
||||
@@ -788,53 +775,21 @@ rdim_line_table_push_sequence(RDIM_Arena *arena, RDIM_LineTableChunkList *line_t
|
||||
RDI_PROC RDIM_Unit *
|
||||
rdim_unit_chunk_list_push(RDIM_Arena *arena, RDIM_UnitChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_UnitChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_UnitChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Unit, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Unit *unit = &n->v[n->count];
|
||||
unit->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return unit;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_UnitChunkNode, RDIM_Unit, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_unit(RDIM_Unit *unit)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(unit != 0 && unit->chunk != 0)
|
||||
{
|
||||
idx = unit->chunk->base_idx + (unit - unit->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(unit, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_unit_chunk_list_concat_in_place(RDIM_UnitChunkList *dst, RDIM_UnitChunkList *to_push)
|
||||
{
|
||||
for(RDIM_UnitChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_UnitChunkNode, dst, to_push);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -867,53 +822,21 @@ rdim_type_list_push(RDIM_Arena *arena, RDIM_TypeList *list, RDIM_Type *v)
|
||||
RDI_PROC RDIM_Type *
|
||||
rdim_type_chunk_list_push(RDIM_Arena *arena, RDIM_TypeChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_TypeChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_TypeChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Type, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Type *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_TypeChunkNode, RDIM_Type, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_type(RDIM_Type *type)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(type != 0 && type->chunk != 0)
|
||||
{
|
||||
idx = type->chunk->base_idx + (type - type->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(type, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_type_chunk_list_concat_in_place(RDIM_TypeChunkList *dst, RDIM_TypeChunkList *to_push)
|
||||
{
|
||||
for(RDIM_TypeChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_TypeChunkNode, dst, to_push);
|
||||
}
|
||||
|
||||
//- rjf: UDT members
|
||||
@@ -921,53 +844,21 @@ rdim_type_chunk_list_concat_in_place(RDIM_TypeChunkList *dst, RDIM_TypeChunkList
|
||||
RDI_PROC RDIM_UDTMember *
|
||||
rdim_udt_member_chunk_list_push(RDIM_Arena *arena, RDIM_UDTMemberChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_UDTMemberChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_UDTMemberChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_UDTMember, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_UDTMember *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_UDTMemberChunkNode, RDIM_UDTMember, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_udt_member(RDIM_UDTMember *member)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(member != 0 && member->chunk != 0)
|
||||
{
|
||||
idx = member->chunk->base_idx + (member - member->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(member, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_udt_member_chunk_list_concat_in_place(RDIM_UDTMemberChunkList *dst, RDIM_UDTMemberChunkList *to_push)
|
||||
{
|
||||
for(RDIM_UDTMemberChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_UDTMemberChunkNode, dst, to_push);
|
||||
}
|
||||
|
||||
//- rjf: UDT enum values
|
||||
@@ -975,53 +866,21 @@ rdim_udt_member_chunk_list_concat_in_place(RDIM_UDTMemberChunkList *dst, RDIM_UD
|
||||
RDI_PROC RDIM_UDTEnumVal *
|
||||
rdim_udt_enum_val_chunk_list_push(RDIM_Arena *arena, RDIM_UDTEnumValChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_UDTEnumValChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_UDTEnumValChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_UDTEnumVal, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_UDTEnumVal *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_UDTEnumValChunkNode, RDIM_UDTEnumVal, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_udt_enum_val(RDIM_UDTEnumVal *enum_val)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(enum_val != 0 && enum_val->chunk != 0)
|
||||
{
|
||||
idx = enum_val->chunk->base_idx + (enum_val - enum_val->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(enum_val, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_udt_enum_val_chunk_list_concat_in_place(RDIM_UDTEnumValChunkList *dst, RDIM_UDTEnumValChunkList *to_push)
|
||||
{
|
||||
for(RDIM_UDTEnumValChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_UDTEnumValChunkNode, dst, to_push);
|
||||
}
|
||||
|
||||
//- rjf: UDTs
|
||||
@@ -1029,55 +888,23 @@ rdim_udt_enum_val_chunk_list_concat_in_place(RDIM_UDTEnumValChunkList *dst, RDIM
|
||||
RDI_PROC RDIM_UDT *
|
||||
rdim_udt_chunk_list_push(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_UDTChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_UDTChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_UDT, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_UDT *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_UDTChunkNode, RDIM_UDT, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_udt(RDIM_UDT *udt)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(udt != 0 && udt->chunk != 0)
|
||||
{
|
||||
idx = udt->chunk->base_idx + (udt - udt->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(udt, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_udt_chunk_list_concat_in_place(RDIM_UDTChunkList *dst, RDIM_UDTChunkList *to_push)
|
||||
{
|
||||
for(RDIM_UDTChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
dst->total_member_count += to_push->total_member_count;
|
||||
dst->total_enum_val_count += to_push->total_enum_val_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_UDTChunkNode, dst, to_push,
|
||||
dst->total_member_count += to_push->total_member_count,
|
||||
dst->total_enum_val_count += to_push->total_enum_val_count);
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_UDTMember *
|
||||
@@ -1106,54 +933,21 @@ rdim_udt_push_enum_val(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDIM_UDT *udt
|
||||
RDI_PROC RDIM_Symbol *
|
||||
rdim_symbol_chunk_list_push(RDIM_Arena *arena, RDIM_SymbolChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_SymbolChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_SymbolChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Symbol, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Symbol *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_SymbolChunkNode, RDIM_Symbol, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_symbol(RDIM_Symbol *symbol)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(symbol != 0 && symbol->chunk != 0)
|
||||
{
|
||||
idx = symbol->chunk->base_idx + (symbol - symbol->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(symbol, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_symbol_chunk_list_concat_in_place(RDIM_SymbolChunkList *dst, RDIM_SymbolChunkList *to_push)
|
||||
{
|
||||
for(RDIM_SymbolChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
dst->total_value_data_size += to_push->total_value_data_size;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_SymbolChunkNode, dst, to_push, dst->total_value_data_size += to_push->total_value_data_size);
|
||||
}
|
||||
|
||||
internal void
|
||||
@@ -1169,53 +963,36 @@ rdim_symbol_push_value_data(RDIM_Arena *arena, RDIM_SymbolChunkList *list, RDIM_
|
||||
RDI_PROC RDIM_InlineSite *
|
||||
rdim_inline_site_chunk_list_push(RDIM_Arena *arena, RDIM_InlineSiteChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_InlineSiteChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_InlineSiteChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_InlineSite, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_InlineSite *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_InlineSiteChunkNode, RDIM_InlineSite, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_inline_site(RDIM_InlineSite *inline_site)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(inline_site != 0 && inline_site->chunk != 0)
|
||||
{
|
||||
idx = inline_site->chunk->base_idx + (inline_site - inline_site->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(inline_site, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_inline_site_chunk_list_concat_in_place(RDIM_InlineSiteChunkList *dst, RDIM_InlineSiteChunkList *to_push)
|
||||
{
|
||||
for(RDIM_InlineSiteChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_InlineSiteChunkNode, dst, to_push);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Building] Location Info Building
|
||||
|
||||
RDI_PROC RDIM_Location *
|
||||
rdim_location_chunk_list_push_new(RDIM_Arena *arena, RDIM_LocationChunkList *list, RDI_U64 cap, RDIM_Location *loc)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_location_chunk_list_concat_in_place(RDIM_LocationChunkList *dst, RDIM_LocationChunkList *to_push)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -1226,56 +1003,24 @@ rdim_inline_site_chunk_list_concat_in_place(RDIM_InlineSiteChunkList *dst, RDIM_
|
||||
RDI_PROC RDIM_Scope *
|
||||
rdim_scope_chunk_list_push(RDIM_Arena *arena, RDIM_ScopeChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_ScopeChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_ScopeChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->base_idx = list->total_count;
|
||||
n->v = rdim_push_array(arena, RDIM_Scope, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_Scope *result = &n->v[n->count];
|
||||
result->chunk = n;
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
RDIM_IdxedChunkListPush(arena, list, RDIM_ScopeChunkNode, RDIM_Scope, cap, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_idx_from_scope(RDIM_Scope *scope)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
if(scope != 0 && scope->chunk != 0)
|
||||
{
|
||||
idx = scope->chunk->base_idx + (scope - scope->chunk->v) + 1;
|
||||
}
|
||||
RDIM_IdxedChunkListElementGetIdx(scope, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_scope_chunk_list_concat_in_place(RDIM_ScopeChunkList *dst, RDIM_ScopeChunkList *to_push)
|
||||
{
|
||||
for(RDIM_ScopeChunkNode *n = to_push->first; n != 0; n = n->next)
|
||||
{
|
||||
n->base_idx += dst->total_count;
|
||||
}
|
||||
if(dst->last != 0 && to_push->first != 0)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
dst->last = to_push->last;
|
||||
dst->chunk_count += to_push->chunk_count;
|
||||
dst->total_count += to_push->total_count;
|
||||
dst->scope_voff_count += to_push->scope_voff_count;
|
||||
dst->local_count += to_push->local_count;
|
||||
dst->location_count += to_push->location_count;
|
||||
}
|
||||
else if(dst->first == 0)
|
||||
{
|
||||
rdim_memcpy_struct(dst, to_push);
|
||||
}
|
||||
rdim_memzero_struct(to_push);
|
||||
RDIM_IdxedChunkListConcatInPlace(RDIM_ScopeChunkNode, dst, to_push,
|
||||
dst->scope_voff_count += to_push->scope_voff_count,
|
||||
dst->local_count += to_push->local_count,
|
||||
dst->location_count += to_push->location_count);
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
@@ -1464,6 +1209,7 @@ rdim_count_from_location_block_chunk_list(RDIM_String8List *list)
|
||||
RDI_PROC RDIM_BakeVMap
|
||||
rdim_bake_vmap_from_markers(RDIM_Arena *arena, RDIM_VMapMarker *markers, RDIM_SortKey *keys, RDI_U64 marker_count)
|
||||
{
|
||||
RDIM_ProfBegin("rdim_bake_vmap_from_markers");
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: sort markers
|
||||
@@ -1599,6 +1345,7 @@ rdim_bake_vmap_from_markers(RDIM_Arena *arena, RDIM_VMapMarker *markers, RDIM_So
|
||||
result.vmap = vmap;
|
||||
result.count = vmap_entry_count;
|
||||
rdim_scratch_end(scratch);
|
||||
RDIM_ProfEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2684,6 +2431,24 @@ rdim_bake_string_map_loose_push_type_slice(RDIM_Arena *arena, RDIM_BakeStringMap
|
||||
}
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_bake_string_map_loose_push_udt_member_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_UDTMember *v, RDI_U64 count)
|
||||
{
|
||||
for(RDI_U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
rdim_bake_string_map_loose_insert(arena, top, map, 4, v[idx].name);
|
||||
}
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_bake_string_map_loose_push_udt_enum_val_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_UDTEnumVal *v, RDI_U64 count)
|
||||
{
|
||||
for(RDI_U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
rdim_bake_string_map_loose_insert(arena, top, map, 4, v[idx].name);
|
||||
}
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_bake_string_map_loose_push_udt_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_UDT *v, RDI_U64 count)
|
||||
{
|
||||
|
||||
@@ -822,6 +822,8 @@ struct RDIM_UDTChunkList
|
||||
////////////////////////////////
|
||||
//~ rjf: Location Info Types
|
||||
|
||||
//- rjf: bytecode types
|
||||
|
||||
typedef struct RDIM_EvalBytecodeOp RDIM_EvalBytecodeOp;
|
||||
struct RDIM_EvalBytecodeOp
|
||||
{
|
||||
@@ -840,6 +842,8 @@ struct RDIM_EvalBytecode
|
||||
RDI_U32 encoded_size;
|
||||
};
|
||||
|
||||
//- rjf: location types
|
||||
|
||||
typedef struct RDIM_Location RDIM_Location;
|
||||
struct RDIM_Location
|
||||
{
|
||||
@@ -849,6 +853,29 @@ struct RDIM_Location
|
||||
RDIM_EvalBytecode bytecode;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
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 case types (location * voff range)
|
||||
|
||||
typedef struct RDIM_LocationCase RDIM_LocationCase;
|
||||
struct RDIM_LocationCase
|
||||
{
|
||||
@@ -1646,6 +1673,7 @@ RDI_PROC RDIM_UDT *rdim_udt_chunk_list_push(RDIM_Arena *arena, RDIM_UDTChunkList
|
||||
RDI_PROC RDI_U64 rdim_idx_from_udt(RDIM_UDT *udt);
|
||||
RDI_PROC void rdim_udt_chunk_list_concat_in_place(RDIM_UDTChunkList *dst, RDIM_UDTChunkList *to_push);
|
||||
|
||||
//- TODO(rjf): to be removed:
|
||||
RDI_PROC RDIM_UDTMember *rdim_udt_push_member(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDIM_UDT *udt);
|
||||
RDI_PROC RDIM_UDTEnumVal *rdim_udt_push_enum_val(RDIM_Arena *arena, RDIM_UDTChunkList *list, RDIM_UDT *udt);
|
||||
|
||||
@@ -1664,6 +1692,12 @@ RDI_PROC RDIM_InlineSite *rdim_inline_site_chunk_list_push(RDIM_Arena *arena, RD
|
||||
RDI_PROC RDI_U64 rdim_idx_from_inline_site(RDIM_InlineSite *inline_site);
|
||||
RDI_PROC void rdim_inline_site_chunk_list_concat_in_place(RDIM_InlineSiteChunkList *dst, RDIM_InlineSiteChunkList *to_push);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Building] Location Info Building
|
||||
|
||||
RDI_PROC RDIM_Location *rdim_location_chunk_list_push_new(RDIM_Arena *arena, RDIM_LocationChunkList *list, RDI_U64 cap, RDIM_Location *loc);
|
||||
RDI_PROC void rdim_location_chunk_list_concat_in_place(RDIM_LocationChunkList *dst, RDIM_LocationChunkList *to_push);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Building] Scope Info Building
|
||||
|
||||
@@ -1782,6 +1816,8 @@ RDI_PROC void rdim_bake_string_map_loose_push_path_tree(RDIM_Arena *arena, RDIM_
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_src_file_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_SrcFile *v, RDI_U64 count);
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_unit_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_Unit *v, RDI_U64 count);
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_type_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_Type *v, RDI_U64 count);
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_udt_member_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_UDTMember *v, RDI_U64 count);
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_udt_enum_val_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_UDTEnumVal *v, RDI_U64 count);
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_udt_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_UDT *v, RDI_U64 count);
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_symbol_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_Symbol *v, RDI_U64 count);
|
||||
RDI_PROC void rdim_bake_string_map_loose_push_inline_site_slice(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top, RDIM_BakeStringMapLoose *map, RDIM_InlineSite *v, RDI_U64 count);
|
||||
|
||||
@@ -1031,7 +1031,6 @@ rb_thread_entry_point(void *p)
|
||||
case RDI_ParseStatus_HeaderDoesNotMatch: {log_user_errorf("RDI parse failure: header does not match\n");}break;
|
||||
case RDI_ParseStatus_UnsupportedVersionNumber:{log_user_errorf("RDI parse failure: unsupported version\n");}break;
|
||||
case RDI_ParseStatus_InvalidDataSecionLayout: {log_user_errorf("RDI parse failure: invalid data section layout\n");}break;
|
||||
case RDI_ParseStatus_MissingRequiredSection: {log_user_errorf("RDI parse failure: missing required section\n");}break;
|
||||
case RDI_ParseStatus_Good:
|
||||
{
|
||||
String8List dump = rdi_dump_list_from_parsed(arena, &rdi, rdi_dump_subset_flags);
|
||||
|
||||
+41
-46
@@ -117,49 +117,49 @@ RDI_HeaderMemberTable:
|
||||
////////////////////////////////
|
||||
//~ rjf: Format Section Tables
|
||||
|
||||
@table(name name_lower element_type value is_required index_base_type desc)
|
||||
@table(name name_lower element_type value index_base_type desc)
|
||||
RDI_SectionTable:
|
||||
{
|
||||
{NULL null RDI_U8 0x0000 - - ""}
|
||||
{TopLevelInfo top_level_info RDI_TopLevelInfo 0x0001 - - ""}
|
||||
{StringData string_data RDI_U8 0x0002 x - ""}
|
||||
{StringTable string_table RDI_U32 0x0003 x U32 ""}
|
||||
{IndexRuns index_runs RDI_U32 0x0004 x U32 ""}
|
||||
{BinarySections binary_sections RDI_BinarySection 0x0005 - U32 ""}
|
||||
{FilePathNodes file_path_nodes RDI_FilePathNode 0x0006 - U32 ""}
|
||||
{SourceFiles source_files RDI_SourceFile 0x0007 - U32 ""}
|
||||
{LineTables line_tables RDI_LineTable 0x0008 - U32 ""}
|
||||
{LineInfoVOffs line_info_voffs RDI_U64 0x0009 - U32 ""}
|
||||
{LineInfoLines line_info_lines RDI_Line 0x000A - U32 ""}
|
||||
{LineInfoColumns line_info_columns RDI_Column 0x000B - U32 ""}
|
||||
{SourceLineMaps source_line_maps RDI_SourceLineMap 0x000C - U32 ""}
|
||||
{SourceLineMapNumbers source_line_map_numbers RDI_U32 0x000D - U32 ""}
|
||||
{SourceLineMapRanges source_line_map_ranges RDI_U32 0x000E - U32 ""}
|
||||
{SourceLineMapVOffs source_line_map_voffs RDI_U64 0x000F - U32 ""}
|
||||
{Units units RDI_Unit 0x0010 - U32 ""}
|
||||
{UnitVMap unit_vmap RDI_VMapEntry 0x0011 - - ""}
|
||||
{TypeNodes type_nodes RDI_TypeNode 0x0012 - U32 ""}
|
||||
{UDTs udts RDI_UDT 0x0013 - U32 ""}
|
||||
{Members members RDI_Member 0x0014 - U32 ""}
|
||||
{EnumMembers enum_members RDI_EnumMember 0x0015 - U32 ""}
|
||||
{GlobalVariables global_variables RDI_GlobalVariable 0x0016 - U32 ""}
|
||||
{GlobalVMap global_vmap RDI_VMapEntry 0x0017 - - ""}
|
||||
{ThreadVariables thread_variables RDI_ThreadVariable 0x0018 - U32 ""}
|
||||
{Constants constants RDI_Constant 0x0019 - U32 ""}
|
||||
{Procedures procedures RDI_Procedure 0x001A - U32 ""}
|
||||
{Scopes scopes RDI_Scope 0x001B - U32 ""}
|
||||
{ScopeVOffData scope_voff_data RDI_U64 0x001C - U32 ""}
|
||||
{ScopeVMap scope_vmap RDI_VMapEntry 0x001D - - ""}
|
||||
{InlineSites inline_sites RDI_InlineSite 0x001E - U32 ""}
|
||||
{Locals locals RDI_Local 0x001F - U32 ""}
|
||||
{LocationBlocks location_blocks RDI_LocationBlock 0x0020 - U32 ""}
|
||||
{LocationData location_data RDI_U8 0x0021 - U32 ""}
|
||||
{ConstantValueData constant_value_data RDI_U8 0x0022 - U32 ""}
|
||||
{ConstantValueTable constant_value_table RDI_U32 0x0023 - U32 ""}
|
||||
{NameMaps name_maps RDI_NameMap 0x0024 - U32 ""}
|
||||
{NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0025 - U32 ""}
|
||||
{NameMapNodes name_map_nodes RDI_NameMapNode 0x0026 - U32 ""}
|
||||
{COUNT count RDI_U8 0x0027 - - ""}
|
||||
{NULL null RDI_U8 0x0000 - ""}
|
||||
{TopLevelInfo top_level_info RDI_TopLevelInfo 0x0001 - ""}
|
||||
{StringData string_data RDI_U8 0x0002 - ""}
|
||||
{StringTable string_table RDI_U32 0x0003 U32 ""}
|
||||
{IndexRuns index_runs RDI_U32 0x0004 U32 ""}
|
||||
{BinarySections binary_sections RDI_BinarySection 0x0005 U32 ""}
|
||||
{FilePathNodes file_path_nodes RDI_FilePathNode 0x0006 U32 ""}
|
||||
{SourceFiles source_files RDI_SourceFile 0x0007 U32 ""}
|
||||
{LineTables line_tables RDI_LineTable 0x0008 U32 ""}
|
||||
{LineInfoVOffs line_info_voffs RDI_U64 0x0009 U32 ""}
|
||||
{LineInfoLines line_info_lines RDI_Line 0x000A U32 ""}
|
||||
{LineInfoColumns line_info_columns RDI_Column 0x000B U32 ""}
|
||||
{SourceLineMaps source_line_maps RDI_SourceLineMap 0x000C U32 ""}
|
||||
{SourceLineMapNumbers source_line_map_numbers RDI_U32 0x000D U32 ""}
|
||||
{SourceLineMapRanges source_line_map_ranges RDI_U32 0x000E U32 ""}
|
||||
{SourceLineMapVOffs source_line_map_voffs RDI_U64 0x000F U32 ""}
|
||||
{Units units RDI_Unit 0x0010 U32 ""}
|
||||
{UnitVMap unit_vmap RDI_VMapEntry 0x0011 - ""}
|
||||
{TypeNodes type_nodes RDI_TypeNode 0x0012 U32 ""}
|
||||
{UDTs udts RDI_UDT 0x0013 U32 ""}
|
||||
{Members members RDI_Member 0x0014 U32 ""}
|
||||
{EnumMembers enum_members RDI_EnumMember 0x0015 U32 ""}
|
||||
{GlobalVariables global_variables RDI_GlobalVariable 0x0016 U32 ""}
|
||||
{GlobalVMap global_vmap RDI_VMapEntry 0x0017 - ""}
|
||||
{ThreadVariables thread_variables RDI_ThreadVariable 0x0018 U32 ""}
|
||||
{Constants constants RDI_Constant 0x0019 U32 ""}
|
||||
{Procedures procedures RDI_Procedure 0x001A U32 ""}
|
||||
{Scopes scopes RDI_Scope 0x001B U32 ""}
|
||||
{ScopeVOffData scope_voff_data RDI_U64 0x001C U32 ""}
|
||||
{ScopeVMap scope_vmap RDI_VMapEntry 0x001D - ""}
|
||||
{InlineSites inline_sites RDI_InlineSite 0x001E U32 ""}
|
||||
{Locals locals RDI_Local 0x001F U32 ""}
|
||||
{LocationBlocks location_blocks RDI_LocationBlock 0x0020 U32 ""}
|
||||
{LocationData location_data RDI_U8 0x0021 U32 ""}
|
||||
{ConstantValueData constant_value_data RDI_U8 0x0022 U32 ""}
|
||||
{ConstantValueTable constant_value_table RDI_U32 0x0023 U32 ""}
|
||||
{NameMaps name_maps RDI_NameMap 0x0024 U32 ""}
|
||||
{NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0025 U32 ""}
|
||||
{NameMapNodes name_map_nodes RDI_NameMapNode 0x0026 U32 ""}
|
||||
{COUNT count RDI_U8 0x0027 - ""}
|
||||
}
|
||||
|
||||
@table(name value)
|
||||
@@ -232,11 +232,6 @@ RDI_SectionMemberTable:
|
||||
@expand(RDI_SectionTable a) `sizeof($(a.element_type))`;
|
||||
}
|
||||
|
||||
@data(RDI_U8) rdi_section_is_required_table:
|
||||
{
|
||||
@expand(RDI_SectionTable a) `$(a.is_required == 'x' -> 1)$(a.is_required != 'x' -> 0)`;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Common Type Tables
|
||||
|
||||
|
||||
@@ -889,6 +889,17 @@ p2r2_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
CV_C13Parsed *src_unit_c13 = all_c13s[idx+1];
|
||||
RDIM_Unit *dst_unit = &units[idx];
|
||||
|
||||
// rjf: produce unit name
|
||||
String8 unit_name = src_unit->obj_name;
|
||||
if(unit_name.size != 0)
|
||||
{
|
||||
String8 unit_name_past_last_slash = str8_skip_last_slash(unit_name);
|
||||
if(unit_name_past_last_slash.size != 0)
|
||||
{
|
||||
unit_name = unit_name_past_last_slash;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: produce obj name/path
|
||||
String8 obj_name = src_unit->obj_name;
|
||||
if(str8_match(obj_name, str8_lit("* Linker *"), 0) ||
|
||||
@@ -958,6 +969,16 @@ p2r2_convert(Arena *arena, P2R_ConvertParams *params)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: fill unit
|
||||
dst_unit->unit_name = unit_name;
|
||||
dst_unit->compiler_name = src_unit_sym->info.compiler_name;
|
||||
dst_unit->object_file = obj_name;
|
||||
dst_unit->archive_file = src_unit->group_name;
|
||||
dst_unit->language = p2r_rdi_language_from_cv_language(src_unit_sym->info.language);
|
||||
dst_unit->line_table = line_table;
|
||||
dst_unit->voff_ranges = unit_ranges[idx];
|
||||
|
||||
scratch_end(scratch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,13 +238,23 @@ rdim2_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: push strings from udts
|
||||
ProfScope("udts")
|
||||
// rjf: push strings from udt members
|
||||
ProfScope("udt members")
|
||||
{
|
||||
for(RDIM_UDTChunkNode *n = params->udts.first; n != 0; n = n->next)
|
||||
for EachNode(n, RDIM_UDTMemberChunkNode, params->members.first)
|
||||
{
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
rdim_bake_string_map_loose_push_udt_slice(arena, lane_map_top, lane_map, n->v + range.min, dim_1u64(range));
|
||||
rdim_bake_string_map_loose_push_udt_member_slice(arena, lane_map_top, lane_map, n->v + range.min, dim_1u64(range));
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: push strings from udt enum values
|
||||
ProfScope("udt enum values")
|
||||
{
|
||||
for EachNode(n, RDIM_UDTEnumValChunkNode, params->enum_vals.first)
|
||||
{
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
rdim_bake_string_map_loose_push_udt_enum_val_slice(arena, lane_map_top, lane_map, n->v + range.min, dim_1u64(range));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,12 +349,30 @@ rdim2_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
lane_sync();
|
||||
|
||||
//- rjf: tighten string table
|
||||
if(lane_idx() == 0) ProfScope("tighten string table")
|
||||
ProfScope("tighten string table")
|
||||
{
|
||||
RDIM_BakeStringMapLoose *map = rdim2_shared->bake_string_map__loose;
|
||||
RDIM_BakeStringMapTopology *map_top = &rdim2_shared->bake_string_map_topology;
|
||||
RDIM_BakeStringMapBaseIndices bake_string_map_base_idxes = rdim_bake_string_map_base_indices_from_map_loose(arena, map_top, map);
|
||||
rdim2_shared->bake_strings = rdim_bake_string_map_tight_from_loose(arena, map_top, &bake_string_map_base_idxes, map);
|
||||
if(lane_idx() == 0) ProfScope("calc base indices, set up tight map")
|
||||
{
|
||||
RDIM_BakeStringMapBaseIndices bake_string_map_base_indices = rdim_bake_string_map_base_indices_from_map_loose(arena, map_top, map);
|
||||
rdim2_shared->bake_strings.slots_count = map_top->slots_count;
|
||||
rdim2_shared->bake_strings.slots = rdim_push_array(arena, RDIM_BakeStringChunkList, rdim2_shared->bake_strings.slots_count);
|
||||
rdim2_shared->bake_strings.slots_base_idxs = bake_string_map_base_indices.slots_base_idxs;
|
||||
rdim2_shared->bake_strings.total_count = rdim2_shared->bake_strings.slots_base_idxs[rdim2_shared->bake_strings.slots_count];
|
||||
}
|
||||
lane_sync();
|
||||
ProfScope("fill tight map")
|
||||
{
|
||||
Rng1U64 slot_range = lane_range(rdim2_shared->bake_strings.slots_count);
|
||||
for EachInRange(idx, slot_range)
|
||||
{
|
||||
if(map->slots[idx] != 0)
|
||||
{
|
||||
rdim_memcpy_struct(&rdim2_shared->bake_strings.slots[idx], map->slots[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
@@ -1070,13 +1098,41 @@ rdim2_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: do final baking tasks
|
||||
//
|
||||
ProfScope("do final baking tasks")
|
||||
{
|
||||
if(lane_idx() == lane_from_task_idx(0)) ProfScope("bake top level info")
|
||||
{
|
||||
rdim2_shared->baked_top_level_info = rdim_bake_top_level_info(arena, bake_strings, ¶ms->top_level_info);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(1)) ProfScope("bake binary sections")
|
||||
{
|
||||
rdim2_shared->baked_binary_sections = rdim_bake_binary_sections(arena, bake_strings, ¶ms->binary_sections);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(2)) ProfScope("bake unit vmap")
|
||||
{
|
||||
rdim2_shared->baked_unit_vmap = rdim_bake_unit_vmap(arena, ¶ms->units);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(3)) ProfScope("bake scope vmap")
|
||||
{
|
||||
rdim2_shared->baked_scope_vmap = rdim_bake_scope_vmap(arena, ¶ms->scopes);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(4)) ProfScope("bake global vmap")
|
||||
{
|
||||
rdim2_shared->baked_global_vmap = rdim_bake_global_vmap(arena, ¶ms->global_variables);
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: package results
|
||||
//
|
||||
RDIM_BakeResults result = {0};
|
||||
{
|
||||
// result.top_level_info = rdim2_shared->baked_top_level_info;
|
||||
// result.binary_sections = rdim2_shared->baked_binary_sections;
|
||||
result.top_level_info = rdim2_shared->baked_top_level_info;
|
||||
result.binary_sections = rdim2_shared->baked_binary_sections;
|
||||
result.units = rdim2_shared->baked_units;
|
||||
result.unit_vmap = rdim2_shared->baked_unit_vmap;
|
||||
result.src_files = rdim2_shared->baked_src_files;
|
||||
|
||||
@@ -50,17 +50,20 @@ struct RDIM2_Shared
|
||||
RDIM_IndexRunBakeResult baked_idx_runs;
|
||||
|
||||
RDIM_UnitBakeResult baked_units;
|
||||
RDIM_UnitVMapBakeResult baked_unit_vmap;
|
||||
RDIM_SrcFileBakeResult baked_src_files;
|
||||
RDIM_TypeNodeBakeResult baked_type_nodes;
|
||||
RDIM_UDTBakeResult baked_udts;
|
||||
RDIM_GlobalVariableBakeResult baked_global_variables;
|
||||
RDIM_GlobalVMapBakeResult baked_global_vmap;
|
||||
RDIM_ThreadVariableBakeResult baked_thread_variables;
|
||||
RDIM_ConstantsBakeResult baked_constants;
|
||||
RDIM_ProcedureBakeResult baked_procedures;
|
||||
RDIM_ScopeVMapBakeResult baked_scope_vmap;
|
||||
RDIM_InlineSiteBakeResult baked_inline_sites;
|
||||
|
||||
RDIM_TopLevelInfoBakeResult baked_top_level_info;
|
||||
RDIM_BinarySectionBakeResult baked_binary_sections;
|
||||
RDIM_UnitVMapBakeResult baked_unit_vmap;
|
||||
RDIM_ScopeVMapBakeResult baked_scope_vmap;
|
||||
RDIM_GlobalVMapBakeResult baked_global_vmap;
|
||||
};
|
||||
|
||||
global RDIM2_Shared *rdim2_shared = 0;
|
||||
|
||||
Reference in New Issue
Block a user