extend eval space size to allow u128 key for hash store & related cache keys, + some extra metadata determined by user (user-defined kind & extra u64)

This commit is contained in:
Ryan Fleury
2024-09-11 17:11:33 -07:00
parent 26fb91d539
commit deef05d0d2
10 changed files with 131 additions and 64 deletions
+11
View File
@@ -155,3 +155,14 @@ e_msg_list_concat_in_place(E_MsgList *dst, E_MsgList *to_push)
}
MemoryZeroStruct(to_push);
}
////////////////////////////////
//~ rjf: Space Functions
internal E_Space
e_space_make(E_SpaceKind kind)
{
E_Space space = {0};
space.kind = kind;
return space;
}
+28 -2
View File
@@ -78,8 +78,6 @@ struct E_OpInfo
////////////////////////////////
//~ rjf: Evaluation Spaces
typedef U128 E_Space;
//
// NOTE(rjf): Evaluations occur within the context of a "space". Each "space"
// refers to a different offset/address-space, but it's a bit looser of a
@@ -91,6 +89,29 @@ typedef U128 E_Space;
// value for understanding a key *into* a space, e.g. 1+2 -> 3, in a null
// space, or &foo, in the space of PID: 1234.
typedef U64 E_SpaceKind;
enum
{
E_SpaceKind_Null,
E_SpaceKind_FileSystem,
E_SpaceKind_FirstUserDefined,
};
typedef struct E_Space E_Space;
struct E_Space
{
E_SpaceKind kind;
union
{
U64 u64s[3];
struct
{
U64 u64_0;
U128 u128;
};
};
};
////////////////////////////////
//~ rjf: Evaluation Modes
@@ -134,4 +155,9 @@ internal void e_msg(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *locatio
internal void e_msgf(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, char *fmt, ...);
internal void e_msg_list_concat_in_place(E_MsgList *dst, E_MsgList *to_push);
////////////////////////////////
//~ rjf: Space Functions
internal E_Space e_space_make(E_SpaceKind kind);
#endif // EVAL_CORE_H
+1 -1
View File
@@ -121,7 +121,7 @@ e_interpret(String8 bytecode)
{
case E_IRExtKind_SetSpace:
{
selected_space = imm.u128;
MemoryCopy(&selected_space, &imm, sizeof(selected_space));
}break;
case RDI_EvalOp_Stop:
+10 -5
View File
@@ -138,7 +138,8 @@ e_oplist_push_set_space(Arena *arena, E_OpList *list, E_Space space)
{
E_Op *node = push_array_no_zero(arena, E_Op, 1);
node->opcode = E_IRExtKind_SetSpace;
node->value.u128 = space;
StaticAssert(sizeof(E_Space) <= sizeof(E_Value), space_size_check);
MemoryCopy(&node->value, &space, sizeof(space));
SLLQueuePush(list->first, list->last, node);
list->op_count += 1;
list->encoded_size += 1 + sizeof(space);
@@ -266,7 +267,8 @@ internal E_IRNode *
e_irtree_set_space(Arena *arena, E_Space space, E_IRNode *c)
{
E_IRNode *root = e_push_irnode(arena, E_IRExtKind_SetSpace);
root->value.u128 = space;
StaticAssert(sizeof(E_Space) <= sizeof(E_Value), space_size_check);
MemoryCopy(&root->value, &space, sizeof(space));
e_irnode_push_child(root, c);
return root;
}
@@ -1264,13 +1266,14 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
case E_ExprKind_LeafFilePath:
{
U128 key = fs_key_from_path_range(expr->string, r1u64(0, max_U64));
E_Space space = {E_SpaceKind_FileSystem, .u128 = key};
U64 size = fs_size_from_path(expr->string);
E_IRNode *base_offset = e_irtree_const_u(arena, 0);
E_IRNode *set_space = e_irtree_set_space(arena, key, base_offset);
E_IRNode *set_space = e_irtree_set_space(arena, space, base_offset);
result.root = set_space;
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), size);
result.mode = E_Mode_Offset;
result.space = key;
result.space = space;
}break;
//- rjf: types
@@ -1328,7 +1331,9 @@ e_append_oplist_from_irtree(Arena *arena, E_IRNode *root, E_OpList *out)
case E_IRExtKind_SetSpace:
{
e_oplist_push_set_space(arena, out, root->value.u128);
E_Space space = {0};
MemoryCopy(&space, &root->value, sizeof(space));
e_oplist_push_set_space(arena, out, space);
for(E_IRNode *child = root->first;
child != &e_irnode_nil;
child = child->next)