From 19dc549df020b594e64b8f7531834c3f9918d765 Mon Sep 17 00:00:00 2001 From: Matthew LeVan Date: Wed, 13 Sep 2023 15:20:14 -0400 Subject: [PATCH] wip: IT VERKS --- pkg/noun/manage.c | 14 +++++++------- pkg/noun/v1/jets.c | 19 ++++++++++++++++--- pkg/noun/v1/jets.h | 13 +++++++++++++ pkg/noun/v1/nock.c | 11 ++++++++--- pkg/noun/v2/manage.c | 2 +- 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/pkg/noun/manage.c b/pkg/noun/manage.c index 7dedc72b94..d835252238 100644 --- a/pkg/noun/manage.c +++ b/pkg/noun/manage.c @@ -745,13 +745,6 @@ u3m_dump(void) c3_i u3m_bail(u3_noun how) { - if ( &(u3H->rod_u) == u3R ) { - // XX set exit code - // - fprintf(stderr, "home: bailing out\r\n"); - abort(); - } - // printf some metadata // switch ( how ) { @@ -776,6 +769,13 @@ u3m_bail(u3_noun how) } } + if ( &(u3H->rod_u) == u3R ) { + // XX set exit code + // + fprintf(stderr, "home: bailing out\r\n"); + abort(); + } + // intercept fatal errors // switch ( how ) { diff --git a/pkg/noun/v1/jets.c b/pkg/noun/v1/jets.c index 51a248874a..400e7d278e 100644 --- a/pkg/noun/v1/jets.c +++ b/pkg/noun/v1/jets.c @@ -49,6 +49,18 @@ _cj_v1_fink_free(u3p(u3j_fink) fin_p) fprintf(stderr, "_cj_v1_fink_free 8\r\n"); } +/* u3j_v1_rite_lose(): lose references of u3j_rite (but do not free). + */ +void +u3j_v1_rite_lose(u3j_rite* rit_u) +{ + if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { + u3a_v1_lose(rit_u->clu); + _cj_v1_fink_free(rit_u->fin_p); + } +} + + /* u3j_site_lose(): lose references of u3j_site (but do not free). */ void @@ -89,7 +101,8 @@ static void _cj_v1_free_hank(u3_noun kev) { fprintf(stderr, "_cj_v1_free_hank 1\r\n"); - _cj_v1_hank* han_u = u3to(_cj_v1_hank, u3t(kev)); + u3a_cell* cel_u = u3a_v1_to_ptr(kev); + _cj_v1_hank* han_u = u3to(_cj_v1_hank, cel_u->tel); fprintf(stderr, "_cj_v1_free_hank 2\r\n"); if ( u3_none != han_u->hax ) { fprintf(stderr, "_cj_v1_free_hank 3\r\n"); @@ -97,7 +110,7 @@ _cj_v1_free_hank(u3_noun kev) fprintf(stderr, "_cj_v1_free_hank 4\r\n"); u3j_v1_site_lose(&(han_u->sit_u)); } - fprintf(stderr, "_cj_v1_free_hank 5 %x %x\r\n", u3h(kev), u3t(kev)); + // fprintf(stderr, "_cj_v1_free_hank 5 %x %x\r\n", u3h(kev), u3t(kev)); u3a_wfree(han_u); } @@ -116,7 +129,7 @@ u3j_v1_reclaim(void) // clear the jet hank cache // - fprintf(stderr, "u3j_v1_reclaim 1 \r\n"); + fprintf(stderr, "u3j_v1_reclaim 1 %x\r\n", u3R->jed.han_p); u3h_v1_walk(u3R->jed.han_p, _cj_v1_free_hank); fprintf(stderr, "u3j_v1_reclaim 2 \r\n"); u3h_v1_free(u3R->jed.han_p); diff --git a/pkg/noun/v1/jets.h b/pkg/noun/v1/jets.h index c9feba0e62..78c7fb7e00 100644 --- a/pkg/noun/v1/jets.h +++ b/pkg/noun/v1/jets.h @@ -3,6 +3,8 @@ #ifndef U3_JETS_V1_H #define U3_JETS_V1_H +#include "pkg/noun/jets.h" + /* u3j_v1_reclaim(): clear ad-hoc persistent caches to reclaim memory. */ void @@ -13,4 +15,15 @@ void u3j_v1_rewrite_compact(); + /* u3j_v1_rite_lose(): lose references of u3j_rite (but do not free). + */ + void + u3j_v1_rite_lose(u3j_rite* rit_u); + + /* u3j_v1_site_lose(): lose references of u3j_site (but do not free). + */ + void + u3j_v1_site_lose(u3j_site* sit_u); + + #endif /* ifndef U3_JETS_V1_H */ diff --git a/pkg/noun/v1/nock.c b/pkg/noun/v1/nock.c index 629d275a13..19e0a855ad 100644 --- a/pkg/noun/v1/nock.c +++ b/pkg/noun/v1/nock.c @@ -5,6 +5,8 @@ #include "pkg/noun/v1/allocate.h" #include "pkg/noun/v1/hashtable.h" +#include "pkg/noun/jets.h" +#include "pkg/noun/v1/jets.h" /* u3n_v1_reclaim(): clear ad-hoc persistent caches to reclaim memory. */ @@ -34,10 +36,10 @@ _cn_prog_free(u3n_prog* pog_u) u3a_v1_lose(pog_u->mem_u.sot_u[dex_w].key); } for (dex_w = 0; dex_w < pog_u->cal_u.len_w; ++dex_w) { - u3j_site_lose(&(pog_u->cal_u.sit_u[dex_w])); + u3j_v1_site_lose(&(pog_u->cal_u.sit_u[dex_w])); } for (dex_w = 0; dex_w < pog_u->reg_u.len_w; ++dex_w) { - u3j_rite_lose(&(pog_u->reg_u.rit_u[dex_w])); + u3j_v1_rite_lose(&(pog_u->reg_u.rit_u[dex_w])); } u3a_free(pog_u); } @@ -48,7 +50,8 @@ _cn_prog_free(u3n_prog* pog_u) static void _n_feb(u3_noun kev) { - _cn_prog_free(u3to(u3n_prog, u3t(kev))); + u3a_cell *cel_u = u3a_v1_to_ptr(kev); + _cn_prog_free(u3to(u3n_prog, cel_u->tel)); } /* u3n_v1_free(): free bytecode cache @@ -57,7 +60,9 @@ void u3n_v1_free() { u3p(u3h_root) har_p = u3R->byc.har_p; + fprintf(stderr, "u3n_v1_free walking\r\n"); u3h_v1_walk(har_p, _n_feb); + fprintf(stderr, "u3n_v1_free walked\r\n"); u3h_v1_free(har_p); } diff --git a/pkg/noun/v2/manage.c b/pkg/noun/v2/manage.c index 82e9b9a992..33f68af6ca 100644 --- a/pkg/noun/v2/manage.c +++ b/pkg/noun/v2/manage.c @@ -172,7 +172,7 @@ u3m_v2_migrate() /* packing first simplifies migration logic and minimizes required buffer space */ // XX determine if we need to version this for the v2 migration - u3m_v1_pack(); + // u3m_v1_pack(); fprintf(stderr, "v1 packed\r\n"); /* perform the migration in a pattern similar to |pack */