mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
share arena between type deduper and MSF
This commit is contained in:
@@ -1,6 +1,17 @@
|
|||||||
// Copyright (c) Epic Games Tools
|
// Copyright (c) Epic Games Tools
|
||||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||||
|
|
||||||
|
static Arena *g_huge_arena = 0;
|
||||||
|
|
||||||
|
internal Arena *
|
||||||
|
lnk_get_huge_arena(void)
|
||||||
|
{
|
||||||
|
if (g_huge_arena == 0) {
|
||||||
|
g_huge_arena = arena_alloc(.name = "HUGE");
|
||||||
|
}
|
||||||
|
return g_huge_arena;
|
||||||
|
}
|
||||||
|
|
||||||
internal
|
internal
|
||||||
THREAD_POOL_TASK_FUNC(lnk_parse_debug_s_task)
|
THREAD_POOL_TASK_FUNC(lnk_parse_debug_s_task)
|
||||||
{
|
{
|
||||||
@@ -2158,7 +2169,7 @@ internal CV_DebugT *
|
|||||||
lnk_import_types(TP_Context *tp, TP_Arena *tp_temp, LNK_CodeViewInput *input)
|
lnk_import_types(TP_Context *tp, TP_Arena *tp_temp, LNK_CodeViewInput *input)
|
||||||
{
|
{
|
||||||
ProfBegin("Import Types");
|
ProfBegin("Import Types");
|
||||||
Temp scratch = scratch_begin(tp_temp->v, tp_temp->count);
|
Temp scratch = temp_begin(lnk_get_huge_arena());
|
||||||
|
|
||||||
U64 max_ti_list_size = sizeof(CV_TypeIndexInfo) * (max_U16 / sizeof(CV_TypeIndex));
|
U64 max_ti_list_size = sizeof(CV_TypeIndexInfo) * (max_U16 / sizeof(CV_TypeIndex));
|
||||||
Arena **fixed_arenas = alloc_fixed_size_arena_array(scratch.arena, tp->worker_count, max_ti_list_size, max_ti_list_size);
|
Arena **fixed_arenas = alloc_fixed_size_arena_array(scratch.arena, tp->worker_count, max_ti_list_size, max_ti_list_size);
|
||||||
@@ -2366,7 +2377,7 @@ lnk_import_types(TP_Context *tp, TP_Arena *tp_temp, LNK_CodeViewInput *input)
|
|||||||
|
|
||||||
tp_for_parallel_prof(tp, 0, input->total_symbol_input_count, lnk_post_process_cv_symbols_task, &task, "Post Process CV Symbols");
|
tp_for_parallel_prof(tp, 0, input->total_symbol_input_count, lnk_post_process_cv_symbols_task, &task, "Post Process CV Symbols");
|
||||||
|
|
||||||
scratch_end(scratch);
|
temp_end(scratch);
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
return task.types;
|
return task.types;
|
||||||
}
|
}
|
||||||
@@ -3013,13 +3024,14 @@ lnk_build_pdb(TP_Context *tp,
|
|||||||
{
|
{
|
||||||
ProfBegin("PDB");
|
ProfBegin("PDB");
|
||||||
Temp scratch = scratch_begin(tp_arena->v, tp_arena->count);
|
Temp scratch = scratch_begin(tp_arena->v, tp_arena->count);
|
||||||
|
Temp huge_arena_temp = temp_begin(lnk_get_huge_arena());
|
||||||
|
|
||||||
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, image_data);
|
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, image_data);
|
||||||
COFF_SectionHeader **image_section_table = coff_section_table_from_data(scratch.arena, image_data, pe.section_table_range);
|
COFF_SectionHeader **image_section_table = coff_section_table_from_data(scratch.arena, image_data, pe.section_table_range);
|
||||||
U64 image_section_table_count = pe.section_count+1;
|
U64 image_section_table_count = pe.section_count+1;
|
||||||
|
|
||||||
ProfBegin("Setup PDB Context");
|
ProfBegin("Setup PDB Context");
|
||||||
PDB_Context *pdb = pdb_alloc(config->pdb_page_size, config->machine, config->time_stamp, config->age, config->guid);
|
PDB_Context *pdb = pdb_alloc_(huge_arena_temp.arena, config->pdb_page_size, config->machine, config->time_stamp, config->age, config->guid);
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
|
|
||||||
// move patched type data
|
// move patched type data
|
||||||
@@ -3243,6 +3255,7 @@ lnk_build_pdb(TP_Context *tp,
|
|||||||
ProfEnd();
|
ProfEnd();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
temp_end(huge_arena_temp);
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
return page_data_list;
|
return page_data_list;
|
||||||
|
|||||||
@@ -1343,14 +1343,12 @@ msf_stream_align(MSF_Context *msf, MSF_StreamNumber sn, MSF_UInt align)
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal MSF_Context *
|
internal MSF_Context *
|
||||||
msf_alloc__(MSF_UInt page_size, MSF_PageNumber active_fpm)
|
msf_alloc__(Arena *arena, MSF_UInt page_size, MSF_PageNumber active_fpm)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Assert(active_fpm == MSF_FPM0 || active_fpm == MSF_FPM1);
|
Assert(active_fpm == MSF_FPM0 || active_fpm == MSF_FPM1);
|
||||||
Assert(IsPow2(page_size));
|
Assert(IsPow2(page_size));
|
||||||
|
|
||||||
Arena *arena = arena_alloc();
|
|
||||||
|
|
||||||
MSF_Context *msf = push_array(arena, MSF_Context, 1);
|
MSF_Context *msf = push_array(arena, MSF_Context, 1);
|
||||||
msf->arena = arena;
|
msf->arena = arena;
|
||||||
msf->page_size = page_size;
|
msf->page_size = page_size;
|
||||||
@@ -1361,9 +1359,9 @@ msf_alloc__(MSF_UInt page_size, MSF_PageNumber active_fpm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal MSF_Context *
|
internal MSF_Context *
|
||||||
msf_alloc(MSF_UInt page_size, MSF_UInt active_fpm)
|
msf_alloc_(Arena *arena, MSF_UInt page_size, MSF_UInt active_fpm)
|
||||||
{
|
{
|
||||||
MSF_Context *msf = msf_alloc__(page_size, active_fpm);
|
MSF_Context *msf = msf_alloc__(arena, page_size, active_fpm);
|
||||||
|
|
||||||
// reserve first page for header
|
// reserve first page for header
|
||||||
msf->header_page_list = msf_alloc_pages(msf, 1);
|
msf->header_page_list = msf_alloc_pages(msf, 1);
|
||||||
@@ -1378,6 +1376,12 @@ msf_alloc(MSF_UInt page_size, MSF_UInt active_fpm)
|
|||||||
return msf;
|
return msf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal MSF_Context *
|
||||||
|
msf_alloc(MSF_UInt page_size, MSF_UInt active_fpm)
|
||||||
|
{
|
||||||
|
return msf_alloc_(arena_alloc( .name = "MSF"), page_size, active_fpm);
|
||||||
|
}
|
||||||
|
|
||||||
internal MSF_StreamNode *
|
internal MSF_StreamNode *
|
||||||
msf_find_stream_node(MSF_Context *msf, MSF_StreamNumber sn)
|
msf_find_stream_node(MSF_Context *msf, MSF_StreamNumber sn)
|
||||||
{
|
{
|
||||||
@@ -1608,7 +1612,7 @@ msf_open(String8 data, MSF_Context **msf_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allocate MSF context and don't reserve special pages
|
// allocate MSF context and don't reserve special pages
|
||||||
msf = msf_alloc__(header->page_size, header->active_fpm);
|
msf = msf_alloc__(arena_alloc(.name = "MSF"), header->page_size, header->active_fpm);
|
||||||
|
|
||||||
// divide data into fixed size nodes (with 4KB page each node is 128MB)
|
// divide data into fixed size nodes (with 4KB page each node is 128MB)
|
||||||
msf_set_page_data_list(msf->arena, &page_data_list, header->page_size, data);
|
msf_set_page_data_list(msf->arena, &page_data_list, header->page_size, data);
|
||||||
|
|||||||
@@ -3516,10 +3516,10 @@ dbi_push_section(PDB_DbiContext *dbi, COFF_SectionHeader *hdr)
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
internal MSF_Context *
|
internal MSF_Context *
|
||||||
pdb_alloc_msf(U64 page_size)
|
pdb_alloc_msf(Arena *arena, U64 page_size)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
MSF_Context *msf = msf_alloc(page_size, MSF_DEFAULT_FPM);
|
MSF_Context *msf = msf_alloc_(arena, page_size, MSF_DEFAULT_FPM);
|
||||||
MSF_StreamNumber null_sn = msf_stream_alloc(msf);
|
MSF_StreamNumber null_sn = msf_stream_alloc(msf);
|
||||||
MSF_StreamNumber info_sn = msf_stream_alloc(msf);
|
MSF_StreamNumber info_sn = msf_stream_alloc(msf);
|
||||||
MSF_StreamNumber tpi_sn = msf_stream_alloc(msf);
|
MSF_StreamNumber tpi_sn = msf_stream_alloc(msf);
|
||||||
@@ -3535,13 +3535,12 @@ pdb_alloc_msf(U64 page_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal PDB_Context *
|
internal PDB_Context *
|
||||||
pdb_alloc(U64 page_size, COFF_MachineType machine, COFF_TimeStamp time_stamp, U32 age, Guid guid)
|
pdb_alloc_(Arena *arena, U64 page_size, COFF_MachineType machine, COFF_TimeStamp time_stamp, U32 age, Guid guid)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Arena *arena = arena_alloc();
|
|
||||||
PDB_Context *pdb = push_array(arena, PDB_Context, 1);
|
PDB_Context *pdb = push_array(arena, PDB_Context, 1);
|
||||||
pdb->arena = arena;
|
pdb->arena = arena;
|
||||||
pdb->msf = pdb_alloc_msf(page_size);
|
pdb->msf = pdb_alloc_msf(arena, page_size);
|
||||||
pdb->info = pdb_info_alloc(age, time_stamp, guid);
|
pdb->info = pdb_info_alloc(age, time_stamp, guid);
|
||||||
pdb->dbi = dbi_alloc(machine, age);
|
pdb->dbi = dbi_alloc(machine, age);
|
||||||
pdb->gsi = gsi_alloc();
|
pdb->gsi = gsi_alloc();
|
||||||
@@ -3554,6 +3553,12 @@ pdb_alloc(U64 page_size, COFF_MachineType machine, COFF_TimeStamp time_stamp, U3
|
|||||||
return pdb;
|
return pdb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal PDB_Context *
|
||||||
|
pdb_alloc(U64 page_size, COFF_MachineType machine, COFF_TimeStamp time_stamp, U32 age, Guid guid)
|
||||||
|
{
|
||||||
|
return pdb_alloc_(arena_alloc(.name = "PDB"), page_size, machine, time_stamp, age, guid);
|
||||||
|
}
|
||||||
|
|
||||||
internal PDB_Context *
|
internal PDB_Context *
|
||||||
pdb_open(String8 data)
|
pdb_open(String8 data)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user