Skip to content

Commit

Permalink
wip: st. pantaleon
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Jul 28, 2023
1 parent 06c9e43 commit b83a23e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
10 changes: 10 additions & 0 deletions pkg/noun/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ _ch_slot_put(u3h_slot* sot_w, u3_noun kev, c3_w lef_w, c3_w rem_w, c3_w* use_w)
void
u3h_put(u3p(u3h_root) har_p, u3_noun key, u3_noun val)
{
if ( 1001 == u3h(u3t(key)) ) {
fprintf(stderr, "\r\nu3h_put: 1001\r\n");
}

u3h_root* har_u = u3to(u3h_root, har_p);
u3_noun kev = u3nc(u3k(key), val);
c3_w mug_w = u3r_mug(key);
Expand All @@ -258,10 +262,16 @@ u3h_put(u3p(u3h_root) har_p, u3_noun key, u3_noun val)
u3h_slot* sot_w = &(har_u->sot_w[inx_w]);

if ( c3y == u3h_slot_is_null(*sot_w) ) {
// if ( 1001 == u3h(u3t(kev)) ) {
// fprintf(stderr, "\r\nu3h_put: slot is null for 1001\r\n");
// }
*sot_w = u3h_noun_be_warm(u3h_noun_to_slot(kev));
har_u->use_w += 1;
}
else {
// if ( 1001 == u3h(u3t(kev)) ) {
// fprintf(stderr, "\r\nu3h_put: slot is not null for 1001\r\n");
// }
_ch_slot_put(sot_w, kev, 25, rem_w, &(har_u->use_w));
}

Expand Down
11 changes: 8 additions & 3 deletions pkg/noun/nock.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// @file

#include "log.h"
#include "nock.h"

#include "allocate.h"
Expand Down Expand Up @@ -2627,9 +2628,13 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off)
x = _n_pep(mov, off);
top = _n_peek(off);
o = *top;
if ( &(u3H->rod_u) != u3R ) {
u3z_save_m(144 + c3__nock, o, x);
}
// if ( &(u3H->rod_u) != u3R ) {
// u3z_save_m(144 + c3__nock, o, x);
// }

// save in the cache no matter which road we're on
u3z_save_m(144 + c3__nock, o, x);

*top = x;
u3z(o);
BURN();
Expand Down
40 changes: 39 additions & 1 deletion pkg/noun/zave.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// @file

#include "log.h"
#include "zave.h"

#include "allocate.h"
Expand Down Expand Up @@ -39,15 +40,40 @@ u3z_key_5(c3_m fun, u3_noun one, u3_noun two, u3_noun tri, u3_noun qua, u3_noun
u3_weak
u3z_find(u3_noun key)
{
return u3h_get(u3R->cax.har_p, key);
// search the parent roads' caches
u3a_road* rod_u = u3R;
while ( 1 ) {
u3_weak got = u3h_get(rod_u->cax.har_p, key);
if ( u3_none != got ) {
return got;
}
if ( 0 == rod_u->par_p ) {
return u3_none;
}
rod_u = u3to(u3a_road, rod_u->par_p);
};
}
u3_weak
u3z_find_m(c3_m fun, u3_noun one)
{
u3_noun key = u3nc(fun, u3k(one));
u3_weak val;

// if ( 1001 == u3h(one) ) {
// u3l_log("\r\nzave: 1001\r\n");
// }

val = u3h_get(u3R->cax.har_p, key);

// if ( 1001 == u3h(one) ) {
// if ( u3_none == val ) {
// u3l_log("\r\nzave: miss\r\n");
// }
// else {
// u3l_log("\r\nzave: hit\r\n");
// }
// }

u3z(key);
return val;
}
Expand All @@ -67,6 +93,11 @@ u3z_save(u3_noun key, u3_noun val)
u3_noun
u3z_save_m(c3_m fun, u3_noun one, u3_noun val)
{

if ( 1001 == u3h(one) ) {
u3l_log("\r\nzave: 1001\r\n");
}

u3_noun key = u3nc(fun, u3k(one));

u3h_put(u3R->cax.har_p, key, u3k(val));
Expand Down Expand Up @@ -96,6 +127,13 @@ u3z_uniq(u3_noun som)
void
u3z_reap(u3p(u3h_root) har_p)
{
// u3_noun key = u3nc(1001, u3nc(11, u3nt(u3nq(c3__slog, 1, 2, 23130), 1, 40)));
// u3_noun val = u3z_find_m(144 + c3__nock, key);
// u3m_p("u3z_reap", key);

// if ( u3_none != val ) {
// u3l_log("u3z_reap: hit\r\n");
// }
u3h_uni(u3R->cax.har_p, har_p);
u3h_free(har_p);
}

0 comments on commit b83a23e

Please sign in to comment.