move most eval paths onto unwrapped-direct path, when needing to rely on the actual shape of the type info & when modifiers are irrelevant

This commit is contained in:
Ryan Fleury
2024-01-20 10:57:59 -08:00
parent 921b555346
commit 2a27b5af51
7 changed files with 42 additions and 56 deletions
+1 -1
View File
@@ -4308,7 +4308,7 @@ df_dynamically_typed_eval_from_eval(TG_Graph *graph, RADDBG_Parsed *rdbg, DF_Ctr
TG_Kind type_kind = tg_kind_from_key(type_key);
if(type_kind == TG_Kind_Ptr)
{
TG_Key ptee_type_key = tg_direct_from_graph_raddbg_key(graph, rdbg, type_key);
TG_Key ptee_type_key = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, type_key);
TG_Kind ptee_type_kind = tg_kind_from_key(ptee_type_key);
if(ptee_type_kind == TG_Kind_Struct || ptee_type_kind == TG_Kind_Class)
{
+5 -5
View File
@@ -7168,7 +7168,7 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
row->errors = block->eval.errors;
if(block_type_kind != TG_Kind_Null)
{
for(TG_Key t = block->eval.type_key;; t = tg_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
for(TG_Key t = block->eval.type_key;; t = tg_unwrapped_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
{
TG_Kind kind = tg_kind_from_key(t);
if(kind == TG_Kind_Null)
@@ -7254,7 +7254,7 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
row->expand_ui_rule_spec = expand_ui_rule_spec;
if(tg_kind_from_key(member_eval.type_key) != TG_Kind_Null)
{
for(TG_Key t = member_eval.type_key;; t = tg_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
for(TG_Key t = member_eval.type_key;; t = tg_unwrapped_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
{
TG_Kind kind = tg_kind_from_key(t);
if(kind == TG_Kind_Null)
@@ -7294,7 +7294,7 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
//- rjf: elements -> produce rows for the visible range of elements.
case DF_EvalVizBlockKind_Elements:
{
TG_Key direct_type_key = tg_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, block->eval.type_key);
TG_Key direct_type_key = tg_unwrapped_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, block->eval.type_key);
TG_Kind direct_type_kind = tg_kind_from_key(direct_type_key);
U64 direct_type_key_byte_size = tg_byte_size_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, direct_type_key);
for(U64 idx = visible_idx_range.min; idx < visible_idx_range.max; idx += 1)
@@ -7338,7 +7338,7 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
row->expand_ui_rule_spec = expand_ui_rule_spec;
if(direct_type_kind != TG_Kind_Null)
{
for(TG_Key t = elem_eval.type_key;; t = tg_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
for(TG_Key t = elem_eval.type_key;; t = tg_unwrapped_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
{
TG_Kind kind = tg_kind_from_key(t);
if(kind == TG_Kind_Null)
@@ -7422,7 +7422,7 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
row->expand_ui_rule_spec = expand_ui_rule_spec;
if(link_type_kind != TG_Kind_Null)
{
for(TG_Key t = link_eval.type_key;; t = tg_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
for(TG_Key t = link_eval.type_key;; t = tg_unwrapped_direct_from_graph_raddbg_key(parse_ctx->type_graph, parse_ctx->rdbg, t))
{
TG_Kind kind = tg_kind_from_key(t);
if(kind == TG_Kind_Null)
+2 -2
View File
@@ -31,7 +31,7 @@ df_view_rule_hooks__rgba_from_eval(DF_Eval eval, TG_Graph *graph, RADDBG_Parsed
U64 array_total_size_capped = ClampTop(array_total_size, 64);
Rng1U64 array_memory_vaddr_rng = r1u64(eval.offset, eval.offset + array_total_size_capped);
String8 array_memory = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, array_memory_vaddr_rng);
TG_Key element_type_key = tg_direct_from_graph_raddbg_key(graph, raddbg, type_key);
TG_Key element_type_key = tg_unwrapped_direct_from_graph_raddbg_key(graph, raddbg, type_key);
TG_Kind element_type_kind = tg_kind_from_key(element_type_key);
U64 element_type_size = tg_byte_size_from_graph_raddbg_key(graph, raddbg, element_type_key);
for(U64 element_idx = 0; element_idx < 4; element_idx += 1)
@@ -128,7 +128,7 @@ df_view_rule_hooks__eval_commit_rgba(DF_Eval eval, TG_Graph *graph, RADDBG_Parse
U64 array_total_size_capped = ClampTop(array_total_size, 64);
Rng1U64 array_memory_vaddr_rng = r1u64(eval.offset, eval.offset + array_total_size_capped);
String8 array_memory = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, array_memory_vaddr_rng);
TG_Key element_type_key = tg_direct_from_graph_raddbg_key(graph, raddbg, type_key);
TG_Key element_type_key = tg_unwrapped_direct_from_graph_raddbg_key(graph, raddbg, type_key);
TG_Kind element_type_kind = tg_kind_from_key(element_type_key);
U64 element_type_size = tg_byte_size_from_graph_raddbg_key(graph, raddbg, element_type_key);
for(U64 element_idx = 0; element_idx < 4; element_idx += 1)
+24 -47
View File
@@ -356,27 +356,6 @@ eval_type_group_from_kind(TG_Kind kind){
return(result);
}
internal TG_Key
eval_type_unwrap(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key)
{
TG_Key result = key;
for(B32 good = 1; good;)
{
TG_Kind kind = tg_kind_from_key(result);
if((TG_Kind_FirstIncomplete <= kind && kind <= TG_Kind_LastIncomplete) ||
kind == TG_Kind_Modifier ||
kind == TG_Kind_Alias)
{
result = tg_direct_from_graph_raddbg_key(graph, rdbg, result);
}
else
{
good = 0;
}
}
return result;
}
internal TG_Key
eval_type_unwrap_enum(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key)
{
@@ -435,8 +414,8 @@ eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
B32 result = 0;
// unwrap
TG_Key lu = eval_type_unwrap(graph, rdbg, l);
TG_Key ru = eval_type_unwrap(graph, rdbg, r);
TG_Key lu = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l);
TG_Key ru = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r);
if (tg_key_match(lu, ru)){
result = 1;
@@ -802,8 +781,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdbg, exprr, eout);
if (l.tree->op != 0 && r.tree->op != 0){
TG_Key l_restype = eval_type_unwrap(graph, rdbg, l.type_key);
TG_Key r_restype = eval_type_unwrap(graph, rdbg, r.type_key);
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
TG_Key r_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r.type_key);
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
TG_Kind r_restype_kind = tg_kind_from_key(r_restype);
@@ -816,7 +795,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
eval_errorf(arena, eout, EVAL_ErrorKind_MalformedInput, exprr->location, "Cannot index with this type.");
}
else{
direct_type = tg_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
direct_type = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
direct_type_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, direct_type);
if (l_restype_kind == TG_Kind_Ptr){
if (direct_type_size == 0){
@@ -881,15 +860,14 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdbg, exprl, eout);
if (l.tree->op != 0 && !tg_key_match(tg_key_zero(), l.type_key)){
TG_Key l_restype = eval_type_unwrap(graph, rdbg, l.type_key);
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
// determine which type to use
TG_Key check_type_key = l_restype;
TG_Kind check_type_kind = l_restype_kind;
if (l_restype_kind == TG_Kind_Ptr || l_restype_kind == TG_Kind_LRef || l_restype_kind == TG_Kind_RRef){
check_type_key = tg_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
check_type_key = eval_type_unwrap(graph, rdbg, check_type_key);
check_type_key = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
check_type_kind = tg_kind_from_key(check_type_key);
}
@@ -1000,15 +978,17 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, exprc, eout);
if (c.tree->op != 0){
TG_Key c_restype = eval_type_unwrap(graph, rdbg, c.type_key);
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
TG_Key c_restype_direct = tg_direct_from_graph_raddbg_key(graph, rdbg, c_restype);
TG_Key c_restype_direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, c_restype);
U64 c_restype_direct_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, c_restype_direct);
// analyze situation
B32 can_generate = 0;
B32 c_resolve = 0;
if (c_restype_kind == TG_Kind_Ptr){
if (c_restype_kind == TG_Kind_Ptr ||
c_restype_kind == TG_Kind_LRef ||
c_restype_kind == TG_Kind_RRef){
if (c_restype_direct_size == 0){
eval_errorf(arena, eout, EVAL_ErrorKind_MalformedInput, exprc->location, "Cannot dereference pointers of zero-sized types.");
}
@@ -1055,7 +1035,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, exprc, eout);
if(c.tree->op != 0 && !tg_key_match(c.type_key, tg_key_zero()))
{
TG_Key c_restype = eval_type_unwrap(graph, rdbg, c.type_key);
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
// analyze situation
@@ -1090,7 +1070,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
if(cast_type_kind != TG_Kind_Null && c.tree->op != 0)
{
TG_Key c_restype = eval_type_unwrap(graph, rdbg, c.type_key);
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
U64 c_restype_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, c_restype);
U64 cast_type_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, cast_type_key);
@@ -1182,7 +1162,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, exprc, eout);
if (c.tree->op != 0){
TG_Key c_restype = eval_type_unwrap(graph, rdbg, c.type_key);
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
TG_Key p_type = eval_type_promote(graph, rdbg, c_restype);
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
@@ -1238,8 +1218,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdbg, exprr, eout);
if (l.tree->op != 0 && r.tree->op != 0){
TG_Key l_restype = eval_type_unwrap(graph, rdbg, l.type_key);
TG_Key r_restype = eval_type_unwrap(graph, rdbg, r.type_key);
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
TG_Key r_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r.type_key);
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
TG_Kind r_restype_kind = tg_kind_from_key(r_restype);
@@ -1287,8 +1267,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
arith_path = EVAL_ArithPath_PtrAdd;
}
if (l_is_pointer_like && r_is_pointer_like){
TG_Key l_restype_direct = tg_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
TG_Key r_restype_direct = tg_direct_from_graph_raddbg_key(graph, rdbg, r_restype);
TG_Key l_restype_direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
TG_Key r_restype_direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, r_restype);
U64 l_restype_direct_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, l_restype_direct);
U64 r_restype_direct_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, r_restype_direct);
if (l_restype_direct_byte_size == r_restype_direct_byte_size){
@@ -1359,7 +1339,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
ptr_is_decay = r_is_decay;
}
TG_Key direct = tg_direct_from_graph_raddbg_key(graph, rdbg, ptr->type_key);
TG_Key direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, ptr->type_key);
U64 direct_type_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, direct);
// generate ir tree
@@ -1388,7 +1368,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
case EVAL_ArithPath_PtrSub:
{
TG_Key direct = tg_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
TG_Key direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
U64 direct_type_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, direct);
// generate ir tree
@@ -1430,9 +1410,9 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
if (l.tree->op != 0 && r.tree->op != 0 && c.tree->op != 0){
TG_Key c_restype = eval_type_unwrap(graph, rdbg, c.type_key);
TG_Key l_restype = eval_type_unwrap(graph, rdbg, l.type_key);
TG_Key r_restype = eval_type_unwrap(graph, rdbg, r.type_key);
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
TG_Key r_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r.type_key);
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
TG_Kind r_restype_kind = tg_kind_from_key(r_restype);
@@ -1625,6 +1605,3 @@ eval_oplist_from_irtree(Arena *arena, EVAL_IRTree *tree, EVAL_OpList *out){
}break;
}
}
-1
View File
@@ -164,7 +164,6 @@ internal EVAL_Expr* eval_expr_leaf_type(Arena *arena, void *location, TG_Key typ
internal RADDBG_EvalTypeGroup eval_type_group_from_kind(TG_Kind kind);
internal TG_Key eval_type_unwrap(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key eval_type_unwrap_enum(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key eval_type_promote(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key eval_type_coerce(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r);
+9
View File
@@ -810,6 +810,15 @@ tg_direct_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key
return result;
}
internal TG_Key
tg_unwrapped_direct_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key)
{
key = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, key);
key = tg_direct_from_graph_raddbg_key(graph, rdbg, key);
key = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, key);
return key;
}
internal TG_Key
tg_owner_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key)
{
+1
View File
@@ -226,6 +226,7 @@ internal TG_Key tg_cons_type_make(TG_Graph *graph, TG_Kind kind, TG_Key direct_t
internal TG_Type *tg_type_from_graph_raddbg_key(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key tg_direct_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key tg_unwrapped_direct_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key tg_owner_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key tg_ptee_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
internal TG_Key tg_unwrapped_from_graph_raddbg_key(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);