diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-02-06 00:12:48 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-02-07 00:04:35 +0100 |
commit | 3a49192f3a1e8a5d348cdbfccd0a16d74ba61e3d (patch) | |
tree | 6d8a4b620b362ab4f707678a5b626a85e1531c0b /vallist.c | |
parent | 5bd764a35aeaf50b54957bfa94ba94198514baf0 (diff) |
treewide: rework function memory model
- Instead of treating individual program functions as managed ucode types,
demote uc_function_t values to pointers into a uc_program_t entity
- Promote uc_program_t to a managed type
- Let uc_closure_t claim references to the owning program of the enclosed
uc_function_t
- Redefine public APIs uc_compile() and uc_vm_execute() APIs to return and
expect an uc_program_t object respectively
- Remove vallist indirection for function loading and let the compiler
emit the function id directly when producing function construction code
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'vallist.c')
-rw-r--r-- | vallist.c | 24 |
1 files changed, 0 insertions, 24 deletions
@@ -465,16 +465,6 @@ find_str(uc_value_list_t *list, const char *s, size_t slen) return -1; } -static void -add_func(uc_value_list_t *list, uc_function_t *func) -{ - size_t id = uc_program_function_id(func->program, &func->header); - - assert(id != 0 && TAG_FIT_NV(id)); - - list->index[list->isize++] = (TAG_TYPE)(TAG_FUNC | TAG_SET_NV(id)); -} - ssize_t uc_vallist_add(uc_value_list_t *list, uc_value_t *value) { @@ -525,10 +515,6 @@ uc_vallist_add(uc_value_list_t *list, uc_value_t *value) break; - case UC_FUNCTION: - add_func(list, (uc_function_t *)value); - break; - default: return -1; } @@ -545,15 +531,10 @@ uc_vallist_type(uc_value_list_t *list, size_t idx) return TAG_GET_TYPE(list->index[idx]); } -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - uc_value_t * uc_vallist_get(uc_value_list_t *list, size_t idx) { char str[sizeof(TAG_TYPE)]; - uc_program_t *program; size_t n, len; switch (uc_vallist_type(list, idx)) { @@ -591,11 +572,6 @@ uc_vallist_get(uc_value_list_t *list, size_t idx) return ucv_string_new_length(list->data + TAG_GET_OFFSET(list->index[idx]) + sizeof(uint32_t), len); - case TAG_FUNC: - program = container_of(list, uc_program_t, constants); - - return uc_program_function_load(program, TAG_GET_NV(list->index[idx])); - default: return NULL; } |