adjust new call stack artifact cache hooks to work gracefully with terminated threads/processes

This commit is contained in:
Ryan Fleury
2025-09-24 16:06:46 -07:00
parent 3dc3707b22
commit 10e8a10d9b
5 changed files with 17 additions and 18 deletions
+12 -10
View File
@@ -7727,11 +7727,15 @@ ctrl_call_stack_artifact_create(String8 key, B32 *retry_out)
} }
//- rjf: compute call stack //- rjf: compute call stack
B32 good = 0; CTRL_Entity *thread = ctrl_entity_from_handle(entity_ctx, thread_handle);
Arena *arena = arena_alloc(); B32 good = 1;
CTRL_CallStack *call_stack = push_array(arena, CTRL_CallStack, 1); Arena *arena = 0;
CTRL_CallStack *call_stack = 0;
if(thread != &ctrl_entity_nil)
{ {
CTRL_Entity *thread = ctrl_entity_from_handle(entity_ctx, thread_handle); good = 0;
arena = arena_alloc();
call_stack = push_array(arena, CTRL_CallStack, 1);
CTRL_Entity *process = ctrl_process_from_entity(thread); CTRL_Entity *process = ctrl_process_from_entity(thread);
U64 pre_reg_gen = 0; U64 pre_reg_gen = 0;
U64 post_reg_gen = 0; U64 post_reg_gen = 0;
@@ -7754,6 +7758,10 @@ ctrl_call_stack_artifact_create(String8 key, B32 *retry_out)
{ {
good = 0; good = 0;
} }
if(!good)
{
arena_release(arena);
}
} }
//- rjf: broadcast update //- rjf: broadcast update
@@ -7769,12 +7777,6 @@ ctrl_call_stack_artifact_create(String8 key, B32 *retry_out)
artifact.u64[1] = (U64)call_stack; artifact.u64[1] = (U64)call_stack;
} }
//- rjf: release results on bad
if(!good)
{
arena_release(arena);
}
//- rjf: retry on bad //- rjf: retry on bad
if(!good) if(!good)
{ {
+1 -3
View File
@@ -184,7 +184,7 @@ fs_artifact_create(String8 key, B32 *retry_out)
} }
MemoryZeroStruct(node); MemoryZeroStruct(node);
node->path = str8_copy(stripe->arena, path); node->path = str8_copy(stripe->arena, path);
DLLPushBack(slot->first, slot->last, node); SLLQueuePush(slot->first, slot->last, node);
} }
node->last_modified_timestamp = pre_props.modified; node->last_modified_timestamp = pre_props.modified;
node->size = pre_props.size; node->size = pre_props.size;
@@ -207,7 +207,6 @@ fs_artifact_destroy(AC_Artifact artifact)
{ {
C_Key key = {0}; C_Key key = {0};
MemoryCopyStruct(&key, &artifact); MemoryCopyStruct(&key, &artifact);
key._padding_ = 0;
c_close_key(key); c_close_key(key);
} }
@@ -247,7 +246,6 @@ fs_key_from_path_range(String8 path, Rng1U64 range, U64 endt_us)
//- rjf: map to artifact //- rjf: map to artifact
AC_Artifact artifact = ac_artifact_from_key(access, key, fs_artifact_create, fs_artifact_destroy, endt_us, .gen = gen); AC_Artifact artifact = ac_artifact_from_key(access, key, fs_artifact_create, fs_artifact_destroy, endt_us, .gen = gen);
MemoryCopyStruct(&result, &artifact); MemoryCopyStruct(&result, &artifact);
result._padding_ = 0;
} }
access_close(access); access_close(access);
scratch_end(scratch); scratch_end(scratch);
-1
View File
@@ -11,7 +11,6 @@ typedef struct FS_Node FS_Node;
struct FS_Node struct FS_Node
{ {
FS_Node *next; FS_Node *next;
FS_Node *prev;
String8 path; String8 path;
U64 gen; U64 gen;
U64 last_modified_timestamp; U64 last_modified_timestamp;
+3 -3
View File
@@ -12493,10 +12493,10 @@ rd_frame(void)
}; };
for EachElement(idx, table) for EachElement(idx, table)
{ {
C_Scope *c_scope = c_scope_open(); Access *access = access_open();
C_Key key = table[idx].key; C_Key key = table[idx].key;
U128 hash = c_hash_from_key(key, 0); U128 hash = c_hash_from_key(key, 0);
String8 data = c_data_from_hash(c_scope, hash); String8 data = c_data_from_hash(access, hash);
E_Space space = e_space_make(E_SpaceKind_HashStoreKey); E_Space space = e_space_make(E_SpaceKind_HashStoreKey);
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, r1u64(0, 0)); E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, r1u64(0, 0));
space.u64_0 = key.root.u64[0]; space.u64_0 = key.root.u64[0];
@@ -12505,7 +12505,7 @@ rd_frame(void)
expr->mode = E_Mode_Offset; expr->mode = E_Mode_Offset;
expr->type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), data.size, 0); expr->type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), data.size, 0);
e_string2expr_map_insert(scratch.arena, macro_map, table[idx].name, expr); e_string2expr_map_insert(scratch.arena, macro_map, table[idx].name, expr);
c_scope_close(c_scope); access_close(access);
} }
} }
#endif #endif
+1 -1
View File
@@ -968,7 +968,7 @@ E_TYPE_IREXT_FUNCTION_DEF(call_stack)
B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread); B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread);
accel->arch = entity->arch; accel->arch = entity->arch;
accel->process = ctrl_process_from_entity(entity)->handle; accel->process = ctrl_process_from_entity(entity)->handle;
accel->call_stack = ctrl_call_stack_from_thread(rd_state->frame_ctrl_scope, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); accel->call_stack = ctrl_call_stack_from_thread_new(rd_state->frame_access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0);
} }
scratch_end(scratch); scratch_end(scratch);
} }