From 69f75b9d27fb1ed669a4d2928c5cc76885e0e9b5 Mon Sep 17 00:00:00 2001 From: Matthew LeVan Date: Thu, 14 Sep 2023 20:20:25 -0400 Subject: [PATCH] wip: remove unnecessary v2 code --- pkg/noun/allocate.h | 2 +- pkg/noun/jets.c | 42 +++++++-------- pkg/noun/v1/jets.h | 12 ----- pkg/noun/v1/nock.c | 1 - pkg/noun/v2/allocate.c | 6 --- pkg/noun/v2/hashtable.c | 112 +--------------------------------------- pkg/noun/v2/hashtable.h | 22 ++------ pkg/noun/v2/jets.c | 22 -------- pkg/noun/v2/manage.c | 3 -- pkg/noun/v2/manage.h | 5 -- pkg/noun/v2/nock.h | 5 -- 11 files changed, 26 insertions(+), 206 deletions(-) diff --git a/pkg/noun/allocate.h b/pkg/noun/allocate.h index 8127cd0c94..6546b261f3 100644 --- a/pkg/noun/allocate.h +++ b/pkg/noun/allocate.h @@ -384,7 +384,7 @@ **/ /* u3a_into(): convert loom offset [x] into generic pointer. */ -# define u3a_into(x) (u3_Loom + (x)) +# define u3a_into(x) ((void *)(u3_Loom + (x))) /* u3a_outa(): convert pointer [p] into word offset into loom. */ diff --git a/pkg/noun/jets.c b/pkg/noun/jets.c index dcabcdb559..56f30ce92f 100644 --- a/pkg/noun/jets.c +++ b/pkg/noun/jets.c @@ -26,7 +26,7 @@ typedef struct { u3_weak hax; // axis of hooked inner core u3j_site sit_u; // call-site data -} _cj_hank; +} _cj_v2_hank; /** Functions. **/ @@ -1069,7 +1069,7 @@ _cj_prog(u3_weak loc, u3_noun fol) /* cj_hank_find(): find cached hook information, keyed by arbitrary * prefix and term cords. RETAIN. */ -static _cj_hank* +static _cj_v2_hank* _cj_hank_find(u3_noun pre, u3_noun tam) { u3_noun key = u3nc(u3k(pre), u3k(tam)); @@ -1077,10 +1077,10 @@ _cj_hank_find(u3_noun pre, u3_noun tam) if ( u3_none != got ) { u3z(key); - return u3to(_cj_hank, got); + return u3to(_cj_v2_hank, got); } else { - _cj_hank* new_u = u3a_walloc(c3_wiseof(_cj_hank)); + _cj_v2_hank* new_u = u3a_walloc(c3_wiseof(_cj_v2_hank)); u3a_road* rod_u = u3R; while ( rod_u->par_p && u3_none == got ) { @@ -1092,7 +1092,7 @@ _cj_hank_find(u3_noun pre, u3_noun tam) new_u->hax = u3_none; } else { - _cj_hank* old_u = u3to(_cj_hank, got); + _cj_v2_hank* old_u = u3to(_cj_v2_hank, got); if ( u3_none != (new_u->hax = old_u->hax) ) { // it's unusual but safe to "take" here, because // u3a_take will no-op on senior nouns (just as u3k would) @@ -1101,7 +1101,7 @@ _cj_hank_find(u3_noun pre, u3_noun tam) } } - u3h_put(u3R->jed.han_p, key, u3of(_cj_hank, new_u)); + u3h_put(u3R->jed.han_p, key, u3of(_cj_v2_hank, new_u)); u3z(key); return new_u; } @@ -1112,7 +1112,7 @@ _cj_hank_find(u3_noun pre, u3_noun tam) * core on return if valid. RETAIN. */ static c3_o -_cj_hank_fine(_cj_hank* han_u, u3_noun cor, u3_noun *inn) +_cj_hank_fine(_cj_v2_hank* han_u, u3_noun cor, u3_noun *inn) { u3_noun hax = han_u->hax; if ( u3_none == hax ) { @@ -1134,7 +1134,7 @@ _cj_hank_fine(_cj_hank* han_u, u3_noun cor, u3_noun *inn) /* _cj_hank_lose(): release memory maintained in a hook cache. */ static void -_cj_hank_lose(_cj_hank* han_u) +_cj_hank_lose(_cj_v2_hank* han_u) { if ( u3_none != han_u->hax ) { u3z(han_u->hax); @@ -1145,7 +1145,7 @@ _cj_hank_lose(_cj_hank* han_u) /* _cj_hank_fill(): slow path, populate han_u. */ static u3_noun -_cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) +_cj_hank_fill(_cj_v2_hank* han_u, u3_noun tam, u3_noun cor) { u3_weak loc, col; u3_noun got, pat, nam, huc; @@ -1642,7 +1642,7 @@ u3j_cook(const c3_c* key_c, const c3_c* tam_c) { u3_noun pro, key, tam, inn; - _cj_hank* han_u; + _cj_v2_hank* han_u; u3t_on(glu_o); key = u3i_string(key_c); @@ -1995,8 +1995,8 @@ u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) static u3p(_cj_hank) _cj_take_hank_cb(u3p(_cj_hank) nah_p) { - _cj_hank* nah_u = u3to(_cj_hank, nah_p); - _cj_hank* han_u = u3a_walloc(c3_wiseof(_cj_hank)); + _cj_v2_hank* nah_u = u3to(_cj_v2_hank, nah_p); + _cj_v2_hank* han_u = u3a_walloc(c3_wiseof(_cj_v2_hank)); if ( u3_none == nah_u->hax ) { han_u->hax = u3_none; @@ -2007,7 +2007,7 @@ _cj_take_hank_cb(u3p(_cj_hank) nah_p) u3j_site_take(&(han_u->sit_u), &(nah_u->sit_u)); } - return u3of(_cj_hank, han_u); + return u3of(_cj_v2_hank, han_u); } /* u3j_take(): copy junior jet state. @@ -2029,25 +2029,25 @@ static void _cj_merge_hank_cb(u3_noun kev, void* wit) { u3p(u3h_root) han_p = *(u3p(u3h_root)*)wit; - _cj_hank* nah_u; + _cj_v2_hank* nah_u; u3_noun key; u3p(_cj_hank) nah_p; u3x_cell(kev, &key, &nah_p); - nah_u = u3to(_cj_hank, nah_p); + nah_u = u3to(_cj_v2_hank, nah_p); if ( u3_none == nah_u->hax ) { u3a_wfree(nah_u); } else { - _cj_hank* han_u; + _cj_v2_hank* han_u; u3_weak got = u3h_git(u3R->jed.han_p, key); if ( u3_none == got ) { han_u = nah_u; } else { - han_u = u3to(_cj_hank, got); + han_u = u3to(_cj_v2_hank, got); if ( u3_none != han_u->hax ) { u3z(han_u->hax); @@ -2058,7 +2058,7 @@ _cj_merge_hank_cb(u3_noun kev, void* wit) u3a_wfree(nah_u); } - u3h_put(han_p, key, u3of(_cj_hank, han_u)); + u3h_put(han_p, key, u3of(_cj_v2_hank, han_u)); } } @@ -2170,7 +2170,7 @@ _cj_warm_tap(u3_noun kev, void* wit) static void _cj_ream_hank(u3_noun kev) { - u3j_site_ream(&(u3to(_cj_hank, u3t(kev))->sit_u)); + u3j_site_ream(&(u3to(_cj_v2_hank, u3t(kev))->sit_u)); } /* u3j_ream(): rebuild warm state @@ -2304,7 +2304,7 @@ static void _cj_mark_hank(u3_noun kev, void* dat) { c3_w* tot_w = (c3_w*) dat; - _cj_hank* han_u = u3to(_cj_hank, u3t(kev)); + _cj_v2_hank* han_u = u3to(_cj_v2_hank, u3t(kev)); *tot_w += u3a_mark_ptr(han_u); if ( u3_none != han_u->hax ) { *tot_w += u3a_mark_noun(han_u->hax); @@ -2342,7 +2342,7 @@ u3j_mark(FILE* fil_u) static void _cj_free_hank(u3_noun kev) { - _cj_hank* han_u = u3to(_cj_hank, u3t(kev)); + _cj_v2_hank* han_u = u3to(_cj_v2_hank, u3t(kev)); if ( u3_none != han_u->hax ) { u3z(han_u->hax); u3j_site_lose(&(han_u->sit_u)); diff --git a/pkg/noun/v1/jets.h b/pkg/noun/v1/jets.h index ed429813ab..15e160655b 100644 --- a/pkg/noun/v1/jets.h +++ b/pkg/noun/v1/jets.h @@ -1,17 +1,5 @@ /// @file -// u3a_v1_cell -// u3a_v1_wfree -// u3h_v1_new -// u3j_fink -// u3j_fist -// u3j_ream -// u3j_rite -// u3j_site -// u3j_site_lose -// u3H -// u3R - #ifndef U3_JETS_V1_H #define U3_JETS_V1_H diff --git a/pkg/noun/v1/nock.c b/pkg/noun/v1/nock.c index dcab0e532e..41b76c8a27 100644 --- a/pkg/noun/v1/nock.c +++ b/pkg/noun/v1/nock.c @@ -44,7 +44,6 @@ _cn_prog_free(u3n_v1_prog* pog_u) u3a_v1_free(pog_u); } - /* _n_feb(): u3h_v1_walk helper for u3n_v1_free */ static void diff --git a/pkg/noun/v2/allocate.c b/pkg/noun/v2/allocate.c index 0ebc392569..74e54a975b 100644 --- a/pkg/noun/v2/allocate.c +++ b/pkg/noun/v2/allocate.c @@ -69,9 +69,3 @@ u3a_v2_rewrite_noun(u3_noun som) cel->hed = u3a_v2_rewritten_noun(cel->hed); cel->tel = u3a_v2_rewritten_noun(cel->tel); } - -// 4 categories of symbols: -// - v1 -// - v2 -// - current -// - migration (both) \ No newline at end of file diff --git a/pkg/noun/v2/hashtable.c b/pkg/noun/v2/hashtable.c index 6cab9bc24d..6963d07fde 100644 --- a/pkg/noun/v2/hashtable.c +++ b/pkg/noun/v2/hashtable.c @@ -61,116 +61,6 @@ _ch_v2_free_node(u3h_v2_node* han_u, c3_w lef_w) u3a_v2_wfree(han_u); } -/* u3h_v2_free(): free hashtable. -*/ -void -u3h_v2_free(u3p(u3h_v2_root) har_p) -{ - u3h_v2_root* har_u = u3to(u3h_v2_root, har_p); - c3_w i_w; - - for ( i_w = 0; i_w < 64; i_w++ ) { - c3_w sot_w = har_u->sot_w[i_w]; - - if ( _(u3h_v2_slot_is_noun(sot_w)) ) { - u3z(u3h_v2_slot_to_noun(sot_w)); - } - else if ( _(u3h_v2_slot_is_node(sot_w)) ) { - u3h_v2_node* han_u = u3h_v2_slot_to_node(sot_w); - - _ch_v2_free_node(han_u, 25); - } - } - u3a_v2_wfree(har_u); -} - -/* _ch_v2_walk_buck(): walk bucket for gc. -** NB: copy of _ch_v2_walk_buck in pkg/noun/hashtable.c -*/ -static void -_ch_v2_walk_buck(u3h_v2_buck* hab_u, void (*fun_f)(u3_noun, void*), void* wit) -{ - c3_w i_w; - - for ( i_w = 0; i_w < hab_u->len_w; i_w++ ) { - fun_f(u3h_v2_slot_to_noun(hab_u->sot_w[i_w]), wit); - } -} - -/* _ch_v2_walk_node(): walk node for gc. -*/ -static void -_ch_v2_walk_node(u3h_v2_node* han_u, c3_w lef_w, void (*fun_f)(u3_noun, void*), void* wit) -{ - c3_w len_w = _ch_v2_popcount(han_u->map_w); - c3_w i_w; - - lef_w -= 5; - - for ( i_w = 0; i_w < len_w; i_w++ ) { - c3_w sot_w = han_u->sot_w[i_w]; - - if ( _(u3h_v2_slot_is_noun(sot_w)) ) { - u3_noun kev = u3h_v2_slot_to_noun(sot_w); - - fun_f(kev, wit); - } - else { - void* hav_v = u3h_v2_slot_to_node(sot_w); - - if ( 0 == lef_w ) { - _ch_v2_walk_buck(hav_v, fun_f, wit); - } else { - _ch_v2_walk_node(hav_v, lef_w, fun_f, wit); - } - } - } -} - -/* u3h_v2_walk_with(): traverse hashtable with key, value fn and data - * argument; RETAINS. -*/ -void -u3h_v2_walk_with(u3p(u3h_v2_root) har_p, - void (*fun_f)(u3_noun, void*), - void* wit) -{ - u3h_v2_root* har_u = u3to(u3h_v2_root, har_p); - c3_w i_w; - - for ( i_w = 0; i_w < 64; i_w++ ) { - c3_w sot_w = har_u->sot_w[i_w]; - - if ( _(u3h_v2_slot_is_noun(sot_w)) ) { - u3_noun kev = u3h_v2_slot_to_noun(sot_w); - - fun_f(kev, wit); - } - else if ( _(u3h_v2_slot_is_node(sot_w)) ) { - u3h_v2_node* han_u = u3h_v2_slot_to_node(sot_w); - - _ch_v2_walk_node(han_u, 25, fun_f, wit); - } - } -} - -/* _ch_v2_walk_plain(): use plain u3_noun fun_f for each node - */ -static void -_ch_v2_walk_plain(u3_noun kev, void* wit) -{ - void (*fun_f)(u3_noun) = wit; - fun_f(kev); -} - -/* u3h_v2_walk(): u3h_v2_walk_with, but with no data argument -*/ -void -u3h_v2_walk(u3p(u3h_v2_root) har_p, void (*fun_f)(u3_noun)) -{ - u3h_v2_walk_with(har_p, _ch_v2_walk_plain, fun_f); -} - /* _ch_v2_rewrite_buck(): rewrite buck for compaction. */ void @@ -242,7 +132,7 @@ u3h_v2_rewrite(u3p(u3h_v2_root) har_p) u3a_v2_rewrite_noun(kev); } else if ( _(u3h_v2_slot_is_node(sot_w)) ) { - u3h_v2_node* han_u = u3h_v1_slot_to_node(sot_w); + u3h_v2_node* han_u = (u3h_v2_node*) u3h_v1_slot_to_node(sot_w); u3h_v2_node* nod_u = u3to(u3h_v2_node, u3a_v2_rewritten(u3of(u3h_v2_node,han_u))); har_u->sot_w[i_w] = u3h_v2_node_to_slot(nod_u); diff --git a/pkg/noun/v2/hashtable.h b/pkg/noun/v2/hashtable.h index d6da41cf16..237bdac2af 100644 --- a/pkg/noun/v2/hashtable.h +++ b/pkg/noun/v2/hashtable.h @@ -2,12 +2,15 @@ #define U3_HASHTABLE_V2_H #define u3h_v2_buck u3h_buck +#define u3h_v2_free u3h_free #define u3h_v2_node u3h_node #define u3h_v2_noun_to_slot u3h_noun_to_slot #define u3h_v2_root u3h_root #define u3h_v2_slot_is_node u3h_slot_is_node #define u3h_v2_slot_is_noun u3h_slot_is_noun #define u3h_v2_slot_to_noun u3h_slot_to_noun +#define u3h_v2_walk u3h_walk +#define u3h_v2_walk_with u3h_walk_with #include "pkg/noun/hashtable.h" @@ -29,29 +32,10 @@ /** Functions. *** - *** Needs: delete and merge functions; clock reclamation function. **/ - /* u3h_v2_free(): free hashtable. - */ - void - u3h_v2_free(u3p(u3h_root) har_p); - /* u3h_v2_rewrite(): rewrite hashtable for compaction. */ void u3h_v2_rewrite(u3p(u3h_root) har_p); - /* u3h_v2_walk_with(): traverse hashtable with key, value fn and data - * argument; RETAINS. - */ - void - u3h_v2_walk_with(u3p(u3h_root) har_p, - void (*fun_f)(u3_noun, void*), - void* wit); - - /* u3h_v2_walk(): u3h_v2_walk_with, but with no data argument - */ - void - u3h_v2_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun)); - #endif /* U3_HASHTABLE_V2_H */ \ No newline at end of file diff --git a/pkg/noun/v2/jets.c b/pkg/noun/v2/jets.c index 237c22d03e..91b23e5955 100644 --- a/pkg/noun/v2/jets.c +++ b/pkg/noun/v2/jets.c @@ -12,31 +12,9 @@ /** Data structures. **/ -/* _cj_hank: cached hook information. -** NB: copy of _cj_hank from pkg/noun/jets.c - */ -typedef struct { - u3_weak hax; // axis of hooked inner core - u3j_v2_site sit_u; // call-site data -} _cj_hank; - /** Functions. **/ -/* _cj_v2_free_hank(): free an entry from the hank cache. -** NB: copy of _cj_v2_free_hank() from pkg/noun/jets.c -*/ -static void -_cj_v2_free_hank(u3_noun kev) -{ - _cj_hank* han_u = u3to(_cj_hank, u3t(kev)); - if ( u3_none != han_u->hax ) { - u3z(han_u->hax); - u3j_v2_site_lose(&(han_u->sit_u)); - } - u3a_v2_wfree(han_u); -} - /* u3j_v2_rewrite_compact(): rewrite jet state for compaction. * * NB: u3R_v2->jed.han_p *must* be cleared (currently via u3j_v2_reclaim above) diff --git a/pkg/noun/v2/manage.c b/pkg/noun/v2/manage.c index 2790048b2b..525f356944 100644 --- a/pkg/noun/v2/manage.c +++ b/pkg/noun/v2/manage.c @@ -20,9 +20,6 @@ _cm_pack_rewrite(void) // u3_assert( &(u3H_v2->rod_u) == u3R_v2 ); - // NB: these implementations must be kept in sync with u3m_v2_reclaim(); - // anything not reclaimed must be rewritable - // u3v_v2_rewrite_compact(); u3j_v2_rewrite_compact(); u3n_v2_rewrite_compact(); diff --git a/pkg/noun/v2/manage.h b/pkg/noun/v2/manage.h index 47f2fe2554..ec6ef581a2 100644 --- a/pkg/noun/v2/manage.h +++ b/pkg/noun/v2/manage.h @@ -5,11 +5,6 @@ /** System management. **/ - /* u3m_v2_reclaim: clear persistent caches to reclaim memory - */ - void - u3m_v2_reclaim(void); - /* u3m_v2_migrate: perform pointer compression loom migration if necessary. ver_w - target version */ diff --git a/pkg/noun/v2/nock.h b/pkg/noun/v2/nock.h index 57f358eeca..320e9a5f62 100644 --- a/pkg/noun/v2/nock.h +++ b/pkg/noun/v2/nock.h @@ -10,11 +10,6 @@ /** Functions. **/ - /* u3n_v2_free(): free bytecode cache. - */ - void - u3n_v2_free(void); - /* u3n_v2_rewrite_compact(): rewrite bytecode cache for compaction. */ void