very simple initial test passing

This commit is contained in:
Ted Blackman 2017-11-02 15:39:57 -07:00
parent 7a7cd53cb8
commit 87397ad7ea
4 changed files with 36 additions and 12 deletions

View File

@ -87,6 +87,11 @@
***
*** Needs: delete and merge functions; clock reclamation function.
**/
/* u3h_new_cache(): create hashtable with bounded size.
*/
u3p(u3h_root)
u3h_new_cache(c3_w clk_w);
/* u3h_new(): create hashtable.
*/
u3p(u3h_root)

View File

@ -26,6 +26,16 @@
c3_i
u3m_bail(c3_m how_m) __attribute__((noreturn));
/* u3m_init(): start the environment, with/without checkpointing.
*/
void
u3m_init(c3_o chk_o);
/* u3m_pave(): instantiate or activate image.
*/
void
u3m_pave(c3_o nuu_o, c3_o bug_o);
/* u3m_file(): load file, as atom, or bail.
*/
u3_noun

View File

@ -10,6 +10,8 @@ static c3_o _ch_trim_one_some(u3h_slot*, c3_w);
static c3_o _ch_trim_one_buck(u3h_slot*);
static c3_o _ch_trim_one_node(u3h_slot*, c3_w);
/* u3h_new_cache(): create hashtable with bounded size.
*/
u3p(u3h_root)
u3h_new_cache(c3_w clk_w)
{
@ -223,13 +225,17 @@ u3h_put(u3p(u3h_root) har_p, u3_noun key, u3_noun val)
c3_w rem_w = (mug_w & ((1 << 25) - 1)); // TODO: macro
c3_w sot_w = har_u->sot_w[inx_w];
// nothing stored for this 6-bit prefix
// nothing stored for this 6-bit prefix
//
if ( _(u3h_slot_is_null(sot_w)) ) {
if ( har_u->clk_w > 0 ) {
u3h_trim_to(har_p, har_u->clk_w - 1);
}
har_u->sot_w[inx_w] = u3h_noun_to_slot(kev);
har_u->use_w++;
// make sure we don't immediately trim off the new value.
//
if ( har_u->arm_w == inx_w ) {
har_u->arm_w = (har_u->arm_w + 1) % 64;
}
}
else {
u3h_node* han_u;
@ -252,6 +258,10 @@ u3h_put(u3p(u3h_root) har_p, u3_noun key, u3_noun val)
}
har_u->sot_w[inx_w] = u3h_node_to_slot(han_u);
}
if ( har_u->clk_w > 0 ) {
u3h_trim_to(har_p, har_u->clk_w);
}
}
/* u3h_trim_to(): trim to n key-value pairs
@ -401,7 +411,6 @@ _ch_trim_one_node(u3h_slot* hal_w, c3_w lef_w)
u3h_slot sot_w = han_u->sot_w[han_u->arm_w];
c3_w len_w = _ch_popcount(han_u->map_w);
c3_assert(len_w != 1);
if ( len_w == 2 ) {

View File

@ -479,10 +479,10 @@ u3m_mark(void)
return tot_w;
}
/* _cm_pave(): instantiate or activate image.
/* u3m_pave(): instantiate or activate image.
*/
static void
_cm_pave(c3_o nuu_o, c3_o bug_o)
void
u3m_pave(c3_o nuu_o, c3_o bug_o)
{
if ( c3y == nuu_o ) {
u3H = (void *)_pave_north(u3_Loom + 1,
@ -1456,10 +1456,10 @@ _cm_signals(void)
}
}
/* _cm_init(): start the environment, with/without checkpointing.
/* u3m_init(): start the environment, with/without checkpointing.
*/
void
_cm_init(c3_o chk_o)
u3m_init(c3_o chk_o)
{
_cm_limits();
_cm_signals();
@ -1663,7 +1663,7 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c,
{
/* Activate the loom.
*/
_cm_init(nuu_o);
u3m_init(nuu_o);
/* Activate the storage system.
*/
@ -1675,7 +1675,7 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c,
/* Construct or activate the allocator.
*/
_cm_pave(nuu_o, bug_o);
u3m_pave(nuu_o, bug_o);
/* Initialize the jet system.
*/