Skip to content

Commit

Permalink
wip: migration works, leak lies elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Sep 18, 2023
1 parent 232bf5b commit 5fe3e01
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions pkg/noun/allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2270,9 +2270,9 @@ _ca_print_leak(c3_c* cap_c, u3a_box* box_u, c3_ws use_ws)
u3a_print_memory(stderr, " size", box_u->siz_w);

{
c3_c* dat_c = _ca_print_box(box_u);
fprintf(stderr, " data: %s\r\n", dat_c);
c3_free(dat_c);
// c3_c* dat_c = _ca_print_box(box_u);
// fprintf(stderr, " data: %s\r\n", dat_c);
// c3_free(dat_c);
}
}

Expand Down
24 changes: 12 additions & 12 deletions pkg/noun/jets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,12 +1100,12 @@ u3j_hank_find(u3_noun pre, u3_noun tam)
}
}

/* u3j_hank_fine(): check that cached hook information is valid
/* _cj_hank_fine(): check that cached hook information is valid
* for given core. *inn will point to the hooked
* core on return if valid. RETAIN.
*/
static c3_o
u3j_hank_fine(u3j_hank* han_u, u3_noun cor, u3_noun *inn)
_cj_hank_fine(u3j_hank* han_u, u3_noun cor, u3_noun *inn)
{
u3_noun hax = han_u->hax;
if ( u3_none == hax ) {
Expand All @@ -1124,35 +1124,35 @@ u3j_hank_fine(u3j_hank* han_u, u3_noun cor, u3_noun *inn)
}
}

/* u3j_hank_lose(): release memory maintained in a hook cache.
/* _cj_hank_lose(): release memory maintained in a hook cache.
*/
static void
u3j_hank_lose(u3j_hank* han_u)
_cj_hank_lose(u3j_hank* han_u)
{
if ( u3_none != han_u->hax ) {
u3z(han_u->hax);
u3j_site_lose(&(han_u->sit_u));
}
}

/* u3j_hank_fill(): slow path, populate han_u.
/* _cj_hank_fill(): slow path, populate han_u.
*/
static u3_noun
u3j_hank_fill(u3j_hank* han_u, u3_noun tam, u3_noun cor)
_cj_hank_fill(u3j_hank* han_u, u3_noun tam, u3_noun cor)
{
u3_weak loc, col;
u3_noun got, pat, nam, huc;
u3_noun hax = 1;
u3j_site* sit_u = &(han_u->sit_u);

if ( c3n == u3du(cor) ) {
u3l_log("fail in u3j_hank_fill (c3n == u3du(cor))");
u3l_log("fail in _cj_hank_fill (c3n == u3du(cor))");
return u3m_bail(c3__fail);
}

sit_u->bas = u3_none;
if ( u3_none == (col = loc = _cj_spot(cor, NULL)) ) {
u3l_log("fail in u3j_hank_fill (_cj_spot(cor, NULL))");
u3l_log("fail in _cj_hank_fill (_cj_spot(cor, NULL))");
return u3m_bail(c3__fail);
}

Expand Down Expand Up @@ -1195,7 +1195,7 @@ u3j_hank_fill(u3j_hank* han_u, u3_noun tam, u3_noun cor)
else {
u3_noun sat = u3t(pat);
if ( c3y == u3h(sat) ) {
u3l_log("fail in u3j_hank_fill (c3y == u3h(sat))");
u3l_log("fail in _cj_hank_fill (c3y == u3h(sat))");
return u3m_bail(c3__fail);
}
else {
Expand Down Expand Up @@ -1642,9 +1642,9 @@ u3j_cook(const c3_c* key_c,
key = u3i_string(key_c);
tam = u3i_string(tam_c);
han_u = u3j_hank_find(key, tam);
if ( c3n == u3j_hank_fine(han_u, cor, &inn) ) {
u3j_hank_lose(han_u);
inn = u3j_hank_fill(han_u, tam, cor);
if ( c3n == _cj_hank_fine(han_u, cor, &inn) ) {
_cj_hank_lose(han_u);
inn = _cj_hank_fill(han_u, tam, cor);
}
pro = _cj_site_kick(u3k(inn), &(han_u->sit_u));
if ( u3_none == pro ) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/noun/v2/nock.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ _cn_v2_prog_free(u3n_v2_prog* pog_u)
u3a_v2_free(pog_u);
}


/* _n_v2_feb(): u3h_v2_walk helper for u3n_v2_free
*/
static void
Expand All @@ -39,7 +38,6 @@ _n_v2_feb(u3_noun kev)
_cn_v2_prog_free(u3to(u3n_v2_prog, cel_u->tel));
}


/* u3n_v2_free(): free bytecode cache
*/
void
Expand Down
7 changes: 7 additions & 0 deletions pkg/noun/v3/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ u3m_v3_migrate()
u3H_v2 = (void *)mut_w;
u3R_v2 = &u3H_v2->rod_u;
u3R_v2->cap_p = u3R_v2->mat_p = u3a_v2_outa(u3H_v2);
u3H = (u3v_home*)u3H_v2;
u3R = (u3a_road*)u3R_v2;

// free bytecode caches in old road
u3j_v2_reclaim();
Expand Down Expand Up @@ -101,12 +103,17 @@ u3m_v3_migrate()
// set globals
u3H_v3 = (void*)mat_w;
u3R_v3 = &u3H_v3->rod_u;
u3H = (u3v_home*)u3H_v3;
u3R = (u3a_road*)u3R_v3;

// initialize persistent cache
u3R_v3->cax.per_p = u3h_v3_new_cache(u3C.per_w);

// update the loom version
u3H_v3->ver_w = U3V_VER3;

u3m_mark(stderr);
u3a_sweep();

fprintf(stderr, "loom: memoization migration done\r\n");
}

0 comments on commit 5fe3e01

Please sign in to comment.