pass over the make RDI library

- Handle type layout in the library so converts simply
  define type graph and let the library handle DAG layout.
- Changed location baking. For now the library waits for scope, procs,
  global vars, and thread vars steps to serially finish because
  of common dependency on location sections, we need to parallel for each step.
- Changed encoded offset size for RDI_EvalOp_FrameOff to 8 bytes
  (1 byte is not enough to cover all cases)
- Added frame base location to RDI_Procedure (WASM encodes frame base
  as an index into a global array and so we have to resolve the base
  at runtime).
This commit is contained in:
Nikita Smith
2025-03-10 16:49:54 -07:00
parent 5717d6c54c
commit 44249f35fc
10 changed files with 457 additions and 264 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ RDI_EVAL_CTRLBITS(2, 0, 0),
RDI_EVAL_CTRLBITS(1, 1, 1),
RDI_EVAL_CTRLBITS(4, 0, 1),
RDI_EVAL_CTRLBITS(0, 1, 1),
RDI_EVAL_CTRLBITS(1, 0, 1),
RDI_EVAL_CTRLBITS(8, 0, 1),
RDI_EVAL_CTRLBITS(4, 0, 1),
RDI_EVAL_CTRLBITS(4, 0, 1),
RDI_EVAL_CTRLBITS(0, 0, 0),
+4
View File
@@ -970,6 +970,8 @@ X(RDI_LinkFlags, link_flags)\
X(RDI_U32, type_idx)\
X(RDI_U32, root_scope_idx)\
X(RDI_U32, container_idx)\
X(RDI_U32, frame_base_location_first)\
X(RDI_U32, frame_base_location_opl)\
#define RDI_Scope_XList \
X(RDI_U32, proc_idx)\
@@ -1397,6 +1399,8 @@ RDI_LinkFlags link_flags;
RDI_U32 type_idx;
RDI_U32 root_scope_idx;
RDI_U32 container_idx;
RDI_U32 frame_base_location_first;
RDI_U32 frame_base_location_opl;
};
typedef struct RDI_Scope RDI_Scope;
+22
View File
@@ -813,3 +813,25 @@ rdi_cstring_length(char *cstr)
for(;cstr[result] != 0; result += 1){}
return result;
}
RDI_PROC RDI_U64
rdi_size_from_bytecode_stream(U8 *ptr, U8 *opl)
{
RDI_U64 bytecode_size = 0;
RDI_U8 *off_first = ptr + sizeof(RDI_LocationKind);
for(RDI_U8 *off = off_first, *next_off = opl; off < opl; off = next_off)
{
RDI_U8 op = *off;
if(op == 0)
{
break;
}
RDI_U16 ctrlbits = rdi_eval_op_ctrlbits_table[op];
RDI_U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
bytecode_size += (1 + p_size);
next_off = (off + 1 + p_size);
}
return bytecode_size;
}
+1
View File
@@ -225,5 +225,6 @@ RDI_PROC RDI_U8 *rdi_name_from_file_path_node(RDI_Parsed *rdi, RDI_FilePathNode
#define rdi_parse__min(a,b) (((a)<(b))?(a):(b))
RDI_PROC RDI_U64 rdi_cstring_length(char *cstr);
RDI_PROC RDI_U64 rdi_size_from_bytecode_stream(U8 *ptr, U8 *opl);
#endif // RDI_FORMAT_PARSE_H