Skip to content

Commit

Permalink
Revert "wip: restored u3m_v1_pack()"
Browse files Browse the repository at this point in the history
This reverts commit a516ad7.
  • Loading branch information
matthew-levan committed Sep 13, 2023
1 parent 19dc549 commit 591ea02
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 299 deletions.
59 changes: 0 additions & 59 deletions pkg/noun/v1/allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,62 +65,3 @@ u3a_v1_lose(u3_noun som)
_me_lose_north(som);
}
}

u3_noun
u3a_v1_rewritten_noun(u3_noun som)
{
if ( c3y == u3a_is_cat(som) ) {
return som;
}
u3_post som_p = u3a_rewritten(u3a_v1_to_off(som));

if ( c3y == u3a_is_pug(som) ) {
som_p = u3a_v1_to_pug(som_p); // XX alias?
}
else {
som_p = u3a_v1_to_pom(som_p);
}

return som_p;
}

/* u3a_v1_rewrite_compact(): rewrite pointers in ad-hoc persistent road structures.
* XX need to version
*/
void
// u3a_v1_rewrite_compact(u3a_v1_road *rod_u)
u3a_v1_rewrite_compact(void)
{
u3a_v1_rewrite_noun(u3R->ski.gul);
u3a_v1_rewrite_noun(u3R->bug.tax);
u3a_v1_rewrite_noun(u3R->bug.mer);
u3a_v1_rewrite_noun(u3R->pro.don);
u3a_v1_rewrite_noun(u3R->pro.day);
u3a_v1_rewrite_noun(u3R->pro.trace);
u3h_v1_rewrite(u3R->cax.har_p);

u3R->ski.gul = u3a_v1_rewritten_noun(u3R->ski.gul);
u3R->bug.tax = u3a_v1_rewritten_noun(u3R->bug.tax);
u3R->bug.mer = u3a_v1_rewritten_noun(u3R->bug.mer);
u3R->pro.don = u3a_v1_rewritten_noun(u3R->pro.don);
u3R->pro.day = u3a_v1_rewritten_noun(u3R->pro.day);
u3R->pro.trace = u3a_v1_rewritten_noun(u3R->pro.trace);
u3R->cax.har_p = u3a_rewritten(u3R->cax.har_p);
}
void
u3a_v1_rewrite_noun(u3_noun som)
{
if ( c3n == u3a_is_cell(som) ) {
return;
}

if ( c3n == u3a_rewrite_ptr(u3a_v1_to_ptr((som))) ) return;

u3a_cell* cel = u3a_v1_to_ptr(som);

u3a_v1_rewrite_noun(cel->hed);
u3a_v1_rewrite_noun(cel->tel);

cel->hed = u3a_v1_rewritten_noun(cel->hed);
cel->tel = u3a_v1_rewritten_noun(cel->tel);
}
15 changes: 0 additions & 15 deletions pkg/noun/v1/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@
void
u3a_v1_reclaim(void);

/* u3a_v1_rewrite_compact(): rewrite pointers in ad-hoc persistent road structures.
*/
void
u3a_v1_rewrite_compact(void);

/* u3a_v1_rewrite_noun(): rewrite a noun for compaction.
*/
void
u3a_v1_rewrite_noun(u3_noun som);

/* u3a_v1_rewritten(): rewritten noun pointer for compaction.
*/
u3_noun
u3a_v1_rewritten_noun(u3_noun som);

/* u3a_v1_lose(): lose a reference count.
*/
void
Expand Down
82 changes: 0 additions & 82 deletions pkg/noun/v1/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "pkg/noun/hashtable.h"
#include "pkg/noun/v1/hashtable.h"
#include "pkg/noun/v2/hashtable.h"

#include "pkg/noun/allocate.h"
#include "pkg/noun/v1/allocate.h"
Expand Down Expand Up @@ -169,84 +168,3 @@ u3h_v1_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun))
{
u3h_v1_walk_with(har_p, _ch_v1_walk_plain, fun_f);
}

/* _ch_v1_rewrite_buck(): rewrite buck for compaction.
*/
void
_ch_v1_rewrite_buck(u3h_buck* hab_u)
{
if ( c3n == u3a_rewrite_ptr(hab_u) ) return;
c3_w i_w;

for ( i_w = 0; i_w < hab_u->len_w; i_w++ ) {
u3_noun som = u3h_slot_to_noun(hab_u->sot_w[i_w]);
hab_u->sot_w[i_w] = u3h_noun_to_slot(u3a_v1_rewritten_noun(som));
u3a_v1_rewrite_noun(som);
}
}

/* _ch_v1_rewrite_node(): rewrite node for compaction.
*/
void
_ch_v1_rewrite_node(u3h_node* han_u, c3_w lef_w)
{
if ( c3n == u3a_rewrite_ptr(han_u) ) return;

c3_w len_w = _ch_v1_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_slot_is_noun(sot_w)) ) {
u3_noun kev = u3h_slot_to_noun(sot_w);
han_u->sot_w[i_w] = u3h_noun_to_slot(u3a_v1_rewritten_noun(kev));

u3a_v1_rewrite_noun(kev);
}
else {
void* hav_v = u3h_v1_slot_to_node(sot_w);
u3h_node* nod_u = u3to(u3h_node, u3a_rewritten(u3of(u3h_node,hav_v)));

han_u->sot_w[i_w] = u3h_v1_node_to_slot(nod_u);

if ( 0 == lef_w ) {
_ch_v1_rewrite_buck(hav_v);
} else {
_ch_v1_rewrite_node(hav_v, lef_w);
}
}
}
}

/* u3h_v1_rewrite(): rewrite pointers during compaction.
*/
void
u3h_v1_rewrite(u3p(u3h_root) har_p)
{
u3h_root* har_u = u3to(u3h_root, har_p);
c3_w i_w;

if ( c3n == u3a_rewrite_ptr(har_u) ) return;

for ( i_w = 0; i_w < 64; i_w++ ) {
c3_w sot_w = har_u->sot_w[i_w];

if ( _(u3h_slot_is_noun(sot_w)) ) {
u3_noun kev = u3h_slot_to_noun(sot_w);
har_u->sot_w[i_w] = u3h_noun_to_slot(u3a_v1_rewritten_noun(kev));

u3a_v1_rewrite_noun(kev);
}
else if ( _(u3h_slot_is_node(sot_w)) ) {
u3h_node* han_u = u3h_v1_slot_to_node(sot_w);
u3h_node* nod_u = u3to(u3h_node, u3a_rewritten(u3of(u3h_node,han_u)));

har_u->sot_w[i_w] = u3h_v1_node_to_slot(nod_u);

_ch_v1_rewrite_node(han_u, 25);
}
}
}
5 changes: 0 additions & 5 deletions pkg/noun/v1/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
void
u3h_v1_free(u3p(u3h_root) har_p);

/* u3h_v1_rewrite(): rewrite hashtable for compaction.
*/
void
u3h_v1_rewrite(u3p(u3h_root) har_p);

/* u3h_v1_walk_with(): traverse hashtable with key, value fn and data
* argument; RETAINS.
*/
Expand Down
27 changes: 0 additions & 27 deletions pkg/noun/v1/jets.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,3 @@ u3j_v1_reclaim(void)
u3R->jed.han_p = u3h_new(); // XX maybe initialize these at end of migration
fprintf(stderr, "u3j_v1_reclaim 4 \r\n");
}

/* u3j_v1_rewrite_compact(): rewrite jet state for compaction.
*
* NB: u3R->jed.han_p *must* be cleared (currently via u3j_v1_reclaim above)
* since it contains hanks which are not nouns but have loom pointers.
* Alternately, rewrite the entries with u3h_v1_walk, using u3j_v1_mark as a
* template for how to walk. There's an untested attempt at this in git
* history at e8a307a.
*/
void
u3j_v1_rewrite_compact()
{
u3h_v1_rewrite(u3R->jed.war_p);
u3h_v1_rewrite(u3R->jed.cod_p);
u3h_v1_rewrite(u3R->jed.han_p);
u3h_v1_rewrite(u3R->jed.bas_p);

if ( u3R == &(u3H->rod_u) ) {
u3h_v1_rewrite(u3R->jed.hot_p);
u3R->jed.hot_p = u3a_rewritten(u3R->jed.hot_p);
}

u3R->jed.war_p = u3a_rewritten(u3R->jed.war_p);
u3R->jed.cod_p = u3a_rewritten(u3R->jed.cod_p);
u3R->jed.han_p = u3a_rewritten(u3R->jed.han_p);
u3R->jed.bas_p = u3a_rewritten(u3R->jed.bas_p);
}
6 changes: 0 additions & 6 deletions pkg/noun/v1/jets.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
void
u3j_v1_reclaim(void);

/* u3j_v1_rewrite_compact(): rewrite jet state for compaction.
*/
void
u3j_v1_rewrite_compact();

/* u3j_v1_rite_lose(): lose references of u3j_rite (but do not free).
*/
void
Expand All @@ -25,5 +20,4 @@
void
u3j_v1_site_lose(u3j_site* sit_u);


#endif /* ifndef U3_JETS_V1_H */
46 changes: 0 additions & 46 deletions pkg/noun/v1/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "pkg/noun/v1/hashtable.h"
#include "pkg/noun/v1/jets.h"
#include "pkg/noun/v1/nock.h"
#include "pkg/noun/vortex.h"
#include "pkg/noun/v1/vortex.h"

/* u3m_v1_reclaim: clear persistent caches to reclaim memory
Expand All @@ -24,48 +23,3 @@ u3m_v1_reclaim(void)
u3a_v1_reclaim();
fprintf(stderr, "u3m_v1_reclaim 5\r\n");
}

/* _cm_pack_rewrite(): trace through arena, rewriting pointers.
* XX need to version; dynamic scope insanity!
*/
static void
_cm_pack_rewrite(void)
{
// XX fix u3a_rewrite* to support south roads
//
u3_assert( &(u3H->rod_u) == u3R );

// NB: these implementations must be kept in sync with u3m_v1_reclaim();
// anything not reclaimed must be rewritable
//
u3v_v1_rewrite_compact();
u3j_v1_rewrite_compact();
u3n_v1_rewrite_compact();
u3a_v1_rewrite_compact();
}

/* u3m_v1_pack: compact (defragment) memory, returns u3a_open delta.
*/
c3_w
u3m_v1_pack(void)
{
c3_w pre_w = u3a_open(u3R);

// reclaim first, to free space, and discard anything we can't/don't rewrite
//
u3m_v1_reclaim();

// sweep the heap, finding and saving new locations
//
u3a_pack_seek(u3R);

// trace roots, rewriting inner pointers
//
_cm_pack_rewrite();

// sweep the heap, relocating objects to their new locations
//
u3a_pack_move(u3R);

return (u3a_open(u3R) - pre_w);
}
7 changes: 0 additions & 7 deletions pkg/noun/v1/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
#ifndef U3_MANAGE_V1_H
#define U3_MANAGE_V1_H

#include "c3.h"

/** System management.
**/
/* u3m_v1_reclaim: clear persistent caches to reclaim memory
*/
void
u3m_v1_reclaim(void);

/* u3m_v1_pack: compact (defragment) memory, returns u3a_open delta.
*/
c3_w
u3m_v1_pack(void);

#endif /* ifndef U3_MANAGE_V1_H */
20 changes: 0 additions & 20 deletions pkg/noun/v1/nock.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,3 @@ u3n_v1_free()
fprintf(stderr, "u3n_v1_free walked\r\n");
u3h_v1_free(har_p);
}

/* u3n_v1_rewrite_compact(): rewrite the bytecode cache for compaction.
*
* NB: u3R->byc.har_p *must* be cleared (currently via u3n_v1_reclaim above),
* since it contains things that look like nouns but aren't.
* Specifically, it contains "cells" where the tail is a
* pointer to a u3a_malloc'ed block that contains loom pointers.
*
* You should be able to walk this with u3h_walk and rewrite the
* pointers, but you need to be careful to handle that u3a_malloc
* pointers can't be turned into a box by stepping back two words. You
* must step back one word to get the padding, step then step back that
* many more words (plus one?).
*/
void
u3n_v1_rewrite_compact()
{
u3h_v1_rewrite(u3R->byc.har_p);
u3R->byc.har_p = u3a_rewritten(u3R->byc.har_p);
}
5 changes: 0 additions & 5 deletions pkg/noun/v1/nock.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@
void
u3n_v1_free(void);

/* u3n_v1_rewrite_compact(): rewrite bytecode cache for compaction.
*/
void
u3n_v1_rewrite_compact();

#endif /* ifndef U3_NOCK_V1_H */
17 changes: 0 additions & 17 deletions pkg/noun/v1/vortex.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,3 @@ u3v_v1_reclaim(void)
u3a_v1_lose(u3A->yot);
u3A->yot = u3_nul;
}

/* u3v_v1_rewrite_compact(): rewrite arvo kernel for compaction.
*/
void
u3v_v1_rewrite_compact()
{
u3v_arvo* arv_u = &(u3H->arv_u);

u3a_v1_rewrite_noun(arv_u->roc);
u3a_v1_rewrite_noun(arv_u->now);
u3a_v1_rewrite_noun(arv_u->yot);

arv_u->roc = u3a_v1_rewritten_noun(arv_u->roc);
arv_u->now = u3a_v1_rewritten_noun(arv_u->now);
arv_u->yot = u3a_v1_rewritten_noun(arv_u->yot);
}

5 changes: 0 additions & 5 deletions pkg/noun/v1/vortex.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,4 @@
void
u3v_v1_reclaim(void);

/* u3v_v1_rewrite_compact(): rewrite arvo kernel for compaction.
*/
void
u3v_v1_rewrite_compact();

#endif /* ifndef U3_VORTEX_V1_H */
5 changes: 0 additions & 5 deletions pkg/noun/v2/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ u3m_v2_migrate()

fprintf(stderr, "loom: pointer compression migration running...\r\n");

/* 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();
fprintf(stderr, "v1 packed\r\n");

/* perform the migration in a pattern similar to |pack */
_migrate_reclaim();
_migrate_seek(&u3H->rod_u);
Expand Down

0 comments on commit 591ea02

Please sign in to comment.