@@ -605,6 +605,62 @@ p2r_comp_unit_contributions_parse_task__entry_point(Arena *arena, void *p)
605
605
return out ;
606
606
}
607
607
608
+ ////////////////////////////////
609
+ //~ rjf: Link Name Map Building Task
610
+
611
+ internal void *
612
+ p2r_link_name_map_build_task__entry_point (Arena * arena , void * p )
613
+ {
614
+ P2R_LinkNameMapBuildIn * in = (P2R_LinkNameMapBuildIn * )p ;
615
+ CV_RecRange * rec_ranges_first = in -> sym -> sym_ranges .ranges ;
616
+ CV_RecRange * rec_ranges_opl = rec_ranges_first + in -> sym -> sym_ranges .count ;
617
+ for (CV_RecRange * rec_range = rec_ranges_first ;
618
+ rec_range < rec_ranges_opl ;
619
+ rec_range += 1 )
620
+ {
621
+ //- rjf: unpack symbol range info
622
+ CV_SymKind kind = rec_range -> hdr .kind ;
623
+ U64 header_struct_size = cv_header_struct_size_from_sym_kind (kind );
624
+ U8 * sym_first = in -> sym -> data .str + rec_range -> off + 2 ;
625
+ U8 * sym_opl = sym_first + rec_range -> hdr .size ;
626
+
627
+ //- rjf: skip bad ranges
628
+ if (sym_opl > in -> sym -> data .str + in -> sym -> data .size || sym_first + header_struct_size > in -> sym -> data .str + in -> sym -> data .size )
629
+ {
630
+ continue ;
631
+ }
632
+
633
+ //- rjf: consume symbol
634
+ switch (kind )
635
+ {
636
+ default :{}break ;
637
+ case CV_SymKind_PUB32 :
638
+ {
639
+ // rjf: unpack sym
640
+ CV_SymPub32 * pub32 = (CV_SymPub32 * )sym_first ;
641
+ String8 name = str8_cstring_capped (pub32 + 1 , sym_opl );
642
+ COFF_SectionHeader * section = (0 < pub32 -> sec && pub32 -> sec <= in -> coff_sections -> count ) ? & in -> coff_sections -> sections [pub32 -> sec - 1 ] : 0 ;
643
+ U64 voff = 0 ;
644
+ if (section != 0 )
645
+ {
646
+ voff = section -> voff + pub32 -> off ;
647
+ }
648
+
649
+ // rjf: commit to link name map
650
+ U64 hash = p2r_hash_from_voff (voff );
651
+ U64 bucket_idx = hash %in -> link_name_map -> buckets_count ;
652
+ P2R_LinkNameNode * node = push_array (arena , P2R_LinkNameNode , 1 );
653
+ SLLStackPush (in -> link_name_map -> buckets [bucket_idx ], node );
654
+ node -> voff = voff ;
655
+ node -> name = name ;
656
+ in -> link_name_map -> link_name_count += 1 ;
657
+ in -> link_name_map -> bucket_collision_count += (node -> next != 0 );
658
+ }break ;
659
+ }
660
+ }
661
+ return 0 ;
662
+ }
663
+
608
664
////////////////////////////////
609
665
//~ rjf: Type Parsing/Conversion Tasks
610
666
@@ -2068,6 +2124,22 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
2068
2124
}
2069
2125
}
2070
2126
2127
+ //////////////////////////////////////////////////////////////
2128
+ //- rjf: kick off link name map production
2129
+ //
2130
+ P2R_LinkNameMap link_name_map__in_progress = {0 };
2131
+ P2R_LinkNameMapBuildIn link_name_map_build_in = {0 };
2132
+ TS_Ticket link_name_map_ticket = {0 };
2133
+ ProfScope ("kick off link name map build task" )
2134
+ {
2135
+ link_name_map__in_progress .buckets_count = symbol_count_prediction ;
2136
+ link_name_map__in_progress .buckets = push_array (arena , P2R_LinkNameNode * , link_name_map__in_progress .buckets_count );
2137
+ link_name_map_build_in .sym = sym ;
2138
+ link_name_map_build_in .coff_sections = coff_sections ;
2139
+ link_name_map_build_in .link_name_map = & link_name_map__in_progress ;
2140
+ link_name_map_ticket = ts_kickoff (p2r_link_name_map_build_task__entry_point , & link_name_map_build_in );
2141
+ }
2142
+
2071
2143
//////////////////////////////////////////////////////////////
2072
2144
//- rjf: types pass 1: produce type forward resolution map
2073
2145
//
@@ -3172,59 +3244,13 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
3172
3244
}
3173
3245
3174
3246
//////////////////////////////////////////////////////////////
3175
- //- rjf: produce link name map
3247
+ //- rjf: join link name map building task
3176
3248
//
3177
- P2R_LinkNameMap link_name_map = { 0 } ;
3178
- ProfScope ("produce link name map" )
3249
+ P2R_LinkNameMap * link_name_map = 0 ;
3250
+ ProfScope ("join link name map building task " )
3179
3251
{
3180
- link_name_map .buckets_count = symbol_count_prediction ;
3181
- link_name_map .buckets = push_array (arena , P2R_LinkNameNode * , link_name_map .buckets_count );
3182
- CV_RecRange * rec_ranges_first = sym -> sym_ranges .ranges ;
3183
- CV_RecRange * rec_ranges_opl = rec_ranges_first + sym -> sym_ranges .count ;
3184
- for (CV_RecRange * rec_range = rec_ranges_first ;
3185
- rec_range < rec_ranges_opl ;
3186
- rec_range += 1 )
3187
- {
3188
- //- rjf: unpack symbol range info
3189
- CV_SymKind kind = rec_range -> hdr .kind ;
3190
- U64 header_struct_size = cv_header_struct_size_from_sym_kind (kind );
3191
- U8 * sym_first = sym -> data .str + rec_range -> off + 2 ;
3192
- U8 * sym_opl = sym_first + rec_range -> hdr .size ;
3193
-
3194
- //- rjf: skip bad ranges
3195
- if (sym_opl > sym -> data .str + sym -> data .size || sym_first + header_struct_size > sym -> data .str + sym -> data .size )
3196
- {
3197
- continue ;
3198
- }
3199
-
3200
- //- rjf: consume symbol
3201
- switch (kind )
3202
- {
3203
- default :{}break ;
3204
- case CV_SymKind_PUB32 :
3205
- {
3206
- // rjf: unpack sym
3207
- CV_SymPub32 * pub32 = (CV_SymPub32 * )sym_first ;
3208
- String8 name = str8_cstring_capped (pub32 + 1 , sym_opl );
3209
- COFF_SectionHeader * section = (0 < pub32 -> sec && pub32 -> sec <= coff_sections -> count ) ? & coff_sections -> sections [pub32 -> sec - 1 ] : 0 ;
3210
- U64 voff = 0 ;
3211
- if (section != 0 )
3212
- {
3213
- voff = section -> voff + pub32 -> off ;
3214
- }
3215
-
3216
- // rjf: commit to link name map
3217
- U64 hash = p2r_hash_from_voff (voff );
3218
- U64 bucket_idx = hash %link_name_map .buckets_count ;
3219
- P2R_LinkNameNode * node = push_array (arena , P2R_LinkNameNode , 1 );
3220
- SLLStackPush (link_name_map .buckets [bucket_idx ], node );
3221
- node -> voff = voff ;
3222
- node -> name = name ;
3223
- link_name_map .link_name_count += 1 ;
3224
- link_name_map .bucket_collision_count += (node -> next != 0 );
3225
- }break ;
3226
- }
3227
- }
3252
+ ts_join (link_name_map_ticket , max_U64 );
3253
+ link_name_map = & link_name_map__in_progress ;
3228
3254
}
3229
3255
3230
3256
//////////////////////////////////////////////////////////////
@@ -3254,7 +3280,7 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
3254
3280
tasks_inputs [idx ].tpi_leaf = tpi_leaf ;
3255
3281
tasks_inputs [idx ].itype_fwd_map = itype_fwd_map ;
3256
3282
tasks_inputs [idx ].itype_type_ptrs = itype_type_ptrs ;
3257
- tasks_inputs [idx ].link_name_map = & link_name_map ;
3283
+ tasks_inputs [idx ].link_name_map = link_name_map ;
3258
3284
if (idx < global_stream_subdivision_tasks_count )
3259
3285
{
3260
3286
tasks_inputs [idx ].sym = sym ;
@@ -3307,3 +3333,28 @@ p2r_convert(Arena *arena, P2R_ConvertIn *in)
3307
3333
scratch_end (scratch );
3308
3334
return out ;
3309
3335
}
3336
+
3337
+ ////////////////////////////////
3338
+ //~ rjf: Top-Level Baking Entry Point
3339
+
3340
+ internal P2R_BakeOut *
3341
+ p2r_bake (Arena * arena , P2R_BakeIn * in )
3342
+ {
3343
+ RDIM_BakeParams bake_params = {0 };
3344
+ {
3345
+ bake_params .top_level_info = in -> top_level_info ;
3346
+ bake_params .binary_sections = in -> binary_sections ;
3347
+ bake_params .units = in -> units ;
3348
+ bake_params .types = in -> types ;
3349
+ bake_params .udts = in -> udts ;
3350
+ bake_params .global_variables = in -> global_variables ;
3351
+ bake_params .thread_variables = in -> thread_variables ;
3352
+ bake_params .procedures = in -> procedures ;
3353
+ bake_params .scopes = in -> scopes ;
3354
+ }
3355
+ RDIM_BakeSectionList sections = rdim_bake_sections_from_params (arena , & bake_params );
3356
+ String8List bake_strings = rdim_blobs_from_bake_sections (arena , & sections );
3357
+ P2R_BakeOut * out = push_array (arena , P2R_BakeOut , 1 );
3358
+ out -> blobs = bake_strings ;
3359
+ return out ;
3360
+ }
0 commit comments