program splitting for located cores

This commit is contained in:
Paul Driver 2018-05-25 18:17:19 -07:00
parent 56ff1520bf
commit 7fe3eee82a
3 changed files with 36 additions and 27 deletions

View File

@ -46,10 +46,11 @@
u3_noun u3_noun
u3n_nock_on(u3_noun bus, u3_noun fol); u3n_nock_on(u3_noun bus, u3_noun fol);
/* u3n_find(): return prog for given formula. fol is RETAINED. /* u3n_find(): return prog for given formula,
* split by key (can be u3_none). RETAIN.
*/ */
u3p(u3n_prog) u3p(u3n_prog)
u3n_find(u3_noun fol); u3n_find(u3_weak key, u3_noun fol);
/* u3n_burn(): execute u3n_prog with bus as subject. /* u3n_burn(): execute u3n_prog with bus as subject.
*/ */

View File

@ -1198,11 +1198,11 @@ u3j_hook(u3_noun cor,
/* _cj_prog(): stop tracing glu and find a nock program /* _cj_prog(): stop tracing glu and find a nock program
*/ */
static u3p(u3n_prog) static u3p(u3n_prog)
_cj_prog(u3_noun fol) _cj_prog(u3_weak loc, u3_noun fol)
{ {
u3p(u3n_prog) pog_p; u3p(u3n_prog) pog_p;
u3t_off(glu_o); u3t_off(glu_o);
pog_p = u3n_find(fol); pog_p = u3n_find(loc, fol);
u3t_on(glu_o); u3t_on(glu_o);
return pog_p; return pog_p;
} }
@ -1307,10 +1307,10 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor)
sit_u->fon_o = c3y; sit_u->fon_o = c3y;
if ( 0 == (sit_u->axe = _cj_axis(fol)) ) { if ( 0 == (sit_u->axe = _cj_axis(fol)) ) {
sit_u->jet_o = c3n; sit_u->jet_o = c3n;
sit_u->pog_p = _cj_prog(fol); sit_u->pog_p = _cj_prog(loc, fol);
} }
else { else {
han_u->sit_u.pog_p = _cj_prog(u3r_at(sit_u->axe, cor)); han_u->sit_u.pog_p = _cj_prog(loc, u3r_at(sit_u->axe, cor));
han_u->sit_u.jet_o = _cj_nail(loc, sit_u->axe, han_u->sit_u.jet_o = _cj_nail(loc, sit_u->axe,
&(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u));
} }
@ -1582,13 +1582,13 @@ u3j_site_ream(u3j_site* sit_u)
/* _cj_site_lock(): ensure site has a valid program pointer /* _cj_site_lock(): ensure site has a valid program pointer
*/ */
static void static void
_cj_site_lock(u3_noun cor, u3j_site* sit_u) _cj_site_lock(u3_noun loc, u3_noun cor, u3j_site* sit_u)
{ {
if ( (u3_none != sit_u->bat) && if ( (u3_none != sit_u->bat) &&
(c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) {
return; return;
} }
sit_u->pog_p = _cj_prog(u3r_at(sit_u->axe, cor)); sit_u->pog_p = _cj_prog(loc, u3r_at(sit_u->axe, cor));
if ( u3_none != sit_u->bat ) { if ( u3_none != sit_u->bat ) {
u3z(sit_u->bat); u3z(sit_u->bat);
} }
@ -1611,7 +1611,7 @@ _cj_burn(u3p(u3n_prog) pog_p, u3_noun cor)
** (no validity checks). ** (no validity checks).
*/ */
static u3_weak static u3_weak
_cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u)
{ {
u3_weak pro = u3_none; u3_weak pro = u3_none;
c3_o jet_o = sit_u->jet_o; c3_o jet_o = sit_u->jet_o;
@ -1626,7 +1626,7 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u)
u3t_on(glu_o); u3t_on(glu_o);
} }
if ( u3_none == pro ) { if ( u3_none == pro ) {
_cj_site_lock(cor, sit_u); _cj_site_lock(loc, cor, sit_u);
} }
} }
else { else {
@ -1637,7 +1637,7 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u)
u3t_on(glu_o); u3t_on(glu_o);
} }
if ( u3_none == pro ) { if ( u3_none == pro ) {
_cj_site_lock(cor, sit_u); _cj_site_lock(loc, cor, sit_u);
pro = _cj_burn(sit_u->pog_p, cor); pro = _cj_burn(sit_u->pog_p, cor);
} }
if ( c3y == pof_o ) { if ( c3y == pof_o ) {
@ -1660,7 +1660,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u)
if ( c3y == _cj_fine(cor, sit_u->fin_p) ) { if ( c3y == _cj_fine(cor, sit_u->fin_p) ) {
loc = sit_u->loc; loc = sit_u->loc;
if ( c3y == sit_u->jet_o ) { if ( c3y == sit_u->jet_o ) {
pro = _cj_site_kick_hot(cor, sit_u); pro = _cj_site_kick_hot(loc, cor, sit_u);
} }
} }
} }
@ -1690,7 +1690,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u)
(sit_u->jet_o = _cj_nail(loc, sit_u->axe, (sit_u->jet_o = _cj_nail(loc, sit_u->axe,
&(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) )
{ {
pro = _cj_site_kick_hot(cor, sit_u); pro = _cj_site_kick_hot(loc, cor, sit_u);
} }
else { else {
pro = u3_none; pro = u3_none;
@ -1707,7 +1707,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u)
} }
if ( u3_none == pro ) { if ( u3_none == pro ) {
_cj_site_lock(cor, sit_u); _cj_site_lock(loc, cor, sit_u);
} }
return pro; return pro;
@ -1785,8 +1785,9 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor)
sit_u->axe = 2; sit_u->axe = 2;
sit_u->bas = _cj_bash(u3h(cor)); sit_u->bas = _cj_bash(u3h(cor));
sit_u->bat = cor; // a lie, this isn't really the battery! sit_u->bat = cor; // a lie, this isn't really the battery!
sit_u->pog_p = _cj_prog(u3h(cor)); sit_u->loc = loc = _cj_spot(cor, sit_u->bas);
if ( u3_none != (loc = sit_u->loc = _cj_spot(cor, sit_u->bas)) ) { sit_u->pog_p = _cj_prog(loc, u3h(cor));
if ( u3_none != loc ) {
u3_noun pax = _cj_loc_axe(loc), u3_noun pax = _cj_loc_axe(loc),
pay = u3qc_cap(pax), pay = u3qc_cap(pax),
pam = u3qc_mas(pax); pam = u3qc_mas(pax);
@ -1823,7 +1824,7 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam)
sam, sam,
u3k(u3t(u3t(sit_u->bat)))); u3k(u3t(u3t(sit_u->bat))));
if ( (u3_none != sit_u->loc) && (c3y == sit_u->jet_o) ) { if ( (u3_none != sit_u->loc) && (c3y == sit_u->jet_o) ) {
pro = _cj_site_kick_hot(cor, sit_u); pro = _cj_site_kick_hot(sit_u->loc, cor, sit_u);
} }
if ( u3_none == pro ) { if ( u3_none == pro ) {
pro = _cj_burn(sit_u->pog_p, cor); pro = _cj_burn(sit_u->pog_p, cor);

View File

@ -1442,17 +1442,21 @@ _n_bite(u3_noun fol) {
/* _n_find(): return prog for given formula. fol is RETAINED. /* _n_find(): return prog for given formula. fol is RETAINED.
*/ */
static u3n_prog* static u3n_prog*
_n_find(u3_noun fol) _n_find(u3_weak key, u3_noun fol)
{ {
u3_weak pog = u3h_git(u3R->byc.har_p, fol); key = (u3_none == key)
? u3k(fol)
: u3nc(u3k(key), u3k(fol));
u3_weak pog = u3h_git(u3R->byc.har_p, key);
if ( u3_none != pog ) { if ( u3_none != pog ) {
u3z(key);
return u3to(u3n_prog, pog); return u3to(u3n_prog, pog);
} }
else if ( u3R != &u3H->rod_u ) { else if ( u3R != &u3H->rod_u ) {
u3a_road* rod_u = u3R; u3a_road* rod_u = u3R;
while ( rod_u->par_p ) { while ( rod_u->par_p ) {
rod_u = u3to(u3a_road, rod_u->par_p); rod_u = u3to(u3a_road, rod_u->par_p);
pog = u3h_git(rod_u->byc.har_p, fol); pog = u3h_git(rod_u->byc.har_p, key);
if ( u3_none != pog ) { if ( u3_none != pog ) {
c3_w i_w; c3_w i_w;
u3n_prog* old = _n_prog_old(u3to(u3n_prog, pog)); u3n_prog* old = _n_prog_old(u3to(u3n_prog, pog));
@ -1466,7 +1470,8 @@ _n_find(u3_noun fol)
sit_u->pog_p = 0; sit_u->pog_p = 0;
sit_u->fon_o = c3n; sit_u->fon_o = c3n;
} }
u3h_put(u3R->byc.har_p, fol, u3a_outa(old)); u3h_put(u3R->byc.har_p, key, u3a_outa(old));
u3z(key);
return old; return old;
} }
} }
@ -1474,19 +1479,21 @@ _n_find(u3_noun fol)
{ {
u3n_prog* gop = _n_bite(fol); u3n_prog* gop = _n_bite(fol);
u3h_put(u3R->byc.har_p, fol, u3a_outa(gop)); u3h_put(u3R->byc.har_p, key, u3a_outa(gop));
u3z(key);
return gop; return gop;
} }
} }
/* u3n_find(): return prog for given formula. RETAIN. /* u3n_find(): return prog for given formula,
* split by key (can be u3_none). RETAIN.
*/ */
u3p(u3n_prog) u3p(u3n_prog)
u3n_find(u3_noun fol) u3n_find(u3_weak key, u3_noun fol)
{ {
u3p(u3n_prog) pog_p; u3p(u3n_prog) pog_p;
u3t_on(noc_o); u3t_on(noc_o);
pog_p = u3of(u3n_prog, _n_find(fol)); pog_p = u3of(u3n_prog, _n_find(key, fol));
u3t_off(noc_o); u3t_off(noc_o);
return pog_p; return pog_p;
} }
@ -1793,7 +1800,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off)
fam->pog_u = pog_u; fam->pog_u = pog_u;
_n_push(mov, off, x); _n_push(mov, off, x);
nock_out: nock_out:
pog_u = _n_find(o); pog_u = _n_find(u3_none, o);
pog = pog_u->byc_u.ops_y; pog = pog_u->byc_u.ops_y;
ip_w = 0; ip_w = 0;
#ifdef U3_CPU_DEBUG #ifdef U3_CPU_DEBUG
@ -2189,7 +2196,7 @@ u3n_burn(u3p(u3n_prog) pog_p, u3_noun bus)
static u3_noun static u3_noun
_n_burn_on(u3_noun bus, u3_noun fol) _n_burn_on(u3_noun bus, u3_noun fol)
{ {
u3n_prog* pog_u = _n_find(fol); u3n_prog* pog_u = _n_find(u3_none, fol);
u3z(fol); u3z(fol);
return _n_burn_out(bus, pog_u); return _n_burn_out(bus, pog_u);