Skip to content

Commit

Permalink
wip: IT VERKS
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Sep 13, 2023
1 parent a516ad7 commit 19dc549
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
14 changes: 7 additions & 7 deletions pkg/noun/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) {
Expand Down
19 changes: 16 additions & 3 deletions pkg/noun/v1/jets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,15 +101,16 @@ 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");
u3a_v1_lose(han_u->hax);
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);
}

Expand All @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions pkg/noun/v1/jets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
11 changes: 8 additions & 3 deletions pkg/noun/v1/nock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
}
Expand All @@ -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
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/v2/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 19dc549

Please sign in to comment.