adjust block tree building from being on expr -> being on eval

This commit is contained in:
Ryan Fleury
2025-04-23 14:45:15 -07:00
parent a27b90a3f9
commit c9a05bc76f
9 changed files with 49 additions and 40 deletions
+8 -8
View File
@@ -1466,16 +1466,15 @@ ctrl_stored_hash_from_process_vaddr_range(CTRL_Handle process, Rng1U64 range, B3
U128 result = {0};
U64 size = dim_1u64(range);
U64 pre_mem_gen = dmn_mem_gen();
CTRL_ProcessMemoryCache *cache = &ctrl_state->process_memory_cache;
U64 range_hash = ctrl_hash_from_string(str8_struct(&range));
U64 process_hash = ctrl_hash_from_string(str8_struct(&process));
U64 process_slot_idx = process_hash%cache->slots_count;
U64 process_stripe_idx = process_slot_idx%cache->stripes_count;
CTRL_ProcessMemoryCacheSlot *process_slot = &cache->slots[process_slot_idx];
CTRL_ProcessMemoryCacheStripe *process_stripe = &cache->stripes[process_stripe_idx];
if(size != 0) for(;;)
{
CTRL_ProcessMemoryCache *cache = &ctrl_state->process_memory_cache;
U64 process_hash = ctrl_hash_from_string(str8_struct(&process));
U64 process_slot_idx = process_hash%cache->slots_count;
U64 process_stripe_idx = process_slot_idx%cache->stripes_count;
CTRL_ProcessMemoryCacheSlot *process_slot = &cache->slots[process_slot_idx];
CTRL_ProcessMemoryCacheStripe *process_stripe = &cache->stripes[process_stripe_idx];
U64 range_hash = ctrl_hash_from_string(str8_struct(&range));
//- rjf: try to read from cache
B32 is_good = 0;
B32 process_node_exists = 0;
@@ -6353,6 +6352,7 @@ ASYNC_WORK_DEF(ctrl_mem_stream_work)
{
ProfBeginFunction();
CTRL_ProcessMemoryCache *cache = &ctrl_state->process_memory_cache;
//- rjf: unpack next request
CTRL_Handle process = {0};
Rng1U64 vaddr_range = {0};
+12
View File
@@ -33,10 +33,14 @@ e_eval_from_expr(Arena *arena, E_Expr *expr)
internal E_Eval
e_eval_from_string(Arena *arena, String8 string)
{
ProfBeginFunction();
ProfBegin("e_eval_from_string (%.*s)", str8_varg(string));
E_TokenArray tokens = e_token_array_from_text(arena, string);
E_Parse parse = e_parse_expr_from_text_tokens(arena, string, tokens);
E_Eval eval = e_eval_from_expr(arena, parse.expr);
e_msg_list_concat_in_place(&eval.msgs, &parse.msgs);
ProfEnd();
ProfEnd();
return eval;
}
@@ -217,6 +221,14 @@ e_value_from_expr(E_Expr *expr)
return result;
}
internal E_Value
e_value_from_eval(E_Eval eval)
{
E_Eval value_eval = e_value_eval_from_eval(eval);
E_Value result = value_eval.value;
return result;
}
internal E_Eval
e_eval_wrap(Arena *arena, E_Eval eval, String8 string)
{
+1 -20
View File
@@ -4,26 +4,6 @@
#ifndef EVAL_BUNDLES_H
#define EVAL_BUNDLES_H
////////////////////////////////
//~ rjf: Bundled Evaluation Path Types
typedef struct E_Eval E_Eval;
struct E_Eval
{
E_Value value;
E_Space space;
E_Expr *expr;
E_IRTreeAndType irtree;
String8 bytecode;
E_InterpretationCode code;
E_MsgList msgs;
};
////////////////////////////////
//~ rjf: Globals
read_only global E_Eval e_eval_nil = {zero_struct, zero_struct, &e_expr_nil, {&e_irnode_nil}};
////////////////////////////////
//~ rjf: Bundled Evaluation Functions
@@ -35,6 +15,7 @@ internal E_Eval e_value_eval_from_eval(E_Eval eval);
internal E_Value e_value_from_string(String8 string);
internal E_Value e_value_from_stringf(char *fmt, ...);
internal E_Value e_value_from_expr(E_Expr *expr);
internal E_Value e_value_from_eval(E_Eval eval);
internal E_Eval e_eval_wrap(Arena *arena, E_Eval eval, String8 string);
internal E_Eval e_eval_wrapf(Arena *arena, E_Eval eval, char *fmt, ...);;
+21 -1
View File
@@ -303,6 +303,21 @@ struct E_IRTreeAndType
E_IRTreeAndType *prev;
};
////////////////////////////////
//~ rjf: Evaluation Artifact Bundle
typedef struct E_Eval E_Eval;
struct E_Eval
{
E_Value value;
E_Space space;
E_Expr *expr;
E_IRTreeAndType irtree;
String8 bytecode;
E_InterpretationCode code;
E_MsgList msgs;
};
////////////////////////////////
//~ rjf: Full Extracted Type Information Types
@@ -628,7 +643,12 @@ struct E_BaseCtx
////////////////////////////////
//~ rjf: Globals
global read_only E_Module e_module_nil = {&rdi_parsed_nil};
read_only global E_String2NumMap e_string2num_map_nil = {0};
read_only global E_String2ExprMap e_string2expr_map_nil = {0};
read_only global E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil};
read_only global E_IRNode e_irnode_nil = {&e_irnode_nil, &e_irnode_nil, &e_irnode_nil};
read_only global E_Eval e_eval_nil = {zero_struct, zero_struct, &e_expr_nil, {&e_irnode_nil}};
read_only global E_Module e_module_nil = {&rdi_parsed_nil};
thread_static E_BaseCtx *e_base_ctx = 0;
thread_static U64 e_base_ctx_gen = 0;
-1
View File
@@ -126,7 +126,6 @@ struct E_IRState
////////////////////////////////
//~ rjf: Globals
global read_only E_IRNode e_irnode_nil = {&e_irnode_nil, &e_irnode_nil, &e_irnode_nil};
thread_static E_IRState *e_ir_state = 0;
////////////////////////////////
+1 -3
View File
@@ -29,9 +29,7 @@ struct E_ParseState
////////////////////////////////
//~ rjf: Globals
global read_only E_String2NumMap e_string2num_map_nil = {0};
global read_only E_String2ExprMap e_string2expr_map_nil = {0};
global read_only E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil};
thread_static E_ParseState *e_parse_state = 0;
////////////////////////////////
@@ -512,7 +512,7 @@ ev_resolved_from_expr(Arena *arena, E_Expr *expr)
//~ rjf: Block Building
internal EV_BlockTree
ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, E_Expr *expr)
ev_block_tree_from_eval(Arena *arena, EV_View *view, String8 filter, E_Eval eval)
{
ProfBeginFunction();
EV_BlockTree tree = {&ev_nil_block};
@@ -522,14 +522,13 @@ ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, E_Expr *exp
//- rjf: generate root expression
EV_Key root_key = ev_key_root();
EV_Key root_row_key = ev_key_make(ev_hash_from_key(root_key), 1);
E_Expr *root_expr = e_expr_copy(arena, expr);
//- rjf: generate root block
tree.root = push_array(arena, EV_Block, 1);
MemoryCopyStruct(tree.root, &ev_nil_block);
tree.root->key = root_key;
tree.root->string = str8_zero();
tree.root->eval = e_eval_from_expr(arena, root_expr);
tree.root->eval = eval;
tree.root->type_expand_rule = &e_type_expand_rule__default;
tree.root->viz_expand_rule = &ev_nil_expand_rule;
tree.root->row_count = 1;
@@ -351,7 +351,7 @@ internal E_Expr *ev_resolved_from_expr(Arena *arena, E_Expr *expr);
////////////////////////////////
//~ rjf: Block Building
internal EV_BlockTree ev_block_tree_from_expr(Arena *arena, EV_View *view, String8 filter, E_Expr *expr);
internal EV_BlockTree ev_block_tree_from_eval(Arena *arena, EV_View *view, String8 filter, E_Eval eval);
internal U64 ev_depth_from_block(EV_Block *block);
////////////////////////////////
+3 -3
View File
@@ -2790,7 +2790,7 @@ rd_view_ui(Rng2F32 rect)
{
ev_key_set_expansion(eval_view, ev_key_root(), ev_key_make(ev_hash_from_key(ev_key_root()), 1), 1);
}
block_tree = ev_block_tree_from_expr(scratch.arena, eval_view, filter, eval.expr);
block_tree = ev_block_tree_from_eval(scratch.arena, eval_view, filter, eval);
block_ranges = ev_block_range_list_from_tree(scratch.arena, &block_tree);
if(implicit_root && block_ranges.first != 0)
{
@@ -6315,7 +6315,7 @@ rd_window_frame(void)
EV_BlockTree predicted_block_tree = {0};
RD_RegsScope(.view = view->id)
{
predicted_block_tree = ev_block_tree_from_expr(scratch.arena, rd_view_eval_view(), str8_zero(), hover_eval.expr);
predicted_block_tree = ev_block_tree_from_eval(scratch.arena, rd_view_eval_view(), str8_zero(), hover_eval);
}
F32 row_height_px = ui_top_px_height();
U64 max_row_count = (U64)floor_f32(ui_top_font_size()*10.f / row_height_px);
@@ -6461,7 +6461,7 @@ rd_window_frame(void)
F32 row_height_px = ui_top_px_height();
Vec2F32 content_rect_center = center_2f32(content_rect);
Vec2F32 content_rect_dim = dim_2f32(content_rect);
EV_BlockTree predicted_block_tree = ev_block_tree_from_expr(scratch.arena, rd_view_eval_view(), rd_view_query_input(), query_eval.expr);
EV_BlockTree predicted_block_tree = ev_block_tree_from_eval(scratch.arena, rd_view_eval_view(), rd_view_query_input(), query_eval);
F32 query_width_px = floor_f32(content_rect_dim.x * 0.35f);
F32 max_query_height_px = content_rect_dim.y*0.8f;
F32 query_height_px = max_query_height_px;