UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
syms_data_structures.c
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#if !defined(SYMS_DATA_STRUCTURES_C)
4#define SYMS_DATA_STRUCTURES_C
5
7//~ allen: Syms String Cons
8
11 SYMS_ProfBegin("syms_string_cons");
12 SYMS_String8 result = {0};
13 if (SYMS_STRING_CONS_BUCKET_COUNT > 0 && string.size > 0){
14 SYMS_U64 hash = syms_hash_djb2(string);
16 for (SYMS_StringConsNode *node = cons->buckets[bucket_index];
17 node != 0;
18 node = node->next){
19 if (node->hash == hash && syms_string_match(string, node->string, 0)){
20 result = node->string;
21 break;
22 }
23 }
24 if (result.str == 0){
25 // stabilize the string memory
27 // save a cons node
30 new_node->string = stable_string;
31 new_node->hash = hash;
32 result = new_node->string;
33 }
34 }
36 return(result);
37}
38
39
42 SYMS_DataIdxCons result = {0};
43 result.bucket_count = bucket_count;
44 result.buckets = syms_push_array_zero(arena, SYMS_DataIdxConsNode*, bucket_count);
45 return(result);
46}
47
50 SYMS_ProfBegin("syms_data_idx_cons");
51 SYMS_U64 result = 0;
52 if (cons->bucket_count > 0 && data.size > 0){
53 SYMS_U64 hash = syms_hash_djb2(data);
55 for (SYMS_DataIdxConsNode *node = cons->buckets[bucket_index];
56 node != 0;
57 node = node->bucket_next){
58 if (node->hash == hash && syms_string_match(data, node->data, 0)){
59 result = node->id;
60 break;
61 }
62 }
63 if (result == 0){
64 // take a new id
65 SYMS_U64 new_id = cons->count + 1;
66 // stabilize the data memory
68 // save a cons node
70 SYMS_StackPush_N(cons->buckets[bucket_index], new_node, bucket_next);
71 SYMS_QueuePush_N(cons->first, cons->last, new_node, all_next);
72 cons->count += 1;
73 cons->total_size += data.size;
74 new_node->data = stable_data;
75 new_node->hash = hash;
76 new_node->id = new_id;
77 result = new_id;
78 }
79 }
81 return(result);
82}
83
84
86//~ allen: U64 Set
87
90 SYMS_U64Set result = {0};
91 result.cap = cap;
92 result.vals = syms_push_array_zero(arena, SYMS_U64, cap);
93 return(result);
94}
95
98 SYMS_ProfBegin("syms_u64_set__bs");
99 //- binary search:
100 // min index s.t. x <= vals[index]
101 // set->count if no such index exists
102 // in this one we assume:
103 // (i != j) implies (vals[i] != vals[j])
104 // thus if (vals[index] == x) then index already satisfies the requirement
105 SYMS_U64 count = set->count;
106 SYMS_U64 *vals = set->vals;
107 SYMS_U64 result = set->count;
108 if (count > 0 && x <= vals[count - 1]){
109 SYMS_U64 first = 0;
110 SYMS_U64 opl = count;
111 for (;;){
112 if (first + 1 >= opl){
113 break;
114 }
115 SYMS_U64 mid = (first + opl - 1)/2;
116 SYMS_U64 v = vals[mid];
117 if (x < v){
118 opl = mid + 1;
119 }
120 else if (x > v){
121 first = mid + 1;
122 }
123 else{
124 first = mid;
125 break;
126 }
127 }
128 result = first;
129 }
130 SYMS_ProfEnd();
131 return(result);
132}
133
136 SYMS_ProfBegin("syms_u64_set_insert");
137 SYMS_B32 result = 0;
138 SYMS_U64 index = syms_u64_set__bs(set, x);
139 SYMS_U64 *vals = set->vals;
140 SYMS_U64 count = set->count;
141 if (index < set->cap && (index == count || vals[index] != x)){
142 syms_memmove(vals + index + 1, vals + index,
143 sizeof(SYMS_U64)*(count - index));
144 vals[index] = x;
145 set->count = count + 1;
146 result = 1;
147 }
148 SYMS_ProfEnd();
149 return(result);
150}
151
152SYMS_API void
154 SYMS_ProfBegin("syms_u64_set_erase");
155 SYMS_U64 index = syms_u64_set__bs(set, x);
156 SYMS_U64 *vals = set->vals;
157 SYMS_U64 count = set->count;
158 if (index < count && vals[index] == x){
159 syms_memmove(vals + index, vals + index + 1,
160 sizeof(SYMS_U64)*(count - index - 1));
161 set->count = count - 1;
162 }
163 SYMS_ProfEnd();
164}
165
166
168//~ allen: Syms Spatial Mapping
169
170//- lookups into spatial maps
173 SYMS_ProfBegin("syms_spatial_map_1d_binary_search");
174 //- binary search:
175 // max index s.t. ranges[index].range.min <= x
176 // SYMS_U64_MAX if no such index exists
177 // in this one we assume:
178 // (i != j) implies (ranges[i].range.min != ranges[j].range.min)
179 // thus if (ranges[index].range.min == x) then index already satisfies the requirement
180 SYMS_U64 result = SYMS_U64_MAX;
181 SYMS_SpatialMap1DRange *ranges = map->ranges;
182 SYMS_U64 count = map->count;
183 if (count > 0 && ranges[0].range.min <= x){
184 SYMS_U64 first = 0;
185 SYMS_U64 opl = count;
186 for (;;){
187 SYMS_U64 mid = (first + opl)/2;
188 SYMS_U64 rmin = ranges[mid].range.min;
189 if (x < rmin){
190 opl = mid;
191 }
192 else if (x > rmin){
193 first = mid;
194 }
195 else{
196 first = mid;
197 break;
198 }
199 if (first + 1 >= opl){
200 break;
201 }
202 }
203 result = first;
204 }
205
206 SYMS_ProfEnd();
207 return(result);
208}
209
212 SYMS_ProfBegin("syms_spatial_map_1d_index_from_point");
214 //- check if the range actually contains x
215 // (if we have a range, we already know that (range.min <= x))
216 SYMS_U64 result = SYMS_U64_MAX;
217 if (index != SYMS_U64_MAX &&
218 x < map->ranges[index].range.max){
219 result = index;
220 }
221 SYMS_ProfEnd();
222 return(result);
223}
224
227 SYMS_ProfBegin("syms_spatial_map_1d_value_from_point");
229 SYMS_U64 result = 0;
231 result = map->ranges[index].val;
232 }
233 SYMS_ProfEnd();
234 return(result);
235}
236
237//- copying spatial maps
238
241 SYMS_SpatialMap1D result = {0};
242 result.count = map->count;
243 result.ranges = syms_push_array(arena, SYMS_SpatialMap1DRange, result.count);
244 syms_memmove(result.ranges, map->ranges, sizeof(SYMS_SpatialMap1DRange)*result.count);
245 return(result);
246}
247
248//- constructing spatial maps
249
250SYMS_API void
252 SYMS_U64 val, SYMS_U64RangeArray ranges){
255 node->ranges = ranges;
256 node->val = val;
257 SYMS_QueuePush(loose->first, loose->last, node);
258 loose->total_count += ranges.count;
259}
260
261SYMS_API void
263 SYMS_U64 val, SYMS_U64Range range){
265 node->range = range;
267 node->val = val;
268 SYMS_QueuePush(loose->first, loose->last, node);
269 loose->total_count += 1;
270}
271
274 SYMS_ProfBegin("syms_spatial_map_1d_bake");
275 //- fill tight range array
276 SYMS_U64 count = loose->total_count;
279 for (SYMS_SpatialMap1DNode *node = loose->first;
280 node != 0;
281 node = node->next){
282 SYMS_U64 val = node->val;
283
284 {
285 SYMS_U64Range range = node->range;
286 if (range.min < range.max){
287 range_ptr->range = range;
288 range_ptr->val = val;
289 range_ptr += 1;
290 }
291 }
292
293 SYMS_U64 count = node->ranges.count;
294 SYMS_U64Range *range = node->ranges.ranges;
295 for (SYMS_U64 i = 0; i < count; i += 1, range += 1){
296 if (range->min < range->max){
297 range_ptr->range = *range;
298 range_ptr->val = val;
299 range_ptr += 1;
300 }
301 }
302 }
305
306 //- sort
309 }
310
311 //- assemble map
312 SYMS_SpatialMap1D result = {ranges, final_count};
313
314 SYMS_ProfEnd();
315 return(result);
316}
317
320 SYMS_ProfBegin("syms_spatial_map_1d_array_check_sorted");
321 SYMS_B32 result = syms_true;
323 for (SYMS_U64 i = 1; i < count; i += 1, range_ptr += 1){
324 if (range_ptr->range.min > (range_ptr + 1)->range.min){
325 result = syms_false;
326 break;
327 }
328 }
329 SYMS_ProfEnd();
330 return(result);
331}
332
333SYMS_API void
339
340SYMS_API void
342 if (count > 4){
343 SYMS_U64 last = count - 1;
344
345 // swap
346 SYMS_U64 mid = count/2;
347 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[mid], ranges[last]);
348
349 // partition
351 SYMS_U64 key = ranges[last].range.min;
352 SYMS_U64 j = 0;
353 for (SYMS_U64 i = 0; i < last; i += 1){
354 SYMS_B32 send_left = (ranges[i].range.min < key);
355 if (!send_left && ranges[i].range.min == key){
358 }
359 if (send_left){
360 if (j != i){
361 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[i], ranges[j]);
362 }
363 j += 1;
364 }
365 }
366
367 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[j], ranges[last]);
368
369 // recurse
370 SYMS_U64 pivot = j;
373 }
374 else if (count == 2){
375 if (ranges[0].range.min > ranges[1].range.min){
376 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[0], ranges[1]);
377 }
378 }
379 else if (count == 3){
380 if (ranges[0].range.min > ranges[1].range.min){
381 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[0], ranges[1]);
382 }
383 if (ranges[1].range.min > ranges[2].range.min){
384 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[1], ranges[2]);
385 if (ranges[0].range.min > ranges[1].range.min){
386 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[0], ranges[1]);
387 }
388 }
389 }
390 else if (count == 4){
391 if (ranges[0].range.min > ranges[1].range.min){
392 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[0], ranges[1]);
393 }
394 if (ranges[2].range.min > ranges[3].range.min){
395 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[2], ranges[3]);
396 }
397 if (ranges[0].range.min > ranges[2].range.min){
398 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[0], ranges[2]);
399 }
400 if (ranges[1].range.min > ranges[3].range.min){
401 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[1], ranges[3]);
402 }
403 if (ranges[1].range.min > ranges[2].range.min){
404 SYMS_Swap(SYMS_SpatialMap1DRange, ranges[1], ranges[2]);
405 }
406 }
407}
408
409//- support for the overlapping ranges
410
413 SYMS_ProfBegin("syms_spatial_multi_map_1d_bake");
414 SYMS_SpatialMultiMap1D result = {0};
415
416 if (loose->total_count > 0){
417 //- gather endpoints
419 SYMS_U64 max_endpoint_count = loose->total_count*2;
421
423 {
425 for (SYMS_SpatialMap1DNode *node = loose->first;
426 node != 0;
427 node = node->next){
428 SYMS_U64 val = node->val;
429
430 {
431 SYMS_U64Range range = node->range;
432 if (range.min < range.max){
433 endpoint_ptr->x = range.min;
434 endpoint_ptr->val = val;
435 endpoint_ptr->open = 1;
436 endpoint_ptr += 1;
437
438 endpoint_ptr->x = range.max;
439 endpoint_ptr->val = val;
440 endpoint_ptr->open = 0;
441 endpoint_ptr += 1;
442 }
443 }
444
445 SYMS_U64 count = node->ranges.count;
446 SYMS_U64Range *range = node->ranges.ranges;
447 for (SYMS_U64 i = 0; i < count; i += 1, range += 1){
448 if (range->min < range->max){
449 endpoint_ptr->x = range->min;
450 endpoint_ptr->val = val;
451 endpoint_ptr->open = 1;
452 endpoint_ptr += 1;
453
454 endpoint_ptr->x = range->max;
455 endpoint_ptr->val = val;
456 endpoint_ptr->open = 0;
457 endpoint_ptr += 1;
458 }
459 }
460 }
461
463 }
464 SYMS_U64 range_count = endpoint_count/2;
465
466 //- sort endpoints
468
469 //- walk endpoints
470 SYMS_SpatialMap1D spatial_map = {0};
472 if (endpoint_count > 0){
473 // allocate simple map ranges
475
476 // setup the walk
480 SYMS_U64Set set = syms_u64_set_alloc(scratch.arena, range_count);
481
482 // walk
483 SYMS_U64 prev_x = 0;
484 SYMS_B32 has_prev = 0;
485 for (;endpoint_ptr < endpoint_opl;){
486 // look at the upcoming x
488
489 // emit a range
490 if (has_prev && set.count > 0){
491 // get an index for this set
492 SYMS_String8 data = {0};
493 data.str = (SYMS_U8*)set.vals;
494 data.size = set.count*sizeof(*set.vals);
496
497 // fill range and advance
498 range_ptr->range.min = prev_x;
499 range_ptr->range.max = this_x;
500 range_ptr->val = set_number;
501 range_ptr += 1;
502 }
503
504 // consume all endpoints at this x
506 endpoint_ptr += 1){
507 if (endpoint_ptr->open){
509 }
510 else{
512 }
513 }
514
515 // update prev info
516 prev_x = this_x;
517 has_prev = 1;
518 }
519
520 // since we control emitting endpoints and consuming them,
521 // if we have done everything right then the walk should end
522 // with an empty set
523 SYMS_ASSERT(set.count == 0);
524
525 // assemble the simple spatial map
526 spatial_map.ranges = ranges;
527 spatial_map.count = (SYMS_U64)(range_ptr - ranges);
528 }
529
530 //- assemble the set data
531 SYMS_U64 set_count = data_cons.count;
532 SYMS_U64 *set_end_points = syms_push_array(arena, SYMS_U64, set_count + 1);
533 SYMS_U8 *set_data = syms_push_array(arena, SYMS_U8, data_cons.total_size);
534 {
535 // setup cursors
536 SYMS_U64 *set_end_point_ptr = set_end_points;
538
539 // emit loop
542 for (SYMS_DataIdxConsNode *node = data_cons.first;
543 node != 0;
544 node = node->all_next){
545 SYMS_U64 data_size = node->data.size;
546 syms_memmove(set_data + set_data_pos, node->data.str, data_size);
550 }
551 }
552
553 //- assemble the multi-map
554 result.spatial_map = spatial_map;
555 result.set_end_points = set_end_points;
556 result.set_data = set_data;
557 result.set_count = set_count;
558
560 }
561
562 SYMS_ProfEnd();
563 return(result);
564}
565
568 SYMS_ProfBegin("syms_spatial_multi_map_array_from_point");
569 SYMS_U64Array result = {0};
571 if (0 < set_number && set_number <= map->set_count){
575 SYMS_U64 opl = end_points[set_index + 1];
576 result.u64 = (SYMS_U64*)(map->set_data + first);
577 result.count = (opl - first)/8;
578 }
579 SYMS_ProfEnd();
580 return(result);
581}
582
583
584SYMS_API void
586 if (count > 4){
587 SYMS_U64 last = count - 1;
588
589 // swap
590 SYMS_U64 mid = count/2;
592
593 // partition
595 SYMS_U64 key = endpoints[last].x;
596 SYMS_U64 j = 0;
597 for (SYMS_U64 i = 0; i < last; i += 1){
598 SYMS_B32 send_left = (endpoints[i].x < key);
599 if (!send_left && endpoints[i].x == key){
602 }
603 if (send_left){
604 if (j != i){
606 }
607 j += 1;
608 }
609 }
610
612
613 // recurse
614 SYMS_U64 pivot = j;
617 }
618 else if (count == 2){
619 if (endpoints[0].x > endpoints[1].x){
621 }
622 }
623 else if (count == 3){
624 if (endpoints[0].x > endpoints[1].x){
626 }
627 if (endpoints[1].x > endpoints[2].x){
629 if (endpoints[0].x > endpoints[1].x){
631 }
632 }
633 }
634 else if (count == 4){
635 if (endpoints[0].x > endpoints[1].x){
637 }
638 if (endpoints[2].x > endpoints[3].x){
640 }
641 if (endpoints[0].x > endpoints[2].x){
643 }
644 if (endpoints[1].x > endpoints[3].x){
646 }
647 if (endpoints[1].x > endpoints[2].x){
649 }
650 }
651}
652
653//- invariants for spatial maps
654
657 SYMS_B32 result = syms_true;
658 SYMS_U64 count = map->count;
659 if (count > 0){
660 SYMS_SpatialMap1DRange *range = map->ranges;
661 for (SYMS_U64 i = 1; i < count; i += 1){
662 SYMS_INVARIANT(result, range->range.min < range->range.max);
663 SYMS_INVARIANT(result, range->range.max <= (range + 1)->range.min);
664 }
665 SYMS_INVARIANT(result, range->range.min < range->range.max);
666 }
668 return(result);
669}
670
671
673// NOTE(allen): Mapping Functions ({UnitID,FileID} -> String)
674
675//- shared file id bucket definitions
678 SYMS_U64 result = syms_hash_u64(file_id + uid*97);
679 return(result);
680}
681
682//- lookups into file id buckets
685 SYMS_ProfBegin("syms_file_id_2_name_map_name_from_id");
686 SYMS_U64 hash = syms_file_id_2_name_map_hash(uid, file_id);
688 SYMS_String8 result = {0};
689 for (SYMS_FileID2NameNode *node = buckets->buckets[bucket_index];
690 node != 0;
691 node = node->next){
692 if (node->uid == uid && node->file_id == file_id){
693 result = node->name;
694 if (result.size == 0){
695 result.size = SYMS_U64_MAX;
696 }
697 break;
698 }
699 }
700 SYMS_ProfEnd();
701 return(result);
702}
703
704//- copying file id buckets
707 SYMS_FileID2NameMap result = {0};
708
709 //- allocate
710 SYMS_U64 count = map->count;
713
714 //- fill memory
715 {
720 for (; src_bucket < opl; dst_bucket += 1, src_bucket += 1){
722 for (SYMS_FileID2NameNode *node = *src_bucket;
723 node != 0;
724 node = node->next){
725 // name copy
726 SYMS_String8 name;
727 if (cons != 0){
728 name = syms_string_cons(arena, cons, node->name);
729 }
730 else{
731 name = syms_push_string_copy(arena, node->name);
732 }
733 // fill dst
734 dst_node->uid = node->uid;
735 dst_node->file_id = node->file_id;
736 dst_node->name = name;
737 // link into the chain
739 chain_ptr = &dst_node->next;
740 }
741 *chain_ptr = 0;
742 }
743 }
744
745 //- fill result
746 result.count = count;
747
748 return(result);
749}
750
751//- constructing file id buckets
752
753SYMS_API void
755 SYMS_UnitID uid, SYMS_FileID file_id, SYMS_String8 name){
756 SYMS_ProfBegin("syms_file_id_2_name_map_insert");
757 SYMS_U64 hash = syms_file_id_2_name_map_hash(uid, file_id);
759
761 new_node->uid = uid;
762 new_node->file_id = file_id;
763 new_node->name = name;
765 map->count += 1;
766 SYMS_ProfEnd();
767}
768
769
771//~ allen: Mapping Functions (String -> {UnitID,FileID})
772
773//- copying file maps
774
777 SYMS_ProfBegin("syms_name_2_file_id_map_copy");
778
779 //- deep copies
780 SYMS_U64 file_count = map->file_count;
782 {
784 SYMS_Name2FileIDMapFile *opl = file_src_ptr + file_count;
786 for (; file_src_ptr < opl; file_src_ptr += 1, file_dst_ptr += 1){
787 // per-unit array copy
788 SYMS_U64 unit_count = file_src_ptr->unit_count;
790 syms_memmove(units, file_dst_ptr->units, sizeof(*units)*unit_count);
791 // name copy
792 SYMS_String8 name;
793 if (cons != 0){
794 name = syms_string_cons(arena, cons, file_src_ptr->name);
795 }
796 else{
797 name = syms_push_string_copy(arena, file_src_ptr->name);
798 }
799 // fill dst
800 file_dst_ptr->name = name;
801 file_dst_ptr->units = units;
802 file_dst_ptr->unit_count = unit_count;
803 }
804 }
805
806 //- fill result
807 SYMS_Name2FileIDMap result = {0};
808 result.files = files;
809 result.file_count = file_count;
810
811 SYMS_ProfEnd();
812
813 return(result);
814}
815
816//- constructing file maps
817
820 SYMS_ProfBegin("syms_name_2_file_id_map_bake");
821
822 //- bake file map down to a tight table
826 node != 0;
827 node = node->next, file_ptr += 1){
828 // fill units array
829 SYMS_U64 count = node->count;
832 for (SYMS_Name2FileIDMapUnitNode *unit_node = node->first;
833 unit_node != 0;
834 unit_node = unit_node->next, unit_ptr += 1){
835 unit_ptr->uid = unit_node->uid;
836 unit_ptr->file_id = unit_node->file_id;
837 }
838
839 // fill file
840 file_ptr->name = node->name;
841 file_ptr->units = units;
842 file_ptr->unit_count = count;
843 }
844
845 //- assemble baked table type
846 SYMS_Name2FileIDMap result = {0};
847 result.files = files;
848 result.file_count = loose->count;
849
850 SYMS_ProfEnd();
851
852 return(result);
853}
854
855SYMS_API void
858 SYMS_ProfBegin("syms_name_2_file_id_map_loose_push");
859 // find existing name node
861 for (SYMS_Name2FileIDMapFileNode *node = map->first;
862 node != 0;
863 node = node->next){
864 if (name_cons.str == node->name.str){
865 file_node = node;
866 break;
867 }
868 }
869
870 // insert new node
871 if (file_node == 0){
873 new_node->name = name_cons;
874 SYMS_QueuePush(map->first, map->last, new_node);
875 map->count += 1;
876
878 }
879
880 // insert unit node
882 unit_node->uid = uid;
883 unit_node->file_id = file_id;
884
886 file_node->count += 1;
887 SYMS_ProfEnd();
888}
889
890
892//~ allen: ID Mapping Functions
893
894//- copying id maps
895
898 //- allocate
899 SYMS_U64 bucket_count = map->bucket_count;
900 SYMS_U64 node_count = map->node_count;
901 SYMS_IDMapNode **dst_buckets = syms_push_array(arena, SYMS_IDMapNode*, bucket_count);
902 SYMS_IDMapNode *nodes = syms_push_array(arena, SYMS_IDMapNode, node_count);
903
904 //- fill memory
905 {
906 SYMS_IDMapNode *dst_node = nodes;
909 SYMS_IDMapNode **opl = src_bucket + bucket_count;
910 for (; src_bucket < opl; dst_bucket += 1, src_bucket += 1){
912 for (SYMS_IDMapNode *node = *src_bucket;
913 node != 0;
914 node = node->next){
915 // fill dst
916 SYMS_U64 count = node->count;
917 dst_node->count = count;
918 syms_memmove(dst_node->key, node->key, sizeof(*node->key)*count);
919 syms_memmove(dst_node->val, node->val, sizeof(*node->val)*count);
920 // link into the chain
922 chain_ptr = &dst_node->next;
923 }
924 }
925 }
926
927 //- fill result
928 SYMS_IDMap result = {0};
929 result.buckets = dst_buckets;
930 result.bucket_count = bucket_count;
931 result.node_count = node_count;
932
933 return(result);
934}
935
936//- lookups into id map
937
938SYMS_API void*
940 SYMS_ProfBegin("syms_id_map_ptr_from_u64");
941 void *result = 0;
942 if (map->bucket_count > 0){
943 SYMS_U64 hash = syms_hash_u64(key);
944 SYMS_U64 index = hash%map->bucket_count;
945 for (SYMS_IDMapNode *node = map->buckets[index];
946 node != 0;
947 node = node->next){
948 SYMS_U64 count = node->count;
949 SYMS_U64 *kptr = node->key;
950 for (SYMS_U64 i = 0; i < count; i += 1, kptr += 1){
951 if (*kptr == key){
952 result = node->val[i];
953 goto dbl_break;
954 }
955 }
956 }
957 dbl_break:;
958 }
959 SYMS_ProfEnd();
960 return(result);
961}
962
963//- constructing id maps
964
967 SYMS_IDMap result = {0};
968 result.buckets = syms_push_array_zero(arena, SYMS_IDMapNode*, bucket_count);
969 result.bucket_count = bucket_count;
970 return(result);
971}
972
973SYMS_API void
974syms_id_map_insert(SYMS_Arena *arena, SYMS_IDMap *map, SYMS_U64 key, void *val){
975 SYMS_ProfBegin("syms_id_map_insert");
976 if (map->bucket_count > 0){
977 SYMS_U64 hash = syms_hash_u64(key);
978 SYMS_U64 index = hash%map->bucket_count;
979
980 SYMS_IDMapNode *node = map->buckets[index];
981 if (node == 0 || node->count == SYMS_ID_MAP_NODE_CAP){
982 syms_arena_push_align(arena, 64);
983 node = syms_push_array(arena, SYMS_IDMapNode, 1);
984 node->count = 0;
985 SYMS_StackPush(map->buckets[index], node);
986 map->node_count += 1;
987 }
988
989 SYMS_U64 i = node->count;
990 node->key[i] = key;
991 node->val[i] = val;
992 node->count += 1;
993 }
994 SYMS_ProfEnd();
995}
996
997
999//~ allen: Symbol Name Mapping Structure (String -> Array(SID))
1000
1001//- lookups into symbol name map
1002
1005 SYMS_ProfBegin("syms_symbol_name_map_array_from_string");
1006 SYMS_SymbolIDArray result = {0};
1007 SYMS_U64 hash = syms_hash_djb2(string);
1009 for (SYMS_SymbolNameNode *node = map->buckets[bucket_index];
1010 node != 0;
1011 node = node->next_bucket){
1012 if (node->hash == hash && syms_string_match(node->name, string, 0)){
1013 result = node->sid_array;
1014 break;
1015 }
1016 }
1017 SYMS_ProfEnd();
1018 return(result);
1019}
1020
1021//- constructing symbol name maps
1022
1023SYMS_API void
1025 SYMS_String8 name, SYMS_SymbolID sid){
1026 SYMS_ProfBegin("syms_symbol_name_map_push");
1027
1028 SYMS_U64 hash = syms_hash_djb2(name);
1030
1031 // find existing node
1032 SYMS_SymbolNameNodeLoose *node = 0;
1034 bucket != 0;
1035 bucket = bucket->next_bucket){
1036 if (bucket->hash == hash &&
1037 syms_string_match(name, bucket->name, 0)){
1038 node = bucket;
1039 break;
1040 }
1041 }
1042
1043 // create node
1044 if (node == 0){
1046 SYMS_StackPush_N(map->buckets[bucket_index], node, next_bucket);
1047 SYMS_QueuePush(map->first, map->last, node);
1048 map->node_count += 1;
1049 node->name = syms_push_string_copy(arena, name);
1050 node->hash = hash;
1051 }
1052
1053 // insert sid
1054 {
1057 node->sid_list.count += 1;
1058 sid_node->id = sid;
1059 }
1060
1061 SYMS_ProfEnd();
1062}
1063
1066 SYMS_ProfBegin("syms_symbol_name_map_bake");
1067
1068 SYMS_SymbolNameMap result = {0};
1069 SYMS_SymbolNameNode **buckets = result.buckets;
1070
1071 //- allocate map memory
1072 SYMS_U64 node_count = loose->node_count;
1073 SYMS_SymbolNameNode *nodes = syms_push_array(arena, SYMS_SymbolNameNode, node_count);
1074
1075 //- fill map from loose
1078 loose_node != 0;
1079 loose_node = loose_node->next){
1080 // copy node's name
1081 SYMS_String8 name = syms_push_string_copy(arena, loose_node->name);
1082
1083 // grab the node's hash
1084 SYMS_U64 hash = loose_node->hash;
1085
1086 // fill node's usid array
1087 SYMS_SymbolIDArray sid_array = {0};
1088 sid_array.count = loose_node->sid_list.count;
1089 sid_array.ids = syms_push_array(arena, SYMS_SymbolID, sid_array.count);
1090 {
1091 SYMS_SymbolID *sid_ptr = sid_array.ids;
1092 for (SYMS_SymbolIDNode *sid_node = loose_node->sid_list.first;
1093 sid_node != 0;
1094 sid_node = sid_node->next){
1095 *sid_ptr = sid_node->id;
1096 sid_ptr += 1;
1097 }
1098 }
1099
1100 // insert node to bucket
1102 SYMS_StackPush_N(buckets[bucket_index], node_ptr, next_bucket);
1103
1104 // fill node ptr
1105 node_ptr->name = name;
1106 node_ptr->hash = hash;
1107 node_ptr->sid_array = sid_array;
1108 node_ptr += 1;
1109 }
1110
1111 //- assemble result
1112 result.nodes = nodes;
1113 result.node_count = node_count;
1114
1115 SYMS_ProfEnd();
1116 return(result);
1117}
1118
1119
1121//~ allen: Line Tables
1122
1123//- lookups into line tables
1124
1127 SYMS_ProfBegin("syms_line_index_from_voff__binary_search");
1128 SYMS_U64 result = SYMS_U64_MAX;
1129 if (ender_index > 0 && lines->voff <= voff && voff < (lines + ender_index)->voff){
1130 //- binary search:
1131 // max index s.t. lines[index].virt_off <= x
1132 // we must allow for cases where (i != j) and (lines[i].virt_off == lines[j].virt_off)
1133 // thus (lines[index].virt_off == x) does not prove that index saatisfies the requiement
1134 SYMS_U64 first = 0;
1135 SYMS_U64 opl = ender_index;
1136 for (;;){
1137 SYMS_U64 mid = (first + opl)/2;
1138 SYMS_U64 lvoff = lines[mid].voff;
1139 if (lvoff > voff){
1140 opl = mid;
1141 }
1142 else{
1143 first = mid;
1144 }
1145 if (first + 1 >= opl){
1146 break;
1147 }
1148 }
1149 result = first;
1150 }
1151 SYMS_ProfEnd();
1152 return(result);
1153}
1154
1157 SYMS_Line result = {0};
1158 if (0 < seq_number && seq_number <= line_table->sequence_count){
1159 SYMS_U64 first = line_table->sequence_index_array[seq_number - 1];
1160 SYMS_U64 opl = line_table->sequence_index_array[seq_number];
1161 SYMS_U64 last = opl - 1;
1162 SYMS_U64 index = syms_line_index_from_voff__binary_search(line_table->line_array + first, last - first, voff);
1163 result = line_table->line_array[first + index];
1164 }
1165 return(result);
1166}
1167
1168//- copying and rewriting line tables
1169
1172 SYMS_ProfBegin("syms_line_table_copy");
1173
1174 SYMS_LineTable result = {0};
1175 if (line_table->sequence_index_array != 0){
1176 //- copy arrays
1177 SYMS_U64 sequence_count = line_table->sequence_count;
1178 SYMS_U64 *sequence_index_array = syms_push_array(arena, SYMS_U64, sequence_count + 1);
1179 syms_memmove(sequence_index_array, line_table->sequence_index_array, sizeof(SYMS_U64)*(sequence_count + 1));
1180
1181 SYMS_U64 line_count = line_table->line_count;
1182 SYMS_Line *line_array = syms_push_array(arena, SYMS_Line, line_count);
1183 syms_memmove(line_array, line_table->line_array, sizeof(*line_array)*line_count);
1184
1185 //- assemble result
1186 result.sequence_index_array = sequence_index_array;
1187 result.sequence_count = sequence_count;
1188 result.line_array = line_array;
1189 result.line_count = line_count;
1190 }
1191
1192 SYMS_ProfEnd();
1193
1194 return(result);
1195}
1196
1197SYMS_API void
1199 SYMS_ProfBegin("syms_line_table_rewrite_file_ids_in_place");
1200
1201 // check for file ids (no rewrite necessary if this array is empty)
1202 if (file_ids->count != 0){
1203
1204 // NOTE(allen): if this is slow the first easy step is to build a faster lookup for (file_id -> index)
1205 // currently this is just a linear scan with a most recently used cache
1206
1207 // most recently used cache
1210
1211 // rewrite loop
1212 SYMS_FileID *file_id_array = file_ids->ids;
1213 SYMS_FileID *file_id_opl = file_id_array + file_ids->count;
1214 SYMS_Line *line_ptr = line_table->line_array;
1215 SYMS_Line *opl = line_ptr + line_table->line_count;
1216 for (; line_ptr < opl; line_ptr += 1){
1217 // decide on the index
1218 if (line_ptr->src_coord.file_id != last_file_id){
1219 last_file_id = line_ptr->src_coord.file_id;
1220 last_file_index = 1;
1221 for (SYMS_FileID *file_id_ptr = file_id_array;
1223 file_id_ptr += 1, last_file_index += 1){
1224 if (*file_id_ptr == last_file_id){
1225 break;
1226 }
1227 }
1228 }
1229 SYMS_U64 index = last_file_index;
1230
1231 // rewrite the file id
1232 line_ptr->src_coord.file_id = index;
1233 }
1234 }
1235
1236 SYMS_ProfEnd();
1237}
1238
1241 SYMS_LineTable result = syms_line_table_copy(arena, &parse->line_table);
1242 syms_line_table_rewrite_file_ids_in_place(&parse->file_id_array, &result);
1243 return(result);
1244}
1245
1246
1248//~ allen: Line To Addr Map
1249
1253
1254 //- setup loose map
1256
1257 //- last-used cache for file nodes
1260
1261 //- read lines
1263 SYMS_U64 seq_count = line_table->sequence_count;
1264 for (SYMS_U64 i = 0; i < seq_count; i += 1){
1265 // get sequence range & inc
1266 SYMS_U64 first = *seq_idx_ptr;
1267 seq_idx_ptr += 1;
1268 SYMS_U64 opl = *seq_idx_ptr;
1269
1270 // iterate lines
1271 if (first < opl){
1272 SYMS_Line *line_ptr = line_table->line_array + first;
1273 SYMS_U64 last = opl - 1;
1274 for (SYMS_U64 j = first; j < last; j += 1, line_ptr += 1){
1275 // grab line data
1277 SYMS_U32 line_number = line_ptr->src_coord.line;
1278
1279 // get file node
1283 }
1284 else{
1286 node != 0;
1287 node = node->next){
1288 if (node->file_id == line_file_id){
1289 file_node = node;
1290 break;
1291 }
1292 }
1293 }
1294 if (file_node == 0){
1296 SYMS_QueuePush(loose.first, loose.last, file_node);
1297 loose.count += 1;
1298 file_node->file_id = line_file_id;
1299 }
1300
1301 // update the file node cache slot
1304
1305 // get line node
1307 for (SYMS_FileToLineToAddrLooseLine *node = file_node->first;
1308 node != 0;
1309 node = node->next){
1310 if (node->line == line_number){
1311 line_node = node;
1312 break;
1313 }
1314 }
1315 if (line_node == 0){
1318 file_node->line_count += 1;
1319 line_node->line = line_number;
1320 }
1321
1322 // push range
1323 SYMS_U64Range range = syms_make_u64_range(line_ptr->voff, (line_ptr + 1)->voff);
1324 syms_u64_range_list_push(scratch.arena, &line_node->ranges, range);
1325 file_node->range_count += 1;
1326 }
1327 }
1328 }
1329
1330 //- convert loose to buckets & maps
1331 SYMS_U64 bucket_count = 0;
1332 if (loose.count > 0){
1333 bucket_count = ((loose.count + 1)*3/2) | 1;
1334 }
1335
1338 loose_file_node != 0;
1341
1342 // grab counts
1343 SYMS_U64 line_count = loose_file_node->line_count;
1344 SYMS_U64 range_count = loose_file_node->range_count;
1345
1346 // create sorted node array
1348 line_count);
1349 {
1352 loose_line_node != 0;
1355 }
1356 }
1358
1359 // fill line map arrays
1360 SYMS_U64Range *ranges = syms_push_array(arena, SYMS_U64Range, range_count);
1361 SYMS_U32 *line_range_indexes = syms_push_array(arena, SYMS_U32, line_count + 1);
1362 SYMS_U32 *line_numbers = syms_push_array(arena, SYMS_U32, line_count);
1363
1365 SYMS_U32 *line_range_index_ptr = line_range_indexes;
1366 SYMS_U32 *line_number_ptr = line_numbers;
1367
1368 {
1370 for (SYMS_U64 i = 0; i < line_count; i += 1, line_ptr += 1){
1371 // fills
1372 *line_number_ptr = (**line_ptr).line;
1376 for (SYMS_U64RangeNode *node = (**line_ptr).ranges.first;
1377 node != 0;
1378 node = node->next, range_ptr += 1){
1379 *range_ptr = node->range;
1380 }
1381
1382 // incs
1383 line_number_ptr += 1;
1386 }
1387
1388 // fill ender index
1390 }
1391
1392 // assemble the line map
1394 new_map->ranges = ranges;
1395 new_map->line_range_indexes = line_range_indexes;
1396 new_map->line_numbers = line_numbers;
1397 new_map->line_count = line_count;
1398
1399 // insert bucket
1401 new_file_node->file_id = loose_file_node->file_id;
1402 new_file_node->map = new_map;
1403 SYMS_U64 bucket_index = loose_file_node->file_id%bucket_count;
1405
1407 }
1408
1410
1411 //- build result
1412 SYMS_FileToLineToAddrMap result = {0};
1413 result.buckets = buckets;
1414 result.bucket_count = bucket_count;
1415
1416 return(result);
1417}
1418
1422 if (map->bucket_count > 0){
1423 SYMS_U64 bucket_index = file_id%map->bucket_count;
1425 node != 0;
1426 node = node->next){
1427 if (node->file_id == file_id){
1428 result = node->map;
1429 break;
1430 }
1431 }
1432 }
1433 return(result);
1434}
1435
1439 SYMS_U64 count = map->line_count;
1442 if (count > 0 && index >= count){
1443 index = count - 1;
1444 }
1445 SYMS_U64RangeArray result = {0};
1446 if (index < count){
1448 result.ranges = map->ranges + range_indexes[index];
1449 result.count = range_indexes[index + 1] - range_indexes[index];
1450 *actual_line_out = numbers[index];
1451 }
1452 return(result);
1453}
1454
1455
1456SYMS_API void
1462
1463SYMS_API void
1465 if (count > 4){
1466 SYMS_U64 last = count - 1;
1467
1468 // swap
1469 SYMS_U64 mid = count/2;
1471
1472 // partition
1473 SYMS_U64 key = array[last]->line;
1474 SYMS_U64 j = 0;
1475 for (SYMS_U64 i = 0; i < last; i += 1){
1476 if (array[i]->line < key){
1477 if (j != i){
1479 }
1480 j += 1;
1481 }
1482 }
1483
1485
1486 // recurse
1487 SYMS_U64 pivot = j;
1490 }
1491 else if (count == 2){
1492 if (array[0]->line > array[1]->line){
1494 }
1495 }
1496 else if (count == 3){
1497 if (array[0]->line > array[1]->line){
1499 }
1500 if (array[1]->line > array[2]->line){
1502 if (array[0]->line > array[1]->line){
1504 }
1505 }
1506 }
1507 else if (count == 4){
1508 if (array[0]->line > array[1]->line){
1510 }
1511 if (array[2]->line > array[3]->line){
1513 }
1514 if (array[0]->line > array[2]->line){
1516 }
1517 if (array[1]->line > array[3]->line){
1519 }
1520 if (array[1]->line > array[2]->line){
1522 }
1523 }
1524}
1525
1526
1528//~ allen: Copies & Operators for Other Data Structures
1529
1532 SYMS_ProfBegin("syms_string_array_copy");
1533
1534 //- allocate
1535 SYMS_U64 count = array->count;
1536 SYMS_String8 *strings = syms_push_array(arena, SYMS_String8, count);
1537
1538 //- fill
1539 SYMS_String8 *dst_ptr = strings;
1540 SYMS_String8 *src_ptr = array->strings;
1541 SYMS_String8 *opl = src_ptr + count;
1542 for (; src_ptr < opl; src_ptr += 1, dst_ptr += 1){
1543 SYMS_String8 string;
1544 if (cons != 0){
1545 string = syms_string_cons(arena, cons, *src_ptr);
1546 }
1547 else{
1548 string = syms_push_string_copy(arena, *src_ptr);
1549 }
1550 *dst_ptr = string;
1551 }
1552
1553 //- assemble result
1554 SYMS_String8Array result = {0};
1555 result.strings = strings;
1556 result.count = count;
1557
1558 SYMS_ProfEnd();
1559
1560 return(result);
1561}
1562
1565 SYMS_ProfBegin("syms_link_name_record_copy");
1566 SYMS_LinkNameRecArray result = {0};
1567 result.count = array->count;
1568 result.recs = syms_push_array(arena, SYMS_LinkNameRec, result.count);
1569
1570 SYMS_LinkNameRec *src = array->recs;
1571 SYMS_LinkNameRec *dst = result.recs;
1572 for (SYMS_U64 i = 0; i < result.count; i += 1, src += 1, dst += 1){
1573 dst->name = syms_push_string_copy(arena, src->name);
1574 dst->voff = src->voff;
1575 }
1576
1577 SYMS_ProfEnd();
1578 return(result);
1579}
1580
1582//~ allen: Binary Search Functions
1583
1586 SYMS_ProfBegin("syms_index_from_n__u32__binary_search_round_up");
1587 SYMS_U64 result = SYMS_U64_MAX;
1588 if (count > 0 && n <= v[count - 1]){
1589 //- binary search:
1590 // minimum index s.t. v[index] >= n
1591 // in this one we assume:
1592 // (i != j) implies (v[i] != v[j])
1593 // thus if (v[index] == n) then index already satisfies the requirement
1594 SYMS_U64 first = 0;
1595 SYMS_U64 opl = count;
1596 for (;;){
1597 SYMS_U64 mid = (first + opl - 1)/2;
1598 SYMS_U64 w = v[mid];
1599 if (w < n){
1600 first = mid + 1;
1601 }
1602 else if (w > n){
1603 opl = mid + 1;
1604 }
1605 else{
1606 first = mid;
1607 break;
1608 }
1609 if (first + 1 >= opl){
1610 break;
1611 }
1612 }
1613 result = first;
1614 }
1615 SYMS_ProfEnd();
1616 return(result);
1617}
1618
1619#endif //SYMS_DATA_STRUCTURES_C
OODEFFUNC typedef const char int line
Definition oodle2.h:678
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
char * dst
Definition lz4.h:735
float v
Definition radaudio_mdct.cpp:62
Definition syms_data_structures.h:94
SYMS_U64 val
Definition syms_data_structures.h:96
Definition syms_base.h:402
Definition syms_data_structures.h:26
Definition syms_data_structures.h:34
SYMS_U64 count
Definition syms_data_structures.h:39
SYMS_DataIdxConsNode ** buckets
Definition syms_data_structures.h:35
SYMS_DataIdxConsNode * last
Definition syms_data_structures.h:38
SYMS_DataIdxConsNode * first
Definition syms_data_structures.h:37
SYMS_U64 bucket_count
Definition syms_data_structures.h:36
SYMS_U64 total_size
Definition syms_data_structures.h:40
Definition syms_data_structures.h:117
SYMS_U64 count
Definition syms_data_structures.h:119
SYMS_FileID2NameNode * buckets[SYMS_FILE_ID_TO_NAME_MAP_BUCKET_COUNT]
Definition syms_data_structures.h:118
Definition syms_data_structures.h:108
struct SYMS_FileID2NameNode * next
Definition syms_data_structures.h:109
Definition syms_debug_info.h:148
SYMS_FileID * ids
Definition syms_debug_info.h:149
SYMS_U64 count
Definition syms_debug_info.h:150
Definition syms_data_structures.h:265
SYMS_FileToLineToAddrLooseLine * first
Definition syms_data_structures.h:268
Definition syms_data_structures.h:259
SYMS_U32 line
Definition syms_data_structures.h:261
Definition syms_data_structures.h:274
Definition syms_data_structures.h:253
SYMS_FileToLineToAddrNode ** buckets
Definition syms_data_structures.h:254
SYMS_U64 bucket_count
Definition syms_data_structures.h:255
Definition syms_data_structures.h:247
Definition syms_data_structures.h:180
struct SYMS_IDMapNode * next
Definition syms_data_structures.h:181
SYMS_U64 key[SYMS_ID_MAP_NODE_CAP]
Definition syms_data_structures.h:183
void * val[SYMS_ID_MAP_NODE_CAP]
Definition syms_data_structures.h:184
SYMS_U64 count
Definition syms_data_structures.h:182
Definition syms_data_structures.h:187
SYMS_IDMapNode ** buckets
Definition syms_data_structures.h:188
SYMS_U64 bucket_count
Definition syms_data_structures.h:189
SYMS_U64 node_count
Definition syms_data_structures.h:190
Definition syms_debug_info.h:164
Definition syms_debug_info.h:153
SYMS_U64 line_count
Definition syms_debug_info.h:161
SYMS_Line * line_array
Definition syms_debug_info.h:160
SYMS_U64 * sequence_index_array
Definition syms_debug_info.h:157
SYMS_U64 sequence_count
Definition syms_debug_info.h:158
Definition syms_data_structures.h:237
SYMS_U64 line_count
Definition syms_data_structures.h:244
SYMS_U64Range * ranges
Definition syms_data_structures.h:238
SYMS_U32 * line_range_indexes
Definition syms_data_structures.h:242
SYMS_U32 * line_numbers
Definition syms_data_structures.h:243
Definition syms_debug_info.h:136
SYMS_U64 voff
Definition syms_debug_info.h:138
SYMS_SrcCoord src_coord
Definition syms_debug_info.h:137
Definition syms_debug_info.h:390
SYMS_LinkNameRec * recs
Definition syms_debug_info.h:391
SYMS_U64 count
Definition syms_debug_info.h:392
Definition syms_debug_info.h:385
SYMS_String8 name
Definition syms_debug_info.h:386
SYMS_U64 voff
Definition syms_debug_info.h:387
Definition syms_data_structures.h:157
SYMS_Name2FileIDMapUnitNode * first
Definition syms_data_structures.h:160
Definition syms_data_structures.h:139
SYMS_U64 unit_count
Definition syms_data_structures.h:142
Definition syms_data_structures.h:165
SYMS_U64 count
Definition syms_data_structures.h:168
SYMS_Name2FileIDMapFileNode * first
Definition syms_data_structures.h:166
SYMS_Name2FileIDMapFileNode * last
Definition syms_data_structures.h:167
Definition syms_data_structures.h:151
Definition syms_data_structures.h:134
SYMS_UnitID uid
Definition syms_data_structures.h:135
Definition syms_data_structures.h:145
SYMS_U64 file_count
Definition syms_data_structures.h:147
SYMS_Name2FileIDMapFile * files
Definition syms_data_structures.h:146
Definition syms_data_structures.h:78
Definition syms_data_structures.h:71
SYMS_U64 val
Definition syms_data_structures.h:75
SYMS_U64Range range
Definition syms_data_structures.h:73
SYMS_U64RangeArray ranges
Definition syms_data_structures.h:74
Definition syms_data_structures.h:59
SYMS_U64 val
Definition syms_data_structures.h:61
SYMS_U64Range range
Definition syms_data_structures.h:60
Definition syms_data_structures.h:65
SYMS_U64 count
Definition syms_data_structures.h:67
SYMS_SpatialMap1DRange * ranges
Definition syms_data_structures.h:66
Definition syms_data_structures.h:85
SYMS_U64 set_count
Definition syms_data_structures.h:91
SYMS_U8 * set_data
Definition syms_data_structures.h:90
SYMS_SpatialMap1D spatial_map
Definition syms_data_structures.h:86
SYMS_U64 * set_end_points
Definition syms_data_structures.h:88
SYMS_FileID file_id
Definition syms_debug_info.h:131
Definition syms_base.h:313
SYMS_String8 * strings
Definition syms_base.h:314
SYMS_U64 count
Definition syms_base.h:315
Definition syms_base.h:296
SYMS_U8 * str
Definition syms_base.h:297
SYMS_U64 size
Definition syms_base.h:298
Definition syms_data_structures.h:14
Definition syms_data_structures.h:20
SYMS_StringConsNode * buckets[SYMS_STRING_CONS_BUCKET_COUNT]
Definition syms_data_structures.h:21
Definition syms_debug_info.h:228
SYMS_SymbolID * ids
Definition syms_debug_info.h:229
SYMS_U64 count
Definition syms_debug_info.h:230
SYMS_U64 count
Definition syms_debug_info.h:225
SYMS_SymbolIDNode * last
Definition syms_debug_info.h:224
SYMS_SymbolIDNode * first
Definition syms_debug_info.h:223
Definition syms_debug_info.h:217
Definition syms_data_structures.h:226
SYMS_SymbolNameNodeLoose * first
Definition syms_data_structures.h:228
SYMS_SymbolNameNodeLoose * last
Definition syms_data_structures.h:229
SYMS_U64 node_count
Definition syms_data_structures.h:230
SYMS_SymbolNameNodeLoose * buckets[SYMS_SYMBOL_NAME_MAP_BUCKET_COUNT]
Definition syms_data_structures.h:227
Definition syms_data_structures.h:211
SYMS_U64 node_count
Definition syms_data_structures.h:214
SYMS_SymbolNameNode * nodes
Definition syms_data_structures.h:213
SYMS_SymbolNameNode * buckets[SYMS_SYMBOL_NAME_MAP_BUCKET_COUNT]
Definition syms_data_structures.h:212
Definition syms_data_structures.h:218
SYMS_U64 hash
Definition syms_data_structures.h:222
SYMS_SymbolIDList sid_list
Definition syms_data_structures.h:223
SYMS_String8 name
Definition syms_data_structures.h:221
Definition syms_data_structures.h:204
Definition syms_base.h:233
SYMS_U64 * u64
Definition syms_base.h:234
SYMS_U64 count
Definition syms_base.h:235
Definition syms_base.h:280
SYMS_U64Range * ranges
Definition syms_base.h:281
SYMS_U64 count
Definition syms_base.h:282
Definition syms_base.h:269
Definition syms_base.h:264
SYMS_U64 max
Definition syms_base.h:266
SYMS_U64 min
Definition syms_base.h:265
Definition syms_data_structures.h:46
SYMS_U64 * vals
Definition syms_data_structures.h:47
SYMS_U64 cap
Definition syms_data_structures.h:49
SYMS_U64 count
Definition syms_data_structures.h:48
SYMS_API SYMS_U64 syms_hash_u64(SYMS_U64 x)
Definition syms_base.c:57
SYMS_API void syms_arena_push_align(SYMS_Arena *arena, SYMS_U64 pow2_boundary)
Definition syms_base.c:664
SYMS_API SYMS_ArenaTemp syms_get_scratch(SYMS_Arena **conflicts, SYMS_U64 conflict_count)
Definition syms_base.c:694
SYMS_API SYMS_B32 syms_string_match(SYMS_String8 a, SYMS_String8 b, SYMS_StringMatchFlags flags)
Definition syms_base.c:210
SYMS_API void syms_u64_range_list_push(SYMS_Arena *arena, SYMS_U64RangeList *list, SYMS_U64Range range)
Definition syms_base.c:564
SYMS_API void syms_arena_put_back(SYMS_Arena *arena, SYMS_U64 amount)
Definition syms_base.c:672
SYMS_API SYMS_U64Range syms_make_u64_range(SYMS_U64 min, SYMS_U64 max)
Definition syms_base.c:18
SYMS_API SYMS_U64 syms_hash_djb2(SYMS_String8 string)
Definition syms_base.c:40
SYMS_API void syms_arena_temp_end(SYMS_ArenaTemp temp)
Definition syms_base.c:689
SYMS_API SYMS_String8 syms_push_string_copy(SYMS_Arena *arena, SYMS_String8 string)
Definition syms_base.c:353
SYMS_API SYMS_ArenaTemp syms_arena_temp_begin(SYMS_Arena *arena)
Definition syms_base.c:682
#define syms_true
Definition syms_base.h:105
#define SYMS_QueuePush_N(f, l, n, next)
Definition syms_base.h:210
#define SYMS_Swap(T, a, b)
Definition syms_base.h:190
#define SYMS_StackPush(f, n)
Definition syms_base.h:227
#define syms_push_array(a, T, c)
Definition syms_base.h:561
#define syms_memzero_struct(s)
Definition syms_base.h:161
#define SYMS_StackPush_N(f, n, next)
Definition syms_base.h:224
#define syms_false
Definition syms_base.h:104
#define SYMS_API
Definition syms_base.h:29
#define SYMS_ASSERT(x)
Definition syms_base.h:125
#define SYMS_INVARIANT(r, x)
Definition syms_base.h:138
SYMS_S32 SYMS_B32
Definition syms_base.h:99
#define syms_push_array_zero(a, T, c)
Definition syms_base.h:564
#define SYMS_U64_MAX
Definition syms_base.h:176
#define SYMS_QueuePush(f, l, n)
Definition syms_base.h:220
#define syms_release_scratch
Definition syms_base.h:567
uint32_t SYMS_U32
Definition syms_crt_overrides.h:38
uint64_t SYMS_U64
Definition syms_crt_overrides.h:39
#define syms_memmove
Definition syms_crt_overrides.h:65
#define SYMS_U64
Definition syms_crt_overrides.h:54
uint8_t SYMS_U8
Definition syms_crt_overrides.h:36
SYMS_API SYMS_IDMap syms_id_map_copy(SYMS_Arena *arena, SYMS_IDMap *map)
Definition syms_data_structures.c:897
SYMS_API SYMS_U64 syms_spatial_map_1d_binary_search(SYMS_SpatialMap1D *map, SYMS_U64 x)
Definition syms_data_structures.c:172
SYMS_API SYMS_B32 syms_spatial_map_1d_invariants(SYMS_SpatialMap1D *map)
Definition syms_data_structures.c:656
SYMS_API void syms_symbol_name_map_push(SYMS_Arena *arena, SYMS_SymbolNameMapLoose *map, SYMS_String8 name, SYMS_SymbolID sid)
Definition syms_data_structures.c:1024
SYMS_API void syms_line_to_addr_line_sort__rec(SYMS_FileToLineToAddrLooseLine **array, SYMS_U64 count)
Definition syms_data_structures.c:1464
SYMS_API SYMS_FileToLineToAddrMap syms_line_to_addr_map_from_line_table(SYMS_Arena *arena, SYMS_LineTable *line_table)
Definition syms_data_structures.c:1251
SYMS_API void syms_line_to_addr_line_sort(SYMS_FileToLineToAddrLooseLine **array, SYMS_U64 count)
Definition syms_data_structures.c:1457
SYMS_API void syms_spatial_map_1d_array_sort(SYMS_SpatialMap1DRange *ranges, SYMS_U64 count)
Definition syms_data_structures.c:334
SYMS_API SYMS_U64Set syms_u64_set_alloc(SYMS_Arena *arena, SYMS_U64 cap)
Definition syms_data_structures.c:89
SYMS_API SYMS_Name2FileIDMap syms_name_2_file_id_map_copy(SYMS_Arena *arena, SYMS_StringCons *cons, SYMS_Name2FileIDMap *map)
Definition syms_data_structures.c:776
SYMS_API SYMS_String8Array syms_string_array_copy(SYMS_Arena *arena, SYMS_StringCons *cons, SYMS_String8Array *array)
Definition syms_data_structures.c:1531
SYMS_API SYMS_U64 syms_line_index_from_voff__binary_search(SYMS_Line *lines, SYMS_U64 ender_index, SYMS_U64 voff)
Definition syms_data_structures.c:1126
SYMS_API SYMS_B32 syms_u64_set_insert(SYMS_U64Set *set, SYMS_U64 x)
Definition syms_data_structures.c:135
SYMS_API SYMS_SymbolNameMap syms_symbol_name_map_bake(SYMS_Arena *arena, SYMS_SymbolNameMapLoose *loose)
Definition syms_data_structures.c:1065
SYMS_API void syms_id_map_insert(SYMS_Arena *arena, SYMS_IDMap *map, SYMS_U64 key, void *val)
Definition syms_data_structures.c:974
SYMS_API SYMS_U64 syms_index_from_n__u32__binary_search_round_up(SYMS_U32 *v, SYMS_U64 count, SYMS_U32 n)
Definition syms_data_structures.c:1585
SYMS_API SYMS_LineTable syms_line_table_with_indexes_from_parse(SYMS_Arena *arena, SYMS_LineParseOut *parse)
Definition syms_data_structures.c:1240
SYMS_API SYMS_SymbolIDArray syms_symbol_name_map_array_from_string(SYMS_SymbolNameMap *map, SYMS_String8 string)
Definition syms_data_structures.c:1004
SYMS_API void syms_u64_set_erase(SYMS_U64Set *set, SYMS_U64 x)
Definition syms_data_structures.c:153
SYMS_API SYMS_B32 syms_spatial_map_1d_array_check_sorted(SYMS_SpatialMap1DRange *ranges, SYMS_U64 count)
Definition syms_data_structures.c:319
SYMS_API SYMS_U64RangeArray syms_line_to_addr_map_lookup_nearest_line_number(SYMS_LineToAddrMap *map, SYMS_U32 line, SYMS_U32 *actual_line_out)
Definition syms_data_structures.c:1437
SYMS_API SYMS_U64 syms_spatial_map_1d_index_from_point(SYMS_SpatialMap1D *map, SYMS_U64 x)
Definition syms_data_structures.c:211
SYMS_API SYMS_LineToAddrMap * syms_line_to_addr_map_lookup_file_id(SYMS_FileToLineToAddrMap *map, SYMS_FileID file_id)
Definition syms_data_structures.c:1420
SYMS_API SYMS_FileID2NameMap syms_file_id_2_name_map_copy(SYMS_Arena *arena, SYMS_StringCons *cons, SYMS_FileID2NameMap *map)
Definition syms_data_structures.c:706
SYMS_API SYMS_Name2FileIDMap syms_name_2_file_id_map_bake(SYMS_Arena *arena, SYMS_Name2FileIDMapLoose *loose)
Definition syms_data_structures.c:819
SYMS_API void syms_line_table_rewrite_file_ids_in_place(SYMS_FileIDArray *file_ids, SYMS_LineTable *line_table)
Definition syms_data_structures.c:1198
SYMS_API void syms_spatial_map_1d_array_sort__rec(SYMS_SpatialMap1DRange *ranges, SYMS_U64 count)
Definition syms_data_structures.c:341
SYMS_API void syms_name_2_file_id_map_loose_push(SYMS_Arena *arena, SYMS_Name2FileIDMapLoose *map, SYMS_String8 name_cons, SYMS_UnitID uid, SYMS_FileID file_id)
Definition syms_data_structures.c:856
SYMS_API void syms_spatial_map_1d_loose_push(SYMS_Arena *arena, SYMS_SpatialMap1DLoose *loose, SYMS_U64 val, SYMS_U64RangeArray ranges)
Definition syms_data_structures.c:251
SYMS_API SYMS_String8 syms_string_cons(SYMS_Arena *arena, SYMS_StringCons *cons, SYMS_String8 string)
Definition syms_data_structures.c:10
SYMS_API SYMS_LinkNameRecArray syms_link_name_record_copy(SYMS_Arena *arena, SYMS_LinkNameRecArray *array)
Definition syms_data_structures.c:1564
SYMS_API SYMS_U64 syms_file_id_2_name_map_hash(SYMS_UnitID uid, SYMS_FileID file_id)
Definition syms_data_structures.c:677
SYMS_API SYMS_DataIdxCons syms_data_idx_cons_alloc(SYMS_Arena *arena, SYMS_U64 bucket_count)
Definition syms_data_structures.c:41
SYMS_API SYMS_U64Array syms_spatial_multi_map_1d_array_from_point(SYMS_SpatialMultiMap1D *map, SYMS_U64 x)
Definition syms_data_structures.c:567
SYMS_API void * syms_id_map_ptr_from_u64(SYMS_IDMap *map, SYMS_U64 key)
Definition syms_data_structures.c:939
SYMS_API void syms_spatial_map_1d_endpoint_sort(SYMS_1DEndPoint *endpoints, SYMS_U64 count)
Definition syms_data_structures.c:585
SYMS_API void syms_file_id_2_name_map_insert(SYMS_Arena *arena, SYMS_FileID2NameMap *map, SYMS_UnitID uid, SYMS_FileID file_id, SYMS_String8 name)
Definition syms_data_structures.c:754
SYMS_API SYMS_U64 syms_spatial_map_1d_value_from_point(SYMS_SpatialMap1D *map, SYMS_U64 x)
Definition syms_data_structures.c:226
SYMS_API SYMS_Line syms_line_from_sequence_voff(SYMS_LineTable *line_table, SYMS_U64 seq_number, SYMS_U64 voff)
Definition syms_data_structures.c:1156
SYMS_API void syms_spatial_map_1d_loose_push_single(SYMS_Arena *arena, SYMS_SpatialMap1DLoose *loose, SYMS_U64 val, SYMS_U64Range range)
Definition syms_data_structures.c:262
SYMS_API SYMS_SpatialMap1D syms_spatial_map_1d_bake(SYMS_Arena *arena, SYMS_SpatialMap1DLoose *loose)
Definition syms_data_structures.c:273
SYMS_API SYMS_SpatialMap1D syms_spatial_map_1d_copy(SYMS_Arena *arena, SYMS_SpatialMap1D *map)
Definition syms_data_structures.c:240
SYMS_API SYMS_U64 syms_data_idx_cons(SYMS_Arena *arena, SYMS_DataIdxCons *cons, SYMS_String8 data)
Definition syms_data_structures.c:49
SYMS_API SYMS_U64 syms_u64_set__bs(SYMS_U64Set *set, SYMS_U64 x)
Definition syms_data_structures.c:97
SYMS_API SYMS_SpatialMultiMap1D syms_spatial_multi_map_1d_bake(SYMS_Arena *arena, SYMS_SpatialMap1DLoose *loose)
Definition syms_data_structures.c:412
SYMS_API SYMS_LineTable syms_line_table_copy(SYMS_Arena *arena, SYMS_LineTable *line_table)
Definition syms_data_structures.c:1171
SYMS_API SYMS_String8 syms_file_id_2_name_map_name_from_id(SYMS_FileID2NameMap *buckets, SYMS_UnitID uid, SYMS_FileID file_id)
Definition syms_data_structures.c:684
SYMS_API SYMS_IDMap syms_id_map_alloc(SYMS_Arena *arena, SYMS_U64 bucket_count)
Definition syms_data_structures.c:966
#define SYMS_STRING_CONS_BUCKET_COUNT
Definition syms_data_structures.h:12
#define SYMS_FILE_ID_TO_NAME_MAP_BUCKET_COUNT
Definition syms_data_structures.h:106
#define SYMS_ID_MAP_NODE_CAP
Definition syms_data_structures.h:178
#define SYMS_SYMBOL_NAME_MAP_BUCKET_COUNT
Definition syms_data_structures.h:202
SYMS_U64 SYMS_UnitID
Definition syms_debug_info.h:77
SYMS_U64 SYMS_FileID
Definition syms_debug_info.h:128
SYMS_U64 SYMS_SymbolID
Definition syms_debug_info.h:215
#define SYMS_Arena
Definition syms_default_arena.h:61
#define SYMS_ProfEnd()
Definition syms_dev.h:212
#define SYMS_ProfBegin(str)
Definition syms_dev.h:209
SYMS_READ_ONLY SYMS_GLOBAL SYMS_LineToAddrMap syms_line_to_addr_map_nil
Definition syms_group.h:112