mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-22 11:44:59 -07:00
eliminate old slow identifier resolution path
This commit is contained in:
+1
-209
@@ -1809,7 +1809,7 @@ BasicCase("float32", F32)\
|
||||
BasicCase("double", F64)\
|
||||
BasicCase("float64", F64)\
|
||||
|
||||
#define BasicCase(str, kind) else if(str8_match(string, str8_lit(str), 0)) {mapped_type_key = e_type_key_basic(E_TypeKind_##kind);}
|
||||
#define BasicCase(str, kind) else if(str8_match(string, str8_lit(str), 0)) {string_mapped = 1; mapped_type_key = e_type_key_basic(E_TypeKind_##kind);}
|
||||
BuiltInType_XList
|
||||
#undef BasicCase
|
||||
}break;
|
||||
@@ -1939,216 +1939,8 @@ BasicCase("float64", F64)\
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: try globals
|
||||
#if 0
|
||||
if(path == E_IdentifierResolutionPath_Globals && !string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("global"), 0)))
|
||||
{
|
||||
for(U64 module_idx = 0; module_idx < e_base_ctx->modules_count; module_idx += 1)
|
||||
{
|
||||
E_Module *module = &e_base_ctx->modules[module_idx];
|
||||
RDI_Parsed *rdi = module->rdi;
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_GlobalVariables);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, string.str, string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, match_idx);
|
||||
U32 type_idx = global_var->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU64, e_value_u64(module->vaddr_range.min + global_var->voff));
|
||||
string_mapped = 1;
|
||||
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)module_idx);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Offset;
|
||||
mapped_bytecode_space = module->space;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//- rjf: try thread-locals
|
||||
#if 0
|
||||
if(path == E_IdentifierResolutionPath_ThreadLocals && !string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("thread_local"), 0)))
|
||||
{
|
||||
for(U64 module_idx = 0; module_idx < e_base_ctx->modules_count; module_idx += 1)
|
||||
{
|
||||
E_Module *module = &e_base_ctx->modules[module_idx];
|
||||
RDI_Parsed *rdi = module->rdi;
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_ThreadVariables);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, string.str, string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_ThreadVariable *thread_var = rdi_element_from_name_idx(rdi, ThreadVariables, match_idx);
|
||||
U32 type_idx = thread_var->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, e_value_u64(thread_var->tls_off));
|
||||
string_mapped = 1;
|
||||
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)module_idx);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Offset;
|
||||
mapped_bytecode_space = module->space;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//- rjf: try constants
|
||||
#if 0
|
||||
if(path == E_IdentifierResolutionPath_Constants && !string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("constant"), 0)))
|
||||
{
|
||||
if(str8_match(string, str8_lit("true"), 0))
|
||||
{
|
||||
string_mapped = 1;
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_uconst(arena, &oplist, 1);
|
||||
mapped_type_key = e_type_key_basic(E_TypeKind_Bool);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Value;
|
||||
}
|
||||
else if(str8_match(string, str8_lit("false"), 0))
|
||||
{
|
||||
string_mapped = 1;
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_uconst(arena, &oplist, 0);
|
||||
mapped_type_key = e_type_key_basic(E_TypeKind_Bool);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Value;
|
||||
}
|
||||
else for(U64 module_idx = 0; module_idx < e_base_ctx->modules_count; module_idx += 1)
|
||||
{
|
||||
E_Module *module = &e_base_ctx->modules[module_idx];
|
||||
RDI_Parsed *rdi = module->rdi;
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Constants);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, string.str, string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_Constant *constant = rdi_element_from_name_idx(rdi, Constants, match_idx);
|
||||
U32 type_idx = constant->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
||||
RDI_U32 constant_value_off = *rdi_element_from_name_idx(rdi, ConstantValueTable, constant->constant_value_idx);
|
||||
RDI_U32 constant_value_size = *rdi_element_from_name_idx(rdi, ConstantValueTable, constant->constant_value_idx+1) - constant_value_off;
|
||||
if(constant_value_size <= 8)
|
||||
{
|
||||
RDI_U64 constant_value_data_size = 0;
|
||||
RDI_U8 *constant_value_data = rdi_table_from_name(rdi, ConstantValueData, &constant_value_data_size);
|
||||
if(0 <= constant_value_off && constant_value_off + constant_value_size <= constant_value_data_size)
|
||||
{
|
||||
RDI_U64 value = 0;
|
||||
MemoryCopy(&value, constant_value_data+constant_value_off, constant_value_size);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU64, e_value_u64(value));
|
||||
string_mapped = 1;
|
||||
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)module_idx);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Value;
|
||||
mapped_bytecode_space = module->space;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//- rjf: try procedures
|
||||
#if 0
|
||||
if(path == E_IdentifierResolutionPath_Procedures && !string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("procedure"), 0)))
|
||||
{
|
||||
for(U64 module_idx = 0; module_idx < e_base_ctx->modules_count; module_idx += 1)
|
||||
{
|
||||
E_Module *module = &e_base_ctx->modules[module_idx];
|
||||
RDI_Parsed *rdi = module->rdi;
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Procedures);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, string.str, string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, match_idx);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
|
||||
U64 voff = *rdi_element_from_name_idx(rdi, ScopeVOffData, scope->voff_range_first);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU64, e_value_u64(module->vaddr_range.min + voff));
|
||||
string_mapped = 1;
|
||||
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)module_idx);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Value;
|
||||
mapped_bytecode_space = module->space;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}break;
|
||||
|
||||
//- rjf: try types
|
||||
#if 0
|
||||
case E_IdentifierResolutionPath_Types:
|
||||
if(!string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("type"), 0)))
|
||||
{
|
||||
mapped_type_key = e_leaf_type_from_name(string);
|
||||
if(!e_type_key_match(e_type_key_zero(), mapped_type_key))
|
||||
{
|
||||
string_mapped = 1;
|
||||
}
|
||||
}break;
|
||||
#endif
|
||||
|
||||
//- rjf: try registers
|
||||
case E_IdentifierResolutionPath_Registers:
|
||||
if(!string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("reg"), 0)))
|
||||
|
||||
Reference in New Issue
Block a user