mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-26 21:44:59 -07:00
expand match store cache to include all match info
This commit is contained in:
+33
-6
@@ -1590,6 +1590,10 @@ di_match_store_alloc(void)
|
||||
store->u2m_ring_mutex = os_mutex_alloc();
|
||||
store->u2m_ring_size = KB(2);
|
||||
store->u2m_ring_base = push_array_no_zero(arena, U8, store->u2m_ring_size);
|
||||
store->m2u_ring_cv = os_condition_variable_alloc();
|
||||
store->m2u_ring_mutex = os_mutex_alloc();
|
||||
store->m2u_ring_size = KB(2);
|
||||
store->m2u_ring_base = push_array_no_zero(arena, U8, store->m2u_ring_size);
|
||||
return store;
|
||||
}
|
||||
|
||||
@@ -1638,13 +1642,21 @@ di_match_store_begin(DI_MatchStore *store, DI_KeyArray keys)
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: pop new matches
|
||||
#if 0
|
||||
for(;;)
|
||||
{
|
||||
U64 unconsumed_size = store->m2u_ring_write_pos - store->m2u_ring_read_pos;
|
||||
}
|
||||
#endif
|
||||
|
||||
ProfEnd();
|
||||
}
|
||||
|
||||
internal RDI_SectionKind
|
||||
di_match_store_section_kind_from_name(DI_MatchStore *store, String8 name, U64 endt_us)
|
||||
internal DI_Match
|
||||
di_match_from_name(DI_MatchStore *store, String8 name, U64 endt_us)
|
||||
{
|
||||
RDI_SectionKind result = 0;
|
||||
DI_Match result = {0};
|
||||
{
|
||||
// rjf: unpack name
|
||||
U64 hash = di_hash_from_string(name, 0);
|
||||
@@ -1743,7 +1755,7 @@ di_match_store_section_kind_from_name(DI_MatchStore *store, String8 name, U64 en
|
||||
}
|
||||
|
||||
// rjf: return node present info
|
||||
result = node->section_kind;
|
||||
result = node->primary_match;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1783,7 +1795,9 @@ ASYNC_WORK_DEF(di_match_work)
|
||||
params_hash = store->params_hash;
|
||||
}
|
||||
|
||||
//- rjf: do match
|
||||
//- rjf: gather matches
|
||||
DI_MatchNode *first_match = 0;
|
||||
DI_MatchNode *last_match = 0;
|
||||
RDI_NameMapKind name_map_kinds[] =
|
||||
{
|
||||
RDI_NameMapKind_GlobalVariables,
|
||||
@@ -1815,7 +1829,20 @@ ASYNC_WORK_DEF(di_match_work)
|
||||
U32 *run = rdi_matches_from_map_node(rdi, map_node, &num);
|
||||
if(num != 0)
|
||||
{
|
||||
ins_atomic_u32_eval_assign(&node->section_kind, name_map_section_kinds[name_map_kind_idx]);
|
||||
// rjf: atomically update the node's primary match
|
||||
ins_atomic_u64_eval_assign(&node->primary_match.dbgi_idx, dbgi_idx);
|
||||
ins_atomic_u32_eval_assign(&node->primary_match.section, name_map_section_kinds[name_map_kind_idx]);
|
||||
ins_atomic_u32_eval_assign(&node->primary_match.idx, run[0]);
|
||||
|
||||
// rjf: gather all alternate matches
|
||||
for(U32 match_idx = 1; match_idx < num; match_idx += 1)
|
||||
{
|
||||
DI_MatchNode *m = push_array(scratch.arena, DI_MatchNode, 1);
|
||||
SLLQueuePush(first_match, last_match, m);
|
||||
m->v.dbgi_idx = dbgi_idx;
|
||||
m->v.section = name_map_section_kinds[name_map_kind_idx];
|
||||
m->v.idx = run[match_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
di_scope_close(di_scope);
|
||||
|
||||
+19
-6
@@ -263,13 +263,18 @@ struct DI_SearchThread
|
||||
typedef struct DI_Match DI_Match;
|
||||
struct DI_Match
|
||||
{
|
||||
DI_Match *next;
|
||||
DI_Match *prev;
|
||||
U64 dbgi_idx;
|
||||
RDI_SectionKind section;
|
||||
U32 idx;
|
||||
};
|
||||
|
||||
typedef struct DI_MatchNode DI_MatchNode;
|
||||
struct DI_MatchNode
|
||||
{
|
||||
DI_MatchNode *next;
|
||||
DI_Match v;
|
||||
};
|
||||
|
||||
typedef struct DI_MatchNameNode DI_MatchNameNode;
|
||||
struct DI_MatchNameNode
|
||||
{
|
||||
@@ -289,9 +294,9 @@ struct DI_MatchNameNode
|
||||
// rjf: atomically written by match work
|
||||
U64 cmp_count;
|
||||
U64 cmp_params_hash;
|
||||
RDI_SectionKind section_kind;
|
||||
// DI_Match *first_match;
|
||||
// DI_Match *last_match;
|
||||
DI_Match primary_match;
|
||||
// DI_MatchNode *first_alt_match;
|
||||
// DI_MatchNode *last_alt_match;
|
||||
};
|
||||
|
||||
typedef struct DI_MatchNameSlot DI_MatchNameSlot;
|
||||
@@ -332,6 +337,14 @@ struct DI_MatchStore
|
||||
U8 *u2m_ring_base;
|
||||
U64 u2m_ring_write_pos;
|
||||
U64 u2m_ring_read_pos;
|
||||
|
||||
// rjf: match -> user work ring buffer
|
||||
OS_Handle m2u_ring_cv;
|
||||
OS_Handle m2u_ring_mutex;
|
||||
U64 m2u_ring_size;
|
||||
U8 *m2u_ring_base;
|
||||
U64 m2u_ring_write_pos;
|
||||
U64 m2u_ring_read_pos;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -470,7 +483,7 @@ internal void di_search_evictor_thread__entry_point(void *p);
|
||||
|
||||
internal DI_MatchStore *di_match_store_alloc(void);
|
||||
internal void di_match_store_begin(DI_MatchStore *store, DI_KeyArray keys);
|
||||
internal RDI_SectionKind di_match_store_section_kind_from_name(DI_MatchStore *store, String8 name, U64 endt_us);
|
||||
internal DI_Match di_match_from_name(DI_MatchStore *store, String8 name, U64 endt_us);
|
||||
ASYNC_WORK_DEF(di_match_work);
|
||||
|
||||
#endif // DBGI_H
|
||||
|
||||
@@ -10287,7 +10287,7 @@ rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8
|
||||
// rjf: try to map using asynchronous matching system
|
||||
if(!mapped && kind == TXT_TokenKind_Identifier)
|
||||
{
|
||||
RDI_SectionKind section_kind = di_match_store_section_kind_from_name(rd_state->match_store, string, 0);
|
||||
RDI_SectionKind section_kind = di_match_from_name(rd_state->match_store, string, 0).section;
|
||||
mapped = 1;
|
||||
switch(section_kind)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user