Skip to content

Commit

Permalink
wip: remove unnecessary v2 code
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Sep 15, 2023
1 parent 94e7801 commit 69f75b9
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 206 deletions.
2 changes: 1 addition & 1 deletion pkg/noun/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
42 changes: 21 additions & 21 deletions pkg/noun/jets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
**/
Expand Down Expand Up @@ -1069,18 +1069,18 @@ _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));
u3_noun got = u3h_git(u3R->jed.han_p, key);

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 ) {
Expand All @@ -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)
Expand All @@ -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;
}
Expand All @@ -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 ) {
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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);
Expand All @@ -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));
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
12 changes: 0 additions & 12 deletions pkg/noun/v1/jets.h
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion pkg/noun/v1/nock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions pkg/noun/v2/allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
112 changes: 1 addition & 111 deletions pkg/noun/v2/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 3 additions & 19 deletions pkg/noun/v2/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 */
Loading

0 comments on commit 69f75b9

Please sign in to comment.