mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-12 23:31:38 -07:00
idx run baking
This commit is contained in:
+2
-2
@@ -47,13 +47,13 @@ commands =
|
||||
{
|
||||
//- rjf: [raddbg]
|
||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
.f1 = { .win = "raddbg_stable --ipc kill_all && build radbin debug telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
.f1 = { .win = "raddbg_stable --ipc kill_all && build radbin release telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
//- rjf: [raddbg wsl]
|
||||
// .f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
//- rjf: [scratch]
|
||||
.f2 = { .win = "build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
.f2 = { .win = "build radbin debug telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
//- rjf: [textperf]
|
||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build no_meta telemetry textperf && raddbg_stable --ipc bring_to_front && raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
#define EachEnumVal(type, it) (type it = (type)0; it < type##_COUNT; it = (type)(it+1))
|
||||
#define EachNonZeroEnumVal(type, it) (type it = (type)1; it < type##_COUNT; it = (type)(it+1))
|
||||
#define EachInRange(it, range) (U64 it = (range).min; it < (range).max; it += 1)
|
||||
#define EachNode(it, T, first) (T *n = first; n != 0; n = n->next)
|
||||
#define EachNode(it, T, first) (T *it = first; it != 0; it = it->next)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Memory Operation Macros
|
||||
|
||||
+239
-5
@@ -1491,9 +1491,9 @@ rdim_bake_vmap_from_markers(RDIM_Arena *arena, RDIM_VMapMarker *markers, RDIM_So
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Interned / Deduplicated Blob Data Structure Helpers
|
||||
//~ rjf: [Baking Helpers] Deduplicated String Baking Map
|
||||
|
||||
//- rjf: bake string chunk lists
|
||||
//- rjf: chunk lists
|
||||
|
||||
RDI_PROC RDIM_BakeString *
|
||||
rdim_bake_string_chunk_list_push(RDIM_Arena *arena, RDIM_BakeStringChunkList *list, RDI_U64 cap)
|
||||
@@ -1614,7 +1614,7 @@ rdim_bake_string_chunk_list_sorted_from_unsorted(RDIM_Arena *arena, RDIM_BakeStr
|
||||
return dst;
|
||||
}
|
||||
|
||||
//- rjf: bake string chunk list maps
|
||||
//- rjf: loose map
|
||||
|
||||
RDI_PROC RDIM_BakeStringMapLoose *
|
||||
rdim_bake_string_map_loose_make(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top)
|
||||
@@ -1693,7 +1693,7 @@ rdim_bake_string_map_base_indices_from_map_loose(RDIM_Arena *arena, RDIM_BakeStr
|
||||
return indices;
|
||||
}
|
||||
|
||||
//- rjf: finalized bake string map
|
||||
//- rjf: finalized / tight map
|
||||
|
||||
RDI_PROC RDIM_BakeStringMapTight
|
||||
rdim_bake_string_map_tight_from_loose(RDIM_Arena *arena, RDIM_BakeStringMapTopology *map_topology, RDIM_BakeStringMapBaseIndices *map_base_indices, RDIM_BakeStringMapLoose *map)
|
||||
@@ -1736,7 +1736,238 @@ rdim_bake_idx_from_string(RDIM_BakeStringMapTight *map, RDIM_String8 string)
|
||||
return idx;
|
||||
}
|
||||
|
||||
//- rjf: bake name chunk list
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Deduplicated Index Run Baking Map
|
||||
|
||||
//- rjf: chunk lists
|
||||
|
||||
RDI_PROC RDIM_BakeIdxRun *
|
||||
rdim_bake_idx_run_chunk_list_push(RDIM_Arena *arena, RDIM_BakeIdxRunChunkList *list, RDI_U64 cap)
|
||||
{
|
||||
RDIM_BakeIdxRunChunkNode *n = list->last;
|
||||
if(n == 0 || n->count >= n->cap)
|
||||
{
|
||||
n = rdim_push_array(arena, RDIM_BakeIdxRunChunkNode, 1);
|
||||
n->cap = cap;
|
||||
n->v = rdim_push_array(arena, RDIM_BakeIdxRun, n->cap);
|
||||
RDIM_SLLQueuePush(list->first, list->last, n);
|
||||
list->chunk_count += 1;
|
||||
}
|
||||
RDIM_BakeIdxRun *s = &n->v[n->count];
|
||||
n->count += 1;
|
||||
list->total_count += 1;
|
||||
return s;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_bake_idx_run_chunk_list_concat_in_place(RDIM_BakeIdxRunChunkList *dst, RDIM_BakeIdxRunChunkList *to_push)
|
||||
{
|
||||
for(RDIM_BakeIdxRunChunkNode *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);
|
||||
}
|
||||
|
||||
RSFORCEINLINE int
|
||||
rdim_bake_idx_run_is_before(void *l, void *r)
|
||||
{
|
||||
return ((RDIM_BakeIdxRun *)l)->hash < ((RDIM_BakeIdxRun *)r)->hash;
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_BakeIdxRunChunkList
|
||||
rdim_bake_idx_run_chunk_list_sorted_from_unsorted(RDIM_Arena *arena, RDIM_BakeIdxRunChunkList *src)
|
||||
{
|
||||
//- rjf: produce unsorted destination list with single chunk node
|
||||
RDIM_BakeIdxRunChunkList dst = {0};
|
||||
for(RDIM_BakeIdxRunChunkNode *n = src->first; n != 0; n = n->next)
|
||||
{
|
||||
for(RDI_U64 idx = 0; idx < n->count; idx += 1)
|
||||
{
|
||||
RDIM_BakeIdxRun *src_str = &n->v[idx];
|
||||
RDIM_BakeIdxRun *dst_str = rdim_bake_idx_run_chunk_list_push(arena, &dst, src->total_count);
|
||||
rdim_memcpy_struct(dst_str, src_str);
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: sort chunk node
|
||||
if(dst.first != 0)
|
||||
{
|
||||
radsort(dst.first->v, dst.first->count, rdim_bake_idx_run_is_before);
|
||||
}
|
||||
|
||||
//- rjf: iterate sorted chunk node, remove duplicates, count # of duplicates
|
||||
RDI_U64 num_duplicates = 0;
|
||||
if(dst.first != 0)
|
||||
{
|
||||
RDI_U64 last_idx = 0;
|
||||
for(RDI_U64 idx = 1; idx < dst.first->count; idx += 1)
|
||||
{
|
||||
if(dst.first->v[last_idx].hash == dst.first->v[idx].hash)
|
||||
{
|
||||
rdim_memzero_struct(&dst.first->v[idx]);
|
||||
num_duplicates += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_idx = idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: iterate sorted chunk node, make non-empty elements contiguous
|
||||
if(num_duplicates != 0)
|
||||
{
|
||||
RDI_U64 last_idx = 0;
|
||||
for(RDI_U64 idx = 1; idx < dst.first->count; idx += 1)
|
||||
{
|
||||
if(last_idx == 0 && dst.first->v[idx].hash == 0)
|
||||
{
|
||||
last_idx = idx;
|
||||
}
|
||||
if(last_idx != 0 && dst.first->v[idx].hash != 0)
|
||||
{
|
||||
rdim_memcpy_struct(&dst.first->v[last_idx], &dst.first->v[idx]);
|
||||
rdim_memzero_struct(&dst.first->v[idx]);
|
||||
last_idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: pop extras
|
||||
if(num_duplicates != 0)
|
||||
{
|
||||
RDI_U64 arena_pos_pre_pop = rdim_arena_pos(arena);
|
||||
rdim_arena_pop_to(arena, arena_pos_pre_pop - num_duplicates*sizeof(dst.first->v[0]));
|
||||
dst.first->count -= num_duplicates;
|
||||
dst.first->cap -= num_duplicates;
|
||||
dst.total_count -= num_duplicates;
|
||||
}
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
//- rjf: loose map
|
||||
|
||||
RDI_PROC RDIM_BakeIdxRunMapLoose *
|
||||
rdim_bake_idx_run_map_loose_make(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *top)
|
||||
{
|
||||
RDIM_BakeIdxRunMapLoose *map = rdim_push_array(arena, RDIM_BakeIdxRunMapLoose, 1);
|
||||
map->slots = rdim_push_array(arena, RDIM_BakeIdxRunChunkList *, top->slots_count);
|
||||
return map;
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdim_bake_idx_run_map_loose_insert(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *map_topology, RDIM_BakeIdxRunMapLoose *map, RDI_U64 chunk_cap, RDI_U32 *idxes, RDI_U32 count)
|
||||
{
|
||||
if(count != 0)
|
||||
{
|
||||
RDI_U64 hash = rdim_hash_from_idx_run(idxes, count);
|
||||
RDI_U64 slot_idx = hash%map_topology->slots_count;
|
||||
RDIM_BakeIdxRunChunkList *slot = map->slots[slot_idx];
|
||||
if(slot == 0)
|
||||
{
|
||||
slot = map->slots[slot_idx] = rdim_push_array(arena, RDIM_BakeIdxRunChunkList, 1);
|
||||
}
|
||||
RDI_S32 is_duplicate = 0;
|
||||
for(RDIM_BakeIdxRunChunkNode *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
for(RDI_U64 idx = 0; idx < n->count; idx += 1)
|
||||
{
|
||||
if(n->v[idx].hash == hash)
|
||||
{
|
||||
is_duplicate = 1;
|
||||
goto break_all;
|
||||
}
|
||||
}
|
||||
}
|
||||
break_all:;
|
||||
if(!is_duplicate)
|
||||
{
|
||||
RDIM_BakeIdxRun *bir = rdim_bake_idx_run_chunk_list_push(arena, slot, chunk_cap);
|
||||
bir->hash = hash;
|
||||
bir->count = count;
|
||||
bir->idxes = idxes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_BakeIdxRunMapBaseIndices
|
||||
rdim_bake_idx_run_map_base_indices_from_map_loose(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *map_topology, RDIM_BakeIdxRunMapLoose *map)
|
||||
{
|
||||
RDIM_BakeIdxRunMapBaseIndices indices = {0};
|
||||
indices.slots_base_idxs = rdim_push_array(arena, RDI_U64, map_topology->slots_count+1);
|
||||
RDI_U64 total_count = 0;
|
||||
for(RDI_U64 idx = 0; idx < map_topology->slots_count; idx += 1)
|
||||
{
|
||||
indices.slots_base_idxs[idx] += total_count;
|
||||
if(map->slots[idx] != 0)
|
||||
{
|
||||
total_count += map->slots[idx]->total_count;
|
||||
}
|
||||
}
|
||||
indices.slots_base_idxs[map_topology->slots_count] = total_count;
|
||||
return indices;
|
||||
}
|
||||
|
||||
//- rjf: finalized / tight map
|
||||
|
||||
RDI_PROC RDIM_BakeIdxRunMap2 *
|
||||
rdim_bake_idx_run_map_from_loose(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *map_topology, RDIM_BakeIdxRunMapBaseIndices *map_base_indices, RDIM_BakeIdxRunMapLoose *map)
|
||||
{
|
||||
RDIM_BakeIdxRunMap2 *m = rdim_push_array(arena, RDIM_BakeIdxRunMap2, 1);
|
||||
m->slots_count = map_topology->slots_count;
|
||||
m->slots = rdim_push_array(arena, RDIM_BakeIdxRunChunkList, m->slots_count);
|
||||
m->slots_base_idxs = map_base_indices->slots_base_idxs;
|
||||
for(RDI_U64 idx = 0; idx < m->slots_count; idx += 1)
|
||||
{
|
||||
if(map->slots[idx] != 0)
|
||||
{
|
||||
rdim_memcpy_struct(&m->slots[idx], map->slots[idx]);
|
||||
}
|
||||
}
|
||||
m->total_count = m->slots_base_idxs[m->slots_count];
|
||||
return m;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U32
|
||||
rdim_bake_idx_from_idx_run_2(RDIM_BakeIdxRunMap2 *map, RDI_U32 *idxes, RDI_U32 count)
|
||||
{
|
||||
RDI_U32 idx = 0;
|
||||
if(count != 0)
|
||||
{
|
||||
RDI_U64 hash = rdim_hash_from_idx_run(idxes, count);
|
||||
RDI_U64 slot_idx = hash%map->slots_count;
|
||||
for(RDIM_BakeIdxRunChunkNode *n = map->slots[slot_idx].first; n != 0; n = n->next)
|
||||
{
|
||||
for(RDI_U64 chunk_idx = 0; chunk_idx < n->count; chunk_idx += 1)
|
||||
{
|
||||
if(n->v[chunk_idx].hash == hash)
|
||||
{
|
||||
idx = map->slots_base_idxs[slot_idx] + n->base_idx + chunk_idx + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Deduplicated Name Map Baking Map
|
||||
|
||||
//- rjf: chunk lists
|
||||
|
||||
RDI_PROC RDIM_BakeName *
|
||||
rdim_bake_name_chunk_list_push(RDIM_Arena *arena, RDIM_BakeNameChunkList *list, RDI_U64 cap)
|
||||
@@ -1903,6 +2134,9 @@ rdim_bake_name_map_2_insert(RDIM_Arena *arena, RDIM_BakeNameMapTopology *map_top
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Interned / Deduplicated Blob Data Structure Helpers
|
||||
|
||||
//- rjf: bake idx run map reading/writing
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
|
||||
@@ -1049,6 +1049,62 @@ struct RDIM_BakeStringMapTight
|
||||
|
||||
//- rjf: index runs
|
||||
|
||||
typedef struct RDIM_BakeIdxRun RDIM_BakeIdxRun;
|
||||
struct RDIM_BakeIdxRun
|
||||
{
|
||||
RDI_U64 hash;
|
||||
RDI_U64 count;
|
||||
RDI_U32 *idxes;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeIdxRunChunkNode RDIM_BakeIdxRunChunkNode;
|
||||
struct RDIM_BakeIdxRunChunkNode
|
||||
{
|
||||
RDIM_BakeIdxRunChunkNode *next;
|
||||
RDIM_BakeIdxRun *v;
|
||||
RDI_U64 count;
|
||||
RDI_U64 cap;
|
||||
RDI_U64 base_idx;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeIdxRunChunkList RDIM_BakeIdxRunChunkList;
|
||||
struct RDIM_BakeIdxRunChunkList
|
||||
{
|
||||
RDIM_BakeIdxRunChunkNode *first;
|
||||
RDIM_BakeIdxRunChunkNode *last;
|
||||
RDI_U64 chunk_count;
|
||||
RDI_U64 total_count;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeIdxRunMapTopology RDIM_BakeIdxRunMapTopology;
|
||||
struct RDIM_BakeIdxRunMapTopology
|
||||
{
|
||||
RDI_U64 slots_count;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeIdxRunMapBaseIndices RDIM_BakeIdxRunMapBaseIndices;
|
||||
struct RDIM_BakeIdxRunMapBaseIndices
|
||||
{
|
||||
RDI_U64 *slots_base_idxs;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeIdxRunMapLoose RDIM_BakeIdxRunMapLoose;
|
||||
struct RDIM_BakeIdxRunMapLoose
|
||||
{
|
||||
RDIM_BakeIdxRunChunkList **slots;
|
||||
};
|
||||
|
||||
typedef struct RDIM_BakeIdxRunMap2 RDIM_BakeIdxRunMap2;
|
||||
struct RDIM_BakeIdxRunMap2
|
||||
{
|
||||
RDIM_BakeIdxRunChunkList *slots;
|
||||
RDI_U64 *slots_base_idxs;
|
||||
RDI_U64 slots_count;
|
||||
RDI_U64 total_count;
|
||||
};
|
||||
|
||||
//- rjf: index runs (OLD)
|
||||
|
||||
typedef struct RDIM_BakeIdxRunNode RDIM_BakeIdxRunNode;
|
||||
struct RDIM_BakeIdxRunNode
|
||||
{
|
||||
@@ -1582,24 +1638,44 @@ RDI_PROC RDI_U32 rdim_count_from_location_block_chunk_list(RDIM_String8List *lis
|
||||
RDI_PROC RDIM_BakeVMap rdim_bake_vmap_from_markers(RDIM_Arena *arena, RDIM_VMapMarker *markers, RDIM_SortKey *keys, RDI_U64 marker_count);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Interned / Deduplicated Blob Data Structure Helpers
|
||||
//~ rjf: [Baking Helpers] Deduplicated String Baking Map
|
||||
|
||||
//- rjf: bake string chunk lists
|
||||
//- rjf: chunk lists
|
||||
RDI_PROC RDIM_BakeString *rdim_bake_string_chunk_list_push(RDIM_Arena *arena, RDIM_BakeStringChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC void rdim_bake_string_chunk_list_concat_in_place(RDIM_BakeStringChunkList *dst, RDIM_BakeStringChunkList *to_push);
|
||||
RDI_PROC RDIM_BakeStringChunkList rdim_bake_string_chunk_list_sorted_from_unsorted(RDIM_Arena *arena, RDIM_BakeStringChunkList *src);
|
||||
|
||||
//- rjf: bake string chunk list maps
|
||||
//- rjf: loose map
|
||||
RDI_PROC RDIM_BakeStringMapLoose *rdim_bake_string_map_loose_make(RDIM_Arena *arena, RDIM_BakeStringMapTopology *top);
|
||||
RDI_PROC void rdim_bake_string_map_loose_insert(RDIM_Arena *arena, RDIM_BakeStringMapTopology *map_topology, RDIM_BakeStringMapLoose *map, RDI_U64 chunk_cap, RDIM_String8 string);
|
||||
RDI_PROC void rdim_bake_string_map_loose_join_in_place(RDIM_BakeStringMapTopology *map_topology, RDIM_BakeStringMapLoose *dst, RDIM_BakeStringMapLoose *src);
|
||||
RDI_PROC RDIM_BakeStringMapBaseIndices rdim_bake_string_map_base_indices_from_map_loose(RDIM_Arena *arena, RDIM_BakeStringMapTopology *map_topology, RDIM_BakeStringMapLoose *map);
|
||||
|
||||
//- rjf: finalized bake string map
|
||||
//- rjf: finalized / tight map
|
||||
RDI_PROC RDIM_BakeStringMapTight rdim_bake_string_map_tight_from_loose(RDIM_Arena *arena, RDIM_BakeStringMapTopology *map_topology, RDIM_BakeStringMapBaseIndices *map_base_indices, RDIM_BakeStringMapLoose *map);
|
||||
RDI_PROC RDI_U32 rdim_bake_idx_from_string(RDIM_BakeStringMapTight *map, RDIM_String8 string);
|
||||
|
||||
//- rjf: bake name chunk list
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Deduplicated Index Run Baking Map
|
||||
|
||||
//- rjf: chunk lists
|
||||
RDI_PROC RDIM_BakeIdxRun *rdim_bake_idx_run_chunk_list_push(RDIM_Arena *arena, RDIM_BakeIdxRunChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC void rdim_bake_idx_run_chunk_list_concat_in_place(RDIM_BakeIdxRunChunkList *dst, RDIM_BakeIdxRunChunkList *to_push);
|
||||
RDI_PROC RDIM_BakeIdxRunChunkList rdim_bake_idx_run_chunk_list_sorted_from_unsorted(RDIM_Arena *arena, RDIM_BakeIdxRunChunkList *src);
|
||||
|
||||
//- rjf: loose map
|
||||
RDI_PROC RDIM_BakeIdxRunMapLoose *rdim_bake_idx_run_map_loose_make(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *top);
|
||||
RDI_PROC void rdim_bake_idx_run_map_loose_insert(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *map_topology, RDIM_BakeIdxRunMapLoose *map, RDI_U64 chunk_cap, RDI_U32 *idxes, RDI_U32 count);
|
||||
RDI_PROC RDIM_BakeIdxRunMapBaseIndices rdim_bake_idx_run_map_base_indices_from_map_loose(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *map_topology, RDIM_BakeIdxRunMapLoose *map);
|
||||
|
||||
//- rjf: finalized / tight map
|
||||
RDI_PROC RDIM_BakeIdxRunMap2 *rdim_bake_idx_run_map_from_loose(RDIM_Arena *arena, RDIM_BakeIdxRunMapTopology *map_topology, RDIM_BakeIdxRunMapBaseIndices *map_base_indices, RDIM_BakeIdxRunMapLoose *map);
|
||||
RDI_PROC RDI_U32 rdim_bake_idx_from_idx_run_2(RDIM_BakeIdxRunMap2 *map, RDI_U32 *idxes, RDI_U32 count);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Deduplicated Name Map Baking Map
|
||||
|
||||
//- rjf: chunk lists
|
||||
RDI_PROC RDIM_BakeName *rdim_bake_name_chunk_list_push(RDIM_Arena *arena, RDIM_BakeNameChunkList *list, RDI_U64 cap);
|
||||
RDI_PROC void rdim_bake_name_chunk_list_concat_in_place(RDIM_BakeNameChunkList *dst, RDIM_BakeNameChunkList *to_push);
|
||||
RDI_PROC RDIM_BakeNameChunkList rdim_bake_name_chunk_list_sorted_from_unsorted(RDIM_Arena *arena, RDIM_BakeNameChunkList *src);
|
||||
@@ -1608,6 +1684,9 @@ RDI_PROC RDIM_BakeNameChunkList rdim_bake_name_chunk_list_sorted_from_unsorted(R
|
||||
RDI_PROC RDIM_BakeNameMap2 *rdim_bake_name_map_2_make(RDIM_Arena *arena, RDIM_BakeNameMapTopology *top);
|
||||
RDI_PROC void rdim_bake_name_map_2_insert(RDIM_Arena *arena, RDIM_BakeNameMapTopology *map_topology, RDIM_BakeNameMap2 *map, RDI_U64 chunk_cap, RDIM_String8 string, RDI_U64 idx);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Interned / Deduplicated Blob Data Structure Helpers
|
||||
|
||||
//- rjf: bake idx run map reading/writing
|
||||
RDI_PROC RDI_U64 rdim_hash_from_idx_run(RDI_U32 *idx_run, RDI_U32 count);
|
||||
RDI_PROC RDI_U32 rdim_bake_idx_from_idx_run(RDIM_BakeIdxRunMap *map, RDI_U32 *idx_run, RDI_U32 count);
|
||||
|
||||
+161
-10
@@ -496,7 +496,153 @@ rdim2_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
lane_sync();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: bake units, src files, symbols, UDTs
|
||||
//- rjf: bake index runs
|
||||
//
|
||||
ProfScope("bake index runs")
|
||||
{
|
||||
//- rjf: set up per-lane outputs
|
||||
if(lane_idx() == 0) ProfScope("set up per-lane outputs")
|
||||
{
|
||||
rdim2_shared->bake_idx_run_map_topology.slots_count = (64 +
|
||||
params->procedures.total_count +
|
||||
params->global_variables.total_count +
|
||||
params->thread_variables.total_count +
|
||||
params->types.total_count);
|
||||
rdim2_shared->lane_bake_idx_run_maps__loose = push_array(arena, RDIM_BakeIdxRunMapLoose *, lane_count());
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
//- rjf: set up this lane's map
|
||||
ProfScope("set up this lane's map")
|
||||
{
|
||||
rdim2_shared->lane_bake_idx_run_maps__loose[lane_idx()] = rdim_bake_idx_run_map_loose_make(arena, &rdim2_shared->bake_idx_run_map_topology);
|
||||
}
|
||||
RDIM_BakeIdxRunMapTopology *lane_map_top = &rdim2_shared->bake_idx_run_map_topology;
|
||||
RDIM_BakeIdxRunMapLoose *lane_map = rdim2_shared->lane_bake_idx_run_maps__loose[lane_idx()];
|
||||
|
||||
//- rjf: wide fill of all index runs
|
||||
ProfScope("fill all lane index run maps")
|
||||
{
|
||||
//- rjf: bake runs of function-type parameter lists
|
||||
ProfScope("bake runs of function-type parameter lists")
|
||||
{
|
||||
for EachNode(n, RDIM_TypeChunkNode, params->types.first)
|
||||
{
|
||||
Rng1U64 range = lane_range(n->count);
|
||||
ProfScope("[%I64u, %I64u)", range.min, range.max) for EachInRange(n_idx, range)
|
||||
{
|
||||
RDIM_Type *type = &n->v[n_idx];
|
||||
if(type->count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(type->kind == RDI_TypeKind_Function || type->kind == RDI_TypeKind_Method)
|
||||
{
|
||||
RDI_U32 param_idx_run_count = type->count;
|
||||
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
|
||||
}
|
||||
rdim_bake_idx_run_map_loose_insert(arena, lane_map_top, lane_map, 4, param_idx_run, param_idx_run_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: bake runs of name map match lists
|
||||
for EachNonZeroEnumVal(RDI_NameMapKind, k) ProfScope("bake runs of name map match lists (%.*s)", str8_varg(rdi_string_from_name_map_kind(k)))
|
||||
{
|
||||
RDIM_BakeNameMapTopology *top = &rdim2_shared->bake_name_map_topology[k];
|
||||
RDIM_BakeNameMap2 *map = rdim2_shared->bake_name_maps[k];
|
||||
Rng1U64 slot_idx_range = lane_range(top->slots_count);
|
||||
for EachInRange(slot_idx, slot_idx_range)
|
||||
{
|
||||
RDIM_BakeNameChunkList *slot = map->slots[slot_idx];
|
||||
if(slot != 0)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
typedef struct IdxRunNode IdxRunNode;
|
||||
struct IdxRunNode
|
||||
{
|
||||
IdxRunNode *next;
|
||||
RDI_U64 idx;
|
||||
};
|
||||
IdxRunNode *first_idx_run_node = 0;
|
||||
IdxRunNode *last_idx_run_node = 0;
|
||||
U64 active_idx_count = 0;
|
||||
U64 active_hash = 0;
|
||||
RDIM_BakeNameChunkNode *n = slot->first;
|
||||
U64 n_idx = 0;
|
||||
for(;;)
|
||||
{
|
||||
// rjf: advance chunk
|
||||
if(n != 0 && n_idx >= n->count)
|
||||
{
|
||||
n = n->next;
|
||||
n_idx = 0;
|
||||
}
|
||||
|
||||
// rjf: grab next element
|
||||
U64 hash = 0;
|
||||
U64 idx = 0;
|
||||
if(n != 0)
|
||||
{
|
||||
hash = n->v[n_idx].hash;
|
||||
idx = n->v[n_idx].idx;
|
||||
}
|
||||
|
||||
// rjf: next element hash doesn't match the active? -> push index run, clear active list, start new list
|
||||
if(hash != active_hash && active_idx_count != 0)
|
||||
{
|
||||
if(active_idx_count > 1)
|
||||
{
|
||||
RDI_U64 idxs_count = active_idx_count;
|
||||
RDI_U32 *idxs = rdim_push_array(arena, RDI_U32, idxs_count);
|
||||
{
|
||||
U64 write_idx = 0;
|
||||
for EachNode(idx_run_n, IdxRunNode, first_idx_run_node)
|
||||
{
|
||||
idxs[write_idx] = (RDI_U32)idx_run_n->idx; // TODO(rjf): @u64_to_u32
|
||||
write_idx += 1;
|
||||
}
|
||||
}
|
||||
rdim_bake_idx_run_map_loose_insert(arena, lane_map_top, lane_map, 4, idxs, idxs_count);
|
||||
}
|
||||
active_hash = hash;
|
||||
first_idx_run_node = 0;
|
||||
last_idx_run_node = 0;
|
||||
temp_end(scratch);
|
||||
}
|
||||
|
||||
// rjf: hash matches the active list -> push
|
||||
if(hash != 0 && hash == active_hash)
|
||||
{
|
||||
IdxRunNode *idx_run_n = push_array(scratch.arena, IdxRunNode, 1);
|
||||
idx_run_n->idx = idx;
|
||||
SLLQueuePush(first_idx_run_node, last_idx_run_node, idx_run_n);
|
||||
active_idx_count += 1;
|
||||
}
|
||||
|
||||
// rjf: advance index
|
||||
n_idx += 1;
|
||||
|
||||
// rjf: end on zero node
|
||||
if(n == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//- rjf: bake units, src files, symbols, types, UDTs
|
||||
//
|
||||
{
|
||||
//- rjf: setup outputs
|
||||
@@ -516,51 +662,56 @@ rdim2_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
rdim2_shared->baked_src_files.source_line_maps = push_array(arena, RDI_SourceLineMap, rdim2_shared->baked_src_files.source_line_maps_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(3))
|
||||
{
|
||||
rdim2_shared->baked_type_nodes.type_nodes_count = params->types.total_count+1;
|
||||
rdim2_shared->baked_type_nodes.type_nodes = push_array(arena, RDI_TypeNode, rdim2_shared->baked_type_nodes.type_nodes_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(4))
|
||||
{
|
||||
rdim2_shared->baked_udts.udts_count = params->udts.total_count+1;
|
||||
rdim2_shared->baked_udts.udts = push_array(arena, RDI_UDT, rdim2_shared->baked_udts.udts_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(4))
|
||||
if(lane_idx() == lane_from_task_idx(5))
|
||||
{
|
||||
rdim2_shared->baked_udts.members_count = params->udts.total_member_count+1;
|
||||
rdim2_shared->baked_udts.members = push_array(arena, RDI_Member, rdim2_shared->baked_udts.members_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(5))
|
||||
if(lane_idx() == lane_from_task_idx(6))
|
||||
{
|
||||
rdim2_shared->baked_udts.enum_members_count = params->udts.total_enum_val_count+1;
|
||||
rdim2_shared->baked_udts.enum_members = push_array(arena, RDI_EnumMember, rdim2_shared->baked_udts.enum_members_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(6))
|
||||
if(lane_idx() == lane_from_task_idx(7))
|
||||
{
|
||||
rdim2_shared->baked_global_variables.global_variables_count = params->global_variables.total_count+1;
|
||||
rdim2_shared->baked_global_variables.global_variables = push_array(arena, RDI_GlobalVariable, rdim2_shared->baked_global_variables.global_variables_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(7))
|
||||
if(lane_idx() == lane_from_task_idx(8))
|
||||
{
|
||||
rdim2_shared->baked_thread_variables.thread_variables_count = params->thread_variables.total_count+1;
|
||||
rdim2_shared->baked_thread_variables.thread_variables = push_array(arena, RDI_ThreadVariable, rdim2_shared->baked_thread_variables.thread_variables_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(8))
|
||||
if(lane_idx() == lane_from_task_idx(9))
|
||||
{
|
||||
rdim2_shared->baked_constants.constants_count = params->constants.total_count+1;
|
||||
rdim2_shared->baked_constants.constants = push_array(arena, RDI_Constant, rdim2_shared->baked_constants.constants_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(9))
|
||||
if(lane_idx() == lane_from_task_idx(10))
|
||||
{
|
||||
rdim2_shared->baked_constants.constant_values_count = params->constants.total_count+1;
|
||||
rdim2_shared->baked_constants.constant_values = push_array(arena, RDI_U32, rdim2_shared->baked_constants.constant_values_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(10))
|
||||
if(lane_idx() == lane_from_task_idx(11))
|
||||
{
|
||||
rdim2_shared->baked_constants.constant_value_data_size = params->constants.total_value_data_size;
|
||||
rdim2_shared->baked_constants.constant_value_data = push_array(arena, RDI_U8, rdim2_shared->baked_constants.constant_value_data_size);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(11))
|
||||
if(lane_idx() == lane_from_task_idx(12))
|
||||
{
|
||||
rdim2_shared->baked_procedures.procedures_count = params->procedures.total_count+1;
|
||||
rdim2_shared->baked_procedures.procedures = push_array(arena, RDI_Procedure, rdim2_shared->baked_procedures.procedures_count);
|
||||
}
|
||||
if(lane_idx() == lane_from_task_idx(12))
|
||||
if(lane_idx() == lane_from_task_idx(13))
|
||||
{
|
||||
rdim2_shared->baked_inline_sites.inline_sites_count = params->inline_sites.total_count+1;
|
||||
rdim2_shared->baked_inline_sites.inline_sites = push_array(arena, RDI_InlineSite, rdim2_shared->baked_inline_sites.inline_sites_count);
|
||||
|
||||
@@ -41,9 +41,15 @@ struct RDIM2_Shared
|
||||
RDIM_BakeNameMap2 **lane_bake_name_maps[RDI_NameMapKind_COUNT];
|
||||
RDIM_BakeNameMap2 *bake_name_maps[RDI_NameMapKind_COUNT];
|
||||
|
||||
RDIM_BakeIdxRunMapTopology bake_idx_run_map_topology;
|
||||
RDIM_BakeIdxRunMapLoose **lane_bake_idx_run_maps__loose;
|
||||
RDIM_BakeIdxRunMapLoose *bake_idx_run_map__loose;
|
||||
RDIM_BakeIdxRunMap2 *bake_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;
|
||||
|
||||
Reference in New Issue
Block a user