From 2c9ff37b2c551323d7f1b2067bf55bcc662a00b0 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 21 Mar 2024 13:53:12 -0700 Subject: [PATCH] sketch out new unwind cache types --- src/ctrl/ctrl_core.c | 18 ++++++------------ src/ctrl/ctrl_core.h | 29 ++++++++++++++++++++++++++++- src/dasm/dasm.c | 2 +- src/df/core/df_core.c | 1 - 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 358dd253..ce051f0c 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -43,12 +43,6 @@ ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind) return cause; } -internal B32 -ctrl_handle_match(DMN_Handle a, DMN_Handle b) -{ - return MemoryMatchStruct(&a, &b); -} - //////////////////////////////// //~ rjf: Machine/Handle Pair Type Functions @@ -923,7 +917,7 @@ ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle { for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) { - if(n->machine_id == machine_id && ctrl_handle_match(n->process, process)) + if(n->machine_id == machine_id && dmn_handle_match(n->process, process)) { U64 range_slot_idx = range_hash%n->range_hash_slots_count; CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; @@ -950,7 +944,7 @@ ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle B32 process_node_exists = 0; for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) { - if(n->machine_id == machine_id && ctrl_handle_match(n->process, process)) + if(n->machine_id == machine_id && dmn_handle_match(n->process, process)) { process_node_exists = 1; break; @@ -978,7 +972,7 @@ ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle { for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) { - if(n->machine_id == machine_id && ctrl_handle_match(n->process, process)) + if(n->machine_id == machine_id && dmn_handle_match(n->process, process)) { U64 range_slot_idx = range_hash%n->range_hash_slots_count; CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; @@ -1018,7 +1012,7 @@ ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle { for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) { - if(n->machine_id == machine_id && ctrl_handle_match(n->process, process)) + if(n->machine_id == machine_id && dmn_handle_match(n->process, process)) { U64 range_slot_idx = range_hash%n->range_hash_slots_count; CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; @@ -3662,7 +3656,7 @@ ctrl_mem_stream_thread__entry_point(void *p) { for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) { - if(n->machine_id == machine_id && ctrl_handle_match(n->process, process)) + if(n->machine_id == machine_id && dmn_handle_match(n->process, process)) { U64 range_slot_idx = range_hash%n->range_hash_slots_count; CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; @@ -3739,7 +3733,7 @@ ctrl_mem_stream_thread__entry_point(void *p) { for(CTRL_ProcessMemoryCacheNode *n = process_slot->first; n != 0; n = n->next) { - if(n->machine_id == machine_id && ctrl_handle_match(n->process, process)) + if(n->machine_id == machine_id && dmn_handle_match(n->process, process)) { U64 range_slot_idx = range_hash%n->range_hash_slots_count; CTRL_ProcessMemoryRangeHashSlot *range_slot = &n->range_hash_slots[range_slot_idx]; diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index b55a3d8a..68d8d818 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -471,6 +471,34 @@ struct CTRL_ThreadRegCache CTRL_ThreadRegCacheStripe *stripes; }; +//////////////////////////////// +//~ rjf: Unwind Cache Types + +typedef struct CTRL_UnwindCacheNode CTRL_UnwindCacheNode; +struct CTRL_UnwindCacheNode +{ + CTRL_UnwindCacheNode *next; + CTRL_UnwindCacheNode *prev; + + // rjf: key + CTRL_MachineID machine_id; + DMN_Handle thread; + U64 run_gen; + U64 mem_gen; + U64 reg_gen; + + // rjf: artifacts + CTRL_Unwind unwind; + U64 tls_base_vaddr; +}; + +typedef struct CTRL_UnwindCacheSlot CTRL_UnwindCacheSlot; +struct CTRL_UnwindCacheSlot +{ + CTRL_UnwindCacheNode *first; + CTRL_UnwindCacheNode *last; +}; + //////////////////////////////// //~ rjf: Wakeup Hook Function Types @@ -554,7 +582,6 @@ read_only global CTRL_Entity ctrl_entity_nil = internal U64 ctrl_hash_from_string(String8 string); internal U64 ctrl_hash_from_machine_id_handle(CTRL_MachineID machine_id, DMN_Handle handle); internal CTRL_EventCause ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind); -internal B32 ctrl_handle_match(DMN_Handle a, DMN_Handle b); //////////////////////////////// //~ rjf: Machine/Handle Pair Type Functions diff --git a/src/dasm/dasm.c b/src/dasm/dasm.c index 5434c9e9..8eb51f1d 100644 --- a/src/dasm/dasm.c +++ b/src/dasm/dasm.c @@ -195,7 +195,7 @@ dasm_handle_from_ctrl_process_range_arch(CTRL_MachineID machine, DMN_Handle proc for(DASM_Entity *e = slot->first; e != 0; e = e->next) { if(e->machine_id == machine && - ctrl_handle_match(e->process, process) && + dmn_handle_match(e->process, process) && MemoryMatchStruct(&e->vaddr_range, &vaddr_range) && e->arch == arch) { diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index 9572c86d..eaebebc1 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -6931,7 +6931,6 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt) if(cache_node->unwind.error != 0) { good = 0; - break; } } if(good)