From 0e3180aea0f22429e904868214b249d21e467682 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 30 Jan 2018 16:27:04 -0800 Subject: [PATCH 001/221] stash - writing it down --- noun/nock.c | 532 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 532 insertions(+) diff --git a/noun/nock.c b/noun/nock.c index ff569cb61..53db6deaa 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -495,3 +495,535 @@ u3n_nock_an(u3_noun bus, u3_noun fol) return u3n_nock_et(gul, bus, fol); } + +/* _n_mush_in(): see _n_mush(). +*/ +static u3_noun +_n_mush_in(u3_noun val) +{ + if ( c3n == u3du(val) ) { + return u3_nul; + } + else { + u3_noun h_val = u3h(val); + u3_noun ite; + + if ( c3n == u3ud(h_val) ) { + ite = u3nc(c3__leaf, u3_nul); + } else { + ite = u3nc(c3__leaf, u3qe_trip(h_val)); + } + return u3nc(ite, _n_mush_in(u3t(val))); + case c3_ + } + } +} + +#define FRAG 0 +#define QUOT 1 +#define NOCK 2 +#define DEEP 3 +#define BUMP 4 +#define SAME 5 +#define BAIL 6 +#define HEAD 7 +#define TAIL 8 +#define COPY 9 +#define SWAP 10 +#define CONS 11 +#define SCON 12 +#define SKIN 13 +#define SKIP 14 +#define WISH 15 +#define KICK 16 + +static inline c3_y +_n_emit(u3_noun *ops, u3_noun op) +{ + *ops = u3nc(op, *ops); + if ( c3n == u3du(op) ) { + return sizeof(c3_y); + } + else switch ( u3h(op) ) { + case SKIP: + case SKIN: + return sizeof(c3_y) + sizeof(c3_s); + case QUOT: + case QUIP: + case FRAG: + case TICK: + case KICK: + return sizeof(c3_y) + sizeof(u3_noun); + default: + c3_assert(0); + } +} + +static c3_s _n_comp(u3_noun*, u3_noun, c3_o); + +static c3_s _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) +{ + if ( c3n == u3du(hif) ) { + // no currently recognized static hints + return _n_comp(ops, nef, tel_o); + } + else { + c3_s tot_s = 0; + u3_noun zep, hod; + u3x_cell(hif, &zep, &hod); + + switch ( zep ) { + default: + tos += _n_emit(ops, COPY); + tos += _n_comp(ops, hod, c3n); + tos += _n_emit(ops, TOSS); + tos += _n_comp(ops, nef, tel_o); + break; + + case c3__hunk: + case c3__lose: + case c3__mean: + case c3__spot: + tot_s += _n_emit(ops, u3nc(QUIP, zep)); + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_emit(ops, CONS); + tot_s += _n_emit(ops, STAP); + tot_s += _n_comp(ops, nef, c3n); + tot_s += _n_emit(ops, STOP); + break; + + case c3__live: + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_emit(ops, PEEP); + tot_s += _n_emit(ops, u3nc(SKIN, sizeof(c3_y) + + sizeof(c3_y) + sizeof(c3_s))); + tot_s += _n_emit(ops, HECK); + tot_s += _n_emit(ops, u3nc(SKIP, sizeof(c3_y))); + tot_s += _n_emit(ops, TOSS); + tot_s += _n_comp(ops, nef, tel_o); + break; + + case c3__slog: + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_emit(ops, SLOG); + tot_s += _n_comp(ops, nef, tel_o); + break; + + case c3__fast: + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, nef, c3n); + tot_s += _n_emit(ops, FAST); + break; + + case c3__memo: { + u3_noun nop = u3_nul; + c3_s n_s = _n_comp(&nop, nef, c3n); + + n_s += _n_emit(ops, PUMO); + tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_emit(ops, GEMO); + tot_s += _n_emit(ops, PEEP); + tot_s += _n_emit(ops, u3nc(SKIN, sizeof(c3_y) + + sizeof(c3_y) + sizeof(c3_s))); + tot_s += _n_emit(ops, TAIL); + tot_s += _n_emit(ops, u3nc(SKIP, n_s)); + + _n_apen(ops, nop); + tot_s += n_s; + break; + } + } + return tot_s; + } +} + +/* fol is RETAINED */ +static c3_s +_n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { + c3_s tot_s = 0; + u3_noun cod, arg, hed, tel; + u3x_cell(fol, &cod, &arg); + + if ( c3y == u3du(cod) ) { + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, cod, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, arg, c3n); + tot_s += _n_emit(ops, CONS); + } + else switch ( cod ) { + case 0: + if ( c3n == u3ud(arg) ) { + return u3m_bail(c3__exit); + } + switch ( arg ) { + case 0: + tot_s += _n_emit(ops, BAIL); + break; + case 1: + break; + case 2: + tot_s += _n_emit(ops, HEAD); + break; + case 3: + tot_s += _n_emit(ops, TAIL); + break; + default: + tot_s += _n_emit(ops, u3nc(FRAG, u3k(arg))); + } + break; + case 1: { + tot_s += _n_emit(ops, u3nc(QUOT, u3k(arg))); + break; + } + case 2: + u3x_cell(arg, &hed, &tel); + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hed, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_emit(ops, (tel_o ? NOCT : NOCK)); + break; + case 3: + tot_s += _n_comp(ops, arg, c3n); + tot_s += _n_emit(ops, DEEP); + break; + case 4: + tot_s += _n_comp(ops, arg, c3n); + tot_s += _n_emit(ops, BUMP); + break; + case 5: + u3x_cell(arg, &hed, &tel); + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hed, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_emit(ops, SAME); + break; + case 6: { + u3_noun mid; + u3x_trel(arg, &hed, &mid, &tel); + + tot_s += _n_comp(ops, hed, c3n); + + u3_noun yep = u3_nul, + nop = u3_nul; + c3_s y_s = _n_comp(&yep, mid, tel_o), + n_s = _n_comp(&nop, tel, tel_o), + sin_s = y_s + sizeof(c3_y) + sizeof(c3_s); + + tot_s += _n_emit(ops, u3nc(SKIN, sin_s)); + _n_apen(ops, yep); + tot_s += y_s; + + tot_s += _n_emit(ops, u3nc(SKIP, n_s)); + _n_apen(ops, nop); + tot_s += n_s; + break; + } + case 7: + u3x_cell(arg, &hed, &tel); + tot_s += _n_comp(ops, hed, c3n); + tot_s += _n_comp(ops, tel, tel_o); + break; + case 8: + u3x_cell(arg, &hed, &tel); + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hed, c3n); + tot_s += _n_emit(ops, SCON); + tot_s += _n_comp(ops, tel, tel_o); + break; + case 9: + u3x_cell(arg, &hed, &tel); + if ( 3 == u3qc_cap(hed) ) { + u3_noun mac = u3nq(7, u3k(tel), 2, u3nt(u3nc(0, 1), 0, u3k(hed))); + tot_s += _n_comp(ops, mac, tel_o); + u3z(mac); + } + else { + tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_emit(ops, u3nc((tel_o ? TICK : KICK), u3k(hed))); + } + break; + case 10: + u3x_cell(arg, &hed, &tel); + tot_s += _n_bint(ops, hed, tel, tel_o); + break; + case 11: + u3x_cell(arg, &hed, &tel); + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hed, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_emit(ops, WISH); + break; + } + return tot_s; +} + +static c3_y* +_n_asm(u3_noun ops) +{ + u3_noun top = ops; + c3_s i_s = _n_comp(&ops, fol); + c3_y* buf_y = u3a_malloc(sizeof(c3_y) * (i_s+1)); + + buf_y[i_s] = HALT; + while ( --i_s >= 0 ) { + u3_noun op = u3h(ops); + if ( c3y == u3ud(op) ) { + buf_y[i_s] = (c3_y) u3h(ops); + } + else { + u3_noun cod = u3h(op); + switch ( cod ) { + case SKIP: + case SKIN: { + c3_s off_s = u3t(op); + buf_y[i_s--] = (c3_y) (off_s >> 8); + buf_y[i_s--] = (c3_y) off_s; + buf_y[i_s] = (c3_y) cod; + break; + } + case QUOT: + case QUIP: + case FRAG: + case TICK: + case KICK: { + c3_w non_w = u3t(op); + buf_y[i_s--] = (c3_y) (non_w >> 24); + buf_y[i_s--] = (c3_y) (non_w >> 16); + buf_y[i_s--] = (c3_y) (non_w >> 8); + buf_y[i_s--] = (c3_y) non_w; + buf_y[i_s] = (c3_y) cod; + break; + } + default: + c3_assert(0); + } + } + ops = u3t(ops); + } + + u3z(ops); + return buf_y; +} + +static inline void +_n_push(u3_noun a) +{ + u3_noun* p = (u3_noun*) u3a_push(sizeof(u3_noun)); + *p = a; +} + +static inline u3_noun* +_n_peek() +{ + return (u3_noun*) u3a_peek(sizeof(u3_noun)); +} + +static inline u3_noun +_n_pop() +{ + u3_noun r = *(_n_peek()); + u3a_pop(sizeof(u3_noun)); + return r; +} + +static inline void +_n_toss() +{ + u3z(_n_pop()); +} + +static inline c3_s +_n_resh(c3_y* buf, c3_s* ip_s) +{ + c3_y les = buf[(*ip_s)++]; + c3_y mos = buf[(*ip_s)++]; + return les | (mos << 8); +} + +static inline u3_noun +_n_rean(c3_y* buf, c3_s* ip_s) +{ + c3_y one = buf[(*ip_s)++], + two = buf[(*ip_s)++], + tre = buf[(*ip_s)++], + qua = buf[(*ip_s)++]; + return one | (two << 8) | (tre << 16) | (qua << 24); +} + +static inline c3_y* +_n_bite(u3_noun fol) +{ + return _n_asm(_n_comp(&bok, fol, c3y)); +} + +static c3_y* +_n_find(u3_noun fol) +{ + u3_noun got = u3h_get(u3R->byc.har_p, fol); + if ( u3_none != got ) { + return u3a_to_ptr(got); + } + else { + c3_y* gop = _n_bite(fol); + got = u3a_to_off(gop); + u3h_put(u3R->byc.har_p, fol, got); + return gop; + } +} + +static u3_noun +_n_burn(c3_y* pog) +{ + static void* lab[] = { + &&do_halt, &&do_copy, &&do_swap, + &&do_toss, &&do_skip, &&do_skin, + &&do_cons, &&do_scon, + &&do_head, &&do_tail, &&do_frag, + &&do_quot, &&do_quip, + &&do_nock, &&do_noct, + &&do_deep, &&do_peep, + &&do_bump, &&do_same, + }; + #define BURN() goto *lab[pog[ip_s++]] + + c3_s sip_s, ip_s = 0; + c3_y op; + c3_y* gop; + u3_noun* top; + u3_noun* up; + u3_noun x, o; + u3p(void) empty = u3R->cap_p; + + BURN(); + while ( 1 ) { + do_halt: + x = _n_pop(); + c3_assert( empty == u3R->cap_p ); + return x; + + do_copy: + top = _n_peek(); + _n_push(u3k(*top)); + BURN(); + + do_swap: + up = (u3_noun*) u3a_peek(sizeof(u3_noun) + sizeof(u3_noun)); + top = _n_peek(); + x = *top; + *top = *up; + *up = x; + BURN(); + + do_toss: + _n_toss(); + BURN(); + + do_skip: + ip_s += _n_resh(pog, &ip_s); + BURN(); + + do_skin: + sip_s = _n_resh(pog, &ip_s); + x = _n_pop(); + if ( c3n == x ) { + ip_s += sip_s; + } + else if ( c3y != x ) { + return u3m_bail(c3__exit); + } + BURN(); + + do_cons: + x = _n_pop(); + top = _n_peek(); + *top = u3nc(*top, x); + BURN(); + + do_scon: + x = _n_pop(); + top = _n_peek(); + *top = u3nc(x, *top); + BURN(); + + do_head: + top = _n_peek(); + o = *top; + if ( c3n == u3du(o) ) { + return u3m_bail(c3__exit); + } + *top = u3k(u3h(o)); + u3z(o); + BURN(); + + do_tail: + top = _n_peek(); + o = *top; + if ( c3n == u3du(o) ) { + return u3m_bail(c3__exit); + } + *top = u3k(u3t(o)); + u3z(o); + BURN(); + + do_frag: + top = _n_peek(); + o = *top; + x = u3x_at(_n_rean(pog, &ip_s), o); + *top = u3k(x); + u3z(o); + BURN(); + + do_quot: + _n_toss(); + do_quip: + _n_push(_n_rean(pog, &ip_s)); + BURN(); + + do_nock: + gop = _n_find(_n_pop()); + _n_push(_n_burn(gop)); + BURN(); + + do_noct: + pog = _n_find(_n_pop()); + ip_s = 0; + BURN(); + + do_deep: + top = _n_peek(); + o = *top; + *top = u3du(o); + u3z(o); + BURN(); + + do_peep: + top = _n_peek(); + _n_push(u3du(*top)); + BURN(); + + do_bump: + top = _n_peek(); + o = *top; + *top = u3i_vint(o); + u3z(o); + BURN(); + + do_same: + x = _n_pop(); + top = _n_peek(); + o = *top; + *top = u3r_sing(x, o); + u3z(x); + u3z(o); + BURN(); + } +} From 9c7f855eeea169ae3970803f35cb9251bb64f280 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 30 Jan 2018 18:14:37 -0800 Subject: [PATCH 002/221] kick and tick --- noun/nock.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/noun/nock.c b/noun/nock.c index 53db6deaa..27db114a9 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -892,6 +892,7 @@ _n_burn(c3_y* pog) &&do_nock, &&do_noct, &&do_deep, &&do_peep, &&do_bump, &&do_same, + &&do_kick, &&do_tick, }; #define BURN() goto *lab[pog[ip_s++]] @@ -985,7 +986,7 @@ _n_burn(c3_y* pog) do_quot: _n_toss(); do_quip: - _n_push(_n_rean(pog, &ip_s)); + _n_push(u3k(_n_rean(pog, &ip_s))); BURN(); do_nock: @@ -1025,5 +1026,41 @@ _n_burn(c3_y* pog) u3z(x); u3z(o); BURN(); + + do_kick: + x = _n_rean(pog, &ip_s); + top = _n_peek(); + o = *top; + u3t_off(noc_o); + *top = u3j_kick(o, x); + u3t_on(noc_o); + if ( u3_none == *top ) { + u3_noun fol = u3r_at(x, o); + if ( u3_none == fol ) { + return u3m_bail(c3__exit); + } + gop = _n_find(fol); + _n_push(o); + *top = _n_burn(gop); + } + BURN(); + + do_tick: + x = _n_rean(pog, &ip_s); + top = _n_peek(); + o = *top; + u3t_off(noc_o); + *top = u3j_kick(o, x); + u3t_on(noc_o); + if ( u3_none == *top ) { + u3_noun fol = u3r_at(x, o); + if ( u3_none == fol ) { + return u3m_bail(c3__exit); + } + *top = o; + pog = _n_find(fol); + ip_s = 0; + } + BURN(); } } From 8038366b5221c1c061bb189ad0c4be58c42c2be6 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 31 Jan 2018 09:20:21 -0800 Subject: [PATCH 003/221] fix memo compilation, implement several hint opcodes --- noun/nock.c | 130 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 21 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 27db114a9..351697611 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -537,6 +537,12 @@ _n_mush_in(u3_noun val) #define WISH 15 #define KICK 16 +static inline void +_n_apen(u3_noun* dst, u3_noun src) +{ + *dst = u3qb_weld(src, *dst); +} + static inline c3_y _n_emit(u3_noun *ops, u3_noun op) { @@ -561,7 +567,8 @@ _n_emit(u3_noun *ops, u3_noun op) static c3_s _n_comp(u3_noun*, u3_noun, c3_o); -static c3_s _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) +static c3_s +_n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) { if ( c3n == u3du(hif) ) { // no currently recognized static hints @@ -588,9 +595,9 @@ static c3_s _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) tot_s += _n_emit(ops, COPY); tot_s += _n_comp(ops, hod, c3n); tot_s += _n_emit(ops, CONS); - tot_s += _n_emit(ops, STAP); + tot_s += _n_emit(ops, CUSH); tot_s += _n_comp(ops, nef, c3n); - tot_s += _n_emit(ops, STOP); + tot_s += _n_emit(ops, DROP); break; case c3__live: @@ -599,9 +606,9 @@ static c3_s _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) tot_s += _n_emit(ops, PEEP); tot_s += _n_emit(ops, u3nc(SKIN, sizeof(c3_y) + sizeof(c3_y) + sizeof(c3_s))); - tot_s += _n_emit(ops, HECK); - tot_s += _n_emit(ops, u3nc(SKIP, sizeof(c3_y))); tot_s += _n_emit(ops, TOSS); + tot_s += _n_emit(ops, u3nc(SKIP, sizeof(c3_y))); + tot_s += _n_emit(ops, HECK); tot_s += _n_comp(ops, nef, tel_o); break; @@ -612,6 +619,8 @@ static c3_s _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) tot_s += _n_comp(ops, nef, tel_o); break; + // germ and sole are unused... + case c3__fast: tot_s += _n_emit(ops, COPY); tot_s += _n_comp(ops, hod, c3n); @@ -621,20 +630,36 @@ static c3_s _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) break; case c3__memo: { - u3_noun nop = u3_nul; - c3_s n_s = _n_comp(&nop, nef, c3n); + u3_noun nop = u3_nul, + yep = u3_nul; + c3_s y_s = 0, + n_s = 0; // top->[bus] + tot_s += _n_emit(ops, COPY); // [bus bus] + tot_s += _n_emit(ops, COPY); // [bus bus bus] + tot_s += _n_comp(ops, hod, c3n); // [clue bus bus] + tot_s += _n_emit(ops, TOSS); // [bus bus] + tot_s += _n_emit(ops, u3nc(QUIP, u3k(nef))); // [fol bus bus] + tot_s += _n_emit(ops, SCON); // [[bus fol] bus] + tot_s += _n_emit(ops, GEMO); // [u key bus] + tot_s += _n_emit(ops, PEEP); // [b u key bus] - n_s += _n_emit(ops, PUMO); - tot_s += _n_comp(ops, hod, c3n); - tot_s += _n_emit(ops, GEMO); - tot_s += _n_emit(ops, PEEP); - tot_s += _n_emit(ops, u3nc(SKIN, sizeof(c3_y) + - sizeof(c3_y) + sizeof(c3_s))); - tot_s += _n_emit(ops, TAIL); - tot_s += _n_emit(ops, u3nc(SKIP, n_s)); + // NO branch, i.e. gemo gave us ~ + n_s += _n_emit(&nop, TOSS); // [key bus] + n_s += _n_emit(&nop, SWAP); // [bus key] + n_s += _n_comp(&nop, nef, c3n); // [pro key] + n_s += _n_emit(ops, PUMO); - _n_apen(ops, nop); - tot_s += n_s; + // YES branch, i.e. gemo gave us [0 pro] + y_s += _n_emit(&yep, TAIL); // [pro key bus] + y_s += _n_emit(ops, SWAT); // [pro bus] + y_s += _n_emit(&yep, u3nc(SKIP, n_s)); + + tot_s += _n_emit(ops, u3nc(SKIN, y_s)); + _n_apen(ops, yup); tot_s += y_s; + _n_apen(ops, nop); tot_s += n_s; + + // both branches leave an extra value under the top + tot_s += _n_emit(ops, SWAT); break; } } @@ -827,6 +852,12 @@ _n_peek() return (u3_noun*) u3a_peek(sizeof(u3_noun)); } +static inline u3_noun* +_n_peet() +{ + return (u3_noun*) u3a_peek(sizeof(u3_noun) + sizeof(u3_noun)); +} + static inline u3_noun _n_pop() { @@ -884,8 +915,9 @@ static u3_noun _n_burn(c3_y* pog) { static void* lab[] = { - &&do_halt, &&do_copy, &&do_swap, - &&do_toss, &&do_skip, &&do_skin, + &&do_halt, &&do_copy, &&do_toss, + &&do_swap, &&do_swat, + &&do_skip, &&do_skin, &&do_cons, &&do_scon, &&do_head, &&do_tail, &&do_frag, &&do_quot, &&do_quip, @@ -893,6 +925,9 @@ _n_burn(c3_y* pog) &&do_deep, &&do_peep, &&do_bump, &&do_same, &&do_kick, &&do_tick, + &&do_cush, &&do_drop, + &&do_pumo, &&do_gemo, + &&do_heck, &&do_slog, &&do_fast, }; #define BURN() goto *lab[pog[ip_s++]] @@ -916,15 +951,24 @@ _n_burn(c3_y* pog) _n_push(u3k(*top)); BURN(); + do_toss: + _n_toss(); + BURN(); + do_swap: - up = (u3_noun*) u3a_peek(sizeof(u3_noun) + sizeof(u3_noun)); top = _n_peek(); + up = _n_peet(); x = *top; *top = *up; *up = x; BURN(); - do_toss: + do_swat: + top = _n_peek(); + up = _n_peet(); + x = *top; + *top = *up; + *up = x; _n_toss(); BURN(); @@ -1062,5 +1106,49 @@ _n_burn(c3_y* pog) ip_s = 0; } BURN(); + + do_cush: + u3t_push(_n_pop()); + BURN(); + + do_drop: + u3t_drop(); + BURN(); + + do_pumo: // top->[pro key] + if ( &(u3H->rod_u) != u3R ) { + top = _n_peek(); + up = _n_peet(); + u3z_save(144 + c3__nock, *up, *top); + } + BURN(); + + do_gemo: + top = _n_peek(); + x = u3z_find(144 + c3__nock, *top); + _n_push(u3_none == x ? 0 : u3nc(0, x)); + BURN(); + + do_heck: + u3t_off(noc_o); + u3t_heck(_n_pop()); + u3t_on(noc_o); + BURN(); + + do_slog: + u3t_off(noc_o); + u3t_slog(_n_pop()); + u3t_on(noc_o); + BURN(); + + do_fast: // top->[pro clu] + top = _n_peek(); + up = _n_peet(); + u3t_off(noc_o); + u3j_mine(*up, u3k(*top)); + u3t_on(noc_o); + *up = *top; + u3a_pop(sizeof(u3_noun)); + BURN(); } } From 62dc052760e57dab666276f325205cbd9e5830eb Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 31 Jan 2018 09:36:31 -0800 Subject: [PATCH 004/221] think-o in stack hints, clarify case 6 in compiler --- noun/nock.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 351697611..df47de7b1 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -591,10 +591,10 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) case c3__lose: case c3__mean: case c3__spot: - tot_s += _n_emit(ops, u3nc(QUIP, zep)); tot_s += _n_emit(ops, COPY); tot_s += _n_comp(ops, hod, c3n); - tot_s += _n_emit(ops, CONS); + tot_s += _n_emit(ops, u3nc(QUIP, zep)); + tot_s += _n_emit(ops, SNOC); tot_s += _n_emit(ops, CUSH); tot_s += _n_comp(ops, nef, c3n); tot_s += _n_emit(ops, DROP); @@ -739,16 +739,12 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { u3_noun yep = u3_nul, nop = u3_nul; c3_s y_s = _n_comp(&yep, mid, tel_o), - n_s = _n_comp(&nop, tel, tel_o), - sin_s = y_s + sizeof(c3_y) + sizeof(c3_s); + n_s = _n_comp(&nop, tel, tel_o); - tot_s += _n_emit(ops, u3nc(SKIN, sin_s)); - _n_apen(ops, yep); - tot_s += y_s; - - tot_s += _n_emit(ops, u3nc(SKIP, n_s)); - _n_apen(ops, nop); - tot_s += n_s; + y_s += _n_emit(&yep, u3nc(SKIP, n_s)); + tot_s += _n_emit(ops, u3nc(SKIN, y_s)); + _n_apen(ops, yep); tot_s += y_s; + _n_apen(ops, nop); tot_s += n_s; break; } case 7: From 9a5bd108714e2ce80b7bae4cf2ba4d6315625fb6 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 31 Jan 2018 15:10:58 -0800 Subject: [PATCH 005/221] wish, some bugfixes, numbered the opcodes --- noun/nock.c | 148 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 100 insertions(+), 48 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index df47de7b1..b690c3c18 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -519,23 +519,37 @@ _n_mush_in(u3_noun val) } } -#define FRAG 0 -#define QUOT 1 -#define NOCK 2 -#define DEEP 3 -#define BUMP 4 -#define SAME 5 -#define BAIL 6 -#define HEAD 7 -#define TAIL 8 -#define COPY 9 -#define SWAP 10 -#define CONS 11 -#define SCON 12 -#define SKIN 13 -#define SKIP 14 -#define WISH 15 -#define KICK 16 +/* These must match the order in the section marked OPCODE TABLE */ +#define HALT 0 +#define COPY 1 +#define TOSS 2 +#define SWAP 3 +#define SWAT 4 +#define SKIP 5 +#define SKIN 6 +#define CONS 7 +#define SCON 8 +#define HEAD 9 +#define TAIL 10 +#define FRAG 11 +#define QUOT 12 +#define QUIP 13 +#define NOCK 14 +#define NOCT 15 +#define DEEP 16 +#define PEEP 17 +#define BUMP 18 +#define SAME 19 +#define KICK 20 +#define TICK 21 +#define WISH 22 +#define FAST 23 +#define CUSH 24 +#define DROP 25 +#define PUMO 26 +#define GEMO 27 +#define HECK 28 +#define SLOG 29 static inline void _n_apen(u3_noun* dst, u3_noun src) @@ -600,17 +614,28 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) tot_s += _n_emit(ops, DROP); break; - case c3__live: + case c3__live: { + u3_noun yep = u3_nul, + nop = u3_nul; + c3_s y_s = 0, + n_s = 0; + tot_s += _n_emit(ops, COPY); tot_s += _n_comp(ops, hod, c3n); tot_s += _n_emit(ops, PEEP); - tot_s += _n_emit(ops, u3nc(SKIN, sizeof(c3_y) + - sizeof(c3_y) + sizeof(c3_s))); - tot_s += _n_emit(ops, TOSS); - tot_s += _n_emit(ops, u3nc(SKIP, sizeof(c3_y))); - tot_s += _n_emit(ops, HECK); + + n_s += _n_emit(&nop, HECK); + + y_s += _n_emit(&yep, TOSS); + y_s += _n_emit(&yep, u3nc(SKIP, n_s)); + + tot_s += n_emit(ops, u3nc(SKIN, y_s)); + _n_apen(ops, yep); tot_s += y_s; + _n_apen(ops, nop); tot_s += n_s; + tot_s += _n_comp(ops, nef, tel_o); break; + } case c3__slog: tot_s += _n_emit(ops, COPY); @@ -632,6 +657,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) case c3__memo: { u3_noun nop = u3_nul, yep = u3_nul; + c3_s y_s = 0, n_s = 0; // top->[bus] tot_s += _n_emit(ops, COPY); // [bus bus] @@ -647,11 +673,11 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) n_s += _n_emit(&nop, TOSS); // [key bus] n_s += _n_emit(&nop, SWAP); // [bus key] n_s += _n_comp(&nop, nef, c3n); // [pro key] - n_s += _n_emit(ops, PUMO); + n_s += _n_emit(&nop, PUMO); // YES branch, i.e. gemo gave us [0 pro] y_s += _n_emit(&yep, TAIL); // [pro key bus] - y_s += _n_emit(ops, SWAT); // [pro bus] + y_s += _n_emit(&yep, SWAT); // [pro bus] y_s += _n_emit(&yep, u3nc(SKIP, n_s)); tot_s += _n_emit(ops, u3nc(SKIN, y_s)); @@ -788,11 +814,11 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { } static c3_y* -_n_asm(u3_noun ops) +_n_asm(u3_noun ops, c3_s len_s) { u3_noun top = ops; - c3_s i_s = _n_comp(&ops, fol); - c3_y* buf_y = u3a_malloc(sizeof(c3_y) * (i_s+1)); + c3_y* buf_y = u3a_malloc(sizeof(c3_y) * (len_s+1)); + c3_s i_s = len_s; buf_y[i_s] = HALT; while ( --i_s >= 0 ) { @@ -889,7 +915,9 @@ _n_rean(c3_y* buf, c3_s* ip_s) static inline c3_y* _n_bite(u3_noun fol) { - return _n_asm(_n_comp(&bok, fol, c3y)); + u3_noun bok = u3_nul; + c3_s len_s = _n_comp(&bok, fol, c3y) + return _n_asm(bok, len_s); } static c3_y* @@ -907,9 +935,12 @@ _n_find(u3_noun fol) } } -static u3_noun +/* _n_burn(): run pog, subject is top of cap stack, return value on cap stack + */ +static void _n_burn(c3_y* pog) { + /* OPCODE TABLE */ static void* lab[] = { &&do_halt, &&do_copy, &&do_toss, &&do_swap, &&do_swat, @@ -921,11 +952,11 @@ _n_burn(c3_y* pog) &&do_deep, &&do_peep, &&do_bump, &&do_same, &&do_kick, &&do_tick, + &&do_wish, &&do_fast, &&do_cush, &&do_drop, &&do_pumo, &&do_gemo, - &&do_heck, &&do_slog, &&do_fast, + &&do_heck, &&do_slog, }; - #define BURN() goto *lab[pog[ip_s++]] c3_s sip_s, ip_s = 0; c3_y op; @@ -935,12 +966,11 @@ _n_burn(c3_y* pog) u3_noun x, o; u3p(void) empty = u3R->cap_p; + #define BURN() goto *lab[pog[ip_s++]] BURN(); while ( 1 ) { do_halt: - x = _n_pop(); - c3_assert( empty == u3R->cap_p ); - return x; + return; do_copy: top = _n_peek(); @@ -1031,7 +1061,7 @@ _n_burn(c3_y* pog) do_nock: gop = _n_find(_n_pop()); - _n_push(_n_burn(gop)); + _n_burn(gop); BURN(); do_noct: @@ -1079,9 +1109,9 @@ _n_burn(c3_y* pog) if ( u3_none == fol ) { return u3m_bail(c3__exit); } + *top = o; gop = _n_find(fol); - _n_push(o); - *top = _n_burn(gop); + _n_burn(gop); } BURN(); @@ -1103,6 +1133,38 @@ _n_burn(c3_y* pog) } BURN(); + do_fast: // top->[pro clu] + top = _n_peek(); + up = _n_peet(); + u3t_off(noc_o); + u3j_mine(*up, u3k(*top)); + u3t_on(noc_o); + *up = *top; + u3a_pop(sizeof(u3_noun)); + BURN(); + + do_wish: + top = _n_peek(); + up = _n_peet(); + u3t_off(noc_o); + x = u3m_soft_esc(*up, u3k(*top)); + u3t_on(noc_o); + + if ( c3n == u3du(x) ) { + return u3m_bail(u3nt(1, *top, 0)); + } + else if ( c3n == u3du(u3t(x)) ) { + // replace with proper error stack push + u3t_push(u3nc(c3__hunk, _n_mush(*top))); + return u3m_bail(c3__exit); + } + else { + u3z(*top); + *top = u3k(u3t(u3t(x))); + u3z(x); + BURN(); + } + do_cush: u3t_push(_n_pop()); BURN(); @@ -1136,15 +1198,5 @@ _n_burn(c3_y* pog) u3t_slog(_n_pop()); u3t_on(noc_o); BURN(); - - do_fast: // top->[pro clu] - top = _n_peek(); - up = _n_peet(); - u3t_off(noc_o); - u3j_mine(*up, u3k(*top)); - u3t_on(noc_o); - *up = *top; - u3a_pop(sizeof(u3_noun)); - BURN(); } } From 9610d598741a8c57876d36162559289ab5f9725a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 1 Feb 2018 09:04:47 -0800 Subject: [PATCH 006/221] cleanup, comments --- noun/nock.c | 166 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 105 insertions(+), 61 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index b690c3c18..dafc6c534 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -496,67 +496,51 @@ u3n_nock_an(u3_noun bus, u3_noun fol) return u3n_nock_et(gul, bus, fol); } -/* _n_mush_in(): see _n_mush(). -*/ -static u3_noun -_n_mush_in(u3_noun val) -{ - if ( c3n == u3du(val) ) { - return u3_nul; - } - else { - u3_noun h_val = u3h(val); - u3_noun ite; - - if ( c3n == u3ud(h_val) ) { - ite = u3nc(c3__leaf, u3_nul); - } else { - ite = u3nc(c3__leaf, u3qe_trip(h_val)); - } - return u3nc(ite, _n_mush_in(u3t(val))); - case c3_ - } - } -} - /* These must match the order in the section marked OPCODE TABLE */ -#define HALT 0 -#define COPY 1 -#define TOSS 2 -#define SWAP 3 -#define SWAT 4 -#define SKIP 5 -#define SKIN 6 -#define CONS 7 -#define SCON 8 -#define HEAD 9 -#define TAIL 10 -#define FRAG 11 -#define QUOT 12 -#define QUIP 13 -#define NOCK 14 -#define NOCT 15 -#define DEEP 16 -#define PEEP 17 -#define BUMP 18 -#define SAME 19 -#define KICK 20 -#define TICK 21 -#define WISH 22 -#define FAST 23 -#define CUSH 24 -#define DROP 25 -#define PUMO 26 -#define GEMO 27 -#define HECK 28 -#define SLOG 29 +#define HALT 0 // stop executing, leaving the product on the top of stack +#define COPY 1 // copy TOS, keep, and push it +#define TOSS 2 // throw away and lose TOS +#define SWAP 3 // exchange TOS with item underneat +#define SWAT 4 // toss item under TOS (under) +#define SKIP 5 // skip N (c3_s) instructions +#define SKIN 6 // pop loob, skip N if it is no, bail if not yes +#define CONS 7 // makes a cell of [under, TOS] +#define SCON 8 // makes a cell of [TOS, under] +#define HEAD 9 // replaces TOS with its head (old TOS lost) +#define TAIL 10 // as HEAD, but for the tail +#define FRAG 11 // as HEAD/TAIL, but with an arbitrary noun axis +#define QUOT 12 // toss TOS, push literal noun argument +#define QUIP 13 // as QUOT, but without the toss +#define NOCK 14 // *(under, TOS) +#define NOCT 15 // as NOCK, but in tail position +#define DEEP 16 // pop TOS and push isCell loob +#define PEEP 17 // as DEEP, but doesn't pop +#define BUMP 18 // increment TOS +#define SAME 19 // pop two items and push equality loob +#define KICK 20 // pull argument arm from TOS +#define TICK 21 // KICK, but in tail position +#define WISH 22 // ref is under, gof is TOS, u3m_soft_esc +#define FAST 23 // u3j_mine TOS +#define CUSH 24 // u3t_push TOS +#define DROP 25 // u3t_drop +#define PUMO 26 // saves memo from tos->[pro key] +#define GEMO 27 // pushes (unit pro) of u3z_save with key=TOS +#define HECK 28 // u3t_heck TOS +#define SLOG 29 // u3t_slog TOS +#define BAIL 30 // bail %exit +/* _n_apen(): emit the instructions contained in src to dst + */ static inline void _n_apen(u3_noun* dst, u3_noun src) { *dst = u3qb_weld(src, *dst); } +/* _n_emit(): emit a single instruction to ops, returning + * the size (in bytes) required to store that + * opcode. + */ static inline c3_y _n_emit(u3_noun *ops, u3_noun op) { @@ -581,6 +565,10 @@ _n_emit(u3_noun *ops, u3_noun op) static c3_s _n_comp(u3_noun*, u3_noun, c3_o); +/* _n_bint(): hint-processing helper for _n_comp. + * hif: hint-formula (first part of 10). RETAIN. + * nef: next-formula (second part of 10). RETAIN. + */ static c3_s _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) { @@ -693,7 +681,10 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) } } -/* fol is RETAINED */ +/* _n_comp(): emit instructions from fol to ops. + * tel_o indicates tail tail position. + * fol is RETAINED. + */ static c3_s _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { c3_s tot_s = 0; @@ -813,6 +804,8 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { return tot_s; } +/* _n_asm(): assemble an accumulated list of instructions (i.e. from _n_comp) + */ static c3_y* _n_asm(u3_noun ops, c3_s len_s) { @@ -861,6 +854,8 @@ _n_asm(u3_noun ops, c3_s len_s) return buf_y; } +/* _n_push(): push a noun onto the stack. RETAIN + */ static inline void _n_push(u3_noun a) { @@ -868,18 +863,24 @@ _n_push(u3_noun a) *p = a; } +/* _n_peet(): address of the top of stack + */ static inline u3_noun* _n_peek() { return (u3_noun*) u3a_peek(sizeof(u3_noun)); } +/* _n_peet(): address of the next-to-top of stack + */ static inline u3_noun* _n_peet() { return (u3_noun*) u3a_peek(sizeof(u3_noun) + sizeof(u3_noun)); } +/* _n_pop(): pop a noun from the cap stack + */ static inline u3_noun _n_pop() { @@ -888,12 +889,16 @@ _n_pop() return r; } +/* _n_toss(): pop and lose + */ static inline void _n_toss() { u3z(_n_pop()); } +/* _n_rean(): read a c3_s from the bytecode stream + */ static inline c3_s _n_resh(c3_y* buf, c3_s* ip_s) { @@ -902,6 +907,8 @@ _n_resh(c3_y* buf, c3_s* ip_s) return les | (mos << 8); } +/* _n_rean(): read a noun from the bytecode stream + */ static inline u3_noun _n_rean(c3_y* buf, c3_s* ip_s) { @@ -912,6 +919,8 @@ _n_rean(c3_y* buf, c3_s* ip_s) return one | (two << 8) | (tre << 16) | (qua << 24); } +/* _n_bite(): compile a nock formula to bytecode + */ static inline c3_y* _n_bite(u3_noun fol) { @@ -920,6 +929,8 @@ _n_bite(u3_noun fol) return _n_asm(bok, len_s); } +/* _n_find(): return bytecode for given formula. fol is RETAINED. + */ static c3_y* _n_find(u3_noun fol) { @@ -955,7 +966,7 @@ _n_burn(c3_y* pog) &&do_wish, &&do_fast, &&do_cush, &&do_drop, &&do_pumo, &&do_gemo, - &&do_heck, &&do_slog, + &&do_heck, &&do_slog, &&do_bail }; c3_s sip_s, ip_s = 0; @@ -964,7 +975,9 @@ _n_burn(c3_y* pog) u3_noun* top; u3_noun* up; u3_noun x, o; - u3p(void) empty = u3R->cap_p; + + // could save interpreter frames on cap instead of using c stack (ip_s + pog) + // XX: do this after the simpler version works #define BURN() goto *lab[pog[ip_s++]] BURN(); @@ -1060,13 +1073,17 @@ _n_burn(c3_y* pog) BURN(); do_nock: - gop = _n_find(_n_pop()); + o = _n_pop(); + gop = _n_find(o); _n_burn(gop); + u3z(o); BURN(); do_noct: - pog = _n_find(_n_pop()); + o = _n_pop(); + pog = _n_find(o); ip_s = 0; + u3z(o); BURN(); do_deep: @@ -1194,9 +1211,36 @@ _n_burn(c3_y* pog) BURN(); do_slog: - u3t_off(noc_o); - u3t_slog(_n_pop()); - u3t_on(noc_o); + x = _n_pop(); + if ( !(u3C.wag_w & u3o_quiet) ) { + u3t_off(noc_o); + u3t_slog(x); + u3t_on(noc_o); + } + else { + u3z(x); + } BURN(); + + do_bail: + return u3m_bail(c3__exit); } } + +/* _n_burn_on(): produce .*(bus fol) with bytecode interpreter + */ +static u3_noun +_n_burn_on(u3_noun bus, u3_noun fol) +{ + u3p(void) empty = u3R->cap_p; + c3_y* pog = _n_find(fol); + u3_noun r; + + u3z(fol); + _n_push(bus); + _n_burn(pog); + r = _n_pop(); + + c3_assert( empty == u3R->cap_p ); + return r; +} From 232d2cccf8d74addecc7aec9d1c8dc8abd4c76bb Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 1 Feb 2018 09:21:10 -0800 Subject: [PATCH 007/221] fixing compile errors and warnings --- include/noun/allocate.h | 4 +++ noun/nock.c | 57 +++++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 075b12d2f..2cab0bd0a 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -132,6 +132,10 @@ u3_noun das; // cold state } jed; + struct { // bytecode state + u3p(u3h_root) har_p; // formula->post of bytecode + } byc; + struct { // namespace u3_noun gul; // (list $+(* (unit (unit)))) now } ski; diff --git a/noun/nock.c b/noun/nock.c index dafc6c534..2b18148ee 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -505,7 +505,7 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SKIP 5 // skip N (c3_s) instructions #define SKIN 6 // pop loob, skip N if it is no, bail if not yes #define CONS 7 // makes a cell of [under, TOS] -#define SCON 8 // makes a cell of [TOS, under] +#define SNOC 8 // makes a cell of [TOS, under] #define HEAD 9 // replaces TOS with its head (old TOS lost) #define TAIL 10 // as HEAD, but for the tail #define FRAG 11 // as HEAD/TAIL, but with an arbitrary noun axis @@ -583,10 +583,10 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) switch ( zep ) { default: - tos += _n_emit(ops, COPY); - tos += _n_comp(ops, hod, c3n); - tos += _n_emit(ops, TOSS); - tos += _n_comp(ops, nef, tel_o); + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_emit(ops, TOSS); + tot_s += _n_comp(ops, nef, tel_o); break; case c3__hunk: @@ -617,7 +617,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) y_s += _n_emit(&yep, TOSS); y_s += _n_emit(&yep, u3nc(SKIP, n_s)); - tot_s += n_emit(ops, u3nc(SKIN, y_s)); + tot_s += _n_emit(ops, u3nc(SKIN, y_s)); _n_apen(ops, yep); tot_s += y_s; _n_apen(ops, nop); tot_s += n_s; @@ -653,7 +653,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) tot_s += _n_comp(ops, hod, c3n); // [clue bus bus] tot_s += _n_emit(ops, TOSS); // [bus bus] tot_s += _n_emit(ops, u3nc(QUIP, u3k(nef))); // [fol bus bus] - tot_s += _n_emit(ops, SCON); // [[bus fol] bus] + tot_s += _n_emit(ops, SNOC); // [[bus fol] bus] tot_s += _n_emit(ops, GEMO); // [u key bus] tot_s += _n_emit(ops, PEEP); // [b u key bus] @@ -669,7 +669,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) y_s += _n_emit(&yep, u3nc(SKIP, n_s)); tot_s += _n_emit(ops, u3nc(SKIN, y_s)); - _n_apen(ops, yup); tot_s += y_s; + _n_apen(ops, yep); tot_s += y_s; _n_apen(ops, nop); tot_s += n_s; // both branches leave an extra value under the top @@ -773,7 +773,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { u3x_cell(arg, &hed, &tel); tot_s += _n_emit(ops, COPY); tot_s += _n_comp(ops, hed, c3n); - tot_s += _n_emit(ops, SCON); + tot_s += _n_emit(ops, SNOC); tot_s += _n_comp(ops, tel, tel_o); break; case 9: @@ -814,7 +814,7 @@ _n_asm(u3_noun ops, c3_s len_s) c3_s i_s = len_s; buf_y[i_s] = HALT; - while ( --i_s >= 0 ) { + while ( i_s-- > 0 ) { u3_noun op = u3h(ops); if ( c3y == u3ud(op) ) { buf_y[i_s] = (c3_y) u3h(ops); @@ -824,7 +824,7 @@ _n_asm(u3_noun ops, c3_s len_s) switch ( cod ) { case SKIP: case SKIN: { - c3_s off_s = u3t(op); + c3_s off_s = u3t(op); buf_y[i_s--] = (c3_y) (off_s >> 8); buf_y[i_s--] = (c3_y) off_s; buf_y[i_s] = (c3_y) cod; @@ -835,7 +835,7 @@ _n_asm(u3_noun ops, c3_s len_s) case FRAG: case TICK: case KICK: { - c3_w non_w = u3t(op); + c3_w non_w = u3k(u3t(op)); buf_y[i_s--] = (c3_y) (non_w >> 24); buf_y[i_s--] = (c3_y) (non_w >> 16); buf_y[i_s--] = (c3_y) (non_w >> 8); @@ -850,7 +850,7 @@ _n_asm(u3_noun ops, c3_s len_s) ops = u3t(ops); } - u3z(ops); + u3z(top); return buf_y; } @@ -925,7 +925,7 @@ static inline c3_y* _n_bite(u3_noun fol) { u3_noun bok = u3_nul; - c3_s len_s = _n_comp(&bok, fol, c3y) + c3_s len_s = _n_comp(&bok, fol, c3y); return _n_asm(bok, len_s); } @@ -936,11 +936,11 @@ _n_find(u3_noun fol) { u3_noun got = u3h_get(u3R->byc.har_p, fol); if ( u3_none != got ) { - return u3a_to_ptr(got); + return u3a_into(got); } else { c3_y* gop = _n_bite(fol); - got = u3a_to_off(gop); + got = u3a_outa(gop); u3h_put(u3R->byc.har_p, fol, got); return gop; } @@ -970,7 +970,6 @@ _n_burn(c3_y* pog) }; c3_s sip_s, ip_s = 0; - c3_y op; c3_y* gop; u3_noun* top; u3_noun* up; @@ -1022,7 +1021,8 @@ _n_burn(c3_y* pog) ip_s += sip_s; } else if ( c3y != x ) { - return u3m_bail(c3__exit); + u3m_bail(c3__exit); + return; } BURN(); @@ -1042,7 +1042,8 @@ _n_burn(c3_y* pog) top = _n_peek(); o = *top; if ( c3n == u3du(o) ) { - return u3m_bail(c3__exit); + u3m_bail(c3__exit); + return; } *top = u3k(u3h(o)); u3z(o); @@ -1052,7 +1053,8 @@ _n_burn(c3_y* pog) top = _n_peek(); o = *top; if ( c3n == u3du(o) ) { - return u3m_bail(c3__exit); + u3m_bail(c3__exit); + return; } *top = u3k(u3t(o)); u3z(o); @@ -1124,7 +1126,8 @@ _n_burn(c3_y* pog) if ( u3_none == *top ) { u3_noun fol = u3r_at(x, o); if ( u3_none == fol ) { - return u3m_bail(c3__exit); + u3m_bail(c3__exit); + return; } *top = o; gop = _n_find(fol); @@ -1142,7 +1145,8 @@ _n_burn(c3_y* pog) if ( u3_none == *top ) { u3_noun fol = u3r_at(x, o); if ( u3_none == fol ) { - return u3m_bail(c3__exit); + u3m_bail(c3__exit); + return; } *top = o; pog = _n_find(fol); @@ -1168,12 +1172,14 @@ _n_burn(c3_y* pog) u3t_on(noc_o); if ( c3n == u3du(x) ) { - return u3m_bail(u3nt(1, *top, 0)); + u3m_bail(u3nt(1, *top, 0)); + return; } else if ( c3n == u3du(u3t(x)) ) { // replace with proper error stack push u3t_push(u3nc(c3__hunk, _n_mush(*top))); - return u3m_bail(c3__exit); + u3m_bail(c3__exit); + return; } else { u3z(*top); @@ -1223,7 +1229,8 @@ _n_burn(c3_y* pog) BURN(); do_bail: - return u3m_bail(c3__exit); + u3m_bail(c3__exit); + return; } } From 17a166fa83d65bf60318a3b1d9d5a3d84b114d86 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 2 Feb 2018 15:28:07 -0800 Subject: [PATCH 008/221] bytecode interpreter can run nock decrement --- include/noun/nock.h | 5 +++ noun/nock.c | 104 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 102 insertions(+), 7 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 2234778d9..13ed0b4c5 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -9,6 +9,11 @@ u3_noun u3n_nock_on(u3_noun bus, u3_noun fol); + /* u3n_burn_on(): TEMPORARY: produce .*(bus fol) with bytecode interpreter. + */ + u3_noun + u3n_burn_on(u3_noun bus, u3_noun fol); + /* u3n_slam_on(): produce (gat sam). */ u3_noun diff --git a/noun/nock.c b/noun/nock.c index 2b18148ee..8d693fd29 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -729,7 +729,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { tot_s += _n_comp(ops, hed, c3n); tot_s += _n_emit(ops, SWAP); tot_s += _n_comp(ops, tel, c3n); - tot_s += _n_emit(ops, (tel_o ? NOCT : NOCK)); + tot_s += _n_emit(ops, ((c3y == tel_o)? NOCT : NOCK)); break; case 3: tot_s += _n_comp(ops, arg, c3n); @@ -751,6 +751,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { u3_noun mid; u3x_trel(arg, &hed, &mid, &tel); + tot_s += _n_emit(ops, COPY); tot_s += _n_comp(ops, hed, c3n); u3_noun yep = u3_nul, @@ -785,7 +786,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { } else { tot_s += _n_comp(ops, tel, c3n); - tot_s += _n_emit(ops, u3nc((tel_o ? TICK : KICK), u3k(hed))); + tot_s += _n_emit(ops, u3nc((c3y == tel_o) ? TICK : KICK, u3k(hed))); } break; case 10: @@ -804,6 +805,8 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { return tot_s; } +static void _n_print_byc(c3_y* pog); + /* _n_asm(): assemble an accumulated list of instructions (i.e. from _n_comp) */ static c3_y* @@ -863,7 +866,7 @@ _n_push(u3_noun a) *p = a; } -/* _n_peet(): address of the top of stack +/* _n_peek(): address of the top of stack */ static inline u3_noun* _n_peek() @@ -876,7 +879,7 @@ _n_peek() static inline u3_noun* _n_peet() { - return (u3_noun*) u3a_peek(sizeof(u3_noun) + sizeof(u3_noun)); + return u3to(u3_noun, u3R->cap_p + (_(u3a_is_north(u3R)) ? 1 : -2)); } /* _n_pop(): pop a noun from the cap stack @@ -926,7 +929,8 @@ _n_bite(u3_noun fol) { u3_noun bok = u3_nul; c3_s len_s = _n_comp(&bok, fol, c3y); - return _n_asm(bok, len_s); + c3_y* buf_y = _n_asm(bok, len_s); + return buf_y; } /* _n_find(): return bytecode for given formula. fol is RETAINED. @@ -956,7 +960,7 @@ _n_burn(c3_y* pog) &&do_halt, &&do_copy, &&do_toss, &&do_swap, &&do_swat, &&do_skip, &&do_skin, - &&do_cons, &&do_scon, + &&do_cons, &&do_snoc, &&do_head, &&do_tail, &&do_frag, &&do_quot, &&do_quip, &&do_nock, &&do_noct, @@ -1032,7 +1036,7 @@ _n_burn(c3_y* pog) *top = u3nc(*top, x); BURN(); - do_scon: + do_snoc: x = _n_pop(); top = _n_peek(); *top = u3nc(x, *top); @@ -1234,6 +1238,82 @@ _n_burn(c3_y* pog) } } +static void +_n_print_byc(c3_y* pog) +{ + static char* names[] = { + "halt", "copy", "toss", + "swap", "swat", + "skip", "skin", + "cons", "snoc", + "head", "tail", "frag", + "quot", "quip", + "nock", "noct", + "deep", "peep", + "bump", "same", + "kick", "tick", + "wish", "fast", + "cush", "drop", + "pumo", "gemo", + "heck", "slog", "bail" + }; + c3_s ip_s = 0; + printf("bytecode: {"); + int first = 1; + while ( pog[ip_s] ) { + if ( first ) { + first = 0; + } + else { + printf(" "); + } + switch ( pog[ip_s] ) { + default: + printf("%s", names[pog[ip_s++]]); + break; + + case SKIP: + case SKIN: + printf("[%s ", names[pog[ip_s++]]); + printf("%d]", _n_resh(pog, &ip_s)); + break; + + case QUOT: + case QUIP: + case FRAG: + case TICK: + case KICK: + printf("[%s ", names[pog[ip_s++]]); + printf("%d]", _n_rean(pog, &ip_s)); + break; + } + } + printf(" halt}\r\n"); +} + +static void _n_print_stack(u3p(u3_noun) empty) { + c3_w cur_p = u3R->cap_p; + printf("["); + int first = 1; + while ( cur_p != empty ) { + if ( first ) { + first = 0; + } + else { + printf(" "); + } + if ( c3y == u3a_is_north(u3R) ) { + printf("%d", *(u3to(u3_noun, cur_p))); + cur_p++; + } + else { + printf("%d", *(u3to(u3_noun, cur_p-1))); + cur_p--; + } + } + printf("]\r\n"); +} + /* _n_burn_on(): produce .*(bus fol) with bytecode interpreter */ static u3_noun @@ -1251,3 +1331,13 @@ _n_burn_on(u3_noun bus, u3_noun fol) c3_assert( empty == u3R->cap_p ); return r; } + +u3_noun +u3n_burn_on(u3_noun bus, u3_noun fol) +{ + u3_noun pro; + u3t_on(noc_o); + pro = _n_burn_on(bus, fol); + u3t_off(noc_o); + return pro; +} From 389261be10a671d23f2889111d4a3d1c0ee85c21 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 5 Feb 2018 10:27:39 -0800 Subject: [PATCH 009/221] try compiling away all fragment axes --- include/noun/nock.h | 4 ++ noun/manage.c | 4 ++ noun/nock.c | 109 +++++++++++++++++++++++++++++++------------- 3 files changed, 85 insertions(+), 32 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 13ed0b4c5..c1b30515a 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -58,3 +58,7 @@ */ u3_noun u3n_nock_an(u3_noun bus, u3_noun fol); + + /* u3n_beep(): promote bytecode state. + */ + void u3n_beep(u3p(u3h_root) har_p); diff --git a/noun/manage.c b/noun/manage.c index 6834d270c..c73781544 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -459,6 +459,7 @@ _pave_parts(void) { u3R->cax.har_p = u3h_new(); u3R->jed.har_p = u3h_new(); + u3R->byc.har_p = u3h_new(); u3R->jed.das = u3_nul; } @@ -469,6 +470,7 @@ u3m_mark(void) { c3_w tot_w = 0; tot_w += u3h_mark(u3R->jed.har_p); + tot_w += u3h_mark(u3R->byc.har_p); tot_w += u3a_mark_noun(u3R->jed.das); tot_w += u3a_mark_noun(u3R->ski.gul); tot_w += u3a_mark_noun(u3R->bug.tax); @@ -508,6 +510,7 @@ u3m_clear(void) { u3h_free(u3R->cax.har_p); u3h_free(u3R->jed.har_p); + u3h_free(u3R->byc.har_p); u3a_lose(u3R->jed.das); } @@ -802,6 +805,7 @@ u3m_love(u3_noun pro) pro = u3a_take(pro); u3j_reap(das, har_p); + u3n_beep(u3R->byc.har_p); u3R->cap_p = u3R->ear_p; u3R->ear_p = 0; diff --git a/noun/nock.c b/noun/nock.c index 8d693fd29..f449bc58f 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -508,26 +508,29 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SNOC 8 // makes a cell of [TOS, under] #define HEAD 9 // replaces TOS with its head (old TOS lost) #define TAIL 10 // as HEAD, but for the tail -#define FRAG 11 // as HEAD/TAIL, but with an arbitrary noun axis -#define QUOT 12 // toss TOS, push literal noun argument -#define QUIP 13 // as QUOT, but without the toss -#define NOCK 14 // *(under, TOS) -#define NOCT 15 // as NOCK, but in tail position -#define DEEP 16 // pop TOS and push isCell loob -#define PEEP 17 // as DEEP, but doesn't pop -#define BUMP 18 // increment TOS -#define SAME 19 // pop two items and push equality loob -#define KICK 20 // pull argument arm from TOS -#define TICK 21 // KICK, but in tail position -#define WISH 22 // ref is under, gof is TOS, u3m_soft_esc -#define FAST 23 // u3j_mine TOS -#define CUSH 24 // u3t_push TOS -#define DROP 25 // u3t_drop -#define PUMO 26 // saves memo from tos->[pro key] -#define GEMO 27 // pushes (unit pro) of u3z_save with key=TOS -#define HECK 28 // u3t_heck TOS -#define SLOG 29 // u3t_slog TOS -#define BAIL 30 // bail %exit +#define STAG 11 // copy tos w/o keep to prepare for hear/tair fragment +#define HART 12 // keep tos and swat +#define HEAR 13 // take head of TOS, no keep/loss +#define TAIR 14 // take tail of TOS, no keep/loss +#define QUOT 15 // toss TOS, push literal noun argument +#define QUIP 16 // as QUOT, but without the toss +#define NOCK 17 // *(under, TOS) +#define NOCT 18 // as NOCK, but in tail position +#define DEEP 19 // pop TOS and push isCell loob +#define PEEP 20 // as DEEP, but doesn't pop +#define BUMP 21 // increment TOS +#define SAME 22 // pop two items and push equality loob +#define KICK 23 // pull argument arm from TOS +#define TICK 24 // KICK, but in tail position +#define WISH 25 // ref is under, gof is TOS, u3m_soft_esc +#define FAST 26 // u3j_mine TOS +#define CUSH 27 // u3t_push TOS +#define DROP 28 // u3t_drop +#define PUMO 29 // saves memo from tos->[pro key] +#define GEMO 30 // pushes (unit pro) of u3z_save with key=TOS +#define HECK 31 // u3t_heck TOS +#define SLOG 32 // u3t_slog TOS +#define BAIL 33 // bail %exit /* _n_apen(): emit the instructions contained in src to dst */ @@ -554,7 +557,6 @@ _n_emit(u3_noun *ops, u3_noun op) return sizeof(c3_y) + sizeof(c3_s); case QUOT: case QUIP: - case FRAG: case TICK: case KICK: return sizeof(c3_y) + sizeof(u3_noun); @@ -715,8 +717,16 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { case 3: tot_s += _n_emit(ops, TAIL); break; - default: - tot_s += _n_emit(ops, u3nc(FRAG, u3k(arg))); + default: { + u3_noun a; + tot_s += _n_emit(ops, STAG); + for ( a = u3k(arg); a > 1; u3z(a), a = u3qc_mas(a) ) { + tot_s += _n_emit(ops, 2 == u3qc_cap(a) ? HEAR : TAIR); + } + u3z(a); + tot_s += _n_emit(ops, HART); + break; + } } break; case 1: { @@ -835,7 +845,6 @@ _n_asm(u3_noun ops, c3_s len_s) } case QUOT: case QUIP: - case FRAG: case TICK: case KICK: { c3_w non_w = u3k(u3t(op)); @@ -930,6 +939,7 @@ _n_bite(u3_noun fol) u3_noun bok = u3_nul; c3_s len_s = _n_comp(&bok, fol, c3y); c3_y* buf_y = _n_asm(bok, len_s); + _n_print_byc(buf_y); return buf_y; } @@ -961,7 +971,9 @@ _n_burn(c3_y* pog) &&do_swap, &&do_swat, &&do_skip, &&do_skin, &&do_cons, &&do_snoc, - &&do_head, &&do_tail, &&do_frag, + &&do_head, &&do_tail, + &&do_stag, &&do_hart, + &&do_hear, &&do_tair, &&do_quot, &&do_quip, &&do_nock, &&do_noct, &&do_deep, &&do_peep, @@ -1064,14 +1076,38 @@ _n_burn(c3_y* pog) u3z(o); BURN(); - do_frag: - top = _n_peek(); - o = *top; - x = u3x_at(_n_rean(pog, &ip_s), o); - *top = u3k(x); + do_stag: + _n_push(*(_n_peek())); + BURN(); + + do_hart: + top = _n_peek(); + up = _n_peet(); + o = *up; + *up = u3k(_n_pop()); u3z(o); BURN(); + do_hear: + top = _n_peek(); + o = *top; + if ( c3n == u3du(o) ) { + u3m_bail(c3__exit); + return; + } + *top = u3h(o); + BURN(); + + do_tair: + top = _n_peek(); + o = *top; + if ( c3n == u3du(o) ) { + u3m_bail(c3__exit); + return; + } + *top = u3t(o); + BURN(); + do_quot: _n_toss(); do_quip: @@ -1246,7 +1282,9 @@ _n_print_byc(c3_y* pog) "swap", "swat", "skip", "skin", "cons", "snoc", - "head", "tail", "frag", + "head", "tail", + "stag", "hart", + "hear", "tair", "quot", "quip", "nock", "noct", "deep", "peep", @@ -1280,7 +1318,6 @@ _n_print_byc(c3_y* pog) case QUOT: case QUIP: - case FRAG: case TICK: case KICK: printf("[%s ", names[pog[ip_s++]]); @@ -1341,3 +1378,11 @@ u3n_burn_on(u3_noun bus, u3_noun fol) u3t_off(noc_o); return pro; } + +/* u3n_beep(): promote bytecode state. +*/ +void +u3n_beep(u3p(u3h_root) har_p) +{ + u3m_p("beep", 0); +} From a8b4012f15e63f0f3d286df8f5196d077ef9de41 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 5 Feb 2018 11:20:34 -0800 Subject: [PATCH 010/221] byte versions of frag/kick --- noun/nock.c | 177 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 70 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index f449bc58f..8d4371e26 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -508,29 +508,32 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SNOC 8 // makes a cell of [TOS, under] #define HEAD 9 // replaces TOS with its head (old TOS lost) #define TAIL 10 // as HEAD, but for the tail -#define STAG 11 // copy tos w/o keep to prepare for hear/tair fragment -#define HART 12 // keep tos and swat -#define HEAR 13 // take head of TOS, no keep/loss -#define TAIR 14 // take tail of TOS, no keep/loss -#define QUOT 15 // toss TOS, push literal noun argument -#define QUIP 16 // as QUOT, but without the toss -#define NOCK 17 // *(under, TOS) -#define NOCT 18 // as NOCK, but in tail position -#define DEEP 19 // pop TOS and push isCell loob -#define PEEP 20 // as DEEP, but doesn't pop -#define BUMP 21 // increment TOS -#define SAME 22 // pop two items and push equality loob -#define KICK 23 // pull argument arm from TOS -#define TICK 24 // KICK, but in tail position -#define WISH 25 // ref is under, gof is TOS, u3m_soft_esc -#define FAST 26 // u3j_mine TOS -#define CUSH 27 // u3t_push TOS -#define DROP 28 // u3t_drop -#define PUMO 29 // saves memo from tos->[pro key] -#define GEMO 30 // pushes (unit pro) of u3z_save with key=TOS -#define HECK 31 // u3t_heck TOS -#define SLOG 32 // u3t_slog TOS -#define BAIL 33 // bail %exit +#define FRAG 11 // as HEAD/TAIL but with arbitrary noun axis +#define FRAS 12 // frag with short +#define FRAB 13 // frag with byte axis +#define QUOT 14 // toss TOS, push literal noun argument +#define QUIP 15 // as QUOT, but without the toss +#define NOCK 16 // *(under, TOS) +#define NOCT 17 // as NOCK, but in tail position +#define DEEP 18 // pop TOS and push isCell loob +#define PEEP 19 // as DEEP, but doesn't pop +#define BUMP 20 // increment TOS +#define SAME 21 // pop two items and push equality loob +#define KICK 22 // pull noun axis from TOS +#define KICS 23 // kick with short axis +#define KICB 24 // kick with byte axis +#define TICK 25 // KICK, but in tail position +#define TICS 26 // tick with short axis +#define TICB 27 // tick with byte axis +#define WISH 28 // ref is under, gof is TOS, u3m_soft_esc +#define FAST 29 // u3j_mine TOS +#define CUSH 30 // u3t_push TOS +#define DROP 31 // u3t_drop +#define PUMO 32 // saves memo from tos->[pro key] +#define GEMO 33 // pushes (unit pro) of u3z_save with key=TOS +#define HECK 34 // u3t_heck TOS +#define SLOG 35 // u3t_slog TOS +#define BAIL 36 // bail %exit /* _n_apen(): emit the instructions contained in src to dst */ @@ -552,9 +555,19 @@ _n_emit(u3_noun *ops, u3_noun op) return sizeof(c3_y); } else switch ( u3h(op) ) { + case KICB: + case TICB: + case FRAB: + return sizeof(c3_y) + sizeof(c3_y); + + case KICS: + case TICS: + case FRAS: case SKIP: case SKIN: return sizeof(c3_y) + sizeof(c3_s); + + case FRAG: case QUOT: case QUIP: case TICK: @@ -717,16 +730,11 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { case 3: tot_s += _n_emit(ops, TAIL); break; - default: { - u3_noun a; - tot_s += _n_emit(ops, STAG); - for ( a = u3k(arg); a > 1; u3z(a), a = u3qc_mas(a) ) { - tot_s += _n_emit(ops, 2 == u3qc_cap(a) ? HEAR : TAIR); - } - u3z(a); - tot_s += _n_emit(ops, HART); + default: + tot_s += _n_emit(ops, u3nc( + (arg < 0xFF ? FRAB : arg < 0xFFFF ? FRAS : FRAG), + arg)); break; - } } break; case 1: { @@ -796,7 +804,11 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { } else { tot_s += _n_comp(ops, tel, c3n); - tot_s += _n_emit(ops, u3nc((c3y == tel_o) ? TICK : KICK, u3k(hed))); + tot_s += _n_emit(ops, u3nc( + (c3y == tel_o) + ? (hed < 0xFF ? TICB : hed < 0xFFFF ? TICS : TICK) + : (hed < 0xFF ? KICB : hed < 0xFFFF ? KICS : KICK), + u3k(hed))); } break; case 10: @@ -835,6 +847,16 @@ _n_asm(u3_noun ops, c3_s len_s) else { u3_noun cod = u3h(op); switch ( cod ) { + case KICB: + case TICB: + case FRAB: + buf_y[i_s--] = (c3_y) u3t(op); + buf_y[i_s] = (c3_y) cod; + break; + + case KICS: + case TICS: + case FRAS: case SKIP: case SKIN: { c3_s off_s = u3t(op); @@ -843,6 +865,7 @@ _n_asm(u3_noun ops, c3_s len_s) buf_y[i_s] = (c3_y) cod; break; } + case FRAG: case QUOT: case QUIP: case TICK: @@ -972,13 +995,13 @@ _n_burn(c3_y* pog) &&do_skip, &&do_skin, &&do_cons, &&do_snoc, &&do_head, &&do_tail, - &&do_stag, &&do_hart, - &&do_hear, &&do_tair, + &&do_frag, &&do_fras, &&do_frab, &&do_quot, &&do_quip, &&do_nock, &&do_noct, &&do_deep, &&do_peep, &&do_bump, &&do_same, - &&do_kick, &&do_tick, + &&do_kick, &&do_kics, &&do_kicb, + &&do_tick, &&do_tics, &&do_ticb, &&do_wish, &&do_fast, &&do_cush, &&do_drop, &&do_pumo, &&do_gemo, @@ -1076,38 +1099,23 @@ _n_burn(c3_y* pog) u3z(o); BURN(); - do_stag: - _n_push(*(_n_peek())); - BURN(); - - do_hart: - top = _n_peek(); - up = _n_peet(); - o = *up; - *up = u3k(_n_pop()); + do_fras: + x = _n_resh(pog, &ip_s); + goto frag_in; + + do_frag: + x = _n_rean(pog, &ip_s); + goto frag_in; + + do_frab: + x = pog[ip_s++]; + frag_in: + top = _n_peek(); + o = *top; + *top = u3k(u3r_at(x, o)); u3z(o); BURN(); - do_hear: - top = _n_peek(); - o = *top; - if ( c3n == u3du(o) ) { - u3m_bail(c3__exit); - return; - } - *top = u3h(o); - BURN(); - - do_tair: - top = _n_peek(); - o = *top; - if ( c3n == u3du(o) ) { - u3m_bail(c3__exit); - return; - } - *top = u3t(o); - BURN(); - do_quot: _n_toss(); do_quip: @@ -1156,8 +1164,17 @@ _n_burn(c3_y* pog) u3z(o); BURN(); + do_kics: + x = _n_resh(pog, &ip_s); + goto kick_in; + do_kick: - x = _n_rean(pog, &ip_s); + x = _n_rean(pog, &ip_s); + goto kick_in; + + do_kicb: + x = pog[ip_s++]; + kick_in: top = _n_peek(); o = *top; u3t_off(noc_o); @@ -1175,8 +1192,17 @@ _n_burn(c3_y* pog) } BURN(); + do_tics: + x = _n_resh(pog, &ip_s); + goto tick_in; + do_tick: - x = _n_rean(pog, &ip_s); + x = _n_rean(pog, &ip_s); + goto tick_in; + + do_ticb: + x = pog[ip_s++]; + tick_in: top = _n_peek(); o = *top; u3t_off(noc_o); @@ -1283,13 +1309,13 @@ _n_print_byc(c3_y* pog) "skip", "skin", "cons", "snoc", "head", "tail", - "stag", "hart", - "hear", "tair", + "frag", "fras", "frab", "quot", "quip", "nock", "noct", "deep", "peep", "bump", "same", - "kick", "tick", + "kick", "kics", "kicb", + "tick", "tics", "ticb", "wish", "fast", "cush", "drop", "pumo", "gemo", @@ -1310,6 +1336,16 @@ _n_print_byc(c3_y* pog) printf("%s", names[pog[ip_s++]]); break; + case KICB: + case TICB: + case FRAB: + printf("[%s ", names[pog[ip_s++]]); + printf("%d]", pog[ip_s++]); + break; + + case KICS: + case TICS: + case FRAS: case SKIP: case SKIN: printf("[%s ", names[pog[ip_s++]]); @@ -1319,6 +1355,7 @@ _n_print_byc(c3_y* pog) case QUOT: case QUIP: case TICK: + case FRAG: case KICK: printf("[%s ", names[pog[ip_s++]]); printf("%d]", _n_rean(pog, &ip_s)); From d50f36bd5155204213f47e0b02917ad2573f9d2f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 5 Feb 2018 13:34:11 -0800 Subject: [PATCH 011/221] byte version of skip, optimized stack ops --- noun/nock.c | 251 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 157 insertions(+), 94 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 8d4371e26..08fa43361 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -504,36 +504,38 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SWAT 4 // toss item under TOS (under) #define SKIP 5 // skip N (c3_s) instructions #define SKIN 6 // pop loob, skip N if it is no, bail if not yes -#define CONS 7 // makes a cell of [under, TOS] -#define SNOC 8 // makes a cell of [TOS, under] -#define HEAD 9 // replaces TOS with its head (old TOS lost) -#define TAIL 10 // as HEAD, but for the tail -#define FRAG 11 // as HEAD/TAIL but with arbitrary noun axis -#define FRAS 12 // frag with short -#define FRAB 13 // frag with byte axis -#define QUOT 14 // toss TOS, push literal noun argument -#define QUIP 15 // as QUOT, but without the toss -#define NOCK 16 // *(under, TOS) -#define NOCT 17 // as NOCK, but in tail position -#define DEEP 18 // pop TOS and push isCell loob -#define PEEP 19 // as DEEP, but doesn't pop -#define BUMP 20 // increment TOS -#define SAME 21 // pop two items and push equality loob -#define KICK 22 // pull noun axis from TOS -#define KICS 23 // kick with short axis -#define KICB 24 // kick with byte axis -#define TICK 25 // KICK, but in tail position -#define TICS 26 // tick with short axis -#define TICB 27 // tick with byte axis -#define WISH 28 // ref is under, gof is TOS, u3m_soft_esc -#define FAST 29 // u3j_mine TOS -#define CUSH 30 // u3t_push TOS -#define DROP 31 // u3t_drop -#define PUMO 32 // saves memo from tos->[pro key] -#define GEMO 33 // pushes (unit pro) of u3z_save with key=TOS -#define HECK 34 // u3t_heck TOS -#define SLOG 35 // u3t_slog TOS -#define BAIL 36 // bail %exit +#define SBIP 7 // skip with byte argument +#define SBIN 8 // skin with byte argument +#define CONS 9 // makes a cell of [under, TOS] +#define SNOC 10 // makes a cell of [TOS, under] +#define HEAD 11 // replaces TOS with its head (old TOS lost) +#define TAIL 12 // as HEAD, but for the tail +#define FRAG 13 // as HEAD/TAIL but with arbitrary noun axis +#define FRAS 14 // frag with short +#define FRAB 15 // frag with byte axis +#define QUOT 16 // toss TOS, push literal noun argument +#define QUIP 17 // as QUOT, but without the toss +#define NOCK 18 // *(under, TOS) +#define NOCT 19 // as NOCK, but in tail position +#define DEEP 20 // pop TOS and push isCell loob +#define PEEP 21 // as DEEP, but doesn't pop +#define BUMP 22 // increment TOS +#define SAME 23 // pop two items and push equality loob +#define KICK 24 // pull noun axis from TOS +#define KICS 25 // kick with short axis +#define KICB 26 // kick with byte axis +#define TICK 27 // KICK, but in tail position +#define TICS 28 // tick with short axis +#define TICB 29 // tick with byte axis +#define WISH 30 // ref is under, gof is TOS, u3m_soft_esc +#define FAST 31 // u3j_mine TOS +#define CUSH 32 // u3t_push TOS +#define DROP 33 // u3t_drop +#define PUMO 34 // saves memo from tos->[pro key] +#define GEMO 35 // pushes (unit pro) of u3z_save with key=TOS +#define HECK 36 // u3t_heck TOS +#define SLOG 37 // u3t_slog TOS +#define BAIL 37 // bail %exit /* _n_apen(): emit the instructions contained in src to dst */ @@ -555,6 +557,8 @@ _n_emit(u3_noun *ops, u3_noun op) return sizeof(c3_y); } else switch ( u3h(op) ) { + case SBIP: + case SBIN: case KICB: case TICB: case FRAB: @@ -580,6 +584,18 @@ _n_emit(u3_noun *ops, u3_noun op) static c3_s _n_comp(u3_noun*, u3_noun, c3_o); +static inline u3_noun +_n_skip(c3_s len_s) +{ + return u3nc((len_s < 0xFF ? SBIP : SKIP), len_s); +} + +static inline u3_noun +_n_skin(c3_s len_s) +{ + return u3nc((len_s < 0xFF ? SBIN : SKIN), len_s); +} + /* _n_bint(): hint-processing helper for _n_comp. * hif: hint-formula (first part of 10). RETAIN. * nef: next-formula (second part of 10). RETAIN. @@ -630,9 +646,9 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) n_s += _n_emit(&nop, HECK); y_s += _n_emit(&yep, TOSS); - y_s += _n_emit(&yep, u3nc(SKIP, n_s)); + y_s += _n_emit(&yep, _n_skip(n_s)); - tot_s += _n_emit(ops, u3nc(SKIN, y_s)); + tot_s += _n_emit(ops, _n_skin(y_s)); _n_apen(ops, yep); tot_s += y_s; _n_apen(ops, nop); tot_s += n_s; @@ -681,9 +697,9 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) // YES branch, i.e. gemo gave us [0 pro] y_s += _n_emit(&yep, TAIL); // [pro key bus] y_s += _n_emit(&yep, SWAT); // [pro bus] - y_s += _n_emit(&yep, u3nc(SKIP, n_s)); + y_s += _n_emit(&yep, _n_skip(n_s)); - tot_s += _n_emit(ops, u3nc(SKIN, y_s)); + tot_s += _n_emit(ops, _n_skin(y_s)); _n_apen(ops, yep); tot_s += y_s; _n_apen(ops, nop); tot_s += n_s; @@ -777,8 +793,8 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { c3_s y_s = _n_comp(&yep, mid, tel_o), n_s = _n_comp(&nop, tel, tel_o); - y_s += _n_emit(&yep, u3nc(SKIP, n_s)); - tot_s += _n_emit(ops, u3nc(SKIN, y_s)); + y_s += _n_emit(&yep, _n_skip(n_s)); + tot_s += _n_emit(ops, _n_skin(y_s)); _n_apen(ops, yep); tot_s += y_s; _n_apen(ops, nop); tot_s += n_s; break; @@ -847,6 +863,8 @@ _n_asm(u3_noun ops, c3_s len_s) else { u3_noun cod = u3h(op); switch ( cod ) { + case SBIP: + case SBIN: case KICB: case TICB: case FRAB: @@ -890,46 +908,66 @@ _n_asm(u3_noun ops, c3_s len_s) } /* _n_push(): push a noun onto the stack. RETAIN + * mov: -1 north, 1 south + * off: 0 north, -1 south */ static inline void -_n_push(u3_noun a) +_n_push(c3_ys mov, c3_ys off, u3_noun a) { - u3_noun* p = (u3_noun*) u3a_push(sizeof(u3_noun)); + u3R->cap_p += mov; + u3_noun* p = u3to(u3_noun, u3R->cap_p + off); + //u3_noun* p = (u3_noun*) u3a_push(sizeof(u3_noun)); *p = a; } -/* _n_peek(): address of the top of stack +/* _n_peek(): pointer to noun at top of stack + * off: 0 north, -1 south */ static inline u3_noun* -_n_peek() +_n_peek(c3_ys off) { - return (u3_noun*) u3a_peek(sizeof(u3_noun)); + return u3to(u3_noun, u3R->cap_p + off); + //return (u3_noun*) u3a_peek(sizeof(u3_noun)); } /* _n_peet(): address of the next-to-top of stack + * mov: -1 north, 1 south + * off: 0 north, -1 south */ static inline u3_noun* -_n_peet() +_n_peet(c3_ys mov, c3_ys off) { - return u3to(u3_noun, u3R->cap_p + (_(u3a_is_north(u3R)) ? 1 : -2)); + return u3to(u3_noun, (u3R->cap_p - mov) + off); +// return u3to(u3_noun, u3R->cap_p + (_(u3a_is_north(u3R)) ? 1 : -2)); } /* _n_pop(): pop a noun from the cap stack + * mov: -1 north, 1 south + */ +static inline void +_n_pop(c3_ys mov) +{ + u3R->cap_p -= mov; +} + +/* _n_pep(): pop and return noun from the cap stack + * mov: -1 north, 1 south + * off: 0 north, -1 south */ static inline u3_noun -_n_pop() +_n_pep(c3_ys mov, c3_ys off) { - u3_noun r = *(_n_peek()); - u3a_pop(sizeof(u3_noun)); + u3_noun r = *(_n_peek(off)); + _n_pop(mov); return r; } -/* _n_toss(): pop and lose +/* _n_toss(): pep and lose */ static inline void -_n_toss() +_n_toss(c3_ys mov, c3_ys off) { - u3z(_n_pop()); + u3z(_n_pep(mov, off)); } /* _n_rean(): read a c3_s from the bytecode stream @@ -984,15 +1022,18 @@ _n_find(u3_noun fol) } /* _n_burn(): run pog, subject is top of cap stack, return value on cap stack + * mov: -1 north, 1 south + * off: 0 north, -1 south */ static void -_n_burn(c3_y* pog) +_n_burn(c3_y* pog, c3_ys mov, c3_ys off) { /* OPCODE TABLE */ static void* lab[] = { &&do_halt, &&do_copy, &&do_toss, &&do_swap, &&do_swat, &&do_skip, &&do_skin, + &&do_sbip, &&do_sbin, &&do_cons, &&do_snoc, &&do_head, &&do_tail, &&do_frag, &&do_fras, &&do_frab, @@ -1024,38 +1065,47 @@ _n_burn(c3_y* pog) return; do_copy: - top = _n_peek(); - _n_push(u3k(*top)); + top = _n_peek(off); + _n_push(mov, off, u3k(*top)); BURN(); do_toss: - _n_toss(); + _n_toss(mov, off); BURN(); do_swap: - top = _n_peek(); - up = _n_peet(); + top = _n_peek(off); + up = _n_peet(mov, off); x = *top; *top = *up; *up = x; BURN(); do_swat: - top = _n_peek(); - up = _n_peet(); + top = _n_peek(off); + up = _n_peet(mov, off); x = *top; *top = *up; *up = x; - _n_toss(); + _n_toss(mov, off); BURN(); do_skip: ip_s += _n_resh(pog, &ip_s); BURN(); + do_sbip: + ip_s += pog[ip_s] + 1; + BURN(); + do_skin: sip_s = _n_resh(pog, &ip_s); - x = _n_pop(); + goto skin_in; + + do_sbin: + sip_s = pog[ip_s++]; + skin_in: + x = _n_pep(mov, off); if ( c3n == x ) { ip_s += sip_s; } @@ -1066,19 +1116,19 @@ _n_burn(c3_y* pog) BURN(); do_cons: - x = _n_pop(); - top = _n_peek(); + x = _n_pep(mov, off); + top = _n_peek(off); *top = u3nc(*top, x); BURN(); do_snoc: - x = _n_pop(); - top = _n_peek(); + x = _n_pep(mov, off); + top = _n_peek(off); *top = u3nc(x, *top); BURN(); do_head: - top = _n_peek(); + top = _n_peek(off); o = *top; if ( c3n == u3du(o) ) { u3m_bail(c3__exit); @@ -1089,7 +1139,7 @@ _n_burn(c3_y* pog) BURN(); do_tail: - top = _n_peek(); + top = _n_peek(off); o = *top; if ( c3n == u3du(o) ) { u3m_bail(c3__exit); @@ -1110,54 +1160,54 @@ _n_burn(c3_y* pog) do_frab: x = pog[ip_s++]; frag_in: - top = _n_peek(); + top = _n_peek(off); o = *top; *top = u3k(u3r_at(x, o)); u3z(o); BURN(); do_quot: - _n_toss(); + _n_toss(mov, off); do_quip: - _n_push(u3k(_n_rean(pog, &ip_s))); + _n_push(mov, off, u3k(_n_rean(pog, &ip_s))); BURN(); do_nock: - o = _n_pop(); + o = _n_pep(mov, off); gop = _n_find(o); - _n_burn(gop); + _n_burn(gop, mov, off); u3z(o); BURN(); do_noct: - o = _n_pop(); + o = _n_pep(mov, off); pog = _n_find(o); ip_s = 0; u3z(o); BURN(); do_deep: - top = _n_peek(); + top = _n_peek(off); o = *top; *top = u3du(o); u3z(o); BURN(); do_peep: - top = _n_peek(); - _n_push(u3du(*top)); + top = _n_peek(off); + _n_push(mov, off, u3du(*top)); BURN(); do_bump: - top = _n_peek(); + top = _n_peek(off); o = *top; *top = u3i_vint(o); u3z(o); BURN(); do_same: - x = _n_pop(); - top = _n_peek(); + x = _n_pep(mov, off); + top = _n_peek(off); o = *top; *top = u3r_sing(x, o); u3z(x); @@ -1175,7 +1225,7 @@ _n_burn(c3_y* pog) do_kicb: x = pog[ip_s++]; kick_in: - top = _n_peek(); + top = _n_peek(off); o = *top; u3t_off(noc_o); *top = u3j_kick(o, x); @@ -1188,7 +1238,7 @@ _n_burn(c3_y* pog) } *top = o; gop = _n_find(fol); - _n_burn(gop); + _n_burn(gop, mov, off); } BURN(); @@ -1203,7 +1253,7 @@ _n_burn(c3_y* pog) do_ticb: x = pog[ip_s++]; tick_in: - top = _n_peek(); + top = _n_peek(off); o = *top; u3t_off(noc_o); *top = u3j_kick(o, x); @@ -1221,8 +1271,8 @@ _n_burn(c3_y* pog) BURN(); do_fast: // top->[pro clu] - top = _n_peek(); - up = _n_peet(); + top = _n_peek(off); + up = _n_peet(mov, off); u3t_off(noc_o); u3j_mine(*up, u3k(*top)); u3t_on(noc_o); @@ -1231,8 +1281,8 @@ _n_burn(c3_y* pog) BURN(); do_wish: - top = _n_peek(); - up = _n_peet(); + top = _n_peek(off); + up = _n_peet(mov, off); u3t_off(noc_o); x = u3m_soft_esc(*up, u3k(*top)); u3t_on(noc_o); @@ -1255,7 +1305,7 @@ _n_burn(c3_y* pog) } do_cush: - u3t_push(_n_pop()); + u3t_push(_n_pep(mov, off)); BURN(); do_drop: @@ -1264,26 +1314,26 @@ _n_burn(c3_y* pog) do_pumo: // top->[pro key] if ( &(u3H->rod_u) != u3R ) { - top = _n_peek(); - up = _n_peet(); + top = _n_peek(off); + up = _n_peet(mov, off); u3z_save(144 + c3__nock, *up, *top); } BURN(); do_gemo: - top = _n_peek(); + top = _n_peek(off); x = u3z_find(144 + c3__nock, *top); - _n_push(u3_none == x ? 0 : u3nc(0, x)); + _n_push(mov, off, (u3_none == x ? 0 : u3nc(0, x))); BURN(); do_heck: u3t_off(noc_o); - u3t_heck(_n_pop()); + u3t_heck(_n_pep(mov, off)); u3t_on(noc_o); BURN(); do_slog: - x = _n_pop(); + x = _n_pep(mov, off); if ( !(u3C.wag_w & u3o_quiet) ) { u3t_off(noc_o); u3t_slog(x); @@ -1307,6 +1357,7 @@ _n_print_byc(c3_y* pog) "halt", "copy", "toss", "swap", "swat", "skip", "skin", + "sbip", "sbin", "cons", "snoc", "head", "tail", "frag", "fras", "frab", @@ -1336,6 +1387,8 @@ _n_print_byc(c3_y* pog) printf("%s", names[pog[ip_s++]]); break; + case SBIP: + case SBIN: case KICB: case TICB: case FRAB: @@ -1395,12 +1448,22 @@ _n_burn_on(u3_noun bus, u3_noun fol) { u3p(void) empty = u3R->cap_p; c3_y* pog = _n_find(fol); + c3_ys mov, off; u3_noun r; u3z(fol); - _n_push(bus); - _n_burn(pog); - r = _n_pop(); + if ( c3y == u3a_is_north(u3R) ) { + mov = -1; + off = 0; + } + else { + mov = 1; + off = -1; + } + _n_push(mov, off, bus); + _n_burn(pog, mov, off); + + r = _n_pep(mov, off); c3_assert( empty == u3R->cap_p ); return r; From a60d2844c11ad258248abf87e6c95ad8570e3824 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 5 Feb 2018 15:26:17 -0800 Subject: [PATCH 012/221] exorcise c stack from _n_burn --- noun/nock.c | 88 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 08fa43361..556032093 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1021,12 +1021,18 @@ _n_find(u3_noun fol) } } -/* _n_burn(): run pog, subject is top of cap stack, return value on cap stack +typedef struct { + c3_y* pog; + c3_s ip_s; +} burnframe; + +/* _n_burn(): pog: program + * bus: subject * mov: -1 north, 1 south * off: 0 north, -1 south */ -static void -_n_burn(c3_y* pog, c3_ys mov, c3_ys off) +static u3_noun +_n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) { /* OPCODE TABLE */ static void* lab[] = { @@ -1050,19 +1056,32 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) }; c3_s sip_s, ip_s = 0; - c3_y* gop; u3_noun* top; u3_noun* up; u3_noun x, o; + u3p(void) empty; + burnframe* fam; - // could save interpreter frames on cap instead of using c stack (ip_s + pog) - // XX: do this after the simpler version works + empty = u3R->cap_p; + _n_push(mov, off, bus); #define BURN() goto *lab[pog[ip_s++]] BURN(); while ( 1 ) { do_halt: - return; + x = _n_pep(mov, off); + if ( empty == u3R->cap_p ) { + return x; + } + else { + fam = u3to(burnframe, u3R->cap_p) + off; + pog = fam->pog; + ip_s = fam->ip_s; + + u3R->cap_p = u3of(burnframe, fam - mov); + _n_push(mov, off, x); + BURN(); + } do_copy: top = _n_peek(off); @@ -1111,7 +1130,7 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) } else if ( c3y != x ) { u3m_bail(c3__exit); - return; + return u3_none; } BURN(); @@ -1132,7 +1151,7 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) o = *top; if ( c3n == u3du(o) ) { u3m_bail(c3__exit); - return; + return u3_none; } *top = u3k(u3h(o)); u3z(o); @@ -1143,7 +1162,7 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) o = *top; if ( c3n == u3du(o) ) { u3m_bail(c3__exit); - return; + return u3_none; } *top = u3k(u3t(o)); u3z(o); @@ -1173,10 +1192,18 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) BURN(); do_nock: - o = _n_pep(mov, off); - gop = _n_find(o); - _n_burn(gop, mov, off); + o = _n_pep(mov, off); + x = _n_pep(mov, off); + + fam = u3to(burnframe, u3R->cap_p) + off + mov; + u3R->cap_p = u3of(burnframe, fam); + fam->ip_s = ip_s; + fam->pog = pog; + + pog = _n_find(o); + ip_s = 0; u3z(o); + _n_push(mov, off, x); BURN(); do_noct: @@ -1234,11 +1261,18 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) u3_noun fol = u3r_at(x, o); if ( u3_none == fol ) { u3m_bail(c3__exit); - return; + return u3_none; } - *top = o; - gop = _n_find(fol); - _n_burn(gop, mov, off); + _n_pop(mov); + + fam = u3to(burnframe, u3R->cap_p) + off + mov; + u3R->cap_p = u3of(burnframe, fam); + fam->ip_s = ip_s; + fam->pog = pog; + + pog = _n_find(fol); + ip_s = 0; + _n_push(mov, off, o); } BURN(); @@ -1262,7 +1296,7 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) u3_noun fol = u3r_at(x, o); if ( u3_none == fol ) { u3m_bail(c3__exit); - return; + return u3_none; } *top = o; pog = _n_find(fol); @@ -1277,7 +1311,7 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) u3j_mine(*up, u3k(*top)); u3t_on(noc_o); *up = *top; - u3a_pop(sizeof(u3_noun)); + _n_pop(mov); BURN(); do_wish: @@ -1289,13 +1323,13 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) if ( c3n == u3du(x) ) { u3m_bail(u3nt(1, *top, 0)); - return; + return u3_none; } else if ( c3n == u3du(u3t(x)) ) { // replace with proper error stack push u3t_push(u3nc(c3__hunk, _n_mush(*top))); u3m_bail(c3__exit); - return; + return u3_none; } else { u3z(*top); @@ -1346,7 +1380,7 @@ _n_burn(c3_y* pog, c3_ys mov, c3_ys off) do_bail: u3m_bail(c3__exit); - return; + return u3_none; } } @@ -1446,10 +1480,8 @@ static void _n_print_stack(u3p(u3_noun) empty) { static u3_noun _n_burn_on(u3_noun bus, u3_noun fol) { - u3p(void) empty = u3R->cap_p; c3_y* pog = _n_find(fol); c3_ys mov, off; - u3_noun r; u3z(fol); if ( c3y == u3a_is_north(u3R) ) { @@ -1460,13 +1492,7 @@ _n_burn_on(u3_noun bus, u3_noun fol) mov = 1; off = -1; } - _n_push(mov, off, bus); - _n_burn(pog, mov, off); - - r = _n_pep(mov, off); - - c3_assert( empty == u3R->cap_p ); - return r; + return _n_burn(pog, bus, mov, off); } u3_noun From c87954b4f835a62614587adae6144c841b309fa4 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 5 Feb 2018 17:04:41 -0800 Subject: [PATCH 013/221] optimized some copy/quot pairs --- noun/nock.c | 93 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 34 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 556032093..2aeafc409 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -596,6 +596,52 @@ _n_skin(c3_s len_s) return u3nc((len_s < 0xFF ? SBIN : SKIN), len_s); } +static inline c3_s +_n_one(u3_noun* ops, u3_noun fol) +{ + c3_assert(c3y == u3du(fol)); + c3_s tot_s = 0; + if ( 1 == u3h(fol) ) { + tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(fol)))); + } + else { + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, fol, c3n); + } + return tot_s; +} + +static inline c3_s +_n_two(u3_noun* ops, u3_noun one, u3_noun two) +{ + c3_assert(c3y == u3du(one)); + c3_assert(c3y == u3du(two)); + c3_s tot_s = 0; + if ( 1 == u3h(one) ) { + if ( 1 == u3h(two) ) { + tot_s += _n_emit(ops, TOSS); + tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(one)))); + tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(two)))); + } + else { + tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(one)))); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, two, c3n); + } + } + else if ( 1 == u3h(two) ) { + tot_s += _n_comp(ops, one, c3n); + tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(two)))); + } + else { + tot_s += _n_emit(ops, COPY); + tot_s += _n_comp(ops, one, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, two, c3n); + } + return tot_s; +} + /* _n_bint(): hint-processing helper for _n_comp. * hif: hint-formula (first part of 10). RETAIN. * nef: next-formula (second part of 10). RETAIN. @@ -614,8 +660,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) switch ( zep ) { default: - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_one(ops, hod); tot_s += _n_emit(ops, TOSS); tot_s += _n_comp(ops, nef, tel_o); break; @@ -624,8 +669,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) case c3__lose: case c3__mean: case c3__spot: - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_one(ops, hod); tot_s += _n_emit(ops, u3nc(QUIP, zep)); tot_s += _n_emit(ops, SNOC); tot_s += _n_emit(ops, CUSH); @@ -639,8 +683,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) c3_s y_s = 0, n_s = 0; - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_one(ops, hod); tot_s += _n_emit(ops, PEEP); n_s += _n_emit(&nop, HECK); @@ -657,8 +700,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) } case c3__slog: - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hod, c3n); + tot_s += _n_one(ops, hod); tot_s += _n_emit(ops, SLOG); tot_s += _n_comp(ops, nef, tel_o); break; @@ -666,10 +708,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) // germ and sole are unused... case c3__fast: - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hod, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, nef, c3n); + tot_s += _n_two(ops, hod, nef); tot_s += _n_emit(ops, FAST); break; @@ -680,8 +719,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) c3_s y_s = 0, n_s = 0; // top->[bus] tot_s += _n_emit(ops, COPY); // [bus bus] - tot_s += _n_emit(ops, COPY); // [bus bus bus] - tot_s += _n_comp(ops, hod, c3n); // [clue bus bus] + tot_s += _n_one(ops, hod); // [clue bus bus] tot_s += _n_emit(ops, TOSS); // [bus bus] tot_s += _n_emit(ops, u3nc(QUIP, u3k(nef))); // [fol bus bus] tot_s += _n_emit(ops, SNOC); // [[bus fol] bus] @@ -723,10 +761,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { u3x_cell(fol, &cod, &arg); if ( c3y == u3du(cod) ) { - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, cod, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, arg, c3n); + tot_s += _n_two(ops, cod, arg); tot_s += _n_emit(ops, CONS); } else switch ( cod ) { @@ -759,10 +794,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { } case 2: u3x_cell(arg, &hed, &tel); - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hed, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_two(ops, hed, tel); tot_s += _n_emit(ops, ((c3y == tel_o)? NOCT : NOCK)); break; case 3: @@ -775,18 +807,14 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { break; case 5: u3x_cell(arg, &hed, &tel); - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hed, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_two(ops, hed, tel); tot_s += _n_emit(ops, SAME); break; case 6: { u3_noun mid; u3x_trel(arg, &hed, &mid, &tel); - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hed, c3n); + tot_s += _n_one(ops, hed); u3_noun yep = u3_nul, nop = u3_nul; @@ -806,8 +834,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { break; case 8: u3x_cell(arg, &hed, &tel); - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hed, c3n); + tot_s += _n_one(ops, hed); tot_s += _n_emit(ops, SNOC); tot_s += _n_comp(ops, tel, tel_o); break; @@ -833,10 +860,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { break; case 11: u3x_cell(arg, &hed, &tel); - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, hed, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_two(ops, hed, tel); tot_s += _n_emit(ops, WISH); break; } @@ -1000,6 +1024,7 @@ _n_bite(u3_noun fol) u3_noun bok = u3_nul; c3_s len_s = _n_comp(&bok, fol, c3y); c3_y* buf_y = _n_asm(bok, len_s); + u3m_p("fol", fol); _n_print_byc(buf_y); return buf_y; } From 2b7f5f23b3b36843f2d3c98b73fde2271dbe1f48 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 6 Feb 2018 11:50:14 -0800 Subject: [PATCH 014/221] in-progress adding general copy elimination --- noun/nock.c | 213 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 149 insertions(+), 64 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 2aeafc409..a14c8ac15 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -584,61 +584,80 @@ _n_emit(u3_noun *ops, u3_noun op) static c3_s _n_comp(u3_noun*, u3_noun, c3_o); -static inline u3_noun +static u3_noun _n_skip(c3_s len_s) { return u3nc((len_s < 0xFF ? SBIP : SKIP), len_s); } -static inline u3_noun +static u3_noun _n_skin(c3_s len_s) { return u3nc((len_s < 0xFF ? SBIN : SKIN), len_s); } -static inline c3_s -_n_one(u3_noun* ops, u3_noun fol) +/* _n_one(): emit non-tail fol's ops with a leading copy if not constant */ +static c3_s +_n_one(u3_noun* ops, c3_o* tos_o, u3_noun fol) { c3_assert(c3y == u3du(fol)); c3_s tot_s = 0; - if ( 1 == u3h(fol) ) { - tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(fol)))); - } - else { + u3_noun bok = u3_nul; + + tot_s += _n_comp(&bok, &tos_o, fol, c3n); + if ( c3n == tos_o ) { tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, fol, c3n); } + _n_apen(ops, bok); + return tot_s; } -static inline c3_s -_n_two(u3_noun* ops, u3_noun one, u3_noun two) +/* _n_two(): emit one and two's ops, regarding and updating tos_o, + * and managing the COPY/SWAP dance, pushing one's product + * and then two's. */ +static c3_s +_n_two(u3_noun* ops, c3_o* tos_o, u3_noun one, u3_noun two) { c3_assert(c3y == u3du(one)); c3_assert(c3y == u3du(two)); c3_s tot_s = 0; - if ( 1 == u3h(one) ) { - if ( 1 == u3h(two) ) { + c3_o one_o = *tos_o, + two_o = one_o; + + u3_noun one_bok = u3_nul, + two_bok = u3_nul; + + tot_s += _n_comp(&one_bok, &one_o, one, c3n); + tot_s += _n_comp(&two_bok, &two_o, two, c3n); + + if ( c3y == one_o ) { + if ( c3y == two_o ) { tot_s += _n_emit(ops, TOSS); - tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(one)))); - tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(two)))); + _n_apen(ops, one_bok); + _n_apen(ops, two_bok); } else { - tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(one)))); + _n_apen(ops, one_bok); tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, two, c3n); + _n_apen(ops, two_bok); } - } - else if ( 1 == u3h(two) ) { - tot_s += _n_comp(ops, one, c3n); - tot_s += _n_emit(ops, u3nc(QUIP, u3k(u3t(two)))); + *tos_o = two_o; } else { - tot_s += _n_emit(ops, COPY); - tot_s += _n_comp(ops, one, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, two, c3n); + if ( c3y == two_o ) { + _n_apen(one_bok); + _n_apen(two_bok); + } + else { + tot_s += _n_emit(ops, COPY); + _n_apen(one_bok); + tot_s += _n_emit(ops, SWAP); + _n_apen(two_bok); + } + *tos_o = c3n; } + return tot_s; } @@ -647,22 +666,42 @@ _n_two(u3_noun* ops, u3_noun one, u3_noun two) * nef: next-formula (second part of 10). RETAIN. */ static c3_s -_n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) +_n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) { if ( c3n == u3du(hif) ) { // no currently recognized static hints - return _n_comp(ops, nef, tel_o); + return _n_comp(ops, tos_o, nef, tel_o); } else { - c3_s tot_s = 0; - u3_noun zep, hod; + c3_s bok_s, tot_s = 0; + c3_o bok_o; + u3_noun zep, hod, bok; u3x_cell(hif, &zep, &hod); switch ( zep ) { default: - tot_s += _n_one(ops, hod); - tot_s += _n_emit(ops, TOSS); - tot_s += _n_comp(ops, nef, tel_o); + bok = u3_nul; + bok_o = *tos_o; + bok_s = _n_comp(&bok, &bok_o, nef, tel_o); + + c3_assert(c3y == u3du(hod)); + if ( 1 == u3h(hod) ) { + // safe to omit 1 hods because we would just toss them + // and they have no side effects + *tos_o = bok_o; + } + else { + *tos_o = bok_o; + tot_s += _n_one(ops, tos_o, hod); + tot_s += _n_emit(ops, TOSS); + if ( *tos_o != bok_o ) { + u3z(bok); + bok = u3_nul; + bok_o = c3n; + bok_s = _n_comp(&bok, &bok_o, hif, c3n); + } + } + tot_s += bok_s; _n_apen(ops, bok); break; case c3__hunk: @@ -751,17 +790,23 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o tel_o) } /* _n_comp(): emit instructions from fol to ops. - * tel_o indicates tail tail position. + * tel_o indicates tail position. * fol is RETAINED. + * + * if *tos_o is c3y when called, attempt to emit instructions + * that assume the subject is left off the top of the stack, + * writing *tos_o = c3n when encountering instructions that cannot + * ignore their subject. */ static c3_s -_n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { +_n_comp(u3_noun* ops, c3_o* tos_o, u3_noun fol, c3_o tel_o) { c3_s tot_s = 0; + c3_o n_o = c3n; u3_noun cod, arg, hed, tel; u3x_cell(fol, &cod, &arg); if ( c3y == u3du(cod) ) { - tot_s += _n_two(ops, cod, arg); + tot_s += _n_two(ops, tos_o, cod, arg); tot_s += _n_emit(ops, CONS); } else switch ( cod ) { @@ -787,66 +832,106 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { arg)); break; } + *tos_o = c3n; break; - case 1: { - tot_s += _n_emit(ops, u3nc(QUOT, u3k(arg))); + case 1: + tot_s += _n_emit(ops, u3nc(((c3y == *tos_o) ? QUIP : QUOT), u3k(arg))); break; - } case 2: u3x_cell(arg, &hed, &tel); - tot_s += _n_two(ops, hed, tel); + tot_s += _n_two(ops, tos_o, hed, tel); tot_s += _n_emit(ops, ((c3y == tel_o)? NOCT : NOCK)); break; case 3: - tot_s += _n_comp(ops, arg, c3n); + tot_s += _n_comp(ops, tos_o, arg, c3n); tot_s += _n_emit(ops, DEEP); break; case 4: - tot_s += _n_comp(ops, arg, c3n); + tot_s += _n_comp(ops, tos_o, arg, c3n); tot_s += _n_emit(ops, BUMP); break; case 5: u3x_cell(arg, &hed, &tel); - tot_s += _n_two(ops, hed, tel); + tot_s += _n_two(ops, tos_o, hed, tel); tot_s += _n_emit(ops, SAME); break; case 6: { - u3_noun mid; + u3_noun mid, tes, yep, nop; + c3_s yep_s, nop_s; + c3_o ban_o, yep_o, nop_o; + u3x_trel(arg, &hed, &mid, &tel); - tot_s += _n_one(ops, hed); + yep = u3_nul; + yep_o = *tos_o; + yep_s = _n_comp(&yep, &yep_o, mid, tel_o); - u3_noun yep = u3_nul, - nop = u3_nul; - c3_s y_s = _n_comp(&yep, mid, tel_o), - n_s = _n_comp(&nop, tel, tel_o); + nop = u3_nul; + nop_o = yep_o; + nop_s = _n_comp(&nop, &nop_o, tel, tel_o); - y_s += _n_emit(&yep, _n_skip(n_s)); - tot_s += _n_emit(ops, _n_skin(y_s)); - _n_apen(ops, yep); tot_s += y_s; - _n_apen(ops, nop); tot_s += n_s; + if ( yep_o == nop_o ) { + ban_o = yep_o; + } + else { + if ( c3y == yep_o ) { + u3z(yep); + yep_s = n_comp(&yep, &n_o, mid, tel_o); + } + else { + u3z(no); + nop_s = n_comp(&nop, &n_o, tel, tel_o); + } + ban_o = c3n; + } + + tes = u3_nul; + tes_s = ( c3y == ban_o ) + ? _n_comp(&tes, tos_o, hed, c3n) + : _n_one(&tes, tos_o, hed); + + tot_s += tes_s; _n_apen(ops, tes); + yep_s += _n_emit(&yep, _n_skip(nop_s)); + tot_s += _n_emit(ops, _n_skin(yep_s)); + tot_s += yep_s; _n_apen(ops, yep); + tot_s += nop_s; _n_apen(ops, nop); break; } - case 7: + case 7: u3x_cell(arg, &hed, &tel); - tot_s += _n_comp(ops, hed, c3n); - tot_s += _n_comp(ops, tel, tel_o); + tot_s += _n_comp(ops, tos_o, hed, c3n); + tot_s += _n_comp(ops, &n_o, tel, tel_o); break; - case 8: + case 8: { + u3_noun aft; + c3_o aft_o; u3x_cell(arg, &hed, &tel); - tot_s += _n_one(ops, hed); - tot_s += _n_emit(ops, SNOC); - tot_s += _n_comp(ops, tel, tel_o); + + aft = u3_nul; + aft_o = *tos_o; + tot_s = _n_comp(&aft, &aft_o, tel, tel_o); + + if ( c3y == aft_o ) { + tot_s += _n_comp(ops, tos_o, hed, c3n); + tot_s += _n_emit(ops, TOSS); + } + else { + tot_s += _n_one(ops, tos_o, hed); + tot_s += _n_emit(ops, SNOC); + *tos_o = c3n; + } + _n_apen(ops, aft); break; + } case 9: u3x_cell(arg, &hed, &tel); if ( 3 == u3qc_cap(hed) ) { u3_noun mac = u3nq(7, u3k(tel), 2, u3nt(u3nc(0, 1), 0, u3k(hed))); - tot_s += _n_comp(ops, mac, tel_o); + tot_s += _n_comp(ops, tos_o, mac, tel_o); u3z(mac); } else { - tot_s += _n_comp(ops, tel, c3n); + tot_s += _n_comp(ops, tos_o, tel, c3n); tot_s += _n_emit(ops, u3nc( (c3y == tel_o) ? (hed < 0xFF ? TICB : hed < 0xFFFF ? TICS : TICK) @@ -856,11 +941,11 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o tel_o) { break; case 10: u3x_cell(arg, &hed, &tel); - tot_s += _n_bint(ops, hed, tel, tel_o); + tot_s += _n_bint(ops, tos_o, hed, tel, tel_o); break; case 11: u3x_cell(arg, &hed, &tel); - tot_s += _n_two(ops, hed, tel); + tot_s += _n_two(ops, tos_o, hed, tel); tot_s += _n_emit(ops, WISH); break; } @@ -1031,7 +1116,7 @@ _n_bite(u3_noun fol) /* _n_find(): return bytecode for given formula. fol is RETAINED. */ -static c3_y* +static inline c3_y* _n_find(u3_noun fol) { u3_noun got = u3h_get(u3R->byc.har_p, fol); From 945371ae46c5d1a1c87f5d7f94959d1e96bda644 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 7 Feb 2018 10:26:06 -0800 Subject: [PATCH 015/221] i have a new idea... stash --- noun/nock.c | 156 ++++++++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 85 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index a14c8ac15..1da6759a2 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -582,7 +582,7 @@ _n_emit(u3_noun *ops, u3_noun op) } } -static c3_s _n_comp(u3_noun*, u3_noun, c3_o); +static c3_s _n_comp(u3_noun*, c3_o*, u3_noun, c3_o); static u3_noun _n_skip(c3_s len_s) @@ -604,8 +604,8 @@ _n_one(u3_noun* ops, c3_o* tos_o, u3_noun fol) c3_s tot_s = 0; u3_noun bok = u3_nul; - tot_s += _n_comp(&bok, &tos_o, fol, c3n); - if ( c3n == tos_o ) { + tot_s += _n_comp(&bok, tos_o, fol, c3n); + if ( c3n == *tos_o ) { tot_s += _n_emit(ops, COPY); } _n_apen(ops, bok); @@ -613,49 +613,47 @@ _n_one(u3_noun* ops, c3_o* tos_o, u3_noun fol) return tot_s; } -/* _n_two(): emit one and two's ops, regarding and updating tos_o, - * and managing the COPY/SWAP dance, pushing one's product - * and then two's. */ +/* _n_two(): _n_comp() helper for computing two products + * from a single subject + */ static c3_s -_n_two(u3_noun* ops, c3_o* tos_o, u3_noun one, u3_noun two) +_n_two(u3_noun* ops, c3_o* lev_o, u3_noun one, u3_noun two, c3_o cop_o) { - c3_assert(c3y == u3du(one)); - c3_assert(c3y == u3du(two)); - c3_s tot_s = 0; - c3_o one_o = *tos_o, - two_o = one_o; - u3_noun one_bok = u3_nul, two_bok = u3_nul; - tot_s += _n_comp(&one_bok, &one_o, one, c3n); - tot_s += _n_comp(&two_bok, &two_o, two, c3n); + c3_s tot_s = 0; + c3_o one_o, two_o; + + tot_s += _n_comp(&one_bok, &one_o, one, cop_o, c3n); + tot_s += _n_comp(&two_bok, &two_o, two, cop_o, c3n); if ( c3y == one_o ) { if ( c3y == two_o ) { - tot_s += _n_emit(ops, TOSS); _n_apen(ops, one_bok); _n_apen(ops, two_bok); + *lev_o = c3y; } else { _n_apen(ops, one_bok); tot_s += _n_emit(ops, SWAP); _n_apen(ops, two_bok); + *lev_o = c3n; } - *tos_o = two_o; } else { if ( c3y == two_o ) { - _n_apen(one_bok); - _n_apen(two_bok); + _n_apen(ops, one_bok); + _n_apen(ops, two_bok); + *lev_o = c3n; } else { tot_s += _n_emit(ops, COPY); - _n_apen(one_bok); + _n_apen(ops, one_bok); tot_s += _n_emit(ops, SWAP); - _n_apen(two_bok); + _n_apen(ops, two_bok); + *lev_o = c3n; } - *tos_o = c3n; } return tot_s; @@ -668,51 +666,34 @@ _n_two(u3_noun* ops, c3_o* tos_o, u3_noun one, u3_noun two) static c3_s _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) { + *tos_o = c3n; + // XX todo: hints don't currently participate in optimization because it's + // complicated and i want to test it without them. if ( c3n == u3du(hif) ) { // no currently recognized static hints return _n_comp(ops, tos_o, nef, tel_o); } else { - c3_s bok_s, tot_s = 0; - c3_o bok_o; - u3_noun zep, hod, bok; + c3_s tot_s = 0; + u3_noun zep, hod; u3x_cell(hif, &zep, &hod); switch ( zep ) { default: - bok = u3_nul; - bok_o = *tos_o; - bok_s = _n_comp(&bok, &bok_o, nef, tel_o); - - c3_assert(c3y == u3du(hod)); - if ( 1 == u3h(hod) ) { - // safe to omit 1 hods because we would just toss them - // and they have no side effects - *tos_o = bok_o; - } - else { - *tos_o = bok_o; - tot_s += _n_one(ops, tos_o, hod); - tot_s += _n_emit(ops, TOSS); - if ( *tos_o != bok_o ) { - u3z(bok); - bok = u3_nul; - bok_o = c3n; - bok_s = _n_comp(&bok, &bok_o, hif, c3n); - } - } - tot_s += bok_s; _n_apen(ops, bok); + tot_s += _n_one(ops, tos_o, hod); + tot_s += _n_emit(ops, TOSS); + tot_s += _n_comp(ops, tos_o, nef, tel_o); break; case c3__hunk: case c3__lose: case c3__mean: case c3__spot: - tot_s += _n_one(ops, hod); + tot_s += _n_one(ops, tos_o, hod); tot_s += _n_emit(ops, u3nc(QUIP, zep)); tot_s += _n_emit(ops, SNOC); tot_s += _n_emit(ops, CUSH); - tot_s += _n_comp(ops, nef, c3n); + tot_s += _n_comp(ops, tos_o, nef, c3n); tot_s += _n_emit(ops, DROP); break; @@ -722,7 +703,7 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) c3_s y_s = 0, n_s = 0; - tot_s += _n_one(ops, hod); + tot_s += _n_one(ops, tos_o, hod); tot_s += _n_emit(ops, PEEP); n_s += _n_emit(&nop, HECK); @@ -734,20 +715,20 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) _n_apen(ops, yep); tot_s += y_s; _n_apen(ops, nop); tot_s += n_s; - tot_s += _n_comp(ops, nef, tel_o); + tot_s += _n_comp(ops, tos_o, nef, tel_o); break; } case c3__slog: - tot_s += _n_one(ops, hod); + tot_s += _n_one(ops, tos_o, hod); tot_s += _n_emit(ops, SLOG); - tot_s += _n_comp(ops, nef, tel_o); + tot_s += _n_comp(ops, tos_o, nef, tel_o); break; // germ and sole are unused... case c3__fast: - tot_s += _n_two(ops, hod, nef); + tot_s += _n_two(ops, tos_o, hod, nef); tot_s += _n_emit(ops, FAST); break; @@ -758,7 +739,7 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) c3_s y_s = 0, n_s = 0; // top->[bus] tot_s += _n_emit(ops, COPY); // [bus bus] - tot_s += _n_one(ops, hod); // [clue bus bus] + tot_s += _n_one(ops, tos_o, hod); // [clue bus bus] tot_s += _n_emit(ops, TOSS); // [bus bus] tot_s += _n_emit(ops, u3nc(QUIP, u3k(nef))); // [fol bus bus] tot_s += _n_emit(ops, SNOC); // [[bus fol] bus] @@ -768,7 +749,7 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) // NO branch, i.e. gemo gave us ~ n_s += _n_emit(&nop, TOSS); // [key bus] n_s += _n_emit(&nop, SWAP); // [bus key] - n_s += _n_comp(&nop, nef, c3n); // [pro key] + n_s += _n_comp(&nop, tos_o, nef, c3n); // [pro key] n_s += _n_emit(&nop, PUMO); // YES branch, i.e. gemo gave us [0 pro] @@ -789,31 +770,30 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) } } -/* _n_comp(): emit instructions from fol to ops. - * tel_o indicates tail position. - * fol is RETAINED. - * - * if *tos_o is c3y when called, attempt to emit instructions - * that assume the subject is left off the top of the stack, - * writing *tos_o = c3n when encountering instructions that cannot - * ignore their subject. +/* _n_comp(): compile nock formula to reversed opcode list + * ops is a pointer to a list (to be emitted to) + * lev_o is written: c3y/n whether the operand is left on the stack + * fol is the nock formula to compile. RETAIN. + * cop_o indicates the subject/product stack position is a COPY + * if this is taken advantage of (lev_o), the caller should + * omit the COPY + * tel_o is yes if this formula is in tail position + * return: the number of bytes needed for this opcode list */ static c3_s -_n_comp(u3_noun* ops, c3_o* tos_o, u3_noun fol, c3_o tel_o) { +_n_comp(u3_noun* ops, c3_o* lev_o, u3_noun fol, c3_o cop_o, c3_o tel_o) { c3_s tot_s = 0; - c3_o n_o = c3n; + c3_y op_y; u3_noun cod, arg, hed, tel; u3x_cell(fol, &cod, &arg); if ( c3y == u3du(cod) ) { - tot_s += _n_two(ops, tos_o, cod, arg); + tot_s += _n_two(ops, lev_o, cod, arg, cop_o); tot_s += _n_emit(ops, CONS); } else switch ( cod ) { case 0: - if ( c3n == u3ud(arg) ) { - return u3m_bail(c3__exit); - } + c3_assert( c3y == u3ud(arg) ); switch ( arg ) { case 0: tot_s += _n_emit(ops, BAIL); @@ -821,26 +801,29 @@ _n_comp(u3_noun* ops, c3_o* tos_o, u3_noun fol, c3_o tel_o) { case 1: break; case 2: - tot_s += _n_emit(ops, HEAD); + tot_s += _n_emit(ops, (c3y == cop_o) ? HELD : HEAD); break; case 3: - tot_s += _n_emit(ops, TAIL); + tot_s += _n_emit(ops, (c3y == cop_o) ? TALL : TAIL); break; - default: - tot_s += _n_emit(ops, u3nc( - (arg < 0xFF ? FRAB : arg < 0xFFFF ? FRAS : FRAG), - arg)); + default: + op_y = (c3y == cop_o) + ? (arg < 0xFF ? GRAB : arg < 0xFFFF ? GRAS : GRAN) + : (arg < 0xFF ? FRAG : arg < 0xFFFF ? FRAS : FRAG); + tot_s += _n_emit(ops, u3nc(op_y, arg)); break; } - *tos_o = c3n; + *lev_o = cop_o; break; case 1: - tot_s += _n_emit(ops, u3nc(((c3y == *tos_o) ? QUIP : QUOT), u3k(arg))); + op_y = (c3y == cop_o) ? QUIP : QUOT; + tot_s += _n_emit(ops, u3nc(op_y, u3k(arg))); + *lev_o = cop_o; break; case 2: u3x_cell(arg, &hed, &tel); - tot_s += _n_two(ops, tos_o, hed, tel); - tot_s += _n_emit(ops, ((c3y == tel_o)? NOCT : NOCK)); + tot_s += _n_two(ops, lev_o, hed, tel, cop_o); + tot_s += _n_emit(ops, (c3y == tel_o)? NOCT : NOCK); break; case 3: tot_s += _n_comp(ops, tos_o, arg, c3n); @@ -857,7 +840,7 @@ _n_comp(u3_noun* ops, c3_o* tos_o, u3_noun fol, c3_o tel_o) { break; case 6: { u3_noun mid, tes, yep, nop; - c3_s yep_s, nop_s; + c3_s yep_s, nop_s, tes_s; c3_o ban_o, yep_o, nop_o; u3x_trel(arg, &hed, &mid, &tel); @@ -876,11 +859,13 @@ _n_comp(u3_noun* ops, c3_o* tos_o, u3_noun fol, c3_o tel_o) { else { if ( c3y == yep_o ) { u3z(yep); - yep_s = n_comp(&yep, &n_o, mid, tel_o); + yep = u3_nul; + yep_s = _n_comp(&yep, &n_o, mid, tel_o); } else { - u3z(no); - nop_s = n_comp(&nop, &n_o, tel, tel_o); + u3z(nop); + nop = u3_nul; + nop_s = _n_comp(&nop, &n_o, tel, tel_o); } ban_o = c3n; } @@ -1107,7 +1092,8 @@ static inline c3_y* _n_bite(u3_noun fol) { u3_noun bok = u3_nul; - c3_s len_s = _n_comp(&bok, fol, c3y); + c3_o tos_o = c3n; + c3_s len_s = _n_comp(&bok, &tos_o, fol, c3y); c3_y* buf_y = _n_asm(bok, len_s); u3m_p("fol", fol); _n_print_byc(buf_y); From 3ea0b3c51556cba870ace072eb81d769d15e2873 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 12 Feb 2018 13:21:20 -0800 Subject: [PATCH 016/221] stash - finished writing interpreter branches for new retaining opcodes --- noun/nock.c | 749 ++++++++++++++++++++++++++-------------------------- 1 file changed, 381 insertions(+), 368 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 1da6759a2..80d58f3ae 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -582,7 +582,7 @@ _n_emit(u3_noun *ops, u3_noun op) } } -static c3_s _n_comp(u3_noun*, c3_o*, u3_noun, c3_o); +static c3_s _n_comp(u3_noun*, u3_noun, c3_o, c3_o); static u3_noun _n_skip(c3_s len_s) @@ -596,82 +596,16 @@ _n_skin(c3_s len_s) return u3nc((len_s < 0xFF ? SBIN : SKIN), len_s); } -/* _n_one(): emit non-tail fol's ops with a leading copy if not constant */ -static c3_s -_n_one(u3_noun* ops, c3_o* tos_o, u3_noun fol) -{ - c3_assert(c3y == u3du(fol)); - c3_s tot_s = 0; - u3_noun bok = u3_nul; - - tot_s += _n_comp(&bok, tos_o, fol, c3n); - if ( c3n == *tos_o ) { - tot_s += _n_emit(ops, COPY); - } - _n_apen(ops, bok); - - return tot_s; -} - -/* _n_two(): _n_comp() helper for computing two products - * from a single subject - */ -static c3_s -_n_two(u3_noun* ops, c3_o* lev_o, u3_noun one, u3_noun two, c3_o cop_o) -{ - u3_noun one_bok = u3_nul, - two_bok = u3_nul; - - c3_s tot_s = 0; - c3_o one_o, two_o; - - tot_s += _n_comp(&one_bok, &one_o, one, cop_o, c3n); - tot_s += _n_comp(&two_bok, &two_o, two, cop_o, c3n); - - if ( c3y == one_o ) { - if ( c3y == two_o ) { - _n_apen(ops, one_bok); - _n_apen(ops, two_bok); - *lev_o = c3y; - } - else { - _n_apen(ops, one_bok); - tot_s += _n_emit(ops, SWAP); - _n_apen(ops, two_bok); - *lev_o = c3n; - } - } - else { - if ( c3y == two_o ) { - _n_apen(ops, one_bok); - _n_apen(ops, two_bok); - *lev_o = c3n; - } - else { - tot_s += _n_emit(ops, COPY); - _n_apen(ops, one_bok); - tot_s += _n_emit(ops, SWAP); - _n_apen(ops, two_bok); - *lev_o = c3n; - } - } - - return tot_s; -} - /* _n_bint(): hint-processing helper for _n_comp. * hif: hint-formula (first part of 10). RETAIN. * nef: next-formula (second part of 10). RETAIN. */ static c3_s -_n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) +_n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) { - *tos_o = c3n; - // XX todo: hints don't currently participate in optimization because it's - // complicated and i want to test it without them. if ( c3n == u3du(hif) ) { // no currently recognized static hints - return _n_comp(ops, tos_o, nef, tel_o); + return _n_comp(ops, nef, los_o, tel_o); } else { c3_s tot_s = 0; @@ -680,20 +614,18 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) switch ( zep ) { default: - tot_s += _n_one(ops, tos_o, hod); + tot_s += _n_comp(ops, hod, c3n, c3n); tot_s += _n_emit(ops, TOSS); - tot_s += _n_comp(ops, tos_o, nef, tel_o); + tot_s += _n_comp(ops, nef, los_o, tel_o); break; case c3__hunk: case c3__lose: case c3__mean: case c3__spot: - tot_s += _n_one(ops, tos_o, hod); - tot_s += _n_emit(ops, u3nc(QUIP, zep)); - tot_s += _n_emit(ops, SNOC); - tot_s += _n_emit(ops, CUSH); - tot_s += _n_comp(ops, tos_o, nef, c3n); + tot_s += _n_comp(ops, hod, c3n, c3n); + tot_s += _n_emit(ops, u3nc(CUSH, zep)); + tot_s += _n_comp(ops, nef, los_o, c3n); tot_s += _n_emit(ops, DROP); break; @@ -703,66 +635,48 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) c3_s y_s = 0, n_s = 0; - tot_s += _n_one(ops, tos_o, hod); - tot_s += _n_emit(ops, PEEP); - - n_s += _n_emit(&nop, HECK); - - y_s += _n_emit(&yep, TOSS); - y_s += _n_emit(&yep, _n_skip(n_s)); - - tot_s += _n_emit(ops, _n_skin(y_s)); - _n_apen(ops, yep); tot_s += y_s; - _n_apen(ops, nop); tot_s += n_s; - - tot_s += _n_comp(ops, tos_o, nef, tel_o); + tot_s += _n_comp(ops, hod, c3n, c3n); + tot_s += _n_emit(ops, HECK); + tot_s += _n_comp(ops, nef, los_o, tel_o); break; } case c3__slog: - tot_s += _n_one(ops, tos_o, hod); + tot_s += _n_comp(ops, hod, c3n, c3n); tot_s += _n_emit(ops, SLOG); - tot_s += _n_comp(ops, tos_o, nef, tel_o); + tot_s += _n_comp(ops, nef, los_o, tel_o); break; // germ and sole are unused... case c3__fast: - tot_s += _n_two(ops, tos_o, hod, nef); - tot_s += _n_emit(ops, FAST); + tot_s += _n_comp(ops, hod, c3n, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, nef, c3n, c3n); + tot_s += _n_emit(ops, (c3y == los_o) ? FALT : FAST); break; case c3__memo: { - u3_noun nop = u3_nul, - yep = u3_nul; + u3_noun mem = u3_nul; + c3_s mem_s; + c3_y op_y; - c3_s y_s = 0, - n_s = 0; // top->[bus] - tot_s += _n_emit(ops, COPY); // [bus bus] - tot_s += _n_one(ops, tos_o, hod); // [clue bus bus] - tot_s += _n_emit(ops, TOSS); // [bus bus] - tot_s += _n_emit(ops, u3nc(QUIP, u3k(nef))); // [fol bus bus] - tot_s += _n_emit(ops, SNOC); // [[bus fol] bus] - tot_s += _n_emit(ops, GEMO); // [u key bus] - tot_s += _n_emit(ops, PEEP); // [b u key bus] + tot_s += _n_comp(ops, hod, c3n, c3n); + tot_s += _n_emit(ops, TOSS); - // NO branch, i.e. gemo gave us ~ - n_s += _n_emit(&nop, TOSS); // [key bus] - n_s += _n_emit(&nop, SWAP); // [bus key] - n_s += _n_comp(&nop, tos_o, nef, c3n); // [pro key] - n_s += _n_emit(&nop, PUMO); + // SKIM leaves [bus key] on the stack in the unmemoized case + mem_s += _n_comp(&mem, nef, c3n, c3n); - // YES branch, i.e. gemo gave us [0 pro] - y_s += _n_emit(&yep, TAIL); // [pro key bus] - y_s += _n_emit(&yep, SWAT); // [pro bus] - y_s += _n_emit(&yep, _n_skip(n_s)); + // now [pro key bus?], where bus was left on if appropropriate + mem_s += _n_emit(ops, SAVE); - tot_s += _n_emit(ops, _n_skin(y_s)); - _n_apen(ops, yep); tot_s += y_s; - _n_apen(ops, nop); tot_s += n_s; + op_y = (c3y == los_o) + ? (( mem_s < 0xFF ) ? SLIB : SLIM) + : (( mem_s < 0xFF ) ? SKIB : SKIM); - // both branches leave an extra value under the top - tot_s += _n_emit(ops, SWAT); + // SKIM leaves [pro bus] and SLIM leaves [pro] + tot_s += _n_emit(ops, u3nt(op_y, mem_s, u3k(nef))); + tot_s += mem_s; _n_apen(ops, mem); break; } } @@ -772,167 +686,149 @@ _n_bint(u3_noun* ops, c3_o* tos_o, u3_noun hif, u3_noun nef, c3_o tel_o) /* _n_comp(): compile nock formula to reversed opcode list * ops is a pointer to a list (to be emitted to) - * lev_o is written: c3y/n whether the operand is left on the stack * fol is the nock formula to compile. RETAIN. - * cop_o indicates the subject/product stack position is a COPY - * if this is taken advantage of (lev_o), the caller should - * omit the COPY + * los_o indicates whether we should remove our subject from the stack * tel_o is yes if this formula is in tail position * return: the number of bytes needed for this opcode list */ static c3_s -_n_comp(u3_noun* ops, c3_o* lev_o, u3_noun fol, c3_o cop_o, c3_o tel_o) { - c3_s tot_s = 0; +_n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) +{ c3_y op_y; + c3_s tot_s = 0; u3_noun cod, arg, hed, tel; u3x_cell(fol, &cod, &arg); - if ( c3y == u3du(cod) ) { - tot_s += _n_two(ops, lev_o, cod, arg, cop_o); - tot_s += _n_emit(ops, CONS); + tot_s += _n_comp(ops, cod, c3n, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, arg, c3n, c3n); + tot_s += _n_emit(ops, (c3y == los_o ) ? AULT : AUTO); } else switch ( cod ) { - case 0: - c3_assert( c3y == u3ud(arg) ); + case 0: + if ( c3n == u3ud(arg) ) { + u3m_bail(c3__exit); + return 0; + } switch ( arg ) { case 0: tot_s += _n_emit(ops, BAIL); break; case 1: + if ( c3n == los_o ) { + tot_s += _n_emit(ops, COPY); + } break; case 2: - tot_s += _n_emit(ops, (c3y == cop_o) ? HELD : HEAD); + tot_s += _n_emit(ops, (c3y == los_o) ? HELD : HEAD); break; case 3: - tot_s += _n_emit(ops, (c3y == cop_o) ? TALL : TAIL); + tot_s += _n_emit(ops, (c3y == los_o) ? TALL : TAIL); break; default: - op_y = (c3y == cop_o) - ? (arg < 0xFF ? GRAB : arg < 0xFFFF ? GRAS : GRAN) - : (arg < 0xFF ? FRAG : arg < 0xFFFF ? FRAS : FRAG); - tot_s += _n_emit(ops, u3nc(op_y, arg)); + op_y = (c3y == los_o) + ? (arg < 0xFF ? FLAB : arg < 0xFFFF ? FLAS : FLAG) + : (arg < 0xFF ? FRAB : arg < 0xFFFF ? FRAS : FRAG); + tot_s += _n_emit(ops, u3nc(op, arg)); break; } - *lev_o = cop_o; break; - case 1: - op_y = (c3y == cop_o) ? QUIP : QUOT; + + case 1: + op_y = (c3y == los_o) + ? (arg < 0xFF ? LILB : arg < 0xFFFF ? LILS : LILN) + : (arg < 0xFF ? LITB : arg < 0xFFFF ? LITS : LITN); tot_s += _n_emit(ops, u3nc(op_y, u3k(arg))); - *lev_o = cop_o; break; + case 2: u3x_cell(arg, &hed, &tel); - tot_s += _n_two(ops, lev_o, hed, tel, cop_o); - tot_s += _n_emit(ops, (c3y == tel_o)? NOCT : NOCK); + tot_s += _n_comp(ops, hed, c3n, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n, c3n); + op_y = (c3y == los_o) + ? ((c3y == tel_o) ? NOLT : NOLK) + : ((c3y == tel_o) ? NOCT : NOCK); + tot_s += _n_emit(ops, op_y); break; + case 3: - tot_s += _n_comp(ops, tos_o, arg, c3n); + tot_s += _n_comp(ops, arg, los_o, c3n); tot_s += _n_emit(ops, DEEP); break; + case 4: - tot_s += _n_comp(ops, tos_o, arg, c3n); + tot_s += _n_comp(ops, arg, los_o, c3n); tot_s += _n_emit(ops, BUMP); break; + case 5: u3x_cell(arg, &hed, &tel); - tot_s += _n_two(ops, tos_o, hed, tel); - tot_s += _n_emit(ops, SAME); + tot_s += _n_comp(ops, hed, c3n, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n, c3n); + tot_s += _n_emit(ops, (c3y == los_o) ? SALM : SAME); break; + case 6: { - u3_noun mid, tes, yep, nop; - c3_s yep_s, nop_s, tes_s; - c3_o ban_o, yep_o, nop_o; - + u3_noun mid, yep, nop; + c3_y yep_s, nop_s; u3x_trel(arg, &hed, &mid, &tel); - - yep = u3_nul; - yep_o = *tos_o; - yep_s = _n_comp(&yep, &yep_o, mid, tel_o); - - nop = u3_nul; - nop_o = yep_o; - nop_s = _n_comp(&nop, &nop_o, tel, tel_o); - - if ( yep_o == nop_o ) { - ban_o = yep_o; - } - else { - if ( c3y == yep_o ) { - u3z(yep); - yep = u3_nul; - yep_s = _n_comp(&yep, &n_o, mid, tel_o); - } - else { - u3z(nop); - nop = u3_nul; - nop_s = _n_comp(&nop, &n_o, tel, tel_o); - } - ban_o = c3n; - } - - tes = u3_nul; - tes_s = ( c3y == ban_o ) - ? _n_comp(&tes, tos_o, hed, c3n) - : _n_one(&tes, tos_o, hed); - - tot_s += tes_s; _n_apen(ops, tes); + tot_s += _n_comp(ops, hed, c3n, c3n); + yep_s = _n_comp(&yep, mid, los_o, tel_o); + nop_s = _n_comp(&nop, tel, los_o, tel_o); yep_s += _n_emit(&yep, _n_skip(nop_s)); tot_s += _n_emit(ops, _n_skin(yep_s)); tot_s += yep_s; _n_apen(ops, yep); tot_s += nop_s; _n_apen(ops, nop); break; } + case 7: u3x_cell(arg, &hed, &tel); - tot_s += _n_comp(ops, tos_o, hed, c3n); - tot_s += _n_comp(ops, &n_o, tel, tel_o); + tot_s += _n_comp(ops, hed, los_o, c3n); + tot_s += _n_comp(ops, tel, c3y, tel_o); break; - case 8: { - u3_noun aft; - c3_o aft_o; + + case 8: u3x_cell(arg, &hed, &tel); - - aft = u3_nul; - aft_o = *tos_o; - tot_s = _n_comp(&aft, &aft_o, tel, tel_o); - - if ( c3y == aft_o ) { - tot_s += _n_comp(ops, tos_o, hed, c3n); - tot_s += _n_emit(ops, TOSS); - } - else { - tot_s += _n_one(ops, tos_o, hed); - tot_s += _n_emit(ops, SNOC); - *tos_o = c3n; - } - _n_apen(ops, aft); + tot_s += _n_comp(ops, hed, c3n, c3n); + tot_s += _n_emit(ops, (c3y == los_o) ? SNOL : SNOC); + tot_s += _n_comp(ops, tel, c3y, tel_o); break; - } + case 9: u3x_cell(arg, &hed, &tel); if ( 3 == u3qc_cap(hed) ) { u3_noun mac = u3nq(7, u3k(tel), 2, u3nt(u3nc(0, 1), 0, u3k(hed))); - tot_s += _n_comp(ops, tos_o, mac, tel_o); + tot_s += _n_comp(ops, mac, tel_o); u3z(mac); } else { - tot_s += _n_comp(ops, tos_o, tel, c3n); - tot_s += _n_emit(ops, u3nc( - (c3y == tel_o) - ? (hed < 0xFF ? TICB : hed < 0xFFFF ? TICS : TICK) - : (hed < 0xFF ? KICB : hed < 0xFFFF ? KICS : KICK), - u3k(hed))); + op_y = (c3y == tel_o) + ? (hed < 0xFF ? TICB : hed < 0xFFFF ? TICS : TICK) + : (hed < 0xFF ? KICB : hed < 0xFFFF ? KICS : KICK); + tot_s += _n_comp(ops, tel, los_o, c3n); + tot_s += _n_emit(ops, u3nc(op_y, u3k(hed))); } break; + case 10: u3x_cell(arg, &hed, &tel); - tot_s += _n_bint(ops, tos_o, hed, tel, tel_o); + tot_s += _n_bint(ops, hed, tel, los_o, tel_o); break; + case 11: u3x_cell(arg, &hed, &tel); - tot_s += _n_two(ops, tos_o, hed, tel); - tot_s += _n_emit(ops, WISH); + tot_s += _n_comp(ops, hed, c3n, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n, c3n); + tot_s += _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; + + default: + u3m_bail(c3__exit); + return 0; } return tot_s; } @@ -991,7 +887,8 @@ _n_asm(u3_noun ops, c3_s len_s) break; } default: - c3_assert(0); + u3m_bail(c3__exit); + return 0; } } ops = u3t(ops); @@ -1032,7 +929,6 @@ static inline u3_noun* _n_peet(c3_ys mov, c3_ys off) { return u3to(u3_noun, (u3R->cap_p - mov) + off); -// return u3to(u3_noun, u3R->cap_p + (_(u3a_is_north(u3R)) ? 1 : -2)); } /* _n_pop(): pop a noun from the cap stack @@ -1092,8 +988,7 @@ static inline c3_y* _n_bite(u3_noun fol) { u3_noun bok = u3_nul; - c3_o tos_o = c3n; - c3_s len_s = _n_comp(&bok, &tos_o, fol, c3y); + c3_s len_s = _n_comp(&bok, fol, c3n, c3y); c3_y* buf_y = _n_asm(bok, len_s); u3m_p("fol", fol); _n_print_byc(buf_y); @@ -1117,6 +1012,30 @@ _n_find(u3_noun fol) } } +/* _n_swap(): swap two items on the top of the stack, return pointer to top + */ +static inline u3_noun* +_n_swap(c3_ys mov, c3_ys off) +{ + u3_noun* up = _n_peek(off); + u3_noun* top = _n_peet(mov, off); + u3_noun tmp = *up; + *up = *top; + *top = tmp; + return top; +} + +/* _n_kale(): bail(exit) if not cell + */ +static inline u3_noun +_n_kale(u3_noun a) +{ + if ( c3n == u3du(a) ) { + u3m_bail(c3__exit); + } + return a; +} + typedef struct { c3_y* pog; c3_s ip_s; @@ -1164,8 +1083,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #define BURN() goto *lab[pog[ip_s++]] BURN(); while ( 1 ) { - do_halt: + do_halt: // [product subject ...burnframes...] x = _n_pep(mov, off); + _n_toss(mov); if ( empty == u3R->cap_p ) { return x; } @@ -1184,10 +1104,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) _n_push(mov, off, u3k(*top)); BURN(); - do_toss: - _n_toss(mov, off); - BURN(); - do_swap: top = _n_peek(off); up = _n_peet(mov, off); @@ -1196,15 +1112,164 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) *up = x; BURN(); - do_swat: - top = _n_peek(off); - up = _n_peet(mov, off); - x = *top; - *top = *up; - *up = x; + do_toss: _n_toss(mov, off); BURN(); + do_bail: + u3m_bail(c3__exit); + return u3_none; + + do_auto: // [tel bus hed] + x = _n_pep(mov, off); // [bus hed] + top = _n_swap(mov, off); // [hed bus] + *top = u3nc(*top, x); // [pro bus] + BURN(); + + do_ault: // [tel bus hed] + x = _n_pep(mov, off); // [bus hed] + _n_toss(mov, off); // [hed] + top = _n_peek(off); + *top = u3nc(*top, x); // [pro] + BURN(); + + do_head: + top = _n_peek(off); + _n_push(u3k(u3h(_n_kale(*top)))); + BURN(); + + do_held: + top = _n_peek(off); + o = _n_kale(*top); + *top = u3k(u3h(o)); + u3z(o); + BURN(); + + do_tail: + top = _n_peek(off); + _n_push(u3k(u3t(_n_kale(*top)))); + BURN(); + + do_tall: + top = _n_peek(off); + o = _n_kale(*top); + *top = u3k(u3t(o)); + u3z(o); + BURN(); + + do_fras: + x = _n_resh(pog, &ip_s); + goto frag_in; + + do_frag: + x = _n_rean(pog, &ip_s); + goto frag_in; + + do_frab: + x = pog[ip_s++]; + frag_in: + top = _n_peek(off); + _n_push(u3k(u3x_at(x, *top))); + BURN(); + + do_flas: + x = _n_resh(pog, &ip_s); + goto flag_in; + + do_flag: + x = _n_rean(pog, &ip_s); + goto flag_in; + + do_flab: + x = pog[ip_s++]; + flag_in: + top = _n_peek(off); + o = *top; + *top = u3k(u3x_at(x, o)); + u3z(o); + BURN(); + + do_lils: + _n_toss(mov, off); + do_litb: + x = _n_resh(pog, &ip_s); + goto quot_in; + + do_liln: + _n_toss(mov, off); + do_litn: + x = _n_rean(pog, &ip_s); + goto quot_in; + + do_lilb: + _n_toss(mov, off); + do_litb: + x = pog[ip_s++]; + quot_in: + _n_push(mov, off, u3k(x)); + BURN(); + + do_nolt: // [fol old bus] + o = _n_pep(mov, off); // [old bus] + _n_toss(mov, off); // [bus] + goto noct_in; + + do_nolk: // [fol old bus] + o = _n_pep(mov, off); // [old bus] + _n_toss(mov, off); // [bus] + goto nock_in; + + do_noct: // [fol old bus] + o = _n_pep(mov, off); // [old bus] + _n_swap(mov, off); // [bus old] + goto noct_in; + + do_nock: // [fol old bus] + o = _n_pep(mov, off); // [old bus] + _n_swap(mov, off); // [bus old] + nock_in: + x = _n_pep(mov, off); + fam = u3to(burnframe, u3R->cap_p) + off + mov; + u3R->cap_p = u3of(burnframe, fam); + fam->ip_s = ip_s; + fam->pog = pog; + _n_push(mov, off, x); + noct_in: + pog = _n_find(o); + ip_s = 0; + BURN(); + + do_deep: + top = _n_peek(off); + o = *top; + *top = u3du(o); + u3z(o); + BURN(); + + do_bump: + top = _n_peek(off); + o = *top; + *top = u3i_vint(o); + u3z(o); + BURN(); + + do_same: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + o = *top; + *top = u3r_sing(x, o); + u3z(o); + BURN(); + + do_salm: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + o = *top; + *top = u3r_sing(x, o); + u3z(o); + BURN(); + do_skip: ip_s += _n_resh(pog, &ip_s); BURN(); @@ -1230,110 +1295,19 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } BURN(); - do_cons: - x = _n_pep(mov, off); - top = _n_peek(off); - *top = u3nc(*top, x); - BURN(); - - do_snoc: + do_snoc: // [hed tel] x = _n_pep(mov, off); top = _n_peek(off); *top = u3nc(x, *top); BURN(); - do_head: - top = _n_peek(off); - o = *top; - if ( c3n == u3du(o) ) { - u3m_bail(c3__exit); - return u3_none; - } - *top = u3k(u3h(o)); - u3z(o); - BURN(); - - do_tail: - top = _n_peek(off); - o = *top; - if ( c3n == u3du(o) ) { - u3m_bail(c3__exit); - return u3_none; - } - *top = u3k(u3t(o)); - u3z(o); - BURN(); - - do_fras: - x = _n_resh(pog, &ip_s); - goto frag_in; - - do_frag: - x = _n_rean(pog, &ip_s); - goto frag_in; - - do_frab: - x = pog[ip_s++]; - frag_in: - top = _n_peek(off); - o = *top; - *top = u3k(u3r_at(x, o)); - u3z(o); - BURN(); - - do_quot: - _n_toss(mov, off); - do_quip: - _n_push(mov, off, u3k(_n_rean(pog, &ip_s))); - BURN(); - - do_nock: - o = _n_pep(mov, off); + do_snol: x = _n_pep(mov, off); - - fam = u3to(burnframe, u3R->cap_p) + off + mov; - u3R->cap_p = u3of(burnframe, fam); - fam->ip_s = ip_s; - fam->pog = pog; - - pog = _n_find(o); - ip_s = 0; - u3z(o); - _n_push(mov, off, x); - BURN(); - - do_noct: o = _n_pep(mov, off); - pog = _n_find(o); - ip_s = 0; - u3z(o); - BURN(); - - do_deep: + x = u3nc(x, o); top = _n_peek(off); o = *top; - *top = u3du(o); - u3z(o); - BURN(); - - do_peep: - top = _n_peek(off); - _n_push(mov, off, u3du(*top)); - BURN(); - - do_bump: - top = _n_peek(off); - o = *top; - *top = u3i_vint(o); - u3z(o); - BURN(); - - do_same: - x = _n_pep(mov, off); - top = _n_peek(off); - o = *top; - *top = u3r_sing(x, o); - u3z(x); + *top = x; u3z(o); BURN(); @@ -1354,12 +1328,8 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) *top = u3j_kick(o, x); u3t_on(noc_o); if ( u3_none == *top ) { - u3_noun fol = u3r_at(x, o); - if ( u3_none == fol ) { - u3m_bail(c3__exit); - return u3_none; - } - _n_pop(mov); + u3_noun fol = u3x_at(x, o); + _n_toss(mov); fam = u3to(burnframe, u3R->cap_p) + off + mov; u3R->cap_p = u3of(burnframe, fam); @@ -1390,76 +1360,63 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3t_on(noc_o); if ( u3_none == *top ) { u3_noun fol = u3r_at(x, o); - if ( u3_none == fol ) { - u3m_bail(c3__exit); - return u3_none; - } *top = o; pog = _n_find(fol); ip_s = 0; } BURN(); - do_fast: // top->[pro clu] + do_wils: // [gof bus ref] + o = _n_pep(mov,off); // [bus ref] + _n_toss(mov, off); // [ref] top = _n_peek(off); - up = _n_peet(mov, off); - u3t_off(noc_o); - u3j_mine(*up, u3k(*top)); - u3t_on(noc_o); - *up = *top; - _n_pop(mov); - BURN(); + goto wish_in; - do_wish: - top = _n_peek(off); - up = _n_peet(mov, off); + do_wish: // [gof bus ref] + o = _n_pep(mov,off); // [bus ref] + top = _n_swap(mov, off); // [ref bus] + wish_in: u3t_off(noc_o); - x = u3m_soft_esc(*up, u3k(*top)); + x = u3m_soft_esc(u3k(o), *top); u3t_on(noc_o); if ( c3n == u3du(x) ) { - u3m_bail(u3nt(1, *top, 0)); + u3m_bail(u3nt(1, o, 0)); return u3_none; } else if ( c3n == u3du(u3t(x)) ) { // replace with proper error stack push - u3t_push(u3nc(c3__hunk, _n_mush(*top))); + u3t_push(u3nc(c3__hunk, _n_mush(o))); u3m_bail(c3__exit); return u3_none; } else { - u3z(*top); + u3z(o); *top = u3k(u3t(u3t(x))); u3z(x); BURN(); } do_cush: - u3t_push(_n_pep(mov, off)); + x = _n_rean(pog, &ip_s); + o = _n_pep(mov, off); + u3t_push(u3nc(u3k(x), o)); BURN(); do_drop: u3t_drop(); BURN(); - do_pumo: // top->[pro key] - if ( &(u3H->rod_u) != u3R ) { - top = _n_peek(off); - up = _n_peet(mov, off); - u3z_save(144 + c3__nock, *up, *top); - } - BURN(); - - do_gemo: - top = _n_peek(off); - x = u3z_find(144 + c3__nock, *top); - _n_push(mov, off, (u3_none == x ? 0 : u3nc(0, x))); - BURN(); - do_heck: - u3t_off(noc_o); - u3t_heck(_n_pep(mov, off)); - u3t_on(noc_o); + x = _n_pep(mov, off); + if ( c3y == u3ud(x) ) { + u3t_off(noc_o); + u3t_heck(x); + u3t_on(noc_o); + } + else { + u3z(x); + } BURN(); do_slog: @@ -1474,9 +1431,65 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } BURN(); - do_bail: - u3m_bail(c3__exit); - return u3_none; + do_falt: // [pro bus clu] + o = _n_pep(mov, off); // [bus clu] + _n_toss(); // [clu] + top = _n_peek(off); + goto fast_in; + + do_fast: // [pro bus clu] + o = _n_pep(mov, off); // [bus clu] + top = _n_swap(mov, off); // [clu bus] + fast_in: + u3t_off(noc_o); + u3j_mine(*top, u3k(o)); + u3t_on(noc_o); + u3z(*top); + *top = o; + BURN(); + + do_skim: + sip_s = _n_resh(pog, &ip_s); + goto skim_in; + + do_slim: + sip_s = _n_resh(pog, &ip_s); + goto slim_in; + + do_slib: + sip_s = pog[ip_s++]; + goto slim_in; + + do_skib: + sip_s = pog[ip_s++]; + skim_in: + top = _n_peek(off); + _n_push(mov, off, u3k(*top)); + slim_in: + o = _n_rean(pog, &ip_s); + x = u3nc(u3k(o), _n_pep(mov, off)); + o = u3z_find(144 + c3__nock, x); + if ( u3_none == o ) { + _n_push(mov, off, x); + _n_push(mov, off, u3k(u3t(x))); + } + else { + ip_s += sip_s; + _n_push(o); + u3z(x); + } + BURN(); + + do_save: + x = _n_pep(mov, off); + top = _n_peek(off); + o = *top; + if ( &(u3H->rod_u) != u3R ) { + u3z_save(144 + c3__nock, o, x); + } + *top = x; + u3z(o); + BURN(); } } From b116b22bc6f6791bc746a1de9bf07ab541aa151e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 12 Feb 2018 15:19:11 -0800 Subject: [PATCH 017/221] retain-bytecode refactor compiles --- noun/nock.c | 367 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 230 insertions(+), 137 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 80d58f3ae..17f7aa298 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -497,45 +497,62 @@ u3n_nock_an(u3_noun bus, u3_noun fol) } /* These must match the order in the section marked OPCODE TABLE */ -#define HALT 0 // stop executing, leaving the product on the top of stack -#define COPY 1 // copy TOS, keep, and push it -#define TOSS 2 // throw away and lose TOS -#define SWAP 3 // exchange TOS with item underneat -#define SWAT 4 // toss item under TOS (under) -#define SKIP 5 // skip N (c3_s) instructions -#define SKIN 6 // pop loob, skip N if it is no, bail if not yes -#define SBIP 7 // skip with byte argument -#define SBIN 8 // skin with byte argument -#define CONS 9 // makes a cell of [under, TOS] -#define SNOC 10 // makes a cell of [TOS, under] -#define HEAD 11 // replaces TOS with its head (old TOS lost) -#define TAIL 12 // as HEAD, but for the tail -#define FRAG 13 // as HEAD/TAIL but with arbitrary noun axis -#define FRAS 14 // frag with short -#define FRAB 15 // frag with byte axis -#define QUOT 16 // toss TOS, push literal noun argument -#define QUIP 17 // as QUOT, but without the toss -#define NOCK 18 // *(under, TOS) -#define NOCT 19 // as NOCK, but in tail position -#define DEEP 20 // pop TOS and push isCell loob -#define PEEP 21 // as DEEP, but doesn't pop -#define BUMP 22 // increment TOS -#define SAME 23 // pop two items and push equality loob -#define KICK 24 // pull noun axis from TOS -#define KICS 25 // kick with short axis -#define KICB 26 // kick with byte axis -#define TICK 27 // KICK, but in tail position -#define TICS 28 // tick with short axis -#define TICB 29 // tick with byte axis -#define WISH 30 // ref is under, gof is TOS, u3m_soft_esc -#define FAST 31 // u3j_mine TOS -#define CUSH 32 // u3t_push TOS -#define DROP 33 // u3t_drop -#define PUMO 34 // saves memo from tos->[pro key] -#define GEMO 35 // pushes (unit pro) of u3z_save with key=TOS -#define HECK 36 // u3t_heck TOS -#define SLOG 37 // u3t_slog TOS -#define BAIL 37 // bail %exit +#define HALT 0 +#define BAIL 1 +#define COPY 2 +#define SWAP 3 +#define TOSS 4 +#define AUTO 5 +#define AULT 6 +#define HEAD 7 +#define HELD 8 +#define TAIL 9 +#define TALL 10 +#define FRAS 11 +#define FRAG 12 +#define FRAB 13 +#define FLAS 14 +#define FLAG 15 +#define FLAB 16 +#define LITB 17 +#define LITS 18 +#define LITN 19 +#define LILB 20 +#define LILS 21 +#define LILN 22 +#define NOLT 23 +#define NOLK 24 +#define NOCT 25 +#define NOCK 26 +#define DEEP 27 +#define BUMP 28 +#define SAME 29 +#define SALM 30 +#define SKIP 31 +#define SBIP 32 +#define SKIN 33 +#define SBIN 34 +#define SNOC 35 +#define SNOL 36 +#define KICB 37 +#define KICS 38 +#define KICK 39 +#define TICB 40 +#define TICS 41 +#define TICK 42 +#define WILS 43 +#define WISH 44 +#define CUSH 45 +#define DROP 46 +#define HECK 47 +#define SLOG 48 +#define FALT 49 +#define FAST 50 +#define SKIB 51 +#define SKIM 52 +#define SLIB 53 +#define SLIM 54 +#define SAVE 55 /* _n_apen(): emit the instructions contained in src to dst */ @@ -557,26 +574,43 @@ _n_emit(u3_noun *ops, u3_noun op) return sizeof(c3_y); } else switch ( u3h(op) ) { + case FRAB: + case FLAB: + case LILB: + case LITB: case SBIP: case SBIN: case KICB: case TICB: - case FRAB: return sizeof(c3_y) + sizeof(c3_y); + case FRAS: + case FLAS: + case LILS: + case LITS: + case SKIP: + case SKIN: case KICS: case TICS: - case FRAS: - case SKIP: - case SKIN: return sizeof(c3_y) + sizeof(c3_s); + case CUSH: case FRAG: - case QUOT: - case QUIP: + case FLAG: + case LILN: + case LITN: case TICK: case KICK: return sizeof(c3_y) + sizeof(u3_noun); + + case SKIM: + case SLIM: + return sizeof(c3_y) + sizeof(c3_s) + sizeof(u3_noun); + + case SKIB: + case SLIB: + return sizeof(c3_y) + sizeof(c3_y) + sizeof(u3_noun); + default: c3_assert(0); } @@ -584,18 +618,6 @@ _n_emit(u3_noun *ops, u3_noun op) static c3_s _n_comp(u3_noun*, u3_noun, c3_o, c3_o); -static u3_noun -_n_skip(c3_s len_s) -{ - return u3nc((len_s < 0xFF ? SBIP : SKIP), len_s); -} - -static u3_noun -_n_skin(c3_s len_s) -{ - return u3nc((len_s < 0xFF ? SBIN : SKIN), len_s); -} - /* _n_bint(): hint-processing helper for _n_comp. * hif: hint-formula (first part of 10). RETAIN. * nef: next-formula (second part of 10). RETAIN. @@ -629,17 +651,11 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) tot_s += _n_emit(ops, DROP); break; - case c3__live: { - u3_noun yep = u3_nul, - nop = u3_nul; - c3_s y_s = 0, - n_s = 0; - + case c3__live: tot_s += _n_comp(ops, hod, c3n, c3n); tot_s += _n_emit(ops, HECK); tot_s += _n_comp(ops, nef, los_o, tel_o); break; - } case c3__slog: tot_s += _n_comp(ops, hod, c3n, c3n); @@ -658,7 +674,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) case c3__memo: { u3_noun mem = u3_nul; - c3_s mem_s; + c3_s mem_s = 0; c3_y op_y; tot_s += _n_comp(ops, hod, c3n, c3n); @@ -671,8 +687,8 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) mem_s += _n_emit(ops, SAVE); op_y = (c3y == los_o) - ? (( mem_s < 0xFF ) ? SLIB : SLIM) - : (( mem_s < 0xFF ) ? SKIB : SKIM); + ? (( mem_s <= 0xFF ) ? SLIB : SLIM) + : (( mem_s <= 0xFF ) ? SKIB : SKIM); // SKIM leaves [pro bus] and SLIM leaves [pro] tot_s += _n_emit(ops, u3nt(op_y, mem_s, u3k(nef))); @@ -727,17 +743,17 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) break; default: op_y = (c3y == los_o) - ? (arg < 0xFF ? FLAB : arg < 0xFFFF ? FLAS : FLAG) - : (arg < 0xFF ? FRAB : arg < 0xFFFF ? FRAS : FRAG); - tot_s += _n_emit(ops, u3nc(op, arg)); + ? (arg <= 0xFF ? FLAB : arg <= 0xFFFF ? FLAS : FLAG) + : (arg <= 0xFF ? FRAB : arg <= 0xFFFF ? FRAS : FRAG); + tot_s += _n_emit(ops, u3nc(op_y, arg)); break; } break; case 1: op_y = (c3y == los_o) - ? (arg < 0xFF ? LILB : arg < 0xFFFF ? LILS : LILN) - : (arg < 0xFF ? LITB : arg < 0xFFFF ? LITS : LITN); + ? (arg <= 0xFF ? LILB : arg <= 0xFFFF ? LILS : LILN) + : (arg <= 0xFF ? LITB : arg <= 0xFFFF ? LITS : LITN); tot_s += _n_emit(ops, u3nc(op_y, u3k(arg))); break; @@ -772,13 +788,15 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) case 6: { u3_noun mid, yep, nop; - c3_y yep_s, nop_s; + c3_s yep_s, nop_s; u3x_trel(arg, &hed, &mid, &tel); tot_s += _n_comp(ops, hed, c3n, c3n); yep_s = _n_comp(&yep, mid, los_o, tel_o); nop_s = _n_comp(&nop, tel, los_o, tel_o); - yep_s += _n_emit(&yep, _n_skip(nop_s)); - tot_s += _n_emit(ops, _n_skin(yep_s)); + op_y = (nop_s <= 0xFF ? SBIP : SKIP); + yep_s += _n_emit(&yep, u3nc(op_y, nop_s)); + op_y = (yep_s <= 0xFF ? SBIN : SKIN); + tot_s += _n_emit(ops, u3nc(op_y, yep_s)); tot_s += yep_s; _n_apen(ops, yep); tot_s += nop_s; _n_apen(ops, nop); break; @@ -801,13 +819,13 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) u3x_cell(arg, &hed, &tel); if ( 3 == u3qc_cap(hed) ) { u3_noun mac = u3nq(7, u3k(tel), 2, u3nt(u3nc(0, 1), 0, u3k(hed))); - tot_s += _n_comp(ops, mac, tel_o); + tot_s += _n_comp(ops, mac, los_o, tel_o); u3z(mac); } else { op_y = (c3y == tel_o) - ? (hed < 0xFF ? TICB : hed < 0xFFFF ? TICS : TICK) - : (hed < 0xFF ? KICB : hed < 0xFFFF ? KICS : KICK); + ? (hed <= 0xFF ? TICB : hed <= 0xFFFF ? TICS : TICK) + : (hed <= 0xFF ? KICB : hed <= 0xFFFF ? KICS : KICK); tot_s += _n_comp(ops, tel, los_o, c3n); tot_s += _n_emit(ops, u3nc(op_y, u3k(hed))); } @@ -853,29 +871,38 @@ _n_asm(u3_noun ops, c3_s len_s) else { u3_noun cod = u3h(op); switch ( cod ) { + case FRAB: + case FLAB: + case LILB: + case LITB: case SBIP: case SBIN: case KICB: case TICB: - case FRAB: buf_y[i_s--] = (c3_y) u3t(op); buf_y[i_s] = (c3_y) cod; break; - case KICS: - case TICS: case FRAS: + case FLAS: + case LILS: + case LITS: case SKIP: - case SKIN: { + case SKIN: + case KICS: + case TICS: { c3_s off_s = u3t(op); buf_y[i_s--] = (c3_y) (off_s >> 8); buf_y[i_s--] = (c3_y) off_s; buf_y[i_s] = (c3_y) cod; break; } + + case CUSH: case FRAG: - case QUOT: - case QUIP: + case FLAG: + case LILN: + case LITN: case TICK: case KICK: { c3_w non_w = u3k(u3t(op)); @@ -886,6 +913,33 @@ _n_asm(u3_noun ops, c3_s len_s) buf_y[i_s] = (c3_y) cod; break; } + + case SKIB: + case SLIB: { + c3_w non_w = u3k(u3t(u3t(op))); + buf_y[i_s--] = (c3_y) (non_w >> 24); + buf_y[i_s--] = (c3_y) (non_w >> 16); + buf_y[i_s--] = (c3_y) (non_w >> 8); + buf_y[i_s--] = (c3_y) non_w; + buf_y[i_s--] = (c3_y) u3h(u3t(op)); + buf_y[i_s] = (c3_y) cod; + break; + } + + case SKIM: + case SLIM: { + c3_w non_w = u3k(u3t(u3t(op))); + c3_s sip_s = u3h(u3t(op)); + buf_y[i_s--] = (c3_y) (non_w >> 24); + buf_y[i_s--] = (c3_y) (non_w >> 16); + buf_y[i_s--] = (c3_y) (non_w >> 8); + buf_y[i_s--] = (c3_y) non_w; + buf_y[i_s--] = (c3_y) (sip_s >> 8); + buf_y[i_s--] = (c3_y) sip_s; + buf_y[i_s] = (c3_y) cod; + break; + } + default: u3m_bail(c3__exit); return 0; @@ -1051,23 +1105,31 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) { /* OPCODE TABLE */ static void* lab[] = { - &&do_halt, &&do_copy, &&do_toss, - &&do_swap, &&do_swat, - &&do_skip, &&do_skin, - &&do_sbip, &&do_sbin, - &&do_cons, &&do_snoc, - &&do_head, &&do_tail, - &&do_frag, &&do_fras, &&do_frab, - &&do_quot, &&do_quip, - &&do_nock, &&do_noct, - &&do_deep, &&do_peep, - &&do_bump, &&do_same, - &&do_kick, &&do_kics, &&do_kicb, - &&do_tick, &&do_tics, &&do_ticb, - &&do_wish, &&do_fast, + &&do_halt, &&do_bail, + &&do_copy, &&do_swap, &&do_toss, + &&do_auto, &&do_ault, + &&do_head, &&do_held, + &&do_tail, &&do_tall, + &&do_fras, &&do_frag, &&do_frab, + &&do_flas, &&do_flag, &&do_flab, + &&do_litb, &&do_lits, &&do_litn, + &&do_lilb, &&do_lils, &&do_liln, + &&do_nolt, &&do_nolk, + &&do_noct, &&do_nock, + &&do_deep, &&do_bump, + &&do_same, &&do_salm, + &&do_skip, &&do_sbip, + &&do_skin, &&do_sbin, + &&do_snoc, &&do_snol, + &&do_kicb, &&do_kics, &&do_kick, + &&do_ticb, &&do_tics, &&do_tick, + &&do_wils, &&do_wish, &&do_cush, &&do_drop, - &&do_pumo, &&do_gemo, - &&do_heck, &&do_slog, &&do_bail + &&do_heck, &&do_slog, + &&do_falt, &&do_fast, + &&do_skib, &&do_skim, + &&do_slib, &&do_slim, + &&do_save }; c3_s sip_s, ip_s = 0; @@ -1085,7 +1147,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) while ( 1 ) { do_halt: // [product subject ...burnframes...] x = _n_pep(mov, off); - _n_toss(mov); + _n_toss(mov, off); if ( empty == u3R->cap_p ) { return x; } @@ -1099,6 +1161,10 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) BURN(); } + do_bail: + u3m_bail(c3__exit); + return u3_none; + do_copy: top = _n_peek(off); _n_push(mov, off, u3k(*top)); @@ -1116,10 +1182,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) _n_toss(mov, off); BURN(); - do_bail: - u3m_bail(c3__exit); - return u3_none; - do_auto: // [tel bus hed] x = _n_pep(mov, off); // [bus hed] top = _n_swap(mov, off); // [hed bus] @@ -1135,7 +1197,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_head: top = _n_peek(off); - _n_push(u3k(u3h(_n_kale(*top)))); + _n_push(mov, off, u3k(u3h(_n_kale(*top)))); BURN(); do_held: @@ -1147,7 +1209,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_tail: top = _n_peek(off); - _n_push(u3k(u3t(_n_kale(*top)))); + _n_push(mov, off, u3k(u3t(_n_kale(*top)))); BURN(); do_tall: @@ -1169,7 +1231,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) x = pog[ip_s++]; frag_in: top = _n_peek(off); - _n_push(u3k(u3x_at(x, *top))); + _n_push(mov, off, u3k(u3x_at(x, *top))); BURN(); do_flas: @@ -1191,7 +1253,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_lils: _n_toss(mov, off); - do_litb: + do_lits: x = _n_resh(pog, &ip_s); goto quot_in; @@ -1329,7 +1391,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3t_on(noc_o); if ( u3_none == *top ) { u3_noun fol = u3x_at(x, o); - _n_toss(mov); + _n_toss(mov, off); fam = u3to(burnframe, u3R->cap_p) + off + mov; u3R->cap_p = u3of(burnframe, fam); @@ -1433,7 +1495,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_falt: // [pro bus clu] o = _n_pep(mov, off); // [bus clu] - _n_toss(); // [clu] + _n_toss(mov, off); // [clu] top = _n_peek(off); goto fast_in; @@ -1475,7 +1537,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } else { ip_s += sip_s; - _n_push(o); + _n_push(mov, off, o); u3z(x); } BURN(); @@ -1496,24 +1558,33 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) static void _n_print_byc(c3_y* pog) { + // match to OPCODE TABLE static char* names[] = { - "halt", "copy", "toss", - "swap", "swat", - "skip", "skin", - "sbip", "sbin", - "cons", "snoc", - "head", "tail", - "frag", "fras", "frab", - "quot", "quip", - "nock", "noct", - "deep", "peep", - "bump", "same", - "kick", "kics", "kicb", - "tick", "tics", "ticb", - "wish", "fast", + "halt", "bail", + "copy", "swap", "toss", + "auto", "ault", + "head", "held", + "tail", "tall", + "fras", "frag", "frab", + "flas", "flag", "flab", + "litb", "lits", "litn", + "lilb", "lils", "liln", + "nolt", "nolk", + "noct", "nock", + "deep", "bump", + "same", "salm", + "skip", "sbip", + "skin", "sbin", + "snoc", "snol", + "kicb", "kics", "kick", + "ticb", "tics", "tick", + "wils", "wish", "cush", "drop", - "pumo", "gemo", - "heck", "slog", "bail" + "heck", "slog", + "falt", "fast", + "skib", "skim", + "slib", "slim", + "save" }; c3_s ip_s = 0; printf("bytecode: {"); @@ -1530,32 +1601,54 @@ _n_print_byc(c3_y* pog) printf("%s", names[pog[ip_s++]]); break; + case FRAB: + case FLAB: + case LILB: + case LITB: case SBIP: case SBIN: case KICB: case TICB: - case FRAB: printf("[%s ", names[pog[ip_s++]]); printf("%d]", pog[ip_s++]); break; + case FRAS: + case FLAS: + case LILS: + case LITS: + case SKIP: + case SKIN: case KICS: case TICS: - case FRAS: - case SKIP: - case SKIN: printf("[%s ", names[pog[ip_s++]]); printf("%d]", _n_resh(pog, &ip_s)); break; - case QUOT: - case QUIP: - case TICK: + case CUSH: case FRAG: + case FLAG: + case LILN: + case LITN: + case TICK: case KICK: printf("[%s ", names[pog[ip_s++]]); printf("%d]", _n_rean(pog, &ip_s)); break; + + case SKIB: + case SLIB: + printf("[%s", names[pog[ip_s++]]); + printf(" %d ", pog[ip_s++]); + printf("%d]", _n_rean(pog, &ip_s)); + break; + + case SKIM: + case SLIM: + printf("[%s", names[pog[ip_s++]]); + printf(" %d ", _n_resh(pog, &ip_s)); + printf("%d]", _n_rean(pog, &ip_s)); + break; } } printf(" halt}\r\n"); @@ -1573,11 +1666,11 @@ static void _n_print_stack(u3p(u3_noun) empty) { printf(" "); } if ( c3y == u3a_is_north(u3R) ) { - printf("%d", *(u3to(u3_noun, cur_p))); + printf("%x", *(u3to(u3_noun, cur_p))); cur_p++; } else { - printf("%d", *(u3to(u3_noun, cur_p-1))); + printf("%x", *(u3to(u3_noun, cur_p-1))); cur_p--; } } From a8af4dbfb5fb6e395e8a1fd710e7badebc3f5632 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 13 Feb 2018 13:54:56 -0800 Subject: [PATCH 018/221] copy-reduced interpreter can run ackermann --- noun/nock.c | 139 +++++++++++++++++++++++----------------------------- 1 file changed, 62 insertions(+), 77 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 17f7aa298..92d98f98e 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -520,39 +520,38 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define LILB 20 #define LILS 21 #define LILN 22 -#define NOLT 23 -#define NOLK 24 -#define NOCT 25 -#define NOCK 26 -#define DEEP 27 -#define BUMP 28 -#define SAME 29 -#define SALM 30 -#define SKIP 31 -#define SBIP 32 -#define SKIN 33 -#define SBIN 34 -#define SNOC 35 -#define SNOL 36 -#define KICB 37 -#define KICS 38 -#define KICK 39 -#define TICB 40 -#define TICS 41 -#define TICK 42 -#define WILS 43 -#define WISH 44 -#define CUSH 45 -#define DROP 46 -#define HECK 47 -#define SLOG 48 -#define FALT 49 -#define FAST 50 -#define SKIB 51 -#define SKIM 52 -#define SLIB 53 -#define SLIM 54 -#define SAVE 55 +#define NOLK 23 +#define NOCT 24 +#define NOCK 25 +#define DEEP 26 +#define BUMP 27 +#define SAME 28 +#define SALM 29 +#define SKIP 30 +#define SBIP 31 +#define SKIN 32 +#define SBIN 33 +#define SNOC 34 +#define SNOL 35 +#define KICB 36 +#define KICS 37 +#define KICK 38 +#define TICB 39 +#define TICS 40 +#define TICK 41 +#define WILS 42 +#define WISH 43 +#define CUSH 44 +#define DROP 45 +#define HECK 46 +#define SLOG 47 +#define FALT 48 +#define FAST 49 +#define SKIB 50 +#define SKIM 51 +#define SLIB 52 +#define SLIM 53 +#define SAVE 54 /* _n_apen(): emit the instructions contained in src to dst */ @@ -762,9 +761,10 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) tot_s += _n_comp(ops, hed, c3n, c3n); tot_s += _n_emit(ops, SWAP); tot_s += _n_comp(ops, tel, c3n, c3n); - op_y = (c3y == los_o) - ? ((c3y == tel_o) ? NOLT : NOLK) - : ((c3y == tel_o) ? NOCT : NOCK); + /* things in tail position replace (so, lose) top of stack, + * so NOCT "loses" and there is no non-losing version */ + op_y = (c3y == tel_o) ? NOCT + : ((c3y == los_o) ? NOLK : NOCK); tot_s += _n_emit(ops, op_y); break; @@ -787,7 +787,9 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) break; case 6: { - u3_noun mid, yep, nop; + u3_noun mid, + yep = u3_nul, + nop = u3_nul; c3_s yep_s, nop_s; u3x_trel(arg, &hed, &mid, &tel); tot_s += _n_comp(ops, hed, c3n, c3n); @@ -826,7 +828,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) op_y = (c3y == tel_o) ? (hed <= 0xFF ? TICB : hed <= 0xFFFF ? TICS : TICK) : (hed <= 0xFF ? KICB : hed <= 0xFFFF ? KICS : KICK); - tot_s += _n_comp(ops, tel, los_o, c3n); + tot_s += _n_comp(ops, tel, (c3y == tel_o ? c3y : los_o), c3n); tot_s += _n_emit(ops, u3nc(op_y, u3k(hed))); } break; @@ -1042,7 +1044,7 @@ static inline c3_y* _n_bite(u3_noun fol) { u3_noun bok = u3_nul; - c3_s len_s = _n_comp(&bok, fol, c3n, c3y); + c3_s len_s = _n_comp(&bok, fol, c3y, c3y); c3_y* buf_y = _n_asm(bok, len_s); u3m_p("fol", fol); _n_print_byc(buf_y); @@ -1071,8 +1073,8 @@ _n_find(u3_noun fol) static inline u3_noun* _n_swap(c3_ys mov, c3_ys off) { - u3_noun* up = _n_peek(off); - u3_noun* top = _n_peet(mov, off); + u3_noun* top = _n_peek(off); + u3_noun* up = _n_peet(mov, off); u3_noun tmp = *up; *up = *top; *top = tmp; @@ -1114,8 +1116,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) &&do_flas, &&do_flag, &&do_flab, &&do_litb, &&do_lits, &&do_litn, &&do_lilb, &&do_lils, &&do_liln, - &&do_nolt, &&do_nolk, - &&do_noct, &&do_nock, + &&do_nolk, &&do_noct, &&do_nock, &&do_deep, &&do_bump, &&do_same, &&do_salm, &&do_skip, &&do_sbip, @@ -1134,7 +1135,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) c3_s sip_s, ip_s = 0; u3_noun* top; - u3_noun* up; u3_noun x, o; u3p(void) empty; burnframe* fam; @@ -1145,9 +1145,8 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #define BURN() goto *lab[pog[ip_s++]] BURN(); while ( 1 ) { - do_halt: // [product subject ...burnframes...] + do_halt: // [product ...burnframes...] x = _n_pep(mov, off); - _n_toss(mov, off); if ( empty == u3R->cap_p ) { return x; } @@ -1171,11 +1170,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) BURN(); do_swap: - top = _n_peek(off); - up = _n_peet(mov, off); - x = *top; - *top = *up; - *up = x; + _n_swap(mov, off); BURN(); do_toss: @@ -1271,21 +1266,16 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) _n_push(mov, off, u3k(x)); BURN(); - do_nolt: // [fol old bus] + do_noct: // [fol old bus] o = _n_pep(mov, off); // [old bus] _n_toss(mov, off); // [bus] - goto noct_in; + goto nock_out; do_nolk: // [fol old bus] o = _n_pep(mov, off); // [old bus] _n_toss(mov, off); // [bus] goto nock_in; - do_noct: // [fol old bus] - o = _n_pep(mov, off); // [old bus] - _n_swap(mov, off); // [bus old] - goto noct_in; - do_nock: // [fol old bus] o = _n_pep(mov, off); // [old bus] _n_swap(mov, off); // [bus old] @@ -1296,9 +1286,10 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) fam->ip_s = ip_s; fam->pog = pog; _n_push(mov, off, x); - noct_in: + nock_out: pog = _n_find(o); ip_s = 0; + u3z(o); BURN(); do_deep: @@ -1360,17 +1351,13 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_snoc: // [hed tel] x = _n_pep(mov, off); top = _n_peek(off); - *top = u3nc(x, *top); + _n_push(mov, off, u3nc(x, u3k(*top))); BURN(); do_snol: x = _n_pep(mov, off); - o = _n_pep(mov, off); - x = u3nc(x, o); top = _n_peek(off); - o = *top; - *top = x; - u3z(o); + *top = u3nc(x, *top); BURN(); do_kics: @@ -1506,7 +1493,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3t_off(noc_o); u3j_mine(*top, u3k(o)); u3t_on(noc_o); - u3z(*top); *top = o; BURN(); @@ -1569,8 +1555,7 @@ _n_print_byc(c3_y* pog) "flas", "flag", "flab", "litb", "lits", "litn", "lilb", "lils", "liln", - "nolt", "nolk", - "noct", "nock", + "nolk", "noct", "nock", "deep", "bump", "same", "salm", "skip", "sbip", @@ -1610,7 +1595,7 @@ _n_print_byc(c3_y* pog) case KICB: case TICB: printf("[%s ", names[pog[ip_s++]]); - printf("%d]", pog[ip_s++]); + printf("%u]", pog[ip_s++]); break; case FRAS: @@ -1622,7 +1607,7 @@ _n_print_byc(c3_y* pog) case KICS: case TICS: printf("[%s ", names[pog[ip_s++]]); - printf("%d]", _n_resh(pog, &ip_s)); + printf("%u]", _n_resh(pog, &ip_s)); break; case CUSH: @@ -1633,21 +1618,21 @@ _n_print_byc(c3_y* pog) case TICK: case KICK: printf("[%s ", names[pog[ip_s++]]); - printf("%d]", _n_rean(pog, &ip_s)); + printf("%u]", _n_rean(pog, &ip_s)); break; case SKIB: case SLIB: printf("[%s", names[pog[ip_s++]]); - printf(" %d ", pog[ip_s++]); - printf("%d]", _n_rean(pog, &ip_s)); + printf(" %u ", pog[ip_s++]); + printf("%u]", _n_rean(pog, &ip_s)); break; case SKIM: case SLIM: printf("[%s", names[pog[ip_s++]]); - printf(" %d ", _n_resh(pog, &ip_s)); - printf("%d]", _n_rean(pog, &ip_s)); + printf(" %u ", _n_resh(pog, &ip_s)); + printf("%u]", _n_rean(pog, &ip_s)); break; } } @@ -1666,11 +1651,11 @@ static void _n_print_stack(u3p(u3_noun) empty) { printf(" "); } if ( c3y == u3a_is_north(u3R) ) { - printf("%x", *(u3to(u3_noun, cur_p))); + printf("%u", *(u3to(u3_noun, cur_p))); cur_p++; } else { - printf("%x", *(u3to(u3_noun, cur_p-1))); + printf("%u", *(u3to(u3_noun, cur_p-1))); cur_p--; } } From 10413983bae719c31f7ab89fc36d1e044e5b427e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 13 Feb 2018 14:17:47 -0800 Subject: [PATCH 019/221] lit0 and lit1 bytecodes --- noun/nock.c | 118 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 44 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 92d98f98e..a84e45c6a 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -514,44 +514,48 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define FLAS 14 #define FLAG 15 #define FLAB 16 -#define LITB 17 -#define LITS 18 -#define LITN 19 -#define LILB 20 -#define LILS 21 -#define LILN 22 -#define NOLK 23 -#define NOCT 24 -#define NOCK 25 -#define DEEP 26 -#define BUMP 27 -#define SAME 28 -#define SALM 29 -#define SKIP 30 -#define SBIP 31 -#define SKIN 32 -#define SBIN 33 -#define SNOC 34 -#define SNOL 35 -#define KICB 36 -#define KICS 37 -#define KICK 38 -#define TICB 39 -#define TICS 40 -#define TICK 41 -#define WILS 42 -#define WISH 43 -#define CUSH 44 -#define DROP 45 -#define HECK 46 -#define SLOG 47 -#define FALT 48 -#define FAST 49 -#define SKIB 50 -#define SKIM 51 -#define SLIB 52 -#define SLIM 53 -#define SAVE 54 +#define LIT0 17 +#define LIT1 18 +#define LITB 19 +#define LITS 20 +#define LITN 21 +#define LIL0 22 +#define LIL1 23 +#define LILB 24 +#define LILS 25 +#define LILN 26 +#define NOLK 27 +#define NOCT 28 +#define NOCK 29 +#define DEEP 30 +#define BUMP 31 +#define SAME 32 +#define SALM 33 +#define SKIP 34 +#define SBIP 35 +#define SKIN 36 +#define SBIN 37 +#define SNOC 38 +#define SNOL 39 +#define KICB 40 +#define KICS 41 +#define KICK 42 +#define TICB 43 +#define TICS 44 +#define TICK 45 +#define WILS 46 +#define WISH 47 +#define CUSH 48 +#define DROP 49 +#define HECK 50 +#define SLOG 51 +#define FALT 52 +#define FAST 53 +#define SKIB 54 +#define SKIM 55 +#define SLIB 56 +#define SLIM 57 +#define SAVE 58 /* _n_apen(): emit the instructions contained in src to dst */ @@ -750,10 +754,20 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) break; case 1: - op_y = (c3y == los_o) - ? (arg <= 0xFF ? LILB : arg <= 0xFFFF ? LILS : LILN) - : (arg <= 0xFF ? LITB : arg <= 0xFFFF ? LITS : LITN); - tot_s += _n_emit(ops, u3nc(op_y, u3k(arg))); + switch ( arg ) { + case 0: + tot_s += _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); + break; + case 1: + tot_s += _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); + break; + default: + op_y = (c3y == los_o) + ? (arg <= 0xFF ? LILB : arg <= 0xFFFF ? LILS : LILN) + : (arg <= 0xFF ? LITB : arg <= 0xFFFF ? LITS : LITN); + tot_s += _n_emit(ops, u3nc(op_y, u3k(arg))); + break; + } break; case 2: @@ -1114,7 +1128,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) &&do_tail, &&do_tall, &&do_fras, &&do_frag, &&do_frab, &&do_flas, &&do_flag, &&do_flab, + &&do_lit0, &&do_lit1, &&do_litb, &&do_lits, &&do_litn, + &&do_lil0, &&do_lil1, &&do_lilb, &&do_lils, &&do_liln, &&do_nolk, &&do_noct, &&do_nock, &&do_deep, &&do_bump, @@ -1246,6 +1262,18 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); + do_lil0: + _n_toss(mov, off); + do_lit0: + x = 0; + goto quot_in; + + do_lil1: + _n_toss(mov, off); + do_lit1: + x = 1; + goto quot_in; + do_lils: _n_toss(mov, off); do_lits: @@ -1255,7 +1283,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_liln: _n_toss(mov, off); do_litn: - x = _n_rean(pog, &ip_s); + x = u3k(_n_rean(pog, &ip_s)); goto quot_in; do_lilb: @@ -1263,7 +1291,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_litb: x = pog[ip_s++]; quot_in: - _n_push(mov, off, u3k(x)); + _n_push(mov, off, x); BURN(); do_noct: // [fol old bus] @@ -1553,7 +1581,9 @@ _n_print_byc(c3_y* pog) "tail", "tall", "fras", "frag", "frab", "flas", "flag", "flab", + "lit0", "lit1", "litb", "lits", "litn", + "lil0", "lil1", "lilb", "lils", "liln", "nolk", "noct", "nock", "deep", "bump", From 8adc247d48dbd4039eafd291d9ba185e32f5f9f7 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 13 Feb 2018 14:32:32 -0800 Subject: [PATCH 020/221] slam and slat --- noun/nock.c | 72 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index a84e45c6a..36019ca55 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -537,25 +537,27 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SBIN 37 #define SNOC 38 #define SNOL 39 -#define KICB 40 -#define KICS 41 -#define KICK 42 -#define TICB 43 -#define TICS 44 -#define TICK 45 -#define WILS 46 -#define WISH 47 -#define CUSH 48 -#define DROP 49 -#define HECK 50 -#define SLOG 51 -#define FALT 52 -#define FAST 53 -#define SKIB 54 -#define SKIM 55 -#define SLIB 56 -#define SLIM 57 -#define SAVE 58 +#define SLAM 40 +#define KICB 41 +#define KICS 42 +#define KICK 43 +#define SLAT 44 +#define TICB 45 +#define TICS 46 +#define TICK 47 +#define WILS 48 +#define WISH 49 +#define CUSH 50 +#define DROP 51 +#define HECK 52 +#define SLOG 53 +#define FALT 54 +#define FAST 55 +#define SKIB 56 +#define SKIM 57 +#define SLIB 58 +#define SLIM 59 +#define SAVE 60 /* _n_apen(): emit the instructions contained in src to dst */ @@ -839,11 +841,16 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) u3z(mac); } else { - op_y = (c3y == tel_o) - ? (hed <= 0xFF ? TICB : hed <= 0xFFFF ? TICS : TICK) - : (hed <= 0xFF ? KICB : hed <= 0xFFFF ? KICS : KICK); tot_s += _n_comp(ops, tel, (c3y == tel_o ? c3y : los_o), c3n); - tot_s += _n_emit(ops, u3nc(op_y, u3k(hed))); + if ( 2 == hed ) { + tot_s += _n_emit(ops, (c3y == tel_o) ? SLAT : SLAM); + } + else { + op_y = (c3y == tel_o) + ? (hed <= 0xFF ? TICB : hed <= 0xFFFF ? TICS : TICK) + : (hed <= 0xFF ? KICB : hed <= 0xFFFF ? KICS : KICK); + tot_s += _n_emit(ops, u3nc(op_y, u3k(hed))); + } } break; @@ -1138,8 +1145,8 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) &&do_skip, &&do_sbip, &&do_skin, &&do_sbin, &&do_snoc, &&do_snol, - &&do_kicb, &&do_kics, &&do_kick, - &&do_ticb, &&do_tics, &&do_tick, + &&do_slam, &&do_kicb, &&do_kics, &&do_kick, + &&do_slat, &&do_ticb, &&do_tics, &&do_tick, &&do_wils, &&do_wish, &&do_cush, &&do_drop, &&do_heck, &&do_slog, @@ -1397,7 +1404,10 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) goto kick_in; do_kicb: - x = pog[ip_s++]; + x = pog[ip_s++]; + goto kick_in; + do_slam: + x = 2; kick_in: top = _n_peek(off); o = *top; @@ -1428,7 +1438,11 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) goto tick_in; do_ticb: - x = pog[ip_s++]; + x = pog[ip_s++]; + goto tick_in; + + do_slat: + x = 2; tick_in: top = _n_peek(off); o = *top; @@ -1591,8 +1605,8 @@ _n_print_byc(c3_y* pog) "skip", "sbip", "skin", "sbin", "snoc", "snol", - "kicb", "kics", "kick", - "ticb", "tics", "tick", + "slam", "kicb", "kics", "kick", + "slat", "ticb", "tics", "tick", "wils", "wish", "cush", "drop", "heck", "slog", From f0d1ee8d4ffcd36efd74d769685a941c4f908202 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 14 Feb 2018 09:18:53 -0800 Subject: [PATCH 021/221] same-as-literal opcodes --- noun/nock.c | 160 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 121 insertions(+), 39 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 36019ca55..cdec44479 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -529,35 +529,40 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define NOCK 29 #define DEEP 30 #define BUMP 31 -#define SAME 32 -#define SALM 33 -#define SKIP 34 -#define SBIP 35 -#define SKIN 36 -#define SBIN 37 -#define SNOC 38 -#define SNOL 39 -#define SLAM 40 -#define KICB 41 -#define KICS 42 -#define KICK 43 -#define SLAT 44 -#define TICB 45 -#define TICS 46 -#define TICK 47 -#define WILS 48 -#define WISH 49 -#define CUSH 50 -#define DROP 51 -#define HECK 52 -#define SLOG 53 -#define FALT 54 -#define FAST 55 -#define SKIB 56 -#define SKIM 57 -#define SLIB 58 -#define SLIM 59 -#define SAVE 60 +#define SAM0 32 +#define SAM1 33 +#define SAMB 34 +#define SAMS 35 +#define SAMN 36 +#define SAME 37 +#define SALM 38 +#define SKIP 39 +#define SBIP 40 +#define SKIN 41 +#define SBIN 42 +#define SNOC 43 +#define SNOL 44 +#define SLAM 45 +#define KICB 46 +#define KICS 47 +#define KICK 48 +#define SLAT 49 +#define TICB 50 +#define TICS 51 +#define TICK 52 +#define WILS 53 +#define WISH 54 +#define CUSH 55 +#define DROP 56 +#define HECK 57 +#define SLOG 58 +#define FALT 59 +#define FAST 60 +#define SKIB 61 +#define SKIM 62 +#define SLIB 63 +#define SLIM 64 +#define SAVE 65 /* _n_apen(): emit the instructions contained in src to dst */ @@ -583,6 +588,7 @@ _n_emit(u3_noun *ops, u3_noun op) case FLAB: case LILB: case LITB: + case SAMB: case SBIP: case SBIN: case KICB: @@ -593,6 +599,7 @@ _n_emit(u3_noun *ops, u3_noun op) case FLAS: case LILS: case LITS: + case SAMS: case SKIP: case SKIN: case KICS: @@ -604,6 +611,7 @@ _n_emit(u3_noun *ops, u3_noun op) case FLAG: case LILN: case LITN: + case SAMN: case TICK: case KICK: return sizeof(c3_y) + sizeof(u3_noun); @@ -794,13 +802,56 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) tot_s += _n_emit(ops, BUMP); break; - case 5: + case 5: { + c3_t hec_t, tec_t; u3x_cell(arg, &hed, &tel); - tot_s += _n_comp(ops, hed, c3n, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n, c3n); - tot_s += _n_emit(ops, (c3y == los_o) ? SALM : SAME); + + if ( c3n == u3du(hed) ) { + u3m_bail(c3__exit); + break; + } + else { + hec_t = (1 == u3h(hed)); + } + if ( c3n == u3du(tel) ) { + u3m_bail(c3__exit); + break; + } + else { + tec_t = (1 == u3h(tel)); + } + if ( hec_t && tec_t ) { + if ( c3y == u3r_sing(u3t(hed), u3t(tel)) ) { + _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); + } + else { + _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); + } + } + else if ( !hec_t && !tec_t ) { + tot_s += _n_comp(ops, hed, c3n, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n, c3n); + tot_s += _n_emit(ops, (c3y == los_o) ? SALM : SAME); + } + else { + tot_s += _n_comp(ops, (hec_t ? tel : hed), los_o, c3n); + u3_noun lit = u3t(hec_t ? hed : tel); + switch ( lit ) { + case 0: + tot_s += _n_emit(ops, SAM0); + break; + case 1: + tot_s += _n_emit(ops, SAM1); + break; + default: + op_y = lit <= 0xFF ? SAMB : lit <= 0xFFFF ? SAMS : SAMN; + tot_s += _n_emit(ops, u3nc(op_y, u3k(lit))); + } + } + break; + } case 6: { u3_noun mid, @@ -898,6 +949,7 @@ _n_asm(u3_noun ops, c3_s len_s) case FLAB: case LILB: case LITB: + case SAMB: case SBIP: case SBIN: case KICB: @@ -910,6 +962,7 @@ _n_asm(u3_noun ops, c3_s len_s) case FLAS: case LILS: case LITS: + case SAMS: case SKIP: case SKIN: case KICS: @@ -926,6 +979,7 @@ _n_asm(u3_noun ops, c3_s len_s) case FLAG: case LILN: case LITN: + case SAMN: case TICK: case KICK: { c3_w non_w = u3k(u3t(op)); @@ -1141,6 +1195,8 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) &&do_lilb, &&do_lils, &&do_liln, &&do_nolk, &&do_noct, &&do_nock, &&do_deep, &&do_bump, + &&do_sam0, &&do_sam1, + &&do_samb, &&do_sams, &&do_samn, &&do_same, &&do_salm, &&do_skip, &&do_sbip, &&do_skin, &&do_sbin, @@ -1341,21 +1397,45 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_same: - x = _n_pep(mov, off); - top = _n_swap(mov, off); + do_sam1: + x = 1; + goto samd_in; + + do_samb: + x = pog[ip_s++]; + goto samd_in; + + do_sams: + x = _n_resh(pog, &ip_s); + goto samd_in; + + do_sam0: + x = 0; + samd_in: + top = _n_peek(off); o = *top; *top = u3r_sing(x, o); - u3z(o); + u3z(o); // don't bother losing x BURN(); + do_same: + x = _n_pep(mov, off); + _n_swap(mov, off); + goto same_in; + do_salm: - x = _n_pep(mov, off); + x = _n_pep(mov, off); _n_toss(mov, off); + goto same_in; + + do_samn: + x = u3k(_n_rean(pog, &ip_s)); + same_in: top = _n_peek(off); o = *top; *top = u3r_sing(x, o); u3z(o); + u3z(x); BURN(); do_skip: @@ -1601,6 +1681,8 @@ _n_print_byc(c3_y* pog) "lilb", "lils", "liln", "nolk", "noct", "nock", "deep", "bump", + "sam0", "sam1", + "samb", "sams", "samn", "same", "salm", "skip", "sbip", "skin", "sbin", From 2a247cb8599d6c2aa459ba7c7a9962517b614756 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 14 Feb 2018 15:56:00 -0800 Subject: [PATCH 022/221] some bugfixes, can compute memoizing fibonacci --- noun/nock.c | 95 ++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 45 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index cdec44479..b7f4718c3 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -439,6 +439,7 @@ u3n_nock_on(u3_noun bus, u3_noun fol) u3t_off(noc_o); return pro; + //return u3n_burn_on(bus, fol); } /* u3n_kick_on(): fire `gat` without changing the sample. @@ -694,10 +695,10 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) tot_s += _n_emit(ops, TOSS); // SKIM leaves [bus key] on the stack in the unmemoized case - mem_s += _n_comp(&mem, nef, c3n, c3n); + mem_s += _n_comp(&mem, nef, los_o, c3n); // now [pro key bus?], where bus was left on if appropropriate - mem_s += _n_emit(ops, SAVE); + mem_s += _n_emit(&mem, SAVE); op_y = (c3y == los_o) ? (( mem_s <= 0xFF ) ? SLIB : SLIM) @@ -822,10 +823,10 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } if ( hec_t && tec_t ) { if ( c3y == u3r_sing(u3t(hed), u3t(tel)) ) { - _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); + tot_s += _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); } else { - _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); + tot_s += _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); } } else if ( !hec_t && !tec_t ) { @@ -927,6 +928,38 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) static void _n_print_byc(c3_y* pog); +// match to OPCODE TABLE +static char* names[] = { + "halt", "bail", + "copy", "swap", "toss", + "auto", "ault", + "head", "held", + "tail", "tall", + "fras", "frag", "frab", + "flas", "flag", "flab", + "lit0", "lit1", + "litb", "lits", "litn", + "lil0", "lil1", + "lilb", "lils", "liln", + "nolk", "noct", "nock", + "deep", "bump", + "sam0", "sam1", + "samb", "sams", "samn", + "same", "salm", + "skip", "sbip", + "skin", "sbin", + "snoc", "snol", + "slam", "kicb", "kics", "kick", + "slat", "ticb", "tics", "tick", + "wils", "wish", + "cush", "drop", + "heck", "slog", + "falt", "fast", + "skib", "skim", + "slib", "slim", + "save" +}; + /* _n_asm(): assemble an accumulated list of instructions (i.e. from _n_comp) */ static c3_y* @@ -1121,7 +1154,7 @@ _n_bite(u3_noun fol) u3_noun bok = u3_nul; c3_s len_s = _n_comp(&bok, fol, c3y, c3y); c3_y* buf_y = _n_asm(bok, len_s); - u3m_p("fol", fol); + //u3m_p("fol", fol); _n_print_byc(buf_y); return buf_y; } @@ -1325,18 +1358,18 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_lil0: - _n_toss(mov, off); - do_lit0: - x = 0; - goto quot_in; - do_lil1: _n_toss(mov, off); do_lit1: x = 1; goto quot_in; + do_lilb: + _n_toss(mov, off); + do_litb: + x = pog[ip_s++]; + goto quot_in; + do_lils: _n_toss(mov, off); do_lits: @@ -1349,10 +1382,10 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) x = u3k(_n_rean(pog, &ip_s)); goto quot_in; - do_lilb: + do_lil0: _n_toss(mov, off); - do_litb: - x = pog[ip_s++]; + do_lit0: + x = 0; quot_in: _n_push(mov, off, x); BURN(); @@ -1666,37 +1699,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) static void _n_print_byc(c3_y* pog) { - // match to OPCODE TABLE - static char* names[] = { - "halt", "bail", - "copy", "swap", "toss", - "auto", "ault", - "head", "held", - "tail", "tall", - "fras", "frag", "frab", - "flas", "flag", "flab", - "lit0", "lit1", - "litb", "lits", "litn", - "lil0", "lil1", - "lilb", "lils", "liln", - "nolk", "noct", "nock", - "deep", "bump", - "sam0", "sam1", - "samb", "sams", "samn", - "same", "salm", - "skip", "sbip", - "skin", "sbin", - "snoc", "snol", - "slam", "kicb", "kics", "kick", - "slat", "ticb", "tics", "tick", - "wils", "wish", - "cush", "drop", - "heck", "slog", - "falt", "fast", - "skib", "skim", - "slib", "slim", - "save" - }; c3_s ip_s = 0; printf("bytecode: {"); int first = 1; @@ -1716,6 +1718,7 @@ _n_print_byc(c3_y* pog) case FLAB: case LILB: case LITB: + case SAMB: case SBIP: case SBIN: case KICB: @@ -1728,6 +1731,7 @@ _n_print_byc(c3_y* pog) case FLAS: case LILS: case LITS: + case SAMS: case SKIP: case SKIN: case KICS: @@ -1741,6 +1745,7 @@ _n_print_byc(c3_y* pog) case FLAG: case LILN: case LITN: + case SAMN: case TICK: case KICK: printf("[%s ", names[pog[ip_s++]]); From 3943f3fd95c798c9041dbc238d5b32763b59f022 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 18 Feb 2018 12:53:07 -0800 Subject: [PATCH 023/221] some debugging convenience, proper handling of non-cons nock 5, fixed memo coded --- noun/nock.c | 223 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 83 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index b7f4718c3..73cc63950 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -3,6 +3,8 @@ */ #include "all.h" +//#define VERBYC + static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); /* u3_term_io_hija(): hijack console for cooked print. @@ -432,6 +434,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) u3_noun u3n_nock_on(u3_noun bus, u3_noun fol) { + /* u3_noun pro; u3t_on(noc_o); @@ -439,7 +442,8 @@ u3n_nock_on(u3_noun bus, u3_noun fol) u3t_off(noc_o); return pro; - //return u3n_burn_on(bus, fol); + */ + return u3n_burn_on(bus, fol); } /* u3n_kick_on(): fire `gat` without changing the sample. @@ -537,6 +541,7 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SAMN 36 #define SAME 37 #define SALM 38 +#define SAMC 39 #define SKIP 39 #define SBIP 40 #define SKIN 41 @@ -691,20 +696,17 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) c3_s mem_s = 0; c3_y op_y; + // we just throw away the hint (why is this not a static hint?) tot_s += _n_comp(ops, hod, c3n, c3n); tot_s += _n_emit(ops, TOSS); - // SKIM leaves [bus key] on the stack in the unmemoized case - mem_s += _n_comp(&mem, nef, los_o, c3n); - - // now [pro key bus?], where bus was left on if appropropriate + // memoizing code always loses TOS because SAVE needs [pro key] + mem_s += _n_comp(&mem, nef, c3y, c3n); mem_s += _n_emit(&mem, SAVE); op_y = (c3y == los_o) ? (( mem_s <= 0xFF ) ? SLIB : SLIM) : (( mem_s <= 0xFF ) ? SKIB : SKIM); - - // SKIM leaves [pro bus] and SLIM leaves [pro] tot_s += _n_emit(ops, u3nt(op_y, mem_s, u3k(nef))); tot_s += mem_s; _n_apen(ops, mem); break; @@ -804,53 +806,52 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) break; case 5: { - c3_t hec_t, tec_t; u3x_cell(arg, &hed, &tel); if ( c3n == u3du(hed) ) { - u3m_bail(c3__exit); - break; + tot_s += _n_comp(ops, arg, los_o, c3n); + tot_s += _n_emit(ops, SAMC); } else { + c3_t hec_t, tec_t; hec_t = (1 == u3h(hed)); - } - if ( c3n == u3du(tel) ) { - u3m_bail(c3__exit); - break; - } - else { - tec_t = (1 == u3h(tel)); - } - if ( hec_t && tec_t ) { - if ( c3y == u3r_sing(u3t(hed), u3t(tel)) ) { - tot_s += _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); + if ( c3n == u3du(tel) ) { + u3m_bail(c3__exit); + break; } else { - tot_s += _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); + tec_t = (1 == u3h(tel)); + } + if ( hec_t && tec_t ) { + if ( c3y == u3r_sing(u3t(hed), u3t(tel)) ) { + tot_s += _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); + } + else { + tot_s += _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); + } + } + else if ( !hec_t && !tec_t ) { + tot_s += _n_comp(ops, hed, c3n, c3n); + tot_s += _n_emit(ops, SWAP); + tot_s += _n_comp(ops, tel, c3n, c3n); + tot_s += _n_emit(ops, (c3y == los_o) ? SALM : SAME); + } + else { + tot_s += _n_comp(ops, (hec_t ? tel : hed), los_o, c3n); + u3_noun lit = u3t(hec_t ? hed : tel); + switch ( lit ) { + case 0: + tot_s += _n_emit(ops, SAM0); + break; + case 1: + tot_s += _n_emit(ops, SAM1); + break; + default: + op_y = lit <= 0xFF ? SAMB : lit <= 0xFFFF ? SAMS : SAMN; + tot_s += _n_emit(ops, u3nc(op_y, u3k(lit))); + } } } - else if ( !hec_t && !tec_t ) { - tot_s += _n_comp(ops, hed, c3n, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n, c3n); - tot_s += _n_emit(ops, (c3y == los_o) ? SALM : SAME); - } - else { - tot_s += _n_comp(ops, (hec_t ? tel : hed), los_o, c3n); - u3_noun lit = u3t(hec_t ? hed : tel); - switch ( lit ) { - case 0: - tot_s += _n_emit(ops, SAM0); - break; - case 1: - tot_s += _n_emit(ops, SAM1); - break; - default: - op_y = lit <= 0xFF ? SAMB : lit <= 0xFFFF ? SAMS : SAMN; - tot_s += _n_emit(ops, u3nc(op_y, u3k(lit))); - } - } - break; } @@ -926,7 +927,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) return tot_s; } -static void _n_print_byc(c3_y* pog); +static void _n_print_byc(c3_y* pog, c3_s her_s); // match to OPCODE TABLE static char* names[] = { @@ -945,7 +946,7 @@ static char* names[] = { "deep", "bump", "sam0", "sam1", "samb", "sams", "samn", - "same", "salm", + "same", "salm", "samc", "skip", "sbip", "skin", "sbin", "snoc", "snol", @@ -1057,6 +1058,7 @@ _n_asm(u3_noun ops, c3_s len_s) } ops = u3t(ops); } + c3_assert(u3_nul == ops); u3z(top); return buf_y; @@ -1124,7 +1126,7 @@ _n_toss(c3_ys mov, c3_ys off) u3z(_n_pep(mov, off)); } -/* _n_rean(): read a c3_s from the bytecode stream +/* _n_resh(): read a c3_s from the bytecode stream */ static inline c3_s _n_resh(c3_y* buf, c3_s* ip_s) @@ -1134,7 +1136,8 @@ _n_resh(c3_y* buf, c3_s* ip_s) return les | (mos << 8); } -/* _n_rean(): read a noun from the bytecode stream +/* _n_rean(): read a noun from the bytecode stream. + * refcount is NOT incremented. */ static inline u3_noun _n_rean(c3_y* buf, c3_s* ip_s) @@ -1155,7 +1158,8 @@ _n_bite(u3_noun fol) c3_s len_s = _n_comp(&bok, fol, c3y, c3y); c3_y* buf_y = _n_asm(bok, len_s); //u3m_p("fol", fol); - _n_print_byc(buf_y); + //_n_print_byc(buf_y); + //printf("%d bytes\n", len_s); return buf_y; } @@ -1230,7 +1234,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) &&do_deep, &&do_bump, &&do_sam0, &&do_sam1, &&do_samb, &&do_sams, &&do_samn, - &&do_same, &&do_salm, + &&do_same, &&do_salm, &&do_samc, &&do_skip, &&do_sbip, &&do_skin, &&do_sbin, &&do_snoc, &&do_snol, @@ -1254,11 +1258,18 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) empty = u3R->cap_p; _n_push(mov, off, bus); +#ifdef VERBYC + #define BURN() fprintf(stderr, "%s ", names[pog[ip_s]]); goto *lab[pog[ip_s++]] +#else #define BURN() goto *lab[pog[ip_s++]] +#endif BURN(); while ( 1 ) { do_halt: // [product ...burnframes...] x = _n_pep(mov, off); +#ifdef VERBYC + fprintf(stderr, "return\r\n"); +#endif if ( empty == u3R->cap_p ) { return x; } @@ -1269,6 +1280,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3R->cap_p = u3of(burnframe, fam - mov); _n_push(mov, off, x); +#ifdef VERBYC + _n_print_byc(pog, ip_s); +#endif BURN(); } @@ -1413,6 +1427,10 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) nock_out: pog = _n_find(o); ip_s = 0; +#ifdef VERBYC + fprintf(stderr, "\r\nnock jump: %u\r\n", o); + _n_print_byc(pog, ip_s); +#endif u3z(o); BURN(); @@ -1442,6 +1460,10 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) x = _n_resh(pog, &ip_s); goto samd_in; + do_samn: + x = _n_rean(pog, &ip_s); + goto samd_in; + do_sam0: x = 0; samd_in: @@ -1461,8 +1483,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) _n_toss(mov, off); goto same_in; - do_samn: - x = u3k(_n_rean(pog, &ip_s)); same_in: top = _n_peek(off); o = *top; @@ -1471,6 +1491,13 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(x); BURN(); + do_samc: + top = _n_peek(off); + o = *top; + *top = u3r_sing(u3h(o), u3t(o)); + u3z(o); + BURN(); + do_skip: ip_s += _n_resh(pog, &ip_s); BURN(); @@ -1538,8 +1565,18 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) pog = _n_find(fol); ip_s = 0; +#ifdef VERBYC + fprintf(stderr, "\r\nhead kick jump: %u, sp: %p\r\n", fol, top); + _n_print_byc(pog, ip_s); +#endif _n_push(mov, off, o); } +#ifdef VERBYC + else { + fprintf(stderr, "head jet\r\n"); +// u3m_p("head jet", *top); + } +#endif BURN(); do_tics: @@ -1563,11 +1600,21 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) *top = u3j_kick(o, x); u3t_on(noc_o); if ( u3_none == *top ) { - u3_noun fol = u3r_at(x, o); + u3_noun fol = u3x_at(x, o); *top = o; pog = _n_find(fol); ip_s = 0; +#ifdef VERBYC + fprintf(stderr, "\r\ntail kick jump: %u, sp: %p\r\n", fol, top); + _n_print_byc(pog, ip_s); +#endif } +#ifdef VERBYC + else { + fprintf(stderr, "tail jet\r\n"); +// u3m_p("tail jet", *top); + } +#endif BURN(); do_wils: // [gof bus ref] @@ -1655,22 +1702,24 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) sip_s = _n_resh(pog, &ip_s); goto skim_in; + do_skib: + sip_s = pog[ip_s++]; + skim_in: + top = _n_peek(off); + x = u3k(*top); + goto skim_out; + do_slim: sip_s = _n_resh(pog, &ip_s); goto slim_in; do_slib: sip_s = pog[ip_s++]; - goto slim_in; - - do_skib: - sip_s = pog[ip_s++]; - skim_in: - top = _n_peek(off); - _n_push(mov, off, u3k(*top)); slim_in: + x = _n_pep(mov, off); + skim_out: o = _n_rean(pog, &ip_s); - x = u3nc(u3k(o), _n_pep(mov, off)); + x = u3nc(u3k(o), x); o = u3z_find(144 + c3__nock, x); if ( u3_none == o ) { _n_push(mov, off, x); @@ -1697,21 +1746,29 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } static void -_n_print_byc(c3_y* pog) +_n_print_byc(c3_y* pog, c3_s her_s) { c3_s ip_s = 0; - printf("bytecode: {"); + if ( her_s == 0 ) { + fprintf(stderr, "begin: {"); + } + else { + fprintf(stderr, "resume: {"); + } int first = 1; while ( pog[ip_s] ) { if ( first ) { first = 0; } + else if (ip_s == her_s) { + fprintf(stderr, " [*]"); + } else { - printf(" "); + fprintf(stderr, " "); } switch ( pog[ip_s] ) { default: - printf("%s", names[pog[ip_s++]]); + fprintf(stderr, "%s", names[pog[ip_s++]]); break; case FRAB: @@ -1723,8 +1780,8 @@ _n_print_byc(c3_y* pog) case SBIN: case KICB: case TICB: - printf("[%s ", names[pog[ip_s++]]); - printf("%u]", pog[ip_s++]); + fprintf(stderr, "[%s ", names[pog[ip_s++]]); + fprintf(stderr, "%u]", pog[ip_s++]); break; case FRAS: @@ -1736,8 +1793,8 @@ _n_print_byc(c3_y* pog) case SKIN: case KICS: case TICS: - printf("[%s ", names[pog[ip_s++]]); - printf("%u]", _n_resh(pog, &ip_s)); + fprintf(stderr, "[%s ", names[pog[ip_s++]]); + fprintf(stderr, "%u]", _n_resh(pog, &ip_s)); break; case CUSH: @@ -1748,49 +1805,49 @@ _n_print_byc(c3_y* pog) case SAMN: case TICK: case KICK: - printf("[%s ", names[pog[ip_s++]]); - printf("%u]", _n_rean(pog, &ip_s)); + fprintf(stderr, "[%s ", names[pog[ip_s++]]); + fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); break; case SKIB: case SLIB: - printf("[%s", names[pog[ip_s++]]); - printf(" %u ", pog[ip_s++]); - printf("%u]", _n_rean(pog, &ip_s)); + fprintf(stderr, "[%s", names[pog[ip_s++]]); + fprintf(stderr, " %u ", pog[ip_s++]); + fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); break; case SKIM: case SLIM: - printf("[%s", names[pog[ip_s++]]); - printf(" %u ", _n_resh(pog, &ip_s)); - printf("%u]", _n_rean(pog, &ip_s)); + fprintf(stderr, "[%s", names[pog[ip_s++]]); + fprintf(stderr, " %u ", _n_resh(pog, &ip_s)); + fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); break; } } - printf(" halt}\r\n"); + fprintf(stderr, " halt}\r\n"); } static void _n_print_stack(u3p(u3_noun) empty) { c3_w cur_p = u3R->cap_p; - printf("["); + fprintf(stderr, "["); int first = 1; while ( cur_p != empty ) { if ( first ) { first = 0; } else { - printf(" "); + fprintf(stderr, " "); } if ( c3y == u3a_is_north(u3R) ) { - printf("%u", *(u3to(u3_noun, cur_p))); + fprintf(stderr, "%u", *(u3to(u3_noun, cur_p))); cur_p++; } else { - printf("%u", *(u3to(u3_noun, cur_p-1))); + fprintf(stderr, "%u", *(u3to(u3_noun, cur_p-1))); cur_p--; } } - printf("]\r\n"); + fprintf(stderr, "]\r\n"); } /* _n_burn_on(): produce .*(bus fol) with bytecode interpreter From e3ca0ad64bae4c116c7fda18559d2034bc93193a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 18 Feb 2018 12:55:00 -0800 Subject: [PATCH 024/221] renumber opcodes after samc --- noun/nock.c | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 73cc63950..c72d76a62 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -542,33 +542,33 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SAME 37 #define SALM 38 #define SAMC 39 -#define SKIP 39 -#define SBIP 40 -#define SKIN 41 -#define SBIN 42 -#define SNOC 43 -#define SNOL 44 -#define SLAM 45 -#define KICB 46 -#define KICS 47 -#define KICK 48 -#define SLAT 49 -#define TICB 50 -#define TICS 51 -#define TICK 52 -#define WILS 53 -#define WISH 54 -#define CUSH 55 -#define DROP 56 -#define HECK 57 -#define SLOG 58 -#define FALT 59 -#define FAST 60 -#define SKIB 61 -#define SKIM 62 -#define SLIB 63 -#define SLIM 64 -#define SAVE 65 +#define SKIP 40 +#define SBIP 41 +#define SKIN 42 +#define SBIN 43 +#define SNOC 44 +#define SNOL 45 +#define SLAM 46 +#define KICB 47 +#define KICS 48 +#define KICK 49 +#define SLAT 50 +#define TICB 51 +#define TICS 52 +#define TICK 53 +#define WILS 54 +#define WISH 55 +#define CUSH 56 +#define DROP 57 +#define HECK 58 +#define SLOG 59 +#define FALT 60 +#define FAST 61 +#define SKIB 62 +#define SKIM 63 +#define SLIB 64 +#define SLIM 65 +#define SAVE 66 /* _n_apen(): emit the instructions contained in src to dst */ From b95a663b591f1e8deb46a44f586f1d026a4ec519 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 18 Feb 2018 13:10:33 -0800 Subject: [PATCH 025/221] minor improvements to the quote opcode implementation --- noun/nock.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index c72d76a62..74cb654b3 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1372,36 +1372,48 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_lil1: - _n_toss(mov, off); + do_lit0: + _n_push(mov, off, 0); + BURN(); + do_lit1: + _n_push(mov, off, 1); + BURN(); + + do_litb: + _n_push(mov, off, pog[ip_s++]); + BURN(); + + do_lits: + _n_push(mov, off, _n_resh(pog, &ip_s)); + BURN(); + + do_litn: + _n_push(mov, off, u3k(_n_rean(pog, &ip_s))); + BURN(); + + do_lil1: x = 1; - goto quot_in; + goto lil_in; do_lilb: - _n_toss(mov, off); - do_litb: x = pog[ip_s++]; - goto quot_in; + goto lil_in; do_lils: - _n_toss(mov, off); - do_lits: x = _n_resh(pog, &ip_s); - goto quot_in; + goto lil_in; do_liln: - _n_toss(mov, off); - do_litn: x = u3k(_n_rean(pog, &ip_s)); - goto quot_in; + goto lil_in; do_lil0: - _n_toss(mov, off); - do_lit0: x = 0; - quot_in: - _n_push(mov, off, x); + lil_in: + top = _n_peek(off); + u3z(*top); + *top = x; BURN(); do_noct: // [fol old bus] From dc09b2cf70b335c3928cd4e799968be2370e2f6b Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 18 Feb 2018 14:11:44 -0800 Subject: [PATCH 026/221] fix refcounting bug in do_bump --- noun/nock.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 74cb654b3..ca60a6335 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1455,9 +1455,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_bump: top = _n_peek(off); - o = *top; - *top = u3i_vint(o); - u3z(o); + *top = u3i_vint(*top); BURN(); do_sam1: From b08cdcf7fceb5c91b9d764f7f223d419c6e2b2b1 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 18 Feb 2018 15:40:36 -0800 Subject: [PATCH 027/221] correct offsets for south roads --- noun/nock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index ca60a6335..5b5f86371 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1432,7 +1432,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) nock_in: x = _n_pep(mov, off); fam = u3to(burnframe, u3R->cap_p) + off + mov; - u3R->cap_p = u3of(burnframe, fam); + u3R->cap_p = u3of(burnframe, fam - off); fam->ip_s = ip_s; fam->pog = pog; _n_push(mov, off, x); @@ -1569,7 +1569,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) _n_toss(mov, off); fam = u3to(burnframe, u3R->cap_p) + off + mov; - u3R->cap_p = u3of(burnframe, fam); + u3R->cap_p = u3of(burnframe, fam - off); fam->ip_s = ip_s; fam->pog = pog; From 98bb18f28cbac49b05c79ead1edda8fb37365966 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 19 Feb 2018 12:13:59 -0800 Subject: [PATCH 028/221] bytecode promotion, small south road fix --- noun/manage.c | 3 ++- noun/nock.c | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/noun/manage.c b/noun/manage.c index c73781544..b4f77f736 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -799,13 +799,14 @@ u3m_love(u3_noun pro) { u3_noun das = u3R->jed.das; u3p(u3h_root) har_p = u3R->jed.har_p; + u3p(u3h_root) byc_p = u3R->byc.har_p; u3m_fall(); pro = u3a_take(pro); u3j_reap(das, har_p); - u3n_beep(u3R->byc.har_p); + u3n_beep(byc_p); u3R->cap_p = u3R->ear_p; u3R->ear_p = 0; diff --git a/noun/nock.c b/noun/nock.c index 5b5f86371..1efdc8208 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -3,7 +3,7 @@ */ #include "all.h" -//#define VERBYC +#define VERBYC static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); @@ -1168,14 +1168,24 @@ _n_bite(u3_noun fol) static inline c3_y* _n_find(u3_noun fol) { - u3_noun got = u3h_get(u3R->byc.har_p, fol); - if ( u3_none != got ) { - return u3a_into(got); + u3a_road* rod_u = u3R; + + while ( 1 ) { + u3_weak jaw = u3h_gut(rod_u->byc.har_p, fol); + + if ( u3_none != jaw ) { + return u3a_into(jaw); + } + + if ( rod_u->par_p ) { + rod_u = u3to(u3_road, rod_u->par_p); + } + else break; } - else { + + { c3_y* gop = _n_bite(fol); - got = u3a_outa(gop); - u3h_put(u3R->byc.har_p, fol, got); + u3h_put(u3R->byc.har_p, fol, u3a_outa(gop)); return gop; } } @@ -1278,7 +1288,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) pog = fam->pog; ip_s = fam->ip_s; - u3R->cap_p = u3of(burnframe, fam - mov); + u3R->cap_p = u3of(burnframe, fam - (mov+off)); _n_push(mov, off, x); #ifdef VERBYC _n_print_byc(pog, ip_s); @@ -1890,10 +1900,33 @@ u3n_burn_on(u3_noun bus, u3_noun fol) return pro; } +/* _n_reap(): reap key and value from byc table. +*/ +static void +_n_reap(u3_noun kev) +{ + u3_noun fol = u3h(kev); + u3_noun got = u3t(kev); + + if ( _(u3a_left(fol)) ) { + if ( !_(u3a_is_junior(u3R, fol)) && + (u3_none != u3h_git(u3R->byc.har_p, fol)) ) { + fprintf(stderr, "_n_reap: promote collision (fol %x)\r\n", u3r_mug(fol)); + u3m_p("collision", fol); + } + else { + u3_noun lof = u3a_take(fol); + u3_noun tog = u3a_take(got); + u3h_put(u3R->byc.har_p, lof, tog); + u3z(lof); + } + } +} + /* u3n_beep(): promote bytecode state. */ void u3n_beep(u3p(u3h_root) har_p) { - u3m_p("beep", 0); + u3h_walk(har_p, _n_reap); } From 6ab1f076ce75e9a3d0f92f9f584c116e9bd589bb Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 20 Feb 2018 11:28:01 -0800 Subject: [PATCH 029/221] proper bytecode reaping, fix wish --- noun/nock.c | 245 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 144 insertions(+), 101 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 1efdc8208..241084244 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -3,7 +3,7 @@ */ #include "all.h" -#define VERBYC +//#define VERBYC static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); @@ -570,6 +570,38 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SLIM 65 #define SAVE 66 +// match to OPCODE TABLE +static char* names[] = { + "halt", "bail", + "copy", "swap", "toss", + "auto", "ault", + "head", "held", + "tail", "tall", + "fras", "frag", "frab", + "flas", "flag", "flab", + "lit0", "lit1", + "litb", "lits", "litn", + "lil0", "lil1", + "lilb", "lils", "liln", + "nolk", "noct", "nock", + "deep", "bump", + "sam0", "sam1", + "samb", "sams", "samn", + "same", "salm", "samc", + "skip", "sbip", + "skin", "sbin", + "snoc", "snol", + "slam", "kicb", "kics", "kick", + "slat", "ticb", "tics", "tick", + "wils", "wish", + "cush", "drop", + "heck", "slog", + "falt", "fast", + "skib", "skim", + "slib", "slim", + "save" +}; + /* _n_apen(): emit the instructions contained in src to dst */ static inline void @@ -578,6 +610,35 @@ _n_apen(u3_noun* dst, u3_noun src) *dst = u3qb_weld(src, *dst); } +/* _n_emit(): return the size (in bytes) of an opcode's argument + */ +static inline c3_y +_n_arg(c3_y cod_y) +{ + switch ( cod_y ) { + case FRAB: case FLAB: case LILB: case LITB: case SAMB: + case SBIP: case SBIN: case KICB: case TICB: + return sizeof(c3_y); + + case FRAS: case FLAS: case LILS: case LITS: case SAMS: + case SKIP: case SKIN: case KICS: case TICS: + return sizeof(c3_s); + + case CUSH: case FRAG: case FLAG: case LILN: case LITN: + case SAMN: case TICK: case KICK: + return sizeof(u3_noun); + + case SKIM: case SLIM: + return sizeof(c3_s) + sizeof(u3_noun); + + case SKIB: case SLIB: + return sizeof(c3_y) + sizeof(u3_noun); + + default: + return 0; + } +} + /* _n_emit(): emit a single instruction to ops, returning * the size (in bytes) required to store that * opcode. @@ -586,53 +647,7 @@ static inline c3_y _n_emit(u3_noun *ops, u3_noun op) { *ops = u3nc(op, *ops); - if ( c3n == u3du(op) ) { - return sizeof(c3_y); - } - else switch ( u3h(op) ) { - case FRAB: - case FLAB: - case LILB: - case LITB: - case SAMB: - case SBIP: - case SBIN: - case KICB: - case TICB: - return sizeof(c3_y) + sizeof(c3_y); - - case FRAS: - case FLAS: - case LILS: - case LITS: - case SAMS: - case SKIP: - case SKIN: - case KICS: - case TICS: - return sizeof(c3_y) + sizeof(c3_s); - - case CUSH: - case FRAG: - case FLAG: - case LILN: - case LITN: - case SAMN: - case TICK: - case KICK: - return sizeof(c3_y) + sizeof(u3_noun); - - case SKIM: - case SLIM: - return sizeof(c3_y) + sizeof(c3_s) + sizeof(u3_noun); - - case SKIB: - case SLIB: - return sizeof(c3_y) + sizeof(c3_y) + sizeof(u3_noun); - - default: - c3_assert(0); - } + return sizeof(c3_y) + (c3n == u3du(op) ? 0 : _n_arg(u3h(op))); } static c3_s _n_comp(u3_noun*, u3_noun, c3_o, c3_o); @@ -929,37 +944,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) static void _n_print_byc(c3_y* pog, c3_s her_s); -// match to OPCODE TABLE -static char* names[] = { - "halt", "bail", - "copy", "swap", "toss", - "auto", "ault", - "head", "held", - "tail", "tall", - "fras", "frag", "frab", - "flas", "flag", "flab", - "lit0", "lit1", - "litb", "lits", "litn", - "lil0", "lil1", - "lilb", "lils", "liln", - "nolk", "noct", "nock", - "deep", "bump", - "sam0", "sam1", - "samb", "sams", "samn", - "same", "salm", "samc", - "skip", "sbip", - "skin", "sbin", - "snoc", "snol", - "slam", "kicb", "kics", "kick", - "slat", "ticb", "tics", "tick", - "wils", "wish", - "cush", "drop", - "heck", "slog", - "falt", "fast", - "skib", "skim", - "slib", "slim", - "save" -}; /* _n_asm(): assemble an accumulated list of instructions (i.e. from _n_comp) */ @@ -1637,18 +1621,18 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #endif BURN(); - do_wils: // [gof bus ref] - o = _n_pep(mov,off); // [bus ref] - _n_toss(mov, off); // [ref] + do_wils: // [gof bus ref] + o = _n_pep(mov,off); // [bus ref] + _n_toss(mov, off); // [ref] top = _n_peek(off); goto wish_in; - do_wish: // [gof bus ref] - o = _n_pep(mov,off); // [bus ref] - top = _n_swap(mov, off); // [ref bus] + do_wish: // [gof bus ref] + o = _n_pep(mov,off); // [bus ref] + top = _n_swap(mov, off); // [ref bus] wish_in: u3t_off(noc_o); - x = u3m_soft_esc(u3k(o), *top); + x = u3m_soft_esc(*top, u3k(o)); u3t_on(noc_o); if ( c3n == u3du(x) ) { @@ -1739,11 +1723,11 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) x = _n_pep(mov, off); skim_out: o = _n_rean(pog, &ip_s); - x = u3nc(u3k(o), x); + x = u3nc(x, u3k(o)); o = u3z_find(144 + c3__nock, x); if ( u3_none == o ) { _n_push(mov, off, x); - _n_push(mov, off, u3k(u3t(x))); + _n_push(mov, off, u3k(u3h(x))); } else { ip_s += sip_s; @@ -1887,7 +1871,8 @@ _n_burn_on(u3_noun bus, u3_noun fol) mov = 1; off = -1; } - return _n_burn(pog, bus, mov, off); + u3_noun pro = _n_burn(pog, bus, mov, off); + return pro; } u3_noun @@ -1900,6 +1885,66 @@ u3n_burn_on(u3_noun bus, u3_noun fol) return pro; } +/* _n_take_byc(): copy bytecode from a junior road + */ +static c3_y* +_n_take_byc(c3_y* pog) +{ + u3_noun x; + c3_s sax_s, ip_s, len_s; + c3_y* gop, cod_y; + + // measure + for ( ip_s = 0; (cod_y = pog[ip_s]) != HALT; ++ip_s ) { + ip_s += _n_arg(cod_y); + } + len_s = ip_s + 1; + + gop = u3a_malloc(len_s); + for ( ip_s = 0; ip_s < len_s; ) { + cod_y = gop[ip_s] = pog[ip_s]; + x = u3_none; + sax_s = ip_s + 1; + switch ( cod_y ) { + default: + sax_s += _n_arg(cod_y); + break; + + case CUSH: case FRAG: case FLAG: case LILN: case LITN: + case SAMN: case TICK: case KICK: + x = _n_rean(pog, &sax_s); + break; + + case SKIB: case SLIB: + sax_s += sizeof(c3_y); + x = _n_rean(pog, &sax_s); + break; + + case SKIM: case SLIM: + sax_s += sizeof(c3_s); + x = _n_rean(pog, &sax_s); + break; + } + if ( u3_none != x ) { + if ( c3y == u3a_is_junior(u3R, x) ) { + x = u3a_take(x); + } + gop[ip_s++] = cod_y; + gop[ip_s++] = (c3_y) x; + gop[ip_s++] = (c3_y) (x >> 8); + gop[ip_s++] = (c3_y) (x >> 16); + gop[ip_s++] = (c3_y) (x >> 24); + } + else { + while ( ip_s < sax_s ) { + gop[ip_s] = pog[ip_s]; + ++ip_s; + } + } + } + return gop; +} + /* _n_reap(): reap key and value from byc table. */ static void @@ -1907,19 +1952,17 @@ _n_reap(u3_noun kev) { u3_noun fol = u3h(kev); u3_noun got = u3t(kev); + c3_y* pog = u3a_into(got); + c3_y* gop = _n_take_byc(pog); + u3_noun tog = u3a_outa(gop); - if ( _(u3a_left(fol)) ) { - if ( !_(u3a_is_junior(u3R, fol)) && - (u3_none != u3h_git(u3R->byc.har_p, fol)) ) { - fprintf(stderr, "_n_reap: promote collision (fol %x)\r\n", u3r_mug(fol)); - u3m_p("collision", fol); - } - else { - u3_noun lof = u3a_take(fol); - u3_noun tog = u3a_take(got); - u3h_put(u3R->byc.har_p, lof, tog); - u3z(lof); - } + if ( c3y == u3a_is_junior(u3R, fol) ) { + u3_noun lof = u3a_take(fol); + u3h_put(u3R->byc.har_p, lof, tog); + u3z(lof); + } + else { + u3h_put(u3R->byc.har_p, fol, tog); } } From d3bfebdd1adc19d7783522533f63a2d680f80606 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 20 Feb 2018 12:13:14 -0800 Subject: [PATCH 030/221] always take in bytecode reap --- noun/nock.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 241084244..006398d07 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1926,9 +1926,7 @@ _n_take_byc(c3_y* pog) break; } if ( u3_none != x ) { - if ( c3y == u3a_is_junior(u3R, x) ) { - x = u3a_take(x); - } + x = u3a_take(x); gop[ip_s++] = cod_y; gop[ip_s++] = (c3_y) x; gop[ip_s++] = (c3_y) (x >> 8); @@ -1955,15 +1953,9 @@ _n_reap(u3_noun kev) c3_y* pog = u3a_into(got); c3_y* gop = _n_take_byc(pog); u3_noun tog = u3a_outa(gop); - - if ( c3y == u3a_is_junior(u3R, fol) ) { - u3_noun lof = u3a_take(fol); - u3h_put(u3R->byc.har_p, lof, tog); - u3z(lof); - } - else { - u3h_put(u3R->byc.har_p, fol, tog); - } + u3_noun lof = u3a_take(fol); + u3h_put(u3R->byc.har_p, lof, tog); + u3z(lof); } /* u3n_beep(): promote bytecode state. From fad4db8b6696eff097bce34aff9e4459f828df2e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 20 Feb 2018 12:57:59 -0800 Subject: [PATCH 031/221] commenting out and moving around some debugging code, boot is working --- include/noun/nock.h | 4 +- noun/nock.c | 127 +++++++++++++++++++++----------------------- 2 files changed, 65 insertions(+), 66 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index c1b30515a..01826582a 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -9,10 +9,12 @@ u3_noun u3n_nock_on(u3_noun bus, u3_noun fol); - /* u3n_burn_on(): TEMPORARY: produce .*(bus fol) with bytecode interpreter. +#if 0 + /* u3n_burn_on(): produce .*(bus fol) with bytecode interpreter. */ u3_noun u3n_burn_on(u3_noun bus, u3_noun fol); +#endif /* u3n_slam_on(): produce (gat sam). */ diff --git a/noun/nock.c b/noun/nock.c index 006398d07..31cb0d37a 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -3,9 +3,8 @@ */ #include "all.h" -//#define VERBYC - static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); +static u3_noun _n_burn_on(u3_noun bus, u3_noun fol); /* u3_term_io_hija(): hijack console for cooked print. */ @@ -434,16 +433,14 @@ _n_nock_on(u3_noun bus, u3_noun fol) u3_noun u3n_nock_on(u3_noun bus, u3_noun fol) { - /* u3_noun pro; u3t_on(noc_o); - pro = _n_nock_on(bus, fol); + //pro = _n_nock_on(bus, fol); + pro = _n_burn_on(bus, fol); u3t_off(noc_o); return pro; - */ - return u3n_burn_on(bus, fol); } /* u3n_kick_on(): fire `gat` without changing the sample. @@ -570,6 +567,7 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SLIM 65 #define SAVE 66 +#ifdef VERBYC // match to OPCODE TABLE static char* names[] = { "halt", "bail", @@ -601,6 +599,7 @@ static char* names[] = { "slib", "slim", "save" }; +#endif /* _n_apen(): emit the instructions contained in src to dst */ @@ -942,8 +941,9 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) return tot_s; } +#ifdef VERBYC static void _n_print_byc(c3_y* pog, c3_s her_s); - +#endif /* _n_asm(): assemble an accumulated list of instructions (i.e. from _n_comp) */ @@ -963,28 +963,16 @@ _n_asm(u3_noun ops, c3_s len_s) else { u3_noun cod = u3h(op); switch ( cod ) { - case FRAB: - case FLAB: - case LILB: - case LITB: - case SAMB: - case SBIP: - case SBIN: - case KICB: - case TICB: + case FRAB: case FLAB: case LILB: case LITB: + case SAMB: case SBIP: case SBIN: + case KICB: case TICB: buf_y[i_s--] = (c3_y) u3t(op); buf_y[i_s] = (c3_y) cod; break; - case FRAS: - case FLAS: - case LILS: - case LITS: - case SAMS: - case SKIP: - case SKIN: - case KICS: - case TICS: { + case FRAS: case FLAS: case LILS: case LITS: + case SAMS: case SKIP: case SKIN: + case KICS: case TICS: { c3_s off_s = u3t(op); buf_y[i_s--] = (c3_y) (off_s >> 8); buf_y[i_s--] = (c3_y) off_s; @@ -992,14 +980,9 @@ _n_asm(u3_noun ops, c3_s len_s) break; } - case CUSH: - case FRAG: - case FLAG: - case LILN: - case LITN: - case SAMN: - case TICK: - case KICK: { + case CUSH: case FRAG: case FLAG: + case LILN: case LITN: + case SAMN: case TICK: case KICK: { c3_w non_w = u3k(u3t(op)); buf_y[i_s--] = (c3_y) (non_w >> 24); buf_y[i_s--] = (c3_y) (non_w >> 16); @@ -1009,8 +992,7 @@ _n_asm(u3_noun ops, c3_s len_s) break; } - case SKIB: - case SLIB: { + case SKIB: case SLIB: { c3_w non_w = u3k(u3t(u3t(op))); buf_y[i_s--] = (c3_y) (non_w >> 24); buf_y[i_s--] = (c3_y) (non_w >> 16); @@ -1021,8 +1003,7 @@ _n_asm(u3_noun ops, c3_s len_s) break; } - case SKIM: - case SLIM: { + case SKIM: case SLIM: { c3_w non_w = u3k(u3t(u3t(op))); c3_s sip_s = u3h(u3t(op)); buf_y[i_s--] = (c3_y) (non_w >> 24); @@ -1042,6 +1023,8 @@ _n_asm(u3_noun ops, c3_s len_s) } ops = u3t(ops); } + // this will trigger if we ever have a nock formula that compiles to more + // than 2^16 opcodes. if needed, ip can be a c3_w. c3_assert(u3_nul == ops); u3z(top); @@ -1141,9 +1124,6 @@ _n_bite(u3_noun fol) u3_noun bok = u3_nul; c3_s len_s = _n_comp(&bok, fol, c3y, c3y); c3_y* buf_y = _n_asm(bok, len_s); - //u3m_p("fol", fol); - //_n_print_byc(buf_y); - //printf("%d bytes\n", len_s); return buf_y; } @@ -1203,6 +1183,11 @@ typedef struct { c3_s ip_s; } burnframe; +/* defining this will cause the bytecode interpreter to print out every opcode + * as it executes, along with some other information. very spammy. + * #define VERBYC + */ + /* _n_burn(): pog: program * bus: subject * mov: -1 north, 1 south @@ -1578,7 +1563,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #ifdef VERBYC else { fprintf(stderr, "head jet\r\n"); -// u3m_p("head jet", *top); } #endif BURN(); @@ -1616,7 +1600,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #ifdef VERBYC else { fprintf(stderr, "tail jet\r\n"); -// u3m_p("tail jet", *top); } #endif BURN(); @@ -1749,6 +1732,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } } +#ifdef VERBYC +/* _n_print_byc(): print bytecode. used for debugging. + */ static void _n_print_byc(c3_y* pog, c3_s her_s) { @@ -1830,29 +1816,7 @@ _n_print_byc(c3_y* pog, c3_s her_s) } fprintf(stderr, " halt}\r\n"); } - -static void _n_print_stack(u3p(u3_noun) empty) { - c3_w cur_p = u3R->cap_p; - fprintf(stderr, "["); - int first = 1; - while ( cur_p != empty ) { - if ( first ) { - first = 0; - } - else { - fprintf(stderr, " "); - } - if ( c3y == u3a_is_north(u3R) ) { - fprintf(stderr, "%u", *(u3to(u3_noun, cur_p))); - cur_p++; - } - else { - fprintf(stderr, "%u", *(u3to(u3_noun, cur_p-1))); - cur_p--; - } - } - fprintf(stderr, "]\r\n"); -} +#endif /* _n_burn_on(): produce .*(bus fol) with bytecode interpreter */ @@ -1875,6 +1839,10 @@ _n_burn_on(u3_noun bus, u3_noun fol) return pro; } +#if 0 +/* u3n_burn_on(): useful for distinguishing the bytecode interpreter from the + * tree-walking interpreter. + */ u3_noun u3n_burn_on(u3_noun bus, u3_noun fol) { @@ -1884,6 +1852,7 @@ u3n_burn_on(u3_noun bus, u3_noun fol) u3t_off(noc_o); return pro; } +#endif /* _n_take_byc(): copy bytecode from a junior road */ @@ -1965,3 +1934,31 @@ u3n_beep(u3p(u3h_root) har_p) { u3h_walk(har_p, _n_reap); } + +#if 0 +/* _n_print_stack(): print out the cap stack up to a designated "empty" + * used only for debugging + */ +static void _n_print_stack(u3p(u3_noun) empty) { + c3_w cur_p = u3R->cap_p; + fprintf(stderr, "["); + int first = 1; + while ( cur_p != empty ) { + if ( first ) { + first = 0; + } + else { + fprintf(stderr, " "); + } + if ( c3y == u3a_is_north(u3R) ) { + fprintf(stderr, "%u", *(u3to(u3_noun, cur_p))); + cur_p++; + } + else { + fprintf(stderr, "%u", *(u3to(u3_noun, cur_p-1))); + cur_p--; + } + } + fprintf(stderr, "]\r\n"); +} +#endif From 03ae2dfffcd5ae24fc1581d294f12da59239e2e7 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 20 Feb 2018 13:41:09 -0800 Subject: [PATCH 032/221] nox_d bumps in appropriate places, remove superfluous while --- noun/nock.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/noun/nock.c b/noun/nock.c index 31cb0d37a..1c8b6769c 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1237,13 +1237,16 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) empty = u3R->cap_p; _n_push(mov, off, bus); +#ifdef U3_CPU_DEBUG + u3R->pro.nox_d += 1; +#endif #ifdef VERBYC #define BURN() fprintf(stderr, "%s ", names[pog[ip_s]]); goto *lab[pog[ip_s++]] #else #define BURN() goto *lab[pog[ip_s++]] #endif BURN(); - while ( 1 ) { + { do_halt: // [product ...burnframes...] x = _n_pep(mov, off); #ifdef VERBYC @@ -1418,6 +1421,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) nock_out: pog = _n_find(o); ip_s = 0; +#ifdef U3_CPU_DEBUG + u3R->pro.nox_d += 1; +#endif #ifdef VERBYC fprintf(stderr, "\r\nnock jump: %u\r\n", o); _n_print_byc(pog, ip_s); @@ -1554,6 +1560,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) pog = _n_find(fol); ip_s = 0; +#ifdef U3_CPU_DEBUG + u3R->pro.nox_d += 1; +#endif #ifdef VERBYC fprintf(stderr, "\r\nhead kick jump: %u, sp: %p\r\n", fol, top); _n_print_byc(pog, ip_s); @@ -1592,6 +1601,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) *top = o; pog = _n_find(fol); ip_s = 0; +#ifdef U3_CPU_DEBUG + u3R->pro.nox_d += 1; +#endif #ifdef VERBYC fprintf(stderr, "\r\ntail kick jump: %u, sp: %p\r\n", fol, top); _n_print_byc(pog, ip_s); From adb9a4e437e90c97f35073533e247aa9ab623b82 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 22 Feb 2018 11:42:29 -0800 Subject: [PATCH 033/221] recompiling when reaping solves generator issues --- noun/nock.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 1c8b6769c..719de9291 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -567,7 +567,11 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SLIM 65 #define SAVE 66 -#ifdef VERBYC +/* defining this will cause the bytecode interpreter to print out every opcode + * as it executes, along with some other information. very spammy. + */ + +#if 1 // match to OPCODE TABLE static char* names[] = { "halt", "bail", @@ -941,7 +945,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) return tot_s; } -#ifdef VERBYC +#if 1 static void _n_print_byc(c3_y* pog, c3_s her_s); #endif @@ -1183,11 +1187,6 @@ typedef struct { c3_s ip_s; } burnframe; -/* defining this will cause the bytecode interpreter to print out every opcode - * as it executes, along with some other information. very spammy. - * #define VERBYC - */ - /* _n_burn(): pog: program * bus: subject * mov: -1 north, 1 south @@ -1744,7 +1743,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } } -#ifdef VERBYC +#if 1 /* _n_print_byc(): print bytecode. used for debugging. */ static void @@ -1866,6 +1865,10 @@ u3n_burn_on(u3_noun bus, u3_noun fol) } #endif +#if 0 +// FIXME: we could avoid recompiling by traversing the bytecode and copying +// out quoted nouns, but u3a_take() is complicated and we haven't +// gotten it to work right yet. /* _n_take_byc(): copy bytecode from a junior road */ static c3_y* @@ -1907,7 +1910,16 @@ _n_take_byc(c3_y* pog) break; } if ( u3_none != x ) { - x = u3a_take(x); + if ( c3y == u3a_left(x) ) { + x = u3a_take(x); + } + else { + // TRICKY: new location is stored in mug, relies on u3a internals + u3m_p("relocating", x); + u3a_noun* dog_u = u3a_to_ptr(x); + x = u3a_take(dog_u->mug_w); + u3m_p("relocated", x); + } gop[ip_s++] = cod_y; gop[ip_s++] = (c3_y) x; gop[ip_s++] = (c3_y) (x >> 8); @@ -1923,6 +1935,7 @@ _n_take_byc(c3_y* pog) } return gop; } +#endif /* _n_reap(): reap key and value from byc table. */ @@ -1930,12 +1943,14 @@ static void _n_reap(u3_noun kev) { u3_noun fol = u3h(kev); - u3_noun got = u3t(kev); - c3_y* pog = u3a_into(got); - c3_y* gop = _n_take_byc(pog); - u3_noun tog = u3a_outa(gop); + //u3_noun got = u3t(kev); + //c3_y* pog = u3a_into(got); + //c3_y* gop = _n_take_byc(pog); + //u3_noun tog = u3a_outa(gop); u3_noun lof = u3a_take(fol); - u3h_put(u3R->byc.har_p, lof, tog); + // recompile rather than traverse bytecode, simpler + u3h_put(u3R->byc.har_p, lof, u3a_outa(_n_bite(lof))); + //u3h_put(u3R->byc.har_p, lof, tog); u3z(lof); } @@ -1947,7 +1962,7 @@ u3n_beep(u3p(u3h_root) har_p) u3h_walk(har_p, _n_reap); } -#if 0 +#if 1 /* _n_print_stack(): print out the cap stack up to a designated "empty" * used only for debugging */ From 910154b140d2758aa5cc4e718cc874dbc4bf7344 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 22 Feb 2018 13:33:27 -0800 Subject: [PATCH 034/221] reaping actual bytecodes instead of recompiling --- noun/nock.c | 84 ++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 49 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 719de9291..018d09654 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -571,7 +571,7 @@ u3n_nock_an(u3_noun bus, u3_noun fol) * as it executes, along with some other information. very spammy. */ -#if 1 +#if 0 // match to OPCODE TABLE static char* names[] = { "halt", "bail", @@ -945,7 +945,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) return tot_s; } -#if 1 +#if 0 static void _n_print_byc(c3_y* pog, c3_s her_s); #endif @@ -1743,7 +1743,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } } -#if 1 +#if 0 /* _n_print_byc(): print bytecode. used for debugging. */ static void @@ -1865,17 +1865,29 @@ u3n_burn_on(u3_noun bus, u3_noun fol) } #endif -#if 0 -// FIXME: we could avoid recompiling by traversing the bytecode and copying -// out quoted nouns, but u3a_take() is complicated and we haven't -// gotten it to work right yet. +static void +_n_take_narg(c3_y* pog, c3_y* gop, c3_s sip_s, c3_s* ip_s) +{ + c3_s i_s; + while ( sip_s-- > 0 ) { + gop[*ip_s] = pog[*ip_s]; + *ip_s += 1; + } + u3_noun x = u3a_take(_n_rean(pog, ip_s)); + i_s = *ip_s; + gop[--i_s] = (c3_y) (x >> 24); + gop[--i_s] = (c3_y) (x >> 16); + gop[--i_s] = (c3_y) (x >> 8); + gop[--i_s] = (c3_y) x; +} + /* _n_take_byc(): copy bytecode from a junior road */ static c3_y* _n_take_byc(c3_y* pog) { - u3_noun x; - c3_s sax_s, ip_s, len_s; + c3_y i_y; + c3_s ip_s, len_s; c3_y* gop, cod_y; // measure @@ -1887,55 +1899,31 @@ _n_take_byc(c3_y* pog) gop = u3a_malloc(len_s); for ( ip_s = 0; ip_s < len_s; ) { cod_y = gop[ip_s] = pog[ip_s]; - x = u3_none; - sax_s = ip_s + 1; + ip_s += 1; switch ( cod_y ) { default: - sax_s += _n_arg(cod_y); + for ( i_y = _n_arg(cod_y); i_y > 0; --i_y ) { + gop[ip_s] = pog[ip_s]; + ip_s += 1; + } break; case CUSH: case FRAG: case FLAG: case LILN: case LITN: case SAMN: case TICK: case KICK: - x = _n_rean(pog, &sax_s); + _n_take_narg(pog, gop, 0, &ip_s); break; case SKIB: case SLIB: - sax_s += sizeof(c3_y); - x = _n_rean(pog, &sax_s); + _n_take_narg(pog, gop, 1, &ip_s); break; case SKIM: case SLIM: - sax_s += sizeof(c3_s); - x = _n_rean(pog, &sax_s); + _n_take_narg(pog, gop, 2, &ip_s); break; } - if ( u3_none != x ) { - if ( c3y == u3a_left(x) ) { - x = u3a_take(x); - } - else { - // TRICKY: new location is stored in mug, relies on u3a internals - u3m_p("relocating", x); - u3a_noun* dog_u = u3a_to_ptr(x); - x = u3a_take(dog_u->mug_w); - u3m_p("relocated", x); - } - gop[ip_s++] = cod_y; - gop[ip_s++] = (c3_y) x; - gop[ip_s++] = (c3_y) (x >> 8); - gop[ip_s++] = (c3_y) (x >> 16); - gop[ip_s++] = (c3_y) (x >> 24); - } - else { - while ( ip_s < sax_s ) { - gop[ip_s] = pog[ip_s]; - ++ip_s; - } - } } return gop; } -#endif /* _n_reap(): reap key and value from byc table. */ @@ -1943,14 +1931,12 @@ static void _n_reap(u3_noun kev) { u3_noun fol = u3h(kev); - //u3_noun got = u3t(kev); - //c3_y* pog = u3a_into(got); - //c3_y* gop = _n_take_byc(pog); - //u3_noun tog = u3a_outa(gop); + u3_noun got = u3t(kev); u3_noun lof = u3a_take(fol); - // recompile rather than traverse bytecode, simpler - u3h_put(u3R->byc.har_p, lof, u3a_outa(_n_bite(lof))); - //u3h_put(u3R->byc.har_p, lof, tog); + c3_y* pog = u3a_into(got); + c3_y* gop = _n_take_byc(pog); + u3_noun tog = u3a_outa(gop); + u3h_put(u3R->byc.har_p, lof, tog); u3z(lof); } @@ -1962,7 +1948,7 @@ u3n_beep(u3p(u3h_root) har_p) u3h_walk(har_p, _n_reap); } -#if 1 +#if 0 /* _n_print_stack(): print out the cap stack up to a designated "empty" * used only for debugging */ From 7fc59254e4e1e6e6d463c4f13de4b94dd207572a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 22 Feb 2018 14:21:33 -0800 Subject: [PATCH 035/221] slightly improve special sam opcodes --- noun/nock.c | 55 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 018d09654..d013fed95 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1442,29 +1442,55 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) *top = u3i_vint(*top); BURN(); + do_sam0: + top = _n_peek(off); + if ( *top == 0 ) { + *top = c3y; + } + else { + u3z(*top); + *top = c3n; + } + BURN(); + do_sam1: - x = 1; - goto samd_in; + top = _n_peek(off); + if ( *top == 1 ) { + *top = c3y; + } + else { + u3z(*top); + *top = c3n; + } + BURN(); do_samb: - x = pog[ip_s++]; - goto samd_in; + top = _n_peek(off); + if ( *top == pog[ip_s++] ) { + *top = c3y; + } + else { + u3z(*top); + *top = c3n; + } + BURN(); do_sams: - x = _n_resh(pog, &ip_s); - goto samd_in; + top = _n_peek(off); + if ( *top == _n_resh(pog, &ip_s) ) { + *top = c3y; + } + else { + u3z(*top); + *top = c3n; + } + BURN(); do_samn: - x = _n_rean(pog, &ip_s); - goto samd_in; - - do_sam0: - x = 0; - samd_in: top = _n_peek(off); o = *top; - *top = u3r_sing(x, o); - u3z(o); // don't bother losing x + *top = u3r_sing(o, _n_rean(pog, &ip_s)); + u3z(o); BURN(); do_same: @@ -1865,6 +1891,7 @@ u3n_burn_on(u3_noun bus, u3_noun fol) } #endif +/* _n_take_narg(): helper for copying noun-parts of bytecode */ static void _n_take_narg(c3_y* pog, c3_y* gop, c3_s sip_s, c3_s* ip_s) { From 5490a4c4cf567609a5e520e4e82842db917a79a6 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 5 Mar 2018 11:12:18 -0800 Subject: [PATCH 036/221] stash --- noun/manage.c | 6 ++++++ noun/nock.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/noun/manage.c b/noun/manage.c index b4f77f736..6215e7cb1 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -1673,6 +1673,12 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, */ u3j_boot(); +#ifdef TREE_NOCK + printf("nock: tree\r\n"); +#else + printf("nock: bytecode\r\n"); +#endif + /* Install or reactivate the kernel. */ if ( _(nuu_o) ) { diff --git a/noun/nock.c b/noun/nock.c index d013fed95..dda1a2090 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -436,8 +436,11 @@ u3n_nock_on(u3_noun bus, u3_noun fol) u3_noun pro; u3t_on(noc_o); - //pro = _n_nock_on(bus, fol); +#ifdef TREE_NOCK + pro = _n_nock_on(bus, fol); +#else pro = _n_burn_on(bus, fol); +#endif u3t_off(noc_o); return pro; From 6aa498ab94639b6ed48ae2bd7b57f24726828aec Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 5 Mar 2018 13:38:34 -0800 Subject: [PATCH 037/221] fix memory leak in bytecode compiler --- noun/nock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noun/nock.c b/noun/nock.c index dda1a2090..f6505a23a 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -613,7 +613,7 @@ static char* names[] = { static inline void _n_apen(u3_noun* dst, u3_noun src) { - *dst = u3qb_weld(src, *dst); + *dst = u3kb_weld(src, *dst); } /* _n_emit(): return the size (in bytes) of an opcode's argument From 42c460ed3b68c938257331f887037eef7e6a9a45 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 9 Mar 2018 16:04:47 -0800 Subject: [PATCH 038/221] midway through adding making for bytecode --- include/noun/nock.h | 4 +++ noun/manage.c | 8 +---- noun/nock.c | 77 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 76 insertions(+), 13 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 01826582a..3d1297f78 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -64,3 +64,7 @@ /* u3n_beep(): promote bytecode state. */ void u3n_beep(u3p(u3h_root) har_p); + + /* u3n_bark(): mark bytecode cache. + */ + c3_w u3n_bark(); diff --git a/noun/manage.c b/noun/manage.c index 6215e7cb1..3acf06af9 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -470,7 +470,7 @@ u3m_mark(void) { c3_w tot_w = 0; tot_w += u3h_mark(u3R->jed.har_p); - tot_w += u3h_mark(u3R->byc.har_p); + tot_w += u3n_bark(); tot_w += u3a_mark_noun(u3R->jed.das); tot_w += u3a_mark_noun(u3R->ski.gul); tot_w += u3a_mark_noun(u3R->bug.tax); @@ -1673,12 +1673,6 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, */ u3j_boot(); -#ifdef TREE_NOCK - printf("nock: tree\r\n"); -#else - printf("nock: bytecode\r\n"); -#endif - /* Install or reactivate the kernel. */ if ( _(nuu_o) ) { diff --git a/noun/nock.c b/noun/nock.c index f6505a23a..af39af719 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -3,6 +3,8 @@ */ #include "all.h" +#define TREE_NOCK + static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); static u3_noun _n_burn_on(u3_noun bus, u3_noun fol); @@ -574,7 +576,7 @@ u3n_nock_an(u3_noun bus, u3_noun fol) * as it executes, along with some other information. very spammy. */ -#if 0 +#if 1 // match to OPCODE TABLE static char* names[] = { "halt", "bail", @@ -948,7 +950,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) return tot_s; } -#if 0 +#if 1 static void _n_print_byc(c3_y* pog, c3_s her_s); #endif @@ -1191,7 +1193,7 @@ typedef struct { } burnframe; /* _n_burn(): pog: program - * bus: subject + * bus: subject (TRANSFER) * mov: -1 north, 1 south * off: 0 north, -1 south */ @@ -1772,7 +1774,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } } -#if 0 +#if 1 /* _n_print_byc(): print bytecode. used for debugging. */ static void @@ -1866,7 +1868,7 @@ _n_burn_on(u3_noun bus, u3_noun fol) c3_y* pog = _n_find(fol); c3_ys mov, off; - u3z(fol); + //u3z(fol); if ( c3y == u3a_is_north(u3R) ) { mov = -1; off = 0; @@ -1875,7 +1877,8 @@ _n_burn_on(u3_noun bus, u3_noun fol) mov = 1; off = -1; } - u3_noun pro = _n_burn(pog, bus, mov, off); + //u3_noun pro = _n_burn(pog, bus, mov, off); + u3_noun pro = _n_nock_on(bus, fol); return pro; } @@ -1978,6 +1981,68 @@ u3n_beep(u3p(u3h_root) har_p) u3h_walk(har_p, _n_reap); } +static c3_w +_n_mark_byc(c3_y* pog) +{ + c3_y cod_y; + c3_s ip_s = 0; + c3_w tot_w = 0; + u3_noun non; + + while ( pog[ip_s] != HALT ) { + cod_y = pog[ip_s++]; + switch ( cod_y ) { + default: + ip_s += _n_arg(cod_y); + break; + + case CUSH: case FRAG: case FLAG: case LILN: case LITN: + case SAMN: case TICK: case KICK: + non = _n_rean(pog, &ip_s); + tot_w += u3a_mark_noun(non); + break; + + case SKIB: case SLIB: + ip_s += sizeof(c3_y); + non = _n_rean(pog, &ip_s); + tot_w += u3a_mark_noun(non); + break; + + case SKIM: case SLIM: + ip_s += sizeof(c3_s); + non = _n_rean(pog, &ip_s); + tot_w += u3a_mark_noun(non); + break; + } + } + + return tot_w; +} + +static c3_w bam_w; + +/* _n_bam(): u3h_walk helper for u3n_bark + */ +static void +_n_bam(u3_noun kev) +{ + c3_y* pog = u3a_into(u3t(kev)); + bam_w += u3a_mark_noun(kev) + _n_mark_byc(pog); +} + +/* u3n_bark(): mark the bytecode cache for gc. + */ +c3_w +u3n_bark() +{ + return 0; + /* + bam_w = 0; + u3h_walk(u3R->byc.har_p, _n_bam); + return bam_w; + */ +} + #if 0 /* _n_print_stack(): print out the cap stack up to a designated "empty" * used only for debugging From bf8ac6fc37078b46cd736274e3653ee8e27ca037 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 9 Mar 2018 16:38:55 -0800 Subject: [PATCH 039/221] bytecode interpreter passes memory checker --- noun/nock.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index af39af719..fd07fd882 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -3,8 +3,6 @@ */ #include "all.h" -#define TREE_NOCK - static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); static u3_noun _n_burn_on(u3_noun bus, u3_noun fol); @@ -1868,7 +1866,7 @@ _n_burn_on(u3_noun bus, u3_noun fol) c3_y* pog = _n_find(fol); c3_ys mov, off; - //u3z(fol); + u3z(fol); if ( c3y == u3a_is_north(u3R) ) { mov = -1; off = 0; @@ -1877,8 +1875,7 @@ _n_burn_on(u3_noun bus, u3_noun fol) mov = 1; off = -1; } - //u3_noun pro = _n_burn(pog, bus, mov, off); - u3_noun pro = _n_nock_on(bus, fol); + u3_noun pro = _n_burn(pog, bus, mov, off); return pro; } @@ -2016,6 +2013,7 @@ _n_mark_byc(c3_y* pog) } } + tot_w += u3a_mark_mptr(pog); return tot_w; } @@ -2027,7 +2025,7 @@ static void _n_bam(u3_noun kev) { c3_y* pog = u3a_into(u3t(kev)); - bam_w += u3a_mark_noun(kev) + _n_mark_byc(pog); + bam_w += _n_mark_byc(pog); } /* u3n_bark(): mark the bytecode cache for gc. @@ -2035,12 +2033,10 @@ _n_bam(u3_noun kev) c3_w u3n_bark() { - return 0; - /* + u3p(u3h_root) har_p = u3R->byc.har_p; bam_w = 0; - u3h_walk(u3R->byc.har_p, _n_bam); - return bam_w; - */ + u3h_walk(har_p, _n_bam); + return bam_w + u3h_mark(har_p); } #if 0 From a2a0f3ae6ab41a0107244443369d292e107253fb Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 12 Mar 2018 10:45:04 -0700 Subject: [PATCH 040/221] code cleanup --- include/noun/nock.h | 7 - noun/manage.c | 1 + noun/nock.c | 480 ++++++++++++++++++++------------------------ 3 files changed, 221 insertions(+), 267 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 3d1297f78..4f3e2c04e 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -9,13 +9,6 @@ u3_noun u3n_nock_on(u3_noun bus, u3_noun fol); -#if 0 - /* u3n_burn_on(): produce .*(bus fol) with bytecode interpreter. - */ - u3_noun - u3n_burn_on(u3_noun bus, u3_noun fol); -#endif - /* u3n_slam_on(): produce (gat sam). */ u3_noun diff --git a/noun/manage.c b/noun/manage.c index 3acf06af9..1a661ea2b 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -510,6 +510,7 @@ u3m_clear(void) { u3h_free(u3R->cax.har_p); u3h_free(u3R->jed.har_p); + // TODO: free entries in byc.har_p u3h_free(u3R->byc.har_p); u3a_lose(u3R->jed.das); } diff --git a/noun/nock.c b/noun/nock.c index fd07fd882..5b48be9ef 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -3,9 +3,6 @@ */ #include "all.h" -static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); -static u3_noun _n_burn_on(u3_noun bus, u3_noun fol); - /* u3_term_io_hija(): hijack console for cooked print. */ FILE* @@ -23,6 +20,48 @@ static u3_noun _n_burn_on(u3_noun bus, u3_noun fol); # define uH u3_term_io_hija() # define uL(x) u3_term_io_loja(x) +// define to have each opcode printed as it executes, +// along with some other debugging info +# undef VERBOSE_BYTECODE + +/* _n_mush_in(): see _n_mush(). +*/ +static u3_noun +_n_mush_in(u3_noun val) +{ + if ( c3n == u3du(val) ) { + return u3_nul; + } + else { + u3_noun h_val = u3h(val); + u3_noun ite; + + if ( c3n == u3ud(h_val) ) { + ite = u3nc(c3__leaf, u3_nul); + } else { + ite = u3nc(c3__leaf, u3qe_trip(h_val)); + } + return u3nc(ite, _n_mush_in(u3t(val))); + } +} + +/* _n_mush(): tank from failed path request. +*/ +static u3_noun +_n_mush(u3_noun val) +{ + u3_noun pro; + + pro = u3nt(c3__rose, + u3nt(u3nc('/', u3_nul), u3nc('/', u3_nul), u3_nul), + _n_mush_in(val)); + u3z(val); + return pro; +} + +#if 0 +// Retained for debugging purposes. +static u3_noun _n_nock_on(u3_noun bus, u3_noun fol); /* _n_hint(): process hint. */ @@ -151,41 +190,6 @@ _n_hint(u3_noun zep, } } -/* _n_mush_in(): see _n_mush(). -*/ -static u3_noun -_n_mush_in(u3_noun val) -{ - if ( c3n == u3du(val) ) { - return u3_nul; - } - else { - u3_noun h_val = u3h(val); - u3_noun ite; - - if ( c3n == u3ud(h_val) ) { - ite = u3nc(c3__leaf, u3_nul); - } else { - ite = u3nc(c3__leaf, u3qe_trip(h_val)); - } - return u3nc(ite, _n_mush_in(u3t(val))); - } -} - -/* _n_mush(): tank from failed path request. -*/ -static u3_noun -_n_mush(u3_noun val) -{ - u3_noun pro; - - pro = u3nt(c3__rose, - u3nt(u3nc('/', u3_nul), u3nc('/', u3_nul), u3_nul), - _n_mush_in(val)); - u3z(val); - return pro; -} - /* _n_nock_on(): produce .*(bus fol). Do not virtualize. */ static u3_noun @@ -427,79 +431,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) } } } - -/* u3n_nock_on(): produce .*(bus fol). Do not virtualize. -*/ -u3_noun -u3n_nock_on(u3_noun bus, u3_noun fol) -{ - u3_noun pro; - - u3t_on(noc_o); -#ifdef TREE_NOCK - pro = _n_nock_on(bus, fol); -#else - pro = _n_burn_on(bus, fol); #endif - u3t_off(noc_o); - - return pro; -} - -/* u3n_kick_on(): fire `gat` without changing the sample. -*/ -u3_noun -u3n_kick_on(u3_noun gat) -{ - return u3j_kink(gat, 2); -} - -c3_w exc_w; - -/* u3n_slam_on(): produce (gat sam). -*/ -u3_noun -u3n_slam_on(u3_noun gat, u3_noun sam) -{ - u3_noun cor = u3nc(u3k(u3h(gat)), u3nc(sam, u3k(u3t(u3t(gat))))); - -#if 0 - if ( &u3H->rod_u == u3R ) { - if ( exc_w == 1 ) { - c3_assert(0); - } - exc_w++; - } -#endif - u3z(gat); - return u3n_kick_on(cor); -} - -/* u3n_nock_et(): produce .*(bus fol), as ++toon, in namespace. -*/ -u3_noun -u3n_nock_et(u3_noun gul, u3_noun bus, u3_noun fol) -{ - return u3m_soft_run(gul, u3n_nock_on, bus, fol); -} - -/* u3n_slam_et(): produce (gat sam), as ++toon, in namespace. -*/ -u3_noun -u3n_slam_et(u3_noun gul, u3_noun gat, u3_noun sam) -{ - return u3m_soft_run(gul, u3n_slam_on, gat, sam); -} - -/* u3n_nock_an(): as slam_in(), but with empty fly. -*/ -u3_noun -u3n_nock_an(u3_noun bus, u3_noun fol) -{ - u3_noun gul = u3nt(u3nt(1, 0, 0), 0, 0); // |=(a/{* *} ~) - - return u3n_nock_et(gul, bus, fol); -} /* These must match the order in the section marked OPCODE TABLE */ #define HALT 0 @@ -570,13 +502,37 @@ u3n_nock_an(u3_noun bus, u3_noun fol) #define SLIM 65 #define SAVE 66 -/* defining this will cause the bytecode interpreter to print out every opcode - * as it executes, along with some other information. very spammy. +#if 0 +/* _n_print_stack(): print out the cap stack up to a designated "empty" + * used only for debugging */ +static void _n_print_stack(u3p(u3_noun) empty) { + c3_w cur_p = u3R->cap_p; + fprintf(stderr, "["); + int first = 1; + while ( cur_p != empty ) { + if ( first ) { + first = 0; + } + else { + fprintf(stderr, " "); + } + if ( c3y == u3a_is_north(u3R) ) { + fprintf(stderr, "%u", *(u3to(u3_noun, cur_p))); + cur_p++; + } + else { + fprintf(stderr, "%u", *(u3to(u3_noun, cur_p-1))); + cur_p--; + } + } + fprintf(stderr, "]\r\n"); +} +#endif -#if 1 +#ifdef VERBOSE_BYTECODE // match to OPCODE TABLE -static char* names[] = { +static char* opcode_names[] = { "halt", "bail", "copy", "swap", "toss", "auto", "ault", @@ -616,7 +572,7 @@ _n_apen(u3_noun* dst, u3_noun src) *dst = u3kb_weld(src, *dst); } -/* _n_emit(): return the size (in bytes) of an opcode's argument +/* _n_arg(): return the size (in bytes) of an opcode's argument */ static inline c3_y _n_arg(c3_y cod_y) @@ -684,7 +640,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) case c3__hunk: case c3__lose: case c3__mean: - case c3__spot: + case c3__spot: tot_s += _n_comp(ops, hod, c3n, c3n); tot_s += _n_emit(ops, u3nc(CUSH, zep)); tot_s += _n_comp(ops, nef, los_o, c3n); @@ -697,7 +653,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) tot_s += _n_comp(ops, nef, los_o, tel_o); break; - case c3__slog: + case c3__slog: tot_s += _n_comp(ops, hod, c3n, c3n); tot_s += _n_emit(ops, SLOG); tot_s += _n_comp(ops, nef, los_o, tel_o); @@ -705,7 +661,7 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) // germ and sole are unused... - case c3__fast: + case c3__fast: tot_s += _n_comp(ops, hod, c3n, c3n); tot_s += _n_emit(ops, SWAP); tot_s += _n_comp(ops, nef, c3n, c3n); @@ -811,7 +767,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) tot_s += _n_comp(ops, tel, c3n, c3n); /* things in tail position replace (so, lose) top of stack, * so NOCT "loses" and there is no non-losing version */ - op_y = (c3y == tel_o) ? NOCT + op_y = (c3y == tel_o) ? NOCT : ((c3y == los_o) ? NOLK : NOCK); tot_s += _n_emit(ops, op_y); break; @@ -877,7 +833,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } case 6: { - u3_noun mid, + u3_noun mid, yep = u3_nul, nop = u3_nul; c3_s yep_s, nop_s; @@ -894,13 +850,13 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) break; } - case 7: + case 7: u3x_cell(arg, &hed, &tel); tot_s += _n_comp(ops, hed, los_o, c3n); tot_s += _n_comp(ops, tel, c3y, tel_o); break; - case 8: + case 8: u3x_cell(arg, &hed, &tel); tot_s += _n_comp(ops, hed, c3n, c3n); tot_s += _n_emit(ops, (c3y == los_o) ? SNOL : SNOC); @@ -920,7 +876,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) tot_s += _n_emit(ops, (c3y == tel_o) ? SLAT : SLAM); } else { - op_y = (c3y == tel_o) + op_y = (c3y == tel_o) ? (hed <= 0xFF ? TICB : hed <= 0xFFFF ? TICS : TICK) : (hed <= 0xFF ? KICB : hed <= 0xFFFF ? KICS : KICK); tot_s += _n_emit(ops, u3nc(op_y, u3k(hed))); @@ -948,8 +904,68 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) return tot_s; } -#if 1 -static void _n_print_byc(c3_y* pog, c3_s her_s); +#ifdef VERBOSE_BYTECODE +/* _n_print_byc(): print bytecode. used for debugging. + */ +static void +_n_print_byc(c3_y* pog, c3_s her_s) +{ + c3_s ip_s = 0; + if ( her_s == 0 ) { + fprintf(stderr, "begin: {"); + } + else { + fprintf(stderr, "resume: {"); + } + int first = 1; + while ( pog[ip_s] ) { + if ( first ) { + first = 0; + } + else if (ip_s == her_s) { + fprintf(stderr, " [*]"); + } + else { + fprintf(stderr, " "); + } + switch ( pog[ip_s] ) { + default: + fprintf(stderr, "%s", opcode_names[pog[ip_s++]]); + break; + + case FRAB: case FLAB: case LILB: case LITB: case SAMB: + case SBIP: case SBIN: case KICB: case TICB: + fprintf(stderr, "[%s ", opcode_names[pog[ip_s++]]); + fprintf(stderr, "%u]", pog[ip_s++]); + break; + + case FRAS: case FLAS: case LILS: case LITS: case SAMS: + case SKIP: case SKIN: case KICS: case TICS: + fprintf(stderr, "[%s ", opcode_names[pog[ip_s++]]); + fprintf(stderr, "%u]", _n_resh(pog, &ip_s)); + break; + + case CUSH: case FRAG: case FLAG: case LILN: + case LITN: case SAMN: case TICK: case KICK: + fprintf(stderr, "[%s ", opcode_names[pog[ip_s++]]); + fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); + break; + + case SKIB: case SLIB: + fprintf(stderr, "[%s", opcode_names[pog[ip_s++]]); + fprintf(stderr, " %u ", pog[ip_s++]); + fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); + break; + + case SKIM: case SLIM: + fprintf(stderr, "[%s", opcode_names[pog[ip_s++]]); + fprintf(stderr, " %u ", _n_resh(pog, &ip_s)); + fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); + break; + } + } + fprintf(stderr, " halt}\r\n"); +} #endif /* _n_asm(): assemble an accumulated list of instructions (i.e. from _n_comp) @@ -1031,7 +1047,7 @@ _n_asm(u3_noun ops, c3_s len_s) ops = u3t(ops); } // this will trigger if we ever have a nock formula that compiles to more - // than 2^16 opcodes. if needed, ip can be a c3_w. + // than 2^16 bytes. if needed, ip can be a c3_w. c3_assert(u3_nul == ops); u3z(top); @@ -1047,7 +1063,6 @@ _n_push(c3_ys mov, c3_ys off, u3_noun a) { u3R->cap_p += mov; u3_noun* p = u3to(u3_noun, u3R->cap_p + off); - //u3_noun* p = (u3_noun*) u3a_push(sizeof(u3_noun)); *p = a; } @@ -1058,7 +1073,6 @@ static inline u3_noun* _n_peek(c3_ys off) { return u3to(u3_noun, u3R->cap_p + off); - //return (u3_noun*) u3a_peek(sizeof(u3_noun)); } /* _n_peet(): address of the next-to-top of stack @@ -1175,7 +1189,7 @@ _n_swap(c3_ys mov, c3_ys off) } /* _n_kale(): bail(exit) if not cell - */ + */ static inline u3_noun _n_kale(u3_noun a) { @@ -1242,8 +1256,8 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif -#ifdef VERBYC - #define BURN() fprintf(stderr, "%s ", names[pog[ip_s]]); goto *lab[pog[ip_s++]] +#ifdef VERBOSE_BYTECODE + #define BURN() fprintf(stderr, "%s ", opcode_names[pog[ip_s]]); goto *lab[pog[ip_s++]] #else #define BURN() goto *lab[pog[ip_s++]] #endif @@ -1251,7 +1265,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) { do_halt: // [product ...burnframes...] x = _n_pep(mov, off); -#ifdef VERBYC +#ifdef VERBOSE_BYTECODE fprintf(stderr, "return\r\n"); #endif if ( empty == u3R->cap_p ) { @@ -1264,7 +1278,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3R->cap_p = u3of(burnframe, fam - (mov+off)); _n_push(mov, off, x); -#ifdef VERBYC +#ifdef VERBOSE_BYTECODE _n_print_byc(pog, ip_s); #endif BURN(); @@ -1296,7 +1310,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_ault: // [tel bus hed] x = _n_pep(mov, off); // [bus hed] _n_toss(mov, off); // [hed] - top = _n_peek(off); + top = _n_peek(off); *top = u3nc(*top, x); // [pro] BURN(); @@ -1421,18 +1435,18 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) fam->pog = pog; _n_push(mov, off, x); nock_out: - pog = _n_find(o); + pog = _n_find(o); ip_s = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif -#ifdef VERBYC +#ifdef VERBOSE_BYTECODE fprintf(stderr, "\r\nnock jump: %u\r\n", o); _n_print_byc(pog, ip_s); #endif u3z(o); BURN(); - + do_deep: top = _n_peek(off); o = *top; @@ -1561,7 +1575,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_kics: x = _n_resh(pog, &ip_s); goto kick_in; - + do_kick: x = _n_rean(pog, &ip_s); goto kick_in; @@ -1591,13 +1605,13 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif -#ifdef VERBYC +#ifdef VERBOSE_BYTECODE fprintf(stderr, "\r\nhead kick jump: %u, sp: %p\r\n", fol, top); _n_print_byc(pog, ip_s); #endif _n_push(mov, off, o); } -#ifdef VERBYC +#ifdef VERBOSE_BYTECODE else { fprintf(stderr, "head jet\r\n"); } @@ -1607,7 +1621,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_tics: x = _n_resh(pog, &ip_s); goto tick_in; - + do_tick: x = _n_rean(pog, &ip_s); goto tick_in; @@ -1632,12 +1646,12 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif -#ifdef VERBYC +#ifdef VERBOSE_BYTECODE fprintf(stderr, "\r\ntail kick jump: %u, sp: %p\r\n", fol, top); _n_print_byc(pog, ip_s); #endif } -#ifdef VERBYC +#ifdef VERBOSE_BYTECODE else { fprintf(stderr, "tail jet\r\n"); } @@ -1772,92 +1786,6 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } } -#if 1 -/* _n_print_byc(): print bytecode. used for debugging. - */ -static void -_n_print_byc(c3_y* pog, c3_s her_s) -{ - c3_s ip_s = 0; - if ( her_s == 0 ) { - fprintf(stderr, "begin: {"); - } - else { - fprintf(stderr, "resume: {"); - } - int first = 1; - while ( pog[ip_s] ) { - if ( first ) { - first = 0; - } - else if (ip_s == her_s) { - fprintf(stderr, " [*]"); - } - else { - fprintf(stderr, " "); - } - switch ( pog[ip_s] ) { - default: - fprintf(stderr, "%s", names[pog[ip_s++]]); - break; - - case FRAB: - case FLAB: - case LILB: - case LITB: - case SAMB: - case SBIP: - case SBIN: - case KICB: - case TICB: - fprintf(stderr, "[%s ", names[pog[ip_s++]]); - fprintf(stderr, "%u]", pog[ip_s++]); - break; - - case FRAS: - case FLAS: - case LILS: - case LITS: - case SAMS: - case SKIP: - case SKIN: - case KICS: - case TICS: - fprintf(stderr, "[%s ", names[pog[ip_s++]]); - fprintf(stderr, "%u]", _n_resh(pog, &ip_s)); - break; - - case CUSH: - case FRAG: - case FLAG: - case LILN: - case LITN: - case SAMN: - case TICK: - case KICK: - fprintf(stderr, "[%s ", names[pog[ip_s++]]); - fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); - break; - - case SKIB: - case SLIB: - fprintf(stderr, "[%s", names[pog[ip_s++]]); - fprintf(stderr, " %u ", pog[ip_s++]); - fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); - break; - - case SKIM: - case SLIM: - fprintf(stderr, "[%s", names[pog[ip_s++]]); - fprintf(stderr, " %u ", _n_resh(pog, &ip_s)); - fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); - break; - } - } - fprintf(stderr, " halt}\r\n"); -} -#endif - /* _n_burn_on(): produce .*(bus fol) with bytecode interpreter */ static u3_noun @@ -1879,20 +1807,23 @@ _n_burn_on(u3_noun bus, u3_noun fol) return pro; } -#if 0 -/* u3n_burn_on(): useful for distinguishing the bytecode interpreter from the - * tree-walking interpreter. - */ +/* u3n_nock_on(): produce .*(bus fol). Do not virtualize. +*/ u3_noun -u3n_burn_on(u3_noun bus, u3_noun fol) +u3n_nock_on(u3_noun bus, u3_noun fol) { u3_noun pro; + u3t_on(noc_o); +#if 0 + pro = _n_nock_on(bus, fol); +#else pro = _n_burn_on(bus, fol); +#endif u3t_off(noc_o); + return pro; } -#endif /* _n_take_narg(): helper for copying noun-parts of bytecode */ static void @@ -1978,6 +1909,8 @@ u3n_beep(u3p(u3h_root) har_p) u3h_walk(har_p, _n_reap); } +/* _n_mark_byc(): mark bytecode for gc. +*/ static c3_w _n_mark_byc(c3_y* pog) { @@ -2039,30 +1972,57 @@ u3n_bark() return bam_w + u3h_mark(har_p); } -#if 0 -/* _n_print_stack(): print out the cap stack up to a designated "empty" - * used only for debugging - */ -static void _n_print_stack(u3p(u3_noun) empty) { - c3_w cur_p = u3R->cap_p; - fprintf(stderr, "["); - int first = 1; - while ( cur_p != empty ) { - if ( first ) { - first = 0; - } - else { - fprintf(stderr, " "); - } - if ( c3y == u3a_is_north(u3R) ) { - fprintf(stderr, "%u", *(u3to(u3_noun, cur_p))); - cur_p++; - } - else { - fprintf(stderr, "%u", *(u3to(u3_noun, cur_p-1))); - cur_p--; - } - } - fprintf(stderr, "]\r\n"); +/* u3n_kick_on(): fire `gat` without changing the sample. +*/ +u3_noun +u3n_kick_on(u3_noun gat) +{ + return u3j_kink(gat, 2); } + +c3_w exc_w; + +/* u3n_slam_on(): produce (gat sam). +*/ +u3_noun +u3n_slam_on(u3_noun gat, u3_noun sam) +{ + u3_noun cor = u3nc(u3k(u3h(gat)), u3nc(sam, u3k(u3t(u3t(gat))))); + +#if 0 + if ( &u3H->rod_u == u3R ) { + if ( exc_w == 1 ) { + c3_assert(0); + } + exc_w++; + } #endif + u3z(gat); + return u3n_kick_on(cor); +} + +/* u3n_nock_et(): produce .*(bus fol), as ++toon, in namespace. +*/ +u3_noun +u3n_nock_et(u3_noun gul, u3_noun bus, u3_noun fol) +{ + return u3m_soft_run(gul, u3n_nock_on, bus, fol); +} + +/* u3n_slam_et(): produce (gat sam), as ++toon, in namespace. +*/ +u3_noun +u3n_slam_et(u3_noun gul, u3_noun gat, u3_noun sam) +{ + return u3m_soft_run(gul, u3n_slam_on, gat, sam); +} + +/* u3n_nock_an(): as slam_in(), but with empty fly. +*/ +u3_noun +u3n_nock_an(u3_noun bus, u3_noun fol) +{ + u3_noun gul = u3nt(u3nt(1, 0, 0), 0, 0); // |=(a/{* *} ~) + + return u3n_nock_et(gul, bus, fol); +} From 1871595b57cdc4182994961964c05f4fa2f56fcb Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 12 Mar 2018 10:58:41 -0700 Subject: [PATCH 041/221] add bytecode free functions --- include/noun/nock.h | 8 +++++-- noun/manage.c | 3 +-- noun/nock.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 4f3e2c04e..e978528f3 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -56,8 +56,12 @@ /* u3n_beep(): promote bytecode state. */ - void u3n_beep(u3p(u3h_root) har_p); + void u3n_beep(u3p(u3h_root) har_p); /* u3n_bark(): mark bytecode cache. */ - c3_w u3n_bark(); + c3_w u3n_bark(); + + /* u3n_bree(): free bytecode cache. + */ + void u3n_bree(); diff --git a/noun/manage.c b/noun/manage.c index 1a661ea2b..47ae65ad7 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -510,8 +510,7 @@ u3m_clear(void) { u3h_free(u3R->cax.har_p); u3h_free(u3R->jed.har_p); - // TODO: free entries in byc.har_p - u3h_free(u3R->byc.har_p); + u3n_bree(); u3a_lose(u3R->jed.das); } diff --git a/noun/nock.c b/noun/nock.c index 5b48be9ef..ac562baf1 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1972,6 +1972,59 @@ u3n_bark() return bam_w + u3h_mark(har_p); } +/* _n_free_byc(): free memory retained by bytecode +*/ +static void +_n_free_byc(c3_y* pog) +{ + c3_y cod_y; + c3_s ip_s = 0; + + while ( pog[ip_s] != HALT ) { + cod_y = pog[ip_s++]; + switch ( cod_y ) { + default: + ip_s += _n_arg(cod_y); + break; + + case CUSH: case FRAG: case FLAG: case LILN: case LITN: + case SAMN: case TICK: case KICK: + u3z(_n_rean(pog, &ip_s)); + break; + + case SKIB: case SLIB: + ip_s += sizeof(c3_y); + u3z(_n_rean(pog, &ip_s)); + break; + + case SKIM: case SLIM: + ip_s += sizeof(c3_s); + u3z(_n_rean(pog, &ip_s)); + break; + } + } + + u3a_free(pog); +} + +/* _n_feb(): u3h_walk helper for u3n_bree + */ +static void +_n_feb(u3_noun kev) +{ + _n_free_byc(u3a_into(u3t(kev))); +} + +/* u3n_bree(): free bytecode cache + */ +void +u3n_bree() +{ + u3p(u3h_root) har_p = u3R->byc.har_p; + u3h_walk(har_p, _n_feb); + u3h_free(har_p); +} + /* u3n_kick_on(): fire `gat` without changing the sample. */ u3_noun From 2c8f8b084600d2db5661c76fd5026ba6b3f6c2b3 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 26 Mar 2018 09:58:36 -0700 Subject: [PATCH 042/221] stash --- noun/jets.c | 292 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 200 insertions(+), 92 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 640b1ddc0..47b2da514 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -195,6 +195,111 @@ _cj_sham(u3_noun som) // XX wrong, does not match ++sham return haf; } +static u3_weak +_cj_find_cold(u3_noun bat) +{ + u3a_road* rod_u = u3R; + + while ( 1 ) { + u3_weak reg = u3h_gut(rod_u->jed.cod_p, bat); + + if ( u3_none != reg ) { + return reg; + } + + if ( rod_u->par_p ) { + rod_u = u3to(u3_road, rod_u->par_p); + } + else return u3_none; + } +} + +static u3_weak +_cj_find_warm(u3_noun loc) +{ + u3a_road* rod_u = u3R; + + while ( 1 ) { + u3_weak ank = u3h_gut(rod_u->jed.war_p, loc); + + if ( u3_none != ank ) { + return ank; + } + + if ( rod_u->par_p ) { + rod_u = u3to(u3_road, rod_u->par_p); + } + else return u3_none; + } +} + +u3_weak +u3j_spot(u3_noun cor) +{ + u3_weak reg = _cj_find_cold(u3h(cor)); + if ( u3_none == sag ) { + return u3_none; + } + else { + u3_noun rut, kid; + u3x_cell(reg, &rut, &kid); + u3_weak rum = u3qdb_get(rut, u3t(cor)); + if ( u3_nul != rum ) { + u3_noun loc = u3nc(c3y, u3k(u3t(rum))); + u3z(rum); + return loc; + } + else { + while ( u3_nul != kid ) { + u3_noun axe, bas, nam, par; + u3x_trel(u3h(kid), &nam, &axe, &bas); + par = u3r_at(axe, cor); + if ( c3y == u3qdi_has(bas, u3h(par)) ) { + u3_weak pas = u3j_spot(par); + if ( u3_none != pas ) { + return u3nq(c3n, u3k(nam), u3k(axe), pas); + } + } + kid = u3t(kid); + } + return u3_none; + } + } +} + +/* _cj_scan(): has this core been registered? + */ +static c3_o +_cj_scan(u3_noun cor) +{ + u3_weak reg = _cj_find_cold(u3h(cor)); + if ( u3_none == reg ) { + return c3n; + } + else { + u3_noun rut, kid, rum; + u3x_cell(reg, &rut, &kid); + + rum = u3qdb_get(rut, u3t(cor)); + if ( c3y == u3qdb_has(rut, u3t(cor)) ) { + return c3y; + } + else { + while ( u3_nul != kid ) { + u3_noun axe, bas, nam, par; + u3x_trel(u3h(kid), &nam, &axe, &bas); + par = u3r_at(axe, cor); + if ( (c3y == u3qdi_has(bas, u3h(par))) && + (c3y == _cj_scan(par)) ) { + return c3y; + } + kid = u3t(kid); + } + return c3n; + } + } +} + /* u3j_find(): in warm state, return u3_none or calx. RETAINS. */ u3_weak @@ -265,11 +370,9 @@ _cj_warm_hump(c3_l jax_l, u3_noun huc) } /* _cj_hot_mean(): in parent, declare a core. RETAINS. -** -** XX bat is used only for printing, remove. */ static c3_l -_cj_hot_mean(c3_l par_l, u3_noun mop, u3_noun bat) +_cj_hot_mean(c3_l par_l, u3_noun nam) { u3j_core* par_u; u3j_core* dev_u; @@ -288,13 +391,12 @@ _cj_hot_mean(c3_l par_l, u3_noun mop, u3_noun bat) u3j_core* cop_u; while ( (cop_u = &dev_u[i_l])->cos_c ) { - if ( _(u3r_sing_c(cop_u->cos_c, u3h(mop))) ) { + if ( _(u3r_sing_c(cop_u->cos_c, nam)) ) { #if 0 - fprintf(stderr, "hot: bound jet %d/%s/%s/%x\r\n", + fprintf(stderr, "hot: bound jet %d/%s/%s/\r\n", cop_u->jax_l, cop_u->cos_c, - par_u ? par_u->cos_c : "~", - u3r_mug(bat)); + par_u ? par_u->cos_c : "~"); #endif return cop_u->jax_l; } @@ -326,7 +428,7 @@ _cj_hot_mine(u3_noun mop, u3_noun cor) } else par_l = 0; - return _cj_hot_mean(par_l, mop, u3h(cor)); + return _cj_hot_mean(par_l, u3h(mop)); } } @@ -707,104 +809,113 @@ _cj_jit(c3_l jax_l, u3_noun bat) return u3_nul; } +/* +|% ++= battery ^ ++= root [name=term payload=*] ++= branch [name=term parent=static] ++= static (each root branch) ++= dynamic [name=term where=axis parent=location] ++= location (each static dynamic) ++= registry [roots=(map * root) branches=(list ancestor)] ++= ancestor (pair axis (set battery)) ++= activation $: hot-index=@ud + arms=(map axis @ud) + label=path + jit=* + == ++= cold (map battery registry) ++= warm (map location activation) +-- +*/ + /* _cj_mine(): declare a core. RETAIN. */ static void _cj_mine(u3_noun cey, u3_noun cor) { - u3_noun bat = u3h(cor); - u3_noun p_cey, q_cey, r_cey; + u3_noun bal, nam, axe, map, reg, loc, act, bat = u3h(cor); + u3x_trel(cey, &nam, &axe, &map); + c3_l jax_l; - u3r_trel(cey, &p_cey, &q_cey, &r_cey); - { - /* Calculate semantic identity (cope) and match state (corp). - */ - u3_noun mop; // ++cope - u3_noun cup; // ++corp - u3_noun soh; // ++bash - u3_noun cuz; // ++club - u3_noun lab; // ++path - - if ( 0 == q_cey ) { - mop = u3nq(u3k(p_cey), 3, c3n, u3k(u3t(cor))); - cup = u3nc(c3n, u3k(cor)); - lab = u3_nul; + if ( 0 == axe ) { + u3_noun pay = u3t(cor); + jax_l = 0; + reg = _cj_find_cold(bat); + loc = u3nq(c3y, c3y, u3k(nam), u3k(pay)); + if ( u3_none == reg ) { + reg = u3nc(u3qdb_put(u3_nul, pay, bat), u3_nul); } else { - u3_weak rah = u3r_at(q_cey, cor); - - if ( (u3_none == rah) || !_(u3du(rah)) ) { - fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(p_cey)); + u3_noun rut, ger; + u3x_cell(reg, &rut, &kid); + ger = u3nc(u3qdb_put(rut, pay, bat), kid); + u3z(reg); + reg = ger; + } + bal = u3nc(u3k(nam), u3_nul); + act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); + } + else { + u3_weak par = u3r_at(axe, cor); + if ( u3_none == par || c3n == u3du(par) ) { + fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(nam)); + return; + } + else { + u3_weak pel = u3j_spot(par); + if ( u3_none == pel ) { + fprintf(stderr, "fund: in %s, parent %x not found at %d\r\n", + u3r_string(nam), + u3r_mug(u3h(par)), + axe); return; } else { - u3_noun tab = u3h(rah); - u3_weak cax = u3j_find(tab); + u3_noun pac = _cj_find_warm(pel); + c3_l par_l; + c3_assert(u3_none != pac); - if ( u3_none == cax ) { - fprintf(stderr, "fund: in %s, parent %x not found at %d\r\n", - u3r_string(p_cey), - u3r_mug(u3h(rah)), - q_cey); - return; + par_l = u3h(pac); + jax_l = _cj_hot_mean(par_l, nam); + bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); + act = u3nq(jax_l, + _cj_warm_hump(jax_l, map), + bal, + _cj_jit(jax_l, bat)); + + if ( (3 == axe) && (c3y == u3h(pel)) ) { + loc = u3nq(c3y, c3n, u3k(nam), u3k(pel)); } else { - u3_noun hos = u3h(u3h(u3t(cax))); - u3_noun puc = u3h(u3t(u3t(cax))); + loc = u3nq(c3n, u3k(nam), u3k(axe), u3k(pel)); + } - mop = u3nq(u3k(p_cey), u3k(q_cey), c3y, u3k(hos)); - if ( (3 == q_cey) && (c3y == u3h(puc)) ) { - cup = u3nc(c3y, u3k(cor)); - } - else { - cup = u3nc(c3n, u3k(tab)); - } - lab = u3k(u3h(u3t(u3t(u3h(cax))))); - u3z(cax); + reg = _cj_find_cold(bat); + if ( u3_none == reg ) { + u3_noun bas = u3qdi_put(u3_nul, bat), + ank = u3nc(3, bas), + kid = u3nc(ank, u3_nul); + reg = u3nc(u3_nul, kid); + } + else { + u3_noun rut, ger, kid; + u3x_cell(reg, &rut, &kid); + kid = _cj_add_kid(kid, axe, loc); + ger = u3nc(rut, kid); + u3z(reg); + reg = ger; } } } - soh = _cj_sham(u3k(mop)); - cuz = u3nc(cup, u3k(r_cey)); - - // Save cold state. - // - { - u3_noun hoe = u3kdb_get(u3k(u3R->jed.das), u3k(soh)); - u3_noun sab; - - if ( u3_none == hoe ) { - sab = u3nt(u3nc(u3k(bat), u3k(cuz)), u3_nul, u3_nul); - } - else { - sab = u3kdb_put(u3k(u3t(hoe)), u3k(bat), u3k(cuz)); - u3z(hoe); - } - - u3R->jed.das = u3kdb_put(u3R->jed.das, u3k(soh), u3nc(u3k(mop), sab)); - } - - // Save warm state. - // - { - c3_l jax_l = _cj_hot_mine(mop, cor); - u3_noun bal = u3nc(u3k(p_cey), lab); - -#if 0 - u3m_p("new jet", bal); - fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); -#endif - - u3h_put(u3R->jed.har_p, - bat, - u3nt(u3nq(jax_l, - _cj_warm_hump(jax_l, r_cey), - bal, - _cj_jit(jax_l, bat)), - u3nc(soh, mop), - cuz)); - } } + u3h_put(u3R->jed.cod_p, bat, reg); + u3h_put(u3R->jed.war_p, loc, act); + u3z(loc); +#if 0 + u3m_p("new jet", bal); + fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); +#endif } /* u3j_mine(): register core for jets. @@ -816,12 +927,9 @@ u3j_mine(u3_noun clu, u3_noun cor) u3_noun cax; u3t_on(glu_o); - if ( !_(u3du(cor)) ) { + if ( (c3n == u3du(cor)) || (c3y == _cj_scan(cor)) ) { u3z(clu); } - else if ( u3_none != (cax = u3j_find(bat)) ) { - u3z(cax); u3z(clu); - } else { u3_noun cey = _cj_je_fsck(clu); @@ -1056,7 +1164,7 @@ _cj_warm_ream_at(u3_noun soh, u3_noun* lab, u3_noun cag) pal = u3_nul; } *lab = u3nc(u3k(p_mop), pal); - jax_l = _cj_hot_mean(par_l, mop, 0); + jax_l = _cj_hot_mean(par_l, u3h(mop)); _cj_warm_ream_is(jax_l, soh, *lab, mop, sab); return jax_l; From f73408979b226b5f500ab75b86279a01e0bf0887 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 26 Mar 2018 13:25:23 -0700 Subject: [PATCH 043/221] most logic thru u3j_kick moved to new dashboard --- noun/jets.c | 121 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 88 insertions(+), 33 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 47b2da514..d4b6e88b9 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -237,7 +237,7 @@ u3_weak u3j_spot(u3_noun cor) { u3_weak reg = _cj_find_cold(u3h(cor)); - if ( u3_none == sag ) { + if ( u3_none == reg ) { return u3_none; } else { @@ -282,6 +282,7 @@ _cj_scan(u3_noun cor) rum = u3qdb_get(rut, u3t(cor)); if ( c3y == u3qdb_has(rut, u3t(cor)) ) { + u3z(reg); return c3y; } else { @@ -291,10 +292,12 @@ _cj_scan(u3_noun cor) par = u3r_at(axe, cor); if ( (c3y == u3qdi_has(bas, u3h(par))) && (c3y == _cj_scan(par)) ) { + u3z(reg); return c3y; } kid = u3t(kid); } + u3z(reg); return c3n; } } @@ -707,22 +710,27 @@ _cj_fine(u3_noun cup, u3_noun mop, u3_noun cor) u3_weak u3j_kick(u3_noun cor, u3_noun axe) { - if ( !_(u3du(cor)) ) { return u3_none; } - u3t_on(glu_o); - { - u3_noun bat = u3h(cor); - u3_weak cax = u3j_find(bat); + u3_weak loc = _cj_find_cold(cor); + if ( u3_none == loc ) { + u3t_off(glu_o); + return u3_none; + } + else { + u3_weak act = _cj_find_warm(loc); + u3z(loc); + if ( u3_none == act ) { + u3t_off(glu_o); + return u3_none; + } + else { + c3_l jax_l; + u3_noun hap, bal, jit, inx; - if ( u3_none == cax ) { u3t_off(glu_o); return u3_none; } - { - u3_noun mop = u3t(u3h(u3t(cax))); - u3_noun hap = u3h(u3t(u3h(cax))); - u3_noun cup = u3h(u3t(u3t(cax))); - u3_noun inx = u3kdb_get(u3k(hap), u3k(axe)); + u3x_qual(act, &jax_l, &hap, &bal, &jit); - if ( u3_none == inx ) { - u3z(cax); + if ( u3_none == (inx = u3qdb_get(hap, axe)) ) { + u3z(act); u3t_off(glu_o); { c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); @@ -741,25 +749,14 @@ u3j_kick(u3_noun cor, u3_noun axe) } } } -#if 1 - else if ( !_(_cj_fine(cup, mop, cor)) ) { - fprintf(stderr, "improper core %x\r\n", u3r_mug(cor)); - u3m_p("improper label", u3h(u3t(u3t(u3h(cax))))); - u3m_bail(c3__exit); - - u3t_off(glu_o); - return u3_none; - } -#endif else { - c3_l jax_l = u3h(u3h(cax)); u3j_core* cop_u = &u3D.ray_u[jax_l]; c3_l inx_l = inx; u3j_harm* ham_u = &cop_u->arm_u[inx_l]; c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); u3_noun pro; - u3z(cax); + u3z(act); if ( _(pof_o) ) { pof_o = u3t_come(bat); } @@ -829,6 +826,63 @@ _cj_jit(c3_l jax_l, u3_noun bat) -- */ +/* cj_register_old(): attempt to update correct set within lan with + * bat. u3_none if axe not found within lan. RETAIN. + */ +static u3_weak +_cj_register_old(u3_noun lan, u3_noun bat, u3_noun axe) +{ + u3_noun ank; + if ( u3_nul == lan ) { + return u3_none; + } + else if ( u3r_sing(axe, ank = u3h(lan)) ) { + u3_noun bas = u3qdi_put(u3t(ank), bat), + kan = u3nc(axe, bas); + return u3nc(kan, u3k(u3t(lan))); + } + else { + u3_weak nex = _cj_register_old(u3t(lan), bat, axe); + if ( u3_none == nex ) { + return u3_none; + } + else { + return u3nc(u3k(ank), nex); + } + } +} + +/* cj_register_new(): insert ancestor within lan at sorted index. RETAIN. + */ +static u3_noun +_cj_register_new(u3_noun lan, u3_noun bat, u3_noun axe) +{ + u3_noun ank; + if ( (u3_nul == lan) || (c3y == u3qa_lth(axe, u3h(u3h(lan)))) ) { + ank = u3nc(axe, u3qdi_put(u3_nul, bat)); + return u3nc(ank, lan); + } + else { + return u3nc(u3k(u3h(lan)), + _cj_register_new(u3t(lan), bat, axe)); + } +} + +/* _cj_register(): register a battery as an ancestor in a list of ancestors. + * RETAIN. + */ +static u3_noun +_cj_register(u3_noun lan, u3_noun bat, u3_noun axe) +{ + u3_weak old = _cj_register_old(lan, bat, axe); + if ( u3_none != old ) { + return old; + } + else { + return _cj_register_new(lan, bat, axe); + } +} + /* _cj_mine(): declare a core. RETAIN. */ static void @@ -844,12 +898,12 @@ _cj_mine(u3_noun cey, u3_noun cor) reg = _cj_find_cold(bat); loc = u3nq(c3y, c3y, u3k(nam), u3k(pay)); if ( u3_none == reg ) { - reg = u3nc(u3qdb_put(u3_nul, pay, bat), u3_nul); + reg = u3nc(u3qdb_put(u3_nul, pay, loc), u3_nul); } else { u3_noun rut, ger; u3x_cell(reg, &rut, &kid); - ger = u3nc(u3qdb_put(rut, pay, bat), kid); + ger = u3nc(u3qdb_put(rut, pay, loc), kid); u3z(reg); reg = ger; } @@ -884,11 +938,12 @@ _cj_mine(u3_noun cey, u3_noun cor) bal, _cj_jit(jax_l, bat)); + u3z(pac); if ( (3 == axe) && (c3y == u3h(pel)) ) { - loc = u3nq(c3y, c3n, u3k(nam), u3k(pel)); + loc = u3nq(c3y, c3n, u3k(nam), pel); } else { - loc = u3nq(c3n, u3k(nam), u3k(axe), u3k(pel)); + loc = u3nq(c3n, u3k(nam), u3k(axe), pel); } reg = _cj_find_cold(bat); @@ -899,10 +954,10 @@ _cj_mine(u3_noun cey, u3_noun cor) reg = u3nc(u3_nul, kid); } else { - u3_noun rut, ger, kid; + u3_noun rut, ger, kid, ank; u3x_cell(reg, &rut, &kid); - kid = _cj_add_kid(kid, axe, loc); - ger = u3nc(rut, kid); + ank = _cj_register(kid, bat, axe); + ger = u3nc(u3k(rut), ank); u3z(reg); reg = ger; } From e82f4c617e88b3e20a7ca090a527818e3815db22 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 28 Mar 2018 11:27:33 -0700 Subject: [PATCH 044/221] that should do for _cj_hook_in... --- noun/jets.c | 314 +++++++++++++++++++++++++--------------------------- 1 file changed, 151 insertions(+), 163 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index d4b6e88b9..fde4dcb5d 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -241,26 +241,40 @@ u3j_spot(u3_noun cor) return u3_none; } else { - u3_noun rut, kid; - u3x_cell(reg, &rut, &kid); - u3_weak rum = u3qdb_get(rut, u3t(cor)); + u3_noun rut, ban; + u3x_cell(reg, &rut, &ban); + u3_noun rum = u3qdb_get(rut, u3t(cor)); if ( u3_nul != rum ) { - u3_noun loc = u3nc(c3y, u3k(u3t(rum))); + u3_noun loc = u3nt(c3y, c3y, u3k(u3t(rum))); u3z(rum); return loc; } else { - while ( u3_nul != kid ) { - u3_noun axe, bas, nam, par; - u3x_trel(u3h(kid), &nam, &axe, &bas); + while ( u3_nul != ban ) { + u3_weak pel, par; + u3_noun axe, luk; + u3x_cell(u3h(ban), &axe, &luk); par = u3r_at(axe, cor); - if ( c3y == u3qdi_has(bas, u3h(par)) ) { - u3_weak pas = u3j_spot(par); - if ( u3_none != pas ) { - return u3nq(c3n, u3k(nam), u3k(axe), pas); + if ( u3_none == par ) { + return u3_none; + } + pel = u3j_spot(par); + if ( u3_none != pel ) { + u3_noun huc = u3qdb_get(luk, pel); + if ( u3_nul == huc ) { + u3z(pel); + } + else { + u3_noun loc = ( (3 == axe) && (c3y == u3h(pel)) ) + ? u3nc(c3y, + u3nq(c3n, u3k(nam), pel, u3k(u3t(huc)))) + : u3nc(c3n, + u3nq(u3k(nam), u3k(axe), pel, u3k(u3t(huc)))); + u3z(huc); + return loc; } } - kid = u3t(kid); + ban = u3t(ban); } return u3_none; } @@ -277,53 +291,34 @@ _cj_scan(u3_noun cor) return c3n; } else { - u3_noun rut, kid, rum; - u3x_cell(reg, &rut, &kid); - - rum = u3qdb_get(rut, u3t(cor)); - if ( c3y == u3qdb_has(rut, u3t(cor)) ) { - u3z(reg); + u3_noun rut, ban; + u3x_cell(reg, &rut, &ban); + u3_noun rum = u3qdb_get(rut, u3t(cor)); + if ( u3_nul != rum ) { + u3z(rum); return c3y; } else { - while ( u3_nul != kid ) { - u3_noun axe, bas, nam, par; - u3x_trel(u3h(kid), &nam, &axe, &bas); + while ( u3_nul != ban ) { + u3_weak par; + u3_noun axe, luk; + u3x_cell(u3h(ban), &axe, &luk); par = u3r_at(axe, cor); - if ( (c3y == u3qdi_has(bas, u3h(par))) && - (c3y == _cj_scan(par)) ) { - u3z(reg); + if ( u3_none == par ) { + return c3n; + } + else if ( c3y == _cj_scan(par) ) { return c3y; } - kid = u3t(kid); + else { + ban = u3t(ban); + } } - u3z(reg); return c3n; } } } -/* u3j_find(): in warm state, return u3_none or calx. RETAINS. -*/ -u3_weak -u3j_find(u3_noun bat) -{ - u3a_road* rod_u = u3R; - - while ( 1 ) { - u3_weak jaw = u3h_gut(rod_u->jed.har_p, bat); - - if ( u3_none != jaw ) { - return jaw; - } - - if ( rod_u->par_p ) { - rod_u = u3to(u3_road, rod_u->par_p); - } - else return u3_none; - } -} - /* _cj_warm_hump(): generate axis-to-arm map. RETAIN. */ static u3_noun @@ -409,32 +404,6 @@ _cj_hot_mean(c3_l par_l, u3_noun nam) return 0; } -/* _cj_hot_mine(): in hot state, declare a core. RETAINS. -*/ -static c3_l -_cj_hot_mine(u3_noun mop, u3_noun cor) -{ - u3_noun p_mop, q_mop, r_mop, hr_mop, tr_mop; - - u3x_trel(mop, &p_mop, &q_mop, &r_mop); - u3x_cell(r_mop, &hr_mop, &tr_mop); - { - c3_l par_l; - - // Calculate parent axis. - // - if ( c3y == hr_mop ) { - u3_noun cax = u3j_find(u3h(u3r_at(q_mop, cor))); - - par_l = u3h(u3h(cax)); - u3z(cax); - } - else par_l = 0; - - return _cj_hot_mean(par_l, u3h(mop)); - } -} - /* u3j_boot(): initialize jet system. */ void @@ -553,6 +522,29 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) } } + +/* +|% ++= battery ^ ++= hooks (map term axis) ++= root [name=term payload=* hooks] ++= branch [name=term parent=static hooks] ++= dynamic [name=term where=axis parent=location hooks] ++= static (each root branch) ++= location (each static dynamic) ++= registry [roots=(map * root) branches=(list ancestor)] ++= ancestor (pair axis (map location hooks)) +:: ++= activation $: hot-index=@ud + drivers=(map axis @ud) + label=path + jit=* + == +:: ++= cold (map battery registry) ++= warm (map location activation) +-- +*/ /* _cj_hook_in(): execute hook from core, or fail. */ static u3_noun @@ -560,70 +552,89 @@ _cj_hook_in(u3_noun cor, const c3_c* tam_c, c3_o jet_o) { - u3_noun bat = u3h(cor); + if ( c3n == u3du(cor) ) { + return u3m_bail(c3__fail); + } + else { + u3_weak loc = u3j_spot(cor); - if ( !_(u3du(cor)) ) { return u3m_bail(c3__fail); } - { - u3_weak cax = u3j_find(bat); - - if ( u3_none == cax ) { return u3m_bail(c3__fail); } - { - u3_noun p_cax, q_cax, r_cax; - u3_noun jax, soh, mop, huc, hap, jit; - u3_noun p_mop, q_mop, r_mop; - - u3x_trel(cax, &p_cax, &q_cax, &r_cax); - u3x_trel(p_cax, &jax, &hap, &jit); - u3x_cell(q_cax, &soh, &mop); - u3x_trel(mop, &p_mop, &q_mop, &r_mop); - - huc = u3t(r_cax); - { - c3_l jax_l = jax; - u3j_core* cop_u = &u3D.ray_u[jax_l]; - u3_noun fol = u3kdb_get(u3k(huc), u3i_string(tam_c)); - - if ( u3_none == fol ) { - // The caller wants a deeper core. - // - if ( 0 == q_mop ) { return u3m_bail(c3__fail); } + if ( u3_none == loc ) { + return u3m_bail(c3__fail); + } + else { + u3j_core* cop_u; + u3_noun tem = u3i_string(tam_c), + got = u3_nul; + while ( 1 ) { + if ( c3y == u3h(loc) ) { + u3_noun sat = u3t(loc), + las = u3t(u3t(sat)), + huc = u3t(las); + got = u3qdb_get(huc, tem); + if ( u3_nul != got ) { + break; + } else { - u3_noun inn = u3k(u3x_at(q_mop, cor)); - - u3z(cax); u3z(cor); - return _cj_hook_in(inn, tam_c, jet_o); + if ( c3y == u3h(sat) ) { + return u3m_bail(c3__fail); + } + else { + u3_noun col = u3k(u3h(las)); + cor = u3t(cor); + u3z(loc); + loc = col; + } } } else { - u3_noun pro; - c3_l axe_l = _cj_axis(fol); - c3_l inx_l; - - if ( (0 == axe_l) || - (c3n == jet_o) || - (u3_none == (inx_l = u3kdb_get(u3k(hap), axe_l))) || - (u3_none == (pro = _cj_kick_z(cor, - cop_u, - &cop_u->arm_u[inx_l], - axe_l))) ) - { - if ( 0 == axe_l ) { - u3z(cax); - return u3n_nock_on(cor, fol); - } else { - // Tricky: the above case would work here too, but would - // disable jet_o and create some infinite recursions. - // - u3z(cax); u3z(fol); - return u3n_nock_on(cor, u3k(u3x_at(axe_l, cor))); - } + u3_noun nam, axe, par, huc; + u3x_qual(u3t(loc), &nam, &axe, &par, &huc); + got = u3qdb_get(huc, tem); + if ( u3_nul != got ) { + break; } else { - u3z(cax); u3z(fol); - return pro; + u3_noun col = u3k(par); + u3z(loc); + loc = col; + cor = u3r_at(axe, cor); + c3_assert(u3_none != cor); } } } + + u3z(tem); + fol = u3k(u3t(got)); + u3z(got); + axe_l = _cj_axis(fol); + + if ( 0 == axe_l ) { + pro = u3n_nock_on(cor, fol); + } + else { + c3_l axe_l, inx_l; + u3_noun jit, bal, hap, act, pro, fol; + + u3z(fol); + act = _cj_find_warm(loc); + u3x_qual(act, &jax_l, &hap, &bal, &jit); + cop_u = &u3D.ray_u[jax_l]; + + // Tricky: the above case would work here too, but would + // disable jet_o and create some infinite recursions. + // + if ( (c3n == jet_o) || + (u3_none == (inx_l = u3kdb_get(u3k(hap), axe_l))) || + (u3_none == (pro = _cj_kick_z(cor, + cop_u, + &cop_u->arm_u[inx_l], + axe_l))) ) { + pro = u3n_nock_on(cor, u3k(u3x_at(axe_l, cor))); + } + u3z(act); + } + u3z(loc); + return pro; } } } @@ -711,7 +722,7 @@ u3_weak u3j_kick(u3_noun cor, u3_noun axe) { u3t_on(glu_o); - u3_weak loc = _cj_find_cold(cor); + u3_weak loc = u3j_spot(cor); if ( u3_none == loc ) { u3t_off(glu_o); return u3_none; @@ -806,26 +817,6 @@ _cj_jit(c3_l jax_l, u3_noun bat) return u3_nul; } -/* -|% -+= battery ^ -+= root [name=term payload=*] -+= branch [name=term parent=static] -+= static (each root branch) -+= dynamic [name=term where=axis parent=location] -+= location (each static dynamic) -+= registry [roots=(map * root) branches=(list ancestor)] -+= ancestor (pair axis (set battery)) -+= activation $: hot-index=@ud - arms=(map axis @ud) - label=path - jit=* - == -+= cold (map battery registry) -+= warm (map location activation) --- -*/ - /* cj_register_old(): attempt to update correct set within lan with * bat. u3_none if axe not found within lan. RETAIN. */ @@ -888,15 +879,15 @@ _cj_register(u3_noun lan, u3_noun bat, u3_noun axe) static void _cj_mine(u3_noun cey, u3_noun cor) { - u3_noun bal, nam, axe, map, reg, loc, act, bat = u3h(cor); - u3x_trel(cey, &nam, &axe, &map); + u3_noun bal, nam, axe, huc, reg, loc, act, bat = u3h(cor); + u3x_trel(cey, &nam, &axe, &huc); c3_l jax_l; if ( 0 == axe ) { u3_noun pay = u3t(cor); jax_l = 0; reg = _cj_find_cold(bat); - loc = u3nq(c3y, c3y, u3k(nam), u3k(pay)); + loc = u3nc(u3k(huc), u3nq(c3y, c3y, u3k(nam), u3k(pay))); if ( u3_none == reg ) { reg = u3nc(u3qdb_put(u3_nul, pay, loc), u3_nul); } @@ -926,26 +917,23 @@ _cj_mine(u3_noun cey, u3_noun cor) return; } else { - u3_noun pac = _cj_find_warm(pel); + u3_noun pat, pac = _cj_find_warm(pel); c3_l par_l; c3_assert(u3_none != pac); par_l = u3h(pac); jax_l = _cj_hot_mean(par_l, nam); bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); - act = u3nq(jax_l, - _cj_warm_hump(jax_l, map), - bal, - _cj_jit(jax_l, bat)); - u3z(pac); - if ( (3 == axe) && (c3y == u3h(pel)) ) { - loc = u3nq(c3y, c3n, u3k(nam), pel); - } - else { - loc = u3nq(c3n, u3k(nam), u3k(axe), pel); - } + act = u3nq(jax_l, + _cj_warm_hump(jax_l, huc), + bal, + _cj_jit(jax_l, bat)); + pat = ( (3 == axe) && (c3y == u3h(pel)) ) + ? u3nq(c3y, c3n, u3k(nam), pel) + : u3nq(c3n, u3k(nam), u3k(axe), pel); + loc = u3nc(u3k(huc), pat); reg = _cj_find_cold(bat); if ( u3_none == reg ) { u3_noun bas = u3qdi_put(u3_nul, bat), From a5e55372e96252aea4ce01af0733c2627b0b3e7c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 29 Mar 2018 11:56:09 -0700 Subject: [PATCH 045/221] stash before changing dashboard yet again --- include/noun/allocate.h | 4 +- noun/jets.c | 514 ++++++++++++++++++---------------------- noun/trace.c | 42 +--- 3 files changed, 242 insertions(+), 318 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 2cab0bd0a..294a40b01 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -128,8 +128,8 @@ } all; struct { // jet dashboard - u3p(u3h_root) har_p; // warm state - u3_noun das; // cold state + u3p(u3h_root) war_p; // warm state + u3p(u3h_root) cod_p; // cold state } jed; struct { // bytecode state diff --git a/noun/jets.c b/noun/jets.c index fde4dcb5d..e78dc86dc 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -522,29 +522,6 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) } } - -/* -|% -+= battery ^ -+= hooks (map term axis) -+= root [name=term payload=* hooks] -+= branch [name=term parent=static hooks] -+= dynamic [name=term where=axis parent=location hooks] -+= static (each root branch) -+= location (each static dynamic) -+= registry [roots=(map * root) branches=(list ancestor)] -+= ancestor (pair axis (map location hooks)) -:: -+= activation $: hot-index=@ud - drivers=(map axis @ud) - label=path - jit=* - == -:: -+= cold (map battery registry) -+= warm (map location activation) --- -*/ /* _cj_hook_in(): execute hook from core, or fail. */ static u3_noun @@ -613,11 +590,12 @@ _cj_hook_in(u3_noun cor, } else { c3_l axe_l, inx_l; - u3_noun jit, bal, hap, act, pro, fol; + u3_noun hap, act, pro, fol; u3z(fol); act = _cj_find_warm(loc); - u3x_qual(act, &jax_l, &hap, &bal, &jit); + jax_l = u3h(act); + hap = u3h(u3t(act)); cop_u = &u3D.ray_u[jax_l]; // Tricky: the above case would work here too, but would @@ -663,56 +641,6 @@ u3j_hook(u3_noun cor, return pro; } -/* _cj_fine(): validate core. RETAIN. -*/ -static c3_o -_cj_fine(u3_noun cup, u3_noun mop, u3_noun cor) -{ - if ( c3y == u3h(cup) ) { - return u3r_sing(cor, u3t(cup)); - } - else { - u3_noun par = u3t(u3t(mop)); - u3_noun pax = u3h(u3t(mop)); - - if ( c3n == u3h(par) ) { - c3_assert(3 == pax); - if ( c3n == u3r_sing(u3t(par), u3t(cor)) ) { - fprintf(stderr, "fine: core mismatch: %x, %x\r\n", - u3t(par), u3t(cor)); - } - return u3r_sing(u3t(par), u3t(cor)); - } - else { - u3_weak pac = u3r_at(pax, cor); - - if ( u3_none == pac || !_(u3du(pac)) ) { - fprintf(stderr, "fail 1\r\n"); - return c3n; - } - else { - u3_weak cax = u3j_find(u3h(pac)); - - if ( u3_none == cax ) { - fprintf(stderr, "fine: parent not found (%x)\r\n", u3r_mug(u3h(pac))); - return c3n; - } - else { - c3_o pro_o; - - cup = u3h(u3t(u3t(cax))); - mop = u3t(u3h(u3t(cax))); - cor = pac; - - pro_o = _cj_fine(cup, mop, cor); - u3z(cax); - return pro_o; - } - } - } - } -} - /* u3j_kick(): new kick. ** ** `axe` is RETAINED by the caller; `cor` is RETAINED iff there @@ -740,15 +668,15 @@ u3j_kick(u3_noun cor, u3_noun axe) u3x_qual(act, &jax_l, &hap, &bal, &jit); - if ( u3_none == (inx = u3qdb_get(hap, axe)) ) { - u3z(act); + if ( u3_none == (inx = u3kdb_get(u3k(hap), u3k(axe))) ) { u3t_off(glu_o); { c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); if ( _(pof_o) ) { - pof_o = u3t_come(bat); + pof_o = u3t_come(bal); } + u3z(act); if ( _(pof_o) ) { u3_noun pro = u3n_nock_on(cor, u3nq(9, u3k(axe), 0, 1)); @@ -767,10 +695,10 @@ u3j_kick(u3_noun cor, u3_noun axe) c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); u3_noun pro; - u3z(act); if ( _(pof_o) ) { - pof_o = u3t_come(bat); + pof_o = u3t_come(bal); } + u3z(act); u3t_off(glu_o); pro = _cj_kick_z(cor, cop_u, ham_u, axe); @@ -817,23 +745,23 @@ _cj_jit(c3_l jax_l, u3_noun bat) return u3_nul; } -/* cj_register_old(): attempt to update correct set within lan with - * bat. u3_none if axe not found within lan. RETAIN. +/* _cj_register_old(): register hooks and parent location within existing + * axis in ancestor list or u3_none. RETAIN. */ static u3_weak -_cj_register_old(u3_noun lan, u3_noun bat, u3_noun axe) +_cj_register_old(u3_noun lan, u3_noun loc, u3_noun huc, u3_noun axe) { u3_noun ank; if ( u3_nul == lan ) { return u3_none; } else if ( u3r_sing(axe, ank = u3h(lan)) ) { - u3_noun bas = u3qdi_put(u3t(ank), bat), - kan = u3nc(axe, bas); + u3_noun hal = u3qdb_put(u3t(ank), loc, huc), + kan = u3nc(axe, hal); return u3nc(kan, u3k(u3t(lan))); } else { - u3_weak nex = _cj_register_old(u3t(lan), bat, axe); + u3_weak nex = _cj_register_old(u3t(lan), loc, huc, axe); if ( u3_none == nex ) { return u3_none; } @@ -846,31 +774,31 @@ _cj_register_old(u3_noun lan, u3_noun bat, u3_noun axe) /* cj_register_new(): insert ancestor within lan at sorted index. RETAIN. */ static u3_noun -_cj_register_new(u3_noun lan, u3_noun bat, u3_noun axe) +_cj_register_new(u3_noun lan, u3_noun loc, u3_noun huc, u3_noun axe) { u3_noun ank; if ( (u3_nul == lan) || (c3y == u3qa_lth(axe, u3h(u3h(lan)))) ) { - ank = u3nc(axe, u3qdi_put(u3_nul, bat)); - return u3nc(ank, lan); + ank = u3nc(axe, u3qdb_put(u3_nul, loc, huc)); + return u3nc(ank, u3k(lan)); } else { return u3nc(u3k(u3h(lan)), - _cj_register_new(u3t(lan), bat, axe)); + _cj_register_new(u3t(lan), loc, huc, axe)); } } -/* _cj_register(): register a battery as an ancestor in a list of ancestors. +/* _cj_register(): register a location as an ancestor in a list of ancestors. * RETAIN. */ static u3_noun -_cj_register(u3_noun lan, u3_noun bat, u3_noun axe) +_cj_register(u3_noun lan, u3_noun loc, u3_noun huc, u3_noun axe) { - u3_weak old = _cj_register_old(lan, bat, axe); + u3_weak old = _cj_register_old(lan, loc, huc, axe); if ( u3_none != old ) { return old; } else { - return _cj_register_new(lan, bat, axe); + return _cj_register_new(lan, loc, huc, axe); } } @@ -879,78 +807,64 @@ _cj_register(u3_noun lan, u3_noun bat, u3_noun axe) static void _cj_mine(u3_noun cey, u3_noun cor) { - u3_noun bal, nam, axe, huc, reg, loc, act, bat = u3h(cor); + c3_l jax_l, par_l; + u3_weak par, pel; + u3_noun pac, rut, ger, pay, ank, bal, + nam, axe, huc, reg, loc, act; + u3_noun bat = u3h(cor); + u3x_trel(cey, &nam, &axe, &huc); - c3_l jax_l; if ( 0 == axe ) { - u3_noun pay = u3t(cor); + pay = u3t(cor); jax_l = 0; reg = _cj_find_cold(bat); - loc = u3nc(u3k(huc), u3nq(c3y, c3y, u3k(nam), u3k(pay))); + rut = u3nt(u3k(nam), u3k(pay), u3k(huc)); + loc = u3nt(c3y, c3y, rut); if ( u3_none == reg ) { - reg = u3nc(u3qdb_put(u3_nul, pay, loc), u3_nul); + reg = u3nc(u3_nul, u3_nul); } - else { - u3_noun rut, ger; - u3x_cell(reg, &rut, &kid); - ger = u3nc(u3qdb_put(rut, pay, loc), kid); - u3z(reg); - reg = ger; - } - bal = u3nc(u3k(nam), u3_nul); - act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); + ger = u3nc(u3qdb_put(u3h(reg), pay, rut), u3k(u3t(reg))); + u3z(reg); + reg = ger; + bal = u3nc(u3k(nam), u3_nul); + act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); } else { - u3_weak par = u3r_at(axe, cor); + par = u3r_at(axe, cor); if ( u3_none == par || c3n == u3du(par) ) { fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(nam)); return; } - else { - u3_weak pel = u3j_spot(par); - if ( u3_none == pel ) { - fprintf(stderr, "fund: in %s, parent %x not found at %d\r\n", - u3r_string(nam), - u3r_mug(u3h(par)), - axe); - return; - } - else { - u3_noun pat, pac = _cj_find_warm(pel); - c3_l par_l; - c3_assert(u3_none != pac); - - par_l = u3h(pac); - jax_l = _cj_hot_mean(par_l, nam); - bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); - u3z(pac); - - act = u3nq(jax_l, - _cj_warm_hump(jax_l, huc), - bal, - _cj_jit(jax_l, bat)); - pat = ( (3 == axe) && (c3y == u3h(pel)) ) - ? u3nq(c3y, c3n, u3k(nam), pel) - : u3nq(c3n, u3k(nam), u3k(axe), pel); - loc = u3nc(u3k(huc), pat); - reg = _cj_find_cold(bat); - if ( u3_none == reg ) { - u3_noun bas = u3qdi_put(u3_nul, bat), - ank = u3nc(3, bas), - kid = u3nc(ank, u3_nul); - reg = u3nc(u3_nul, kid); - } - else { - u3_noun rut, ger, kid, ank; - u3x_cell(reg, &rut, &kid); - ank = _cj_register(kid, bat, axe); - ger = u3nc(u3k(rut), ank); - u3z(reg); - reg = ger; - } - } + pel = u3j_spot(par); + if ( u3_none == pel ) { + fprintf(stderr, "fund: in %s, parent %x not found at %d\r\n", + u3r_string(nam), + u3r_mug(u3h(par)), + axe); + return; } + pac = _cj_find_warm(pel); + c3_assert(u3_none != pac); + par_l = u3h(pac); + jax_l = _cj_hot_mean(par_l, nam); + bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); + u3z(pac); + act = u3nq(jax_l, + _cj_warm_hump(jax_l, huc), + bal, + _cj_jit(jax_l, bat)); + loc = ( (3 == axe) && (c3y == u3h(pel)) ) + ? u3nt(c3y, c3n, u3nt(u3k(nam), pel, u3k(huc))) + : u3nc(c3n, u3nq(u3k(nam), u3k(axe), pel, u3k(huc))); + reg = _cj_find_cold(bat); + if ( u3_none == reg ) { + reg = u3nc(u3_nul, u3_nul); + } + ank = _cj_register(u3t(reg), loc, huc, axe); + ger = u3nc(u3k(u3h(reg)), ank); + u3z(reg); + reg = ger; } u3h_put(u3R->jed.cod_p, bat, reg); u3h_put(u3R->jed.war_p, loc, act); @@ -985,132 +899,104 @@ u3j_mine(u3_noun clu, u3_noun cor) u3t_off(glu_o); } -/* _cj_cold_reap_to: reap clog list. RETAINS `sab`, TRANSFERS `bam`. -*/ -static u3_noun -_cj_cold_reap_to(u3_noun sab, u3_noun bam) -{ - if ( u3_nul == sab ) { - return bam; - } - else { - u3_noun n_sab, l_sab, r_sab, pn_sab, qn_sab; - - u3x_trel(sab, &n_sab, &l_sab, &r_sab); - u3x_cell(n_sab, &pn_sab, &qn_sab); - { - bam = _cj_cold_reap_to(l_sab, bam); - bam = _cj_cold_reap_to(r_sab, bam); - - // If the battery is not junior, or if it has been - // already collected for the product, promote it. - // - if ( _(u3a_left(pn_sab)) ) { - u3_noun bat = u3a_take(pn_sab); - - bam = u3nc(u3nc(bat, u3a_take(qn_sab)), bam); - } - return bam; - } - } -} - -/* _cj_cold_reap_with(): unify old and new battery maps. TRANSFERS. -*/ -static u3_noun -_cj_cold_reap_with(u3_noun sab, u3_noun bam) -{ - u3_noun mab = bam; - - while ( u3_nul != mab ) { - u3_noun i_mab = u3h(mab); - - sab = u3kdb_put(sab, u3k(u3h(i_mab)), u3k(u3t(i_mab))); - mab = u3t(mab); - } - u3z(bam); - return sab; -} - -/* _cj_cold_reap_at(): reap haw node. RETAINS. -*/ -static void -_cj_cold_reap_at(u3_noun soh, u3_noun cag) -{ - u3_noun bam = _cj_cold_reap_to(u3t(cag), u3_nul); - - if ( u3_nul != bam ) { - u3_noun hoe, sab; - - soh = u3a_take(soh); - hoe = u3kdb_get(u3k(u3R->jed.das), u3k(soh)); - - if ( u3_none == hoe ) { - sab = _cj_cold_reap_with(u3_nul, bam); - cag = u3nc(u3a_take(u3h(cag)), sab); - } - else { - sab = _cj_cold_reap_with(u3k(u3t(hoe)), bam); - cag = u3nc(u3k(u3h(hoe)), sab); - } - u3z(hoe); - - u3R->jed.das = u3kdb_put(u3R->jed.das, soh, cag); - } -} - -/* _cj_cold_reap_in(): reap in (junior) haw. RETAINS. -*/ -static void -_cj_cold_reap_in(u3_noun taw) -{ - if ( u3_nul != taw ) { - u3_noun n_taw, l_taw, r_taw, pn_taw, qn_taw; - - u3x_trel(taw, &n_taw, &l_taw, &r_taw); - u3x_cell(n_taw, &pn_taw, &qn_taw); - - _cj_cold_reap_at(pn_taw, qn_taw); - _cj_cold_reap_in(l_taw); - _cj_cold_reap_in(r_taw); - } -} - /* _cj_warm_reap(): reap key and value from warm table. */ static void _cj_warm_reap(u3_noun kev) { - u3_noun bat = u3h(kev); - u3_noun cax = u3t(kev); - - if ( _(u3a_left(bat)) ) { - if ( !_(u3a_is_junior(u3R, bat)) && - (u3_none != u3h_git(u3R->jed.har_p, bat)) ) { - fprintf(stderr, "reap: promote collision (bat %x)\r\n", u3r_mug(bat)); - u3m_p("collision", u3h(u3t(u3t(u3h(cax))))); - } - else { - u3_noun tab = u3a_take(bat); - u3_noun xac = u3a_take(cax); - -#if 0 - u3m_p("hot jet", u3h(u3t(u3t(u3h(cax))))); - fprintf(stderr, " bat %x\r\n", u3r_mug(tab)); -#endif - u3h_put(u3R->jed.har_p, tab, xac); - u3z(tab); - } - } + u3_noun loc = u3a_take(u3h(kev)); + u3_noun act = u3a_take(u3t(kev)); + u3h_put(u3R->jed.har_p, loc, act); + u3z(loc); } -/* u3j_reap(): promote jet state. RETAINS. +/* +|% ++= battery ^ ++= hooks (map term axis) ++= root [name=term payload=* hooks] ++= branch [name=term parent=static hooks] ++= dynamic [name=term where=axis parent=location hooks] ++= static (each root branch) ++= location (each static dynamic) ++= registry [roots=(map * root) parents=(list ancestor)] ++= ancestor (pair axis (map location location)) +:: ++= activation $: hot-index=@ud + drivers=(map axis @ud) + label=path + jit=* + == +:: ++= cold (map battery registry) ++= warm (map location activation) +-- +*/ + +/* _cj_merge_ancestors(): merge ancestor lists. + * sel is TRANSFERRED. + * jul is RETAINED. + */ +static u3_noun +_cj_merge_ancestors(u3_noun sel, u3_noun jul) +{ + u3_noun kel, kev, i, j, ank, les, axe, loc, huc; + for ( i = jul; u3_nul != i; i = u3t(i) ) { + ank = u3h(i); + axe = u3a_take(u3h(ank)); + kel = u3qdb_tap(u3t(ank)); + for ( j = kel; u3_nul != j; j = u3t(j) ) { + kev = u3h(j); + loc = u3a_take(u3h(kev)); + huc = u3a_take(u3t(kev)); + les = _cj_register(sel, loc, huc, axe); + u3z(sel); u3z(loc); u3z(huc); + sel = les; + } + u3z(kel); u3z(ank); u3z(axe); + } + return sel; +} + +/* _cj_merge_roots(): merge root maps of ancestor. + * sor is TRANSFERRED. + * jor is RETAINED. + */ +static u3_noun +_cj_merge_roots(u3_noun sor, u3_noun jor) +{ + u3_noun i, rut, kel = u3qdb_tap(jor); + for ( i = kel; u3_nul != i; i = u3t(i) ) { + rut = u3h(i); + sor = u3kdb_put(sor, u3a_take(u3h(rut)), u3a_take(u3t(rut))); + } + u3z(kel); + return sor; +} + +/* _cj_cold_reap(): reap cold dashboard entries. + */ +static void +_cj_cold_reap(u3_noun kev) +{ + u3_noun jur = u3t(kev); + u3_noun bat = u3a_take(u3h(kev)); + u3_weak ser = _cj_find_cold(bat); + u3_noun reg = ( u3_none == ser ) + ? u3a_take(jur) + : u3nc(_cj_merge_roots(u3k(u3h(ser)), u3h(jur)), + _cj_merge_ancestors(u3k(u3t(ser)), u3t(jur))); + u3h_put(u3R->jed.cod_p, bat, reg); + u3z(ser); u3z(bat); +} + +/* u3j_reap(): promote jet state. */ void -u3j_reap(u3_noun das, u3p(u3h_root) har_p) +u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p) { - _cj_cold_reap_in(das); - u3h_walk(har_p, _cj_warm_reap); + u3h_walk(cod_p, _cj_cold_reap); + u3h_walk(war_p, _cj_warm_reap); } static c3_l _cj_warm_ream_at(u3_noun soh, u3_noun* lab, u3_noun cag); @@ -1234,24 +1120,96 @@ _cj_warm_ream_in(u3_noun taw) } } -/* _cj_warm_ream(): reream warm from cold state. + +/* _cj_warm_ream_all(): tap cod_p to rel */ +static u3_noun rel; static void -_cj_warm_ream(void) +_cj_warm_ream_all(u3_noun kev) { - c3_assert(u3R == &(u3H->rod_u)); - { - _cj_warm_ream_in(u3R->jed.das); - } + rel = u3nc(kev, u3k(rel)); } -/* u3j_ream(): reream after restoring from checkpoint. +/* u3j_ream(): rebuild warm state from cold state */ void u3j_ream(void) { - u3h_free(u3R->jed.har_p); - u3R->jed.har_p = u3h_new(); + u3_noun rut, lan, bat, reg, kev, rem, dol, lok; + u3_weak pel; + u3h_free(u3R->jed.war_p); + u3R->jed.war_p = u3h_new(); + c3_assert(u3R == &(u3H->rod_u)); + rel = u3_nul; + u3h_walk(u3R->jed.cod_p, _cj_warm_ream_all); - _cj_warm_ream(); + for ( lok = rel, dol = u3_nul; lok != u3_nul; lok = u3t(lok) ) { + kev = u3h(lok); + bat = u3h(kev); + reg = u3t(kev); + rut = u3h(reg); + + // register roots + rul = u3qdb_tap(rut); + jax_l = 0; + for ( rep = rul; rep != u3_nul; rep = u3t(rep) ) { + nut = u3h(rep); + rin = u3t(nut); + bal = u3nc(u3k(u3h(rin)), u3_nul); + act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); + loc = u3nt(c3y, c3y, u3k(rin)); + u3h_put(u3R->jed.war_p, loc, act); + } + u3z(rul); + + // put ancestors in dol + for ( lan = u3t(reg); lan != u3_nul; lan = u3t(lan) ) { + ank = u3h(lan); + axe = u3h(ank); + kel = u3qdb_tap(u3t(ank)); + for ( pul = kel; pul != u3_nul; pul = u3t(pul) ) { + dol = u3nc(u3nc(u3k(axe, u3k(u3h(pul)))), u3k(dol)); + } + u3z(kel); + } + } + u3z(rel); + + while ( u3_nul != dol ) { + top = dol; + rem = u3_nul; + while ( u3_nul != dol ) { + rec = u3h(dol); + dol = u3t(dol); + u3x_qual(rec, &axe, &pel, &nam, &huc); + pac = _cj_find_warm(pel); + if ( u3_none == pac ) { + rem = u3nc(u3k(rec), u3k(rem)); + } + else { + par_l = u3h(pac); + jax_l = _cj_hot_mean(par_l, nam); + bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); + u3z(pac); + act = u3nq(jax_l, + _cj_warm_hump(jax_l, huc), + bal, + _cj_jit(jax_l, bat)); + loc = ( (3 == axe) && (c3y == u3h(pel)) ) + ? u3nt(c3y, c3n, u3nt(u3k(nam), pel, u3k(huc))) + : u3nc(c3n, u3nq(u3k(nam), u3k(axe), pel, u3k(huc))); + reg = _cj_find_cold(bat); + } + } + u3z(top); + dol = rem; + } + + w + for ( top = dol, rem = u3_nul; + dol != u3_nul; + = dol = rem ) { + rec = u3h(dol); + + } } diff --git a/noun/trace.c b/noun/trace.c index 1464d719b..691ab3dd7 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -106,25 +106,6 @@ u3t_heck(u3_atom cog) } } -/* _t_jet_label(): -*/ -u3_weak -_t_jet_label(u3a_road* rod_u, u3_noun bat) -{ - while ( 1 ) { - u3_weak cax = u3h_git(rod_u->jed.har_p, bat); - - if ( u3_none != cax ) { - return u3h(u3t(u3t(u3h(cax)))); - } - - if ( rod_u->par_p ) { - rod_u = u3to(u3_road, rod_u->par_p); - } - else return u3_none; - } -} - #if 1 /* _t_samp_process(): process raw sample data from live road. */ @@ -141,22 +122,7 @@ _t_samp_process(u3_road* rod_u) u3_noun don = rod_u->pro.don; while ( u3_nul != don ) { - u3_noun bat = u3h(don); - u3_noun lab; - - // Find the label from this battery, surface allocated. - // - { - u3_noun laj = _t_jet_label(rod_u, bat); - - if ( u3_none == laj ) { - don = u3t(don); - continue; - } - - // lab = u3nc(u3i_string("foobar"), u3_nul); - lab = u3a_take(laj); u3a_wash(laj); - } + u3_noun lab = u3h(don); // Add the label to the traced label stack, trimming recursion. // { @@ -273,10 +239,10 @@ u3t_samp(void) /* u3t_come(): push on profile stack; return yes if active push. RETAIN. */ c3_o -u3t_come(u3_noun bat) +u3t_come(u3_noun lab) { - if ( (u3_nul == u3R->pro.don) || !_(u3r_sing(bat, u3h(u3R->pro.don))) ) { - u3R->pro.don = u3nc(u3k(bat), u3R->pro.don); + if ( (u3_nul == u3R->pro.don) || !_(u3r_sing(bal, u3h(u3R->pro.don))) ) { + u3R->pro.don = u3nc(u3k(lab), u3R->pro.don); return c3y; } else return c3n; From a4a2a38ce82738c91ca023bf3151ff7724ba867c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 29 Mar 2018 16:18:22 -0700 Subject: [PATCH 046/221] stash commit for interested onlookers --- noun/jets.c | 295 +++++++++++++++++++++++----------------------------- 1 file changed, 131 insertions(+), 164 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index e78dc86dc..44688344e 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -195,6 +195,9 @@ _cj_sham(u3_noun som) // XX wrong, does not match ++sham return haf; } +/* _cj_find_cold(): search cold state for `bat`s registry. + * RETAIN. + */ static u3_weak _cj_find_cold(u3_noun bat) { @@ -214,6 +217,9 @@ _cj_find_cold(u3_noun bat) } } +/* _cj_find_warm(): search warm state for `loc`s activation. + * RETAIN. + */ static u3_weak _cj_find_warm(u3_noun loc) { @@ -233,6 +239,8 @@ _cj_find_warm(u3_noun loc) } } +/* u3j_spot(): identify `cor`s location. RETAIN. + */ u3_weak u3j_spot(u3_noun cor) { @@ -241,40 +249,34 @@ u3j_spot(u3_noun cor) return u3_none; } else { - u3_noun rut, ban; - u3x_cell(reg, &rut, &ban); - u3_noun rum = u3qdb_get(rut, u3t(cor)); + u3_noun rut = u3h(reg), + lan = u3t(reg), + rum = u3qdb_get(rut, u3t(cor)); if ( u3_nul != rum ) { - u3_noun loc = u3nt(c3y, c3y, u3k(u3t(rum))); + u3_noun loc = u3k(u3t(rum)); u3z(rum); return loc; } else { - while ( u3_nul != ban ) { - u3_weak pel, par; - u3_noun axe, luk; - u3x_cell(u3h(ban), &axe, &luk); - par = u3r_at(axe, cor); - if ( u3_none == par ) { - return u3_none; - } - pel = u3j_spot(par); - if ( u3_none != pel ) { - u3_noun huc = u3qdb_get(luk, pel); - if ( u3_nul == huc ) { + while ( u3_nul != lan ) { + u3_noun pas = u3h(lan), + axe = u3h(pas), + lol = u3t(pas); + u3_weak par = u3r_at(axe, cor), + pel; + if ( u3_none != par ) { + pel = u3j_spot(par); + if ( u3_none != pel ) { + u3_noun nit = u3qdb_get(lol, pel); u3z(pel); - } - else { - u3_noun loc = ( (3 == axe) && (c3y == u3h(pel)) ) - ? u3nc(c3y, - u3nq(c3n, u3k(nam), pel, u3k(u3t(huc)))) - : u3nc(c3n, - u3nq(u3k(nam), u3k(axe), pel, u3k(u3t(huc)))); - u3z(huc); - return loc; + if ( u3_nul != nit ) { + u3_noun loc = u3k(u3t(nit)); + u3z(nit); + return loc; + } } } - ban = u3t(ban); + lan = u3t(lan); } return u3_none; } @@ -286,37 +288,10 @@ u3j_spot(u3_noun cor) static c3_o _cj_scan(u3_noun cor) { - u3_weak reg = _cj_find_cold(u3h(cor)); - if ( u3_none == reg ) { - return c3n; - } - else { - u3_noun rut, ban; - u3x_cell(reg, &rut, &ban); - u3_noun rum = u3qdb_get(rut, u3t(cor)); - if ( u3_nul != rum ) { - u3z(rum); - return c3y; - } - else { - while ( u3_nul != ban ) { - u3_weak par; - u3_noun axe, luk; - u3x_cell(u3h(ban), &axe, &luk); - par = u3r_at(axe, cor); - if ( u3_none == par ) { - return c3n; - } - else if ( c3y == _cj_scan(par) ) { - return c3y; - } - else { - ban = u3t(ban); - } - } - return c3n; - } - } + u3_weak loc = u3j_spot(cor); + c3_o reg_o = (u3_none == loc) ? c3y : c3n; + u3z(loc); + return reg_o; } /* _cj_warm_hump(): generate axis-to-arm map. RETAIN. @@ -529,62 +504,30 @@ _cj_hook_in(u3_noun cor, const c3_c* tam_c, c3_o jet_o) { + u3_weak loc, col; + u3_noun roc, tem, got, pat, nam, huc; + if ( c3n == u3du(cor) ) { return u3m_bail(c3__fail); } - else { - u3_weak loc = u3j_spot(cor); - if ( u3_none == loc ) { - return u3m_bail(c3__fail); - } - else { + loc = u3j_spot(cor); + if ( u3_none == loc ) { + return u3m_bail(c3__fail); + } + + tem = u3i_string(tam_c), + while ( 1 ) { + u3x_trel(loc, &pat, &name, &huc); + got = u3qdb_get(huc, tem); + if ( u3_nul != got ) { + u3_noun pro, fol; u3j_core* cop_u; - u3_noun tem = u3i_string(tam_c), - got = u3_nul; - while ( 1 ) { - if ( c3y == u3h(loc) ) { - u3_noun sat = u3t(loc), - las = u3t(u3t(sat)), - huc = u3t(las); - got = u3qdb_get(huc, tem); - if ( u3_nul != got ) { - break; - } - else { - if ( c3y == u3h(sat) ) { - return u3m_bail(c3__fail); - } - else { - u3_noun col = u3k(u3h(las)); - cor = u3t(cor); - u3z(loc); - loc = col; - } - } - } - else { - u3_noun nam, axe, par, huc; - u3x_qual(u3t(loc), &nam, &axe, &par, &huc); - got = u3qdb_get(huc, tem); - if ( u3_nul != got ) { - break; - } - else { - u3_noun col = u3k(par); - u3z(loc); - loc = col; - cor = u3r_at(axe, cor); - c3_assert(u3_none != cor); - } - } - } - + u3z(tem); fol = u3k(u3t(got)); u3z(got); axe_l = _cj_axis(fol); - if ( 0 == axe_l ) { pro = u3n_nock_on(cor, fol); } @@ -593,7 +536,7 @@ _cj_hook_in(u3_noun cor, u3_noun hap, act, pro, fol; u3z(fol); - act = _cj_find_warm(loc); + act = _cj_find_warm(loc); jax_l = u3h(act); hap = u3h(u3t(act)); cop_u = &u3D.ray_u[jax_l]; @@ -614,6 +557,30 @@ _cj_hook_in(u3_noun cor, u3z(loc); return pro; } + else if ( c3n == u3h(pat) ) { + u3_noun dyn = u3t(pat), + axe = u3h(dyn), + pel = u3t(dyn); + roc = u3k(u3r_at(axe, cor)); + u3z(cor); + cor = roc; + col = u3k(pel); + u3z(loc); + loc = col; + } + else { + u3_noun sat = u3t(pat); + if ( c3y == u3h(sat) ) { + return u3m_bail(c3__fail); + } + else { + col = u3k(u3t(sat)); + u3z(loc); + loc = col; + roc = u3k(u3t(cor)); + cor = roc; + } + } } } @@ -745,60 +712,60 @@ _cj_jit(c3_l jax_l, u3_noun bat) return u3_nul; } -/* _cj_register_old(): register hooks and parent location within existing +/* _cj_mine_par_old(): register hooks and parent location within existing * axis in ancestor list or u3_none. RETAIN. */ static u3_weak -_cj_register_old(u3_noun lan, u3_noun loc, u3_noun huc, u3_noun axe) +_cj_mine_par_old(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) { - u3_noun ank; + u3_noun par; if ( u3_nul == lan ) { return u3_none; } - else if ( u3r_sing(axe, ank = u3h(lan)) ) { - u3_noun hal = u3qdb_put(u3t(ank), loc, huc), - kan = u3nc(axe, hal); - return u3nc(kan, u3k(u3t(lan))); + else if ( u3r_sing(axe, u3h(par = u3h(lan))) ) { + u3_noun lol = u3qdb_put(u3t(par), pel, loc), + rap = u3nc(u3k(axe), lol); + return u3nc(rap, u3k(u3t(lan))); } else { - u3_weak nex = _cj_register_old(u3t(lan), loc, huc, axe); + u3_weak nex = _cj_mine_par_old(u3t(lan), axe, pel, loc); if ( u3_none == nex ) { return u3_none; } else { - return u3nc(u3k(ank), nex); + return u3nc(u3k(par), nex); } } } -/* cj_register_new(): insert ancestor within lan at sorted index. RETAIN. +/* _cj_mine_par_new(): insert ancestor within lan at sorted index. RETAIN. */ static u3_noun -_cj_register_new(u3_noun lan, u3_noun loc, u3_noun huc, u3_noun axe) +_cj_mine_par_new(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) { - u3_noun ank; + u3_noun par; if ( (u3_nul == lan) || (c3y == u3qa_lth(axe, u3h(u3h(lan)))) ) { - ank = u3nc(axe, u3qdb_put(u3_nul, loc, huc)); - return u3nc(ank, u3k(lan)); + par = u3nc(u3k(axe), u3qdb_put(u3_nul, pel, loc)); + return u3nc(par, u3k(lan)); } else { return u3nc(u3k(u3h(lan)), - _cj_register_new(u3t(lan), loc, huc, axe)); + _cj_mine_par_new(u3t(lan), axe, pel, loc)); } } -/* _cj_register(): register a location as an ancestor in a list of ancestors. +/* _cj_mine_par(): register a location as an ancestor in a list of ancestors. * RETAIN. */ static u3_noun -_cj_register(u3_noun lan, u3_noun loc, u3_noun huc, u3_noun axe) +_cj_mine_par(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) { - u3_weak old = _cj_register_old(lan, loc, huc, axe); + u3_weak old = _cj_mine_par_old(lan, axe, pel, loc); if ( u3_none != old ) { return old; } else { - return _cj_register_new(lan, loc, huc, axe); + return _cj_mine_par_new(lan, axe, pel, loc); } } @@ -807,30 +774,30 @@ _cj_register(u3_noun lan, u3_noun loc, u3_noun huc, u3_noun axe) static void _cj_mine(u3_noun cey, u3_noun cor) { - c3_l jax_l, par_l; - u3_weak par, pel; - u3_noun pac, rut, ger, pay, ank, bal, - nam, axe, huc, reg, loc, act; - u3_noun bat = u3h(cor); + c3_l jax_l; + u3_noun bat = u3h(cor), + reg, loc, bal, act, nam, axe, huc, ger; u3x_trel(cey, &nam, &axe, &huc); - if ( 0 == axe ) { - pay = u3t(cor); + u3_noun pay = u3t(cor); jax_l = 0; reg = _cj_find_cold(bat); - rut = u3nt(u3k(nam), u3k(pay), u3k(huc)); - loc = u3nt(c3y, c3y, rut); + loc = u3nt(u3nt(c3y, c3y, u3k(pay)), u3k(nam), u3k(huc)); if ( u3_none == reg ) { reg = u3nc(u3_nul, u3_nul); } - ger = u3nc(u3qdb_put(u3h(reg), pay, rut), u3k(u3t(reg))); + ger = u3nc(u3qdb_put(u3h(reg), pay, loc), u3k(u3t(reg))); u3z(reg); reg = ger; bal = u3nc(u3k(nam), u3_nul); act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); } else { + u3_weak par, pel, pac; + u3_noun pat; + c3_l par_l; + par = u3r_at(axe, cor); if ( u3_none == par || c3n == u3du(par) ) { fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(nam)); @@ -854,25 +821,26 @@ _cj_mine(u3_noun cey, u3_noun cor) _cj_warm_hump(jax_l, huc), bal, _cj_jit(jax_l, bat)); - loc = ( (3 == axe) && (c3y == u3h(pel)) ) - ? u3nt(c3y, c3n, u3nt(u3k(nam), pel, u3k(huc))) - : u3nc(c3n, u3nq(u3k(nam), u3k(axe), pel, u3k(huc))); + pat = ( ( 3 == axe ) && (c3y == u3h(pel)) ) + ? u3nt(c3y, c3n, u3k(pel)) + : u3nt(c3n, u3k(axe), u3k(pel)); + loc = u3nt(pat, u3k(nam), u3k(huc)); reg = _cj_find_cold(bat); if ( u3_none == reg ) { reg = u3nc(u3_nul, u3_nul); } - ank = _cj_register(u3t(reg), loc, huc, axe); - ger = u3nc(u3k(u3h(reg)), ank); - u3z(reg); + ger = u3nc(u3k(u3h(reg)), + _cj_mine_par(u3t(reg), axe, pel, loc)); + u3z(pel); u3z(reg); reg = ger; } - u3h_put(u3R->jed.cod_p, bat, reg); - u3h_put(u3R->jed.war_p, loc, act); - u3z(loc); #if 0 u3m_p("new jet", bal); fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); #endif + u3h_put(u3R->jed.cod_p, bat, reg); + u3h_put(u3R->jed.war_p, loc, act); + u3z(loc); } /* u3j_mine(): register core for jets. @@ -912,15 +880,15 @@ _cj_warm_reap(u3_noun kev) /* |% -+= battery ^ -+= hooks (map term axis) -+= root [name=term payload=* hooks] -+= branch [name=term parent=static hooks] -+= dynamic [name=term where=axis parent=location hooks] -+= static (each root branch) -+= location (each static dynamic) -+= registry [roots=(map * root) parents=(list ancestor)] -+= ancestor (pair axis (map location location)) ++= location $: pattern=(each static dynamic) + name=term + hooks=(map term axis) + == ++= static (each payload=* parent=static) ++= dynamic [where=axis parent=location] +:: ++= registry [roots=(map * location) parents=(list parent)] ++= parent (pair axis (map location location)) :: += activation $: hot-index=@ud drivers=(map axis @ud) @@ -928,17 +896,16 @@ _cj_warm_reap(u3_noun kev) jit=* == :: -+= cold (map battery registry) ++= cold (map battery=^ registry) += warm (map location activation) -- */ - -/* _cj_merge_ancestors(): merge ancestor lists. - * sel is TRANSFERRED. - * jul is RETAINED. +/* _cj_remarry(): merge parent lists. + * sel is TRANSFERRED. + * jul is RETAINED. */ static u3_noun -_cj_merge_ancestors(u3_noun sel, u3_noun jul) +_cj_remarry(u3_noun sel, u3_noun jul) { u3_noun kel, kev, i, j, ank, les, axe, loc, huc; for ( i = jul; u3_nul != i; i = u3t(i) ) { @@ -958,12 +925,12 @@ _cj_merge_ancestors(u3_noun sel, u3_noun jul) return sel; } -/* _cj_merge_roots(): merge root maps of ancestor. - * sor is TRANSFERRED. - * jor is RETAINED. +/* _cj_graft(): merge root maps of registry. + * sor is TRANSFERRED. + * jor is RETAINED. */ static u3_noun -_cj_merge_roots(u3_noun sor, u3_noun jor) +_cj_graft(u3_noun sor, u3_noun jor) { u3_noun i, rut, kel = u3qdb_tap(jor); for ( i = kel; u3_nul != i; i = u3t(i) ) { @@ -984,8 +951,8 @@ _cj_cold_reap(u3_noun kev) u3_weak ser = _cj_find_cold(bat); u3_noun reg = ( u3_none == ser ) ? u3a_take(jur) - : u3nc(_cj_merge_roots(u3k(u3h(ser)), u3h(jur)), - _cj_merge_ancestors(u3k(u3t(ser)), u3t(jur))); + : u3nc(_cj_graft(u3k(u3h(ser)), u3h(jur)), + _cj_remarry(u3k(u3t(ser)), u3t(jur))); u3h_put(u3R->jed.cod_p, bat, reg); u3z(ser); u3z(bat); } From 04d210509ade9d6ca766c9d00ae1457a0a45c9ac Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 30 Mar 2018 11:13:48 -0700 Subject: [PATCH 047/221] initial rewrite of dashboard --- noun/jets.c | 165 ++++++++++++++++++++++++++-------------------------- 1 file changed, 84 insertions(+), 81 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 44688344e..ccb3fbae7 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -878,28 +878,6 @@ _cj_warm_reap(u3_noun kev) u3z(loc); } -/* -|% -+= location $: pattern=(each static dynamic) - name=term - hooks=(map term axis) - == -+= static (each payload=* parent=static) -+= dynamic [where=axis parent=location] -:: -+= registry [roots=(map * location) parents=(list parent)] -+= parent (pair axis (map location location)) -:: -+= activation $: hot-index=@ud - drivers=(map axis @ud) - label=path - jit=* - == -:: -+= cold (map battery=^ registry) -+= warm (map location activation) --- -*/ /* _cj_remarry(): merge parent lists. * sel is TRANSFERRED. * jul is RETAINED. @@ -907,20 +885,20 @@ _cj_warm_reap(u3_noun kev) static u3_noun _cj_remarry(u3_noun sel, u3_noun jul) { - u3_noun kel, kev, i, j, ank, les, axe, loc, huc; + u3_noun kel, kev, i, j, par, les, axe, pel, loc; for ( i = jul; u3_nul != i; i = u3t(i) ) { - ank = u3h(i); - axe = u3a_take(u3h(ank)); - kel = u3qdb_tap(u3t(ank)); + par = u3h(i); + axe = u3a_take(u3h(par)); + kel = u3qdb_tap(u3t(par)); for ( j = kel; u3_nul != j; j = u3t(j) ) { kev = u3h(j); - loc = u3a_take(u3h(kev)); - huc = u3a_take(u3t(kev)); - les = _cj_register(sel, loc, huc, axe); - u3z(sel); u3z(loc); u3z(huc); + pel = u3a_take(u3h(kev)); + loc = u3a_take(u3t(kev)); + les = _cj_mine_par(sel, axe, pel, loc); + u3z(sel); u3z(pel); u3z(loc); sel = les; } - u3z(kel); u3z(ank); u3z(axe); + u3z(kel); u3z(axe); } return sel; } @@ -1088,30 +1066,28 @@ _cj_warm_ream_in(u3_noun taw) } -/* _cj_warm_ream_all(): tap cod_p to rel +/* _cj_warm_tap(): tap war_p to rel */ static u3_noun rel; static void -_cj_warm_ream_all(u3_noun kev) +_cj_warm_tap(u3_noun kev) { rel = u3nc(kev, u3k(rel)); } -/* u3j_ream(): rebuild warm state from cold state -*/ -void -u3j_ream(void) +/* _cj_ream(): ream list of battery registry pairs. RETAIN. + */ +static void +_cj_ream(u3_noun all) { - u3_noun rut, lan, bat, reg, kev, rem, dol, lok; - u3_weak pel; - u3h_free(u3R->jed.war_p); - u3R->jed.war_p = u3h_new(); - c3_assert(u3R == &(u3H->rod_u)); - rel = u3_nul; - u3h_walk(u3R->jed.cod_p, _cj_warm_ream_all); + c3_l par_l, jax_l; + u3_noun i, j, k, + all, lop, rul, loc, bal, act, lop, + pol, rem, rec, bat, pel, nam, huc; + u3_weak pac; - for ( lok = rel, dol = u3_nul; lok != u3_nul; lok = u3t(lok) ) { - kev = u3h(lok); + for ( i = all, lop = u3_nul; i != u3_nul; i = u3t(i) ) { + kev = u3h(i); bat = u3h(kev); reg = u3t(kev); rut = u3h(reg); @@ -1119,64 +1095,91 @@ u3j_ream(void) // register roots rul = u3qdb_tap(rut); jax_l = 0; - for ( rep = rul; rep != u3_nul; rep = u3t(rep) ) { - nut = u3h(rep); - rin = u3t(nut); - bal = u3nc(u3k(u3h(rin)), u3_nul); + for ( j = rul; j != u3_nul; j = u3t(j) ) { + loc = u3t(u3h(j)); + bal = u3nc(u3k(u3h(u3t(loc))), u3_nul); act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); - loc = u3nt(c3y, c3y, u3k(rin)); u3h_put(u3R->jed.war_p, loc, act); } u3z(rul); - // put ancestors in dol - for ( lan = u3t(reg); lan != u3_nul; lan = u3t(lan) ) { - ank = u3h(lan); - axe = u3h(ank); - kel = u3qdb_tap(u3t(ank)); - for ( pul = kel; pul != u3_nul; pul = u3t(pul) ) { - dol = u3nc(u3nc(u3k(axe, u3k(u3h(pul)))), u3k(dol)); + // put ancestors in lop (list [battery=^ parent=location this=location]) + for ( j = u3t(reg); j != u3_nul; j = u3t(j) ) { + pol = lop; + lop = u3qdb_tap(u3t(u3h(j))); + for ( k = lop; u3_nul != k; k = u3t(k) ) { + pol = u3nc(u3nc(u3k(bat), u3k(u3h(k))), pol); } - u3z(kel); + u3z(lop); + lop = pol; } } - u3z(rel); - while ( u3_nul != dol ) { - top = dol; + while ( u3_nul != lop ) { rem = u3_nul; - while ( u3_nul != dol ) { - rec = u3h(dol); - dol = u3t(dol); - u3x_qual(rec, &axe, &pel, &nam, &huc); + for ( i = lop; u3_nul != i; i = u3t(i) ) { + rec = u3h(i); + u3x_trel(rec, &bat, &pel, &loc); pac = _cj_find_warm(pel); if ( u3_none == pac ) { - rem = u3nc(u3k(rec), u3k(rem)); + rem = u3nc(u3k(rec), rem); } else { + u3x_trel(loc, &pat, &nam, &huc); par_l = u3h(pac); jax_l = _cj_hot_mean(par_l, nam); bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); u3z(pac); + act = u3nq(jax_l, _cj_warm_hump(jax_l, huc), bal, _cj_jit(jax_l, bat)); - loc = ( (3 == axe) && (c3y == u3h(pel)) ) - ? u3nt(c3y, c3n, u3nt(u3k(nam), pel, u3k(huc))) - : u3nc(c3n, u3nq(u3k(nam), u3k(axe), pel, u3k(huc))); - reg = _cj_find_cold(bat); + u3h_put(u3R->jed.war_p, loc, act); + u3z(loc); } + lop = u3t(lop); } - u3z(top); - dol = rem; - } - - w - for ( top = dol, rem = u3_nul; - dol != u3_nul; - = dol = rem ) { - rec = u3h(dol); - + u3z(lop); + lop = rem; } } + +/* u3j_ream(): rebuild warm state +*/ +void +u3j_ream(void) +{ + u3_noun rut, bat, reg, kev, rem, lop, i; + u3_weak pel; + u3h_free(u3R->jed.war_p); + u3R->jed.war_p = u3h_new(); + c3_assert(u3R == &(u3H->rod_u)); + rel = u3_nul; + u3h_walk(u3R->jed.cod_p, _cj_warm_tap); + _cj_ream(rel); + u3z(rel); +} + +/* XX FIXME: move to u3.md +|% ++= location $: pattern=(each static dynamic) + name=term + hooks=(map term axis) + == ++= static (each payload=* parent=static) ++= dynamic [where=axis parent=location] +:: ++= registry [roots=(map * location) parents=(list parent)] ++= parent (pair axis (map location location)) +:: ++= activation $: hot-index=@ud + drivers=(map axis @ud) + label=path + jit=* + == +:: ++= cold (map battery=^ registry) ++= warm (map location activation) +-- +*/ From 58e21b4d2e9f8a9296a384e1598c5b78c61d8dbe Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 30 Mar 2018 11:16:05 -0700 Subject: [PATCH 048/221] housekeeping --- noun/jets.c | 140 ++++------------------------------------------------ 1 file changed, 9 insertions(+), 131 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index ccb3fbae7..9e11ca2e8 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -944,137 +944,6 @@ u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p) u3h_walk(war_p, _cj_warm_reap); } -static c3_l _cj_warm_ream_at(u3_noun soh, u3_noun* lab, u3_noun cag); - -/* _cj_warm_ream_be(): install battery; RETAINS. -*/ -static void -_cj_warm_ream_be(c3_l jax_l, - u3_noun soh, - u3_noun lab, - u3_noun mop, - u3_noun bat, - u3_noun cuz) -{ -#if 0 - u3m_p("old jet", lab); - fprintf(stderr, " bat %x, soh %x, jax %d\r\n", - u3r_mug(bat), u3r_mug(soh), jax_l); -#endif - - u3h_put(u3R->jed.har_p, - bat, - u3nt(u3nq(jax_l, - _cj_warm_hump(jax_l, u3t(cuz)), - u3k(lab), - _cj_jit(jax_l, bat)), - u3nc(u3k(soh), u3k(mop)), - u3k(cuz))); -} - -/* _cj_warm_ream_is(): reream battery; RETAINS. -*/ -static void -_cj_warm_ream_is(c3_l jax_l, - u3_noun soh, - u3_noun lab, - u3_noun mop, - u3_noun sab) -{ - if ( u3_nul != sab ) { - u3_noun n_sab, l_sab, r_sab, pn_sab, qn_sab; - - u3x_trel(sab, &n_sab, &l_sab, &r_sab); - u3x_cell(n_sab, &pn_sab, &qn_sab); - - _cj_warm_ream_be(jax_l, soh, lab, mop, pn_sab, qn_sab); - _cj_warm_ream_is(jax_l, soh, lab, mop, l_sab); - _cj_warm_ream_is(jax_l, soh, lab, mop, r_sab); - } -} - -/* _cj_warm_ream_un(): reream under `soh`; RETAINS, transfers `*lab`. -*/ -static c3_l -_cj_warm_ream_un(u3_noun soh, u3_noun* lab) -{ - u3_noun cag = u3kdb_got(u3k(u3R->jed.das), u3k(soh)); - u3_noun sab = u3t(cag); - u3_noun cax; - c3_l jax_l; - - if ( u3_none != (cax = u3h_get(u3R->jed.har_p, u3h(u3h(sab)))) ) { - jax_l = u3h(u3h(cax)); - *lab = u3k(u3h(u3t(u3t(u3h(cax))))); - u3z(cax); - } - else { - jax_l = _cj_warm_ream_at(soh, lab, cag); - } - u3z(cag); - return jax_l; -} - -/* _cj_warm_ream_at(): reream at `soh` and `cag`; RETAINS, transfers `*lab`. -*/ -static c3_l -_cj_warm_ream_at(u3_noun soh, u3_noun* lab, u3_noun cag) -{ - u3_noun mop = u3h(cag); - u3_noun sab = u3t(cag); - u3_noun p_mop, q_mop, r_mop, hr_mop, tr_mop; - - u3x_trel(mop, &p_mop, &q_mop, &r_mop); - u3x_cell(r_mop, &hr_mop, &tr_mop); - { - c3_l par_l, jax_l; - u3_noun pal = u3_nul; - - if ( c3y == hr_mop ) { - par_l = _cj_warm_ream_un(tr_mop, &pal); - } - else { - par_l = 0; - pal = u3_nul; - } - *lab = u3nc(u3k(p_mop), pal); - jax_l = _cj_hot_mean(par_l, u3h(mop)); - - _cj_warm_ream_is(jax_l, soh, *lab, mop, sab); - return jax_l; - } -} - -/* _cj_warm_ream_in(): reream in `taw`; RETAINS. -*/ -static void -_cj_warm_ream_in(u3_noun taw) -{ - if ( u3_nul != taw ) { - u3_noun n_taw, l_taw, r_taw, pn_taw, qn_taw; - u3_noun lab; - - u3x_trel(taw, &n_taw, &l_taw, &r_taw); - u3x_cell(n_taw, &pn_taw, &qn_taw); - - _cj_warm_ream_at(pn_taw, &lab, qn_taw); - u3z(lab); - - _cj_warm_ream_in(l_taw); - _cj_warm_ream_in(r_taw); - } -} - - -/* _cj_warm_tap(): tap war_p to rel -*/ -static u3_noun rel; -static void -_cj_warm_tap(u3_noun kev) -{ - rel = u3nc(kev, u3k(rel)); -} - /* _cj_ream(): ream list of battery registry pairs. RETAIN. */ static void @@ -1145,6 +1014,15 @@ _cj_ream(u3_noun all) } } +/* _cj_warm_tap(): tap war_p to rel +*/ +static u3_noun rel; +static void +_cj_warm_tap(u3_noun kev) +{ + rel = u3nc(kev, u3k(rel)); +} + /* u3j_ream(): rebuild warm state */ void From 78d4d799594808b96876928dd3f30bac2948e8cf Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 30 Mar 2018 11:17:48 -0700 Subject: [PATCH 049/221] a clarifying comment --- noun/jets.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/noun/jets.c b/noun/jets.c index 9e11ca2e8..31e517929 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -984,6 +984,8 @@ _cj_ream(u3_noun all) } } + // ordering is random so we need to push onto rem when parent + // isn't yet present in the warm state while ( u3_nul != lop ) { rem = u3_nul; for ( i = lop; u3_nul != i; i = u3t(i) ) { From a61ed7df172f5e41bd0af838e81c6d79d1bdb6c2 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 30 Mar 2018 11:49:18 -0700 Subject: [PATCH 050/221] fix compile errors --- include/noun/jets.h | 8 +++++--- noun/jets.c | 34 ++++++++-------------------------- noun/manage.c | 14 +++++++------- noun/trace.c | 2 +- vere/raft.c | 4 ++-- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 321eb26f5..9bff76d89 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -96,10 +96,12 @@ u3j_soft(u3_noun cor, const c3_c* tam_c); - /* u3j_find(): in warm state, return u3_none or calx. RETAINS. + /* u3j_spot(): + ** + ** Identify `cor`s location. RETAIN. */ u3_weak - u3j_find(u3_noun bat); + u3j_spot(u3_noun cor); /* u3j_kick(): try to kick by jet. If no kick, produce u3_none. ** @@ -129,4 +131,4 @@ /* u3j_reap(): promote jet state. RETAINS. */ void - u3j_reap(u3_noun das, u3p(u3h_root) har_p); + u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p); diff --git a/noun/jets.c b/noun/jets.c index 31e517929..bfe5acce4 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -182,19 +182,6 @@ _cj_je_fsck(u3_noun clu) return u3nt(u3i_string(nam_c), axe_l, huk); } -/* _cj_sham(): ++sham. -*/ -static u3_atom -_cj_sham(u3_noun som) // XX wrong, does not match ++sham -{ - u3_atom jam = u3ke_jam(som); - u3_noun sha = u3qe_shax(jam); - u3_noun haf = u3qc_end(7, 1, sha); - - u3z(jam); u3z(sha); - return haf; -} - /* _cj_find_cold(): search cold state for `bat`s registry. * RETAIN. */ @@ -516,11 +503,12 @@ _cj_hook_in(u3_noun cor, return u3m_bail(c3__fail); } - tem = u3i_string(tam_c), + tem = u3i_string(tam_c); while ( 1 ) { - u3x_trel(loc, &pat, &name, &huc); + u3x_trel(loc, &pat, &nam, &huc); got = u3qdb_get(huc, tem); if ( u3_nul != got ) { + c3_l axe_l; u3_noun pro, fol; u3j_core* cop_u; @@ -532,8 +520,8 @@ _cj_hook_in(u3_noun cor, pro = u3n_nock_on(cor, fol); } else { - c3_l axe_l, inx_l; - u3_noun hap, act, pro, fol; + c3_l jax_l, inx_l; + u3_noun hap, act; u3z(fol); act = _cj_find_warm(loc); @@ -848,9 +836,6 @@ _cj_mine(u3_noun cey, u3_noun cor) void u3j_mine(u3_noun clu, u3_noun cor) { - u3_noun bat = u3h(cor); - u3_noun cax; - u3t_on(glu_o); if ( (c3n == u3du(cor)) || (c3y == _cj_scan(cor)) ) { u3z(clu); @@ -874,7 +859,7 @@ _cj_warm_reap(u3_noun kev) { u3_noun loc = u3a_take(u3h(kev)); u3_noun act = u3a_take(u3t(kev)); - u3h_put(u3R->jed.har_p, loc, act); + u3h_put(u3R->jed.war_p, loc, act); u3z(loc); } @@ -950,9 +935,8 @@ static void _cj_ream(u3_noun all) { c3_l par_l, jax_l; - u3_noun i, j, k, - all, lop, rul, loc, bal, act, lop, - pol, rem, rec, bat, pel, nam, huc; + u3_noun i, j, k, rul, loc, bal, act, lop, kev, rut, + pat, reg, pol, rem, rec, bat, pel, nam, huc; u3_weak pac; for ( i = all, lop = u3_nul; i != u3_nul; i = u3t(i) ) { @@ -1030,8 +1014,6 @@ _cj_warm_tap(u3_noun kev) void u3j_ream(void) { - u3_noun rut, bat, reg, kev, rem, lop, i; - u3_weak pel; u3h_free(u3R->jed.war_p); u3R->jed.war_p = u3h_new(); c3_assert(u3R == &(u3H->rod_u)); diff --git a/noun/manage.c b/noun/manage.c index 47ae65ad7..8f83c4a32 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -458,9 +458,9 @@ static void _pave_parts(void) { u3R->cax.har_p = u3h_new(); - u3R->jed.har_p = u3h_new(); + u3R->jed.war_p = u3h_new(); + u3R->jed.cod_p = u3h_new(); u3R->byc.har_p = u3h_new(); - u3R->jed.das = u3_nul; } /* u3m_mark(): mark all nouns in the road. @@ -469,9 +469,9 @@ c3_w u3m_mark(void) { c3_w tot_w = 0; - tot_w += u3h_mark(u3R->jed.har_p); + tot_w += u3h_mark(u3R->jed.war_p); + tot_w += u3h_mark(u3R->jed.cod_p); tot_w += u3n_bark(); - tot_w += u3a_mark_noun(u3R->jed.das); tot_w += u3a_mark_noun(u3R->ski.gul); tot_w += u3a_mark_noun(u3R->bug.tax); tot_w += u3a_mark_noun(u3R->bug.mer); @@ -797,15 +797,15 @@ u3_noun u3m_love(u3_noun pro) { { - u3_noun das = u3R->jed.das; - u3p(u3h_root) har_p = u3R->jed.har_p; + u3p(u3h_root) cod_p = u3R->jed.cod_p; + u3p(u3h_root) war_p = u3R->jed.war_p; u3p(u3h_root) byc_p = u3R->byc.har_p; u3m_fall(); pro = u3a_take(pro); - u3j_reap(das, har_p); + u3j_reap(cod_p, war_p); u3n_beep(byc_p); u3R->cap_p = u3R->ear_p; diff --git a/noun/trace.c b/noun/trace.c index 691ab3dd7..ce7bb8f9c 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -241,7 +241,7 @@ u3t_samp(void) c3_o u3t_come(u3_noun lab) { - if ( (u3_nul == u3R->pro.don) || !_(u3r_sing(bal, u3h(u3R->pro.don))) ) { + if ( (u3_nul == u3R->pro.don) || !_(u3r_sing(lab, u3h(u3R->pro.don))) ) { u3R->pro.don = u3nc(u3k(lab), u3R->pro.don); return c3y; } diff --git a/vere/raft.c b/vere/raft.c index bfd4036dd..6f66b31b0 100644 --- a/vere/raft.c +++ b/vere/raft.c @@ -1880,11 +1880,11 @@ _raft_grab(u3_noun ova) fprintf(stderr, "arvo stuff: "); _raft_print_memory(utv_w); - har_w = u3h_mark(u3R->jed.har_p); + har_w = u3h_mark(u3R->jed.war_p); fprintf(stderr, " warm jet state: "); _raft_print_memory(har_w); - das_w = u3a_mark_noun(u3R->jed.das); + das_w = u3h_mark(u3R->jed.cod_p); fprintf(stderr, " cold jet state: "); _raft_print_memory(das_w); From b8506c70eae93034e9f8a9cf9147ed13daa95459 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 30 Mar 2018 13:01:03 -0700 Subject: [PATCH 051/221] bugfixes --- noun/jets.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index bfe5acce4..430373efc 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -237,7 +237,7 @@ u3j_spot(u3_noun cor) } else { u3_noun rut = u3h(reg), - lan = u3t(reg), + pas = u3t(reg), rum = u3qdb_get(rut, u3t(cor)); if ( u3_nul != rum ) { u3_noun loc = u3k(u3t(rum)); @@ -245,10 +245,10 @@ u3j_spot(u3_noun cor) return loc; } else { - while ( u3_nul != lan ) { - u3_noun pas = u3h(lan), - axe = u3h(pas), - lol = u3t(pas); + while ( u3_nul != pas ) { + u3_noun pap = u3h(pas), + axe = u3h(pap), + lol = u3t(pap); u3_weak par = u3r_at(axe, cor), pel; if ( u3_none != par ) { @@ -263,7 +263,7 @@ u3j_spot(u3_noun cor) } } } - lan = u3t(lan); + pas = u3t(pas); } return u3_none; } @@ -276,7 +276,7 @@ static c3_o _cj_scan(u3_noun cor) { u3_weak loc = u3j_spot(cor); - c3_o reg_o = (u3_none == loc) ? c3y : c3n; + c3_o reg_o = (u3_none == loc) ? c3n : c3y; u3z(loc); return reg_o; } @@ -809,7 +809,7 @@ _cj_mine(u3_noun cey, u3_noun cor) _cj_warm_hump(jax_l, huc), bal, _cj_jit(jax_l, bat)); - pat = ( ( 3 == axe ) && (c3y == u3h(pel)) ) + pat = ( ( 3 == axe ) && (c3y == u3h(u3h(pel))) ) ? u3nt(c3y, c3n, u3k(pel)) : u3nt(c3n, u3k(axe), u3k(pel)); loc = u3nt(pat, u3k(nam), u3k(huc)); From 4fc65663c6b5e963db2adfcadf95b18c914b71e8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 31 Mar 2018 13:51:41 -0700 Subject: [PATCH 052/221] more bugfixes: now boots and restores from checkpoint --- noun/jets.c | 119 +++++++++++++++++++++++++++++--------------------- noun/manage.c | 4 +- 2 files changed, 72 insertions(+), 51 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 430373efc..9b2d245ad 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -710,7 +710,7 @@ _cj_mine_par_old(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) if ( u3_nul == lan ) { return u3_none; } - else if ( u3r_sing(axe, u3h(par = u3h(lan))) ) { + else if ( c3y == u3r_sing(axe, u3h(par = u3h(lan))) ) { u3_noun lol = u3qdb_put(u3t(par), pel, loc), rap = u3nc(u3k(axe), lol); return u3nc(rap, u3k(u3t(lan))); @@ -762,14 +762,13 @@ _cj_mine_par(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) static void _cj_mine(u3_noun cey, u3_noun cor) { - c3_l jax_l; + c3_l par_l, jax_l; u3_noun bat = u3h(cor), - reg, loc, bal, act, nam, axe, huc, ger; + hap, reg, loc, bal, act, nam, axe, huc, ger; u3x_trel(cey, &nam, &axe, &huc); if ( 0 == axe ) { u3_noun pay = u3t(cor); - jax_l = 0; reg = _cj_find_cold(bat); loc = u3nt(u3nt(c3y, c3y, u3k(pay)), u3k(nam), u3k(huc)); if ( u3_none == reg ) { @@ -779,12 +778,11 @@ _cj_mine(u3_noun cey, u3_noun cor) u3z(reg); reg = ger; bal = u3nc(u3k(nam), u3_nul); - act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); + par_l = 0; } else { u3_weak par, pel, pac; u3_noun pat; - c3_l par_l; par = u3r_at(axe, cor); if ( u3_none == par || c3n == u3du(par) ) { @@ -802,13 +800,8 @@ _cj_mine(u3_noun cey, u3_noun cor) pac = _cj_find_warm(pel); c3_assert(u3_none != pac); par_l = u3h(pac); - jax_l = _cj_hot_mean(par_l, nam); bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); u3z(pac); - act = u3nq(jax_l, - _cj_warm_hump(jax_l, huc), - bal, - _cj_jit(jax_l, bat)); pat = ( ( 3 == axe ) && (c3y == u3h(u3h(pel))) ) ? u3nt(c3y, c3n, u3k(pel)) : u3nt(c3n, u3k(axe), u3k(pel)); @@ -822,10 +815,13 @@ _cj_mine(u3_noun cey, u3_noun cor) u3z(pel); u3z(reg); reg = ger; } + jax_l = _cj_hot_mean(par_l, nam); #if 0 u3m_p("new jet", bal); fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); #endif + hap = _cj_warm_hump(jax_l, huc); + act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); u3h_put(u3R->jed.cod_p, bat, reg); u3h_put(u3R->jed.war_p, loc, act); u3z(loc); @@ -863,6 +859,25 @@ _cj_warm_reap(u3_noun kev) u3z(loc); } +/* _cj_uni_jun(): merge junior map into senior map. + * sem is TRANSFERRED. + * jum is RETAINED. + */ +static u3_noun +_cj_uni_jun(u3_noun sem, u3_noun jum) +{ + if ( u3_nul == jum ) { + return sem; + } + else { + u3_noun n, l, r; + u3x_trel(jum, &n, &l, &r); + sem = _cj_uni_jun(sem, l); + sem = _cj_uni_jun(sem, r); + return u3kdb_put(sem, u3a_take(u3h(n)), u3a_take(u3t(n))); + } +} + /* _cj_remarry(): merge parent lists. * sel is TRANSFERRED. * jul is RETAINED. @@ -870,38 +885,35 @@ _cj_warm_reap(u3_noun kev) static u3_noun _cj_remarry(u3_noun sel, u3_noun jul) { - u3_noun kel, kev, i, j, par, les, axe, pel, loc; - for ( i = jul; u3_nul != i; i = u3t(i) ) { - par = u3h(i); - axe = u3a_take(u3h(par)); - kel = u3qdb_tap(u3t(par)); - for ( j = kel; u3_nul != j; j = u3t(j) ) { - kev = u3h(j); - pel = u3a_take(u3h(kev)); - loc = u3a_take(u3t(kev)); - les = _cj_mine_par(sel, axe, pel, loc); - u3z(sel); u3z(pel); u3z(loc); - sel = les; + if ( u3_nul == sel ) { + return u3a_take(jul); + } + else if ( u3_nul == jul ) { + return sel; + } + else { + u3_noun sap = u3h(sel), + jup = u3h(jul), + sax = u3h(sap), + jux = u3h(jup); + if ( c3y == u3r_sing(sax, jux) ) { + u3_noun lol = _cj_uni_jun(u3k(u3t(sap)), u3t(jup)), + par = u3nc(u3k(u3h(sap)), lol), + nex = _cj_remarry(u3k(u3t(sel)), u3t(jul)), + pro = u3nc(par, nex); + u3z(sel); + return pro; + } + else if ( c3y == u3qa_lth(sax, jux) ) { + u3_noun nex = _cj_remarry(u3k(u3t(sel)), jul), + pro = u3nc(u3k(sap), nex); + u3z(sel); + return pro; + } + else { + return u3nc(u3a_take(jup), _cj_remarry(sel, u3t(jul))); } - u3z(kel); u3z(axe); } - return sel; -} - -/* _cj_graft(): merge root maps of registry. - * sor is TRANSFERRED. - * jor is RETAINED. - */ -static u3_noun -_cj_graft(u3_noun sor, u3_noun jor) -{ - u3_noun i, rut, kel = u3qdb_tap(jor); - for ( i = kel; u3_nul != i; i = u3t(i) ) { - rut = u3h(i); - sor = u3kdb_put(sor, u3a_take(u3h(rut)), u3a_take(u3t(rut))); - } - u3z(kel); - return sor; } /* _cj_cold_reap(): reap cold dashboard entries. @@ -914,7 +926,7 @@ _cj_cold_reap(u3_noun kev) u3_weak ser = _cj_find_cold(bat); u3_noun reg = ( u3_none == ser ) ? u3a_take(jur) - : u3nc(_cj_graft(u3k(u3h(ser)), u3h(jur)), + : u3nc(_cj_uni_jun(u3k(u3h(ser)), u3h(jur)), _cj_remarry(u3k(u3t(ser)), u3t(jur))); u3h_put(u3R->jed.cod_p, bat, reg); u3z(ser); u3z(bat); @@ -935,7 +947,7 @@ static void _cj_ream(u3_noun all) { c3_l par_l, jax_l; - u3_noun i, j, k, rul, loc, bal, act, lop, kev, rut, + u3_noun i, j, k, rul, loc, bal, act, lop, kev, rut, hap, pat, reg, pol, rem, rec, bat, pel, nam, huc; u3_weak pac; @@ -947,11 +959,17 @@ _cj_ream(u3_noun all) // register roots rul = u3qdb_tap(rut); - jax_l = 0; for ( j = rul; j != u3_nul; j = u3t(j) ) { - loc = u3t(u3h(j)); - bal = u3nc(u3k(u3h(u3t(loc))), u3_nul); - act = u3nq(jax_l, u3_nul, bal, _cj_jit(jax_l, bat)); + loc = u3t(u3h(j)); + u3x_trel(loc, &pat, &nam, &huc); + bal = u3nc(u3k(nam), u3_nul); + jax_l = _cj_hot_mean(0, nam); + hap = _cj_warm_hump(jax_l, huc); + act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); +#if 0 + u3m_p("old jet", bal); + fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); +#endif u3h_put(u3R->jed.war_p, loc, act); } u3z(rul); @@ -990,8 +1008,11 @@ _cj_ream(u3_noun all) _cj_warm_hump(jax_l, huc), bal, _cj_jit(jax_l, bat)); +#if 0 + u3m_p("old jet", bal); + fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); +#endif u3h_put(u3R->jed.war_p, loc, act); - u3z(loc); } lop = u3t(lop); } @@ -1006,7 +1027,7 @@ static u3_noun rel; static void _cj_warm_tap(u3_noun kev) { - rel = u3nc(kev, u3k(rel)); + rel = u3nc(u3k(kev), u3k(rel)); } /* u3j_ream(): rebuild warm state diff --git a/noun/manage.c b/noun/manage.c index 8f83c4a32..319482cb6 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -509,9 +509,9 @@ void u3m_clear(void) { u3h_free(u3R->cax.har_p); - u3h_free(u3R->jed.har_p); + u3h_free(u3R->jed.war_p); + u3h_free(u3R->jed.cod_p); u3n_bree(); - u3a_lose(u3R->jed.das); } void From a078e03f3328e0e12fe113d8c8541d2f75bb2a74 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 31 Mar 2018 14:27:19 -0700 Subject: [PATCH 053/221] fix a memory leak in u3j_spot --- noun/jets.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 9b2d245ad..88b7f62c7 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -241,7 +241,7 @@ u3j_spot(u3_noun cor) rum = u3qdb_get(rut, u3t(cor)); if ( u3_nul != rum ) { u3_noun loc = u3k(u3t(rum)); - u3z(rum); + u3z(rum); u3z(reg); return loc; } else { @@ -258,13 +258,14 @@ u3j_spot(u3_noun cor) u3z(pel); if ( u3_nul != nit ) { u3_noun loc = u3k(u3t(nit)); - u3z(nit); + u3z(nit); u3z(reg); return loc; } } } pas = u3t(pas); } + u3z(reg); return u3_none; } } From 9b00b2084d050197a9218877ee0e6ac3bc3ae010 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 31 Mar 2018 15:15:29 -0700 Subject: [PATCH 054/221] fix memory errors in ream: boot and resume now pass memory checker --- noun/jets.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 88b7f62c7..c7d05cbe5 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1003,19 +1003,15 @@ _cj_ream(u3_noun all) par_l = u3h(pac); jax_l = _cj_hot_mean(par_l, nam); bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); + hap = _cj_warm_hump(jax_l, huc), u3z(pac); - - act = u3nq(jax_l, - _cj_warm_hump(jax_l, huc), - bal, - _cj_jit(jax_l, bat)); + act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); #if 0 u3m_p("old jet", bal); fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); #endif u3h_put(u3R->jed.war_p, loc, act); } - lop = u3t(lop); } u3z(lop); lop = rem; @@ -1028,7 +1024,7 @@ static u3_noun rel; static void _cj_warm_tap(u3_noun kev) { - rel = u3nc(u3k(kev), u3k(rel)); + rel = u3nc(u3k(kev), rel); } /* u3j_ream(): rebuild warm state From 41fd9cf287c1faecb9ff92822b85711d91e7aecf Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 2 Apr 2018 11:39:03 -0700 Subject: [PATCH 055/221] surface allocate label in profile sample --- noun/allocate.c | 2 ++ noun/trace.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/noun/allocate.c b/noun/allocate.c index 92af40851..ddb0e0cdd 100644 --- a/noun/allocate.c +++ b/noun/allocate.c @@ -1736,7 +1736,9 @@ u3a_sweep(void) : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w)))), box_u->use_w); u3a_print_memory("leak (minimum)", box_u->siz_w); + // fprintf(stderr, "\r\n\r\n"); // u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); + // fprintf(stderr, "\r\n\r\n"); leq_w += box_u->siz_w; } if ( box_u->cod_w ) { diff --git a/noun/trace.c b/noun/trace.c index ce7bb8f9c..97af57b86 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -122,7 +122,13 @@ _t_samp_process(u3_road* rod_u) u3_noun don = rod_u->pro.don; while ( u3_nul != don ) { - u3_noun lab = u3h(don); + // Get surface allocated label + // + // u3_noun lab = u3nc(u3i_string("foobar"), 0); + u3_noun laj = u3h(don), + lab = u3a_take(laj); + u3a_wash(laj); + // Add the label to the traced label stack, trimming recursion. // { From 03763e48177b0098961130f6d0e30aa174fc601c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 2 Apr 2018 14:08:28 -0700 Subject: [PATCH 056/221] fix profiling leaks --- include/noun/hashtable.h | 10 ++++++++- noun/hashtable.c | 39 +++++++++++++++++++++++++--------- noun/nock.c | 46 ++++++++++++++++++++++++++-------------- 3 files changed, 68 insertions(+), 27 deletions(-) diff --git a/include/noun/hashtable.h b/include/noun/hashtable.h index 93c34f487..127514afd 100644 --- a/include/noun/hashtable.h +++ b/include/noun/hashtable.h @@ -141,7 +141,15 @@ c3_w u3h_mark(u3p(u3h_root) har_p); - /* u3h_walk(): traverse hashtable with key, value fn; RETAINS. + /* u3h_walk_with(): traverse hashtable with key, value fn and data + * argument; RETAINS. + */ + void + u3h_walk_with(u3p(u3h_root) har_p, + void (*fun_f)(u3_noun, void*), + void* wit); + + /* u3h_walk(): u3h_walk_with, but with no data argument */ void u3h_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun)); diff --git a/noun/hashtable.c b/noun/hashtable.c index 410119f7f..c54dc3136 100644 --- a/noun/hashtable.c +++ b/noun/hashtable.c @@ -767,19 +767,19 @@ u3h_free(u3p(u3h_root) har_p) /* _ch_walk_buck(): walk bucket for gc. */ static void -_ch_walk_buck(u3h_buck* hab_u, void (*fun_f)(u3_noun)) +_ch_walk_buck(u3h_buck* hab_u, void (*fun_f)(u3_noun, void*), void* wit) { c3_w i_w; for ( i_w = 0; i_w < hab_u->len_w; i_w++ ) { - fun_f(u3h_slot_to_noun(hab_u->sot_w[i_w])); + fun_f(u3h_slot_to_noun(hab_u->sot_w[i_w]), wit); } } /* _ch_walk_node(): walk node for gc. */ static void -_ch_walk_node(u3h_node* han_u, c3_w lef_w, void (*fun_f)(u3_noun)) +_ch_walk_node(u3h_node* han_u, c3_w lef_w, void (*fun_f)(u3_noun, void*), void* wit) { c3_w len_w = _ch_popcount(han_u->map_w); c3_w i_w; @@ -792,24 +792,27 @@ _ch_walk_node(u3h_node* han_u, c3_w lef_w, void (*fun_f)(u3_noun)) if ( _(u3h_slot_is_noun(sot_w)) ) { u3_noun kev = u3h_slot_to_noun(sot_w); - fun_f(kev); + fun_f(kev, wit); } else { void* hav_v = u3h_slot_to_node(sot_w); if ( 0 == lef_w ) { - _ch_walk_buck(hav_v, fun_f); + _ch_walk_buck(hav_v, fun_f, wit); } else { - _ch_walk_node(hav_v, lef_w, fun_f); + _ch_walk_node(hav_v, lef_w, fun_f, wit); } } } } -/* u3h_walk(): walk hashtable for gc. +/* u3h_walk_with(): traverse hashtable with key, value fn and data + * argument; RETAINS. */ void -u3h_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun)) +u3h_walk_with(u3p(u3h_root) har_p, + void (*fun_f)(u3_noun, void*), + void* wit) { u3h_root* har_u = u3to(u3h_root, har_p); c3_w i_w; @@ -820,16 +823,32 @@ u3h_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun)) if ( _(u3h_slot_is_noun(sot_w)) ) { u3_noun kev = u3h_slot_to_noun(sot_w); - fun_f(kev); + fun_f(kev, wit); } else if ( _(u3h_slot_is_node(sot_w)) ) { u3h_node* han_u = u3h_slot_to_node(sot_w); - _ch_walk_node(han_u, 25, fun_f); + _ch_walk_node(han_u, 25, fun_f, wit); } } } +/* _ch_walk_plain(): use plain u3_noun fun_f for each node + */ +static void +_ch_walk_plain(u3_noun kev, void* wit) +{ + void (*fun_f)(u3_noun) = wit; + fun_f(kev); +} + +/* u3h_walk(): u3h_walk_with, but with no data argument +*/ +void +u3h_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun)) +{ + u3h_walk_with(har_p, _ch_walk_plain, fun_f); +} /* _ch_mark_buck(): mark bucket for gc. */ diff --git a/noun/nock.c b/noun/nock.c index ac562baf1..d083f7f78 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1153,13 +1153,23 @@ _n_bite(u3_noun fol) static inline c3_y* _n_find(u3_noun fol) { + /* check on the home road first. not only is this likely to be faster, it + * protects us from things which compile bytecode on the home road + * mid-computation (like u3t_samp()) + */ u3a_road* rod_u = u3R; + u3a_road* hom_u = &(u3H->rod_u); + u3_weak byc = u3h_gut(hom_u->byc.har_p, fol); - while ( 1 ) { - u3_weak jaw = u3h_gut(rod_u->byc.har_p, fol); + if ( u3_none != byc ) { + return u3a_into(byc); + } - if ( u3_none != jaw ) { - return u3a_into(jaw); + while ( rod_u != hom_u ) { + byc = u3h_gut(rod_u->byc.har_p, fol); + + if ( u3_none != byc ) { + return u3a_into(byc); } if ( rod_u->par_p ) { @@ -1894,10 +1904,15 @@ _n_reap(u3_noun kev) u3_noun fol = u3h(kev); u3_noun got = u3t(kev); u3_noun lof = u3a_take(fol); - c3_y* pog = u3a_into(got); - c3_y* gop = _n_take_byc(pog); - u3_noun tog = u3a_outa(gop); - u3h_put(u3R->byc.har_p, lof, tog); + u3_weak con = u3h_get(u3R->byc.har_p, lof); + // u3t_samp() etc. can interrupt us while we're compiling + // so we need to avoid leaking any parent bytecode + if ( u3_none == con ) { + c3_y* pog = u3a_into(got); + c3_y* gop = _n_take_byc(pog); + u3_noun tog = u3a_outa(gop); + u3h_put(u3R->byc.har_p, lof, tog); + } u3z(lof); } @@ -1950,15 +1965,14 @@ _n_mark_byc(c3_y* pog) return tot_w; } -static c3_w bam_w; - -/* _n_bam(): u3h_walk helper for u3n_bark +/* _n_bam(): u3h_walk_with helper for u3n_bark */ static void -_n_bam(u3_noun kev) +_n_bam(u3_noun kev, void* dat) { - c3_y* pog = u3a_into(u3t(kev)); - bam_w += _n_mark_byc(pog); + c3_w* bam_w = dat; + c3_y* pog = u3a_into(u3t(kev)); + *bam_w += _n_mark_byc(pog); } /* u3n_bark(): mark the bytecode cache for gc. @@ -1966,9 +1980,9 @@ _n_bam(u3_noun kev) c3_w u3n_bark() { + c3_w bam_w = 0; u3p(u3h_root) har_p = u3R->byc.har_p; - bam_w = 0; - u3h_walk(har_p, _n_bam); + u3h_walk_with(har_p, _n_bam, &bam_w); return bam_w + u3h_mark(har_p); } From cd342ab1c1a0eb26faf49dda9f6e6cf207fae13c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 2 Apr 2018 18:38:24 -0700 Subject: [PATCH 057/221] make come and flee more atomic profiler and mememory checker are working properly now (and together) --- noun/trace.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/noun/trace.c b/noun/trace.c index 97af57b86..29a4daca9 100644 --- a/noun/trace.c +++ b/noun/trace.c @@ -5,6 +5,8 @@ #include "all.h" #include +static c3_o _ct_lop_o; + /* u3t_push(): push on trace stack. */ void @@ -106,6 +108,18 @@ u3t_heck(u3_atom cog) } } +#if 0 +static void +_ct_sane(u3_noun lab) +{ + if ( u3_nul != lab ) { + c3_assert(c3y == u3du(lab)); + c3_assert(c3y == u3ud(u3h(lab))); + _ct_sane(u3t(lab)); + } +} +#endif + #if 1 /* _t_samp_process(): process raw sample data from live road. */ @@ -186,6 +200,12 @@ _t_samp_process(u3_road* rod_u) void u3t_samp(void) { + if ( c3y == _ct_lop_o ) { + // _ct_lop_o here is a mutex for modifying pro.don. we + // do not want to sample in the middle of doing that, as + // it can cause memory errors. + return; + } u3C.wag_w &= ~u3o_debug_cpu; static int home = 0; @@ -248,7 +268,10 @@ c3_o u3t_come(u3_noun lab) { if ( (u3_nul == u3R->pro.don) || !_(u3r_sing(lab, u3h(u3R->pro.don))) ) { - u3R->pro.don = u3nc(u3k(lab), u3R->pro.don); + u3a_gain(lab); + _ct_lop_o = c3y; + u3R->pro.don = u3nc(lab, u3R->pro.don); + _ct_lop_o = c3n; return c3y; } else return c3n; @@ -259,10 +282,11 @@ u3t_come(u3_noun lab) void u3t_flee(void) { - u3_noun t_don = u3k(u3t(u3R->pro.don)); - - u3z(u3R->pro.don); - u3R->pro.don = t_don; + _ct_lop_o = c3y; + u3_noun don = u3R->pro.don; + u3R->pro.don = u3k(u3t(don)); + _ct_lop_o = c3n; + u3z(don); } extern FILE* @@ -355,6 +379,7 @@ void u3t_boot(void) { if ( u3C.wag_w & u3o_debug_cpu ) { + _ct_lop_o = c3n; #if defined(U3_OS_osx) #if 1 { From c027d8aca4ef14bed89bbb5ce9e77ecde30ddb72 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 3 Apr 2018 20:28:44 -0700 Subject: [PATCH 058/221] fix (untriggered) memory leak in _cj_hook_in) --- noun/jets.c | 1 + 1 file changed, 1 insertion(+) diff --git a/noun/jets.c b/noun/jets.c index c7d05cbe5..5fecf7b40 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -567,6 +567,7 @@ _cj_hook_in(u3_noun cor, u3z(loc); loc = col; roc = u3k(u3t(cor)); + u3z(cor); cor = roc; } } From d25b3d04b1756e99a62aadcba53a5a7eb7dda622 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 4 Apr 2018 11:51:21 -0700 Subject: [PATCH 059/221] use walk_with in u3j_ream --- noun/jets.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 5fecf7b40..a6782b8e9 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1021,11 +1021,11 @@ _cj_ream(u3_noun all) /* _cj_warm_tap(): tap war_p to rel */ -static u3_noun rel; static void -_cj_warm_tap(u3_noun kev) +_cj_warm_tap(u3_noun kev, void* wit) { - rel = u3nc(u3k(kev), rel); + u3_noun* rel = wit; + *rel = u3nc(u3k(kev), *rel); } /* u3j_ream(): rebuild warm state @@ -1033,11 +1033,11 @@ _cj_warm_tap(u3_noun kev) void u3j_ream(void) { + u3_noun rel = u3_nul; u3h_free(u3R->jed.war_p); u3R->jed.war_p = u3h_new(); c3_assert(u3R == &(u3H->rod_u)); - rel = u3_nul; - u3h_walk(u3R->jed.cod_p, _cj_warm_tap); + u3h_walk_with(u3R->jed.cod_p, _cj_warm_tap, &rel); _cj_ream(rel); u3z(rel); } From c619f27b08b9d9b3a05f000148d0bd825e5cca69 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 11 Apr 2018 16:30:57 -0700 Subject: [PATCH 060/221] stash --- noun/nock.c | 1429 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 887 insertions(+), 542 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index d083f7f78..be33a1869 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -433,74 +433,489 @@ _n_nock_on(u3_noun bus, u3_noun fol) } #endif -/* These must match the order in the section marked OPCODE TABLE */ -#define HALT 0 -#define BAIL 1 -#define COPY 2 -#define SWAP 3 -#define TOSS 4 -#define AUTO 5 -#define AULT 6 -#define HEAD 7 -#define HELD 8 -#define TAIL 9 -#define TALL 10 -#define FRAS 11 -#define FRAG 12 -#define FRAB 13 -#define FLAS 14 -#define FLAG 15 -#define FLAB 16 -#define LIT0 17 -#define LIT1 18 -#define LITB 19 -#define LITS 20 -#define LITN 21 -#define LIL0 22 -#define LIL1 23 -#define LILB 24 -#define LILS 25 -#define LILN 26 -#define NOLK 27 -#define NOCT 28 -#define NOCK 29 -#define DEEP 30 -#define BUMP 31 -#define SAM0 32 -#define SAM1 33 -#define SAMB 34 -#define SAMS 35 -#define SAMN 36 -#define SAME 37 -#define SALM 38 -#define SAMC 39 -#define SKIP 40 -#define SBIP 41 -#define SKIN 42 -#define SBIN 43 -#define SNOC 44 -#define SNOL 45 -#define SLAM 46 -#define KICB 47 -#define KICS 48 -#define KICK 49 -#define SLAT 50 -#define TICB 51 -#define TICS 52 -#define TICK 53 -#define WILS 54 -#define WISH 55 -#define CUSH 56 -#define DROP 57 -#define HECK 58 -#define SLOG 59 -#define FALT 60 -#define FAST 61 -#define SKIB 62 -#define SKIM 63 -#define SLIB 64 -#define SLIM 65 -#define SAVE 66 +/* These must match the order in the section marked OPCODE TABLE, + * and several opcodes "overflow" (from byte to short index) to + * their successor, so order can matter here. */ +// general purpose +#define HALT 0 +#define BAIL 1 +#define COPY 2 +#define SWAP 3 +#define TOSS 4 +#define AUTO 5 +#define AULT 6 +#define SNOC 7 +#define SNOL 8 +#define HEAD 9 +#define HELD 10 +#define TAIL 11 +#define TALL 12 +// fragment (keep) +#define FABK 13 +#define FASK 14 +#define FIBK 15 +#define FISK 16 +// fragment (lose) +#define FABL 17 +#define FASL 18 +#define FIBL 19 +#define FISL 20 +// literal (keep) +#define LIT0 21 +#define LIT1 22 +#define LITB 23 +#define LITS 24 +#define LIBK 25 +#define LISK 26 +// literal (lose) +#define LIL0 27 +#define LIL1 28 +#define LILB 29 +#define LILS 30 +#define LIBL 31 +#define LISL 32 +// nock +#define NOLK 33 +#define NOCT 34 +#define NOCK 35 +// 3 & 4 +#define DEEP 36 +#define BUMP 37 +// equality +#define SAM0 38 +#define SAM1 39 +#define SAMB 40 +#define SAMS 41 +#define SANB 42 +#define SANS 43 +#define SAME 44 +#define SALM 45 +#define SAMC 46 +// unconditional skips +#define SBIP 47 +#define SIPS 48 +#define SWIP 49 +// conditional skips +#define SBIN 50 +#define SINS 51 +#define SWIN 52 +// nock 9 +#define KICB 53 +#define KICS 54 +#define TICB 55 +#define TICS 56 +// nock 11 +#define WILS 57 +#define WISH 58 +// hint processing +#define BUSH 59 +#define SUSH 60 +#define DROP 61 +#define HECK 62 +#define SLOG 63 +// fast (keep) +#define BAST 64 +#define SAST 65 +// fast (lose) +#define BALT 66 +#define SALT 67 +// memo (keep) +#define SKIB 68 +#define SKIS 69 +// memo (lose) +#define SLIB 70 +#define SLIS 71 +#define SAVE 72 + + +/* placeholder: call site memory */ +typedef struct { + u3_noun axe; +} _n_site; + +/* placeholder: registration site memory */ +typedef struct { + c3_w nul_w; +} _n_rite; + +typedef struct { + c3_w sip_w; + u3_noun key; +} _n_memo; + +typedef struct { + c3_w len_w; + _n_memo* sot_u; +} _n_prog_memo; + +typedef struct { + c3_w len_w; + u3_noun* non; +} _n_prog_lit; + +typedef struct { + c3_o own_w; + c3_w len_w; + c3_y* ops_u; +} _n_prog_ops; + +typedef struct { + c3_w len_w; + _n_site* sit_u; +} _n_prog_call; + +typedef struct { + c3_w len_w; + _n_rite* rit_u; +} _n_prog_reg; + +typedef struct { + _n_prog_ops byc_u; + _n_prog_lit lit_u; + _n_prog_memo mem_u; + _n_prog_call cal_u; + _n_prog_reg reg_u; + void* dat[0]; +} _n_prog; + +/* _n_melt(): measure space for list of ops (from _n_comp) */ +static void +_n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, + c3_w* reg_w, c3_w* lit_w, c3_w* mem_w) +{ + c3_w i_w; + + while ( u3_nul != ops ) { + op = u3h(ops); + if ( c3n == u3du(op) ) { + ++(*byc_w); + } + else { + cod_y = u3h(op); + + switch ( cod_y ) { + default: + *byc_w += _n_arg(cod_y) + 1; + break; + + case SAST: case SALT: case KICS: case TICS: + case FISK: case FISL: case SUSH: case SANS: + case LISL: case LISK: case SKIS: case SLIS: + c3_assert(0); //overflows + break; + + case KICB: case TICB: + i_w = (*cal_w)++; + if ( i_w <= 0xFF ) { + *byc_w += 2; + } + else if ( i_w <= 0xFFFF ) { + *byc_w += 3; + } + else { + fprintf(stderr, "_n_melt(): over 2^16 call sites.\r\n"); + c3_assert(0); + } + break; + + case BAST: case BALT: + i_w = (*reg_w)++; + if ( i_w <= 0xFF ) { + *byc_w += 2; + } + else if ( i_w <= 0xFFFF ) { + *byc_w += 3; + } + else { + fprintf(stderr, "_n_melt(): over 2^16 registration sites.\r\n"); + c3_assert(0); + } + break; + + case BUSH: case FIBK: case FIBL: + case SANB: case LIBL: case LIBK: + i_w = (*lit_w)++; + if ( i_w <= 0xFF ) { + *byc_w += 2; + } + else if ( i_w <= 0xFFFF ) { + *byc_w += 3; + } + else { + fprintf(stderr, "_n_melt(): over 2^16 literals.\r\n"); + c3_assert(0); + } + break; + + case SKIB: case SLIB: + i_w = (*mem_w)++; + if ( i_w <= 0xFF ) { + *byc_w += 2; + } + else if ( i_w <= 0xFFFF ) { + *byc_w += 3; + } + else { + fprintf(stderr, "_n_melt(): over 2^16 memos.\r\n"); + c3_assert(0); + } + break; + } + } + + ops = u3t(ops); + } +} + +static _n_prog* +_n_prog_new(u3_noun bok) +{ + _n_prog* pog_u; + c3_w byc_w = 1, // HALT + cal_w = 0, + reg_w = 0, + lit_w = 0, + mem_w = 0, + off_w, cab_w, reb_w, lib_w, meb_w; + + _n_melt(bok, &byc_w, &cal_w, ®_w, &lit_w, &mem_w); + + cab_w = (sizeof(_n_site) * cal_w); + reb_w = (sizeof(_n_rite) * reg_w); + lib_w = (sizeof(u3_noun) * lit_w); + meb_w = (sizeof(_n_memo) * mem_w); + pog_u = u3a_calloc(sizeof(_n_prog) + + sizeof(_n_prog_ops) + byc_w + + sizeof(_n_prog_call) + cab_w + + sizeof(_n_prog_reg) + reb_w + + sizeof(_n_prog_lit) + lib_w + + sizeof(_n_prog_memo) + meb_w); + + pog_u->byc_u.own_o = c3y; + pog_u->byc_u.len_w = byc_w; + pog_u->byc_u.ops_u = &(pog_u->dat); + + pog_u->lit_u.len_w = lit_w; + pog_u->cal_u.lit_u = &(pog_u->dat) + (off_w = byc_w); + + pog_u->mem_u.len_w = mem_w; + pog_u->mem_u.sot_u = &(pog_u->dat) + (off_w += lib_w); + + pog_u->cal_u.len_w = cal_w; + pog_u->cal_u.sit_u = &(pog_u->dat) + (off_w += meb_w); + + pog_u->reg_u.len_w = reg_w; + pog_u->reg_u.rit_u = &(pog_u->dat) + (off_w + cab_w); + + _n_prog_asm(bok, pog_u); + return pog_u; +} + +static _n_prog* +_n_prog_old(_n_prog* sep) +{ + c3_w cab_w = sizeof(_n_site) * sep->cal_u.len_w, + reb_w = sizeof(_n_rite) * sep->reg_u.len_w, + lib_w = sizeof(u3_noun) * sep->lit_u.len_w, + meb_w = sizeof(_n_memo) * sep->mem_u.len_w; + + _n_prog* pog_u = u3a_calloc(sizeof(_n_prog) + + sizeof(_n_prog_ops) + + sizeof(_n_prog_call) + cab_w + + sizeof(_n_prog_reg) + reb_w + + sizeof(_n_prog_lit) + lib_w + + sizeof(_n_prog_memo) + meb_w); + + pog_u->byc_u.own_o = c3n; + pog_u->byc_u.len_w = sep->byc_u.len_w; + pog_u->byc_u.ops_u = sep->byc_u.ops_u; + + pog_u->lit_u.len_w = sep->lit_u.len_w; + pog_u->cal_u.lit_u = &(pog_u->dat); + + pog_u->mem_u.len_w = sep->mem_u.len_w; + pog_u->mem_u.sot_u = &(pog_u->dat) + (off_w = lib_w); + + pog_u->cal_u.len_w = sep->cal_u.len_w; + pog_u->cal_u.sit_u = &(pog_u->dat) + (off_w += meb_w); + + pog_u->reg_u.len_w = sep->reg_u.len_w; + pog_u->reg_u.rit_u = &(pog_u->dat) + (off_w + cab_w); + + return pog_u; +} + +static inline void +_n_prog_asm_inx(c3_y* buf_y, c3_w* i_w, c3_s inx_s, c3_y cod) +{ + if ( inx_s <= 0xFF ) { + buf_y[(*i_w)--] = (c3_y) (inx_s); + buf_y[*i_w] = (c3_y) cod; + } + else { + buf_y[(*i_w)--] = (c3_y) (inx_s >> 8); + buf_y[(*i_w)--] = (c3_y) (inx_s); + // the short-index versions of these opcodes must immediately + // follow the byte-index versions because of this convention + buf_y[(*i_w)] = cod + 1; + } +} + +static void +_n_prog_asm(u3_noun ops, _n_prog* pog_u) +{ + u3_noun top = ops; + c3_y* buf_y = pog_u->byc.ops_y; + c3_w i_w = pog_u->byc.len_w, + sip_l = 0, + ip_l = 0, + c3_l wil_l, was_l; + c3_s lit_s = 0, + cal_s = 0, + mem_s = 0, + reg_s = 0; + + buf_y[i_w] = HALT; + + while ( i_w-- > 0 ) { + u3_noun op = u3h(ops); + if ( c3y == u3ud(op) ) { + buf_y[i_w] = (c3_y) u3h(ops); + } + else { + u3_noun cod = u3h(op); + switch ( cod ) { + default: + c3_assert(0); + return 0; + + /* skips cannot be computed until we have generated the next + * n opcodes, so we create some state and finish the insert + * at the end of the loop + */ + case SBIP: case SBIN: + sod_y = (c3_y) cod; + wil_l = (c3_l) ip_l + ((c3_l) u3t(op)); + was_l = (c3_l) i_w; + c3_assert(c3y == u3a_is_cat(wil_l)); + c3_assert(c3y == u3a_is_cat(was_l)); + sil = u3nc(u3nt(sod_y, wil_l, was_l), sil); + break; + + /* 8-bit direct args */ + case FABK: case FABL: + case LITB: case LILB: + case SAMB: + buf_y[i_w--] = (c3_y) u3t(op); + buf_y[i_w] = (c3_y) cod; + break; + + /* 16-bit direct args */ + case FASK: case FASL: + case LILS: case LITS: + case SAMS: case SIPS: case SINS: { + c3_s off_s = u3t(op); + buf_y[i_w--] = (c3_y) (off_s >> 8); + buf_y[i_w--] = (c3_y) off_s; + buf_y[i_w] = (c3_y) cod; + break; + } + + /* 31-bit direct args */ + case SWIP: case SWIN: { + c3_w off_l = u3t(op); + buf_y[i_w--] = (c3_y) (off_l >> 24); + buf_y[i_w--] = (c3_y) (off_l >> 16); + buf_y[i_w--] = (c3_y) (off_l >> 8); + buf_y[i_w--] = (c3_y) off_l; + buf_y[i_w] = (c3_y) cod; + break; + } + + /* literal index args */ + case FIBK: case FIBL: + case LIBK: case LIBL: + case BUSH: case SANB: + _n_prog_asm_inx(buf_y, &i_w, lit_s, cod); + pog_u->lit_u.non[lit_s++] = u3k(u3t(op)); + break; + + /* memo index args */ + case SKIB: case SLIB: { + _n_prog_asm_inx(buf_y, &i_w, mem_s, cod); + _n_mem* mem_u = &(pog_u->mem_u.sot_u[mem_s++]); + mem_u->sip_l = u3h(u3t(op)); + mem_u->key = u3k(u3t(u3t(op))); + break; + } + + /* call site index args */ + case TICB: case KICB: { + _n_prog_asm_inx(buf_y, &i_w, cal_s, cod); + _n_site* sit_u = &(pog_u->cal_u.sit_u[cal_s++]); + sit_u->axe = u3k(u3t(op)); + break; + } + + /* registration site index args */ + case BAST: case BALT: { + _n_prog_asm_inx(buf_y, &i_w, reg_s, cod); + _n_rite* rit_u = &(pog_u->reg_u.rit_u[reg_s++]); + rit_u->nul_w = 0; + break; + } + } + } + while ( u3_nul != sil ) { + u3_noun cod, wil, was; + u3x_trel(u3h(sil), &cod, &wil, &was); + cod_y = (c3_y) cod; + wil_l = (c3_l) wil; + was_l = (c3_l) was; + if ( ip_l != wil_l ) { + // first is finished or none are + break; + } + else { + c3_w dif_w = was_l - i_w; + c3_y siz_y = dif_w <= 0xFF ? 2 : dif_w <= 0xFFFF ? 3 : 5; + u3_noun lis = u3k(u3t(sil)); + u3z(sil); + sil = lis; + memmove(buf_y + i_w - siz_y, buf_y + i_w, dif_w); + i_w -= siz_y; + switch ( siz_y ) { + case 2: + buf_y[was_l--] = (c3_y) dif_w; + buf_y[was_l] = sod_y; + break; + case 3: + buf_y[was_l--] = (c3_y) (dif_w >> 8); + buf_y[was_l--] = (c3_y) dif_w; + buf_y[was_l] = sod_y + 1; + break; + case 5: + buf_y[was_l--] = (c3_y) (dif_w >> 24); + buf_y[was_l--] = (c3_y) (dif_w >> 16); + buf_y[was_l--] = (c3_y) (dif_w >> 8); + buf_y[was_l--] = (c3_y) dif_w; + buf_y[was_l] = sod_y + 2; + break; + defaut: + c3_assert(0); + break; + } + } + } + ++ip_l; + ops = u3t(ops); + } + // this assert will fail if we overflow a c3_w worth of instructions + c3_assert(u3_nul == ops); + + u3z(top); + return buf_y; +} #if 0 /* _n_print_stack(): print out the cap stack up to a designated "empty" @@ -535,32 +950,29 @@ static void _n_print_stack(u3p(u3_noun) empty) { static char* opcode_names[] = { "halt", "bail", "copy", "swap", "toss", - "auto", "ault", - "head", "held", - "tail", "tall", - "fras", "frag", "frab", - "flas", "flag", "flab", - "lit0", "lit1", - "litb", "lits", "litn", - "lil0", "lil1", - "lilb", "lils", "liln", + "auto", "ault", "snoc", "snol", + "head", "held", "tail", "tall", + "fabk", "fask", "fibk", "fisk", + "fabl", "fasl", "fibl", "fisl", + "lit0", "lit1", "litb", "lits", + "libk", "lisk", + "lil0", "lil1", "lilb", "lils", + "libl", "lisl", "nolk", "noct", "nock", "deep", "bump", - "sam0", "sam1", - "samb", "sams", "samn", + "sam0", "sam1", "samb", "sams", + "sanb", "sans", "same", "salm", "samc", - "skip", "sbip", - "skin", "sbin", - "snoc", "snol", - "slam", "kicb", "kics", "kick", - "slat", "ticb", "tics", "tick", + "sbip", "sips", "swip", + "sbin", "sins", "swin", + "kicb", "kics", "ticb", "tics", "wils", "wish", - "cush", "drop", - "heck", "slog", - "falt", "fast", - "skib", "skim", - "slib", "slim", - "save" + "bush", "sush", + "drop", "heck", "slog", + "bast", "sast", + "balt", "salt", + "skib", "skis", "slib", "slis", + "save", }; #endif @@ -578,47 +990,43 @@ static inline c3_y _n_arg(c3_y cod_y) { switch ( cod_y ) { - case FRAB: case FLAB: case LILB: case LITB: case SAMB: - case SBIP: case SBIN: case KICB: case TICB: + case FABK: case FABL: case FIBL: case FIBK: + case LILB: case LITB: case LIBL: case LIBK: + case SAMB: case SANB: case SBIP: case SBIN: + case SLIB: case SKIB: case KICB: case TICB: + case BUSH: case BAST: case BALT: return sizeof(c3_y); - case FRAS: case FLAS: case LILS: case LITS: case SAMS: - case SKIP: case SKIN: case KICS: case TICS: + case FASK: case FASL: case FISL: case FISK: + case LILS: case LITS: case LISL: case LISK: + case SAMS: case SANS: case SIPS: case SINS: + case SLIS: case SKIS: case KICS: case TICS: + case SUSH: case SAST: case SALT: return sizeof(c3_s); - case CUSH: case FRAG: case FLAG: case LILN: case LITN: - case SAMN: case TICK: case KICK: - return sizeof(u3_noun); - - case SKIM: case SLIM: - return sizeof(c3_s) + sizeof(u3_noun); - - case SKIB: case SLIB: - return sizeof(c3_y) + sizeof(u3_noun); + case SWIP: case SWIN: + return sizeof(c3_l); default: return 0; } } -/* _n_emit(): emit a single instruction to ops, returning - * the size (in bytes) required to store that - * opcode. +/* _n_emit(): emit a single instruction to ops */ -static inline c3_y +static inline void _n_emit(u3_noun *ops, u3_noun op) { *ops = u3nc(op, *ops); - return sizeof(c3_y) + (c3n == u3du(op) ? 0 : _n_arg(u3h(op))); } -static c3_s _n_comp(u3_noun*, u3_noun, c3_o, c3_o); +static c3_w _n_comp(u3_noun*, u3_noun, c3_o, c3_o); /* _n_bint(): hint-processing helper for _n_comp. * hif: hint-formula (first part of 10). RETAIN. * nef: next-formula (second part of 10). RETAIN. */ -static c3_s +static c3_w _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) { if ( c3n == u3du(hif) ) { @@ -626,66 +1034,65 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) return _n_comp(ops, nef, los_o, tel_o); } else { - c3_s tot_s = 0; + c3_w tot_w = 0; u3_noun zep, hod; u3x_cell(hif, &zep, &hod); switch ( zep ) { default: - tot_s += _n_comp(ops, hod, c3n, c3n); - tot_s += _n_emit(ops, TOSS); - tot_s += _n_comp(ops, nef, los_o, tel_o); + tot_w += _n_comp(ops, hod, c3n, c3n); + ++tot_w; _n_emit(ops, TOSS); + tot_w += _n_comp(ops, nef, los_o, tel_o); break; case c3__hunk: case c3__lose: case c3__mean: case c3__spot: - tot_s += _n_comp(ops, hod, c3n, c3n); - tot_s += _n_emit(ops, u3nc(CUSH, zep)); - tot_s += _n_comp(ops, nef, los_o, c3n); - tot_s += _n_emit(ops, DROP); + tot_w += _n_comp(ops, hod, c3n, c3n); + ++tot_w; _n_emit(ops, u3nc(BUSH, zep)); // overflows to SUSH + tot_w += _n_comp(ops, nef, los_o, c3n); + ++tot_w; _n_emit(ops, DROP); break; case c3__live: - tot_s += _n_comp(ops, hod, c3n, c3n); - tot_s += _n_emit(ops, HECK); - tot_s += _n_comp(ops, nef, los_o, tel_o); + tot_w += _n_comp(ops, hod, c3n, c3n); + ++tot_w; _n_emit(ops, HECK); + tot_w += _n_comp(ops, nef, los_o, tel_o); break; case c3__slog: - tot_s += _n_comp(ops, hod, c3n, c3n); - tot_s += _n_emit(ops, SLOG); - tot_s += _n_comp(ops, nef, los_o, tel_o); + tot_w += _n_comp(ops, hod, c3n, c3n); + ++tot_w; _n_emit(ops, SLOG); + tot_w += _n_comp(ops, nef, los_o, tel_o); break; // germ and sole are unused... case c3__fast: - tot_s += _n_comp(ops, hod, c3n, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, nef, c3n, c3n); - tot_s += _n_emit(ops, (c3y == los_o) ? FALT : FAST); + tot_w += _n_comp(ops, hod, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, nef, c3n, c3n); + // overflows to SALT / SAST + ++tot_w; _n_emit(ops, (c3y == los_o) ? BALT : BAST); break; case c3__memo: { u3_noun mem = u3_nul; - c3_s mem_s = 0; + c3_w mem_w = 0; c3_y op_y; // we just throw away the hint (why is this not a static hint?) - tot_s += _n_comp(ops, hod, c3n, c3n); - tot_s += _n_emit(ops, TOSS); + tot_w += _n_comp(ops, hod, c3n, c3n); + ++tot_w; _n_emit(ops, TOSS); // memoizing code always loses TOS because SAVE needs [pro key] - mem_s += _n_comp(&mem, nef, c3y, c3n); - mem_s += _n_emit(&mem, SAVE); + mem_w += _n_comp(&mem, nef, c3y, c3n); + ++mem_w; _n_emit(&mem, SAVE); - op_y = (c3y == los_o) - ? (( mem_s <= 0xFF ) ? SLIB : SLIM) - : (( mem_s <= 0xFF ) ? SKIB : SKIM); - tot_s += _n_emit(ops, u3nt(op_y, mem_s, u3k(nef))); - tot_s += mem_s; _n_apen(ops, mem); + op_y = (c3y == los_o) ? SLIB : SKIB; // overflows to SLIS / SKIS + ++tot_w; _n_emit(ops, u3nt(op_y, mem_w, u3k(nef))); + tot_s += mem_w; _n_apen(ops, mem); break; } } @@ -696,22 +1103,23 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) /* _n_comp(): compile nock formula to reversed opcode list * ops is a pointer to a list (to be emitted to) * fol is the nock formula to compile. RETAIN. - * los_o indicates whether we should remove our subject from the stack + * los_o indicates whether we should remove our + * subject from the stack * tel_o is yes if this formula is in tail position - * return: the number of bytes needed for this opcode list + * return: number of instructions added to the opcode list */ -static c3_s +static c3_w _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) { c3_y op_y; - c3_s tot_s = 0; + c3_w tot_w = 0; u3_noun cod, arg, hed, tel; u3x_cell(fol, &cod, &arg); if ( c3y == u3du(cod) ) { - tot_s += _n_comp(ops, cod, c3n, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, arg, c3n, c3n); - tot_s += _n_emit(ops, (c3y == los_o ) ? AULT : AUTO); + tot_w += _n_comp(ops, cod, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, arg, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o ) ? AULT : AUTO); } else switch ( cod ) { case 0: @@ -721,24 +1129,24 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } switch ( arg ) { case 0: - tot_s += _n_emit(ops, BAIL); + ++tot_w; _n_emit(ops, BAIL); break; case 1: if ( c3n == los_o ) { - tot_s += _n_emit(ops, COPY); + ++tot_w; _n_emit(ops, COPY); } break; case 2: - tot_s += _n_emit(ops, (c3y == los_o) ? HELD : HEAD); + ++tot_w; _n_emit(ops, (c3y == los_o) ? HELD : HEAD); break; case 3: - tot_s += _n_emit(ops, (c3y == los_o) ? TALL : TAIL); + ++tot_w; _n_emit(ops, (c3y == los_o) ? TALL : TAIL); break; default: op_y = (c3y == los_o) - ? (arg <= 0xFF ? FLAB : arg <= 0xFFFF ? FLAS : FLAG) - : (arg <= 0xFF ? FRAB : arg <= 0xFFFF ? FRAS : FRAG); - tot_s += _n_emit(ops, u3nc(op_y, arg)); + ? (arg <= 0xFF ? FABL : arg <= 0xFFFF ? FASL : FIBL) // overflows to FISL + : (arg <= 0xFF ? FABK : arg <= 0xFFFF ? FASK : FIBK); // overflows to FISK + ++tot_w; _n_emit(ops, u3nc(op_y, arg)); break; } break; @@ -746,48 +1154,48 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) case 1: switch ( arg ) { case 0: - tot_s += _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); + ++tot_w; _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); break; case 1: - tot_s += _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); + ++tot_w; _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); break; default: op_y = (c3y == los_o) - ? (arg <= 0xFF ? LILB : arg <= 0xFFFF ? LILS : LILN) - : (arg <= 0xFF ? LITB : arg <= 0xFFFF ? LITS : LITN); - tot_s += _n_emit(ops, u3nc(op_y, u3k(arg))); + ? (arg <= 0xFF ? LILB : arg <= 0xFFFF ? LILS : LIBL) // overflows to LISL + : (arg <= 0xFF ? LITB : arg <= 0xFFFF ? LITS : LIBK); // overflows to LISK + ++tot_w; _n_emit(ops, u3nc(op_y, u3k(arg))); break; } break; case 2: u3x_cell(arg, &hed, &tel); - tot_s += _n_comp(ops, hed, c3n, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n, c3n); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); /* things in tail position replace (so, lose) top of stack, * so NOCT "loses" and there is no non-losing version */ op_y = (c3y == tel_o) ? NOCT : ((c3y == los_o) ? NOLK : NOCK); - tot_s += _n_emit(ops, op_y); + ++tot_w; _n_emit(ops, op_y); break; case 3: - tot_s += _n_comp(ops, arg, los_o, c3n); - tot_s += _n_emit(ops, DEEP); + tot_w += _n_comp(ops, arg, los_o, c3n); + ++tot_w; _n_emit(ops, DEEP); break; case 4: - tot_s += _n_comp(ops, arg, los_o, c3n); - tot_s += _n_emit(ops, BUMP); + tot_w += _n_comp(ops, arg, los_o, c3n); + ++tot_w; _n_emit(ops, BUMP); break; case 5: { u3x_cell(arg, &hed, &tel); if ( c3n == u3du(hed) ) { - tot_s += _n_comp(ops, arg, los_o, c3n); - tot_s += _n_emit(ops, SAMC); + tot_w += _n_comp(ops, arg, los_o, c3n); + ++tot_w; _n_emit(ops, SAMC); } else { c3_t hec_t, tec_t; @@ -801,31 +1209,32 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } if ( hec_t && tec_t ) { if ( c3y == u3r_sing(u3t(hed), u3t(tel)) ) { - tot_s += _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); + ++tot_w; _n_emit(ops, (c3y == los_o) ? LIL0 : LIT0); } else { - tot_s += _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); + ++tot_w; _n_emit(ops, (c3y == los_o) ? LIL1 : LIT1); } } else if ( !hec_t && !tec_t ) { - tot_s += _n_comp(ops, hed, c3n, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n, c3n); - tot_s += _n_emit(ops, (c3y == los_o) ? SALM : SAME); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? SALM : SAME); } else { - tot_s += _n_comp(ops, (hec_t ? tel : hed), los_o, c3n); + tot_w += _n_comp(ops, (hec_t ? tel : hed), los_o, c3n); u3_noun lit = u3t(hec_t ? hed : tel); switch ( lit ) { case 0: - tot_s += _n_emit(ops, SAM0); + ++tot_w; _n_emit(ops, SAM0); break; case 1: - tot_s += _n_emit(ops, SAM1); + ++tot_w; _n_emit(ops, SAM1); break; default: - op_y = lit <= 0xFF ? SAMB : lit <= 0xFFFF ? SAMS : SAMN; - tot_s += _n_emit(ops, u3nc(op_y, u3k(lit))); + // overflows to SANS + op_y = lit <= 0xFF ? SAMB : lit <= 0xFFFF ? SAMS : SANB; + ++tot_w; _n_emit(ops, u3nc(op_y, u3k(lit))); } } } @@ -836,131 +1245,108 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) u3_noun mid, yep = u3_nul, nop = u3_nul; - c3_s yep_s, nop_s; + c3_w yep_w, nop_w; u3x_trel(arg, &hed, &mid, &tel); - tot_s += _n_comp(ops, hed, c3n, c3n); - yep_s = _n_comp(&yep, mid, los_o, tel_o); - nop_s = _n_comp(&nop, tel, los_o, tel_o); - op_y = (nop_s <= 0xFF ? SBIP : SKIP); - yep_s += _n_emit(&yep, u3nc(op_y, nop_s)); - op_y = (yep_s <= 0xFF ? SBIN : SKIN); - tot_s += _n_emit(ops, u3nc(op_y, yep_s)); - tot_s += yep_s; _n_apen(ops, yep); - tot_s += nop_s; _n_apen(ops, nop); + tot_w += _n_comp(ops, hed, c3n, c3n); + yep_w = _n_comp(&yep, mid, los_o, tel_o); + nop_w = _n_comp(&nop, tel, los_o, tel_o); + // SBIP and SBIN get sized during assembly + ++yep_w; _n_emit(&yep, u3nc(SBIP, nop_w)); + ++tot_w; _n_emit(ops, u3nc(SBIN, yep_w)); + tot_w += yep_w; _n_apen(ops, yep); + tot_w += nop_w; _n_apen(ops, nop); break; } case 7: u3x_cell(arg, &hed, &tel); - tot_s += _n_comp(ops, hed, los_o, c3n); - tot_s += _n_comp(ops, tel, c3y, tel_o); + tot_w += _n_comp(ops, hed, los_o, c3n); + tot_w += _n_comp(ops, tel, c3y, tel_o); break; case 8: u3x_cell(arg, &hed, &tel); - tot_s += _n_comp(ops, hed, c3n, c3n); - tot_s += _n_emit(ops, (c3y == los_o) ? SNOL : SNOC); - tot_s += _n_comp(ops, tel, c3y, tel_o); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? SNOL : SNOC); + tot_w += _n_comp(ops, tel, c3y, tel_o); break; case 9: u3x_cell(arg, &hed, &tel); if ( 3 == u3qc_cap(hed) ) { u3_noun mac = u3nq(7, u3k(tel), 2, u3nt(u3nc(0, 1), 0, u3k(hed))); - tot_s += _n_comp(ops, mac, los_o, tel_o); + tot_w += _n_comp(ops, mac, los_o, tel_o); u3z(mac); } else { - tot_s += _n_comp(ops, tel, (c3y == tel_o ? c3y : los_o), c3n); - if ( 2 == hed ) { - tot_s += _n_emit(ops, (c3y == tel_o) ? SLAT : SLAM); - } - else { - op_y = (c3y == tel_o) - ? (hed <= 0xFF ? TICB : hed <= 0xFFFF ? TICS : TICK) - : (hed <= 0xFF ? KICB : hed <= 0xFFFF ? KICS : KICK); - tot_s += _n_emit(ops, u3nc(op_y, u3k(hed))); - } + tot_w += _n_comp(ops, tel, (c3y == tel_o ? c3y : los_o), c3n); + op_y = (c3y == tel_o) ? TICB : KICB; // overflows to TICS/KICS + ++tot_w; _n_emit(ops, u3nc(op_y, u3k(hed))); } break; case 10: u3x_cell(arg, &hed, &tel); - tot_s += _n_bint(ops, hed, tel, los_o, tel_o); + tot_w += _n_bint(ops, hed, tel, los_o, tel_o); break; case 11: u3x_cell(arg, &hed, &tel); - tot_s += _n_comp(ops, hed, c3n, c3n); - tot_s += _n_emit(ops, SWAP); - tot_s += _n_comp(ops, tel, c3n, c3n); - tot_s += _n_emit(ops, (c3y == los_o) ? WILS : WISH); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; default: u3m_bail(c3__exit); return 0; } - return tot_s; + return tot_w; } #ifdef VERBOSE_BYTECODE /* _n_print_byc(): print bytecode. used for debugging. */ static void -_n_print_byc(c3_y* pog, c3_s her_s) +_n_print_byc(c3_y* pog, c3_w her_w) { - c3_s ip_s = 0; - if ( her_s == 0 ) { + c3_w ip_w = 0; + if ( her_w == 0 ) { fprintf(stderr, "begin: {"); } else { fprintf(stderr, "resume: {"); } int first = 1; - while ( pog[ip_s] ) { + while ( pog[ip_w] ) { if ( first ) { first = 0; } - else if (ip_s == her_s) { + else if (ip_w == her_w) { fprintf(stderr, " [*]"); } else { fprintf(stderr, " "); } - switch ( pog[ip_s] ) { - default: - fprintf(stderr, "%s", opcode_names[pog[ip_s++]]); + switch ( _n_arg(pog[ip_w]) ) { + case 0: + fprintf(stderr, "%s", opcode_names[pog[ip_w++]]); break; - case FRAB: case FLAB: case LILB: case LITB: case SAMB: - case SBIP: case SBIN: case KICB: case TICB: - fprintf(stderr, "[%s ", opcode_names[pog[ip_s++]]); - fprintf(stderr, "%u]", pog[ip_s++]); + case 1: + fprintf(stderr, "[%s ", opcode_names[pog[ip_w++]]); + fprintf(stderr, "%u]", pog[ip_w++]); break; - case FRAS: case FLAS: case LILS: case LITS: case SAMS: - case SKIP: case SKIN: case KICS: case TICS: - fprintf(stderr, "[%s ", opcode_names[pog[ip_s++]]); - fprintf(stderr, "%u]", _n_resh(pog, &ip_s)); + case 2: + fprintf(stderr, "[%s ", opcode_names[pog[ip_w++]]); + fprintf(stderr, "%u]", _n_resh(pog, &ip_w)); break; - case CUSH: case FRAG: case FLAG: case LILN: - case LITN: case SAMN: case TICK: case KICK: - fprintf(stderr, "[%s ", opcode_names[pog[ip_s++]]); - fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); - break; - - case SKIB: case SLIB: - fprintf(stderr, "[%s", opcode_names[pog[ip_s++]]); - fprintf(stderr, " %u ", pog[ip_s++]); - fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); - break; - - case SKIM: case SLIM: - fprintf(stderr, "[%s", opcode_names[pog[ip_s++]]); - fprintf(stderr, " %u ", _n_resh(pog, &ip_s)); - fprintf(stderr, "%u]", _n_rean(pog, &ip_s)); + case 4: + fprintf(stderr, "[%s", opcode_names[pog[ip_w++]]); + fprintf(stderr, "%u]", _n_rean(pog, &ip_w)); break; } } @@ -968,92 +1354,6 @@ _n_print_byc(c3_y* pog, c3_s her_s) } #endif -/* _n_asm(): assemble an accumulated list of instructions (i.e. from _n_comp) - */ -static c3_y* -_n_asm(u3_noun ops, c3_s len_s) -{ - u3_noun top = ops; - c3_y* buf_y = u3a_malloc(sizeof(c3_y) * (len_s+1)); - c3_s i_s = len_s; - - buf_y[i_s] = HALT; - while ( i_s-- > 0 ) { - u3_noun op = u3h(ops); - if ( c3y == u3ud(op) ) { - buf_y[i_s] = (c3_y) u3h(ops); - } - else { - u3_noun cod = u3h(op); - switch ( cod ) { - case FRAB: case FLAB: case LILB: case LITB: - case SAMB: case SBIP: case SBIN: - case KICB: case TICB: - buf_y[i_s--] = (c3_y) u3t(op); - buf_y[i_s] = (c3_y) cod; - break; - - case FRAS: case FLAS: case LILS: case LITS: - case SAMS: case SKIP: case SKIN: - case KICS: case TICS: { - c3_s off_s = u3t(op); - buf_y[i_s--] = (c3_y) (off_s >> 8); - buf_y[i_s--] = (c3_y) off_s; - buf_y[i_s] = (c3_y) cod; - break; - } - - case CUSH: case FRAG: case FLAG: - case LILN: case LITN: - case SAMN: case TICK: case KICK: { - c3_w non_w = u3k(u3t(op)); - buf_y[i_s--] = (c3_y) (non_w >> 24); - buf_y[i_s--] = (c3_y) (non_w >> 16); - buf_y[i_s--] = (c3_y) (non_w >> 8); - buf_y[i_s--] = (c3_y) non_w; - buf_y[i_s] = (c3_y) cod; - break; - } - - case SKIB: case SLIB: { - c3_w non_w = u3k(u3t(u3t(op))); - buf_y[i_s--] = (c3_y) (non_w >> 24); - buf_y[i_s--] = (c3_y) (non_w >> 16); - buf_y[i_s--] = (c3_y) (non_w >> 8); - buf_y[i_s--] = (c3_y) non_w; - buf_y[i_s--] = (c3_y) u3h(u3t(op)); - buf_y[i_s] = (c3_y) cod; - break; - } - - case SKIM: case SLIM: { - c3_w non_w = u3k(u3t(u3t(op))); - c3_s sip_s = u3h(u3t(op)); - buf_y[i_s--] = (c3_y) (non_w >> 24); - buf_y[i_s--] = (c3_y) (non_w >> 16); - buf_y[i_s--] = (c3_y) (non_w >> 8); - buf_y[i_s--] = (c3_y) non_w; - buf_y[i_s--] = (c3_y) (sip_s >> 8); - buf_y[i_s--] = (c3_y) sip_s; - buf_y[i_s] = (c3_y) cod; - break; - } - - default: - u3m_bail(c3__exit); - return 0; - } - } - ops = u3t(ops); - } - // this will trigger if we ever have a nock formula that compiles to more - // than 2^16 bytes. if needed, ip can be a c3_w. - c3_assert(u3_nul == ops); - - u3z(top); - return buf_y; -} - /* _n_push(): push a noun onto the stack. RETAIN * mov: -1 north, 1 south * off: 0 north, -1 south @@ -1128,60 +1428,51 @@ _n_resh(c3_y* buf, c3_s* ip_s) * refcount is NOT incremented. */ static inline u3_noun -_n_rean(c3_y* buf, c3_s* ip_s) +_n_rean(c3_y* buf, c3_w* ip_w) { - c3_y one = buf[(*ip_s)++], - two = buf[(*ip_s)++], - tre = buf[(*ip_s)++], - qua = buf[(*ip_s)++]; + c3_y one = buf[(*ip_w)++], + two = buf[(*ip_w)++], + tre = buf[(*ip_w)++], + qua = buf[(*ip_w)++]; return one | (two << 8) | (tre << 16) | (qua << 24); } /* _n_bite(): compile a nock formula to bytecode */ -static inline c3_y* -_n_bite(u3_noun fol) -{ - u3_noun bok = u3_nul; - c3_s len_s = _n_comp(&bok, fol, c3y, c3y); - c3_y* buf_y = _n_asm(bok, len_s); - return buf_y; +static inline _n_prog* +_n_bite(u3_noun fol) { + u3_noun ops = u3_nul; + _n_comp(&ops, fol, c3y, c3y); + return _n_prog_new(ops); } -/* _n_find(): return bytecode for given formula. fol is RETAINED. +/* _n_find(): return prog for given formula. fol is RETAINED. */ -static inline c3_y* +static inline _n_prog* _n_find(u3_noun fol) { - /* check on the home road first. not only is this likely to be faster, it - * protects us from things which compile bytecode on the home road - * mid-computation (like u3t_samp()) - */ - u3a_road* rod_u = u3R; - u3a_road* hom_u = &(u3H->rod_u); - u3_weak byc = u3h_gut(hom_u->byc.har_p, fol); - - if ( u3_none != byc ) { - return u3a_into(byc); + u3_weak pog = u3h_git(u3R->byc.har_p, fol); + if ( u3_none != pog ) { + return u3to(_n_prog, pog); } - - while ( rod_u != hom_u ) { - byc = u3h_gut(rod_u->byc.har_p, fol); - - if ( u3_none != byc ) { - return u3a_into(byc); + else { + u3a_road* rod_u = u3R->par_p; + while ( rod_u ) { + pog = u3h_git(rod_u->byc.har_p, fol); + if ( u3_none != pog ) { + _n_prog* old = _n_prog_old(u3to(_n_prog, pog)); + u3h_put(u3R->byc.har_p, u3a_outa(old)); + return old; + } + else { + rod_u = rod_u->par_p; + } } - - if ( rod_u->par_p ) { - rod_u = u3to(u3_road, rod_u->par_p); + { + _n_prog* gop = _n_bite(fol); + u3h_put(u3R->byc.har_p, fol, u3a_outa(gop)); + return gop; } - else break; - } - - { - c3_y* gop = _n_bite(fol); - u3h_put(u3R->byc.har_p, fol, u3a_outa(gop)); - return gop; } } @@ -1210,8 +1501,8 @@ _n_kale(u3_noun a) } typedef struct { - c3_y* pog; - c3_s ip_s; + _n_prog* pog_u; + c3_w ip_w; } burnframe; /* _n_burn(): pog: program @@ -1220,41 +1511,42 @@ typedef struct { * off: 0 north, -1 south */ static u3_noun -_n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) +_n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) { /* OPCODE TABLE */ static void* lab[] = { &&do_halt, &&do_bail, &&do_copy, &&do_swap, &&do_toss, - &&do_auto, &&do_ault, - &&do_head, &&do_held, - &&do_tail, &&do_tall, - &&do_fras, &&do_frag, &&do_frab, - &&do_flas, &&do_flag, &&do_flab, - &&do_lit0, &&do_lit1, - &&do_litb, &&do_lits, &&do_litn, - &&do_lil0, &&do_lil1, - &&do_lilb, &&do_lils, &&do_liln, + &&do_auto, &&do_ault, &&do_snoc, &&do_snol, + &&do_head, &&do_held, &&do_tail, &&do_tall, + &&do_fabk, &&do_fask, &&do_fibk, &&do_fisk, + &&do_fabl, &&do_fasl, &&do_fibl, &&do_fisl, + &&do_lit0, &&do_lit1, &&do_litb, &&do_lits, + &&do_libk, &&do_lisk, + &&do_lil0, &&do_lil1, &&do_lilb, &&do_lils, + &&do_libl, &&do_lisl, &&do_nolk, &&do_noct, &&do_nock, &&do_deep, &&do_bump, - &&do_sam0, &&do_sam1, - &&do_samb, &&do_sams, &&do_samn, + &&do_sam0, &&do_sam1, &&do_samb, &&do_sams, + &&do_sanb, &&do_sans, &&do_same, &&do_salm, &&do_samc, - &&do_skip, &&do_sbip, - &&do_skin, &&do_sbin, - &&do_snoc, &&do_snol, - &&do_slam, &&do_kicb, &&do_kics, &&do_kick, - &&do_slat, &&do_ticb, &&do_tics, &&do_tick, + &&do_sbip, &&do_sips, &&do_swip, + &&do_sbin, &&do_sins, &&do_swin, + &&do_kicb, &&do_kics, &&do_ticb, &&do_tics, &&do_wils, &&do_wish, - &&do_cush, &&do_drop, - &&do_heck, &&do_slog, - &&do_falt, &&do_fast, - &&do_skib, &&do_skim, - &&do_slib, &&do_slim, - &&do_save + &&do_bush, &&do_sush, + &&do_drop, &&do_heck, &&do_slog, + &&do_bast, &&do_sast, + &&do_balt, &&do_salt, + &&do_skib, &&do_skis, &&do_slib, &&do_slis, + &&do_save, }; - c3_s sip_s, ip_s = 0; + _n_site* sit_u; + _n_rite* rit_u; + _n_memo* mem_u; + c3_y *pog = pog_u->byc.ops_u; + c3_w sip_w, ip_w = 0; u3_noun* top; u3_noun x, o; u3p(void) empty; @@ -1267,9 +1559,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3R->pro.nox_d += 1; #endif #ifdef VERBOSE_BYTECODE - #define BURN() fprintf(stderr, "%s ", opcode_names[pog[ip_s]]); goto *lab[pog[ip_s++]] + #define BURN() fprintf(stderr, "%s ", opcode_names[pog[ip_w]]); goto *lab[pog[ip_w++]] #else - #define BURN() goto *lab[pog[ip_s++]] + #define BURN() goto *lab[pog[ip_w++]] #endif BURN(); { @@ -1282,14 +1574,15 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) return x; } else { - fam = u3to(burnframe, u3R->cap_p) + off; - pog = fam->pog; - ip_s = fam->ip_s; + fam = u3to(burnframe, u3R->cap_p) + off; + pog_u = fam->pog_u; + pog = pog_u->byc.ops_u; + ip_w = fam->ip_w; u3R->cap_p = u3of(burnframe, fam - (mov+off)); _n_push(mov, off, x); #ifdef VERBOSE_BYTECODE - _n_print_byc(pog, ip_s); + _n_print_byc(pog, ip_w); #endif BURN(); } @@ -1323,6 +1616,18 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) top = _n_peek(off); *top = u3nc(*top, x); // [pro] BURN(); + + do_snoc: // [hed tel] + x = _n_pep(mov, off); + top = _n_peek(off); + _n_push(mov, off, u3nc(x, u3k(*top))); + BURN(); + + do_snol: + x = _n_pep(mov, off); + top = _n_peek(off); + *top = u3nc(x, *top); + BURN(); do_head: top = _n_peek(off); @@ -1348,31 +1653,39 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_fras: - x = _n_resh(pog, &ip_s); + do_fisk: + x = pog_u->lit_u.non[_n_resh(pog, &ip_w)]; goto frag_in; - do_frag: - x = _n_rean(pog, &ip_s); + do_fibk: + x = pog_u->lit_u.non[pog[ip_w++]]; goto frag_in; - do_frab: - x = pog[ip_s++]; + do_fask: + x = _n_resh(pog, &ip_w); + goto frag_in; + + do_fabk: + x = pog[ip_w++]; frag_in: top = _n_peek(off); _n_push(mov, off, u3k(u3x_at(x, *top))); BURN(); - do_flas: - x = _n_resh(pog, &ip_s); + do_fisl: + x = pog_u->lit_u.non[_n_resh(pog, &ip_w)]; goto flag_in; - do_flag: - x = _n_rean(pog, &ip_s); + do_fibl: + x = pog_u->lit_u.non[pog[ip_w++]]; goto flag_in; - do_flab: - x = pog[ip_s++]; + do_fasl: + x = _n_resh(pog, &ip_w); + goto flag_in; + + do_fabl: + x = pog[ip_w++]; flag_in: top = _n_peek(off); o = *top; @@ -1380,6 +1693,9 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); + &&do_lit0, &&do_lit1, &&do_litb, &&do_lits, + &&do_libk, &&do_lisk, + do_lit0: _n_push(mov, off, 0); BURN(); @@ -1389,15 +1705,19 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) BURN(); do_litb: - _n_push(mov, off, pog[ip_s++]); + _n_push(mov, off, pog[ip_w++]); BURN(); do_lits: - _n_push(mov, off, _n_resh(pog, &ip_s)); + _n_push(mov, off, _n_resh(pog, &ip_w)); BURN(); - do_litn: - _n_push(mov, off, u3k(_n_rean(pog, &ip_s))); + do_libk: + _n_push(mov, off, u3k(pog_u->lit_u.non[pog[ip_w++]])); + BURN(); + + do_lisk: + _n_push(mov, off, u3k(pog_u->lit_u.non[_n_resh(pog, &ip_w)])); BURN(); do_lil1: @@ -1405,15 +1725,19 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) goto lil_in; do_lilb: - x = pog[ip_s++]; + x = pog[ip_w++]; goto lil_in; do_lils: - x = _n_resh(pog, &ip_s); + x = _n_resh(pog, &ip_w); goto lil_in; - do_liln: - x = u3k(_n_rean(pog, &ip_s)); + do_libl: + x = u3k(pog_u->lit_u.non[pog[ip_w++]]); + goto lil_in; + + do_lisl: + x = u3k(pog_u->lit_u.non[_n_resh(pog, &ip_w)]); goto lil_in; do_lil0: @@ -1441,18 +1765,19 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) x = _n_pep(mov, off); fam = u3to(burnframe, u3R->cap_p) + off + mov; u3R->cap_p = u3of(burnframe, fam - off); - fam->ip_s = ip_s; - fam->pog = pog; + fam->ip_w = ip_w; + fam->pog_u = pog_u; _n_push(mov, off, x); nock_out: - pog = _n_find(o); - ip_s = 0; + pog_u = _n_find(o); + pog = pog_u->byc.ops_u; + ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif #ifdef VERBOSE_BYTECODE fprintf(stderr, "\r\nnock jump: %u\r\n", o); - _n_print_byc(pog, ip_s); + _n_print_byc(pog, ip_w); #endif u3z(o); BURN(); @@ -1493,7 +1818,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_samb: top = _n_peek(off); - if ( *top == pog[ip_s++] ) { + if ( *top == pog[ip_w++] ) { *top = c3y; } else { @@ -1504,7 +1829,7 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) do_sams: top = _n_peek(off); - if ( *top == _n_resh(pog, &ip_s) ) { + if ( *top == _n_resh(pog, &ip_w) ) { *top = c3y; } else { @@ -1513,10 +1838,15 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } BURN(); - do_samn: + do_sans: + x = pog_u->lit_u.non[_n_resh(pog, &ip_w)]; + goto samn_in; + do_sanb: + x = pog_u->lit_u.non[pog[ip_w++]]; + samn_in: top = _n_peek(off); o = *top; - *top = u3r_sing(o, _n_rean(pog, &ip_s)); + *top = u3r_sing(o, x); u3z(o); BURN(); @@ -1545,24 +1875,35 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_skip: - ip_s += _n_resh(pog, &ip_s); - BURN(); - do_sbip: - ip_s += pog[ip_s] + 1; + sip_w = pog[ip_w++]; + ip_w += sip_w; BURN(); - do_skin: - sip_s = _n_resh(pog, &ip_s); + do_sips: + sip_w = _n_resh(pog, &ip_w); + ip_w += sip_w; + BURN(); + + do_swip: + sip_w = _n_rean(pog, &ip_w); + ip_w += sip_w; + BURN(); + + do_swin: + sip_w = _n_rean(pog, &ip_w); + goto skin_in; + + do_sins: + sip_w = _n_resh(pog, &ip_w); goto skin_in; do_sbin: - sip_s = pog[ip_s++]; + sip_w = pog[ip_w++]; skin_in: - x = _n_pep(mov, off); + x = _n_pep(mov, off); if ( c3n == x ) { - ip_s += sip_s; + ip_w += sip_w; } else if ( c3y != x ) { u3m_bail(c3__exit); @@ -1570,34 +1911,17 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } BURN(); - do_snoc: // [hed tel] - x = _n_pep(mov, off); - top = _n_peek(off); - _n_push(mov, off, u3nc(x, u3k(*top))); - BURN(); - - do_snol: - x = _n_pep(mov, off); - top = _n_peek(off); - *top = u3nc(x, *top); - BURN(); - do_kics: - x = _n_resh(pog, &ip_s); - goto kick_in; - - do_kick: - x = _n_rean(pog, &ip_s); + x = _n_resh(pog, &ip_w); goto kick_in; do_kicb: - x = pog[ip_s++]; - goto kick_in; - do_slam: - x = 2; + x = pog[ip_w++]; kick_in: - top = _n_peek(off); - o = *top; + sit_u = &(pog_u->cal_u.sit_u[x]); + top = _n_peek(off); + o = *top; + x = sit_u->axe; u3t_off(noc_o); *top = u3j_kick(o, x); u3t_on(noc_o); @@ -1605,19 +1929,20 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) u3_noun fol = u3x_at(x, o); _n_toss(mov, off); - fam = u3to(burnframe, u3R->cap_p) + off + mov; - u3R->cap_p = u3of(burnframe, fam - off); - fam->ip_s = ip_s; - fam->pog = pog; + fam = u3to(burnframe, u3R->cap_p) + off + mov; + u3R->cap_p = u3of(burnframe, fam - off); + fam->ip_w = ip_w; + fam->pog->u = pog_u; - pog = _n_find(fol); - ip_s = 0; + pog_u = _n_find(fol); + pog = pog_u->byc.ops_u; + ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif #ifdef VERBOSE_BYTECODE fprintf(stderr, "\r\nhead kick jump: %u, sp: %p\r\n", fol, top); - _n_print_byc(pog, ip_s); + _n_print_byc(pog, ip_w); #endif _n_push(mov, off, o); } @@ -1629,36 +1954,31 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) BURN(); do_tics: - x = _n_resh(pog, &ip_s); - goto tick_in; - - do_tick: - x = _n_rean(pog, &ip_s); + x = _n_resh(pog, &ip_w); goto tick_in; do_ticb: - x = pog[ip_s++]; - goto tick_in; - - do_slat: - x = 2; + x = pog[ip_w++]; tick_in: - top = _n_peek(off); - o = *top; + sit_u = &(pog_u->cal_u.sit_u[x]); + top = _n_peek(off); + o = *top; + x = sit_u->axe; u3t_off(noc_o); *top = u3j_kick(o, x); u3t_on(noc_o); if ( u3_none == *top ) { u3_noun fol = u3x_at(x, o); - *top = o; - pog = _n_find(fol); - ip_s = 0; + *top = o; + pog_u = _n_find(fol); + pog = pog_u->byc.ops_u; + ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif #ifdef VERBOSE_BYTECODE fprintf(stderr, "\r\ntail kick jump: %u, sp: %p\r\n", fol, top); - _n_print_byc(pog, ip_s); + _n_print_byc(pog, ip_w); #endif } #ifdef VERBOSE_BYTECODE @@ -1699,10 +2019,16 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) BURN(); } - do_cush: - x = _n_rean(pog, &ip_s); + do_sush: + x = _n_resh(pog, &ip_w); + goto cush_in; + + do_bush: + x = pog[ip_w++]; + cush_in: + x = u3k(pog_u->lit_u.non[x]); o = _n_pep(mov, off); - u3t_push(u3nc(u3k(x), o)); + u3t_push(u3nc(x, o)); BURN(); do_drop: @@ -1733,51 +2059,70 @@ _n_burn(c3_y* pog, u3_noun bus, c3_ys mov, c3_ys off) } BURN(); - do_falt: // [pro bus clu] + + do_sast: + x = _n_resh(pog, &ip_w); + goto fast_in; + + do_bast: + x = pog[ip_w++]; + goto fast_in; + + do_salt: + x = _n_resh(pog, &ip_w); + goto falt_in; + do_balt: + x = pog[ip_w++]; + falt_in: // [pro bus clu] o = _n_pep(mov, off); // [bus clu] _n_toss(mov, off); // [clu] top = _n_peek(off); - goto fast_in; + goto fast_out; - do_fast: // [pro bus clu] + fast_in: // [pro bus clu] o = _n_pep(mov, off); // [bus clu] top = _n_swap(mov, off); // [clu bus] - fast_in: + fast_out: + rit_u = &(pog_u->reg_u.rit_u[x]); u3t_off(noc_o); u3j_mine(*top, u3k(o)); u3t_on(noc_o); *top = o; BURN(); - do_skim: - sip_s = _n_resh(pog, &ip_s); + &&do_skib, &&do_skis, &&do_slib, &&do_slis, + &&do_save, + do_skis: + x = _n_resh(pog, &ip_w); goto skim_in; do_skib: - sip_s = pog[ip_s++]; + x = pog[ip_w++]; skim_in: - top = _n_peek(off); - x = u3k(*top); + mem_u = &(pog_u->mem_u.mem_u[x]); + top = _n_peek(off); + x = u3k(*top); goto skim_out; - do_slim: - sip_s = _n_resh(pog, &ip_s); + do_slis: + x = _n_resh(pog, &ip_w); goto slim_in; do_slib: - sip_s = pog[ip_s++]; + x = pog[ip_w++]; slim_in: - x = _n_pep(mov, off); + mem_u = &(pog_u->mem_u.mem_u[x]); + x = _n_pep(mov, off); skim_out: - o = _n_rean(pog, &ip_s); - x = u3nc(x, u3k(o)); - o = u3z_find(144 + c3__nock, x); + o = u3k(mem_u->key); + x = u3nc(x, o); + o = u3z_find(144 + c3__nock, x); if ( u3_none == o ) { _n_push(mov, off, x); _n_push(mov, off, u3k(u3h(x))); } else { - ip_s += sip_s; + ip_w += mem_u->sip_w; _n_push(mov, off, o); u3z(x); } @@ -1837,15 +2182,15 @@ u3n_nock_on(u3_noun bus, u3_noun fol) /* _n_take_narg(): helper for copying noun-parts of bytecode */ static void -_n_take_narg(c3_y* pog, c3_y* gop, c3_s sip_s, c3_s* ip_s) +_n_take_narg(c3_y* pog, c3_y* gop, c3_s sip_w, c3_s* ip_w) { c3_s i_s; - while ( sip_s-- > 0 ) { - gop[*ip_s] = pog[*ip_s]; - *ip_s += 1; + while ( sip_w-- > 0 ) { + gop[*ip_w] = pog[*ip_w]; + *ip_w += 1; } - u3_noun x = u3a_take(_n_rean(pog, ip_s)); - i_s = *ip_s; + u3_noun x = u3a_take(_n_rean(pog, ip_w)); + i_s = *ip_w; gop[--i_s] = (c3_y) (x >> 24); gop[--i_s] = (c3_y) (x >> 16); gop[--i_s] = (c3_y) (x >> 8); @@ -1858,38 +2203,38 @@ static c3_y* _n_take_byc(c3_y* pog) { c3_y i_y; - c3_s ip_s, len_s; + c3_s ip_w, len_s; c3_y* gop, cod_y; // measure - for ( ip_s = 0; (cod_y = pog[ip_s]) != HALT; ++ip_s ) { - ip_s += _n_arg(cod_y); + for ( ip_w = 0; (cod_y = pog[ip_w]) != HALT; ++ip_w ) { + ip_w += _n_arg(cod_y); } - len_s = ip_s + 1; + len_s = ip_w + 1; gop = u3a_malloc(len_s); - for ( ip_s = 0; ip_s < len_s; ) { - cod_y = gop[ip_s] = pog[ip_s]; - ip_s += 1; + for ( ip_w = 0; ip_w < len_s; ) { + cod_y = gop[ip_w] = pog[ip_w]; + ip_w += 1; switch ( cod_y ) { default: for ( i_y = _n_arg(cod_y); i_y > 0; --i_y ) { - gop[ip_s] = pog[ip_s]; - ip_s += 1; + gop[ip_w] = pog[ip_w]; + ip_w += 1; } break; case CUSH: case FRAG: case FLAG: case LILN: case LITN: case SAMN: case TICK: case KICK: - _n_take_narg(pog, gop, 0, &ip_s); + _n_take_narg(pog, gop, 0, &ip_w); break; case SKIB: case SLIB: - _n_take_narg(pog, gop, 1, &ip_s); + _n_take_narg(pog, gop, 1, &ip_w); break; case SKIM: case SLIM: - _n_take_narg(pog, gop, 2, &ip_s); + _n_take_narg(pog, gop, 2, &ip_w); break; } } @@ -1930,32 +2275,32 @@ static c3_w _n_mark_byc(c3_y* pog) { c3_y cod_y; - c3_s ip_s = 0; + c3_w ip_w = 0; c3_w tot_w = 0; u3_noun non; - while ( pog[ip_s] != HALT ) { - cod_y = pog[ip_s++]; + while ( pog[ip_w] != HALT ) { + cod_y = pog[ip_w++]; switch ( cod_y ) { default: - ip_s += _n_arg(cod_y); + ip_w += _n_arg(cod_y); break; case CUSH: case FRAG: case FLAG: case LILN: case LITN: case SAMN: case TICK: case KICK: - non = _n_rean(pog, &ip_s); + non = _n_rean(pog, &ip_w); tot_w += u3a_mark_noun(non); break; case SKIB: case SLIB: - ip_s += sizeof(c3_y); - non = _n_rean(pog, &ip_s); + ip_w += sizeof(c3_y); + non = _n_rean(pog, &ip_w); tot_w += u3a_mark_noun(non); break; case SKIM: case SLIM: - ip_s += sizeof(c3_s); - non = _n_rean(pog, &ip_s); + ip_w += sizeof(c3_s); + non = _n_rean(pog, &ip_w); tot_w += u3a_mark_noun(non); break; } @@ -1992,28 +2337,28 @@ static void _n_free_byc(c3_y* pog) { c3_y cod_y; - c3_s ip_s = 0; + c3_w ip_w = 0; - while ( pog[ip_s] != HALT ) { - cod_y = pog[ip_s++]; + while ( pog[ip_w] != HALT ) { + cod_y = pog[ip_w++]; switch ( cod_y ) { default: - ip_s += _n_arg(cod_y); + ip_w += _n_arg(cod_y); break; case CUSH: case FRAG: case FLAG: case LILN: case LITN: case SAMN: case TICK: case KICK: - u3z(_n_rean(pog, &ip_s)); + u3z(_n_rean(pog, &ip_w)); break; case SKIB: case SLIB: - ip_s += sizeof(c3_y); - u3z(_n_rean(pog, &ip_s)); + ip_w += sizeof(c3_y); + u3z(_n_rean(pog, &ip_w)); break; case SKIM: case SLIM: - ip_s += sizeof(c3_s); - u3z(_n_rean(pog, &ip_s)); + ip_w += sizeof(c3_w); + u3z(_n_rean(pog, &ip_w)); break; } } From 4959d951b022ebef8d45835e539bd267f2bea801 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 12 Apr 2018 11:31:42 -0700 Subject: [PATCH 061/221] stash - first pass & compile --- noun/nock.c | 454 ++++++++++++++++++++++++---------------------------- 1 file changed, 206 insertions(+), 248 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index be33a1869..03fafd211 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -539,7 +539,7 @@ typedef struct { } _n_rite; typedef struct { - c3_w sip_w; + c3_l sip_l; u3_noun key; } _n_memo; @@ -554,9 +554,9 @@ typedef struct { } _n_prog_lit; typedef struct { - c3_o own_w; + c3_o own_o; c3_w len_w; - c3_y* ops_u; + c3_y* ops_y; } _n_prog_ops; typedef struct { @@ -575,15 +575,46 @@ typedef struct { _n_prog_memo mem_u; _n_prog_call cal_u; _n_prog_reg reg_u; - void* dat[0]; + c3_y* dat[0]; } _n_prog; +/* _n_arg(): return the size (in bytes) of an opcode's argument + */ +static inline c3_y +_n_arg(c3_y cod_y) +{ + switch ( cod_y ) { + case FABK: case FABL: case FIBL: case FIBK: + case LILB: case LITB: case LIBL: case LIBK: + case SAMB: case SANB: case SBIP: case SBIN: + case SLIB: case SKIB: case KICB: case TICB: + case BUSH: case BAST: case BALT: + return sizeof(c3_y); + + case FASK: case FASL: case FISL: case FISK: + case LILS: case LITS: case LISL: case LISK: + case SAMS: case SANS: case SIPS: case SINS: + case SLIS: case SKIS: case KICS: case TICS: + case SUSH: case SAST: case SALT: + return sizeof(c3_s); + + case SWIP: case SWIN: + return sizeof(c3_l); + + default: + return 0; + } +} + + /* _n_melt(): measure space for list of ops (from _n_comp) */ static void _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, c3_w* reg_w, c3_w* lit_w, c3_w* mem_w) { + c3_y cod_y; c3_w i_w; + u3_noun op; while ( u3_nul != ops ) { op = u3h(ops); @@ -668,84 +699,66 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, } static _n_prog* -_n_prog_new(u3_noun bok) +_n_prog_new(c3_w byc_w, c3_w cal_w, + c3_w reg_w, c3_w lit_w, c3_w mem_w) { - _n_prog* pog_u; - c3_w byc_w = 1, // HALT - cal_w = 0, - reg_w = 0, - lit_w = 0, - mem_w = 0, - off_w, cab_w, reb_w, lib_w, meb_w; - - _n_melt(bok, &byc_w, &cal_w, ®_w, &lit_w, &mem_w); - - cab_w = (sizeof(_n_site) * cal_w); - reb_w = (sizeof(_n_rite) * reg_w); - lib_w = (sizeof(u3_noun) * lit_w); - meb_w = (sizeof(_n_memo) * mem_w); - pog_u = u3a_calloc(sizeof(_n_prog) + - sizeof(_n_prog_ops) + byc_w + - sizeof(_n_prog_call) + cab_w + - sizeof(_n_prog_reg) + reb_w + - sizeof(_n_prog_lit) + lib_w + - sizeof(_n_prog_memo) + meb_w); + c3_w cab_w = (sizeof(_n_site) * cal_w), + reb_w = (sizeof(_n_rite) * reg_w), + lib_w = (sizeof(u3_noun) * lit_w), + meb_w = (sizeof(_n_memo) * mem_w), + dat_w = byc_w + cab_w + reb_w + lib_w + meb_w; + _n_prog* pog_u = u3a_malloc(sizeof(_n_prog) + dat_w); pog_u->byc_u.own_o = c3y; pog_u->byc_u.len_w = byc_w; - pog_u->byc_u.ops_u = &(pog_u->dat); + pog_u->byc_u.ops_y = (c3_y*) (&(pog_u->dat)); pog_u->lit_u.len_w = lit_w; - pog_u->cal_u.lit_u = &(pog_u->dat) + (off_w = byc_w); + pog_u->lit_u.non = (u3_noun*) (pog_u->byc_u.ops_y + pog_u->byc_u.len_w); pog_u->mem_u.len_w = mem_w; - pog_u->mem_u.sot_u = &(pog_u->dat) + (off_w += lib_w); + pog_u->mem_u.sot_u = (_n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); pog_u->cal_u.len_w = cal_w; - pog_u->cal_u.sit_u = &(pog_u->dat) + (off_w += meb_w); + pog_u->cal_u.sit_u = (_n_site*) (pog_u->mem_u.sot_u + pog_u->mem_u.len_w); pog_u->reg_u.len_w = reg_w; - pog_u->reg_u.rit_u = &(pog_u->dat) + (off_w + cab_w); + pog_u->reg_u.rit_u = (_n_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); - _n_prog_asm(bok, pog_u); return pog_u; } static _n_prog* -_n_prog_old(_n_prog* sep) +_n_prog_old(_n_prog* sep_u) { - c3_w cab_w = sizeof(_n_site) * sep->cal_u.len_w, - reb_w = sizeof(_n_rite) * sep->reg_u.len_w, - lib_w = sizeof(u3_noun) * sep->lit_u.len_w, - meb_w = sizeof(_n_memo) * sep->mem_u.len_w; - - _n_prog* pog_u = u3a_calloc(sizeof(_n_prog) + - sizeof(_n_prog_ops) + - sizeof(_n_prog_call) + cab_w + - sizeof(_n_prog_reg) + reb_w + - sizeof(_n_prog_lit) + lib_w + - sizeof(_n_prog_memo) + meb_w); + c3_w cab_w = sizeof(_n_site) * sep_u->cal_u.len_w, + reb_w = sizeof(_n_rite) * sep_u->reg_u.len_w, + lib_w = sizeof(u3_noun) * sep_u->lit_u.len_w, + meb_w = sizeof(_n_memo) * sep_u->mem_u.len_w, + dat_w = cab_w + reb_w + lib_w + meb_w; + _n_prog* pog_u = u3a_malloc(sizeof(_n_prog) + dat_w); pog_u->byc_u.own_o = c3n; - pog_u->byc_u.len_w = sep->byc_u.len_w; - pog_u->byc_u.ops_u = sep->byc_u.ops_u; + pog_u->byc_u.len_w = sep_u->byc_u.len_w; + pog_u->byc_u.ops_y = sep_u->byc_u.ops_y; - pog_u->lit_u.len_w = sep->lit_u.len_w; - pog_u->cal_u.lit_u = &(pog_u->dat); + pog_u->lit_u.len_w = sep_u->lit_u.len_w; + pog_u->lit_u.non = (u3_noun*) &(pog_u->dat); - pog_u->mem_u.len_w = sep->mem_u.len_w; - pog_u->mem_u.sot_u = &(pog_u->dat) + (off_w = lib_w); + pog_u->mem_u.len_w = sep_u->mem_u.len_w; + pog_u->mem_u.sot_u = (_n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); - pog_u->cal_u.len_w = sep->cal_u.len_w; - pog_u->cal_u.sit_u = &(pog_u->dat) + (off_w += meb_w); + pog_u->cal_u.len_w = sep_u->cal_u.len_w; + pog_u->cal_u.sit_u = (_n_site*) (pog_u->mem_u.sot_u + pog_u->mem_u.len_w); - pog_u->reg_u.len_w = sep->reg_u.len_w; - pog_u->reg_u.rit_u = &(pog_u->dat) + (off_w + cab_w); + pog_u->reg_u.len_w = sep_u->reg_u.len_w; + pog_u->reg_u.rit_u = (_n_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); + memcpy(pog_u->dat, sep_u->dat, dat_w); return pog_u; } -static inline void +static void _n_prog_asm_inx(c3_y* buf_y, c3_w* i_w, c3_s inx_s, c3_y cod) { if ( inx_s <= 0xFF ) { @@ -764,16 +777,17 @@ _n_prog_asm_inx(c3_y* buf_y, c3_w* i_w, c3_s inx_s, c3_y cod) static void _n_prog_asm(u3_noun ops, _n_prog* pog_u) { - u3_noun top = ops; - c3_y* buf_y = pog_u->byc.ops_y; - c3_w i_w = pog_u->byc.len_w, - sip_l = 0, - ip_l = 0, - c3_l wil_l, was_l; + u3_noun top = ops, + sil = u3_nul; + c3_y* buf_y = pog_u->byc_u.ops_y; + c3_y sod_y; c3_s lit_s = 0, cal_s = 0, mem_s = 0, reg_s = 0; + c3_l wil_l, was_l; + c3_w i_w = pog_u->byc_u.len_w, + ip_l = 0; buf_y[i_w] = HALT; @@ -787,7 +801,7 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u) switch ( cod ) { default: c3_assert(0); - return 0; + return; /* skips cannot be computed until we have generated the next * n opcodes, so we create some state and finish the insert @@ -843,7 +857,7 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u) /* memo index args */ case SKIB: case SLIB: { _n_prog_asm_inx(buf_y, &i_w, mem_s, cod); - _n_mem* mem_u = &(pog_u->mem_u.sot_u[mem_s++]); + _n_memo* mem_u = &(pog_u->mem_u.sot_u[mem_s++]); mem_u->sip_l = u3h(u3t(op)); mem_u->key = u3k(u3t(u3t(op))); break; @@ -869,7 +883,7 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u) while ( u3_nul != sil ) { u3_noun cod, wil, was; u3x_trel(u3h(sil), &cod, &wil, &was); - cod_y = (c3_y) cod; + sod_y = (c3_y) cod; wil_l = (c3_l) wil; was_l = (c3_l) was; if ( ip_l != wil_l ) { @@ -901,7 +915,7 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u) buf_y[was_l--] = (c3_y) dif_w; buf_y[was_l] = sod_y + 2; break; - defaut: + default: c3_assert(0); break; } @@ -912,9 +926,23 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u) } // this assert will fail if we overflow a c3_w worth of instructions c3_assert(u3_nul == ops); - u3z(top); - return buf_y; +} + +static _n_prog* +_n_prog_from_ops(u3_noun ops) +{ + _n_prog* pog_u; + c3_w byc_w = 1, // HALT + cal_w = 0, + reg_w = 0, + lit_w = 0, + mem_w = 0; + + _n_melt(ops, &byc_w, &cal_w, ®_w, &lit_w, &mem_w); + pog_u = _n_prog_new(byc_w, cal_w, reg_w, lit_w, mem_w); + _n_prog_asm(ops, pog_u); + return pog_u; } #if 0 @@ -984,34 +1012,6 @@ _n_apen(u3_noun* dst, u3_noun src) *dst = u3kb_weld(src, *dst); } -/* _n_arg(): return the size (in bytes) of an opcode's argument - */ -static inline c3_y -_n_arg(c3_y cod_y) -{ - switch ( cod_y ) { - case FABK: case FABL: case FIBL: case FIBK: - case LILB: case LITB: case LIBL: case LIBK: - case SAMB: case SANB: case SBIP: case SBIN: - case SLIB: case SKIB: case KICB: case TICB: - case BUSH: case BAST: case BALT: - return sizeof(c3_y); - - case FASK: case FASL: case FISL: case FISK: - case LILS: case LITS: case LISL: case LISK: - case SAMS: case SANS: case SIPS: case SINS: - case SLIS: case SKIS: case KICS: case TICS: - case SUSH: case SAST: case SALT: - return sizeof(c3_s); - - case SWIP: case SWIN: - return sizeof(c3_l); - - default: - return 0; - } -} - /* _n_emit(): emit a single instruction to ops */ static inline void @@ -1092,11 +1092,11 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o) op_y = (c3y == los_o) ? SLIB : SKIB; // overflows to SLIS / SKIS ++tot_w; _n_emit(ops, u3nt(op_y, mem_w, u3k(nef))); - tot_s += mem_w; _n_apen(ops, mem); + tot_w += mem_w; _n_apen(ops, mem); break; } } - return tot_s; + return tot_w; } } @@ -1417,10 +1417,10 @@ _n_toss(c3_ys mov, c3_ys off) /* _n_resh(): read a c3_s from the bytecode stream */ static inline c3_s -_n_resh(c3_y* buf, c3_s* ip_s) +_n_resh(c3_y* buf, c3_w* ip_w) { - c3_y les = buf[(*ip_s)++]; - c3_y mos = buf[(*ip_s)++]; + c3_y les = buf[(*ip_w)++]; + c3_y mos = buf[(*ip_w)++]; return les | (mos << 8); } @@ -1443,7 +1443,7 @@ static inline _n_prog* _n_bite(u3_noun fol) { u3_noun ops = u3_nul; _n_comp(&ops, fol, c3y, c3y); - return _n_prog_new(ops); + return _n_prog_from_ops(ops); } /* _n_find(): return prog for given formula. fol is RETAINED. @@ -1456,16 +1456,16 @@ _n_find(u3_noun fol) return u3to(_n_prog, pog); } else { - u3a_road* rod_u = u3R->par_p; + u3a_road* rod_u = u3to(u3a_road, u3R->par_p); while ( rod_u ) { pog = u3h_git(rod_u->byc.har_p, fol); if ( u3_none != pog ) { _n_prog* old = _n_prog_old(u3to(_n_prog, pog)); - u3h_put(u3R->byc.har_p, u3a_outa(old)); + u3h_put(u3R->byc.har_p, fol, u3a_outa(old)); return old; } else { - rod_u = rod_u->par_p; + rod_u = u3to(u3a_road, rod_u->par_p); } } { @@ -1543,9 +1543,10 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) }; _n_site* sit_u; +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" _n_rite* rit_u; _n_memo* mem_u; - c3_y *pog = pog_u->byc.ops_u; + c3_y *pog = pog_u->byc_u.ops_y; c3_w sip_w, ip_w = 0; u3_noun* top; u3_noun x, o; @@ -1576,7 +1577,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) else { fam = u3to(burnframe, u3R->cap_p) + off; pog_u = fam->pog_u; - pog = pog_u->byc.ops_u; + pog = pog_u->byc_u.ops_y; ip_w = fam->ip_w; u3R->cap_p = u3of(burnframe, fam - (mov+off)); @@ -1693,9 +1694,6 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - &&do_lit0, &&do_lit1, &&do_litb, &&do_lits, - &&do_libk, &&do_lisk, - do_lit0: _n_push(mov, off, 0); BURN(); @@ -1770,7 +1768,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) _n_push(mov, off, x); nock_out: pog_u = _n_find(o); - pog = pog_u->byc.ops_u; + pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; @@ -1932,11 +1930,11 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) fam = u3to(burnframe, u3R->cap_p) + off + mov; u3R->cap_p = u3of(burnframe, fam - off); fam->ip_w = ip_w; - fam->pog->u = pog_u; + fam->pog_u = pog_u; pog_u = _n_find(fol); - pog = pog_u->byc.ops_u; - ip_w = 0; + pog = pog_u->byc_u.ops_y; + ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif @@ -1971,7 +1969,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) u3_noun fol = u3x_at(x, o); *top = o; pog_u = _n_find(fol); - pog = pog_u->byc.ops_u; + pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; @@ -2090,8 +2088,6 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) *top = o; BURN(); - &&do_skib, &&do_skis, &&do_slib, &&do_slis, - &&do_save, do_skis: x = _n_resh(pog, &ip_w); goto skim_in; @@ -2099,7 +2095,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) do_skib: x = pog[ip_w++]; skim_in: - mem_u = &(pog_u->mem_u.mem_u[x]); + mem_u = &(pog_u->mem_u.sot_u[x]); top = _n_peek(off); x = u3k(*top); goto skim_out; @@ -2111,7 +2107,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) do_slib: x = pog[ip_w++]; slim_in: - mem_u = &(pog_u->mem_u.mem_u[x]); + mem_u = &(pog_u->mem_u.sot_u[x]); x = _n_pep(mov, off); skim_out: o = u3k(mem_u->key); @@ -2122,7 +2118,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) _n_push(mov, off, u3k(u3h(x))); } else { - ip_w += mem_u->sip_w; + ip_w += mem_u->sip_l; _n_push(mov, off, o); u3z(x); } @@ -2146,8 +2142,8 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) static u3_noun _n_burn_on(u3_noun bus, u3_noun fol) { - c3_y* pog = _n_find(fol); c3_ys mov, off; + _n_prog* pog_u = _n_find(fol); u3z(fol); if ( c3y == u3a_is_north(u3R) ) { @@ -2158,7 +2154,7 @@ _n_burn_on(u3_noun bus, u3_noun fol) mov = 1; off = -1; } - u3_noun pro = _n_burn(pog, bus, mov, off); + u3_noun pro = _n_burn(pog_u, bus, mov, off); return pro; } @@ -2180,65 +2176,76 @@ u3n_nock_on(u3_noun bus, u3_noun fol) return pro; } -/* _n_take_narg(): helper for copying noun-parts of bytecode */ -static void -_n_take_narg(c3_y* pog, c3_y* gop, c3_s sip_w, c3_s* ip_w) +/* _n_prog_take(): copy program from a junior road + */ +static _n_prog* +_n_prog_take(_n_prog* pog_u) { - c3_s i_s; - while ( sip_w-- > 0 ) { - gop[*ip_w] = pog[*ip_w]; - *ip_w += 1; + _n_prog* gop_u; + c3_w i_w; + + if ( c3y == pog_u->byc_u.own_o ) { + gop_u = _n_prog_new(pog_u->byc_u.len_w, + pog_u->cal_u.len_w, pog_u->reg_u.len_w, + pog_u->lit_u.len_w, pog_u->mem_u.len_w); + memcpy(gop_u->byc_u.ops_y, pog_u->byc_u.ops_y, pog_u->byc_u.len_w); } - u3_noun x = u3a_take(_n_rean(pog, ip_w)); - i_s = *ip_w; - gop[--i_s] = (c3_y) (x >> 24); - gop[--i_s] = (c3_y) (x >> 16); - gop[--i_s] = (c3_y) (x >> 8); - gop[--i_s] = (c3_y) x; + else { + gop_u = _n_prog_old(pog_u); + } + + for ( i_w = 0; i_w < pog_u->lit_u.len_w; ++i_w ) { + gop_u->lit_u.non[i_w] = u3a_take(pog_u->lit_u.non[i_w]); + } + + for ( i_w = 0; i_w < pog_u->mem_u.len_w; ++i_w ) { + _n_memo* new_u = &(gop_u->mem_u.sot_u[i_w]); + _n_memo* old_u = &(pog_u->mem_u.sot_u[i_w]); + new_u->sip_l = old_u->sip_l; + new_u->key = u3a_take(old_u->key); + } + + for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { + _n_site* new_u = &(gop_u->cal_u.sit_u[i_w]); + _n_site* old_u = &(pog_u->cal_u.sit_u[i_w]); + new_u->axe = u3a_take(old_u->axe); + } + + /* nothing to do yet + for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { + _n_rite* new_u = &(gop_u->reg_u.rit_u[i_w]); + _n_rite* old_u = &(pog_u->reg_u.rit_u[i_w]); + } + */ + + return gop_u; } -/* _n_take_byc(): copy bytecode from a junior road - */ -static c3_y* -_n_take_byc(c3_y* pog) +/* _n_prog_free(): free memory retained by program +*/ +static void +_n_prog_free(_n_prog* pog_u) { - c3_y i_y; - c3_s ip_w, len_s; - c3_y* gop, cod_y; + c3_w i_w; - // measure - for ( ip_w = 0; (cod_y = pog[ip_w]) != HALT; ++ip_w ) { - ip_w += _n_arg(cod_y); + for ( i_w = 0; i_w < pog_u->lit_u.len_w; ++i_w ) { + u3z(pog_u->lit_u.non[i_w]); } - len_s = ip_w + 1; - gop = u3a_malloc(len_s); - for ( ip_w = 0; ip_w < len_s; ) { - cod_y = gop[ip_w] = pog[ip_w]; - ip_w += 1; - switch ( cod_y ) { - default: - for ( i_y = _n_arg(cod_y); i_y > 0; --i_y ) { - gop[ip_w] = pog[ip_w]; - ip_w += 1; - } - break; - - case CUSH: case FRAG: case FLAG: case LILN: case LITN: - case SAMN: case TICK: case KICK: - _n_take_narg(pog, gop, 0, &ip_w); - break; - - case SKIB: case SLIB: - _n_take_narg(pog, gop, 1, &ip_w); - break; - - case SKIM: case SLIM: - _n_take_narg(pog, gop, 2, &ip_w); - break; - } + for ( i_w = 0; i_w < pog_u->mem_u.len_w; ++i_w ) { + u3z(pog_u->mem_u.sot_u[i_w].key); } - return gop; + + for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { + u3z(pog_u->cal_u.sit_u[i_w].axe); + } + + /* nothing to do yet + for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { + } + */ + + u3a_free(pog_u); } /* _n_reap(): reap key and value from byc table. @@ -2250,14 +2257,14 @@ _n_reap(u3_noun kev) u3_noun got = u3t(kev); u3_noun lof = u3a_take(fol); u3_weak con = u3h_get(u3R->byc.har_p, lof); - // u3t_samp() etc. can interrupt us while we're compiling - // so we need to avoid leaking any parent bytecode - if ( u3_none == con ) { - c3_y* pog = u3a_into(got); - c3_y* gop = _n_take_byc(pog); - u3_noun tog = u3a_outa(gop); - u3h_put(u3R->byc.har_p, lof, tog); + + _n_prog* pog_u = u3to(_n_prog, got); + _n_prog* gop_u = _n_prog_take(pog_u); + + if ( u3_none != con ) { + _n_prog_free(u3to(_n_prog, con)); } + u3h_put(u3R->byc.har_p, lof, u3a_outa(gop_u)); u3z(lof); } @@ -2269,44 +2276,30 @@ u3n_beep(u3p(u3h_root) har_p) u3h_walk(har_p, _n_reap); } -/* _n_mark_byc(): mark bytecode for gc. +/* _n_prog_mark(): mark program for gc. */ static c3_w -_n_mark_byc(c3_y* pog) +_n_prog_mark(_n_prog* pog_u) { - c3_y cod_y; - c3_w ip_w = 0; - c3_w tot_w = 0; - u3_noun non; + c3_w i_w, tot_w = u3a_mark_mptr(pog_u); - while ( pog[ip_w] != HALT ) { - cod_y = pog[ip_w++]; - switch ( cod_y ) { - default: - ip_w += _n_arg(cod_y); - break; - - case CUSH: case FRAG: case FLAG: case LILN: case LITN: - case SAMN: case TICK: case KICK: - non = _n_rean(pog, &ip_w); - tot_w += u3a_mark_noun(non); - break; - - case SKIB: case SLIB: - ip_w += sizeof(c3_y); - non = _n_rean(pog, &ip_w); - tot_w += u3a_mark_noun(non); - break; - - case SKIM: case SLIM: - ip_w += sizeof(c3_s); - non = _n_rean(pog, &ip_w); - tot_w += u3a_mark_noun(non); - break; - } + for ( i_w = 0; i_w < pog_u->lit_u.len_w; ++i_w ) { + tot_w += u3a_mark_noun(pog_u->lit_u.non[i_w]); } - tot_w += u3a_mark_mptr(pog); + for ( i_w = 0; i_w < pog_u->mem_u.len_w; ++i_w ) { + tot_w += u3a_mark_noun(pog_u->mem_u.sot_u[i_w].key); + } + + for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { + tot_w += u3a_mark_noun(pog_u->cal_u.sit_u[i_w].axe); + } + + /* nothing to do yet for registration sites + for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { + } + */ + return tot_w; } @@ -2315,9 +2308,9 @@ _n_mark_byc(c3_y* pog) static void _n_bam(u3_noun kev, void* dat) { - c3_w* bam_w = dat; - c3_y* pog = u3a_into(u3t(kev)); - *bam_w += _n_mark_byc(pog); + c3_w* bam_w = dat; + _n_prog* pog = u3to(_n_prog, u3t(kev)); + *bam_w += _n_prog_mark(pog); } /* u3n_bark(): mark the bytecode cache for gc. @@ -2331,47 +2324,12 @@ u3n_bark() return bam_w + u3h_mark(har_p); } -/* _n_free_byc(): free memory retained by bytecode -*/ -static void -_n_free_byc(c3_y* pog) -{ - c3_y cod_y; - c3_w ip_w = 0; - - while ( pog[ip_w] != HALT ) { - cod_y = pog[ip_w++]; - switch ( cod_y ) { - default: - ip_w += _n_arg(cod_y); - break; - - case CUSH: case FRAG: case FLAG: case LILN: case LITN: - case SAMN: case TICK: case KICK: - u3z(_n_rean(pog, &ip_w)); - break; - - case SKIB: case SLIB: - ip_w += sizeof(c3_y); - u3z(_n_rean(pog, &ip_w)); - break; - - case SKIM: case SLIM: - ip_w += sizeof(c3_w); - u3z(_n_rean(pog, &ip_w)); - break; - } - } - - u3a_free(pog); -} - /* _n_feb(): u3h_walk helper for u3n_bree */ static void _n_feb(u3_noun kev) { - _n_free_byc(u3a_into(u3t(kev))); + _n_prog_free(u3to(_n_prog, u3t(kev))); } /* u3n_bree(): free bytecode cache From ed58c5f26783c67550058167a3f65397ef382501 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 12 Apr 2018 17:14:40 -0700 Subject: [PATCH 062/221] stash - jacks kernel successfully --- noun/nock.c | 348 ++++++++++++++++++++++++++-------------------------- 1 file changed, 173 insertions(+), 175 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 03fafd211..c35c3ca3b 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -575,7 +575,7 @@ typedef struct { _n_prog_memo mem_u; _n_prog_call cal_u; _n_prog_reg reg_u; - c3_y* dat[0]; + void* dat[0]; } _n_prog; /* _n_arg(): return the size (in bytes) of an opcode's argument @@ -602,33 +602,68 @@ _n_arg(c3_y cod_y) return sizeof(c3_l); default: + c3_assert( cod_y <= SAVE ); return 0; } } /* _n_melt(): measure space for list of ops (from _n_comp) */ -static void +static u3_noun _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, c3_w* reg_w, c3_w* lit_w, c3_w* mem_w) { + c3_w len_w = u3qb_lent(ops), + i_w = len_w - 1, + a_w; c3_y cod_y; - c3_w i_w; - u3_noun op; + c3_y* siz_y = u3a_malloc(len_w); + u3_noun op, sip = u3_nul; while ( u3_nul != ops ) { op = u3h(ops); if ( c3n == u3du(op) ) { - ++(*byc_w); + switch ( op ) { + default: + siz_y[i_w] = 1; + break; + + case BAST: case BALT: + a_w = (*reg_w)++; + if ( a_w <= 0xFF ) { + siz_y[i_w] = 2; + } + else if ( a_w <= 0xFFFF ) { + siz_y[i_w] = 3; + } + else { + fprintf(stderr, "_n_melt(): over 2^16 registration sites.\r\n"); + c3_assert(0); + } + break; + } } else { cod_y = u3h(op); switch ( cod_y ) { default: - *byc_w += _n_arg(cod_y) + 1; + siz_y[i_w] = 1 + _n_arg(cod_y); break; + case SBIP: case SBIN: { + c3_l tot_l = 0, + sip_l = u3t(op); + c3_w j_w, k_w = i_w; + for ( j_w = 0; j_w < sip_l; ++j_w ) { + tot_l += siz_y[++k_w]; + } + sip = u3nc(tot_l, sip); + siz_y[i_w] = tot_l <= 0xFF ? 2 : tot_l <= 0xFFFF ? 3 : 5; + break; + } + + case SIPS: case SINS: case SWIP: case SWIN: case SAST: case SALT: case KICS: case TICS: case FISK: case FISL: case SUSH: case SANS: case LISL: case LISK: case SKIS: case SLIS: @@ -636,41 +671,27 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, break; case KICB: case TICB: - i_w = (*cal_w)++; - if ( i_w <= 0xFF ) { - *byc_w += 2; + a_w = (*cal_w)++; + if ( a_w <= 0xFF ) { + siz_y[i_w] = 2; } - else if ( i_w <= 0xFFFF ) { - *byc_w += 3; + else if ( a_w <= 0xFFFF ) { + siz_y[i_w] = 3; } else { fprintf(stderr, "_n_melt(): over 2^16 call sites.\r\n"); c3_assert(0); } break; - - case BAST: case BALT: - i_w = (*reg_w)++; - if ( i_w <= 0xFF ) { - *byc_w += 2; - } - else if ( i_w <= 0xFFFF ) { - *byc_w += 3; - } - else { - fprintf(stderr, "_n_melt(): over 2^16 registration sites.\r\n"); - c3_assert(0); - } - break; case BUSH: case FIBK: case FIBL: case SANB: case LIBL: case LIBK: - i_w = (*lit_w)++; - if ( i_w <= 0xFF ) { - *byc_w += 2; + a_w = (*lit_w)++; + if ( a_w <= 0xFF ) { + siz_y[i_w] = 2; } - else if ( i_w <= 0xFFFF ) { - *byc_w += 3; + else if ( a_w <= 0xFFFF ) { + siz_y[i_w] = 3; } else { fprintf(stderr, "_n_melt(): over 2^16 literals.\r\n"); @@ -679,12 +700,12 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, break; case SKIB: case SLIB: - i_w = (*mem_w)++; - if ( i_w <= 0xFF ) { - *byc_w += 2; + a_w = (*mem_w)++; + if ( a_w <= 0xFF ) { + siz_y[i_w] = 2; } - else if ( i_w <= 0xFFFF ) { - *byc_w += 3; + else if ( a_w <= 0xFFFF ) { + siz_y[i_w] = 3; } else { fprintf(stderr, "_n_melt(): over 2^16 memos.\r\n"); @@ -694,8 +715,12 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, } } + *(byc_w) += siz_y[i_w--]; ops = u3t(ops); } + + u3a_free(siz_y); + return u3kb_flop(sip); } static _n_prog* @@ -775,26 +800,34 @@ _n_prog_asm_inx(c3_y* buf_y, c3_w* i_w, c3_s inx_s, c3_y cod) } static void -_n_prog_asm(u3_noun ops, _n_prog* pog_u) +_n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) { - u3_noun top = ops, - sil = u3_nul; + u3_noun top = ops; c3_y* buf_y = pog_u->byc_u.ops_y; - c3_y sod_y; c3_s lit_s = 0, cal_s = 0, mem_s = 0, reg_s = 0; - c3_l wil_l, was_l; - c3_w i_w = pog_u->byc_u.len_w, - ip_l = 0; + c3_w i_w = pog_u->byc_u.len_w-1; buf_y[i_w] = HALT; while ( i_w-- > 0 ) { u3_noun op = u3h(ops); if ( c3y == u3ud(op) ) { - buf_y[i_w] = (c3_y) u3h(ops); + switch ( op ) { + default: + buf_y[i_w] = (c3_y) u3h(ops); + break; + + /* registration site index args */ + case BAST: case BALT: { + _n_prog_asm_inx(buf_y, &i_w, reg_s, op); + _n_rite* rit_u = &(pog_u->reg_u.rit_u[reg_s++]); + rit_u->nul_w = 0; + break; + } + } } else { u3_noun cod = u3h(op); @@ -803,18 +836,29 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u) c3_assert(0); return; - /* skips cannot be computed until we have generated the next - * n opcodes, so we create some state and finish the insert - * at the end of the loop - */ - case SBIP: case SBIN: - sod_y = (c3_y) cod; - wil_l = (c3_l) ip_l + ((c3_l) u3t(op)); - was_l = (c3_l) i_w; - c3_assert(c3y == u3a_is_cat(wil_l)); - c3_assert(c3y == u3a_is_cat(was_l)); - sil = u3nc(u3nt(sod_y, wil_l, was_l), sil); + case SBIP: case SBIN: { + c3_l sip_l = u3h(sip); + u3_noun tmp = sip; + sip = u3k(u3t(sip)); + u3z(tmp); + if ( sip_l <= 0xFF ) { + buf_y[i_w--] = (c3_y) sip_l; + buf_y[i_w] = (c3_y) cod; + } + else if ( sip_l <= 0xFFFF ) { + buf_y[i_w--] = (c3_y) (sip_l >> 8); + buf_y[i_w--] = (c3_y) sip_l; + buf_y[i_w] = (c3_y) cod + 1; + } + else { + buf_y[i_w--] = (c3_y) (sip_l >> 24); + buf_y[i_w--] = (c3_y) (sip_l >> 16); + buf_y[i_w--] = (c3_y) (sip_l >> 8); + buf_y[i_w--] = (c3_y) sip_l; + buf_y[i_w] = (c3_y) cod + 2; + } break; + } /* 8-bit direct args */ case FABK: case FABL: @@ -870,68 +914,21 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u) sit_u->axe = u3k(u3t(op)); break; } - - /* registration site index args */ - case BAST: case BALT: { - _n_prog_asm_inx(buf_y, &i_w, reg_s, cod); - _n_rite* rit_u = &(pog_u->reg_u.rit_u[reg_s++]); - rit_u->nul_w = 0; - break; - } } } - while ( u3_nul != sil ) { - u3_noun cod, wil, was; - u3x_trel(u3h(sil), &cod, &wil, &was); - sod_y = (c3_y) cod; - wil_l = (c3_l) wil; - was_l = (c3_l) was; - if ( ip_l != wil_l ) { - // first is finished or none are - break; - } - else { - c3_w dif_w = was_l - i_w; - c3_y siz_y = dif_w <= 0xFF ? 2 : dif_w <= 0xFFFF ? 3 : 5; - u3_noun lis = u3k(u3t(sil)); - u3z(sil); - sil = lis; - memmove(buf_y + i_w - siz_y, buf_y + i_w, dif_w); - i_w -= siz_y; - switch ( siz_y ) { - case 2: - buf_y[was_l--] = (c3_y) dif_w; - buf_y[was_l] = sod_y; - break; - case 3: - buf_y[was_l--] = (c3_y) (dif_w >> 8); - buf_y[was_l--] = (c3_y) dif_w; - buf_y[was_l] = sod_y + 1; - break; - case 5: - buf_y[was_l--] = (c3_y) (dif_w >> 24); - buf_y[was_l--] = (c3_y) (dif_w >> 16); - buf_y[was_l--] = (c3_y) (dif_w >> 8); - buf_y[was_l--] = (c3_y) dif_w; - buf_y[was_l] = sod_y + 2; - break; - default: - c3_assert(0); - break; - } - } - } - ++ip_l; ops = u3t(ops); } + u3z(top); // this assert will fail if we overflow a c3_w worth of instructions c3_assert(u3_nul == ops); - u3z(top); + // this is just a sanity check + c3_assert(u3_nul == sip); } static _n_prog* _n_prog_from_ops(u3_noun ops) { + u3_noun sip; _n_prog* pog_u; c3_w byc_w = 1, // HALT cal_w = 0, @@ -939,13 +936,13 @@ _n_prog_from_ops(u3_noun ops) lit_w = 0, mem_w = 0; - _n_melt(ops, &byc_w, &cal_w, ®_w, &lit_w, &mem_w); + sip = _n_melt(ops, &byc_w, &cal_w, ®_w, &lit_w, &mem_w); pog_u = _n_prog_new(byc_w, cal_w, reg_w, lit_w, mem_w); - _n_prog_asm(ops, pog_u); + _n_prog_asm(ops, pog_u, sip); return pog_u; } -#if 0 +#if 1 /* _n_print_stack(): print out the cap stack up to a designated "empty" * used only for debugging */ @@ -1305,55 +1302,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) return tot_w; } -#ifdef VERBOSE_BYTECODE -/* _n_print_byc(): print bytecode. used for debugging. - */ -static void -_n_print_byc(c3_y* pog, c3_w her_w) -{ - c3_w ip_w = 0; - if ( her_w == 0 ) { - fprintf(stderr, "begin: {"); - } - else { - fprintf(stderr, "resume: {"); - } - int first = 1; - while ( pog[ip_w] ) { - if ( first ) { - first = 0; - } - else if (ip_w == her_w) { - fprintf(stderr, " [*]"); - } - else { - fprintf(stderr, " "); - } - switch ( _n_arg(pog[ip_w]) ) { - case 0: - fprintf(stderr, "%s", opcode_names[pog[ip_w++]]); - break; - - case 1: - fprintf(stderr, "[%s ", opcode_names[pog[ip_w++]]); - fprintf(stderr, "%u]", pog[ip_w++]); - break; - - case 2: - fprintf(stderr, "[%s ", opcode_names[pog[ip_w++]]); - fprintf(stderr, "%u]", _n_resh(pog, &ip_w)); - break; - - case 4: - fprintf(stderr, "[%s", opcode_names[pog[ip_w++]]); - fprintf(stderr, "%u]", _n_rean(pog, &ip_w)); - break; - } - } - fprintf(stderr, " halt}\r\n"); -} -#endif - /* _n_push(): push a noun onto the stack. RETAIN * mov: -1 north, 1 south * off: 0 north, -1 south @@ -1424,11 +1372,10 @@ _n_resh(c3_y* buf, c3_w* ip_w) return les | (mos << 8); } -/* _n_rean(): read a noun from the bytecode stream. - * refcount is NOT incremented. +/* _n_rewo(): read a c3_w from the bytecode stream. */ -static inline u3_noun -_n_rean(c3_y* buf, c3_w* ip_w) +static inline c3_w +_n_rewo(c3_y* buf, c3_w* ip_w) { c3_y one = buf[(*ip_w)++], two = buf[(*ip_w)++], @@ -1437,6 +1384,58 @@ _n_rean(c3_y* buf, c3_w* ip_w) return one | (two << 8) | (tre << 16) | (qua << 24); } +#ifdef VERBOSE_BYTECODE +/* _n_print_byc(): print bytecode. used for debugging. + */ +static void +_n_print_byc(c3_y* pog, c3_w her_w) +{ + c3_w ip_w = 0; + if ( her_w == 0 ) { + fprintf(stderr, "begin: {"); + } + else { + fprintf(stderr, "resume: {"); + } + int first = 1; + while ( pog[ip_w] ) { + if ( first ) { + first = 0; + } + else if (ip_w == her_w) { + fprintf(stderr, " [*]"); + } + else { + fprintf(stderr, " "); + } + switch ( _n_arg(pog[ip_w]) ) { + case 0: + fprintf(stderr, "%s", opcode_names[pog[ip_w++]]); + break; + + case 1: + fprintf(stderr, "[%s ", opcode_names[pog[ip_w++]]); + fprintf(stderr, "%u]", pog[ip_w++]); + break; + + case 2: + fprintf(stderr, "[%s ", opcode_names[pog[ip_w++]]); + fprintf(stderr, "%u]", _n_resh(pog, &ip_w)); + break; + + case 4: + fprintf(stderr, "[%s", opcode_names[pog[ip_w++]]); + fprintf(stderr, "%u]", _n_rewo(pog, &ip_w)); + break; + default: + c3_assert(0); + break; + } + } + fprintf(stderr, " halt}\r\n"); +} +#endif + /* _n_bite(): compile a nock formula to bytecode */ static inline _n_prog* @@ -1455,25 +1454,24 @@ _n_find(u3_noun fol) if ( u3_none != pog ) { return u3to(_n_prog, pog); } - else { - u3a_road* rod_u = u3to(u3a_road, u3R->par_p); - while ( rod_u ) { - pog = u3h_git(rod_u->byc.har_p, fol); + else if ( u3R != &u3H->rod_u ) { + u3a_road* rod_u = u3R; + while ( rod_u->par_p ) { + rod_u = u3to(u3a_road, rod_u->par_p); + pog = u3h_git(rod_u->byc.har_p, fol); if ( u3_none != pog ) { _n_prog* old = _n_prog_old(u3to(_n_prog, pog)); u3h_put(u3R->byc.har_p, fol, u3a_outa(old)); return old; } - else { - rod_u = u3to(u3a_road, rod_u->par_p); - } - } - { - _n_prog* gop = _n_bite(fol); - u3h_put(u3R->byc.har_p, fol, u3a_outa(gop)); - return gop; } } + + { + _n_prog* gop = _n_bite(fol); + u3h_put(u3R->byc.har_p, fol, u3a_outa(gop)); + return gop; + } } /* _n_swap(): swap two items on the top of the stack, return pointer to top @@ -1884,12 +1882,12 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) BURN(); do_swip: - sip_w = _n_rean(pog, &ip_w); + sip_w = _n_rewo(pog, &ip_w); ip_w += sip_w; BURN(); do_swin: - sip_w = _n_rean(pog, &ip_w); + sip_w = _n_rewo(pog, &ip_w); goto skin_in; do_sins: From 4c482af711b001d4d08cad3ad741eddbcaa6c85f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 13 Apr 2018 13:32:31 -0700 Subject: [PATCH 063/221] fixed memoization, memory problems in reap --- noun/nock.c | 158 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 99 insertions(+), 59 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index c35c3ca3b..a95372645 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -575,7 +575,6 @@ typedef struct { _n_prog_memo mem_u; _n_prog_call cal_u; _n_prog_reg reg_u; - void* dat[0]; } _n_prog; /* _n_arg(): return the size (in bytes) of an opcode's argument @@ -663,6 +662,28 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, break; } + case SKIB: case SLIB: { + c3_l tot_l = 0, + sip_l = u3h(u3t(op)); + c3_w j_w, k_w = i_w; + for ( j_w = 0; j_w < sip_l; ++j_w ) { + tot_l += siz_y[++k_w]; + } + sip = u3nc(tot_l, sip); + a_w = (*mem_w)++; + if ( a_w <= 0xFF ) { + siz_y[i_w] = 2; + } + else if ( a_w <= 0xFFFF ) { + siz_y[i_w] = 3; + } + else { + fprintf(stderr, "_n_melt(): over 2^16 memos.\r\n"); + c3_assert(0); + } + break; + } + case SIPS: case SINS: case SWIP: case SWIN: case SAST: case SALT: case KICS: case TICS: case FISK: case FISL: case SUSH: case SANS: @@ -698,20 +719,6 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, c3_assert(0); } break; - - case SKIB: case SLIB: - a_w = (*mem_w)++; - if ( a_w <= 0xFF ) { - siz_y[i_w] = 2; - } - else if ( a_w <= 0xFFFF ) { - siz_y[i_w] = 3; - } - else { - fprintf(stderr, "_n_melt(): over 2^16 memos.\r\n"); - c3_assert(0); - } - break; } } @@ -723,6 +730,12 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, return u3kb_flop(sip); } +static void* +_n_prog_dat(_n_prog* pog_u) +{ + return ((void*) pog_u) + sizeof(_n_prog); +} + static _n_prog* _n_prog_new(c3_w byc_w, c3_w cal_w, c3_w reg_w, c3_w lit_w, c3_w mem_w) @@ -736,7 +749,7 @@ _n_prog_new(c3_w byc_w, c3_w cal_w, _n_prog* pog_u = u3a_malloc(sizeof(_n_prog) + dat_w); pog_u->byc_u.own_o = c3y; pog_u->byc_u.len_w = byc_w; - pog_u->byc_u.ops_y = (c3_y*) (&(pog_u->dat)); + pog_u->byc_u.ops_y = (c3_y*) _n_prog_dat(pog_u); pog_u->lit_u.len_w = lit_w; pog_u->lit_u.non = (u3_noun*) (pog_u->byc_u.ops_y + pog_u->byc_u.len_w); @@ -767,8 +780,9 @@ _n_prog_old(_n_prog* sep_u) pog_u->byc_u.len_w = sep_u->byc_u.len_w; pog_u->byc_u.ops_y = sep_u->byc_u.ops_y; + pog_u->lit_u.len_w = sep_u->lit_u.len_w; - pog_u->lit_u.non = (u3_noun*) &(pog_u->dat); + pog_u->lit_u.non = (u3_noun*) _n_prog_dat(pog_u); pog_u->mem_u.len_w = sep_u->mem_u.len_w; pog_u->mem_u.sot_u = (_n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); @@ -779,7 +793,7 @@ _n_prog_old(_n_prog* sep_u) pog_u->reg_u.len_w = sep_u->reg_u.len_w; pog_u->reg_u.rit_u = (_n_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); - memcpy(pog_u->dat, sep_u->dat, dat_w); + memcpy(pog_u->lit_u.non, sep_u->lit_u.non, dat_w); return pog_u; } @@ -836,6 +850,21 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) c3_assert(0); return; + /* memo index args */ + case SKIB: case SLIB: { + _n_memo* mem_u; + c3_l sip_l = u3h(sip); + u3_noun tmp = sip; + sip = u3k(u3t(sip)); + u3z(tmp); + _n_prog_asm_inx(buf_y, &i_w, mem_s, cod); + mem_u = &(pog_u->mem_u.sot_u[mem_s++]); + mem_u->sip_l = sip_l; + mem_u->key = u3k(u3t(u3t(op))); + break; + } + + /* skips */ case SBIP: case SBIN: { c3_l sip_l = u3h(sip); u3_noun tmp = sip; @@ -898,15 +927,6 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) pog_u->lit_u.non[lit_s++] = u3k(u3t(op)); break; - /* memo index args */ - case SKIB: case SLIB: { - _n_prog_asm_inx(buf_y, &i_w, mem_s, cod); - _n_memo* mem_u = &(pog_u->mem_u.sot_u[mem_s++]); - mem_u->sip_l = u3h(u3t(op)); - mem_u->key = u3k(u3t(u3t(op))); - break; - } - /* call site index args */ case TICB: case KICB: { _n_prog_asm_inx(buf_y, &i_w, cal_s, cod); @@ -970,7 +990,7 @@ static void _n_print_stack(u3p(u3_noun) empty) { } #endif -#ifdef VERBOSE_BYTECODE +#if 1 // match to OPCODE TABLE static char* opcode_names[] = { "halt", "bail", @@ -1384,7 +1404,7 @@ _n_rewo(c3_y* buf, c3_w* ip_w) return one | (two << 8) | (tre << 16) | (qua << 24); } -#ifdef VERBOSE_BYTECODE +#if 1 /* _n_print_byc(): print bytecode. used for debugging. */ static void @@ -2174,13 +2194,55 @@ u3n_nock_on(u3_noun bus, u3_noun fol) return pro; } +static void +_n_prog_take_dat(_n_prog* dst_u, _n_prog* src_u, c3_o los_o) +{ + c3_w i_w; + for ( i_w = 0; i_w < src_u->lit_u.len_w; ++i_w ) { + u3_noun* dst = &(dst_u->lit_u.non[i_w]); + u3_noun* src = &(src_u->lit_u.non[i_w]); + u3_noun old = *dst; + *dst = u3a_take(*src); + if ( c3y == los_o ) { + u3z(old); + } + } + + for ( i_w = 0; i_w < src_u->mem_u.len_w; ++i_w ) { + _n_memo* dst = &(dst_u->mem_u.sot_u[i_w]); + _n_memo* src = &(src_u->mem_u.sot_u[i_w]); + u3_noun old = dst->key; + dst->sip_l = src->sip_l; + dst->key = u3a_take(src->key); + if ( c3y == los_o ) { + u3z(old); + } + } + + for ( i_w = 0; i_w < src_u->cal_u.len_w; ++i_w ) { + _n_site* dst = &(dst_u->cal_u.sit_u[i_w]); + _n_site* src = &(src_u->cal_u.sit_u[i_w]); + u3_noun old = dst->axe; + dst->axe = u3a_take(src->axe); + if ( c3y == los_o ) { + u3z(old); + } + } + + /* nothing to do yet + for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { + _n_rite* new_u = &(gop_u->reg_u.rit_u[i_w]); + _n_rite* old_u = &(pog_u->reg_u.rit_u[i_w]); + } + */ +} + /* _n_prog_take(): copy program from a junior road */ static _n_prog* _n_prog_take(_n_prog* pog_u) { _n_prog* gop_u; - c3_w i_w; if ( c3y == pog_u->byc_u.own_o ) { gop_u = _n_prog_new(pog_u->byc_u.len_w, @@ -2191,30 +2253,7 @@ _n_prog_take(_n_prog* pog_u) else { gop_u = _n_prog_old(pog_u); } - - for ( i_w = 0; i_w < pog_u->lit_u.len_w; ++i_w ) { - gop_u->lit_u.non[i_w] = u3a_take(pog_u->lit_u.non[i_w]); - } - - for ( i_w = 0; i_w < pog_u->mem_u.len_w; ++i_w ) { - _n_memo* new_u = &(gop_u->mem_u.sot_u[i_w]); - _n_memo* old_u = &(pog_u->mem_u.sot_u[i_w]); - new_u->sip_l = old_u->sip_l; - new_u->key = u3a_take(old_u->key); - } - - for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - _n_site* new_u = &(gop_u->cal_u.sit_u[i_w]); - _n_site* old_u = &(pog_u->cal_u.sit_u[i_w]); - new_u->axe = u3a_take(old_u->axe); - } - - /* nothing to do yet - for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { - _n_rite* new_u = &(gop_u->reg_u.rit_u[i_w]); - _n_rite* old_u = &(pog_u->reg_u.rit_u[i_w]); - } - */ + _n_prog_take_dat(gop_u, pog_u, c3n); return gop_u; } @@ -2255,14 +2294,15 @@ _n_reap(u3_noun kev) u3_noun got = u3t(kev); u3_noun lof = u3a_take(fol); u3_weak con = u3h_get(u3R->byc.har_p, lof); - _n_prog* pog_u = u3to(_n_prog, got); - _n_prog* gop_u = _n_prog_take(pog_u); - + if ( u3_none != con ) { - _n_prog_free(u3to(_n_prog, con)); + _n_prog* sep_u = u3to(_n_prog, con); + _n_prog_take_dat(sep_u, pog_u, c3y); + } + else { + u3h_put(u3R->byc.har_p, lof, u3a_outa(_n_prog_take(pog_u))); } - u3h_put(u3R->byc.har_p, lof, u3a_outa(gop_u)); u3z(lof); } From 3c7317a1a41c3c2a66810c321d8d871bfa44d6b2 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 14 Apr 2018 14:57:12 -0700 Subject: [PATCH 064/221] registration site caching --- include/noun/jets.h | 8 +- noun/jets.c | 64 +++++++++++--- noun/nock.c | 204 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 244 insertions(+), 32 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 9bff76d89..6463707e0 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -116,7 +116,13 @@ u3_noun u3j_kink(u3_noun cor, u3_noun axe); - + + + /* u3j_mile(): register core for jets, returning location. + */ + u3_weak + u3j_mile(u3_noun clu, u3_noun cor); + /* u3j_mine(): register core for jets. */ void diff --git a/noun/jets.c b/noun/jets.c index a6782b8e9..c2f959f3c 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -759,9 +759,9 @@ _cj_mine_par(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) } } -/* _cj_mine(): declare a core. RETAIN. +/* _cj_mine(): declare a core and produce location. RETAIN. */ -static void +static u3_weak _cj_mine(u3_noun cey, u3_noun cor) { c3_l par_l, jax_l; @@ -789,7 +789,7 @@ _cj_mine(u3_noun cey, u3_noun cor) par = u3r_at(axe, cor); if ( u3_none == par || c3n == u3du(par) ) { fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(nam)); - return; + return u3_none; } pel = u3j_spot(par); if ( u3_none == pel ) { @@ -797,7 +797,7 @@ _cj_mine(u3_noun cey, u3_noun cor) u3r_string(nam), u3r_mug(u3h(par)), axe); - return; + return u3_none; } pac = _cj_find_warm(pel); c3_assert(u3_none != pac); @@ -826,7 +826,49 @@ _cj_mine(u3_noun cey, u3_noun cor) act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); u3h_put(u3R->jed.cod_p, bat, reg); u3h_put(u3R->jed.war_p, loc, act); - u3z(loc); + + return loc; +} + +/* _cj_moan(): register core known to be unregistered, returning + * location. + */ +static u3_weak +_cj_moan(u3_noun clu, u3_noun cor) +{ + u3_weak cey = _cj_je_fsck(clu); + u3_weak loc = u3_none; + if ( u3_none != cey ) { + loc = _cj_mine(cey, cor); + u3z(cey); + } + u3z(cor); + return loc; +} + +/* u3j_mile(): register core for jets, returning location. +*/ +u3_weak +u3j_mile(u3_noun clu, u3_noun cor) +{ + u3t_on(glu_o); + u3_weak loc = u3_none; + if ( c3n == u3du(cor) ) { + u3z(clu); + u3z(cor); + } + else { + loc = u3j_spot(cor); + if ( u3_none == loc ) { + loc = _cj_moan(clu, cor); + } + else { + u3z(clu); + u3z(cor); + } + } + u3t_off(glu_o); + return loc; } /* u3j_mine(): register core for jets. @@ -837,16 +879,14 @@ u3j_mine(u3_noun clu, u3_noun cor) u3t_on(glu_o); if ( (c3n == u3du(cor)) || (c3y == _cj_scan(cor)) ) { u3z(clu); + u3z(cor); } else { - u3_noun cey = _cj_je_fsck(clu); - - if ( u3_none != cey ) { - _cj_mine(cey, cor); - u3z(cey); + u3_weak loc = _cj_moan(clu, cor); + if ( u3_none != loc ) { + u3z(loc); } } - u3z(cor); u3t_off(glu_o); } @@ -1048,7 +1088,7 @@ u3j_ream(void) name=term hooks=(map term axis) == -+= static (each payload=* parent=static) ++= static (each payload=* parent=location) += dynamic [where=axis parent=location] :: += registry [roots=(map * location) parents=(list parent)] diff --git a/noun/nock.c b/noun/nock.c index a95372645..ac8811712 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -527,15 +527,27 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIS 71 #define SAVE 72 +typedef struct { + u3_noun bat; + u3_noun pax; +} _n_fist; + +typedef struct { + c3_w len_w; + u3_noun sat; + _n_fist fis_u[0]; +} _n_fink; /* placeholder: call site memory */ typedef struct { u3_noun axe; } _n_site; -/* placeholder: registration site memory */ +/* registration site memory */ typedef struct { - c3_w nul_w; + c3_o own_o; + u3_weak clu; + _n_fink* fin_u; } _n_rite; typedef struct { @@ -577,6 +589,130 @@ typedef struct { _n_prog_reg reg_u; } _n_prog; +static c3_o +_n_fine(u3_noun cor, _n_fink* fin_u) +{ + c3_w i_w; + for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { + _n_fist* fis_u = &(fin_u->fis_u[i_w]); + if ( c3n == u3r_sing(fis_u->bat, u3h(cor)) ) { + return c3n; + } + else { + cor = u3r_at(fis_u->pax, cor); + } + } + return u3r_sing(fin_u->sat, cor); +} + +static _n_fink* +_n_cast(u3_noun cor, u3_noun loc) +{ + c3_w i_w = 0; + u3_noun j, par, bat, dyn, pax, + rev = u3_nul, + pat = u3h(loc); + _n_fink* fin_u; + + while ( c3n == u3h(pat) ) { + bat = u3h(cor); + dyn = u3t(pat); + pax = u3h(dyn); + loc = u3t(dyn); + pat = u3h(loc); + rev = u3nc(u3nc(u3k(bat), u3k(pax)), rev); + cor = u3r_at(pax, cor); + ++i_w; + } + + fin_u = u3a_walloc(c3_wiseof(_n_fink) + + (i_w * c3_wiseof(_n_fist))); + fin_u->len_w = i_w; + fin_u->sat = u3k(cor); + for ( j = rev; i_w-- > 0; j = u3t(j) ) { + _n_fist* fis_u = &(fin_u->fis_u[i_w]); + par = u3h(j); + fis_u->bat = u3k(u3h(par)); + fis_u->pax = u3k(u3t(par)); + } + u3z(rev); + c3_assert( u3_nul == j ); + + return fin_u; +} + +static c3_w +_n_fink_mark(_n_fink* fin_u) +{ + c3_w i_w, tot_w = u3a_mark_noun(fin_u->sat); + for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { + _n_fist* fis_u = &(fin_u->fis_u[i_w]); + tot_w += u3a_mark_noun(fis_u->bat); + tot_w += u3a_mark_noun(fis_u->pax); + } + tot_w += u3a_mark_ptr(fin_u); + return tot_w; +} + +static void +_n_fink_free(_n_fink* fin_u) +{ + c3_w i_w; + u3z(fin_u->sat); + for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { + _n_fist* fis_u = &(fin_u->fis_u[i_w]); + u3z(fis_u->bat); + u3z(fis_u->pax); + } + u3a_wfree(fin_u); +} + +static _n_fink* +_n_fink_take(_n_fink* jun_u) +{ + c3_w i_w, len_w = jun_u->len_w; + _n_fink* fin_u = u3a_walloc(c3_wiseof(_n_fink) + + (len_w * c3_wiseof(_n_fist))); + + fin_u->len_w = len_w; + fin_u->sat = u3a_take(jun_u->sat); + for ( i_w = 0; i_w < len_w; ++i_w ) { + _n_fist* fis_u = &(fin_u->fis_u[i_w]); + _n_fist* sif_u = &(jun_u->fis_u[i_w]); + fis_u->bat = u3a_take(sif_u->bat); + fis_u->pax = u3a_take(sif_u->pax); + } + return fin_u; +} + +static void +_n_mine(_n_rite* rit_u, u3_noun clu, u3_noun cor) +{ + c3_t non_t = (u3_none == rit_u->clu); + + if ( non_t || + c3n == u3r_sing(rit_u->clu, clu) || + c3n == _n_fine(cor, rit_u->fin_u) ) { + u3_weak loc = u3j_mile(u3k(clu), u3k(cor)); + if ( u3_none != loc ) { + u3_noun old = rit_u->clu; + _n_fink* fon_u = rit_u->fin_u; + c3_o own_o = rit_u->own_o; + rit_u->own_o = c3y; + rit_u->clu = u3k(clu); + rit_u->fin_u = _n_cast(cor, loc); + u3z(loc); + + if ( !non_t && (c3y == own_o) ) { + u3z(old); + _n_fink_free(fon_u); + } + } + } + u3z(clu); + u3z(cor); +} + /* _n_arg(): return the size (in bytes) of an opcode's argument */ static inline c3_y @@ -780,7 +916,6 @@ _n_prog_old(_n_prog* sep_u) pog_u->byc_u.len_w = sep_u->byc_u.len_w; pog_u->byc_u.ops_y = sep_u->byc_u.ops_y; - pog_u->lit_u.len_w = sep_u->lit_u.len_w; pog_u->lit_u.non = (u3_noun*) _n_prog_dat(pog_u); @@ -838,7 +973,9 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) case BAST: case BALT: { _n_prog_asm_inx(buf_y, &i_w, reg_s, op); _n_rite* rit_u = &(pog_u->reg_u.rit_u[reg_s++]); - rit_u->nul_w = 0; + rit_u->own_o = c3n; + rit_u->clu = u3_none; + rit_u->fin_u = NULL; break; } } @@ -1480,7 +1617,12 @@ _n_find(u3_noun fol) rod_u = u3to(u3a_road, rod_u->par_p); pog = u3h_git(rod_u->byc.har_p, fol); if ( u3_none != pog ) { + c3_w i_w; _n_prog* old = _n_prog_old(u3to(_n_prog, pog)); + for ( i_w = 0; i_w < old->reg_u.len_w; ++i_w ) { + _n_rite* rit_u = &(old->reg_u.rit_u[i_w]); + rit_u->own_o = c3n; + } u3h_put(u3R->byc.har_p, fol, u3a_outa(old)); return old; } @@ -1561,7 +1703,6 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) }; _n_site* sit_u; -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" _n_rite* rit_u; _n_memo* mem_u; c3_y *pog = pog_u->byc_u.ops_y; @@ -2101,7 +2242,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) fast_out: rit_u = &(pog_u->reg_u.rit_u[x]); u3t_off(noc_o); - u3j_mine(*top, u3k(o)); + _n_mine(rit_u, *top, u3k(o)); u3t_on(noc_o); *top = o; BURN(); @@ -2229,12 +2370,31 @@ _n_prog_take_dat(_n_prog* dst_u, _n_prog* src_u, c3_o los_o) } } - /* nothing to do yet - for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { - _n_rite* new_u = &(gop_u->reg_u.rit_u[i_w]); - _n_rite* old_u = &(pog_u->reg_u.rit_u[i_w]); + for ( i_w = 0; i_w < src_u->reg_u.len_w; ++i_w ) { + _n_rite* dst = &(dst_u->reg_u.rit_u[i_w]); + _n_rite* src = &(src_u->reg_u.rit_u[i_w]); + + if ( u3_none == src->clu ) { + dst->clu = u3_none; + dst->fin_u = NULL; + } + else { + u3_noun old = dst->clu; + _n_fink* fon_u = dst->fin_u; + c3_o own_o = dst->own_o; + if ( c3y == src->own_o ) { + dst->own_o = c3y; + dst->clu = u3a_take(src->clu); + dst->fin_u = _n_fink_take(src->fin_u); + if ( (c3y == los_o) && + (u3_none != old) && + (c3y == own_o) ) { + u3z(old); + _n_fink_free(fon_u); + } + } + } } - */ } /* _n_prog_take(): copy program from a junior road @@ -2277,10 +2437,13 @@ _n_prog_free(_n_prog* pog_u) u3z(pog_u->cal_u.sit_u[i_w].axe); } - /* nothing to do yet for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { + _n_rite* rit_u = &(pog_u->reg_u.rit_u[i_w]); + if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { + u3z(rit_u->clu); + _n_fink_free(rit_u->fin_u); + } } - */ u3a_free(pog_u); } @@ -2296,12 +2459,12 @@ _n_reap(u3_noun kev) u3_weak con = u3h_get(u3R->byc.har_p, lof); _n_prog* pog_u = u3to(_n_prog, got); - if ( u3_none != con ) { - _n_prog* sep_u = u3to(_n_prog, con); - _n_prog_take_dat(sep_u, pog_u, c3y); + if ( u3_none == con ) { + u3h_put(u3R->byc.har_p, lof, u3a_outa(_n_prog_take(pog_u))); } else { - u3h_put(u3R->byc.har_p, lof, u3a_outa(_n_prog_take(pog_u))); + _n_prog* sep_u = u3to(_n_prog, con); + _n_prog_take_dat(sep_u, pog_u, c3y); } u3z(lof); } @@ -2333,10 +2496,13 @@ _n_prog_mark(_n_prog* pog_u) tot_w += u3a_mark_noun(pog_u->cal_u.sit_u[i_w].axe); } - /* nothing to do yet for registration sites for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { + _n_rite* rit_u = &(pog_u->reg_u.rit_u[i_w]); + if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { + tot_w += u3a_mark_noun(rit_u->clu); + tot_w += _n_fink_mark(rit_u->fin_u); + } } - */ return tot_w; } From bb76625c4e2d899b3040ad18988c739269b6c8b8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 16 Apr 2018 16:54:20 -0700 Subject: [PATCH 065/221] keeping batteries for no reason --- noun/nock.c | 247 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 183 insertions(+), 64 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index ac8811712..6d99eb658 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -538,9 +538,13 @@ typedef struct { _n_fist fis_u[0]; } _n_fink; +struct __n_prog; + /* placeholder: call site memory */ typedef struct { u3_noun axe; + struct __n_prog *pog_u; + u3_noun bat; } _n_site; /* registration site memory */ @@ -581,7 +585,7 @@ typedef struct { _n_rite* rit_u; } _n_prog_reg; -typedef struct { +typedef struct __n_prog { _n_prog_ops byc_u; _n_prog_lit lit_u; _n_prog_memo mem_u; @@ -1068,7 +1072,9 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) case TICB: case KICB: { _n_prog_asm_inx(buf_y, &i_w, cal_s, cod); _n_site* sit_u = &(pog_u->cal_u.sit_u[cal_s++]); - sit_u->axe = u3k(u3t(op)); + sit_u->axe = u3k(u3t(op)); + sit_u->pog_u = NULL; + sit_u->bat = u3_none; break; } } @@ -1099,7 +1105,7 @@ _n_prog_from_ops(u3_noun ops) return pog_u; } -#if 1 +#if 0 /* _n_print_stack(): print out the cap stack up to a designated "empty" * used only for debugging */ @@ -1127,7 +1133,7 @@ static void _n_print_stack(u3p(u3_noun) empty) { } #endif -#if 1 +#ifdef VERBOSE_BYTECODE // match to OPCODE TABLE static char* opcode_names[] = { "halt", "bail", @@ -1541,7 +1547,7 @@ _n_rewo(c3_y* buf, c3_w* ip_w) return one | (two << 8) | (tre << 16) | (qua << 24); } -#if 1 +#ifdef VERBOSE_BYTECODE /* _n_print_byc(): print bytecode. used for debugging. */ static void @@ -1623,6 +1629,11 @@ _n_find(u3_noun fol) _n_rite* rit_u = &(old->reg_u.rit_u[i_w]); rit_u->own_o = c3n; } + for ( i_w = 0; i_w < old->cal_u.len_w; ++i_w ) { + _n_site* sit_u = &(old->cal_u.sit_u[i_w]); + sit_u->bat = u3_none; + sit_u->pog_u = NULL; + } u3h_put(u3R->byc.har_p, fol, u3a_outa(old)); return old; } @@ -1636,6 +1647,29 @@ _n_find(u3_noun fol) } } +static u3_weak +_n_kick(u3_noun cor, _n_site* sit_u) +{ + u3_weak pro; + u3t_off(noc_o); + pro = u3j_kick(cor, sit_u->axe); + u3t_on(noc_o); + if ( u3_none == pro ) { + /* + if ( (u3_none != sit_u->bat) && + (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { + return u3_none; + } + */ + sit_u->pog_u = _n_find(u3r_at(sit_u->axe, cor)); + if ( u3_none != sit_u->bat ) { + u3z(sit_u->bat); + } + sit_u->bat = u3k(u3h(cor)); + } + return pro; +} + /* _n_swap(): swap two items on the top of the stack, return pointer to top */ static inline u3_noun* @@ -2078,12 +2112,8 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) sit_u = &(pog_u->cal_u.sit_u[x]); top = _n_peek(off); o = *top; - x = sit_u->axe; - u3t_off(noc_o); - *top = u3j_kick(o, x); - u3t_on(noc_o); + *top = _n_kick(o, sit_u); if ( u3_none == *top ) { - u3_noun fol = u3x_at(x, o); _n_toss(mov, off); fam = u3to(burnframe, u3R->cap_p) + off + mov; @@ -2091,14 +2121,14 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) fam->ip_w = ip_w; fam->pog_u = pog_u; - pog_u = _n_find(fol); + pog_u = sit_u->pog_u; pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif #ifdef VERBOSE_BYTECODE - fprintf(stderr, "\r\nhead kick jump: %u, sp: %p\r\n", fol, top); + fprintf(stderr, "\r\nhead kick jump: %u, sp: %p\r\n", u3r_at(sit_u->axe, cor), top); _n_print_byc(pog, ip_w); #endif _n_push(mov, off, o); @@ -2120,21 +2150,17 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) sit_u = &(pog_u->cal_u.sit_u[x]); top = _n_peek(off); o = *top; - x = sit_u->axe; - u3t_off(noc_o); - *top = u3j_kick(o, x); - u3t_on(noc_o); + *top = _n_kick(o, sit_u); if ( u3_none == *top ) { - u3_noun fol = u3x_at(x, o); *top = o; - pog_u = _n_find(fol); + pog_u = sit_u->pog_u; pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG u3R->pro.nox_d += 1; #endif #ifdef VERBOSE_BYTECODE - fprintf(stderr, "\r\ntail kick jump: %u, sp: %p\r\n", fol, top); + fprintf(stderr, "\r\ntail kick jump: %u, sp: %p\r\n", u3x_at(sit_u->axe, o);, top); _n_print_byc(pog, ip_w); #endif } @@ -2335,6 +2361,68 @@ u3n_nock_on(u3_noun bus, u3_noun fol) return pro; } +static void +_n_site_take(_n_site* dst_u, _n_site* src_u, c3_o los_o) +{ + u3_noun old = dst_u->axe; + u3_noun bot = dst_u->bat; + dst_u->axe = u3a_take(src_u->axe); + + if ( c3n == los_o ) { + if ( u3_none == src_u->bat ) { + dst_u->bat = u3_none; + } + else { + dst_u->bat = u3a_take(src_u->bat); + dst_u->pog_u = src_u->pog_u; + } + } + else { + u3z(old); + if ( u3_none != bot ) { + u3z(bot); + dst_u->bat = u3_none; + } + /* + if ( u3_none != src_u->bat ) { + if ( (u3_none == bot) || + (c3n == u3r_sing(bot, src_u->bat)) ) { + dst_u->bat = u3a_take(src_u->bat); + dst_u->pog_u = src_u->pog_u; + if ( u3_none != bot ) { + u3z(bot); + } + } + } + */ + } +} + +static void +_n_rite_take(_n_rite* dst_u, _n_rite* src_u, c3_o los_o) +{ + if ( u3_none == src_u->clu ) { + dst_u->clu = u3_none; + dst_u->fin_u = NULL; + } + else { + u3_noun old = dst_u->clu; + _n_fink* fon_u = dst_u->fin_u; + c3_o own_o = dst_u->own_o; + if ( c3y == src_u->own_o ) { + dst_u->own_o = c3y; + dst_u->clu = u3a_take(src_u->clu); + dst_u->fin_u = _n_fink_take(src_u->fin_u); + if ( (c3y == los_o) && + (u3_none != old) && + (c3y == own_o) ) { + u3z(old); + _n_fink_free(fon_u); + } + } + } +} + static void _n_prog_take_dat(_n_prog* dst_u, _n_prog* src_u, c3_o los_o) { @@ -2361,39 +2449,13 @@ _n_prog_take_dat(_n_prog* dst_u, _n_prog* src_u, c3_o los_o) } for ( i_w = 0; i_w < src_u->cal_u.len_w; ++i_w ) { - _n_site* dst = &(dst_u->cal_u.sit_u[i_w]); - _n_site* src = &(src_u->cal_u.sit_u[i_w]); - u3_noun old = dst->axe; - dst->axe = u3a_take(src->axe); - if ( c3y == los_o ) { - u3z(old); - } + _n_site_take(&(dst_u->cal_u.sit_u[i_w]), + &(src_u->cal_u.sit_u[i_w]), los_o); } for ( i_w = 0; i_w < src_u->reg_u.len_w; ++i_w ) { - _n_rite* dst = &(dst_u->reg_u.rit_u[i_w]); - _n_rite* src = &(src_u->reg_u.rit_u[i_w]); - - if ( u3_none == src->clu ) { - dst->clu = u3_none; - dst->fin_u = NULL; - } - else { - u3_noun old = dst->clu; - _n_fink* fon_u = dst->fin_u; - c3_o own_o = dst->own_o; - if ( c3y == src->own_o ) { - dst->own_o = c3y; - dst->clu = u3a_take(src->clu); - dst->fin_u = _n_fink_take(src->fin_u); - if ( (c3y == los_o) && - (u3_none != old) && - (c3y == own_o) ) { - u3z(old); - _n_fink_free(fon_u); - } - } - } + _n_rite_take(&(dst_u->reg_u.rit_u[i_w]), + &(src_u->reg_u.rit_u[i_w]), los_o); } } @@ -2418,6 +2480,24 @@ _n_prog_take(_n_prog* pog_u) return gop_u; } +static void +_n_site_free(_n_site* sit_u) +{ + u3z(sit_u->axe); + if ( u3_none != sit_u->bat ) { + u3z(sit_u->bat); + } +} + +static void +_n_rite_free(_n_rite* rit_u) +{ + if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { + u3z(rit_u->clu); + _n_fink_free(rit_u->fin_u); + } +} + /* _n_prog_free(): free memory retained by program */ static void @@ -2434,15 +2514,11 @@ _n_prog_free(_n_prog* pog_u) } for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - u3z(pog_u->cal_u.sit_u[i_w].axe); + _n_site_free(&(pog_u->cal_u.sit_u[i_w])); } for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { - _n_rite* rit_u = &(pog_u->reg_u.rit_u[i_w]); - if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { - u3z(rit_u->clu); - _n_fink_free(rit_u->fin_u); - } + _n_rite_free(&(pog_u->reg_u.rit_u[i_w])); } u3a_free(pog_u); @@ -2451,22 +2527,45 @@ _n_prog_free(_n_prog* pog_u) /* _n_reap(): reap key and value from byc table. */ static void -_n_reap(u3_noun kev) +_n_reap(u3_noun kev, void* dat) { + u3p(u3h_root) mov_p = *((u3p(u3h_root)*) dat); u3_noun fol = u3h(kev); u3_noun got = u3t(kev); u3_noun lof = u3a_take(fol); + u3_noun tog; u3_weak con = u3h_get(u3R->byc.har_p, lof); _n_prog* pog_u = u3to(_n_prog, got); if ( u3_none == con ) { - u3h_put(u3R->byc.har_p, lof, u3a_outa(_n_prog_take(pog_u))); + tog = u3a_outa(_n_prog_take(pog_u)); + u3h_put(u3R->byc.har_p, lof, tog); } else { _n_prog* sep_u = u3to(_n_prog, con); _n_prog_take_dat(sep_u, pog_u, c3y); + tog = u3a_outa(sep_u); } u3z(lof); + u3h_put(mov_p, got, tog); +} + +static void +_n_move(u3_noun kev, void* dat) +{ + u3p(u3h_root) mov_p = *((u3p(u3h_root)*) dat); + _n_prog* pog_u = u3to(_n_prog, u3t(kev)); + c3_w i_w; + + for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { + _n_site* sit_u = &(pog_u->cal_u.sit_u[i_w]); + if ( u3_none != sit_u->bat ) { + u3_weak got = u3h_git(mov_p, u3a_outa(sit_u->pog_u)); + if ( u3_none != got ) { + sit_u->pog_u = u3to(_n_prog, got); + } + } + } } /* u3n_beep(): promote bytecode state. @@ -2474,7 +2573,31 @@ _n_reap(u3_noun kev) void u3n_beep(u3p(u3h_root) har_p) { - u3h_walk(har_p, _n_reap); + u3p(u3h_root) mov_p = u3h_new(); + u3h_walk_with(har_p, _n_reap, &mov_p); + u3h_walk_with(har_p, _n_move, &mov_p); + u3h_free(mov_p); +} + +static c3_w +_n_site_mark(_n_site* sit_u) +{ + c3_w tot_w = u3a_mark_noun(sit_u->axe); + if ( u3_none != sit_u->bat ) { + tot_w += u3a_mark_noun(sit_u->bat); + } + return tot_w; +} + +static c3_w +_n_rite_mark(_n_rite* rit_u) +{ + c3_w tot_w = 0; + if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { + tot_w += u3a_mark_noun(rit_u->clu); + tot_w += _n_fink_mark(rit_u->fin_u); + } + return tot_w; } /* _n_prog_mark(): mark program for gc. @@ -2493,15 +2616,11 @@ _n_prog_mark(_n_prog* pog_u) } for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - tot_w += u3a_mark_noun(pog_u->cal_u.sit_u[i_w].axe); + tot_w += _n_site_mark(&(pog_u->cal_u.sit_u[i_w])); } for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { - _n_rite* rit_u = &(pog_u->reg_u.rit_u[i_w]); - if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { - tot_w += u3a_mark_noun(rit_u->clu); - tot_w += _n_fink_mark(rit_u->fin_u); - } + tot_w += _n_rite_mark(&(pog_u->reg_u.rit_u[i_w])); } return tot_w; From 7333250eeb01bba661f4a938075749c017fce5ae Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 16 Apr 2018 17:27:32 -0700 Subject: [PATCH 066/221] no inter-road call site communication, bat/pog caching working! --- noun/nock.c | 59 ++++++----------------------------------------------- 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 6d99eb658..2e5b02f98 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1655,12 +1655,10 @@ _n_kick(u3_noun cor, _n_site* sit_u) pro = u3j_kick(cor, sit_u->axe); u3t_on(noc_o); if ( u3_none == pro ) { - /* if ( (u3_none != sit_u->bat) && (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { return u3_none; } - */ sit_u->pog_u = _n_find(u3r_at(sit_u->axe, cor)); if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); @@ -2365,36 +2363,14 @@ static void _n_site_take(_n_site* dst_u, _n_site* src_u, c3_o los_o) { u3_noun old = dst_u->axe; - u3_noun bot = dst_u->bat; dst_u->axe = u3a_take(src_u->axe); - if ( c3n == los_o ) { - if ( u3_none == src_u->bat ) { - dst_u->bat = u3_none; - } - else { - dst_u->bat = u3a_take(src_u->bat); - dst_u->pog_u = src_u->pog_u; - } + if ( c3y == los_o ) { + u3z(old); } else { - u3z(old); - if ( u3_none != bot ) { - u3z(bot); - dst_u->bat = u3_none; - } - /* - if ( u3_none != src_u->bat ) { - if ( (u3_none == bot) || - (c3n == u3r_sing(bot, src_u->bat)) ) { - dst_u->bat = u3a_take(src_u->bat); - dst_u->pog_u = src_u->pog_u; - if ( u3_none != bot ) { - u3z(bot); - } - } - } - */ + dst_u->bat = u3_none; + dst_u->pog_u = NULL; } } @@ -2527,9 +2503,8 @@ _n_prog_free(_n_prog* pog_u) /* _n_reap(): reap key and value from byc table. */ static void -_n_reap(u3_noun kev, void* dat) +_n_reap(u3_noun kev) { - u3p(u3h_root) mov_p = *((u3p(u3h_root)*) dat); u3_noun fol = u3h(kev); u3_noun got = u3t(kev); u3_noun lof = u3a_take(fol); @@ -2547,25 +2522,6 @@ _n_reap(u3_noun kev, void* dat) tog = u3a_outa(sep_u); } u3z(lof); - u3h_put(mov_p, got, tog); -} - -static void -_n_move(u3_noun kev, void* dat) -{ - u3p(u3h_root) mov_p = *((u3p(u3h_root)*) dat); - _n_prog* pog_u = u3to(_n_prog, u3t(kev)); - c3_w i_w; - - for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - _n_site* sit_u = &(pog_u->cal_u.sit_u[i_w]); - if ( u3_none != sit_u->bat ) { - u3_weak got = u3h_git(mov_p, u3a_outa(sit_u->pog_u)); - if ( u3_none != got ) { - sit_u->pog_u = u3to(_n_prog, got); - } - } - } } /* u3n_beep(): promote bytecode state. @@ -2573,10 +2529,7 @@ _n_move(u3_noun kev, void* dat) void u3n_beep(u3p(u3h_root) har_p) { - u3p(u3h_root) mov_p = u3h_new(); - u3h_walk_with(har_p, _n_reap, &mov_p); - u3h_walk_with(har_p, _n_move, &mov_p); - u3h_free(mov_p); + u3h_walk(har_p, _n_reap); } static c3_w From 50f3c9ef6310fb7f0efaf8e8b32c0c389aa87fed Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 17 Apr 2018 13:47:52 -0700 Subject: [PATCH 067/221] holding onto locations and finks at call sites without leaks --- include/noun/jets.h | 19 ++++ noun/jets.c | 55 ++++++++++++ noun/nock.c | 211 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 262 insertions(+), 23 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 6463707e0..1a3bb5533 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -103,6 +103,25 @@ u3_weak u3j_spot(u3_noun cor); + /* u3j_nail(): resolve hot state for location and axis. RETAIN. + ** return value indicates presence of driver. + **/ + c3_o + u3j_nail(u3_noun loc, u3_noun axe, + u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u); + + /* u3j_kick_hot(): Try to kick by jet with resolved hot state. + ** If no kick, produce u3_none. + ** + ** `cor` is RETAINED iff there is no kick, TRANSFERRED if one. + ** `axe` is RETAINED. + */ + u3_weak + u3j_hock(u3_noun cor, + u3j_core* cop_u, + u3j_harm* ham_u, + u3_atom axe); + /* u3j_kick(): try to kick by jet. If no kick, produce u3_none. ** ** `axe` is RETAINED by the caller; `cor` is RETAINED iff there diff --git a/noun/jets.c b/noun/jets.c index c2f959f3c..a93a92d05 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -271,6 +271,45 @@ u3j_spot(u3_noun cor) } } +/* u3j_nail(): resolve hot state for location and axis. RETAIN. +** return value indicates presence of driver. +**/ +c3_o +u3j_nail(u3_noun loc, u3_noun axe, + u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u) +{ + c3_o ret_o; + u3_noun jax, hap, bal, jit; + u3_weak act; + + u3t_on(glu_o); + act = _cj_find_warm(loc); + c3_assert(u3_none != act); + u3x_qual(act, &jax, &hap, &bal, &jit); + + *lab = u3k(bal); + if ( 0 == jax ) { + ret_o = c3n; + } + else { + u3_weak inx = u3kdb_get(u3k(hap), u3k(axe)); + if ( u3_none == inx ) { + ret_o = c3n; + } + else { + c3_l jax_l = jax, + inx_l = inx; + *cop_u = &(u3D.ray_u[jax_l]); + *ham_u = &((*cop_u)->arm_u[inx_l]); + ret_o = c3y; + } + } + + u3z(act); + u3t_off(glu_o); + return ret_o; +} + /* _cj_scan(): has this core been registered? */ static c3_o @@ -485,6 +524,22 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) } } +/* u3j_hock(): Try to kick by jet with resolved hot state. +** If no kick, produce u3_none. +** +** `cor` is RETAINED iff there is no kick, TRANSFERRED if one. +** `axe` is RETAINED. +*/ +u3_weak +u3j_hock(u3_noun cor, + u3j_core* cop_u, + u3j_harm* ham_u, + u3_atom axe) +{ + // this is where you would trace, if we traced this + return _cj_kick_z(cor, cop_u, ham_u, axe); +} + /* _cj_hook_in(): execute hook from core, or fail. */ static u3_noun diff --git a/noun/nock.c b/noun/nock.c index 2e5b02f98..14cc8e860 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -542,9 +542,16 @@ struct __n_prog; /* placeholder: call site memory */ typedef struct { - u3_noun axe; struct __n_prog *pog_u; - u3_noun bat; + u3_noun axe; + u3_weak bat; + u3_weak loc; + c3_o jet_o; + c3_o fon_o; + u3_weak lab; + u3j_core* cop_u; + u3j_harm* ham_u; + _n_fink* fin_u; } _n_site; /* registration site memory */ @@ -1075,6 +1082,13 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) sit_u->axe = u3k(u3t(op)); sit_u->pog_u = NULL; sit_u->bat = u3_none; + sit_u->loc = u3_none; + sit_u->lab = u3_none; + sit_u->jet_o = c3n; + sit_u->fon_o = c3n; + sit_u->cop_u = NULL; + sit_u->ham_u = NULL; + sit_u->fin_u = NULL; break; } } @@ -1633,6 +1647,7 @@ _n_find(u3_noun fol) _n_site* sit_u = &(old->cal_u.sit_u[i_w]); sit_u->bat = u3_none; sit_u->pog_u = NULL; + sit_u->fon_o = c3n; } u3h_put(u3R->byc.har_p, fol, u3a_outa(old)); return old; @@ -1648,22 +1663,111 @@ _n_find(u3_noun fol) } static u3_weak -_n_kick(u3_noun cor, _n_site* sit_u) +_n_spot(u3_noun cor) +{ + u3_weak loc; + u3t_off(noc_o); + loc = u3j_spot(cor); + u3t_on(noc_o); + return loc; +} + +static u3_weak +_n_lock(u3_noun cor, _n_site* sit_u) +{ + if ( (u3_none != sit_u->bat) && + (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { + return u3_none; + } + sit_u->pog_u = _n_find(u3r_at(sit_u->axe, cor)); + if ( u3_none != sit_u->bat ) { + u3z(sit_u->bat); + } + sit_u->bat = u3k(u3h(cor)); + return u3_none; +} + +static u3_noun _n_burn_out(u3_noun bus, _n_prog* pog_u); + +static u3_weak +_n_hock(u3_noun cor, _n_site* sit_u) { u3_weak pro; - u3t_off(noc_o); - pro = u3j_kick(cor, sit_u->axe); - u3t_on(noc_o); + c3_o jet_o = sit_u->jet_o; + if ( c3n == __(u3C.wag_w & u3o_debug_cpu) ) { + if ( c3n == jet_o ) { + pro = u3_none; + } + else { + u3t_off(noc_o); + pro = u3j_hock(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); + u3t_on(noc_o); + } + if ( u3_none == pro ) { + pro = _n_lock(cor, sit_u); + } + } + else { + u3t_come(sit_u->lab); + if ( c3y == jet_o ) { + u3t_off(noc_o); + pro = u3j_hock(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); + u3t_on(noc_o); + } + if ( u3_none == pro ) { + pro = _n_lock(cor, sit_u); + if ( u3_none == pro ) { + pro = _n_burn_out(cor, sit_u->pog_u); + } + } + u3t_flee(); + } + return pro; +} + +static u3_weak +_n_kick(u3_noun cor, _n_site* sit_u) +{ + u3_weak loc, pro = u3_none; + + loc = _n_spot(cor); + if ( u3_none != loc ) { + _n_fink* fon_u = NULL; + u3_weak lod = u3_none; + u3_weak lob = u3_none; + + if ( u3_none != sit_u->loc ) { + lod = sit_u->loc; + lob = sit_u->lab; + if ( c3y == sit_u->fon_o ) { + fon_u = sit_u->fin_u; + } + } + + sit_u->loc = loc; + sit_u->fin_u = _n_cast(cor, loc); + sit_u->fon_o = c3y; + if ( c3y == + (sit_u->jet_o = u3j_nail(loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) + { + pro = _n_hock(cor, sit_u); + } + else { + pro = u3_none; + } + + if ( u3_none != lod ) { + u3z(lod); + u3z(lob); + if ( NULL != fon_u ) { + _n_fink_free(fon_u); + } + } + } + if ( u3_none == pro ) { - if ( (u3_none != sit_u->bat) && - (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { - return u3_none; - } - sit_u->pog_u = _n_find(u3r_at(sit_u->axe, cor)); - if ( u3_none != sit_u->bat ) { - u3z(sit_u->bat); - } - sit_u->bat = u3k(u3h(cor)); + pro = _n_lock(cor, sit_u); } return pro; } @@ -2320,15 +2424,10 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) } } -/* _n_burn_on(): produce .*(bus fol) with bytecode interpreter - */ static u3_noun -_n_burn_on(u3_noun bus, u3_noun fol) +_n_burn_out(u3_noun bus, _n_prog* pog_u) { c3_ys mov, off; - _n_prog* pog_u = _n_find(fol); - - u3z(fol); if ( c3y == u3a_is_north(u3R) ) { mov = -1; off = 0; @@ -2337,8 +2436,18 @@ _n_burn_on(u3_noun bus, u3_noun fol) mov = 1; off = -1; } - u3_noun pro = _n_burn(pog_u, bus, mov, off); - return pro; + return _n_burn(pog_u, bus, mov, off); +} + +/* _n_burn_on(): produce .*(bus fol) with bytecode interpreter + */ +static u3_noun +_n_burn_on(u3_noun bus, u3_noun fol) +{ + _n_prog* pog_u = _n_find(fol); + + u3z(fol); + return _n_burn_out(bus, pog_u); } /* u3n_nock_on(): produce .*(bus fol). Do not virtualize. @@ -2371,6 +2480,48 @@ _n_site_take(_n_site* dst_u, _n_site* src_u, c3_o los_o) else { dst_u->bat = u3_none; dst_u->pog_u = NULL; + dst_u->loc = u3_none; + dst_u->lab = u3_none; + dst_u->jet_o = c3n; + dst_u->fon_o = c3n; + dst_u->cop_u = NULL; + dst_u->ham_u = NULL; + dst_u->fin_u = NULL; + } + + if ( u3_none != src_u->loc ) { + u3_noun lob = dst_u->lab, + lod = dst_u->loc; + c3_o fon_o = dst_u->fon_o; + _n_fink* fon_u = dst_u->fin_u; + + dst_u->loc = u3a_take(src_u->loc); + dst_u->lab = u3a_take(src_u->lab); + dst_u->cop_u = src_u->cop_u; + dst_u->ham_u = src_u->ham_u; + dst_u->jet_o = src_u->jet_o; + + if ( c3y == src_u->fon_o ) { + dst_u->fin_u = _n_fink_take(src_u->fin_u); + dst_u->fon_o = c3y; + } + else if ( fon_u != src_u->fin_u ) { + dst_u->fin_u = src_u->fin_u; + dst_u->fon_o = c3n; + } + else { + fon_o = c3n; + } + + if ( c3y == los_o ) { + if ( u3_none != lod ) { + u3z(lod); + u3z(lob); + if ( c3y == fon_o ) { + _n_fink_free(fon_u); + } + } + } } } @@ -2463,6 +2614,13 @@ _n_site_free(_n_site* sit_u) if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); } + if ( u3_none != sit_u->loc ) { + u3z(sit_u->loc); + u3z(sit_u->lab); + if ( c3y == sit_u->fon_o ) { + _n_fink_free(sit_u->fin_u); + } + } } static void @@ -2539,6 +2697,13 @@ _n_site_mark(_n_site* sit_u) if ( u3_none != sit_u->bat ) { tot_w += u3a_mark_noun(sit_u->bat); } + if ( u3_none != sit_u->loc ) { + tot_w += u3a_mark_noun(sit_u->loc); + tot_w += u3a_mark_noun(sit_u->lab); + if ( c3y == sit_u->fon_o ) { + tot_w += _n_fink_mark(sit_u->fin_u); + } + } return tot_w; } From 033b2c172128d8d24e4d133758a122b8a50e836f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 17 Apr 2018 14:57:59 -0700 Subject: [PATCH 068/221] using cached locations to speed up kicks --- noun/nock.c | 71 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 14cc8e860..b80d6fe33 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1728,40 +1728,52 @@ _n_hock(u3_noun cor, _n_site* sit_u) static u3_weak _n_kick(u3_noun cor, _n_site* sit_u) { - u3_weak loc, pro = u3_none; + u3_weak loc = u3_none, + pro = u3_none; - loc = _n_spot(cor); - if ( u3_none != loc ) { - _n_fink* fon_u = NULL; - u3_weak lod = u3_none; - u3_weak lob = u3_none; - - if ( u3_none != sit_u->loc ) { - lod = sit_u->loc; - lob = sit_u->lab; - if ( c3y == sit_u->fon_o ) { - fon_u = sit_u->fin_u; + if ( u3_none != sit_u->loc ) { + if ( c3y == _n_fine(cor, sit_u->fin_u) ) { + loc = sit_u->loc; + if ( c3y == sit_u->jet_o ) { + pro = _n_hock(cor, sit_u); } } + } - sit_u->loc = loc; - sit_u->fin_u = _n_cast(cor, loc); - sit_u->fon_o = c3y; - if ( c3y == - (sit_u->jet_o = u3j_nail(loc, sit_u->axe, - &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) - { - pro = _n_hock(cor, sit_u); - } - else { - pro = u3_none; - } + if ( u3_none == loc ) { + loc = _n_spot(cor); + if ( u3_none != loc ) { + _n_fink* fon_u = NULL; + u3_weak lod = u3_none; + u3_weak lob = u3_none; - if ( u3_none != lod ) { - u3z(lod); - u3z(lob); - if ( NULL != fon_u ) { - _n_fink_free(fon_u); + if ( u3_none != sit_u->loc ) { + lod = sit_u->loc; + lob = sit_u->lab; + if ( c3y == sit_u->fon_o ) { + fon_u = sit_u->fin_u; + } + } + + sit_u->loc = loc; + sit_u->fin_u = _n_cast(cor, loc); + sit_u->fon_o = c3y; + if ( c3y == + (sit_u->jet_o = u3j_nail(loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) + { + pro = _n_hock(cor, sit_u); + } + else { + pro = u3_none; + } + + if ( u3_none != lod ) { + u3z(lod); + u3z(lob); + if ( NULL != fon_u ) { + _n_fink_free(fon_u); + } } } } @@ -1769,6 +1781,7 @@ _n_kick(u3_noun cor, _n_site* sit_u) if ( u3_none == pro ) { pro = _n_lock(cor, sit_u); } + return pro; } From a5e79c2820f323982b7c0991391bebe9f66ac130 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 18 Apr 2018 12:19:56 -0700 Subject: [PATCH 069/221] ream callsites at boot --- include/noun/nock.h | 14 +++++++++++--- noun/manage.c | 1 + noun/nock.c | 25 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index e978528f3..9a0b44057 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -56,12 +56,20 @@ /* u3n_beep(): promote bytecode state. */ - void u3n_beep(u3p(u3h_root) har_p); + void + u3n_beep(u3p(u3h_root) har_p); /* u3n_bark(): mark bytecode cache. */ - c3_w u3n_bark(); + c3_w + u3n_bark(void); /* u3n_bree(): free bytecode cache. */ - void u3n_bree(); + void + u3n_bree(void); + + /* u3n_ream(): refresh after restoring from checkpoint. + */ + void + u3n_ream(void); diff --git a/noun/manage.c b/noun/manage.c index 319482cb6..29e2f69c6 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -1690,5 +1690,6 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, else { u3v_hose(); u3j_ream(); + u3n_ream(); } } diff --git a/noun/nock.c b/noun/nock.c index b80d6fe33..115e226f0 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -2703,6 +2703,31 @@ u3n_beep(u3p(u3h_root) har_p) u3h_walk(har_p, _n_reap); } +void +_n_ream(u3_noun kev) +{ + c3_w i_w; + _n_prog* pog_u = u3to(_n_prog, u3t(kev)); + for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { + _n_site* sit_u = &(pog_u->cal_u.sit_u[i_w]); + if ( u3_none != sit_u->loc ) { + fprintf(stderr, "."); + u3z(sit_u->lab); + sit_u->jet_o = u3j_nail(sit_u->loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); + } + } +} + +/* u3n_ream(): refresh after restoring from checkpoint. +*/ +void +u3n_ream() +{ + c3_assert(u3R == &(u3H->rod_u)); + u3h_walk(u3R->byc.har_p, _n_ream); +} + static c3_w _n_site_mark(_n_site* sit_u) { From 0e45d64cefe49661caf14a0228f9362556a8f404 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 18 Apr 2018 12:22:50 -0700 Subject: [PATCH 070/221] minor things like initializing variables and stuff --- noun/nock.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 115e226f0..2c3bdc287 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1692,8 +1692,8 @@ static u3_noun _n_burn_out(u3_noun bus, _n_prog* pog_u); static u3_weak _n_hock(u3_noun cor, _n_site* sit_u) { - u3_weak pro; - c3_o jet_o = sit_u->jet_o; + u3_weak pro = u3_none; + c3_o jet_o = sit_u->jet_o; if ( c3n == __(u3C.wag_w & u3o_debug_cpu) ) { if ( c3n == jet_o ) { pro = u3_none; @@ -2711,7 +2711,6 @@ _n_ream(u3_noun kev) for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { _n_site* sit_u = &(pog_u->cal_u.sit_u[i_w]); if ( u3_none != sit_u->loc ) { - fprintf(stderr, "."); u3z(sit_u->lab); sit_u->jet_o = u3j_nail(sit_u->loc, sit_u->axe, &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); From 4da79539ec2498c8011afe63cf54bcbf5c2ea6f2 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 11:08:34 -0700 Subject: [PATCH 071/221] move internal _n data structures to headers --- include/noun/jets.h | 36 ++++++ include/noun/nock.h | 33 ++++++ noun/jets.c | 28 +++++ noun/nock.c | 259 +++++++++++++++----------------------------- 4 files changed, 182 insertions(+), 174 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 1a3bb5533..9b6d1f6d3 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -61,6 +61,37 @@ u3j_core* ray_u; // dynamic array by axis } u3j_dash; + typedef struct { + u3_noun bat; + u3_noun pax; + } u3j_fist; + + typedef struct { + c3_w len_w; + u3_noun sat; + u3j_fist fis_u[0]; + } u3j_fink; + + typedef struct { + c3_o own_o; + u3_weak clu; + u3j_fink* fin_u; + } u3j_rite; + + struct _u3n_prog; + typedef struct { + struct _u3n_prog *pog_u; + u3_noun axe; + u3_weak bat; + u3_weak loc; + c3_o jet_o; + c3_o fon_o; + u3_weak lab; + u3j_core* cop_u; + u3j_harm* ham_u; + u3j_fink* fin_u; + } u3j_site; + /** Globals. **/ /* u3_Dash: jet dashboard. @@ -103,6 +134,11 @@ u3_weak u3j_spot(u3_noun cor); + /* u3j_fine(): check core against u3j_fink. + */ + c3_o + u3j_fine(u3_noun cor, u3j_fink* fin_u); + /* u3j_nail(): resolve hot state for location and axis. RETAIN. ** return value indicates presence of driver. **/ diff --git a/include/noun/nock.h b/include/noun/nock.h index 9a0b44057..5c7736062 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -2,6 +2,39 @@ ** ** This file is in the public domain. */ + /** Data structures. + *** + **/ + + typedef struct { + c3_l sip_l; + u3_noun key; + } u3n_memo; + + typedef struct _u3n_prog { + struct { + c3_o own_o; + c3_w len_w; + c3_y* ops_y; + } byc_u; + struct { + c3_w len_w; + u3_noun* non; + } lit_u; + struct { + c3_w len_w; + u3n_memo* sot_u; + } mem_u; + struct { + c3_w len_w; + u3j_site* sit_u; + } cal_u; + struct { + c3_w len_w; + u3j_rite* rit_u; + } reg_u; + } u3n_prog; + /** Functions. **/ /* u3n_nock_on(): produce .*(bus fol). diff --git a/noun/jets.c b/noun/jets.c index a93a92d05..ace1b904a 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -271,6 +271,34 @@ u3j_spot(u3_noun cor) } } +static c3_o +_cj_fine(u3_noun cor, u3j_fink* fin_u) +{ + c3_w i_w; + for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + if ( c3n == u3r_sing(fis_u->bat, u3h(cor)) ) { + return c3n; + } + else { + cor = u3r_at(fis_u->pax, cor); + } + } + return u3r_sing(fin_u->sat, cor); +} + +/* u3j_fine(): check core against u3j_fink. + */ +c3_o +u3j_fine(u3_noun cor, u3j_fink* fin_u) +{ + c3_o ret_o; + u3t_on(glu_o); + ret_o = _cj_fine(cor, fin_u); + u3t_off(glu_o); + return ret_o; +} + /* u3j_nail(): resolve hot state for location and axis. RETAIN. ** return value indicates presence of driver. **/ diff --git a/noun/nock.c b/noun/nock.c index 2c3bdc287..54c9c02de 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -527,103 +527,14 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIS 71 #define SAVE 72 -typedef struct { - u3_noun bat; - u3_noun pax; -} _n_fist; - -typedef struct { - c3_w len_w; - u3_noun sat; - _n_fist fis_u[0]; -} _n_fink; - -struct __n_prog; - -/* placeholder: call site memory */ -typedef struct { - struct __n_prog *pog_u; - u3_noun axe; - u3_weak bat; - u3_weak loc; - c3_o jet_o; - c3_o fon_o; - u3_weak lab; - u3j_core* cop_u; - u3j_harm* ham_u; - _n_fink* fin_u; -} _n_site; - -/* registration site memory */ -typedef struct { - c3_o own_o; - u3_weak clu; - _n_fink* fin_u; -} _n_rite; - -typedef struct { - c3_l sip_l; - u3_noun key; -} _n_memo; - -typedef struct { - c3_w len_w; - _n_memo* sot_u; -} _n_prog_memo; - -typedef struct { - c3_w len_w; - u3_noun* non; -} _n_prog_lit; - -typedef struct { - c3_o own_o; - c3_w len_w; - c3_y* ops_y; -} _n_prog_ops; - -typedef struct { - c3_w len_w; - _n_site* sit_u; -} _n_prog_call; - -typedef struct { - c3_w len_w; - _n_rite* rit_u; -} _n_prog_reg; - -typedef struct __n_prog { - _n_prog_ops byc_u; - _n_prog_lit lit_u; - _n_prog_memo mem_u; - _n_prog_call cal_u; - _n_prog_reg reg_u; -} _n_prog; - -static c3_o -_n_fine(u3_noun cor, _n_fink* fin_u) -{ - c3_w i_w; - for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { - _n_fist* fis_u = &(fin_u->fis_u[i_w]); - if ( c3n == u3r_sing(fis_u->bat, u3h(cor)) ) { - return c3n; - } - else { - cor = u3r_at(fis_u->pax, cor); - } - } - return u3r_sing(fin_u->sat, cor); -} - -static _n_fink* +static u3j_fink* _n_cast(u3_noun cor, u3_noun loc) { c3_w i_w = 0; u3_noun j, par, bat, dyn, pax, rev = u3_nul, pat = u3h(loc); - _n_fink* fin_u; + u3j_fink* fin_u; while ( c3n == u3h(pat) ) { bat = u3h(cor); @@ -636,12 +547,12 @@ _n_cast(u3_noun cor, u3_noun loc) ++i_w; } - fin_u = u3a_walloc(c3_wiseof(_n_fink) + - (i_w * c3_wiseof(_n_fist))); + fin_u = u3a_walloc(c3_wiseof(u3j_fink) + + (i_w * c3_wiseof(u3j_fist))); fin_u->len_w = i_w; fin_u->sat = u3k(cor); for ( j = rev; i_w-- > 0; j = u3t(j) ) { - _n_fist* fis_u = &(fin_u->fis_u[i_w]); + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); par = u3h(j); fis_u->bat = u3k(u3h(par)); fis_u->pax = u3k(u3t(par)); @@ -653,11 +564,11 @@ _n_cast(u3_noun cor, u3_noun loc) } static c3_w -_n_fink_mark(_n_fink* fin_u) +_n_fink_mark(u3j_fink* fin_u) { c3_w i_w, tot_w = u3a_mark_noun(fin_u->sat); for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { - _n_fist* fis_u = &(fin_u->fis_u[i_w]); + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); tot_w += u3a_mark_noun(fis_u->bat); tot_w += u3a_mark_noun(fis_u->pax); } @@ -666,30 +577,30 @@ _n_fink_mark(_n_fink* fin_u) } static void -_n_fink_free(_n_fink* fin_u) +_n_fink_free(u3j_fink* fin_u) { c3_w i_w; u3z(fin_u->sat); for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { - _n_fist* fis_u = &(fin_u->fis_u[i_w]); + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); u3z(fis_u->bat); u3z(fis_u->pax); } u3a_wfree(fin_u); } -static _n_fink* -_n_fink_take(_n_fink* jun_u) +static u3j_fink* +_n_fink_take(u3j_fink* jun_u) { c3_w i_w, len_w = jun_u->len_w; - _n_fink* fin_u = u3a_walloc(c3_wiseof(_n_fink) + - (len_w * c3_wiseof(_n_fist))); + u3j_fink* fin_u = u3a_walloc(c3_wiseof(u3j_fink) + + (len_w * c3_wiseof(u3j_fist))); fin_u->len_w = len_w; fin_u->sat = u3a_take(jun_u->sat); for ( i_w = 0; i_w < len_w; ++i_w ) { - _n_fist* fis_u = &(fin_u->fis_u[i_w]); - _n_fist* sif_u = &(jun_u->fis_u[i_w]); + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + u3j_fist* sif_u = &(jun_u->fis_u[i_w]); fis_u->bat = u3a_take(sif_u->bat); fis_u->pax = u3a_take(sif_u->pax); } @@ -697,17 +608,17 @@ _n_fink_take(_n_fink* jun_u) } static void -_n_mine(_n_rite* rit_u, u3_noun clu, u3_noun cor) +_n_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) { c3_t non_t = (u3_none == rit_u->clu); if ( non_t || c3n == u3r_sing(rit_u->clu, clu) || - c3n == _n_fine(cor, rit_u->fin_u) ) { + c3n == u3j_fine(cor, rit_u->fin_u) ) { u3_weak loc = u3j_mile(u3k(clu), u3k(cor)); if ( u3_none != loc ) { u3_noun old = rit_u->clu; - _n_fink* fon_u = rit_u->fin_u; + u3j_fink* fon_u = rit_u->fin_u; c3_o own_o = rit_u->own_o; rit_u->own_o = c3y; rit_u->clu = u3k(clu); @@ -878,22 +789,22 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, } static void* -_n_prog_dat(_n_prog* pog_u) +_n_prog_dat(u3n_prog* pog_u) { - return ((void*) pog_u) + sizeof(_n_prog); + return ((void*) pog_u) + sizeof(u3n_prog); } -static _n_prog* +static u3n_prog* _n_prog_new(c3_w byc_w, c3_w cal_w, c3_w reg_w, c3_w lit_w, c3_w mem_w) { - c3_w cab_w = (sizeof(_n_site) * cal_w), - reb_w = (sizeof(_n_rite) * reg_w), + c3_w cab_w = (sizeof(u3j_site) * cal_w), + reb_w = (sizeof(u3j_rite) * reg_w), lib_w = (sizeof(u3_noun) * lit_w), - meb_w = (sizeof(_n_memo) * mem_w), + meb_w = (sizeof(u3n_memo) * mem_w), dat_w = byc_w + cab_w + reb_w + lib_w + meb_w; - _n_prog* pog_u = u3a_malloc(sizeof(_n_prog) + dat_w); + u3n_prog* pog_u = u3a_malloc(sizeof(u3n_prog) + dat_w); pog_u->byc_u.own_o = c3y; pog_u->byc_u.len_w = byc_w; pog_u->byc_u.ops_y = (c3_y*) _n_prog_dat(pog_u); @@ -902,27 +813,27 @@ _n_prog_new(c3_w byc_w, c3_w cal_w, pog_u->lit_u.non = (u3_noun*) (pog_u->byc_u.ops_y + pog_u->byc_u.len_w); pog_u->mem_u.len_w = mem_w; - pog_u->mem_u.sot_u = (_n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); + pog_u->mem_u.sot_u = (u3n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); pog_u->cal_u.len_w = cal_w; - pog_u->cal_u.sit_u = (_n_site*) (pog_u->mem_u.sot_u + pog_u->mem_u.len_w); + pog_u->cal_u.sit_u = (u3j_site*) (pog_u->mem_u.sot_u + pog_u->mem_u.len_w); pog_u->reg_u.len_w = reg_w; - pog_u->reg_u.rit_u = (_n_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); + pog_u->reg_u.rit_u = (u3j_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); return pog_u; } -static _n_prog* -_n_prog_old(_n_prog* sep_u) +static u3n_prog* +_n_prog_old(u3n_prog* sep_u) { - c3_w cab_w = sizeof(_n_site) * sep_u->cal_u.len_w, - reb_w = sizeof(_n_rite) * sep_u->reg_u.len_w, + c3_w cab_w = sizeof(u3j_site) * sep_u->cal_u.len_w, + reb_w = sizeof(u3j_rite) * sep_u->reg_u.len_w, lib_w = sizeof(u3_noun) * sep_u->lit_u.len_w, - meb_w = sizeof(_n_memo) * sep_u->mem_u.len_w, + meb_w = sizeof(u3n_memo) * sep_u->mem_u.len_w, dat_w = cab_w + reb_w + lib_w + meb_w; - _n_prog* pog_u = u3a_malloc(sizeof(_n_prog) + dat_w); + u3n_prog* pog_u = u3a_malloc(sizeof(u3n_prog) + dat_w); pog_u->byc_u.own_o = c3n; pog_u->byc_u.len_w = sep_u->byc_u.len_w; pog_u->byc_u.ops_y = sep_u->byc_u.ops_y; @@ -931,13 +842,13 @@ _n_prog_old(_n_prog* sep_u) pog_u->lit_u.non = (u3_noun*) _n_prog_dat(pog_u); pog_u->mem_u.len_w = sep_u->mem_u.len_w; - pog_u->mem_u.sot_u = (_n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); + pog_u->mem_u.sot_u = (u3n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); pog_u->cal_u.len_w = sep_u->cal_u.len_w; - pog_u->cal_u.sit_u = (_n_site*) (pog_u->mem_u.sot_u + pog_u->mem_u.len_w); + pog_u->cal_u.sit_u = (u3j_site*) (pog_u->mem_u.sot_u + pog_u->mem_u.len_w); pog_u->reg_u.len_w = sep_u->reg_u.len_w; - pog_u->reg_u.rit_u = (_n_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); + pog_u->reg_u.rit_u = (u3j_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); memcpy(pog_u->lit_u.non, sep_u->lit_u.non, dat_w); return pog_u; @@ -960,7 +871,7 @@ _n_prog_asm_inx(c3_y* buf_y, c3_w* i_w, c3_s inx_s, c3_y cod) } static void -_n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) +_n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) { u3_noun top = ops; c3_y* buf_y = pog_u->byc_u.ops_y; @@ -983,7 +894,7 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) /* registration site index args */ case BAST: case BALT: { _n_prog_asm_inx(buf_y, &i_w, reg_s, op); - _n_rite* rit_u = &(pog_u->reg_u.rit_u[reg_s++]); + u3j_rite* rit_u = &(pog_u->reg_u.rit_u[reg_s++]); rit_u->own_o = c3n; rit_u->clu = u3_none; rit_u->fin_u = NULL; @@ -1000,7 +911,7 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) /* memo index args */ case SKIB: case SLIB: { - _n_memo* mem_u; + u3n_memo* mem_u; c3_l sip_l = u3h(sip); u3_noun tmp = sip; sip = u3k(u3t(sip)); @@ -1078,7 +989,7 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) /* call site index args */ case TICB: case KICB: { _n_prog_asm_inx(buf_y, &i_w, cal_s, cod); - _n_site* sit_u = &(pog_u->cal_u.sit_u[cal_s++]); + u3j_site* sit_u = &(pog_u->cal_u.sit_u[cal_s++]); sit_u->axe = u3k(u3t(op)); sit_u->pog_u = NULL; sit_u->bat = u3_none; @@ -1102,11 +1013,11 @@ _n_prog_asm(u3_noun ops, _n_prog* pog_u, u3_noun sip) c3_assert(u3_nul == sip); } -static _n_prog* +static u3n_prog* _n_prog_from_ops(u3_noun ops) { u3_noun sip; - _n_prog* pog_u; + u3n_prog* pog_u; c3_w byc_w = 1, // HALT cal_w = 0, reg_w = 0, @@ -1615,7 +1526,7 @@ _n_print_byc(c3_y* pog, c3_w her_w) /* _n_bite(): compile a nock formula to bytecode */ -static inline _n_prog* +static inline u3n_prog* _n_bite(u3_noun fol) { u3_noun ops = u3_nul; _n_comp(&ops, fol, c3y, c3y); @@ -1624,12 +1535,12 @@ _n_bite(u3_noun fol) { /* _n_find(): return prog for given formula. fol is RETAINED. */ -static inline _n_prog* +static inline u3n_prog* _n_find(u3_noun fol) { u3_weak pog = u3h_git(u3R->byc.har_p, fol); if ( u3_none != pog ) { - return u3to(_n_prog, pog); + return u3to(u3n_prog, pog); } else if ( u3R != &u3H->rod_u ) { u3a_road* rod_u = u3R; @@ -1638,13 +1549,13 @@ _n_find(u3_noun fol) pog = u3h_git(rod_u->byc.har_p, fol); if ( u3_none != pog ) { c3_w i_w; - _n_prog* old = _n_prog_old(u3to(_n_prog, pog)); + u3n_prog* old = _n_prog_old(u3to(u3n_prog, pog)); for ( i_w = 0; i_w < old->reg_u.len_w; ++i_w ) { - _n_rite* rit_u = &(old->reg_u.rit_u[i_w]); + u3j_rite* rit_u = &(old->reg_u.rit_u[i_w]); rit_u->own_o = c3n; } for ( i_w = 0; i_w < old->cal_u.len_w; ++i_w ) { - _n_site* sit_u = &(old->cal_u.sit_u[i_w]); + u3j_site* sit_u = &(old->cal_u.sit_u[i_w]); sit_u->bat = u3_none; sit_u->pog_u = NULL; sit_u->fon_o = c3n; @@ -1656,7 +1567,7 @@ _n_find(u3_noun fol) } { - _n_prog* gop = _n_bite(fol); + u3n_prog* gop = _n_bite(fol); u3h_put(u3R->byc.har_p, fol, u3a_outa(gop)); return gop; } @@ -1673,7 +1584,7 @@ _n_spot(u3_noun cor) } static u3_weak -_n_lock(u3_noun cor, _n_site* sit_u) +_n_lock(u3_noun cor, u3j_site* sit_u) { if ( (u3_none != sit_u->bat) && (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { @@ -1687,10 +1598,10 @@ _n_lock(u3_noun cor, _n_site* sit_u) return u3_none; } -static u3_noun _n_burn_out(u3_noun bus, _n_prog* pog_u); +static u3_noun _n_burn_out(u3_noun bus, u3n_prog* pog_u); static u3_weak -_n_hock(u3_noun cor, _n_site* sit_u) +_n_hock(u3_noun cor, u3j_site* sit_u) { u3_weak pro = u3_none; c3_o jet_o = sit_u->jet_o; @@ -1726,13 +1637,13 @@ _n_hock(u3_noun cor, _n_site* sit_u) } static u3_weak -_n_kick(u3_noun cor, _n_site* sit_u) +_n_kick(u3_noun cor, u3j_site* sit_u) { u3_weak loc = u3_none, pro = u3_none; if ( u3_none != sit_u->loc ) { - if ( c3y == _n_fine(cor, sit_u->fin_u) ) { + if ( c3y == u3j_fine(cor, sit_u->fin_u) ) { loc = sit_u->loc; if ( c3y == sit_u->jet_o ) { pro = _n_hock(cor, sit_u); @@ -1743,7 +1654,7 @@ _n_kick(u3_noun cor, _n_site* sit_u) if ( u3_none == loc ) { loc = _n_spot(cor); if ( u3_none != loc ) { - _n_fink* fon_u = NULL; + u3j_fink* fon_u = NULL; u3_weak lod = u3_none; u3_weak lob = u3_none; @@ -1810,7 +1721,7 @@ _n_kale(u3_noun a) } typedef struct { - _n_prog* pog_u; + u3n_prog* pog_u; c3_w ip_w; } burnframe; @@ -1820,7 +1731,7 @@ typedef struct { * off: 0 north, -1 south */ static u3_noun -_n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) +_n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) { /* OPCODE TABLE */ static void* lab[] = { @@ -1851,9 +1762,9 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) &&do_save, }; - _n_site* sit_u; - _n_rite* rit_u; - _n_memo* mem_u; + u3j_site* sit_u; + u3j_rite* rit_u; + u3n_memo* mem_u; c3_y *pog = pog_u->byc_u.ops_y; c3_w sip_w, ip_w = 0; u3_noun* top; @@ -2438,7 +2349,7 @@ _n_burn(_n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) } static u3_noun -_n_burn_out(u3_noun bus, _n_prog* pog_u) +_n_burn_out(u3_noun bus, u3n_prog* pog_u) { c3_ys mov, off; if ( c3y == u3a_is_north(u3R) ) { @@ -2457,7 +2368,7 @@ _n_burn_out(u3_noun bus, _n_prog* pog_u) static u3_noun _n_burn_on(u3_noun bus, u3_noun fol) { - _n_prog* pog_u = _n_find(fol); + u3n_prog* pog_u = _n_find(fol); u3z(fol); return _n_burn_out(bus, pog_u); @@ -2482,7 +2393,7 @@ u3n_nock_on(u3_noun bus, u3_noun fol) } static void -_n_site_take(_n_site* dst_u, _n_site* src_u, c3_o los_o) +_n_site_take(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) { u3_noun old = dst_u->axe; dst_u->axe = u3a_take(src_u->axe); @@ -2506,7 +2417,7 @@ _n_site_take(_n_site* dst_u, _n_site* src_u, c3_o los_o) u3_noun lob = dst_u->lab, lod = dst_u->loc; c3_o fon_o = dst_u->fon_o; - _n_fink* fon_u = dst_u->fin_u; + u3j_fink* fon_u = dst_u->fin_u; dst_u->loc = u3a_take(src_u->loc); dst_u->lab = u3a_take(src_u->lab); @@ -2539,7 +2450,7 @@ _n_site_take(_n_site* dst_u, _n_site* src_u, c3_o los_o) } static void -_n_rite_take(_n_rite* dst_u, _n_rite* src_u, c3_o los_o) +_n_rite_take(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o) { if ( u3_none == src_u->clu ) { dst_u->clu = u3_none; @@ -2547,7 +2458,7 @@ _n_rite_take(_n_rite* dst_u, _n_rite* src_u, c3_o los_o) } else { u3_noun old = dst_u->clu; - _n_fink* fon_u = dst_u->fin_u; + u3j_fink* fon_u = dst_u->fin_u; c3_o own_o = dst_u->own_o; if ( c3y == src_u->own_o ) { dst_u->own_o = c3y; @@ -2564,7 +2475,7 @@ _n_rite_take(_n_rite* dst_u, _n_rite* src_u, c3_o los_o) } static void -_n_prog_take_dat(_n_prog* dst_u, _n_prog* src_u, c3_o los_o) +_n_prog_take_dat(u3n_prog* dst_u, u3n_prog* src_u, c3_o los_o) { c3_w i_w; for ( i_w = 0; i_w < src_u->lit_u.len_w; ++i_w ) { @@ -2578,8 +2489,8 @@ _n_prog_take_dat(_n_prog* dst_u, _n_prog* src_u, c3_o los_o) } for ( i_w = 0; i_w < src_u->mem_u.len_w; ++i_w ) { - _n_memo* dst = &(dst_u->mem_u.sot_u[i_w]); - _n_memo* src = &(src_u->mem_u.sot_u[i_w]); + u3n_memo* dst = &(dst_u->mem_u.sot_u[i_w]); + u3n_memo* src = &(src_u->mem_u.sot_u[i_w]); u3_noun old = dst->key; dst->sip_l = src->sip_l; dst->key = u3a_take(src->key); @@ -2601,10 +2512,10 @@ _n_prog_take_dat(_n_prog* dst_u, _n_prog* src_u, c3_o los_o) /* _n_prog_take(): copy program from a junior road */ -static _n_prog* -_n_prog_take(_n_prog* pog_u) +static u3n_prog* +_n_prog_take(u3n_prog* pog_u) { - _n_prog* gop_u; + u3n_prog* gop_u; if ( c3y == pog_u->byc_u.own_o ) { gop_u = _n_prog_new(pog_u->byc_u.len_w, @@ -2621,7 +2532,7 @@ _n_prog_take(_n_prog* pog_u) } static void -_n_site_free(_n_site* sit_u) +_n_site_free(u3j_site* sit_u) { u3z(sit_u->axe); if ( u3_none != sit_u->bat ) { @@ -2637,7 +2548,7 @@ _n_site_free(_n_site* sit_u) } static void -_n_rite_free(_n_rite* rit_u) +_n_rite_free(u3j_rite* rit_u) { if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { u3z(rit_u->clu); @@ -2648,7 +2559,7 @@ _n_rite_free(_n_rite* rit_u) /* _n_prog_free(): free memory retained by program */ static void -_n_prog_free(_n_prog* pog_u) +_n_prog_free(u3n_prog* pog_u) { c3_w i_w; @@ -2681,14 +2592,14 @@ _n_reap(u3_noun kev) u3_noun lof = u3a_take(fol); u3_noun tog; u3_weak con = u3h_get(u3R->byc.har_p, lof); - _n_prog* pog_u = u3to(_n_prog, got); + u3n_prog* pog_u = u3to(u3n_prog, got); if ( u3_none == con ) { tog = u3a_outa(_n_prog_take(pog_u)); u3h_put(u3R->byc.har_p, lof, tog); } else { - _n_prog* sep_u = u3to(_n_prog, con); + u3n_prog* sep_u = u3to(u3n_prog, con); _n_prog_take_dat(sep_u, pog_u, c3y); tog = u3a_outa(sep_u); } @@ -2707,9 +2618,9 @@ void _n_ream(u3_noun kev) { c3_w i_w; - _n_prog* pog_u = u3to(_n_prog, u3t(kev)); + u3n_prog* pog_u = u3to(u3n_prog, u3t(kev)); for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - _n_site* sit_u = &(pog_u->cal_u.sit_u[i_w]); + u3j_site* sit_u = &(pog_u->cal_u.sit_u[i_w]); if ( u3_none != sit_u->loc ) { u3z(sit_u->lab); sit_u->jet_o = u3j_nail(sit_u->loc, sit_u->axe, @@ -2728,7 +2639,7 @@ u3n_ream() } static c3_w -_n_site_mark(_n_site* sit_u) +_n_site_mark(u3j_site* sit_u) { c3_w tot_w = u3a_mark_noun(sit_u->axe); if ( u3_none != sit_u->bat ) { @@ -2745,7 +2656,7 @@ _n_site_mark(_n_site* sit_u) } static c3_w -_n_rite_mark(_n_rite* rit_u) +_n_rite_mark(u3j_rite* rit_u) { c3_w tot_w = 0; if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { @@ -2758,7 +2669,7 @@ _n_rite_mark(_n_rite* rit_u) /* _n_prog_mark(): mark program for gc. */ static c3_w -_n_prog_mark(_n_prog* pog_u) +_n_prog_mark(u3n_prog* pog_u) { c3_w i_w, tot_w = u3a_mark_mptr(pog_u); @@ -2787,7 +2698,7 @@ static void _n_bam(u3_noun kev, void* dat) { c3_w* bam_w = dat; - _n_prog* pog = u3to(_n_prog, u3t(kev)); + u3n_prog* pog = u3to(u3n_prog, u3t(kev)); *bam_w += _n_prog_mark(pog); } @@ -2807,7 +2718,7 @@ u3n_bark() static void _n_feb(u3_noun kev) { - _n_prog_free(u3to(_n_prog, u3t(kev))); + _n_prog_free(u3to(u3n_prog, u3t(kev))); } /* u3n_bree(): free bytecode cache From bf2d240ed026f5c2cf084d426d86e306677e8122 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 11:15:46 -0700 Subject: [PATCH 072/221] move cast --- include/noun/jets.h | 5 +++++ noun/jets.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ noun/nock.c | 40 ++----------------------------------- 3 files changed, 55 insertions(+), 38 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 9b6d1f6d3..0c6a5727f 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -139,6 +139,11 @@ c3_o u3j_fine(u3_noun cor, u3j_fink* fin_u); + /* u3j_cast(): create u3j_fink from core and location. + */ + u3j_fink* + u3j_cast(u3_noun cor, u3_noun loc); + /* u3j_nail(): resolve hot state for location and axis. RETAIN. ** return value indicates presence of driver. **/ diff --git a/noun/jets.c b/noun/jets.c index ace1b904a..f9001eb27 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -271,6 +271,54 @@ u3j_spot(u3_noun cor) } } +static u3j_fink* +_cj_cast(u3_noun cor, u3_noun loc) +{ + c3_w i_w = 0; + u3_noun j, par, bat, dyn, pax, + rev = u3_nul, + pat = u3h(loc); + u3j_fink* fin_u; + + while ( c3n == u3h(pat) ) { + bat = u3h(cor); + dyn = u3t(pat); + pax = u3h(dyn); + loc = u3t(dyn); + pat = u3h(loc); + rev = u3nc(u3nc(u3k(bat), u3k(pax)), rev); + cor = u3r_at(pax, cor); + ++i_w; + } + + fin_u = u3a_walloc(c3_wiseof(u3j_fink) + + (i_w * c3_wiseof(u3j_fist))); + fin_u->len_w = i_w; + fin_u->sat = u3k(cor); + for ( j = rev; i_w-- > 0; j = u3t(j) ) { + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + par = u3h(j); + fis_u->bat = u3k(u3h(par)); + fis_u->pax = u3k(u3t(par)); + } + u3z(rev); + c3_assert( u3_nul == j ); + + return fin_u; +} + +/* u3j_cast(): create u3j_fink from core and location. + */ +u3j_fink* +u3j_cast(u3_noun cor, u3_noun loc) +{ + u3j_fink* fin_u; + u3t_on(glu_o); + fin_u = _cj_cast(cor, loc); + u3t_off(glu_o); + return fin_u; +} + static c3_o _cj_fine(u3_noun cor, u3j_fink* fin_u) { diff --git a/noun/nock.c b/noun/nock.c index 54c9c02de..a2eba5471 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -527,42 +527,6 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIS 71 #define SAVE 72 -static u3j_fink* -_n_cast(u3_noun cor, u3_noun loc) -{ - c3_w i_w = 0; - u3_noun j, par, bat, dyn, pax, - rev = u3_nul, - pat = u3h(loc); - u3j_fink* fin_u; - - while ( c3n == u3h(pat) ) { - bat = u3h(cor); - dyn = u3t(pat); - pax = u3h(dyn); - loc = u3t(dyn); - pat = u3h(loc); - rev = u3nc(u3nc(u3k(bat), u3k(pax)), rev); - cor = u3r_at(pax, cor); - ++i_w; - } - - fin_u = u3a_walloc(c3_wiseof(u3j_fink) + - (i_w * c3_wiseof(u3j_fist))); - fin_u->len_w = i_w; - fin_u->sat = u3k(cor); - for ( j = rev; i_w-- > 0; j = u3t(j) ) { - u3j_fist* fis_u = &(fin_u->fis_u[i_w]); - par = u3h(j); - fis_u->bat = u3k(u3h(par)); - fis_u->pax = u3k(u3t(par)); - } - u3z(rev); - c3_assert( u3_nul == j ); - - return fin_u; -} - static c3_w _n_fink_mark(u3j_fink* fin_u) { @@ -622,7 +586,7 @@ _n_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) c3_o own_o = rit_u->own_o; rit_u->own_o = c3y; rit_u->clu = u3k(clu); - rit_u->fin_u = _n_cast(cor, loc); + rit_u->fin_u = u3j_cast(cor, loc); u3z(loc); if ( !non_t && (c3y == own_o) ) { @@ -1667,7 +1631,7 @@ _n_kick(u3_noun cor, u3j_site* sit_u) } sit_u->loc = loc; - sit_u->fin_u = _n_cast(cor, loc); + sit_u->fin_u = u3j_cast(cor, loc); sit_u->fon_o = c3y; if ( c3y == (sit_u->jet_o = u3j_nail(loc, sit_u->axe, From 462c6d7bd59d9e0f2d98726a9e65ae41ed693abc Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 11:23:03 -0700 Subject: [PATCH 073/221] move rite and site mark --- include/noun/jets.h | 11 ++++++++++- noun/jets.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ noun/nock.c | 45 ++------------------------------------------- 3 files changed, 57 insertions(+), 44 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 0c6a5727f..b63dbb370 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -177,7 +177,6 @@ u3j_kink(u3_noun cor, u3_noun axe); - /* u3j_mile(): register core for jets, returning location. */ u3_weak @@ -198,3 +197,13 @@ */ void u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p); + + /* u3j_rite_mark(): mark u3j_rite for gc. + */ + c3_w + u3j_rite_mark(u3j_rite* rit_u); + + /* u3j_site_mark(): mark u3j_site for gc. + */ + c3_w + u3j_site_mark(u3j_site* sit_u); diff --git a/noun/jets.c b/noun/jets.c index f9001eb27..4046caa62 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1213,6 +1213,51 @@ u3j_ream(void) u3z(rel); } +static c3_w +_cj_fink_mark(u3j_fink* fin_u) +{ + c3_w i_w, tot_w = u3a_mark_noun(fin_u->sat); + for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + tot_w += u3a_mark_noun(fis_u->bat); + tot_w += u3a_mark_noun(fis_u->pax); + } + tot_w += u3a_mark_ptr(fin_u); + return tot_w; +} + +/* u3j_rite_mark(): mark u3j_rite for gc. +*/ +c3_w +u3j_rite_mark(u3j_rite* rit_u) +{ + c3_w tot_w = 0; + if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { + tot_w += u3a_mark_noun(rit_u->clu); + tot_w += _cj_fink_mark(rit_u->fin_u); + } + return tot_w; +} + +/* u3j_site_mark(): mark u3j_site for gc. +*/ +c3_w +u3j_site_mark(u3j_site* sit_u) +{ + c3_w tot_w = u3a_mark_noun(sit_u->axe); + if ( u3_none != sit_u->bat ) { + tot_w += u3a_mark_noun(sit_u->bat); + } + if ( u3_none != sit_u->loc ) { + tot_w += u3a_mark_noun(sit_u->loc); + tot_w += u3a_mark_noun(sit_u->lab); + if ( c3y == sit_u->fon_o ) { + tot_w += _cj_fink_mark(sit_u->fin_u); + } + } + return tot_w; +} + /* XX FIXME: move to u3.md |% += location $: pattern=(each static dynamic) diff --git a/noun/nock.c b/noun/nock.c index a2eba5471..9c0270361 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -527,19 +527,6 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIS 71 #define SAVE 72 -static c3_w -_n_fink_mark(u3j_fink* fin_u) -{ - c3_w i_w, tot_w = u3a_mark_noun(fin_u->sat); - for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { - u3j_fist* fis_u = &(fin_u->fis_u[i_w]); - tot_w += u3a_mark_noun(fis_u->bat); - tot_w += u3a_mark_noun(fis_u->pax); - } - tot_w += u3a_mark_ptr(fin_u); - return tot_w; -} - static void _n_fink_free(u3j_fink* fin_u) { @@ -2602,34 +2589,6 @@ u3n_ream() u3h_walk(u3R->byc.har_p, _n_ream); } -static c3_w -_n_site_mark(u3j_site* sit_u) -{ - c3_w tot_w = u3a_mark_noun(sit_u->axe); - if ( u3_none != sit_u->bat ) { - tot_w += u3a_mark_noun(sit_u->bat); - } - if ( u3_none != sit_u->loc ) { - tot_w += u3a_mark_noun(sit_u->loc); - tot_w += u3a_mark_noun(sit_u->lab); - if ( c3y == sit_u->fon_o ) { - tot_w += _n_fink_mark(sit_u->fin_u); - } - } - return tot_w; -} - -static c3_w -_n_rite_mark(u3j_rite* rit_u) -{ - c3_w tot_w = 0; - if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { - tot_w += u3a_mark_noun(rit_u->clu); - tot_w += _n_fink_mark(rit_u->fin_u); - } - return tot_w; -} - /* _n_prog_mark(): mark program for gc. */ static c3_w @@ -2646,11 +2605,11 @@ _n_prog_mark(u3n_prog* pog_u) } for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - tot_w += _n_site_mark(&(pog_u->cal_u.sit_u[i_w])); + tot_w += u3j_site_mark(&(pog_u->cal_u.sit_u[i_w])); } for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { - tot_w += _n_rite_mark(&(pog_u->reg_u.rit_u[i_w])); + tot_w += u3j_rite_mark(&(pog_u->reg_u.rit_u[i_w])); } return tot_w; From a15c248e3da8a5fd35981271840d33b00cfe48b9 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 12:06:57 -0700 Subject: [PATCH 074/221] move _n_fink_free and everything that calls it --- include/noun/jets.h | 37 ++++- include/noun/nock.h | 10 ++ noun/jets.c | 355 +++++++++++++++++++++++++++++++++++++++++--- noun/nock.c | 330 +++++----------------------------------- 4 files changed, 413 insertions(+), 319 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index b63dbb370..69bf69262 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -177,11 +177,6 @@ u3j_kink(u3_noun cor, u3_noun axe); - /* u3j_mile(): register core for jets, returning location. - */ - u3_weak - u3j_mile(u3_noun clu, u3_noun cor); - /* u3j_mine(): register core for jets. */ void @@ -198,11 +193,43 @@ void u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p); + /* u3j_rite_mine(): mine cor with clu, using u3j_rite for caching + */ + void + u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor); + + /* u3j_rite_copy(): copy rite references from src_u to dst_u, + ** losing old references if los_o is yes + */ + void + u3j_rite_copy(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o); + + /* u3j_site_copy(): copy site references from src_u to dst_u, + ** losing old references if los_o is yes + */ + void + u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o); + + /* u3j_site_kick(): kick a core with a u3j_site cache. + */ + u3_weak + u3j_site_kick(u3_noun cor, u3j_site* sit_u); + /* u3j_rite_mark(): mark u3j_rite for gc. */ c3_w u3j_rite_mark(u3j_rite* rit_u); + /* u3j_rite_lose(): lose references of u3j_rite (but do not free). + */ + void + u3j_rite_lose(u3j_rite* rit_u); + + /* u3j_site_lose(): lose references of u3j_site (but do not free). + */ + void + u3j_site_lose(u3j_site* sit_u); + /* u3j_site_mark(): mark u3j_site for gc. */ c3_w diff --git a/include/noun/nock.h b/include/noun/nock.h index 5c7736062..b83fb6082 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -42,6 +42,16 @@ u3_noun u3n_nock_on(u3_noun bus, u3_noun fol); + /* u3n_find(): return prog for given formula. fol is RETAINED. + */ + u3n_prog* + u3n_find(u3_noun fol); + + /* u3n_burn(): execute u3n_prog with bus as subject. + */ + u3_noun + u3n_burn(u3_noun bus, u3n_prog* pog_u); + /* u3n_slam_on(): produce (gat sam). */ u3_noun diff --git a/noun/jets.c b/noun/jets.c index 4046caa62..0d8a33067 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -226,10 +226,8 @@ _cj_find_warm(u3_noun loc) } } -/* u3j_spot(): identify `cor`s location. RETAIN. - */ -u3_weak -u3j_spot(u3_noun cor) +static u3_weak +_cj_spot(u3_noun cor) { u3_weak reg = _cj_find_cold(u3h(cor)); if ( u3_none == reg ) { @@ -252,7 +250,7 @@ u3j_spot(u3_noun cor) u3_weak par = u3r_at(axe, cor), pel; if ( u3_none != par ) { - pel = u3j_spot(par); + pel = _cj_spot(par); if ( u3_none != pel ) { u3_noun nit = u3qdb_get(lol, pel); u3z(pel); @@ -271,6 +269,18 @@ u3j_spot(u3_noun cor) } } +/* u3j_spot(): identify `cor`s location. RETAIN. + */ +u3_weak +u3j_spot(u3_noun cor) +{ + u3_weak loc; + u3t_on(glu_o); + loc = _cj_spot(cor); + u3t_off(glu_o); + return loc; +} + static u3j_fink* _cj_cast(u3_noun cor, u3_noun loc) { @@ -347,18 +357,13 @@ u3j_fine(u3_noun cor, u3j_fink* fin_u) return ret_o; } -/* u3j_nail(): resolve hot state for location and axis. RETAIN. -** return value indicates presence of driver. -**/ -c3_o -u3j_nail(u3_noun loc, u3_noun axe, +static c3_o +_cj_nail(u3_noun loc, u3_noun axe, u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u) { c3_o ret_o; u3_noun jax, hap, bal, jit; u3_weak act; - - u3t_on(glu_o); act = _cj_find_warm(loc); c3_assert(u3_none != act); u3x_qual(act, &jax, &hap, &bal, &jit); @@ -382,6 +387,19 @@ u3j_nail(u3_noun loc, u3_noun axe, } u3z(act); + return ret_o; +} + +/* u3j_nail(): resolve hot state for location and axis. RETAIN. +** return value indicates presence of driver. +**/ +c3_o +u3j_nail(u3_noun loc, u3_noun axe, + u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u) +{ + c3_o ret_o; + u3t_on(glu_o); + ret_o = _cj_nail(loc, axe, lab, cop_u, ham_u); u3t_off(glu_o); return ret_o; } @@ -391,7 +409,7 @@ u3j_nail(u3_noun loc, u3_noun axe, static c3_o _cj_scan(u3_noun cor) { - u3_weak loc = u3j_spot(cor); + u3_weak loc = _cj_spot(cor); c3_o reg_o = (u3_none == loc) ? c3n : c3y; u3z(loc); return reg_o; @@ -630,7 +648,7 @@ _cj_hook_in(u3_noun cor, return u3m_bail(c3__fail); } - loc = u3j_spot(cor); + loc = _cj_spot(cor); if ( u3_none == loc ) { return u3m_bail(c3__fail); } @@ -738,7 +756,7 @@ u3_weak u3j_kick(u3_noun cor, u3_noun axe) { u3t_on(glu_o); - u3_weak loc = u3j_spot(cor); + u3_weak loc = _cj_spot(cor); if ( u3_none == loc ) { u3t_off(glu_o); return u3_none; @@ -810,6 +828,237 @@ u3j_kick(u3_noun cor, u3_noun axe) } } +static u3j_fink* +_cj_fink_take(u3j_fink* jun_u) +{ + c3_w i_w, len_w = jun_u->len_w; + u3j_fink* fin_u = u3a_walloc(c3_wiseof(u3j_fink) + + (len_w * c3_wiseof(u3j_fist))); + + fin_u->len_w = len_w; + fin_u->sat = u3a_take(jun_u->sat); + for ( i_w = 0; i_w < len_w; ++i_w ) { + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + u3j_fist* sif_u = &(jun_u->fis_u[i_w]); + fis_u->bat = u3a_take(sif_u->bat); + fis_u->pax = u3a_take(sif_u->pax); + } + return fin_u; +} + +static void +_cj_fink_free(u3j_fink* fin_u) +{ + c3_w i_w; + u3z(fin_u->sat); + for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + u3z(fis_u->bat); + u3z(fis_u->pax); + } + u3a_wfree(fin_u); +} + +/* u3j_rite_copy(): copy rite references from src_u to dst_u, +** losing old references if los_o is yes +*/ +void +u3j_rite_copy(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o) +{ + if ( u3_none == src_u->clu ) { + dst_u->clu = u3_none; + dst_u->fin_u = NULL; + } + else { + u3_noun old = dst_u->clu; + u3j_fink* fon_u = dst_u->fin_u; + c3_o own_o = dst_u->own_o; + if ( c3y == src_u->own_o ) { + dst_u->own_o = c3y; + dst_u->clu = u3a_take(src_u->clu); + dst_u->fin_u = _cj_fink_take(src_u->fin_u); + if ( (c3y == los_o) && + (u3_none != old) && + (c3y == own_o) ) { + u3z(old); + _cj_fink_free(fon_u); + } + } + } +} + +/* u3j_site_copy(): copy site references from src_u to dst_u, +** losing old references if los_o is yes +*/ +void +u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) +{ + u3_noun old = dst_u->axe; + dst_u->axe = u3a_take(src_u->axe); + + if ( c3y == los_o ) { + u3z(old); + } + else { + dst_u->bat = u3_none; + dst_u->pog_u = NULL; + dst_u->loc = u3_none; + dst_u->lab = u3_none; + dst_u->jet_o = c3n; + dst_u->fon_o = c3n; + dst_u->cop_u = NULL; + dst_u->ham_u = NULL; + dst_u->fin_u = NULL; + } + + if ( u3_none != src_u->loc ) { + u3_noun lob = dst_u->lab, + lod = dst_u->loc; + c3_o fon_o = dst_u->fon_o; + u3j_fink* fon_u = dst_u->fin_u; + + dst_u->loc = u3a_take(src_u->loc); + dst_u->lab = u3a_take(src_u->lab); + dst_u->cop_u = src_u->cop_u; + dst_u->ham_u = src_u->ham_u; + dst_u->jet_o = src_u->jet_o; + + if ( c3y == src_u->fon_o ) { + dst_u->fin_u = _cj_fink_take(src_u->fin_u); + dst_u->fon_o = c3y; + } + else if ( fon_u != src_u->fin_u ) { + dst_u->fin_u = src_u->fin_u; + dst_u->fon_o = c3n; + } + else { + fon_o = c3n; + } + + if ( c3y == los_o ) { + if ( u3_none != lod ) { + u3z(lod); + u3z(lob); + if ( c3y == fon_o ) { + _cj_fink_free(fon_u); + } + } + } + } +} + +static u3_weak +_cj_site_lock(u3_noun cor, u3j_site* sit_u) +{ + if ( (u3_none != sit_u->bat) && + (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { + return u3_none; + } + sit_u->pog_u = u3n_find(u3r_at(sit_u->axe, cor)); + if ( u3_none != sit_u->bat ) { + u3z(sit_u->bat); + } + sit_u->bat = u3k(u3h(cor)); + return u3_none; +} + +static u3_weak +_cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) +{ + u3_weak pro = u3_none; + c3_o jet_o = sit_u->jet_o; + if ( c3n == __(u3C.wag_w & u3o_debug_cpu) ) { + if ( c3n == jet_o ) { + pro = u3_none; + } + else { + pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); + } + if ( u3_none == pro ) { + pro = _cj_site_lock(cor, sit_u); + } + } + else { + u3t_come(sit_u->lab); + if ( c3y == jet_o ) { + pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); + } + if ( u3_none == pro ) { + pro = _cj_site_lock(cor, sit_u); + if ( u3_none == pro ) { + pro = u3n_burn(cor, sit_u->pog_u); + } + } + u3t_flee(); + } + return pro; +} + +/* u3j_site_kick(): kick a core with a u3j_site cache. + */ +u3_weak +u3j_site_kick(u3_noun cor, u3j_site* sit_u) +{ + u3_weak loc, pro; + + u3t_on(glu_o); + loc = pro = u3_none; + + if ( u3_none != sit_u->loc ) { + if ( c3y == _cj_fine(cor, sit_u->fin_u) ) { + loc = sit_u->loc; + if ( c3y == sit_u->jet_o ) { + pro = _cj_site_kick_hot(cor, sit_u); + } + } + } + + if ( u3_none == loc ) { + loc = _cj_spot(cor); + if ( u3_none != loc ) { + u3j_fink* fon_u = NULL; + u3_weak lod = u3_none; + u3_weak lob = u3_none; + + if ( u3_none != sit_u->loc ) { + lod = sit_u->loc; + lob = sit_u->lab; + if ( c3y == sit_u->fon_o ) { + fon_u = sit_u->fin_u; + } + } + + sit_u->loc = loc; + sit_u->fin_u = _cj_cast(cor, loc); + sit_u->fon_o = c3y; + if ( c3y == + (sit_u->jet_o = _cj_nail(loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) + { + pro = _cj_site_kick_hot(cor, sit_u); + } + else { + pro = u3_none; + } + + if ( u3_none != lod ) { + u3z(lod); + u3z(lob); + if ( NULL != fon_u ) { + _cj_fink_free(fon_u); + } + } + } + } + + if ( u3_none == pro ) { + pro = _cj_site_lock(cor, sit_u); + } + + u3t_off(glu_o); + return pro; +} + /* u3j_kink(): kick either by jet or by nock. */ u3_noun @@ -922,7 +1171,7 @@ _cj_mine(u3_noun cey, u3_noun cor) fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(nam)); return u3_none; } - pel = u3j_spot(par); + pel = _cj_spot(par); if ( u3_none == pel ) { fprintf(stderr, "fund: in %s, parent %x not found at %d\r\n", u3r_string(nam), @@ -977,19 +1226,19 @@ _cj_moan(u3_noun clu, u3_noun cor) return loc; } -/* u3j_mile(): register core for jets, returning location. + +/* _cj_mile(): register core for jets, returning location. */ -u3_weak -u3j_mile(u3_noun clu, u3_noun cor) +static u3_weak +_cj_mile(u3_noun clu, u3_noun cor) { - u3t_on(glu_o); u3_weak loc = u3_none; if ( c3n == u3du(cor) ) { u3z(clu); u3z(cor); } else { - loc = u3j_spot(cor); + loc = _cj_spot(cor); if ( u3_none == loc ) { loc = _cj_moan(clu, cor); } @@ -998,7 +1247,6 @@ u3j_mile(u3_noun clu, u3_noun cor) u3z(cor); } } - u3t_off(glu_o); return loc; } @@ -1021,6 +1269,40 @@ u3j_mine(u3_noun clu, u3_noun cor) u3t_off(glu_o); } +/* u3j_rite_mine(): mine cor with clue, using u3j_rite for caching +*/ +void +u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) +{ + c3_t non_t; + u3t_on(glu_o); + + non_t = (u3_none == rit_u->clu); + + if ( non_t || + c3n == u3r_sing(rit_u->clu, clu) || + c3n == _cj_fine(cor, rit_u->fin_u) ) { + u3_weak loc = _cj_mile(u3k(clu), u3k(cor)); + if ( u3_none != loc ) { + u3_noun old = rit_u->clu; + u3j_fink* fon_u = rit_u->fin_u; + c3_o own_o = rit_u->own_o; + rit_u->own_o = c3y; + rit_u->clu = u3k(clu); + rit_u->fin_u = _cj_cast(cor, loc); + u3z(loc); + + if ( !non_t && (c3y == own_o) ) { + u3z(old); + _cj_fink_free(fon_u); + } + } + } + u3z(clu); + u3z(cor); + u3t_off(glu_o); +} + /* _cj_warm_reap(): reap key and value from warm table. */ static void @@ -1226,6 +1508,35 @@ _cj_fink_mark(u3j_fink* fin_u) return tot_w; } +/* u3j_site_lose(): lose references of u3j_site (but do not free). + */ +void +u3j_site_lose(u3j_site* sit_u) +{ + u3z(sit_u->axe); + if ( u3_none != sit_u->bat ) { + u3z(sit_u->bat); + } + if ( u3_none != sit_u->loc ) { + u3z(sit_u->loc); + u3z(sit_u->lab); + if ( c3y == sit_u->fon_o ) { + _cj_fink_free(sit_u->fin_u); + } + } +} + +/* u3j_rite_lose(): lose references of u3j_rite (but do not free). + */ +void +u3j_rite_lose(u3j_rite* rit_u) +{ + if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { + u3z(rit_u->clu); + _cj_fink_free(rit_u->fin_u); + } +} + /* u3j_rite_mark(): mark u3j_rite for gc. */ c3_w diff --git a/noun/nock.c b/noun/nock.c index 9c0270361..9ffb15de9 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -527,65 +527,6 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIS 71 #define SAVE 72 -static void -_n_fink_free(u3j_fink* fin_u) -{ - c3_w i_w; - u3z(fin_u->sat); - for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { - u3j_fist* fis_u = &(fin_u->fis_u[i_w]); - u3z(fis_u->bat); - u3z(fis_u->pax); - } - u3a_wfree(fin_u); -} - -static u3j_fink* -_n_fink_take(u3j_fink* jun_u) -{ - c3_w i_w, len_w = jun_u->len_w; - u3j_fink* fin_u = u3a_walloc(c3_wiseof(u3j_fink) + - (len_w * c3_wiseof(u3j_fist))); - - fin_u->len_w = len_w; - fin_u->sat = u3a_take(jun_u->sat); - for ( i_w = 0; i_w < len_w; ++i_w ) { - u3j_fist* fis_u = &(fin_u->fis_u[i_w]); - u3j_fist* sif_u = &(jun_u->fis_u[i_w]); - fis_u->bat = u3a_take(sif_u->bat); - fis_u->pax = u3a_take(sif_u->pax); - } - return fin_u; -} - -static void -_n_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) -{ - c3_t non_t = (u3_none == rit_u->clu); - - if ( non_t || - c3n == u3r_sing(rit_u->clu, clu) || - c3n == u3j_fine(cor, rit_u->fin_u) ) { - u3_weak loc = u3j_mile(u3k(clu), u3k(cor)); - if ( u3_none != loc ) { - u3_noun old = rit_u->clu; - u3j_fink* fon_u = rit_u->fin_u; - c3_o own_o = rit_u->own_o; - rit_u->own_o = c3y; - rit_u->clu = u3k(clu); - rit_u->fin_u = u3j_cast(cor, loc); - u3z(loc); - - if ( !non_t && (c3y == own_o) ) { - u3z(old); - _n_fink_free(fon_u); - } - } - } - u3z(clu); - u3z(cor); -} - /* _n_arg(): return the size (in bytes) of an opcode's argument */ static inline c3_y @@ -1486,7 +1427,7 @@ _n_bite(u3_noun fol) { /* _n_find(): return prog for given formula. fol is RETAINED. */ -static inline u3n_prog* +static u3n_prog* _n_find(u3_noun fol) { u3_weak pog = u3h_git(u3R->byc.har_p, fol); @@ -1524,127 +1465,16 @@ _n_find(u3_noun fol) } } -static u3_weak -_n_spot(u3_noun cor) +/* u3n_find(): return prog for given formula. fol is RETAINED. + */ +u3n_prog* +u3n_find(u3_noun fol) { - u3_weak loc; - u3t_off(noc_o); - loc = u3j_spot(cor); + u3n_prog* pog_u; u3t_on(noc_o); - return loc; -} - -static u3_weak -_n_lock(u3_noun cor, u3j_site* sit_u) -{ - if ( (u3_none != sit_u->bat) && - (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { - return u3_none; - } - sit_u->pog_u = _n_find(u3r_at(sit_u->axe, cor)); - if ( u3_none != sit_u->bat ) { - u3z(sit_u->bat); - } - sit_u->bat = u3k(u3h(cor)); - return u3_none; -} - -static u3_noun _n_burn_out(u3_noun bus, u3n_prog* pog_u); - -static u3_weak -_n_hock(u3_noun cor, u3j_site* sit_u) -{ - u3_weak pro = u3_none; - c3_o jet_o = sit_u->jet_o; - if ( c3n == __(u3C.wag_w & u3o_debug_cpu) ) { - if ( c3n == jet_o ) { - pro = u3_none; - } - else { - u3t_off(noc_o); - pro = u3j_hock(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); - u3t_on(noc_o); - } - if ( u3_none == pro ) { - pro = _n_lock(cor, sit_u); - } - } - else { - u3t_come(sit_u->lab); - if ( c3y == jet_o ) { - u3t_off(noc_o); - pro = u3j_hock(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); - u3t_on(noc_o); - } - if ( u3_none == pro ) { - pro = _n_lock(cor, sit_u); - if ( u3_none == pro ) { - pro = _n_burn_out(cor, sit_u->pog_u); - } - } - u3t_flee(); - } - return pro; -} - -static u3_weak -_n_kick(u3_noun cor, u3j_site* sit_u) -{ - u3_weak loc = u3_none, - pro = u3_none; - - if ( u3_none != sit_u->loc ) { - if ( c3y == u3j_fine(cor, sit_u->fin_u) ) { - loc = sit_u->loc; - if ( c3y == sit_u->jet_o ) { - pro = _n_hock(cor, sit_u); - } - } - } - - if ( u3_none == loc ) { - loc = _n_spot(cor); - if ( u3_none != loc ) { - u3j_fink* fon_u = NULL; - u3_weak lod = u3_none; - u3_weak lob = u3_none; - - if ( u3_none != sit_u->loc ) { - lod = sit_u->loc; - lob = sit_u->lab; - if ( c3y == sit_u->fon_o ) { - fon_u = sit_u->fin_u; - } - } - - sit_u->loc = loc; - sit_u->fin_u = u3j_cast(cor, loc); - sit_u->fon_o = c3y; - if ( c3y == - (sit_u->jet_o = u3j_nail(loc, sit_u->axe, - &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) - { - pro = _n_hock(cor, sit_u); - } - else { - pro = u3_none; - } - - if ( u3_none != lod ) { - u3z(lod); - u3z(lob); - if ( NULL != fon_u ) { - _n_fink_free(fon_u); - } - } - } - } - - if ( u3_none == pro ) { - pro = _n_lock(cor, sit_u); - } - - return pro; + pog_u = _n_find(fol); + u3t_off(noc_o); + return pog_u; } /* _n_swap(): swap two items on the top of the stack, return pointer to top @@ -1660,6 +1490,16 @@ _n_swap(c3_ys mov, c3_ys off) return top; } +static u3_weak +_n_kick(u3_noun cor, u3j_site* sit_u) +{ + u3_weak pro; + u3t_off(noc_o); + pro = u3j_site_kick(cor, sit_u); + u3t_off(noc_o); + return pro; +} + /* _n_kale(): bail(exit) if not cell */ static inline u3_noun @@ -2245,7 +2085,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) fast_out: rit_u = &(pog_u->reg_u.rit_u[x]); u3t_off(noc_o); - _n_mine(rit_u, *top, u3k(o)); + u3j_rite_mine(rit_u, *top, u3k(o)); u3t_on(noc_o); *top = o; BURN(); @@ -2314,6 +2154,18 @@ _n_burn_out(u3_noun bus, u3n_prog* pog_u) return _n_burn(pog_u, bus, mov, off); } +/* u3n_burn(): execute u3n_prog with bus as subject. + */ +u3_noun +u3n_burn(u3_noun bus, u3n_prog* pog_u) +{ + u3_noun pro; + u3t_on(noc_o); + pro = _n_burn_out(bus, pog_u); + u3t_off(noc_o); + return pro; +} + /* _n_burn_on(): produce .*(bus fol) with bytecode interpreter */ static u3_noun @@ -2343,88 +2195,6 @@ u3n_nock_on(u3_noun bus, u3_noun fol) return pro; } -static void -_n_site_take(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) -{ - u3_noun old = dst_u->axe; - dst_u->axe = u3a_take(src_u->axe); - - if ( c3y == los_o ) { - u3z(old); - } - else { - dst_u->bat = u3_none; - dst_u->pog_u = NULL; - dst_u->loc = u3_none; - dst_u->lab = u3_none; - dst_u->jet_o = c3n; - dst_u->fon_o = c3n; - dst_u->cop_u = NULL; - dst_u->ham_u = NULL; - dst_u->fin_u = NULL; - } - - if ( u3_none != src_u->loc ) { - u3_noun lob = dst_u->lab, - lod = dst_u->loc; - c3_o fon_o = dst_u->fon_o; - u3j_fink* fon_u = dst_u->fin_u; - - dst_u->loc = u3a_take(src_u->loc); - dst_u->lab = u3a_take(src_u->lab); - dst_u->cop_u = src_u->cop_u; - dst_u->ham_u = src_u->ham_u; - dst_u->jet_o = src_u->jet_o; - - if ( c3y == src_u->fon_o ) { - dst_u->fin_u = _n_fink_take(src_u->fin_u); - dst_u->fon_o = c3y; - } - else if ( fon_u != src_u->fin_u ) { - dst_u->fin_u = src_u->fin_u; - dst_u->fon_o = c3n; - } - else { - fon_o = c3n; - } - - if ( c3y == los_o ) { - if ( u3_none != lod ) { - u3z(lod); - u3z(lob); - if ( c3y == fon_o ) { - _n_fink_free(fon_u); - } - } - } - } -} - -static void -_n_rite_take(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o) -{ - if ( u3_none == src_u->clu ) { - dst_u->clu = u3_none; - dst_u->fin_u = NULL; - } - else { - u3_noun old = dst_u->clu; - u3j_fink* fon_u = dst_u->fin_u; - c3_o own_o = dst_u->own_o; - if ( c3y == src_u->own_o ) { - dst_u->own_o = c3y; - dst_u->clu = u3a_take(src_u->clu); - dst_u->fin_u = _n_fink_take(src_u->fin_u); - if ( (c3y == los_o) && - (u3_none != old) && - (c3y == own_o) ) { - u3z(old); - _n_fink_free(fon_u); - } - } - } -} - static void _n_prog_take_dat(u3n_prog* dst_u, u3n_prog* src_u, c3_o los_o) { @@ -2451,13 +2221,13 @@ _n_prog_take_dat(u3n_prog* dst_u, u3n_prog* src_u, c3_o los_o) } for ( i_w = 0; i_w < src_u->cal_u.len_w; ++i_w ) { - _n_site_take(&(dst_u->cal_u.sit_u[i_w]), - &(src_u->cal_u.sit_u[i_w]), los_o); + u3j_site_copy(&(dst_u->cal_u.sit_u[i_w]), + &(src_u->cal_u.sit_u[i_w]), los_o); } for ( i_w = 0; i_w < src_u->reg_u.len_w; ++i_w ) { - _n_rite_take(&(dst_u->reg_u.rit_u[i_w]), - &(src_u->reg_u.rit_u[i_w]), los_o); + u3j_rite_copy(&(dst_u->reg_u.rit_u[i_w]), + &(src_u->reg_u.rit_u[i_w]), los_o); } } @@ -2482,30 +2252,6 @@ _n_prog_take(u3n_prog* pog_u) return gop_u; } -static void -_n_site_free(u3j_site* sit_u) -{ - u3z(sit_u->axe); - if ( u3_none != sit_u->bat ) { - u3z(sit_u->bat); - } - if ( u3_none != sit_u->loc ) { - u3z(sit_u->loc); - u3z(sit_u->lab); - if ( c3y == sit_u->fon_o ) { - _n_fink_free(sit_u->fin_u); - } - } -} - -static void -_n_rite_free(u3j_rite* rit_u) -{ - if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { - u3z(rit_u->clu); - _n_fink_free(rit_u->fin_u); - } -} /* _n_prog_free(): free memory retained by program */ @@ -2523,11 +2269,11 @@ _n_prog_free(u3n_prog* pog_u) } for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - _n_site_free(&(pog_u->cal_u.sit_u[i_w])); + u3j_site_lose(&(pog_u->cal_u.sit_u[i_w])); } for ( i_w = 0; i_w < pog_u->reg_u.len_w; ++i_w ) { - _n_rite_free(&(pog_u->reg_u.rit_u[i_w])); + u3j_rite_lose(&(pog_u->reg_u.rit_u[i_w])); } u3a_free(pog_u); From be8c56376dd37893af1b30fc6982b58e59d25d57 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 16:36:29 -0700 Subject: [PATCH 075/221] hook caching in, kink weirdness fixed --- include/noun/allocate.h | 1 + include/noun/jets.h | 30 +++- jets/e/mule.c | 2 +- jets/f/ap.c | 2 +- jets/f/ut.c | 8 +- jets/f/ut_buss.c | 4 +- jets/f/ut_find.c | 6 +- jets/f/ut_gain.c | 2 +- jets/f/ut_lose.c | 2 +- jets/f/ut_mint.c | 6 +- jets/f/ut_mull.c | 4 +- jets/f/ut_play.c | 4 +- jets/f/ut_tack.c | 2 +- noun/jets.c | 306 ++++++++++++++++++++++++++++++++++++++-- noun/manage.c | 10 +- noun/nock.c | 7 +- 16 files changed, 346 insertions(+), 50 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 294a40b01..58f4a1c8f 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -130,6 +130,7 @@ struct { // jet dashboard u3p(u3h_root) war_p; // warm state u3p(u3h_root) cod_p; // cold state + u3p(u3h_root) han_p; // hank cache } jed; struct { // bytecode state diff --git a/include/noun/jets.h b/include/noun/jets.h index 69bf69262..fad8d354a 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -111,13 +111,22 @@ void u3j_clear(void); + /* u3j_cook(): + ** + ** Execute hook from core, call site cached by arbitrary c string + */ + u3_noun + u3j_cook(const c3_c* key_c, + u3_noun cor, + const c3_c* tam_c); + /* u3j_hook(): ** ** Execute hook from core. */ u3_noun u3j_hook(u3_noun cor, - const c3_c* tam_c); + const c3_c* tam_c); /* u3j_soft(): ** @@ -125,7 +134,7 @@ */ u3_noun u3j_soft(u3_noun cor, - const c3_c* tam_c); + const c3_c* tam_c); /* u3j_spot(): ** @@ -191,7 +200,7 @@ /* u3j_reap(): promote jet state. RETAINS. */ void - u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p); + u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p); /* u3j_rite_mine(): mine cor with clu, using u3j_rite for caching */ @@ -210,6 +219,11 @@ void u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o); + /* u3j_site_ream(): refresh u3j_site after restoring from checkpoint + */ + void + u3j_site_ream(u3j_site* sit_u); + /* u3j_site_kick(): kick a core with a u3j_site cache. */ u3_weak @@ -234,3 +248,13 @@ */ c3_w u3j_site_mark(u3j_site* sit_u); + + /* u3j_mark(): mark jet state for gc. + */ + c3_w + u3j_mark(void); + + /* u3j_free(): free jet state. + */ + void + u3j_free(void); diff --git a/jets/e/mule.c b/jets/e/mule.c index 99afc0d34..3f74b7326 100644 --- a/jets/e/mule.c +++ b/jets/e/mule.c @@ -12,7 +12,7 @@ return u3m_bail(c3__exit); } else { - u3_noun hok = u3j_hook(u3k(cor), "mute"); + u3_noun hok = u3j_cook("u3we_mule-mute", u3k(cor), "mute"); /* this takes advantage of the fact that mute's result, at the typeless * C/Nock level, is identical to what a typed mule would produce, diff --git a/jets/f/ap.c b/jets/f/ap.c index 09cbac822..ad5bddfb7 100644 --- a/jets/f/ap.c +++ b/jets/f/ap.c @@ -991,7 +991,7 @@ _ap_core(u3_noun ter, u3_noun gen) { - u3_noun gat = u3j_hook(u3k(ter), "ap"); + u3_noun gat = u3j_cook("_ap_core-ap", u3k(ter), "ap"); return u3i_molt(gat, u3x_sam, u3k(gen), 0); } diff --git a/jets/f/ut.c b/jets/f/ut.c index 7b07aa534..9fcf3ec1a 100644 --- a/jets/f/ut.c +++ b/jets/f/ut.c @@ -14,7 +14,7 @@ u3_noun typ) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0); - u3_noun ret = u3j_hook(u3k(von), "dune"); + u3_noun ret = u3j_cook("u3qfu_duck-dune", u3k(von), "dune"); u3z(von); return ret; @@ -28,7 +28,7 @@ u3_noun typ) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0); - u3_noun duq = u3j_hook(u3k(von), "dunk"); + u3_noun duq = u3j_cook("u3qfu_dung-dunk", u3k(von), "dunk"); u3_noun ret = u3i_molt(u3k(duq), u3x_sam, u3k(paz), 0); u3z(duq); @@ -44,7 +44,7 @@ u3_noun typ) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0); - u3_noun duq = u3j_hook(u3k(von), "dunk"); + u3_noun duq = u3j_cook("u3qfu_dunq-dunk", u3k(von), "dunk"); u3_noun paz = u3i_string(paz_c); u3_noun ret = u3i_molt(u3k(duq), u3x_sam, u3k(paz), 0); @@ -77,7 +77,7 @@ u3qfu_shew(u3_noun van, u3_noun mol) { - u3_noun sho = u3j_hook(u3k(van), "show"); + u3_noun sho = u3j_cook("u3qfu_shew-show", u3k(van), "show"); u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); u3z(sho); diff --git a/jets/f/ut_buss.c b/jets/f/ut_buss.c index df62f7367..144046d8a 100644 --- a/jets/f/ut_buss.c +++ b/jets/f/ut_buss.c @@ -13,7 +13,7 @@ u3_noun gen) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "buss"); + u3_noun gat = u3j_cook("_cqfu_buss-buss", von, "buss"); return u3n_kick_on(u3i_molt(gat, u3x_sam_2, @@ -29,7 +29,7 @@ u3_noun gen) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "busk"); + u3_noun gat = u3j_cook("_cqfu_busk-busk", von, "busk"); return u3n_kick_on(u3i_molt(gat, u3x_sam, diff --git a/jets/f/ut_find.c b/jets/f/ut_find.c index 430d22e96..935869218 100644 --- a/jets/f/ut_find.c +++ b/jets/f/ut_find.c @@ -19,7 +19,7 @@ u3_noun lap) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "felt"); + u3_noun gat = u3j_cook("u3qfu_felt-felt", von, "felt"); return u3n_kick_on(u3i_molt(gat, u3x_sam, @@ -34,7 +34,7 @@ u3_noun gen) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "fund"); + u3_noun gat = u3j_cook("u3qfu_fund-fund", von, "fund"); return u3n_kick_on(u3i_molt(gat, u3x_sam_2, @@ -50,7 +50,7 @@ u3_noun tor) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "fine"); + u3_noun gat = u3j_cook("u3qfu_fine-fine", von, "fine"); return u3n_kick_on(u3i_molt(gat, u3x_sam, diff --git a/jets/f/ut_gain.c b/jets/f/ut_gain.c index d27ee9a18..509740ab1 100644 --- a/jets/f/ut_gain.c +++ b/jets/f/ut_gain.c @@ -10,7 +10,7 @@ u3_noun gen) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "gain"); + u3_noun gat = u3j_cook("u3qfu_gain-gain", von, "gain"); return u3n_kick_on(u3i_molt(gat, u3x_sam, u3k(gen), 0)); } diff --git a/jets/f/ut_lose.c b/jets/f/ut_lose.c index 2e3e29b8f..16e9f6c0f 100644 --- a/jets/f/ut_lose.c +++ b/jets/f/ut_lose.c @@ -10,7 +10,7 @@ u3_noun gen) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "lose"); + u3_noun gat = u3j_cook("u3qfu_lose-lose", von, "lose"); return u3n_kick_on(u3i_molt(gat, u3x_sam, u3k(gen), 0)); } diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index c6c74c07d..b13d05ad8 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -261,7 +261,7 @@ u3_noun loc) { u3_noun mol = u3nc('o', u3k(loc)); - u3_noun sho = u3j_hook(u3k(van), "show"); + u3_noun sho = u3j_cook("_mint_loc-show", u3k(van), "show"); u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); u3z(mol); @@ -279,7 +279,7 @@ u3_noun rig) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "emin"); + u3_noun gat = u3j_cook("_mint_cnts-emin", von, "emin"); return u3n_kick_on(u3i_molt(gat, u3x_sam_2, @@ -839,7 +839,7 @@ } else { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "blow"); + u3_noun gat = u3j_cook("_mint_in-blow", von, "blow"); u3_noun pro; pro = u3n_kick_on(u3i_molt(gat, diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index b64bfcd8a..197cea7cd 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -32,7 +32,7 @@ u3_noun loc) { u3_noun mol = u3nc('o', u3k(loc)); - u3_noun sho = u3j_hook(u3k(van), "show"); + u3_noun sho = u3j_cook("_mull_loc-show", u3k(van), "show"); u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); u3z(mol); @@ -231,7 +231,7 @@ u3_noun rig) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "emul"); + u3_noun gat = u3j_cook("_mull_cnts-emul", von, "emul"); return u3n_kick_on(u3i_molt(gat, u3x_sam_2, diff --git a/jets/f/ut_play.c b/jets/f/ut_play.c index ed97fcc60..2ab4661a0 100644 --- a/jets/f/ut_play.c +++ b/jets/f/ut_play.c @@ -70,7 +70,7 @@ u3_noun loc) { u3_noun mol = u3nc('o', u3k(loc)); - u3_noun sho = u3j_hook(u3k(van), "show"); + u3_noun sho = u3j_cook("_play_loc-show", u3k(van), "show"); u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0); u3z(mol); @@ -107,7 +107,7 @@ u3_noun rig) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "epla"); + u3_noun gat = u3j_cook("_play_cnts-epla", von, "epla"); return u3n_kick_on(u3i_molt(gat, u3x_sam_2, diff --git a/jets/f/ut_tack.c b/jets/f/ut_tack.c index 6aebab50b..9328c43ae 100644 --- a/jets/f/ut_tack.c +++ b/jets/f/ut_tack.c @@ -10,7 +10,7 @@ u3_noun mur) { u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0); - u3_noun gat = u3j_hook(von, "tack"); + u3_noun gat = u3j_cook("u3qfu_tack-tack", von, "tack"); return u3n_kick_on(u3i_molt(gat, u3x_sam_2, diff --git a/noun/jets.c b/noun/jets.c index 0d8a33067..ca1c72c96 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -727,11 +727,12 @@ _cj_hook_in(u3_noun cor, */ u3_noun u3j_soft(u3_noun cor, - const c3_c* tam_c) + const c3_c* tam_c) { u3_noun pro; - + u3t_on(glu_o); pro = _cj_hook_in(cor, tam_c, c3n); + u3t_off(glu_o); return pro; } @@ -739,14 +740,147 @@ u3j_soft(u3_noun cor, */ u3_noun u3j_hook(u3_noun cor, - const c3_c* tam_c) + const c3_c* tam_c) { u3_noun pro; - + u3t_on(glu_o); pro = _cj_hook_in(cor, tam_c, c3y); + u3t_off(glu_o); return pro; } +typedef struct { + u3_weak hax; + u3j_site sit_u; +} _cj_hank; + +static _cj_hank* +_cj_hank_find(u3_noun pre, u3_noun tam) +{ + u3_noun key = u3nc(u3k(pre), u3k(tam)); + u3_noun got = u3h_git(u3R->jed.han_p, key); + if ( u3_none != got ) { + u3z(key); + return u3to(_cj_hank, got); + } + else { + _cj_hank* new_u = u3a_walloc(c3_wiseof(_cj_hank)); + u3a_road* rod_u = u3R; + while ( rod_u->par_p && u3_none == got ) { + rod_u = u3to(u3a_road, rod_u->par_p); + got = u3h_git(u3R->jed.han_p, key); + } + if ( u3_none == got ) { + new_u->hax = u3_none; + } + else { + _cj_hank* old_u = u3to(_cj_hank, got); + if ( u3_none != (new_u->hax = old_u->hax) ) { + u3j_site_copy(&(new_u->sit_u), &(old_u->sit_u), c3n); + } + } + u3h_put(u3R->jed.han_p, key, u3a_outa(new_u)); + u3z(key); + return new_u; + } +} + +static c3_o +_cj_hank_fine(_cj_hank* han_u, u3_noun cor, u3_noun *inn) +{ + u3_noun hax = han_u->hax; + if ( u3_none == hax ) { + return c3n; + } + else { + *inn = u3r_at(hax, cor); + if ( u3_none == *inn ) { + return c3n; + } + else { + u3j_site* sit_u = &(han_u->sit_u); + c3_assert(u3_none != sit_u->loc); + return _cj_fine(*inn, sit_u->fin_u); + } + } +} + +static void +_cj_hank_lose(_cj_hank* han_u) +{ + if ( u3_none != han_u->hax ) { + u3z(han_u->hax); + u3j_site_lose(&(han_u->sit_u)); + } +} + +static u3_noun +_cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) +{ + u3_weak loc, col; + u3_noun got, pat, nam, huc; + u3_noun hax = 1; + u3j_site* sit_u = &(han_u->sit_u); + + if ( c3n == u3du(cor) ) { + return u3m_bail(c3__fail); + } + + if ( u3_none == (col = loc = _cj_spot(cor)) ) { + return u3m_bail(c3__fail); + } + + while ( 1 ) { + u3x_trel(loc, &pat, &nam, &huc); + got = u3qdb_get(huc, tam); + if ( u3_nul != got ) { + u3_noun fol = u3k(u3t(got)); + u3z(got); + sit_u->bat = u3k(u3h(cor)); + sit_u->loc = u3k(loc); + sit_u->fin_u = _cj_cast(cor, loc); + sit_u->fon_o = c3y; + if ( 0 == (sit_u->axe = _cj_axis(fol)) ) { + sit_u->jet_o = c3n; + sit_u->pog_u = u3n_find(fol); + } + else { + han_u->sit_u.pog_u = u3n_find(u3r_at(sit_u->axe, cor)); + han_u->sit_u.jet_o = _cj_nail(loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); + } + u3z(fol); + u3z(col); + han_u->hax = hax; + return cor; + } + else if ( c3n == u3h(pat) ) { + u3_noun dyn = u3t(pat), + axe = u3h(dyn), + xah; + cor = u3r_at(axe, cor); + loc = u3t(dyn); + xah = u3qc_peg(axe, hax); + u3z(hax); + hax = xah; + } + else { + u3_noun sat = u3t(pat); + if ( c3y == u3h(sat) ) { + return u3m_bail(c3__fail); + } + else { + u3_noun xah; + cor = u3t(cor); + loc = u3t(sat); + xah = u3qc_peg(3, hax); + u3z(hax); + hax = xah; + } + } + } +} + /* u3j_kick(): new kick. ** ** `axe` is RETAINED by the caller; `cor` is RETAINED iff there @@ -947,6 +1081,18 @@ u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) } } +/* u3j_site_ream(): refresh u3j_site after restoring from checkpoint +*/ +void +u3j_site_ream(u3j_site* sit_u) +{ + if ( u3_none != sit_u->loc ) { + u3z(sit_u->lab); + sit_u->jet_o = _cj_nail(sit_u->loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); + } +} + static u3_weak _cj_site_lock(u3_noun cor, u3j_site* sit_u) { @@ -994,14 +1140,11 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) return pro; } -/* u3j_site_kick(): kick a core with a u3j_site cache. - */ -u3_weak -u3j_site_kick(u3_noun cor, u3j_site* sit_u) +static u3_weak +_cj_site_kick(u3_noun cor, u3j_site* sit_u) { u3_weak loc, pro; - u3t_on(glu_o); loc = pro = u3_none; if ( u3_none != sit_u->loc ) { @@ -1055,6 +1198,47 @@ u3j_site_kick(u3_noun cor, u3j_site* sit_u) pro = _cj_site_lock(cor, sit_u); } + return pro; +} + +/* u3j_site_kick(): kick a core with a u3j_site cache. + */ +u3_weak +u3j_site_kick(u3_noun cor, u3j_site* sit_u) +{ + u3_weak pro; + u3t_on(glu_o); + pro = _cj_site_kick(cor, sit_u); + u3t_off(glu_o); + return pro; +} + +/* u3j_cook(): Execute hook from core, call site cached by arbitrary c string +*/ +u3_noun +u3j_cook(const c3_c* key_c, + u3_noun cor, + const c3_c* tam_c) +{ + u3_noun pro, key, tam, inn; + _cj_hank* han_u; + + u3t_on(glu_o); + key = u3i_string(key_c); + tam = u3i_string(tam_c); + han_u = _cj_hank_find(key, tam); + if ( c3n == _cj_hank_fine(han_u, cor, &inn) ) { + _cj_hank_lose(han_u); + inn = _cj_hank_fill(han_u, tam, cor); + } + pro = _cj_site_kick(u3k(inn), &(han_u->sit_u)); + if ( u3_none == pro ) { + pro = u3n_burn(inn, han_u->sit_u.pog_u); + } + u3z(cor); + + u3z(key); + u3z(tam); u3t_off(glu_o); return pro; } @@ -1062,15 +1246,21 @@ u3j_site_kick(u3_noun cor, u3j_site* sit_u) /* u3j_kink(): kick either by jet or by nock. */ u3_noun -u3j_kink(u3_noun cor, - u3_noun axe) +u3j_kink(u3_noun cor, u3_noun axe) { u3_weak pro = u3j_kick(cor, axe); if ( u3_none != pro ) { return pro; - } else { - return u3n_nock_on(cor, u3nq(9, axe, 0, 1)); + } + else { + u3_weak fol = u3r_at(axe, cor); + if ( u3_none == fol ) { + return u3m_bail(c3__exit); + } + else { + return u3n_nock_on(cor, u3k(fol)); + } } } @@ -1387,13 +1577,44 @@ _cj_cold_reap(u3_noun kev) u3z(ser); u3z(bat); } +static void +_cj_hank_reap(u3_noun kev) +{ + u3_noun key = u3a_take(u3h(kev)); + u3_noun got = u3h_git(u3R->jed.han_p, key); + _cj_hank* nah_u = u3to(_cj_hank, u3t(kev)); + _cj_hank* han_u; + + if ( u3_none != got ) { + if ( u3_none != nah_u->hax ) { + u3_weak old; + han_u = u3to(_cj_hank, got); + old = han_u->hax; + han_u->hax = u3a_take(nah_u->hax); + u3j_site_copy(&(han_u->sit_u), &(nah_u->sit_u), c3y); + if ( u3_none != old ) { + u3z(old); + } + } + } + else if ( u3_none != nah_u->hax ) { + han_u = u3a_walloc(c3_wiseof(_cj_hank)); + han_u->hax = u3a_take(nah_u->hax); + u3j_site_copy(&(han_u->sit_u), &(nah_u->sit_u), c3n); + u3h_put(u3R->jed.han_p, key, u3a_outa(han_u)); + } + + u3z(key); +} + /* u3j_reap(): promote jet state. */ void -u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p) +u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p) { u3h_walk(cod_p, _cj_cold_reap); u3h_walk(war_p, _cj_warm_reap); + u3h_walk(han_p, _cj_hank_reap); } /* _cj_ream(): ream list of battery registry pairs. RETAIN. @@ -1481,7 +1702,13 @@ _cj_warm_tap(u3_noun kev, void* wit) *rel = u3nc(u3k(kev), *rel); } -/* u3j_ream(): rebuild warm state +static void +_cj_ream_hank(u3_noun kev) +{ + u3j_site_ream(&(u3to(_cj_hank, u3t(kev))->sit_u)); +} + +/* u3j_ream(): rebuild jet state */ void u3j_ream(void) @@ -1493,6 +1720,8 @@ u3j_ream(void) u3h_walk_with(u3R->jed.cod_p, _cj_warm_tap, &rel); _cj_ream(rel); u3z(rel); + + u3h_walk(u3R->jed.han_p, _cj_ream_hank); } static c3_w @@ -1569,6 +1798,53 @@ u3j_site_mark(u3j_site* sit_u) return tot_w; } +static void +_cj_mark_hank(u3_noun kev, void* dat) +{ + c3_w* tot_w = (c3_w*) dat; + _cj_hank* han_u = u3to(_cj_hank, u3t(kev)); + *tot_w += u3a_mark_ptr(han_u); + if ( u3_none != han_u->hax ) { + *tot_w += u3a_mark_noun(han_u->hax); + *tot_w += u3j_site_mark(&(han_u->sit_u)); + } +} + +/* u3j_mark(): mark jet state for gc. +*/ +c3_w +u3j_mark(void) +{ + c3_w tot_w = 0; + tot_w += u3h_mark(u3R->jed.war_p); + tot_w += u3h_mark(u3R->jed.cod_p); + tot_w += u3h_mark(u3R->jed.han_p); + u3h_walk_with(u3R->jed.han_p, _cj_mark_hank, &tot_w); + return tot_w; +} + +static void +_cj_free_hank(u3_noun kev) +{ + _cj_hank* han_u = u3to(_cj_hank, u3t(kev)); + if ( u3_none != han_u->hax ) { + u3z(han_u->hax); + u3j_site_lose(&(han_u->sit_u)); + } + u3a_wfree(han_u); +} + +/* u3j_free(): free jet state. +*/ +void +u3j_free(void) +{ + u3h_walk(u3R->jed.han_p, _cj_free_hank); + u3h_free(u3R->jed.war_p); + u3h_free(u3R->jed.cod_p); + u3h_free(u3R->jed.han_p); +} + /* XX FIXME: move to u3.md |% += location $: pattern=(each static dynamic) diff --git a/noun/manage.c b/noun/manage.c index 29e2f69c6..5334ee227 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -460,6 +460,7 @@ _pave_parts(void) u3R->cax.har_p = u3h_new(); u3R->jed.war_p = u3h_new(); u3R->jed.cod_p = u3h_new(); + u3R->jed.han_p = u3h_new(); u3R->byc.har_p = u3h_new(); } @@ -469,8 +470,7 @@ c3_w u3m_mark(void) { c3_w tot_w = 0; - tot_w += u3h_mark(u3R->jed.war_p); - tot_w += u3h_mark(u3R->jed.cod_p); + tot_w += u3j_mark(); tot_w += u3n_bark(); tot_w += u3a_mark_noun(u3R->ski.gul); tot_w += u3a_mark_noun(u3R->bug.tax); @@ -509,8 +509,7 @@ void u3m_clear(void) { u3h_free(u3R->cax.har_p); - u3h_free(u3R->jed.war_p); - u3h_free(u3R->jed.cod_p); + u3j_free(); u3n_bree(); } @@ -799,13 +798,14 @@ u3m_love(u3_noun pro) { u3p(u3h_root) cod_p = u3R->jed.cod_p; u3p(u3h_root) war_p = u3R->jed.war_p; + u3p(u3h_root) han_p = u3R->jed.han_p; u3p(u3h_root) byc_p = u3R->byc.har_p; u3m_fall(); pro = u3a_take(pro); - u3j_reap(cod_p, war_p); + u3j_reap(cod_p, war_p, han_p); u3n_beep(byc_p); u3R->cap_p = u3R->ear_p; diff --git a/noun/nock.c b/noun/nock.c index 9ffb15de9..9f1553858 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -2317,12 +2317,7 @@ _n_ream(u3_noun kev) c3_w i_w; u3n_prog* pog_u = u3to(u3n_prog, u3t(kev)); for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { - u3j_site* sit_u = &(pog_u->cal_u.sit_u[i_w]); - if ( u3_none != sit_u->loc ) { - u3z(sit_u->lab); - sit_u->jet_o = u3j_nail(sit_u->loc, sit_u->axe, - &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); - } + u3j_site_ream(&(pog_u->cal_u.sit_u[i_w])); } } From 62b8b655ee847dbc53a47e2079df0ba8c75c14f3 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 17:42:38 -0700 Subject: [PATCH 076/221] locally cached gates for things like turn --- include/noun/jets.h | 15 +++++++++++ jets/b/turn.c | 30 ++++++++++++++-------- noun/jets.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 11 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index fad8d354a..10ac03bae 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -229,6 +229,21 @@ u3_weak u3j_site_kick(u3_noun cor, u3j_site* sit_u); + /* u3j_gate_prep(): prepare a locally cached gate to call repeatedly. + */ + void + u3j_gate_prep(u3j_site* sit_u, u3_noun cor); + + /* u3j_gate_slam(): slam a site prepared by u3j_gate_find() with sample. + */ + u3_noun + u3j_gate_slam(u3j_site* sit_u, u3_noun sam); + + /* u3j_gate_lose(): clean up site prepared by u3j_gate_find(). + */ + void + u3j_gate_lose(u3j_site* sit_u); + /* u3j_rite_mark(): mark u3j_rite for gc. */ c3_w diff --git a/jets/b/turn.c b/jets/b/turn.c index 5489325f1..aa28fe29e 100644 --- a/jets/b/turn.c +++ b/jets/b/turn.c @@ -3,25 +3,33 @@ */ #include "all.h" + u3_noun + _turn_in(u3j_site* sit_u, u3_noun a) + { + if ( u3_nul == a ) { + return u3_nul; + } + else { + return u3nc( + u3j_gate_slam(sit_u, u3k(u3h(a))), + _turn_in(sit_u, u3t(a))); + } + } /* functions */ u3_noun u3qb_turn(u3_noun a, u3_noun b) { - if ( 0 == a ) { - return a; - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } - else { - u3_noun one = u3n_slam_on(u3k(b), u3k(u3h(a))); - u3_noun two = u3qb_turn(u3t(a), b); + u3_noun pro; + u3j_site sit_u; - return u3nc(one, two); - } + u3j_gate_prep(&sit_u, b); + pro = _turn_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; } + u3_noun u3wb_turn(u3_noun cor) { diff --git a/noun/jets.c b/noun/jets.c index ca1c72c96..057cc3db2 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1264,6 +1264,67 @@ u3j_kink(u3_noun cor, u3_noun axe) } } +/* u3j_gate_prep(): prepare a locally cached gate to call repeatedly. + */ +void +u3j_gate_prep(u3j_site* sit_u, u3_noun cor) +{ + u3_noun loc; + u3t_on(glu_o); + sit_u->axe = 2; + sit_u->bat = u3k(cor); // a lie, this isn't really the battery! + sit_u->pog_u = u3n_find(u3h(cor)); + if ( u3_none != (loc = sit_u->loc = _cj_spot(cor)) ) { + u3_noun pax = u3h(u3t(loc)), + pay = u3qc_cap(pax), + pam = u3qc_mas(pax); + if ( pam < 4 || 3 != pay || 3 != u3qc_cap(pam) ) { + // parent axis includes sample :( + sit_u->jet_o = c3n; + } + else { + sit_u->jet_o = _cj_nail(loc, 2, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); + } + u3z(pam); + } + u3t_off(glu_o); +} + +/* u3j_gate_slam(): slam a site prepared by u3j_gate_find() with sample. + */ +u3_noun +u3j_gate_slam(u3j_site* sit_u, u3_noun sam) +{ + u3_weak pro; + u3_noun cor; + u3t_on(glu_o); + pro = u3_none; + cor = u3nt(u3k(u3h(sit_u->bat)), + sam, + u3k(u3t(u3t(sit_u->bat)))); + if ( (u3_none != sit_u->loc) && (c3y == sit_u->jet_o) ) { + pro = _cj_site_kick_hot(cor, sit_u); + } + if ( u3_none == pro ) { + pro = u3n_burn(cor, sit_u->pog_u); + } + u3t_off(glu_o); + return pro; +} + +/* u3j_gate_lose(): clean up site prepared by u3j_gate_find(). + */ +void +u3j_gate_lose(u3j_site* sit_u) +{ + u3z(sit_u->bat); + if ( u3_none != sit_u->loc ) { + u3z(sit_u->loc); + u3z(sit_u->lab); + } +} + /* _cj_jit(): generate arbitrary warm jet-associated data. RETAIN. */ static u3_noun From cfc0c6e8d7a2e82e132886a39f3714b602e7e040 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 18:05:02 -0700 Subject: [PATCH 077/221] gate prep in skip --- jets/b/skip.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/jets/b/skip.c b/jets/b/skip.c index 6f44643d6..ac9538b58 100644 --- a/jets/b/skip.c +++ b/jets/b/skip.c @@ -3,12 +3,8 @@ */ #include "all.h" - -/* functions -*/ u3_noun - u3qb_skip(u3_noun a, - u3_noun b) + _skip_in(u3j_site* sit_u, u3_noun a) { if ( 0 == a ) { return a; @@ -16,8 +12,8 @@ else if ( c3n == u3du(a) ) { return u3_none; } else { - u3_noun hoz = u3n_slam_on(u3k(b), u3k(u3h(a))); - u3_noun vyr = u3qb_skip(u3t(a), b); + u3_noun hoz = u3j_gate_slam(sit_u, u3k(u3h(a))); + u3_noun vyr = _skip_in(sit_u, u3t(a)); switch ( hoz ) { case c3y: return vyr; @@ -28,6 +24,20 @@ } } } + +/* functions +*/ + u3_noun + u3qb_skip(u3_noun a, + u3_noun b) + { + u3j_site sit_u; + u3_noun pro; + u3j_gate_prep(&sit_u, b); + pro = _skip_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; + } u3_noun u3wb_skip(u3_noun cor) { From d997f035aecf06b5f7ec7a8fe8204778c52b6828 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 26 Apr 2018 18:17:30 -0700 Subject: [PATCH 078/221] murn --- jets/b/murn.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/jets/b/murn.c b/jets/b/murn.c index 08647c444..d177137f4 100644 --- a/jets/b/murn.c +++ b/jets/b/murn.c @@ -3,11 +3,8 @@ */ #include "all.h" - -/* functions -*/ u3_noun - u3qb_murn(u3_noun a, u3_noun b) + _murn_in(u3j_site* sit_u, u3_noun a) { if ( 0 == a ) { return a; @@ -16,8 +13,8 @@ return u3m_bail(c3__exit); } else { - u3_noun one = u3n_slam_on(u3k(b), u3k(u3h(a))); - u3_noun two = u3qb_murn(u3t(a), b); + u3_noun one = u3j_gate_slam(sit_u, u3k(u3h(a))); + u3_noun two = _murn_in(sit_u, u3t(a)); u3_noun nex; switch ( u3ud(one) ) { @@ -32,6 +29,19 @@ } } } + +/* functions +*/ + u3_noun + u3qb_murn(u3_noun a, u3_noun b) + { + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, b); + pro = _murn_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; + } u3_noun u3wb_murn(u3_noun cor) { From 48eb2fee9b2689f871215e2a6fb6e92a0a26d790 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 09:33:33 -0700 Subject: [PATCH 079/221] roll --- jets/b/roll.c | 46 +++++++++++++++++++++++++--------------------- jets/b/skip.c | 2 +- jets/b/turn.c | 2 +- noun/jets.c | 3 +++ 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/jets/b/roll.c b/jets/b/roll.c index 4700d3c99..bedff9abe 100644 --- a/jets/b/roll.c +++ b/jets/b/roll.c @@ -3,6 +3,25 @@ */ #include "all.h" + static u3_noun + _roll_in(u3j_site* sit_u, u3_noun a, u3_noun b) + { + if ( 0 == a ) { + return u3k(b); + } + else if ( c3n == u3du(a) ) { + return u3m_bail(c3__exit); + } + else { + u3_noun gim = u3k(u3h(a)); + u3_noun zor = u3k(b); + u3_noun daz = u3j_gate_slam(sit_u, u3nc(gim, zor)); + u3_noun hox = _roll_in(sit_u, u3t(a), daz); + u3z(daz); + return hox; + } + } + /* functions */ @@ -10,27 +29,12 @@ u3qb_roll(u3_noun a, u3_noun b) { - if ( 0 == a ) { - return u3k(u3r_at(u3x_sam_3, b)); - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } - else { - u3_noun gim = u3k(u3h(a)); - u3_noun zor = u3k(u3r_at(u3x_sam_3, b)); - u3_noun daz = u3n_slam_on(u3k(b), u3nc(gim, zor)); - u3_noun vel = u3i_molt(u3k(b), u3x_sam_3, daz, 0); - - if ( u3_none == vel ) { - return u3m_bail(c3__exit); - } else { - u3_noun hox = u3qb_roll(u3t(a), vel); - - u3z(vel); - return hox; - } - } + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, b); + pro = _roll_in(&sit_u, a, u3r_at(u3x_sam_3, b)); + u3j_gate_lose(&sit_u); + return pro; } u3_noun u3wb_roll(u3_noun cor) diff --git a/jets/b/skip.c b/jets/b/skip.c index ac9538b58..7dc431a1f 100644 --- a/jets/b/skip.c +++ b/jets/b/skip.c @@ -3,7 +3,7 @@ */ #include "all.h" - u3_noun + static u3_noun _skip_in(u3j_site* sit_u, u3_noun a) { if ( 0 == a ) { diff --git a/jets/b/turn.c b/jets/b/turn.c index aa28fe29e..42ba67e6e 100644 --- a/jets/b/turn.c +++ b/jets/b/turn.c @@ -3,7 +3,7 @@ */ #include "all.h" - u3_noun + static u3_noun _turn_in(u3j_site* sit_u, u3_noun a) { if ( u3_nul == a ) { diff --git a/noun/jets.c b/noun/jets.c index 057cc3db2..9a9a76fcf 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1271,6 +1271,9 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) { u3_noun loc; u3t_on(glu_o); + if ( c3n == u3du(cor) || c3n == u3du(u3t(cor)) ) { + u3m_bail(c3__exit); + } sit_u->axe = 2; sit_u->bat = u3k(cor); // a lie, this isn't really the battery! sit_u->pog_u = u3n_find(u3h(cor)); From 93965fcd8a9f9dc2b7f681ac64b2e7898752eb8d Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 09:42:15 -0700 Subject: [PATCH 080/221] levy --- jets/b/levy.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/jets/b/levy.c b/jets/b/levy.c index 2a58ce1c4..76d437371 100644 --- a/jets/b/levy.c +++ b/jets/b/levy.c @@ -3,12 +3,8 @@ */ #include "all.h" - -/* functions -*/ - u3_noun - u3qb_levy(u3_noun a, - u3_noun b) + static u3_noun + _levy_in(u3j_site* sit_u, u3_noun a) { if ( 0 == a ) { return c3y; @@ -18,14 +14,28 @@ if ( c3n == u3du(a) ) { return u3m_bail(c3__exit); } - else switch ( (loz = u3n_slam_on(u3k(b), u3k(u3h(a)))) ) { - case c3y: return u3qb_levy(u3t(a), b); + else switch ( (loz = u3j_gate_slam(sit_u, u3k(u3h(a)))) ) { + case c3y: return _levy_in(sit_u, u3t(a)); case c3n: return c3n; default: u3z(loz); return u3m_bail(c3__exit); } } } + +/* functions +*/ + u3_noun + u3qb_levy(u3_noun a, + u3_noun b) + { + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, b); + pro = _levy_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; + } u3_noun u3wb_levy(u3_noun cor) { From 2b2dbf7a6dfd96353908d06394663d38b610c357 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 09:50:20 -0700 Subject: [PATCH 081/221] skim --- jets/b/skim.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/jets/b/skim.c b/jets/b/skim.c index 003e461b1..0af438cd3 100644 --- a/jets/b/skim.c +++ b/jets/b/skim.c @@ -3,12 +3,8 @@ */ #include "all.h" - -/* functions -*/ - u3_noun - u3qb_skim(u3_noun a, - u3_noun b) + static u3_noun + _skim_in(u3j_site* sit_u, u3_noun a) { if ( 0 == a ) { return a; @@ -16,8 +12,8 @@ else if ( c3n == u3du(a) ) { return u3m_bail(c3__exit); } else { - u3_noun hoz = u3n_slam_on(u3k(b), u3k(u3h(a))); - u3_noun vyr = u3qb_skim(u3t(a), b); + u3_noun hoz = u3j_gate_slam(sit_u, u3k(u3h(a))); + u3_noun vyr = _skim_in(sit_u, u3t(a)); switch ( hoz ) { case c3y: return u3nc(u3k(u3h(a)), vyr); @@ -28,9 +24,22 @@ } } } + +/* functions +*/ u3_noun - u3wb_skim( - u3_noun cor) + u3qb_skim(u3_noun a, + u3_noun b) + { + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, b); + pro = _skim_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; + } + u3_noun + u3wb_skim(u3_noun cor) { u3_noun a, b; From 25ae735a7e3ebd2f33fd6ae0932d6325d8c2ced8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 10:09:53 -0700 Subject: [PATCH 082/221] reel --- jets/b/reel.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/jets/b/reel.c b/jets/b/reel.c index e78e7c8ca..567fc9c2b 100644 --- a/jets/b/reel.c +++ b/jets/b/reel.c @@ -3,6 +3,22 @@ */ #include "all.h" + static u3_noun + _reel_in(u3j_site* sit_u, u3_noun a, u3_noun b) + { + if ( 0 == a ) { + return u3k(b); + } + else if ( c3n == u3du(a) ) { + return u3m_bail(c3__exit); + } + else { + u3_noun gim = u3k(u3h(a)); + u3_noun hur = _reel_in(sit_u, u3t(a), b); + + return u3j_gate_slam(sit_u, u3nc(gim, hur)); + } + } /* functions */ @@ -10,18 +26,12 @@ u3qb_reel(u3_noun a, u3_noun b) { - if ( 0 == a ) { - return u3k(u3r_at(u3x_sam_3, b)); - } - else if ( c3n == u3du(a) ) { - return u3m_bail(c3__exit); - } - else { - u3_noun gim = u3k(u3h(a)); - u3_noun hur = u3qb_reel(u3t(a), b); - - return u3n_slam_on(u3k(b), u3nc(gim, hur)); - } + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, b); + pro = _reel_in(&sit_u, a, u3r_at(u3x_sam_3, b)); + u3j_gate_lose(&sit_u); + return pro; } u3_noun u3wb_reel(u3_noun cor) From d139b76ece47d95feccd303c4bd232893e7f18b0 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 10:21:09 -0700 Subject: [PATCH 083/221] lien --- jets/b/lien.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/jets/b/lien.c b/jets/b/lien.c index 6768ab511..cede8fa83 100644 --- a/jets/b/lien.c +++ b/jets/b/lien.c @@ -3,12 +3,8 @@ */ #include "all.h" - -/* functions -*/ - u3_noun - u3qb_lien(u3_noun a, - u3_noun b) + static u3_noun + _lien_in(u3j_site* sit_u, u3_noun a) { if ( 0 == a ) { return c3n; @@ -18,14 +14,28 @@ if ( c3n == u3du(a) ) { return u3m_bail(c3__exit); } - else switch ( (loz = u3n_slam_on(u3k(b), u3k(u3h(a)))) ) { + else switch ( (loz = u3j_gate_slam(sit_u, u3k(u3h(a)))) ) { case c3y: return c3y; - case c3n: return u3qb_lien(u3t(a), b); + case c3n: return _lien_in(sit_u, u3t(a)); default: u3z(loz); return u3m_bail(c3__exit); } } } + +/* functions +*/ + u3_noun + u3qb_lien(u3_noun a, + u3_noun b) + { + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, b); + pro = _lien_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; + } u3_noun u3wb_lien(u3_noun cor) { From f42fef9e712d0f27e287964d81945b52c29cfad8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 10:30:36 -0700 Subject: [PATCH 084/221] skid --- jets/b/skid.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/jets/b/skid.c b/jets/b/skid.c index 6bb6626ec..85269436d 100644 --- a/jets/b/skid.c +++ b/jets/b/skid.c @@ -3,12 +3,8 @@ */ #include "all.h" - -/* functions -*/ - u3_noun - u3qb_skid(u3_noun a, - u3_noun b) + static u3_noun + _skid_in(u3j_site* sit_u, u3_noun a) { if ( 0 == a ) { return u3nc(u3_nul, u3_nul); @@ -16,8 +12,8 @@ else if ( c3n == u3du(a) ) { return u3m_bail(c3__exit); } else { - u3_noun acc = u3qb_skid(u3t(a), b); - u3_noun hoz = u3n_slam_on(u3k(b), u3k(u3h(a))); + u3_noun acc = _skid_in(sit_u, u3t(a)); + u3_noun hoz = u3j_gate_slam(sit_u, u3k(u3h(a))); u3_noun nex; if ( c3y == hoz ) { @@ -32,6 +28,20 @@ return nex; } } + +/* functions +*/ + u3_noun + u3qb_skid(u3_noun a, + u3_noun b) + { + u3_noun pro; + u3j_site sit_u; + u3j_gate_prep(&sit_u, b); + pro = _skid_in(&sit_u, a); + u3j_gate_lose(&sit_u); + return pro; + } u3_noun u3wb_skid(u3_noun cor) { From 67c1035d57882fdbb89cdec9e44c44ae167624a8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 12:22:39 -0700 Subject: [PATCH 085/221] fix profiling --- include/noun/jets.h | 12 -------- noun/jets.c | 68 ++++++++++++++++++++++++++++----------------- noun/nock.c | 2 +- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 10ac03bae..a0ef42f53 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -160,18 +160,6 @@ u3j_nail(u3_noun loc, u3_noun axe, u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u); - /* u3j_kick_hot(): Try to kick by jet with resolved hot state. - ** If no kick, produce u3_none. - ** - ** `cor` is RETAINED iff there is no kick, TRANSFERRED if one. - ** `axe` is RETAINED. - */ - u3_weak - u3j_hock(u3_noun cor, - u3j_core* cop_u, - u3j_harm* ham_u, - u3_atom axe); - /* u3j_kick(): try to kick by jet. If no kick, produce u3_none. ** ** `axe` is RETAINED by the caller; `cor` is RETAINED iff there diff --git a/noun/jets.c b/noun/jets.c index 9a9a76fcf..4a6088b6e 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -618,22 +618,6 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) } } -/* u3j_hock(): Try to kick by jet with resolved hot state. -** If no kick, produce u3_none. -** -** `cor` is RETAINED iff there is no kick, TRANSFERRED if one. -** `axe` is RETAINED. -*/ -u3_weak -u3j_hock(u3_noun cor, - u3j_core* cop_u, - u3j_harm* ham_u, - u3_atom axe) -{ - // this is where you would trace, if we traced this - return _cj_kick_z(cor, cop_u, ham_u, axe); -} - /* _cj_hook_in(): execute hook from core, or fail. */ static u3_noun @@ -667,7 +651,9 @@ _cj_hook_in(u3_noun cor, u3z(got); axe_l = _cj_axis(fol); if ( 0 == axe_l ) { + u3t_off(glu_o); pro = u3n_nock_on(cor, fol); + u3t_on(glu_o); } else { c3_l jax_l, inx_l; @@ -682,6 +668,7 @@ _cj_hook_in(u3_noun cor, // Tricky: the above case would work here too, but would // disable jet_o and create some infinite recursions. // + u3t_off(glu_o); if ( (c3n == jet_o) || (u3_none == (inx_l = u3kdb_get(u3k(hap), axe_l))) || (u3_none == (pro = _cj_kick_z(cor, @@ -690,6 +677,7 @@ _cj_hook_in(u3_noun cor, axe_l))) ) { pro = u3n_nock_on(cor, u3k(u3x_at(axe_l, cor))); } + u3t_on(glu_o); u3z(act); } u3z(loc); @@ -814,6 +802,26 @@ _cj_hank_lose(_cj_hank* han_u) } } +static u3_noun +_cj_burn(u3_noun cor, u3n_prog* pog_u) +{ + u3_noun pro; + u3t_off(glu_o); + pro = u3n_burn(cor, pog_u); + u3t_on(glu_o); + return pro; +} + +static u3n_prog* +_cj_prog(u3_noun fol) +{ + u3n_prog* pog_u; + u3t_off(glu_o); + pog_u = u3n_find(fol); + u3t_on(glu_o); + return pog_u; +} + static u3_noun _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) { @@ -842,10 +850,10 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) sit_u->fon_o = c3y; if ( 0 == (sit_u->axe = _cj_axis(fol)) ) { sit_u->jet_o = c3n; - sit_u->pog_u = u3n_find(fol); + sit_u->pog_u = _cj_prog(fol); } else { - han_u->sit_u.pog_u = u3n_find(u3r_at(sit_u->axe, cor)); + han_u->sit_u.pog_u = _cj_prog(u3r_at(sit_u->axe, cor)); han_u->sit_u.jet_o = _cj_nail(loc, sit_u->axe, &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); } @@ -1100,7 +1108,7 @@ _cj_site_lock(u3_noun cor, u3j_site* sit_u) (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { return u3_none; } - sit_u->pog_u = u3n_find(u3r_at(sit_u->axe, cor)); + sit_u->pog_u = _cj_prog(u3r_at(sit_u->axe, cor)); if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); } @@ -1113,29 +1121,36 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) { u3_weak pro = u3_none; c3_o jet_o = sit_u->jet_o; - if ( c3n == __(u3C.wag_w & u3o_debug_cpu) ) { + c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); + if ( c3n == pof_o ) { if ( c3n == jet_o ) { pro = u3_none; } else { + u3t_off(glu_o); pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); + u3t_on(glu_o); } if ( u3_none == pro ) { pro = _cj_site_lock(cor, sit_u); } } else { - u3t_come(sit_u->lab); + pof_o = u3t_come(sit_u->lab); if ( c3y == jet_o ) { + u3t_off(glu_o); pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); + u3t_on(glu_o); } if ( u3_none == pro ) { pro = _cj_site_lock(cor, sit_u); if ( u3_none == pro ) { - pro = u3n_burn(cor, sit_u->pog_u); + pro = _cj_burn(cor, sit_u->pog_u); } } - u3t_flee(); + if ( c3y == pof_o ) { + u3t_flee(); + } } return pro; } @@ -1233,7 +1248,7 @@ u3j_cook(const c3_c* key_c, } pro = _cj_site_kick(u3k(inn), &(han_u->sit_u)); if ( u3_none == pro ) { - pro = u3n_burn(inn, han_u->sit_u.pog_u); + pro = _cj_burn(inn, han_u->sit_u.pog_u); } u3z(cor); @@ -1276,7 +1291,7 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) } sit_u->axe = 2; sit_u->bat = u3k(cor); // a lie, this isn't really the battery! - sit_u->pog_u = u3n_find(u3h(cor)); + sit_u->pog_u = _cj_prog(u3h(cor)); if ( u3_none != (loc = sit_u->loc = _cj_spot(cor)) ) { u3_noun pax = u3h(u3t(loc)), pay = u3qc_cap(pax), @@ -1301,6 +1316,7 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam) { u3_weak pro; u3_noun cor; + u3t_on(glu_o); pro = u3_none; cor = u3nt(u3k(u3h(sit_u->bat)), @@ -1310,7 +1326,7 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam) pro = _cj_site_kick_hot(cor, sit_u); } if ( u3_none == pro ) { - pro = u3n_burn(cor, sit_u->pog_u); + pro = _cj_burn(cor, sit_u->pog_u); } u3t_off(glu_o); return pro; diff --git a/noun/nock.c b/noun/nock.c index 9f1553858..494ffc801 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1496,7 +1496,7 @@ _n_kick(u3_noun cor, u3j_site* sit_u) u3_weak pro; u3t_off(noc_o); pro = u3j_site_kick(cor, sit_u); - u3t_off(noc_o); + u3t_on(noc_o); return pro; } From 61c3398ad9df53d7348c31c89d5473c4cb0c6a7f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 27 Apr 2018 15:19:47 -0700 Subject: [PATCH 086/221] fix memory error in new roll jet --- jets/b/roll.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/jets/b/roll.c b/jets/b/roll.c index bedff9abe..448c25275 100644 --- a/jets/b/roll.c +++ b/jets/b/roll.c @@ -7,22 +7,17 @@ _roll_in(u3j_site* sit_u, u3_noun a, u3_noun b) { if ( 0 == a ) { - return u3k(b); + return b; } else if ( c3n == u3du(a) ) { return u3m_bail(c3__exit); } else { - u3_noun gim = u3k(u3h(a)); - u3_noun zor = u3k(b); - u3_noun daz = u3j_gate_slam(sit_u, u3nc(gim, zor)); - u3_noun hox = _roll_in(sit_u, u3t(a), daz); - u3z(daz); - return hox; + b = u3j_gate_slam(sit_u, u3nc(u3k(u3h(a)), b)); + return _roll_in(sit_u, u3t(a), b); } } - /* functions */ u3_noun @@ -32,7 +27,7 @@ u3_noun pro; u3j_site sit_u; u3j_gate_prep(&sit_u, b); - pro = _roll_in(&sit_u, a, u3r_at(u3x_sam_3, b)); + pro = _roll_in(&sit_u, a, u3k(u3r_at(u3x_sam_3, b))); u3j_gate_lose(&sit_u); return pro; } From 35f137453e36f61652100c8f44102f6154e4e40e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 29 Apr 2018 21:29:25 -0700 Subject: [PATCH 087/221] safer memory for reel --- jets/b/reel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jets/b/reel.c b/jets/b/reel.c index 567fc9c2b..474e43280 100644 --- a/jets/b/reel.c +++ b/jets/b/reel.c @@ -7,7 +7,7 @@ _reel_in(u3j_site* sit_u, u3_noun a, u3_noun b) { if ( 0 == a ) { - return u3k(b); + return b; } else if ( c3n == u3du(a) ) { return u3m_bail(c3__exit); @@ -29,7 +29,7 @@ u3_noun pro; u3j_site sit_u; u3j_gate_prep(&sit_u, b); - pro = _reel_in(&sit_u, a, u3r_at(u3x_sam_3, b)); + pro = _reel_in(&sit_u, a, u3k(u3r_at(u3x_sam_3, b))); u3j_gate_lose(&sit_u); return pro; } From d306975af8a58c422687e9e7d349d5e5aa3f6ba7 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 09:57:09 -0700 Subject: [PATCH 088/221] gate_prep transfers, rites to posts --- include/noun/jets.h | 20 ++++++++++++-------- jets/b/levy.c | 2 +- jets/b/lien.c | 2 +- jets/b/murn.c | 2 +- jets/b/reel.c | 2 +- jets/b/roll.c | 2 +- jets/b/skid.c | 2 +- jets/b/skim.c | 2 +- jets/b/skip.c | 2 +- jets/b/turn.c | 2 +- noun/jets.c | 24 +++++++++++++----------- noun/nock.c | 2 +- 12 files changed, 35 insertions(+), 29 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index a0ef42f53..36b219aff 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -61,23 +61,27 @@ u3j_core* ray_u; // dynamic array by axis } u3j_dash; + /* u3j_fist: a single step in a fine check */ typedef struct { - u3_noun bat; - u3_noun pax; + u3_noun bat; // battery + u3_noun pax; // parent axis } u3j_fist; + /* u3j_fink: (fine check) verify a located core */ typedef struct { - c3_w len_w; - u3_noun sat; - u3j_fist fis_u[0]; + c3_w len_w; // number of fists + u3_noun sat; // static noun at end of check + u3j_fist fis_u[0]; // fists } u3j_fink; + /* u3j_rite: site of a %fast, used to skip re-mining */ typedef struct { - c3_o own_o; - u3_weak clu; - u3j_fink* fin_u; + c3_o own_o; // rite owns fink? + u3_weak clu; // cached product of clue formula + u3p(u3j_fink) fin_p; // fine check } u3j_rite; + /* u3j_site: site of a nock 9 */ struct _u3n_prog; typedef struct { struct _u3n_prog *pog_u; diff --git a/jets/b/levy.c b/jets/b/levy.c index 76d437371..3f4978b79 100644 --- a/jets/b/levy.c +++ b/jets/b/levy.c @@ -31,7 +31,7 @@ { u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _levy_in(&sit_u, a); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/lien.c b/jets/b/lien.c index cede8fa83..c37b1ee8f 100644 --- a/jets/b/lien.c +++ b/jets/b/lien.c @@ -31,7 +31,7 @@ { u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _lien_in(&sit_u, a); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/murn.c b/jets/b/murn.c index d177137f4..e0dcb8d23 100644 --- a/jets/b/murn.c +++ b/jets/b/murn.c @@ -37,7 +37,7 @@ { u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _murn_in(&sit_u, a); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/reel.c b/jets/b/reel.c index 474e43280..de963fe34 100644 --- a/jets/b/reel.c +++ b/jets/b/reel.c @@ -28,7 +28,7 @@ { u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _reel_in(&sit_u, a, u3k(u3r_at(u3x_sam_3, b))); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/roll.c b/jets/b/roll.c index 448c25275..49b7eccf0 100644 --- a/jets/b/roll.c +++ b/jets/b/roll.c @@ -26,7 +26,7 @@ { u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _roll_in(&sit_u, a, u3k(u3r_at(u3x_sam_3, b))); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/skid.c b/jets/b/skid.c index 85269436d..29ab919b0 100644 --- a/jets/b/skid.c +++ b/jets/b/skid.c @@ -37,7 +37,7 @@ { u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _skid_in(&sit_u, a); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/skim.c b/jets/b/skim.c index 0af438cd3..c5e721ec1 100644 --- a/jets/b/skim.c +++ b/jets/b/skim.c @@ -33,7 +33,7 @@ { u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _skim_in(&sit_u, a); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/skip.c b/jets/b/skip.c index 7dc431a1f..36ff1a3e6 100644 --- a/jets/b/skip.c +++ b/jets/b/skip.c @@ -33,7 +33,7 @@ { u3j_site sit_u; u3_noun pro; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _skip_in(&sit_u, a); u3j_gate_lose(&sit_u); return pro; diff --git a/jets/b/turn.c b/jets/b/turn.c index 42ba67e6e..e183ae4bf 100644 --- a/jets/b/turn.c +++ b/jets/b/turn.c @@ -24,7 +24,7 @@ u3_noun pro; u3j_site sit_u; - u3j_gate_prep(&sit_u, b); + u3j_gate_prep(&sit_u, u3k(b)); pro = _turn_in(&sit_u, a); u3j_gate_lose(&sit_u); return pro; diff --git a/noun/jets.c b/noun/jets.c index 4a6088b6e..3edce118a 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1009,16 +1009,16 @@ u3j_rite_copy(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o) { if ( u3_none == src_u->clu ) { dst_u->clu = u3_none; - dst_u->fin_u = NULL; + dst_u->fin_p = 0; } else { - u3_noun old = dst_u->clu; - u3j_fink* fon_u = dst_u->fin_u; - c3_o own_o = dst_u->own_o; + u3_noun old = dst_u->clu; + u3j_fink* fon_u = u3to(u3j_fink, dst_u->fin_p); + c3_o own_o = dst_u->own_o; if ( c3y == src_u->own_o ) { dst_u->own_o = c3y; dst_u->clu = u3a_take(src_u->clu); - dst_u->fin_u = _cj_fink_take(src_u->fin_u); + dst_u->fin_p = u3of(u3j_fink, _cj_fink_take(u3to(u3j_fink, src_u->fin_p))); if ( (c3y == los_o) && (u3_none != old) && (c3y == own_o) ) { @@ -1280,6 +1280,7 @@ u3j_kink(u3_noun cor, u3_noun axe) } /* u3j_gate_prep(): prepare a locally cached gate to call repeatedly. + * core is TRANSFERRED. */ void u3j_gate_prep(u3j_site* sit_u, u3_noun cor) @@ -1288,9 +1289,10 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) u3t_on(glu_o); if ( c3n == u3du(cor) || c3n == u3du(u3t(cor)) ) { u3m_bail(c3__exit); + return; } sit_u->axe = 2; - sit_u->bat = u3k(cor); // a lie, this isn't really the battery! + sit_u->bat = cor; // a lie, this isn't really the battery! sit_u->pog_u = _cj_prog(u3h(cor)); if ( u3_none != (loc = sit_u->loc = _cj_spot(cor)) ) { u3_noun pax = u3h(u3t(loc)), @@ -1551,15 +1553,15 @@ u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) if ( non_t || c3n == u3r_sing(rit_u->clu, clu) || - c3n == _cj_fine(cor, rit_u->fin_u) ) { + c3n == _cj_fine(cor, u3to(u3j_fink, rit_u->fin_p)) ) { u3_weak loc = _cj_mile(u3k(clu), u3k(cor)); if ( u3_none != loc ) { u3_noun old = rit_u->clu; - u3j_fink* fon_u = rit_u->fin_u; + u3j_fink* fon_u = u3to(u3j_fink, rit_u->fin_p); c3_o own_o = rit_u->own_o; rit_u->own_o = c3y; rit_u->clu = u3k(clu); - rit_u->fin_u = _cj_cast(cor, loc); + rit_u->fin_p = u3of(u3j_fink, _cj_cast(cor, loc)); u3z(loc); if ( !non_t && (c3y == own_o) ) { @@ -1842,7 +1844,7 @@ u3j_rite_lose(u3j_rite* rit_u) { if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { u3z(rit_u->clu); - _cj_fink_free(rit_u->fin_u); + _cj_fink_free(u3to(u3j_fink, rit_u->fin_p)); } } @@ -1854,7 +1856,7 @@ u3j_rite_mark(u3j_rite* rit_u) c3_w tot_w = 0; if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { tot_w += u3a_mark_noun(rit_u->clu); - tot_w += _cj_fink_mark(rit_u->fin_u); + tot_w += _cj_fink_mark(u3to(u3j_fink, rit_u->fin_p)); } return tot_w; } diff --git a/noun/nock.c b/noun/nock.c index 494ffc801..f682e1888 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -789,7 +789,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) u3j_rite* rit_u = &(pog_u->reg_u.rit_u[reg_s++]); rit_u->own_o = c3n; rit_u->clu = u3_none; - rit_u->fin_u = NULL; + rit_u->fin_p = 0; break; } } From 825b7eb6048935b6b2adf2757fe97f01e42e265f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 10:16:47 -0700 Subject: [PATCH 089/221] posts in sites --- include/noun/jets.h | 32 +++++++++++++++++------------- noun/jets.c | 48 ++++++++++++++++++++++----------------------- noun/nock.c | 10 +++++----- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 36b219aff..8d9a54fa2 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -61,39 +61,43 @@ u3j_core* ray_u; // dynamic array by axis } u3j_dash; - /* u3j_fist: a single step in a fine check */ + /* u3j_fist: a single step in a fine check + */ typedef struct { u3_noun bat; // battery u3_noun pax; // parent axis } u3j_fist; - /* u3j_fink: (fine check) verify a located core */ + /* u3j_fink: (fine check) verify a located core + */ typedef struct { c3_w len_w; // number of fists u3_noun sat; // static noun at end of check u3j_fist fis_u[0]; // fists } u3j_fink; - /* u3j_rite: site of a %fast, used to skip re-mining */ + /* u3j_rite: site of a %fast, used to skip re-mining + */ typedef struct { c3_o own_o; // rite owns fink? u3_weak clu; // cached product of clue formula u3p(u3j_fink) fin_p; // fine check } u3j_rite; - /* u3j_site: site of a nock 9 */ + /* u3j_site: site of a kick (nock 9), used to cache call target + */ struct _u3n_prog; typedef struct { - struct _u3n_prog *pog_u; - u3_noun axe; - u3_weak bat; - u3_weak loc; - c3_o jet_o; - c3_o fon_o; - u3_weak lab; - u3j_core* cop_u; - u3j_harm* ham_u; - u3j_fink* fin_u; + u3p(struct _u3n_prog) pog_p; // program for formula + u3_noun axe; // axis + u3_weak bat; // battery (for verification) + u3_weak loc; // location (for reaming) + c3_o jet_o; // have jet driver? + c3_o fon_o; // site owns fink? + u3_weak lab; // label (for tracing) + u3j_core* cop_u; // jet core + u3j_harm* ham_u; // jet arm + u3p(u3j_fink) fin_p; // fine check } u3j_site; /** Globals. diff --git a/noun/jets.c b/noun/jets.c index 3edce118a..a30ed30c2 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -788,7 +788,7 @@ _cj_hank_fine(_cj_hank* han_u, u3_noun cor, u3_noun *inn) else { u3j_site* sit_u = &(han_u->sit_u); c3_assert(u3_none != sit_u->loc); - return _cj_fine(*inn, sit_u->fin_u); + return _cj_fine(*inn, u3to(u3j_fink, sit_u->fin_p)); } } } @@ -846,14 +846,14 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) u3z(got); sit_u->bat = u3k(u3h(cor)); sit_u->loc = u3k(loc); - sit_u->fin_u = _cj_cast(cor, loc); + sit_u->fin_p = u3of(u3j_fink, _cj_cast(cor, loc)); sit_u->fon_o = c3y; if ( 0 == (sit_u->axe = _cj_axis(fol)) ) { sit_u->jet_o = c3n; - sit_u->pog_u = _cj_prog(fol); + sit_u->pog_p = u3of(u3n_prog, _cj_prog(fol)); } else { - han_u->sit_u.pog_u = _cj_prog(u3r_at(sit_u->axe, cor)); + han_u->sit_u.pog_p = u3of(u3n_prog, _cj_prog(u3r_at(sit_u->axe, cor))); han_u->sit_u.jet_o = _cj_nail(loc, sit_u->axe, &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); } @@ -1043,21 +1043,21 @@ u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) } else { dst_u->bat = u3_none; - dst_u->pog_u = NULL; + dst_u->pog_p = 0; dst_u->loc = u3_none; dst_u->lab = u3_none; dst_u->jet_o = c3n; dst_u->fon_o = c3n; dst_u->cop_u = NULL; dst_u->ham_u = NULL; - dst_u->fin_u = NULL; + dst_u->fin_p = 0; } if ( u3_none != src_u->loc ) { u3_noun lob = dst_u->lab, lod = dst_u->loc; c3_o fon_o = dst_u->fon_o; - u3j_fink* fon_u = dst_u->fin_u; + u3p(u3j_fink) fon_p = dst_u->fin_p; dst_u->loc = u3a_take(src_u->loc); dst_u->lab = u3a_take(src_u->lab); @@ -1066,11 +1066,11 @@ u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) dst_u->jet_o = src_u->jet_o; if ( c3y == src_u->fon_o ) { - dst_u->fin_u = _cj_fink_take(src_u->fin_u); + dst_u->fin_p = u3of(u3j_fink, _cj_fink_take(u3to(u3j_fink, src_u->fin_p))); dst_u->fon_o = c3y; } - else if ( fon_u != src_u->fin_u ) { - dst_u->fin_u = src_u->fin_u; + else if ( fon_p != src_u->fin_p ) { + dst_u->fin_p = src_u->fin_p; dst_u->fon_o = c3n; } else { @@ -1082,7 +1082,7 @@ u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) u3z(lod); u3z(lob); if ( c3y == fon_o ) { - _cj_fink_free(fon_u); + _cj_fink_free(u3to(u3j_fink, fon_p)); } } } @@ -1108,7 +1108,7 @@ _cj_site_lock(u3_noun cor, u3j_site* sit_u) (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { return u3_none; } - sit_u->pog_u = _cj_prog(u3r_at(sit_u->axe, cor)); + sit_u->pog_p = u3of(u3n_prog, _cj_prog(u3r_at(sit_u->axe, cor))); if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); } @@ -1145,7 +1145,7 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) if ( u3_none == pro ) { pro = _cj_site_lock(cor, sit_u); if ( u3_none == pro ) { - pro = _cj_burn(cor, sit_u->pog_u); + pro = _cj_burn(cor, u3to(u3n_prog, sit_u->pog_p)); } } if ( c3y == pof_o ) { @@ -1163,7 +1163,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) loc = pro = u3_none; if ( u3_none != sit_u->loc ) { - if ( c3y == _cj_fine(cor, sit_u->fin_u) ) { + if ( c3y == _cj_fine(cor, u3to(u3j_fink, sit_u->fin_p)) ) { loc = sit_u->loc; if ( c3y == sit_u->jet_o ) { pro = _cj_site_kick_hot(cor, sit_u); @@ -1174,7 +1174,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) if ( u3_none == loc ) { loc = _cj_spot(cor); if ( u3_none != loc ) { - u3j_fink* fon_u = NULL; + u3p(u3j_fink) fon_p = 0; u3_weak lod = u3_none; u3_weak lob = u3_none; @@ -1182,12 +1182,12 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) lod = sit_u->loc; lob = sit_u->lab; if ( c3y == sit_u->fon_o ) { - fon_u = sit_u->fin_u; + fon_p = sit_u->fin_p; } } sit_u->loc = loc; - sit_u->fin_u = _cj_cast(cor, loc); + sit_u->fin_p = u3of(u3j_fink, _cj_cast(cor, loc)); sit_u->fon_o = c3y; if ( c3y == (sit_u->jet_o = _cj_nail(loc, sit_u->axe, @@ -1202,8 +1202,8 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) if ( u3_none != lod ) { u3z(lod); u3z(lob); - if ( NULL != fon_u ) { - _cj_fink_free(fon_u); + if ( 0 != fon_p ) { + _cj_fink_free(u3to(u3j_fink, fon_p)); } } } @@ -1248,7 +1248,7 @@ u3j_cook(const c3_c* key_c, } pro = _cj_site_kick(u3k(inn), &(han_u->sit_u)); if ( u3_none == pro ) { - pro = _cj_burn(inn, han_u->sit_u.pog_u); + pro = _cj_burn(inn, u3to(u3n_prog, han_u->sit_u.pog_p)); } u3z(cor); @@ -1293,7 +1293,7 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) } sit_u->axe = 2; sit_u->bat = cor; // a lie, this isn't really the battery! - sit_u->pog_u = _cj_prog(u3h(cor)); + sit_u->pog_p = u3of(u3n_prog, _cj_prog(u3h(cor))); if ( u3_none != (loc = sit_u->loc = _cj_spot(cor)) ) { u3_noun pax = u3h(u3t(loc)), pay = u3qc_cap(pax), @@ -1328,7 +1328,7 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam) pro = _cj_site_kick_hot(cor, sit_u); } if ( u3_none == pro ) { - pro = _cj_burn(cor, sit_u->pog_u); + pro = _cj_burn(cor, u3to(u3n_prog, sit_u->pog_p)); } u3t_off(glu_o); return pro; @@ -1832,7 +1832,7 @@ u3j_site_lose(u3j_site* sit_u) u3z(sit_u->loc); u3z(sit_u->lab); if ( c3y == sit_u->fon_o ) { - _cj_fink_free(sit_u->fin_u); + _cj_fink_free(u3to(u3j_fink, sit_u->fin_p)); } } } @@ -1874,7 +1874,7 @@ u3j_site_mark(u3j_site* sit_u) tot_w += u3a_mark_noun(sit_u->loc); tot_w += u3a_mark_noun(sit_u->lab); if ( c3y == sit_u->fon_o ) { - tot_w += _cj_fink_mark(sit_u->fin_u); + tot_w += _cj_fink_mark(u3to(u3j_fink, sit_u->fin_p)); } } return tot_w; diff --git a/noun/nock.c b/noun/nock.c index f682e1888..f82bfe7c0 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -883,7 +883,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) _n_prog_asm_inx(buf_y, &i_w, cal_s, cod); u3j_site* sit_u = &(pog_u->cal_u.sit_u[cal_s++]); sit_u->axe = u3k(u3t(op)); - sit_u->pog_u = NULL; + sit_u->pog_p = 0; sit_u->bat = u3_none; sit_u->loc = u3_none; sit_u->lab = u3_none; @@ -891,7 +891,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) sit_u->fon_o = c3n; sit_u->cop_u = NULL; sit_u->ham_u = NULL; - sit_u->fin_u = NULL; + sit_u->fin_p = 0; break; } } @@ -1449,7 +1449,7 @@ _n_find(u3_noun fol) for ( i_w = 0; i_w < old->cal_u.len_w; ++i_w ) { u3j_site* sit_u = &(old->cal_u.sit_u[i_w]); sit_u->bat = u3_none; - sit_u->pog_u = NULL; + sit_u->pog_p = 0; sit_u->fon_o = c3n; } u3h_put(u3R->byc.har_p, fol, u3a_outa(old)); @@ -1938,7 +1938,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) fam->ip_w = ip_w; fam->pog_u = pog_u; - pog_u = sit_u->pog_u; + pog_u = u3to(u3n_prog, sit_u->pog_p); pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG @@ -1970,7 +1970,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) *top = _n_kick(o, sit_u); if ( u3_none == *top ) { *top = o; - pog_u = sit_u->pog_u; + pog_u = u3to(u3n_prog, sit_u->pog_p); pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG From dc470f76d48e074bd7861ce10fd62b96185a876d Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 10:33:04 -0700 Subject: [PATCH 090/221] deleting unused public functions, cleaning up internal apis --- include/noun/jets.h | 32 +++----------------- noun/jets.c | 72 ++++++++++----------------------------------- 2 files changed, 19 insertions(+), 85 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 8d9a54fa2..41a9225f6 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -61,14 +61,14 @@ u3j_core* ray_u; // dynamic array by axis } u3j_dash; - /* u3j_fist: a single step in a fine check + /* u3j_fist: a single step in a fine check. */ typedef struct { u3_noun bat; // battery u3_noun pax; // parent axis } u3j_fist; - /* u3j_fink: (fine check) verify a located core + /* u3j_fink: (fine check) enough data to verify a located core. */ typedef struct { c3_w len_w; // number of fists @@ -76,7 +76,7 @@ u3j_fist fis_u[0]; // fists } u3j_fink; - /* u3j_rite: site of a %fast, used to skip re-mining + /* u3j_rite: site of a %fast, used to skip re-mining. */ typedef struct { c3_o own_o; // rite owns fink? @@ -84,7 +84,7 @@ u3p(u3j_fink) fin_p; // fine check } u3j_rite; - /* u3j_site: site of a kick (nock 9), used to cache call target + /* u3j_site: site of a kick (nock 9), used to cache call target. */ struct _u3n_prog; typedef struct { @@ -144,30 +144,6 @@ u3j_soft(u3_noun cor, const c3_c* tam_c); - /* u3j_spot(): - ** - ** Identify `cor`s location. RETAIN. - */ - u3_weak - u3j_spot(u3_noun cor); - - /* u3j_fine(): check core against u3j_fink. - */ - c3_o - u3j_fine(u3_noun cor, u3j_fink* fin_u); - - /* u3j_cast(): create u3j_fink from core and location. - */ - u3j_fink* - u3j_cast(u3_noun cor, u3_noun loc); - - /* u3j_nail(): resolve hot state for location and axis. RETAIN. - ** return value indicates presence of driver. - **/ - c3_o - u3j_nail(u3_noun loc, u3_noun axe, - u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u); - /* u3j_kick(): try to kick by jet. If no kick, produce u3_none. ** ** `axe` is RETAINED by the caller; `cor` is RETAINED iff there diff --git a/noun/jets.c b/noun/jets.c index a30ed30c2..036119545 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -226,6 +226,8 @@ _cj_find_warm(u3_noun loc) } } +/* _cj_spot(): find location of cor. expensive. cor is RETAINED. + */ static u3_weak _cj_spot(u3_noun cor) { @@ -269,19 +271,10 @@ _cj_spot(u3_noun cor) } } -/* u3j_spot(): identify `cor`s location. RETAIN. +/* _cj_cast(): create a u3j_fink that can be used to efficiently verify + * that another core is located where this one is. */ -u3_weak -u3j_spot(u3_noun cor) -{ - u3_weak loc; - u3t_on(glu_o); - loc = _cj_spot(cor); - u3t_off(glu_o); - return loc; -} - -static u3j_fink* +static u3p(u3j_fink) _cj_cast(u3_noun cor, u3_noun loc) { c3_w i_w = 0; @@ -314,24 +307,15 @@ _cj_cast(u3_noun cor, u3_noun loc) u3z(rev); c3_assert( u3_nul == j ); - return fin_u; + return u3of(u3j_fink, fin_u); } -/* u3j_cast(): create u3j_fink from core and location. +/* _cj_fine(): check that a core matches a u3j_fink */ -u3j_fink* -u3j_cast(u3_noun cor, u3_noun loc) -{ - u3j_fink* fin_u; - u3t_on(glu_o); - fin_u = _cj_cast(cor, loc); - u3t_off(glu_o); - return fin_u; -} - static c3_o -_cj_fine(u3_noun cor, u3j_fink* fin_u) +_cj_fine(u3_noun cor, u3p(u3j_fink) fin_p) { + u3j_fink* fin_u = u3to(u3j_fink, fin_p); c3_w i_w; for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { u3j_fist* fis_u = &(fin_u->fis_u[i_w]); @@ -345,18 +329,6 @@ _cj_fine(u3_noun cor, u3j_fink* fin_u) return u3r_sing(fin_u->sat, cor); } -/* u3j_fine(): check core against u3j_fink. - */ -c3_o -u3j_fine(u3_noun cor, u3j_fink* fin_u) -{ - c3_o ret_o; - u3t_on(glu_o); - ret_o = _cj_fine(cor, fin_u); - u3t_off(glu_o); - return ret_o; -} - static c3_o _cj_nail(u3_noun loc, u3_noun axe, u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u) @@ -390,20 +362,6 @@ _cj_nail(u3_noun loc, u3_noun axe, return ret_o; } -/* u3j_nail(): resolve hot state for location and axis. RETAIN. -** return value indicates presence of driver. -**/ -c3_o -u3j_nail(u3_noun loc, u3_noun axe, - u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u) -{ - c3_o ret_o; - u3t_on(glu_o); - ret_o = _cj_nail(loc, axe, lab, cop_u, ham_u); - u3t_off(glu_o); - return ret_o; -} - /* _cj_scan(): has this core been registered? */ static c3_o @@ -788,7 +746,7 @@ _cj_hank_fine(_cj_hank* han_u, u3_noun cor, u3_noun *inn) else { u3j_site* sit_u = &(han_u->sit_u); c3_assert(u3_none != sit_u->loc); - return _cj_fine(*inn, u3to(u3j_fink, sit_u->fin_p)); + return _cj_fine(*inn, sit_u->fin_p); } } } @@ -846,7 +804,7 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) u3z(got); sit_u->bat = u3k(u3h(cor)); sit_u->loc = u3k(loc); - sit_u->fin_p = u3of(u3j_fink, _cj_cast(cor, loc)); + sit_u->fin_p = _cj_cast(cor, loc); sit_u->fon_o = c3y; if ( 0 == (sit_u->axe = _cj_axis(fol)) ) { sit_u->jet_o = c3n; @@ -1163,7 +1121,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) loc = pro = u3_none; if ( u3_none != sit_u->loc ) { - if ( c3y == _cj_fine(cor, u3to(u3j_fink, sit_u->fin_p)) ) { + if ( c3y == _cj_fine(cor, sit_u->fin_p) ) { loc = sit_u->loc; if ( c3y == sit_u->jet_o ) { pro = _cj_site_kick_hot(cor, sit_u); @@ -1187,7 +1145,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) } sit_u->loc = loc; - sit_u->fin_p = u3of(u3j_fink, _cj_cast(cor, loc)); + sit_u->fin_p = _cj_cast(cor, loc); sit_u->fon_o = c3y; if ( c3y == (sit_u->jet_o = _cj_nail(loc, sit_u->axe, @@ -1553,7 +1511,7 @@ u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) if ( non_t || c3n == u3r_sing(rit_u->clu, clu) || - c3n == _cj_fine(cor, u3to(u3j_fink, rit_u->fin_p)) ) { + c3n == _cj_fine(cor, rit_u->fin_p) ) { u3_weak loc = _cj_mile(u3k(clu), u3k(cor)); if ( u3_none != loc ) { u3_noun old = rit_u->clu; @@ -1561,7 +1519,7 @@ u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) c3_o own_o = rit_u->own_o; rit_u->own_o = c3y; rit_u->clu = u3k(clu); - rit_u->fin_p = u3of(u3j_fink, _cj_cast(cor, loc)); + rit_u->fin_p = _cj_cast(cor, loc); u3z(loc); if ( !non_t && (c3y == own_o) ) { From 68f98124e5d0e7698dda4ab3492599db64ff0177 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 10:56:19 -0700 Subject: [PATCH 091/221] more comments, u3n_burn takes a post --- include/noun/jets.h | 35 +++++++++++------------ include/noun/nock.h | 2 +- noun/jets.c | 68 +++++++++++++++++++++++---------------------- noun/nock.c | 4 +-- 4 files changed, 56 insertions(+), 53 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 41a9225f6..2bc1eab71 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -5,23 +5,24 @@ /** Noun semantics. **/ #if 0 - ++ bane ,@tas :: battery name - ++ bash ,@uvH :: label hash - ++ bosh ,@uvH :: battery hash - ++ batt ,* :: battery - ++ calf :: - $: jax=,@ud :: hot core index - hap=(map ,@ud ,@ud) :: axis/hot arm index - lab=path :: label as path - jit=* :: arbitrary data - == :: - ++ calx (trel calf (pair bash cope) club) :: cached by battery - ++ clog (pair cope (map batt club)) :: label record - ++ club (pair corp (map term nock)) :: battery pattern - ++ cope (trel bane axis (each bash noun)) :: core pattern - ++ core ,* - ++ corp (each core batt) :: parent or static - ++ dash (map bash clog) :: jet system ++= location $: pattern=(each static dynamic) + name=term + hooks=(map term axis) + == ++= static (each payload=* parent=location) ++= dynamic [where=axis parent=location] +:: ++= registry [roots=(map * location) parents=(list parent)] ++= parent (pair axis (map location location)) +:: ++= activation $: hot-index=@ud + drivers=(map axis @ud) + label=path + jit=* + == +:: ++= cold (map battery=^ registry) ++= warm (map location activation) #endif /** Data structures. diff --git a/include/noun/nock.h b/include/noun/nock.h index b83fb6082..f29fdbe4b 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -50,7 +50,7 @@ /* u3n_burn(): execute u3n_prog with bus as subject. */ u3_noun - u3n_burn(u3_noun bus, u3n_prog* pog_u); + u3n_burn(u3p(u3n_prog) pog_p, u3_noun bus); /* u3n_slam_on(): produce (gat sam). */ diff --git a/noun/jets.c b/noun/jets.c index 036119545..729c2b657 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -3,6 +3,19 @@ */ #include "all.h" +/** Data structures. +**/ + + /* _cj_hank: cached hook information. + */ + typedef struct { + u3_weak hax; // axis of hooked inner core + u3j_site sit_u; // call-site data + } _cj_hank; + +/** Functions. +**/ + /* _cj_count(): count and link dashboard entries. */ static c3_w @@ -329,6 +342,11 @@ _cj_fine(u3_noun cor, u3p(u3j_fink) fin_p) return u3r_sing(fin_u->sat, cor); } +/* _cj_nail(): resolve hot state for arm at axis within cores located + * at loc. a label will be PRODUCED at *lab, unconditionally. + * Arguments are RETAINED. Return value is yes if a jet driver + * is present. + */ static c3_o _cj_nail(u3_noun loc, u3_noun axe, u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u) @@ -362,7 +380,7 @@ _cj_nail(u3_noun loc, u3_noun axe, return ret_o; } -/* _cj_scan(): has this core been registered? +/* _cj_scan(): has this core been registered? RETAIN. */ static c3_o _cj_scan(u3_noun cor) @@ -695,11 +713,9 @@ u3j_hook(u3_noun cor, return pro; } -typedef struct { - u3_weak hax; - u3j_site sit_u; -} _cj_hank; - +/* cj_hank_find(): find cached hook information, keyed by arbitrary + * prefix and term cords. RETAIN. + */ static _cj_hank* _cj_hank_find(u3_noun pre, u3_noun tam) { @@ -731,6 +747,10 @@ _cj_hank_find(u3_noun pre, u3_noun tam) } } +/* _cj_hank_fine(): check that cached hook information is valid + * for given core. *inn will point to the hooked + * core on return if valid. RETAIN. + */ static c3_o _cj_hank_fine(_cj_hank* han_u, u3_noun cor, u3_noun *inn) { @@ -751,6 +771,8 @@ _cj_hank_fine(_cj_hank* han_u, u3_noun cor, u3_noun *inn) } } +/* _cj_hank_lose(): release memory maintained in a hook cache. +*/ static void _cj_hank_lose(_cj_hank* han_u) { @@ -760,12 +782,14 @@ _cj_hank_lose(_cj_hank* han_u) } } +/* _cj_burn(): stop tracing glu and call a nock program + */ static u3_noun -_cj_burn(u3_noun cor, u3n_prog* pog_u) +_cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) { u3_noun pro; u3t_off(glu_o); - pro = u3n_burn(cor, pog_u); + pro = u3n_burn(pog_p, cor); u3t_on(glu_o); return pro; } @@ -1103,7 +1127,7 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) if ( u3_none == pro ) { pro = _cj_site_lock(cor, sit_u); if ( u3_none == pro ) { - pro = _cj_burn(cor, u3to(u3n_prog, sit_u->pog_p)); + pro = _cj_burn(sit_u->pog_p, cor); } } if ( c3y == pof_o ) { @@ -1206,7 +1230,7 @@ u3j_cook(const c3_c* key_c, } pro = _cj_site_kick(u3k(inn), &(han_u->sit_u)); if ( u3_none == pro ) { - pro = _cj_burn(inn, u3to(u3n_prog, han_u->sit_u.pog_p)); + pro = _cj_burn(han_u->sit_u.pog_p, inn); } u3z(cor); @@ -1286,7 +1310,7 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam) pro = _cj_site_kick_hot(cor, sit_u); } if ( u3_none == pro ) { - pro = _cj_burn(cor, u3to(u3n_prog, sit_u->pog_p)); + pro = _cj_burn(sit_u->pog_p, cor); } u3t_off(glu_o); return pro; @@ -1885,25 +1909,3 @@ u3j_free(void) u3h_free(u3R->jed.han_p); } -/* XX FIXME: move to u3.md -|% -+= location $: pattern=(each static dynamic) - name=term - hooks=(map term axis) - == -+= static (each payload=* parent=location) -+= dynamic [where=axis parent=location] -:: -+= registry [roots=(map * location) parents=(list parent)] -+= parent (pair axis (map location location)) -:: -+= activation $: hot-index=@ud - drivers=(map axis @ud) - label=path - jit=* - == -:: -+= cold (map battery=^ registry) -+= warm (map location activation) --- -*/ diff --git a/noun/nock.c b/noun/nock.c index f82bfe7c0..fc65d1ea7 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -2157,11 +2157,11 @@ _n_burn_out(u3_noun bus, u3n_prog* pog_u) /* u3n_burn(): execute u3n_prog with bus as subject. */ u3_noun -u3n_burn(u3_noun bus, u3n_prog* pog_u) +u3n_burn(u3p(u3n_prog) pog_p, u3_noun bus) { u3_noun pro; u3t_on(noc_o); - pro = _n_burn_out(bus, pog_u); + pro = _n_burn_out(bus, u3to(u3n_prog, pog_p)); u3t_off(noc_o); return pro; } From b43f06944113e449f5fd2b7e17987435d1cb0eab Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 11:02:48 -0700 Subject: [PATCH 092/221] u3n_find returns post --- include/noun/nock.h | 2 +- noun/jets.c | 18 ++++++++++-------- noun/nock.c | 8 ++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index f29fdbe4b..14b927209 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -44,7 +44,7 @@ /* u3n_find(): return prog for given formula. fol is RETAINED. */ - u3n_prog* + u3p(u3n_prog) u3n_find(u3_noun fol); /* u3n_burn(): execute u3n_prog with bus as subject. diff --git a/noun/jets.c b/noun/jets.c index 729c2b657..b3f0a4c0b 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -794,14 +794,16 @@ _cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) return pro; } -static u3n_prog* +/* _cj_prog(): stop tracing glu and find a nock program + */ +static u3p(u3n_prog) _cj_prog(u3_noun fol) { - u3n_prog* pog_u; + u3p(u3n_prog) pog_p; u3t_off(glu_o); - pog_u = u3n_find(fol); + pog_p = u3n_find(fol); u3t_on(glu_o); - return pog_u; + return pog_p; } static u3_noun @@ -832,10 +834,10 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) sit_u->fon_o = c3y; if ( 0 == (sit_u->axe = _cj_axis(fol)) ) { sit_u->jet_o = c3n; - sit_u->pog_p = u3of(u3n_prog, _cj_prog(fol)); + sit_u->pog_p = _cj_prog(fol); } else { - han_u->sit_u.pog_p = u3of(u3n_prog, _cj_prog(u3r_at(sit_u->axe, cor))); + han_u->sit_u.pog_p = _cj_prog(u3r_at(sit_u->axe, cor)); han_u->sit_u.jet_o = _cj_nail(loc, sit_u->axe, &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); } @@ -1090,7 +1092,7 @@ _cj_site_lock(u3_noun cor, u3j_site* sit_u) (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { return u3_none; } - sit_u->pog_p = u3of(u3n_prog, _cj_prog(u3r_at(sit_u->axe, cor))); + sit_u->pog_p = _cj_prog(u3r_at(sit_u->axe, cor)); if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); } @@ -1275,7 +1277,7 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) } sit_u->axe = 2; sit_u->bat = cor; // a lie, this isn't really the battery! - sit_u->pog_p = u3of(u3n_prog, _cj_prog(u3h(cor))); + sit_u->pog_p = _cj_prog(u3h(cor)); if ( u3_none != (loc = sit_u->loc = _cj_spot(cor)) ) { u3_noun pax = u3h(u3t(loc)), pay = u3qc_cap(pax), diff --git a/noun/nock.c b/noun/nock.c index fc65d1ea7..9188a6058 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1467,14 +1467,14 @@ _n_find(u3_noun fol) /* u3n_find(): return prog for given formula. fol is RETAINED. */ -u3n_prog* +u3p(u3n_prog) u3n_find(u3_noun fol) { - u3n_prog* pog_u; + u3p(u3n_prog) pog_p; u3t_on(noc_o); - pog_u = _n_find(fol); + pog_p = u3of(u3n_prog, _n_find(fol)); u3t_off(noc_o); - return pog_u; + return pog_p; } /* _n_swap(): swap two items on the top of the stack, return pointer to top From 672d99fcca6af1a19f4bebc8c0ff15da66972ca0 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 11:10:01 -0700 Subject: [PATCH 093/221] comments, no return from _cj_site_lock --- noun/jets.c | 69 ++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index b3f0a4c0b..7d8d4dc03 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -713,6 +713,18 @@ u3j_hook(u3_noun cor, return pro; } +/* _cj_prog(): stop tracing glu and find a nock program + */ +static u3p(u3n_prog) +_cj_prog(u3_noun fol) +{ + u3p(u3n_prog) pog_p; + u3t_off(glu_o); + pog_p = u3n_find(fol); + u3t_on(glu_o); + return pog_p; +} + /* cj_hank_find(): find cached hook information, keyed by arbitrary * prefix and term cords. RETAIN. */ @@ -782,30 +794,8 @@ _cj_hank_lose(_cj_hank* han_u) } } -/* _cj_burn(): stop tracing glu and call a nock program +/* _cj_hank_fill(): slow path, populate han_u. */ -static u3_noun -_cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) -{ - u3_noun pro; - u3t_off(glu_o); - pro = u3n_burn(pog_p, cor); - u3t_on(glu_o); - return pro; -} - -/* _cj_prog(): stop tracing glu and find a nock program - */ -static u3p(u3n_prog) -_cj_prog(u3_noun fol) -{ - u3p(u3n_prog) pog_p; - u3t_off(glu_o); - pog_p = u3n_find(fol); - u3t_on(glu_o); - return pog_p; -} - static u3_noun _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) { @@ -954,6 +944,8 @@ u3j_kick(u3_noun cor, u3_noun axe) } } +/* _cj_fink_take(): copy u3j_fink from junior road. +*/ static u3j_fink* _cj_fink_take(u3j_fink* jun_u) { @@ -972,6 +964,8 @@ _cj_fink_take(u3j_fink* jun_u) return fin_u; } +/* _cj_fink_take(): lose and free everything in a u3j_fink. +*/ static void _cj_fink_free(u3j_fink* fin_u) { @@ -1085,19 +1079,32 @@ u3j_site_ream(u3j_site* sit_u) } } -static u3_weak +/* _cj_site_lock(): ensure site has a valid program pointer + */ +static void _cj_site_lock(u3_noun cor, u3j_site* sit_u) { if ( (u3_none != sit_u->bat) && (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { - return u3_none; + return; } sit_u->pog_p = _cj_prog(u3r_at(sit_u->axe, cor)); if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); } sit_u->bat = u3k(u3h(cor)); - return u3_none; +} + +/* _cj_burn(): stop tracing glu and call a nock program + */ +static u3_noun +_cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) +{ + u3_noun pro; + u3t_off(glu_o); + pro = u3n_burn(pog_p, cor); + u3t_on(glu_o); + return pro; } static u3_weak @@ -1116,7 +1123,7 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) u3t_on(glu_o); } if ( u3_none == pro ) { - pro = _cj_site_lock(cor, sit_u); + _cj_site_lock(cor, sit_u); } } else { @@ -1127,10 +1134,8 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) u3t_on(glu_o); } if ( u3_none == pro ) { - pro = _cj_site_lock(cor, sit_u); - if ( u3_none == pro ) { - pro = _cj_burn(sit_u->pog_p, cor); - } + _cj_site_lock(cor, sit_u); + pro = _cj_burn(sit_u->pog_p, cor); } if ( c3y == pof_o ) { u3t_flee(); @@ -1194,7 +1199,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) } if ( u3_none == pro ) { - pro = _cj_site_lock(cor, sit_u); + _cj_site_lock(cor, sit_u); } return pro; From d1d2f02ef02c9fdee70368e25ec3bc3e7e0f2c8d Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 11:21:04 -0700 Subject: [PATCH 094/221] comments, _cj_fink_free takes post --- noun/jets.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 7d8d4dc03..8c8b73b1f 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -964,12 +964,13 @@ _cj_fink_take(u3j_fink* jun_u) return fin_u; } -/* _cj_fink_take(): lose and free everything in a u3j_fink. +/* _cj_fink_free(): lose and free everything in a u3j_fink. */ static void -_cj_fink_free(u3j_fink* fin_u) +_cj_fink_free(u3p(u3j_fink) fin_p) { c3_w i_w; + u3j_fink* fin_u = u3to(u3j_fink, fin_p); u3z(fin_u->sat); for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { u3j_fist* fis_u = &(fin_u->fis_u[i_w]); @@ -990,8 +991,8 @@ u3j_rite_copy(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o) dst_u->fin_p = 0; } else { + u3p(u3j_fink) fon_p = dst_u->fin_p; u3_noun old = dst_u->clu; - u3j_fink* fon_u = u3to(u3j_fink, dst_u->fin_p); c3_o own_o = dst_u->own_o; if ( c3y == src_u->own_o ) { dst_u->own_o = c3y; @@ -1001,7 +1002,7 @@ u3j_rite_copy(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o) (u3_none != old) && (c3y == own_o) ) { u3z(old); - _cj_fink_free(fon_u); + _cj_fink_free(fon_p); } } } @@ -1060,7 +1061,7 @@ u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) u3z(lod); u3z(lob); if ( c3y == fon_o ) { - _cj_fink_free(u3to(u3j_fink, fon_p)); + _cj_fink_free(fon_p); } } } @@ -1107,6 +1108,9 @@ _cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) return pro; } +/* _cj_site_kick_hot(): execute site's kick on located core +** (no validity checks). +*/ static u3_weak _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) { @@ -1144,6 +1148,8 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) return pro; } +/* _cj_site_kick(): execute site's kick on core. + */ static u3_weak _cj_site_kick(u3_noun cor, u3j_site* sit_u) { @@ -1192,7 +1198,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) u3z(lod); u3z(lob); if ( 0 != fon_p ) { - _cj_fink_free(u3to(u3j_fink, fon_p)); + _cj_fink_free(fon_p); } } } @@ -1301,6 +1307,7 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) } /* u3j_gate_slam(): slam a site prepared by u3j_gate_find() with sample. + * sam is TRANSFERRED. */ u3_noun u3j_gate_slam(u3j_site* sit_u, u3_noun sam) @@ -1472,7 +1479,7 @@ _cj_mine(u3_noun cey, u3_noun cor) } /* _cj_moan(): register core known to be unregistered, returning - * location. + * location. clu and cor are TRANSFERRED. */ static u3_weak _cj_moan(u3_noun clu, u3_noun cor) @@ -1487,7 +1494,6 @@ _cj_moan(u3_noun clu, u3_noun cor) return loc; } - /* _cj_mile(): register core for jets, returning location. */ static u3_weak @@ -1545,8 +1551,8 @@ u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) c3n == _cj_fine(cor, rit_u->fin_p) ) { u3_weak loc = _cj_mile(u3k(clu), u3k(cor)); if ( u3_none != loc ) { + u3p(u3j_fink) fon_p = rit_u->fin_p; u3_noun old = rit_u->clu; - u3j_fink* fon_u = u3to(u3j_fink, rit_u->fin_p); c3_o own_o = rit_u->own_o; rit_u->own_o = c3y; rit_u->clu = u3k(clu); @@ -1555,7 +1561,7 @@ u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) if ( !non_t && (c3y == own_o) ) { u3z(old); - _cj_fink_free(fon_u); + _cj_fink_free(fon_p); } } } @@ -1648,6 +1654,8 @@ _cj_cold_reap(u3_noun kev) u3z(ser); u3z(bat); } +/* _cj_hank_reap(): reap hook resolutions. + */ static void _cj_hank_reap(u3_noun kev) { @@ -1773,13 +1781,15 @@ _cj_warm_tap(u3_noun kev, void* wit) *rel = u3nc(u3k(kev), *rel); } +/* _cj_ream_hank(): clear hot state out of hook sites. +*/ static void _cj_ream_hank(u3_noun kev) { u3j_site_ream(&(u3to(_cj_hank, u3t(kev))->sit_u)); } -/* u3j_ream(): rebuild jet state +/* u3j_ream(): rebuild warm state */ void u3j_ream(void) @@ -1795,6 +1805,8 @@ u3j_ream(void) u3h_walk(u3R->jed.han_p, _cj_ream_hank); } +/* _cj_fink_mark(): mark a u3j_fink for gc. +*/ static c3_w _cj_fink_mark(u3j_fink* fin_u) { @@ -1821,7 +1833,7 @@ u3j_site_lose(u3j_site* sit_u) u3z(sit_u->loc); u3z(sit_u->lab); if ( c3y == sit_u->fon_o ) { - _cj_fink_free(u3to(u3j_fink, sit_u->fin_p)); + _cj_fink_free(sit_u->fin_p); } } } @@ -1833,7 +1845,7 @@ u3j_rite_lose(u3j_rite* rit_u) { if ( (c3y == rit_u->own_o) && u3_none != rit_u->clu ) { u3z(rit_u->clu); - _cj_fink_free(u3to(u3j_fink, rit_u->fin_p)); + _cj_fink_free(rit_u->fin_p); } } From 7551a3c48664c8efac9ccf6f7172efcf6a2c3677 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 11:26:13 -0700 Subject: [PATCH 095/221] comments --- noun/jets.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/noun/jets.c b/noun/jets.c index 8c8b73b1f..f764fb708 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1881,6 +1881,8 @@ u3j_site_mark(u3j_site* sit_u) return tot_w; } +/* _cj_mark_hank(): mark hank cache for gc. +*/ static void _cj_mark_hank(u3_noun kev, void* dat) { @@ -1906,6 +1908,8 @@ u3j_mark(void) return tot_w; } +/* _cj_free_hank(): free hank cache. +*/ static void _cj_free_hank(u3_noun kev) { From 8bc64b09ac9a0fedf96d50f72702f5a462e85184 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 11:39:33 -0700 Subject: [PATCH 096/221] comments, rename some functions --- include/noun/nock.h | 12 ++++++------ noun/manage.c | 6 +++--- noun/nock.c | 41 ++++++++++++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 14b927209..ef1f803de 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -97,20 +97,20 @@ u3_noun u3n_nock_an(u3_noun bus, u3_noun fol); - /* u3n_beep(): promote bytecode state. + /* u3n_reap(): promote bytecode state. */ void - u3n_beep(u3p(u3h_root) har_p); + u3n_reap(u3p(u3h_root) har_p); - /* u3n_bark(): mark bytecode cache. + /* u3n_mark(): mark bytecode cache. */ c3_w - u3n_bark(void); + u3n_mark(void); - /* u3n_bree(): free bytecode cache. + /* u3n_free(): free bytecode cache. */ void - u3n_bree(void); + u3n_free(void); /* u3n_ream(): refresh after restoring from checkpoint. */ diff --git a/noun/manage.c b/noun/manage.c index 5334ee227..35e5a90d0 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -471,7 +471,7 @@ u3m_mark(void) { c3_w tot_w = 0; tot_w += u3j_mark(); - tot_w += u3n_bark(); + tot_w += u3n_mark(); tot_w += u3a_mark_noun(u3R->ski.gul); tot_w += u3a_mark_noun(u3R->bug.tax); tot_w += u3a_mark_noun(u3R->bug.mer); @@ -510,7 +510,7 @@ u3m_clear(void) { u3h_free(u3R->cax.har_p); u3j_free(); - u3n_bree(); + u3n_free(); } void @@ -806,7 +806,7 @@ u3m_love(u3_noun pro) pro = u3a_take(pro); u3j_reap(cod_p, war_p, han_p); - u3n_beep(byc_p); + u3n_reap(byc_p); u3R->cap_p = u3R->ear_p; u3R->ear_p = 0; diff --git a/noun/nock.c b/noun/nock.c index 9188a6058..555a8c4db 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -680,12 +680,16 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, return u3kb_flop(sip); } +/* _n_prog_dat(): return pointer to program's data segment + */ static void* _n_prog_dat(u3n_prog* pog_u) { return ((void*) pog_u) + sizeof(u3n_prog); } +/* _n_prog_new(): allocate and set up pointers for u3n_prog + */ static u3n_prog* _n_prog_new(c3_w byc_w, c3_w cal_w, c3_w reg_w, c3_w lit_w, c3_w mem_w) @@ -716,6 +720,9 @@ _n_prog_new(c3_w byc_w, c3_w cal_w, return pog_u; } +/* _n_prog_old(): as _n_prog_new(), + * but leech off senior program's data segment + */ static u3n_prog* _n_prog_old(u3n_prog* sep_u) { @@ -746,6 +753,8 @@ _n_prog_old(u3n_prog* sep_u) return pog_u; } +/* _n_prog_asm_inx(): write an index to the bytestream with overflow + */ static void _n_prog_asm_inx(c3_y* buf_y, c3_w* i_w, c3_s inx_s, c3_y cod) { @@ -762,6 +771,8 @@ _n_prog_asm_inx(c3_y* buf_y, c3_w* i_w, c3_s inx_s, c3_y cod) } } +/* _n_prog_asm(): assemble list of ops (from _n_comp) into u3n_prog + */ static void _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) { @@ -905,6 +916,8 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) c3_assert(u3_nul == sip); } +/* _n_prog_from_ops(): new program from _n_comp() product + */ static u3n_prog* _n_prog_from_ops(u3_noun ops) { @@ -1416,7 +1429,7 @@ _n_print_byc(c3_y* pog, c3_w her_w) } #endif -/* _n_bite(): compile a nock formula to bytecode +/* _n_bite(): compile a nock formula to bytecode. RETAIN. */ static inline u3n_prog* _n_bite(u3_noun fol) { @@ -1465,7 +1478,7 @@ _n_find(u3_noun fol) } } -/* u3n_find(): return prog for given formula. fol is RETAINED. +/* u3n_find(): return prog for given formula. RETAIN. */ u3p(u3n_prog) u3n_find(u3_noun fol) @@ -1490,6 +1503,8 @@ _n_swap(c3_ys mov, c3_ys off) return top; } +/* _n_kick(): stop tracing noc and kick a u3j_site. + */ static u3_weak _n_kick(u3_noun cor, u3j_site* sit_u) { @@ -2139,6 +2154,8 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) } } +/* _n_burn_out(): execute u3n_prog with bus as subject. + */ static u3_noun _n_burn_out(u3_noun bus, u3n_prog* pog_u) { @@ -2195,6 +2212,10 @@ u3n_nock_on(u3_noun bus, u3_noun fol) return pro; } +/* _n_prog_take_dat(): copy references from src u3n_prog. overwritten + * values in dst u3n_prog are lost/freed only if + * los_o is yes. + */ static void _n_prog_take_dat(u3n_prog* dst_u, u3n_prog* src_u, c3_o los_o) { @@ -2303,14 +2324,16 @@ _n_reap(u3_noun kev) u3z(lof); } -/* u3n_beep(): promote bytecode state. +/* u3n_reap(): promote bytecode state. */ void -u3n_beep(u3p(u3h_root) har_p) +u3n_reap(u3p(u3h_root) har_p) { u3h_walk(har_p, _n_reap); } +/* _n_ream(): ream program call sites +*/ void _n_ream(u3_noun kev) { @@ -2356,7 +2379,7 @@ _n_prog_mark(u3n_prog* pog_u) return tot_w; } -/* _n_bam(): u3h_walk_with helper for u3n_bark +/* _n_bam(): u3h_walk_with helper for u3n_mark */ static void _n_bam(u3_noun kev, void* dat) @@ -2366,10 +2389,10 @@ _n_bam(u3_noun kev, void* dat) *bam_w += _n_prog_mark(pog); } -/* u3n_bark(): mark the bytecode cache for gc. +/* u3n_mark(): mark the bytecode cache for gc. */ c3_w -u3n_bark() +u3n_mark() { c3_w bam_w = 0; u3p(u3h_root) har_p = u3R->byc.har_p; @@ -2385,10 +2408,10 @@ _n_feb(u3_noun kev) _n_prog_free(u3to(u3n_prog, u3t(kev))); } -/* u3n_bree(): free bytecode cache +/* u3n_free(): free bytecode cache */ void -u3n_bree() +u3n_free() { u3p(u3h_root) har_p = u3R->byc.har_p; u3h_walk(har_p, _n_feb); From 30af289c34c5f8a104ac9cf5630fe12d998b0b48 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 30 Apr 2018 13:32:39 -0700 Subject: [PATCH 097/221] document u3n_prog and u3n_memo --- include/noun/nock.h | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index ef1f803de..5914f413c 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -6,33 +6,37 @@ *** **/ + /* u3n_memo: %memo hint space + */ typedef struct { c3_l sip_l; u3_noun key; } u3n_memo; + /* u3n_prog: program compiled from nock + */ typedef struct _u3n_prog { struct { - c3_o own_o; - c3_w len_w; - c3_y* ops_y; - } byc_u; + c3_o own_o; // program owns ops_y? + c3_w len_w; // length of bytecode (bytes) + c3_y* ops_y; // actual array of bytes + } byc_u; // bytecode struct { - c3_w len_w; - u3_noun* non; - } lit_u; + c3_w len_w; // number of literals + u3_noun* non; // array of literals + } lit_u; // literals struct { - c3_w len_w; - u3n_memo* sot_u; - } mem_u; + c3_w len_w; // number of memo slots + u3n_memo* sot_u; // array of memo slots + } mem_u; // memo slot data struct { - c3_w len_w; - u3j_site* sit_u; - } cal_u; + c3_w len_w; // number of calls sites + u3j_site* sit_u; // array of sites + } cal_u; // call site data struct { - c3_w len_w; - u3j_rite* rit_u; - } reg_u; + c3_w len_w; // number of registration sites + u3j_rite* rit_u; // array of sites + } reg_u; // registration site data } u3n_prog; /** Functions. From 10c775961f9b3d03e91ca6d85a2f527de673732c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 8 May 2018 13:33:55 -0700 Subject: [PATCH 098/221] stash - building and booting --- include/noun/jets.h | 26 ++- jets/tree.c | 491 ++++++++++++++++++++++---------------------- noun/jets.c | 465 +++++++++++++++++++++++++++-------------- noun/nock.c | 1 + 4 files changed, 574 insertions(+), 409 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 2bc1eab71..772c287ef 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -18,9 +18,12 @@ += activation $: hot-index=@ud drivers=(map axis @ud) label=path - jit=* + jit=* :: FIXME: should probably be (map battery *) + :: since there can be multiple batteries per location == :: ++= bash mug=@ :: later, noun-flavored sha256 ++= hot (map bash registry) += cold (map battery=^ registry) += warm (map location activation) #endif @@ -42,24 +45,34 @@ struct _u3j_core* cop_u; // containing core } u3j_harm; + /* u3j_hood: hook description. + */ + typedef struct _u3j_hood { + c3_c* nam_c; // hook name + c3_l axe_l; // hook axis (XX: direct) + } u3j_hood; + /* u3j_core: driver definition. */ typedef struct _u3j_core { c3_c* cos_c; // control string + c3_l axe_l; // axis to parent struct _u3j_harm* arm_u; // blank-terminated static list struct _u3j_core* dev_u; // blank-terminated static list + c3_c** bas_u; // blank-terminated static list + struct _u3j_hood* huc_u; // blank-terminated static list struct _u3j_core* par_u; // dynamic parent pointer - c3_l axe_l; // axis to parent c3_l jax_l; // index in global dashboard } u3j_core; /* u3e_dash, u3_Dash, u3D: jet dashboard singleton */ typedef struct _u3e_dash { - u3j_core* dev_u; // null-terminated static list - c3_l len_l; // dynamic array length - c3_l all_l; // allocated length - u3j_core* ray_u; // dynamic array by axis + u3j_core* dev_u; // null-terminated static list + c3_l len_l; // dynamic array length + c3_l all_l; // allocated length + u3j_core* ray_u; // dynamic array by axis + u3p(u3h_root) hot_p; // driver info by pasted hash } u3j_dash; /* u3j_fist: a single step in a fine check. @@ -92,6 +105,7 @@ u3p(struct _u3n_prog) pog_p; // program for formula u3_noun axe; // axis u3_weak bat; // battery (for verification) + u3_weak bas; // hash of battery (for hot find) u3_weak loc; // location (for reaming) c3_o jet_o; // have jet driver? c3_o fon_o; // site owns fink? diff --git a/jets/tree.c b/jets/tree.c index 784ae0607..8d0287507 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -17,54 +17,54 @@ static u3j_harm _143_hex_aes_cbcc_de_a[] = {{".2", u3wea_cbcc_de}, {}}; static u3j_core _143_hex_aes_ecba_d[] = - { { "en", _143_hex_aes_ecba_en_a }, - { "de", _143_hex_aes_ecba_de_a }, + { { "en", 7, _143_hex_aes_ecba_en_a }, + { "de", 7, _143_hex_aes_ecba_de_a }, {} }; static u3j_core _143_hex_aes_ecbb_d[] = - { { "en", _143_hex_aes_ecbb_en_a }, - { "de", _143_hex_aes_ecbb_de_a }, + { { "en", 7, _143_hex_aes_ecbb_en_a }, + { "de", 7, _143_hex_aes_ecbb_de_a }, {} }; static u3j_core _143_hex_aes_ecbc_d[] = - { { "en", _143_hex_aes_ecbc_en_a }, - { "de", _143_hex_aes_ecbc_de_a }, + { { "en", 7, _143_hex_aes_ecbc_en_a }, + { "de", 7, _143_hex_aes_ecbc_de_a }, {} }; static u3j_core _143_hex_aes_cbca_d[] = - { { "en", _143_hex_aes_cbca_en_a }, - { "de", _143_hex_aes_cbca_de_a }, + { { "en", 7, _143_hex_aes_cbca_en_a }, + { "de", 7, _143_hex_aes_cbca_de_a }, {} }; static u3j_core _143_hex_aes_cbcb_d[] = - { { "en", _143_hex_aes_cbcb_en_a }, - { "de", _143_hex_aes_cbcb_de_a }, + { { "en", 7, _143_hex_aes_cbcb_en_a }, + { "de", 7, _143_hex_aes_cbcb_de_a }, {} }; static u3j_core _143_hex_aes_cbcc_d[] = - { { "en", _143_hex_aes_cbcc_en_a }, - { "de", _143_hex_aes_cbcc_de_a }, + { { "en", 7, _143_hex_aes_cbcc_en_a }, + { "de", 7, _143_hex_aes_cbcc_de_a }, {} }; static u3j_core _143_hex_aes_d[] = - { { "ecba", 0, _143_hex_aes_ecba_d }, - { "ecbb", 0, _143_hex_aes_ecbb_d }, - { "ecbc", 0, _143_hex_aes_ecbc_d }, - { "cbca", 0, _143_hex_aes_cbca_d }, - { "cbcb", 0, _143_hex_aes_cbcb_d }, - { "cbcc", 0, _143_hex_aes_cbcc_d }, + { { "ecba", 7, 0, _143_hex_aes_ecba_d }, + { "ecbb", 7, 0, _143_hex_aes_ecbb_d }, + { "ecbc", 7, 0, _143_hex_aes_ecbc_d }, + { "cbca", 7, 0, _143_hex_aes_cbca_d }, + { "cbcb", 7, 0, _143_hex_aes_cbcb_d }, + { "cbcc", 7, 0, _143_hex_aes_cbcc_d }, {} }; static u3j_harm _143_hex_down_mark_a[] = {{".2", u3wg_down, c3y}, {}}; static u3j_core _143_hex_down_d[] = - { { "mark", _143_hex_down_mark_a }, + { { "mark", 7, _143_hex_down_mark_a }, {} }; @@ -78,24 +78,24 @@ static u3j_harm _143_hex_coed__ed_shar_a[] = {{".2", u3wee_shar}, {}}; static u3j_core _143_hex_coed__ed_d[] = - { { "sign", _143_hex_coed__ed_sign_a }, - { "puck", _143_hex_coed__ed_puck_a }, - { "veri", _143_hex_coed__ed_veri_a }, - { "shar", _143_hex_coed__ed_shar_a }, + { { "sign", 7, _143_hex_coed__ed_sign_a }, + { "puck", 7, _143_hex_coed__ed_puck_a }, + { "veri", 7, _143_hex_coed__ed_veri_a }, + { "shar", 7, _143_hex_coed__ed_shar_a }, {} }; static u3j_core _143_hex_coed_d[] = - { { "ed", 0, _143_hex_coed__ed_d }, + { { "ed", 3, 0, _143_hex_coed__ed_d }, {} }; static u3j_core _143_hex_d[] = - { { "down", 0, _143_hex_down_d }, - { "lore", _143_hex_lore_a }, - { "loss", _143_hex_loss_a }, - { "lune", _143_hex_lune_a }, - { "coed", 0, _143_hex_coed_d }, - { "aes", 0, _143_hex_aes_d }, + { { "down", 31337, 0, _143_hex_down_d }, + { "lore", 7, _143_hex_lore_a }, + { "loss", 7, _143_hex_loss_a }, + { "lune", 7, _143_hex_lune_a }, + { "coed", 31337, 0, _143_hex_coed_d }, + { "aes", 31337, 0, _143_hex_aes_d }, {} }; @@ -133,21 +133,21 @@ static u3j_core _143_hex_d[] = static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; static u3j_core _143_pen__ut_d[] = { - { "burn", _143_pen__ut_burn_a }, - { "conk", _143_pen__ut_conk_a }, - { "crop", _143_pen__ut_crop_a }, - { "fond", _143_pen__ut_fond_a }, - // { "fire", _143_pen__ut_fire_a }, - { "fish", _143_pen__ut_fish_a }, - { "fuse", _143_pen__ut_fuse_a }, - { "mint", _143_pen__ut_mint_a }, - { "mull", _143_pen__ut_mull_a }, - { "nest", _143_pen__ut_nest_a }, - { "peek", _143_pen__ut_peek_a }, - { "play", _143_pen__ut_play_a }, - { "rest", _143_pen__ut_rest_a }, - { "toss", _143_pen__ut_toss_a }, - { "wrap", _143_pen__ut_wrap_a }, + { "burn", 7, _143_pen__ut_burn_a }, + { "conk", 7, _143_pen__ut_conk_a }, + { "crop", 7, _143_pen__ut_crop_a }, + { "fond", 7, _143_pen__ut_fond_a }, + // { "fire", 7, _143_pen__ut_fire_a }, + { "fish", 7, _143_pen__ut_fish_a }, + { "fuse", 7, _143_pen__ut_fuse_a }, + { "mint", 7, _143_pen__ut_mint_a }, + { "mull", 7, _143_pen__ut_mull_a }, + { "nest", 7, _143_pen__ut_nest_a }, + { "peek", 7, _143_pen__ut_peek_a }, + { "play", 7, _143_pen__ut_play_a }, + { "rest", 7, _143_pen__ut_rest_a }, + { "toss", 7, _143_pen__ut_toss_a }, + { "wrap", 7, _143_pen__ut_wrap_a }, {} }; static u3j_harm _143_pen__ut_a[] = @@ -170,26 +170,26 @@ static u3j_core _143_hex_d[] = #endif static u3j_core _143_pen_d[] = - { { "hex", 0, _143_hex_d }, + { { "hex", 0, 0, _143_hex_d }, - { "cell", _143_pen_cell_a }, - { "comb", _143_pen_comb_a }, - { "cons", _143_pen_cons_a }, - { "core", _143_pen_core_a }, - { "face", _143_pen_face_a }, - { "fitz", _143_pen_fitz_a }, - { "flan", _143_pen_flan_a }, - { "flip", _143_pen_flip_a }, - { "flor", _143_pen_flor_a }, - { "fork", _143_pen_fork_a }, - { "help", _143_pen_help_a }, - { "hike", _143_pen_hike_a }, - { "look", _143_pen_look_a }, - { "loot", _143_pen_loot_a }, + { "cell", 7, _143_pen_cell_a }, + { "comb", 7, _143_pen_comb_a }, + { "cons", 7, _143_pen_cons_a }, + { "core", 7, _143_pen_core_a }, + { "face", 7, _143_pen_face_a }, + { "fitz", 7, _143_pen_fitz_a }, + { "flan", 7, _143_pen_flan_a }, + { "flip", 7, _143_pen_flip_a }, + { "flor", 7, _143_pen_flor_a }, + { "fork", 7, _143_pen_fork_a }, + { "help", 7, _143_pen_help_a }, + { "hike", 7, _143_pen_hike_a }, + { "look", 7, _143_pen_look_a }, + { "loot", 7, _143_pen_loot_a }, // { "ap", _143_pen__ap_a }, // { "al", _143_pen__al_a }, - { "ut", _143_pen__ut_a, _143_pen__ut_d }, + { "ut", 15, _143_pen__ut_a, _143_pen__ut_d }, {} }; @@ -203,88 +203,88 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__po_tod_a[] = {{".2", u3wcp_tod}, {}}; static u3j_harm _143_qua__po_tos_a[] = {{".2", u3wcp_tos}, {}}; static u3j_core _143_qua__po_d[] = - { { "ind", _143_qua__po_ind_a }, - { "ins", _143_qua__po_ins_a }, - { "tod", _143_qua__po_tod_a }, - { "tos", _143_qua__po_tos_a }, + { { "ind", 7, _143_qua__po_ind_a }, + { "ins", 7, _143_qua__po_ins_a }, + { "tod", 7, _143_qua__po_tod_a }, + { "tos", 7, _143_qua__po_tos_a }, {} }; static u3j_harm _143_qua__bend_fun_a[] = {{".2", u3we_bend_fun}, {}}; static u3j_core _143_qua__bend_d[] = - { { "fun", _143_qua__bend_fun_a }, + { { "fun", 7, _143_qua__bend_fun_a }, {} }; static u3j_harm _143_qua__cold_fun_a[] = {{".2", u3we_cold_fun}, {}}; static u3j_core _143_qua__cold_d[] = - { { "fun", _143_qua__cold_fun_a }, + { { "fun", 7, _143_qua__cold_fun_a }, {} }; static u3j_harm _143_qua__cook_fun_a[] = {{".2", u3we_cook_fun}, {}}; static u3j_core _143_qua__cook_d[] = - { { "fun", _143_qua__cook_fun_a }, + { { "fun", 7, _143_qua__cook_fun_a }, {} }; static u3j_harm _143_qua__comp_fun_a[] = {{".2", u3we_comp_fun}, {}}; static u3j_core _143_qua__comp_d[] = - { { "fun", _143_qua__comp_fun_a }, + { { "fun", 7, _143_qua__comp_fun_a }, {} }; static u3j_harm _143_qua__easy_fun_a[] = {{".2", u3we_easy_fun}, {}}; static u3j_core _143_qua__easy_d[] = - { { "fun", _143_qua__easy_fun_a }, + { { "fun", 7, _143_qua__easy_fun_a }, {} }; static u3j_harm _143_qua__glue_fun_a[] = {{".2", u3we_glue_fun}, {}}; static u3j_core _143_qua__glue_d[] = - { { "fun", _143_qua__glue_fun_a }, + { { "fun", 7, _143_qua__glue_fun_a }, {} }; static u3j_harm _143_qua__here_fun_a[] = {{".2", u3we_here_fun}, {}}; static u3j_core _143_qua__here_d[] = - { { "fun", _143_qua__here_fun_a }, + { { "fun", 7, _143_qua__here_fun_a }, {} }; static u3j_harm _143_qua__just_fun_a[] = {{".2", u3we_just_fun}, {}}; static u3j_core _143_qua__just_d[] = - { { "fun", _143_qua__just_fun_a }, + { { "fun", 7, _143_qua__just_fun_a }, {} }; static u3j_harm _143_qua__mask_fun_a[] = {{".2", u3we_mask_fun}, {}}; static u3j_core _143_qua__mask_d[] = - { { "fun", _143_qua__mask_fun_a }, + { { "fun", 7, _143_qua__mask_fun_a }, {} }; static u3j_harm _143_qua__shim_fun_a[] = {{".2", u3we_shim_fun}, {}}; static u3j_core _143_qua__shim_d[] = - { { "fun", _143_qua__shim_fun_a }, + { { "fun", 7, _143_qua__shim_fun_a }, {} }; static u3j_harm _143_qua__stag_fun_a[] = {{".2", u3we_stag_fun}, {}}; static u3j_core _143_qua__stag_d[] = - { { "fun", _143_qua__stag_fun_a }, + { { "fun", 7, _143_qua__stag_fun_a }, {} }; static u3j_harm _143_qua__stew_fun_a[] = {{".2", u3we_stew_fun}, {}}; static u3j_core _143_qua__stew_d[] = - { { "fun", _143_qua__stew_fun_a }, + { { "fun", 7, _143_qua__stew_fun_a }, {} }; static u3j_harm _143_qua__stir_fun_a[] = {{".2", u3we_stir_fun}, {}}; static u3j_core _143_qua__stir_d[] = - { { "fun", _143_qua__stir_fun_a }, + { { "fun", 7, _143_qua__stir_fun_a }, {} }; @@ -297,33 +297,33 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua_mule_a[] = {{".2", u3we_mule}, {}}; static u3j_core _143_qua_d[] = - { { "pen", 0, _143_pen_d }, + { { "pen", 3, 0, _143_pen_d }, - { "po", 0, _143_qua__po_d }, + { "po", 7, 0, _143_qua__po_d }, - { "trip", _143_qua_trip_a }, + { "trip", 7, _143_qua_trip_a }, - { "bend", 0, _143_qua__bend_d }, - { "cold", 0, _143_qua__cold_d }, - { "comp", 0, _143_qua__comp_d }, - { "cook", 0, _143_qua__cook_d }, - { "easy", 0, _143_qua__easy_d }, - { "glue", 0, _143_qua__glue_d }, - { "here", 0, _143_qua__here_d }, - { "just", 0, _143_qua__just_d }, - { "mask", 0, _143_qua__mask_d }, - { "shim", 0, _143_qua__shim_d }, - { "stag", 0, _143_qua__stag_d }, - { "stew", 0, _143_qua__stew_d }, - { "stir", 0, _143_qua__stir_d }, + { "bend", 7, 0, _143_qua__bend_d }, + { "cold", 7, 0, _143_qua__cold_d }, + { "comp", 7, 0, _143_qua__comp_d }, + { "cook", 7, 0, _143_qua__cook_d }, + { "easy", 7, 0, _143_qua__easy_d }, + { "glue", 7, 0, _143_qua__glue_d }, + { "here", 7, 0, _143_qua__here_d }, + { "just", 7, 0, _143_qua__just_d }, + { "mask", 7, 0, _143_qua__mask_d }, + { "shim", 7, 0, _143_qua__shim_d }, + { "stag", 7, 0, _143_qua__stag_d }, + { "stew", 7, 0, _143_qua__stew_d }, + { "stir", 7, 0, _143_qua__stir_d }, - { "pfix", _143_qua_pfix_a }, - { "plug", _143_qua_plug_a }, - { "pose", _143_qua_pose_a }, - { "sfix", _143_qua_sfix_a }, + { "pfix", 7, _143_qua_pfix_a }, + { "plug", 7, _143_qua_plug_a }, + { "pose", 7, _143_qua_pose_a }, + { "sfix", 7, _143_qua_sfix_a }, - { "mink", _143_qua_mink_a }, - { "mule", _143_qua_mule_a }, + { "mink", 7, _143_qua_mink_a }, + { "mule", 7, _143_qua_mule_a }, {} }; @@ -332,8 +332,8 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__cofl__drg_a[] = {{".2", u3wef_drg}, {}}; static u3j_harm _143_tri__cofl__lug_a[] = {{".2", u3wef_lug}, {}}; static u3j_core _143_tri__cofl_d[] = - { { "drg", _143_tri__cofl__drg_a }, - { "lug", _143_tri__cofl__lug_a }, + { { "drg", 7, _143_tri__cofl__drg_a }, + { "lug", 7, _143_tri__cofl__lug_a }, {} }; @@ -349,17 +349,17 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rd_gte_a[] = {{".2", u3wer_gte}, {}}; static u3j_harm _143_tri__rd_gth_a[] = {{".2", u3wer_gth}, {}}; static u3j_core _143_tri__rd_d[] = - { { "add", _143_tri__rd_add_a }, - { "sub", _143_tri__rd_sub_a }, - { "mul", _143_tri__rd_mul_a }, - { "div", _143_tri__rd_div_a }, - { "sqt", _143_tri__rd_sqt_a }, - { "fma", _143_tri__rd_fma_a }, - { "lth", _143_tri__rd_lth_a }, - { "lte", _143_tri__rd_lte_a }, - { "equ", _143_tri__rd_equ_a }, - { "gte", _143_tri__rd_gte_a }, - { "gth", _143_tri__rd_gth_a }, + { { "add", 7, _143_tri__rd_add_a }, + { "sub", 7, _143_tri__rd_sub_a }, + { "mul", 7, _143_tri__rd_mul_a }, + { "div", 7, _143_tri__rd_div_a }, + { "sqt", 7, _143_tri__rd_sqt_a }, + { "fma", 7, _143_tri__rd_fma_a }, + { "lth", 7, _143_tri__rd_lth_a }, + { "lte", 7, _143_tri__rd_lte_a }, + { "equ", 7, _143_tri__rd_equ_a }, + { "gte", 7, _143_tri__rd_gte_a }, + { "gth", 7, _143_tri__rd_gth_a }, {} }; static u3j_harm _143_tri__rs_add_a[] = {{".2", u3wet_add}, {}}; @@ -374,17 +374,17 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rs_gte_a[] = {{".2", u3wet_gte}, {}}; static u3j_harm _143_tri__rs_gth_a[] = {{".2", u3wet_gth}, {}}; static u3j_core _143_tri__rs_d[] = - { { "add", _143_tri__rs_add_a }, - { "sub", _143_tri__rs_sub_a }, - { "mul", _143_tri__rs_mul_a }, - { "div", _143_tri__rs_div_a }, - { "sqt", _143_tri__rs_sqt_a }, - { "fma", _143_tri__rs_fma_a }, - { "lth", _143_tri__rs_lth_a }, - { "lte", _143_tri__rs_lte_a }, - { "equ", _143_tri__rs_equ_a }, - { "gte", _143_tri__rs_gte_a }, - { "gth", _143_tri__rs_gth_a }, + { { "add", 7, _143_tri__rs_add_a }, + { "sub", 7, _143_tri__rs_sub_a }, + { "mul", 7, _143_tri__rs_mul_a }, + { "div", 7, _143_tri__rs_div_a }, + { "sqt", 7, _143_tri__rs_sqt_a }, + { "fma", 7, _143_tri__rs_fma_a }, + { "lth", 7, _143_tri__rs_lth_a }, + { "lte", 7, _143_tri__rs_lte_a }, + { "equ", 7, _143_tri__rs_equ_a }, + { "gte", 7, _143_tri__rs_gte_a }, + { "gth", 7, _143_tri__rs_gth_a }, {} }; @@ -400,17 +400,17 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rq_gte_a[] = {{".2", u3weq_gte}, {}}; static u3j_harm _143_tri__rq_gth_a[] = {{".2", u3weq_gth}, {}}; static u3j_core _143_tri__rq_d[] = - { { "add", _143_tri__rq_add_a }, - { "sub", _143_tri__rq_sub_a }, - { "mul", _143_tri__rq_mul_a }, - { "div", _143_tri__rq_div_a }, - { "sqt", _143_tri__rq_sqt_a }, - { "fma", _143_tri__rq_fma_a }, - { "lth", _143_tri__rq_lth_a }, - { "lte", _143_tri__rq_lte_a }, - { "equ", _143_tri__rq_equ_a }, - { "gte", _143_tri__rq_gte_a }, - { "gth", _143_tri__rq_gth_a }, + { { "add", 7, _143_tri__rq_add_a }, + { "sub", 7, _143_tri__rq_sub_a }, + { "mul", 7, _143_tri__rq_mul_a }, + { "div", 7, _143_tri__rq_div_a }, + { "sqt", 7, _143_tri__rq_sqt_a }, + { "fma", 7, _143_tri__rq_fma_a }, + { "lth", 7, _143_tri__rq_lth_a }, + { "lte", 7, _143_tri__rq_lte_a }, + { "equ", 7, _143_tri__rq_equ_a }, + { "gte", 7, _143_tri__rq_gte_a }, + { "gth", 7, _143_tri__rq_gth_a }, {} }; @@ -426,23 +426,23 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rh_gte_a[] = {{".2", u3wes_gte}, {}}; static u3j_harm _143_tri__rh_gth_a[] = {{".2", u3wes_gth}, {}}; static u3j_core _143_tri__rh_d[] = - { { "add", _143_tri__rh_add_a }, - { "sub", _143_tri__rh_sub_a }, - { "mul", _143_tri__rh_mul_a }, - { "div", _143_tri__rh_div_a }, - { "sqt", _143_tri__rh_sqt_a }, - { "fma", _143_tri__rh_fma_a }, - { "lth", _143_tri__rh_lth_a }, - { "lte", _143_tri__rh_lte_a }, - { "equ", _143_tri__rh_equ_a }, - { "gte", _143_tri__rh_gte_a }, - { "gth", _143_tri__rh_gth_a }, + { { "add", 7, _143_tri__rh_add_a }, + { "sub", 7, _143_tri__rh_sub_a }, + { "mul", 7, _143_tri__rh_mul_a }, + { "div", 7, _143_tri__rh_div_a }, + { "sqt", 7, _143_tri__rh_sqt_a }, + { "fma", 7, _143_tri__rh_fma_a }, + { "lth", 7, _143_tri__rh_lth_a }, + { "lte", 7, _143_tri__rh_lte_a }, + { "equ", 7, _143_tri__rh_equ_a }, + { "gte", 7, _143_tri__rh_gte_a }, + { "gth", 7, _143_tri__rh_gth_a }, {} }; static u3j_harm _143_tri__og_raw_a[] = {{".2", u3weo_raw}, {}}; static u3j_core _143_tri__og_d[] = - { { "raw", _143_tri__og_raw_a }, + { { "raw", 7, _143_tri__og_raw_a }, {} }; @@ -452,18 +452,18 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri_shal_a[] = {{".2", u3we_shal}, {}}; static u3j_core _143_tri_d[] = - { { "qua", 0, _143_qua_d }, + { { "qua", 3, 0, _143_qua_d }, - { "cofl", 0, _143_tri__cofl_d }, - { "rd", 0, _143_tri__rd_d }, - { "rs", 0, _143_tri__rs_d }, - { "rq", 0, _143_tri__rq_d }, - { "rh", 0, _143_tri__rh_d }, - { "og", 0, _143_tri__og_d }, - { "shax", _143_tri_shax_a }, - { "shay", _143_tri_shay_a }, - { "shas", _143_tri_shas_a }, - { "shal", _143_tri_shal_a }, + { "cofl", 7, 0, _143_tri__cofl_d }, + { "rd", 7, 0, _143_tri__rd_d }, + { "rs", 7, 0, _143_tri__rs_d }, + { "rq", 7, 0, _143_tri__rq_d }, + { "rh", 7, 0, _143_tri__rh_d }, + { "og", 7, 0, _143_tri__og_d }, + { "shax", 7, _143_tri_shax_a }, + { "shay", 7, _143_tri_shay_a }, + { "shas", 7, _143_tri_shas_a }, + { "shal", 7, _143_tri_shal_a }, {} }; @@ -529,16 +529,16 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; static u3j_harm _143_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static u3j_core _143_two__in_d[] = - { { "bif", _143_two__in_bif_a }, - { "dif", _143_two__in_dif_a }, - { "gas", _143_two__in_gas_a }, - { "has", _143_two__in_has_a }, - { "mer", _143_two__in_mer_a }, - // { "int", _143_two__in_int_a }, - { "put", _143_two__in_put_a }, - { "tap", _143_two__in_tap_a }, - { "wyt", _143_two__in_wyt_a }, - { "uni", _143_two__in_uni_a }, + { { "bif", 7, _143_two__in_bif_a }, + { "dif", 7, _143_two__in_dif_a }, + { "gas", 7, _143_two__in_gas_a }, + { "has", 7, _143_two__in_has_a }, + { "mer", 7, _143_two__in_mer_a }, + // { "int", 7, _143_two__in_int_a }, + { "put", 7, _143_two__in_put_a }, + { "tap", 7, _143_two__in_tap_a }, + { "wyt", 7, _143_two__in_wyt_a }, + { "uni", 7, _143_two__in_uni_a }, {} }; @@ -552,14 +552,14 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; // static u3j_harm _143_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; static u3j_core _143_two__by_d[] = - { { "bif", _143_two__by_bif_a }, - { "dif", _143_two__by_dif_a }, - { "gas", _143_two__by_gas_a }, - { "get", _143_two__by_get_a }, - { "has", _143_two__by_has_a }, - // { "int", _143_two__by_int_a }, - { "put", _143_two__by_put_a }, - { "tap", _143_two__by_tap_a }, + { { "bif", 7, _143_two__by_bif_a }, + { "dif", 7, _143_two__by_dif_a }, + { "gas", 7, _143_two__by_gas_a }, + { "get", 7, _143_two__by_get_a }, + { "has", 7, _143_two__by_has_a }, + // { "int", 7, _143_two__by_int_a }, + { "put", 7, _143_two__by_put_a }, + { "tap", 7, _143_two__by_tap_a }, // { "uni", _143_two__by_uni_a }, {} }; @@ -570,60 +570,61 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_rub_a[] = {{".2", u3we_rub}, {}}; static u3j_core _143_two_d[] = - { { "tri", 0, _143_tri_d }, - { "flop", _143_two_flop_a }, - { "lent", _143_two_lent_a }, - { "levy", _143_two_levy_a }, - { "lien", _143_two_lien_a }, - { "murn", _143_two_murn_a }, - { "need", _143_two_need_a }, - { "reap", _143_two_reap_a }, - { "reel", _143_two_reel_a }, - { "roll", _143_two_roll_a }, - { "skid", _143_two_skid_a }, - { "skim", _143_two_skim_a }, - { "skip", _143_two_skip_a }, - { "scag", _143_two_scag_a }, - { "slag", _143_two_slag_a }, - { "snag", _143_two_snag_a }, -// { "sort", _143_two_sort_a }, - { "turn", _143_two_turn_a }, - { "weld", _143_two_weld_a }, + { { "tri", 3, 0, _143_tri_d }, + { "flop", 7, _143_two_flop_a }, + { "lent", 7, _143_two_lent_a }, + { "levy", 7, _143_two_levy_a }, + { "lien", 7, _143_two_lien_a }, + { "murn", 7, _143_two_murn_a }, + { "need", 7, _143_two_need_a }, + { "reap", 7, _143_two_reap_a }, + { "reel", 7, _143_two_reel_a }, + { "roll", 7, _143_two_roll_a }, + { "skid", 7, _143_two_skid_a }, + { "skim", 7, _143_two_skim_a }, + { "skip", 7, _143_two_skip_a }, + { "scag", 7, _143_two_scag_a }, + { "slag", 7, _143_two_slag_a }, + { "snag", 7, _143_two_snag_a }, +// { "sort", 7, _143_two_sort_a }, + { "turn", 7, _143_two_turn_a }, + { "weld", 7, _143_two_weld_a }, - { "bex", _143_two_bex_a }, - { "cat", _143_two_cat_a }, - { "can", _143_two_can_a }, - { "cap", _143_two_cap_a }, - { "con", _143_two_con_a }, - { "cue", _143_two_cue_a }, - { "cut", _143_two_cut_a }, - { "dis", _143_two_dis_a }, - { "dor", _143_two_dor_a }, - { "dvr", _143_two_dvr_a }, - { "end", _143_two_end_a }, - { "gor", _143_two_gor_a }, - { "hor", _143_two_hor_a }, - { "jam", _143_two_jam_a }, - { "lsh", _143_two_lsh_a }, - { "mas", _143_two_mas_a }, - { "mat", _143_two_mat_a }, - { "met", _143_two_met_a }, - { "mix", _143_two_mix_a }, - { "mug", _143_two_mug_a }, - { "muk", _143_two_muk_a }, - { "rap", _143_two_rap_a }, - { "rep", _143_two_rep_a }, - { "rip", _143_two_rip_a }, - { "rsh", _143_two_rsh_a }, - { "rub", _143_two_rub_a }, - { "peg", _143_two_peg_a }, - { "pow", _143_two_pow_a }, - { "sqt", _143_two_sqt_a }, - { "vor", _143_two_vor_a }, - { "xeb", _143_two_xeb_a }, + { "bex", 7, _143_two_bex_a }, + { "cat", 7, _143_two_cat_a }, + { "can", 7, _143_two_can_a }, + { "cap", 7, _143_two_cap_a }, + { "con", 7, _143_two_con_a }, + { "cue", 7, _143_two_cue_a }, + { "cut", 7, _143_two_cut_a }, + { "dis", 7, _143_two_dis_a }, + { "dor", 7, _143_two_dor_a }, + { "dvr", 7, _143_two_dvr_a }, + { "end", 7, _143_two_end_a }, + { "gor", 7, _143_two_gor_a }, + { "hor", 7, _143_two_hor_a }, + { "jam", 7, _143_two_jam_a }, + { "lsh", 7, _143_two_lsh_a }, + { "mas", 7, _143_two_mas_a }, + { "mat", 7, _143_two_mat_a }, + { "met", 7, _143_two_met_a }, + { "mix", 7, _143_two_mix_a }, + { "mug", 7, _143_two_mug_a }, + { "muk", 7, _143_two_muk_a }, + { "rap", 7, _143_two_rap_a }, + { "rep", 7, _143_two_rep_a }, + { "rip", 7, _143_two_rip_a }, + { "rsh", 7, _143_two_rsh_a }, + { "rub", 7, _143_two_rub_a }, + { "peg", 7, _143_two_peg_a }, + { "pow", 7, _143_two_pow_a }, + { "sqt", 7, _143_two_sqt_a }, + { "vor", 7, _143_two_vor_a }, + { "xeb", 7, _143_two_xeb_a }, - { "by", 0, _143_two__by_d }, - { "in", 0, _143_two__in_d }, + { "by", 7, 0, _143_two__by_d }, + { "in", 7, 0, _143_two__in_d }, + {}, }; @@ -646,32 +647,32 @@ static u3j_core _143_two_d[] = static u3j_harm _143_one_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; static u3j_core _143_one_d[] = - { { "two", 0, _143_two_d }, - { "add", _143_one_add_a }, - { "dec", _143_one_dec_a }, - { "div", _143_one_div_a }, - { "dvr", _143_one_dvr_a }, - { "gte", _143_one_gte_a }, - { "gth", _143_one_gth_a }, - { "lte", _143_one_lte_a }, - { "lth", _143_one_lth_a }, - { "mod", _143_one_mod_a }, - { "mul", _143_one_mul_a }, - { "sub", _143_one_sub_a }, + { { "two", 3, 0, _143_two_d }, + { "add", 7, _143_one_add_a }, + { "dec", 7, _143_one_dec_a }, + { "div", 7, _143_one_div_a }, + { "dvr", 7, _143_one_dvr_a }, + { "gte", 7, _143_one_gte_a }, + { "gth", 7, _143_one_gth_a }, + { "lte", 7, _143_one_lte_a }, + { "lth", 7, _143_one_lth_a }, + { "mod", 7, _143_one_mod_a }, + { "mul", 7, _143_one_mul_a }, + { "sub", 7, _143_one_sub_a }, - { "cap", _143_one_cap_a }, - { "mas", _143_one_mas_a }, - { "peg", _143_one_peg_a }, + { "cap", 7, _143_one_cap_a }, + { "mas", 7, _143_one_mas_a }, + { "peg", 7, _143_one_peg_a }, {} }; u3j_core _k143_d[] = - { { "one", 0, _143_one_d }, + { { "one", 3, 0, _143_one_d }, {} }; static u3j_core _d[] = { - { "k143", 0, _k143_d}, + { "k143", 0, 0, _k143_d, 0, 0, (u3j_core*) 143, 0}, {} }; diff --git a/noun/jets.c b/noun/jets.c index f764fb708..8dda1b89b 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -6,53 +6,195 @@ /** Data structures. **/ - /* _cj_hank: cached hook information. - */ - typedef struct { - u3_weak hax; // axis of hooked inner core - u3j_site sit_u; // call-site data - } _cj_hank; +/* _cj_hank: cached hook information. + */ +typedef struct { + u3_weak hax; // axis of hooked inner core + u3j_site sit_u; // call-site data +} _cj_hank; /** Functions. **/ - /* _cj_count(): count and link dashboard entries. - */ - static c3_w - _cj_count(u3j_core* par_u, u3j_core* dev_u) - { - c3_w len_l = 0; - c3_w i_w; +/* _cj_count(): count and link dashboard entries. +*/ +static c3_w +_cj_count(u3j_core* par_u, u3j_core* dev_u) +{ + c3_w len_l = 0; + c3_w i_w; - if ( dev_u ) { - for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) { - u3j_core* kid_u = &dev_u[i_w]; + if ( dev_u ) { + for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) { + u3j_core* kid_u = &dev_u[i_w]; + if ( par_u ) { kid_u->par_u = par_u; - len_l += _cj_count(kid_u, kid_u->dev_u); } + len_l += _cj_count(kid_u, kid_u->dev_u); } - return 1 + len_l; } - /* _cj_install(): install dashboard entries. - */ - static c3_w - _cj_install(u3j_core* ray_u, c3_w jax_l, u3j_core* dev_u) - { - c3_w i_w; + return 1 + len_l; +} - if ( dev_u ) { - for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) { - u3j_core* kid_u = &dev_u[i_w]; +/* _cj_core_loc(): location noun from u3j_core. pel is TRANSFERRED. + */ +static u3_noun +_cj_core_loc(u3_noun pel, u3j_core* cop_u) +{ + c3_w i_w; + u3_noun nam = u3i_string(cop_u->cos_c), + huc = u3_nul, + pat; - kid_u->jax_l = jax_l; - ray_u[jax_l++] = *kid_u; + if ( cop_u->huc_u ) { + for ( i_w = 0; 0 != cop_u->huc_u[i_w].nam_c; ++i_w ) { + huc = u3kdb_put(huc, + u3i_string(cop_u->huc_u[i_w].nam_c), + cop_u->huc_u[i_w].axe_l); + } + } - jax_l = _cj_install(ray_u, jax_l, kid_u->dev_u); + pat = ( 0 == cop_u->axe_l ) + ? u3nt(c3y, c3y, pel) + : ( (3 == cop_u->axe_l) && (c3y == u3h(pel)) ) + ? u3nt(c3y, c3n, pel) + : u3nt(c3n, cop_u->axe_l, pel); + + return u3nt(pat, nam, huc); +} + +/* _cj_hash(): noun from pasted-in battery hash + */ +static u3_noun +_cj_hash(c3_c* has_c) +{ + c3_l mug; + sscanf(has_c, "%d", &mug); + return mug; +} + +/* _cj_bash(): battery hash. + */ +static u3_noun +_cj_bash(u3_noun bat) +{ + return u3r_mug(bat); +} + +/* _cj_mine_par_old(): register hooks and parent location within existing + * axis in ancestor list or u3_none. RETAIN. + */ +static u3_weak +_cj_mine_par_old(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) +{ + u3_noun par; + if ( u3_nul == lan ) { + return u3_none; + } + else if ( c3y == u3r_sing(axe, u3h(par = u3h(lan))) ) { + u3_noun lol = u3qdb_put(u3t(par), pel, loc), + rap = u3nc(u3k(axe), lol); + return u3nc(rap, u3k(u3t(lan))); + } + else { + u3_weak nex = _cj_mine_par_old(u3t(lan), axe, pel, loc); + if ( u3_none == nex ) { + return u3_none; + } + else { + return u3nc(u3k(par), nex); + } + } +} + +/* _cj_mine_par_new(): insert ancestor within lan at sorted index. RETAIN. + */ +static u3_noun +_cj_mine_par_new(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) +{ + u3_noun par; + if ( (u3_nul == lan) || (c3y == u3qa_lth(axe, u3h(u3h(lan)))) ) { + par = u3nc(u3k(axe), u3qdb_put(u3_nul, pel, loc)); + return u3nc(par, u3k(lan)); + } + else { + return u3nc(u3k(u3h(lan)), + _cj_mine_par_new(u3t(lan), axe, pel, loc)); + } +} + +/* _cj_mine_par(): register a location as an ancestor in a list of ancestors. + * RETAIN. + */ +static u3_noun +_cj_mine_par(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) +{ + u3_weak old = _cj_mine_par_old(lan, axe, pel, loc); + if ( u3_none != old ) { + return old; + } + else { + return _cj_mine_par_new(lan, axe, pel, loc); + } +} + + +/* _cj_gust(): add location to registry. TRANSFER. */ +static u3_noun +_cj_gust(u3_weak reg, u3_noun axe, u3_noun pel, u3_noun loc) +{ + u3_noun ger; + if ( u3_none == reg ) { + reg = u3nc(u3_nul, u3_nul); + } + + ger = ( 0 == axe ) + ? u3nc(u3qdb_put(u3h(reg), pel, loc), u3k(u3t(reg))) + : u3nc(u3k(u3h(reg)), _cj_mine_par(u3t(reg), axe, pel, loc)); + + u3z(reg); + u3z(pel); + u3z(loc); + u3z(axe); + return ger; +} + +/* _cj_install(): install dashboard entries. +*/ +static c3_w +_cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev_u) +{ + c3_w i_w; + + if ( dev_u ) { + for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) { + u3j_core* kid_u = &dev_u[i_w]; + u3_noun loc = _cj_core_loc(u3k(pel), kid_u), + bal = u3nc(u3k(u3h(u3t(loc))), u3k(lab)); + + if ( kid_u->bas_u ) { + c3_w j_w; + for ( j_w = 0; 0 != kid_u->bas_u[j_w]; j_w++ ) { + u3_noun key = _cj_hash(kid_u->bas_u[j_w]), + reg = _cj_gust(u3h_get(u3D.hot_p, key), + kid_u->axe_l, u3k(pel), u3k(loc)); + u3h_put(u3D.hot_p, key, + u3nq(reg, jax_l, u3k(u3t(u3t(loc))), u3k(bal))); + u3z(key); + } } + + kid_u->jax_l = jax_l; + ray_u[jax_l++] = *kid_u; + + jax_l = _cj_install(ray_u, jax_l, loc, bal, kid_u->dev_u); } - return jax_l; + u3z(pel); + u3z(lab); } + return jax_l; +} /* _cj_axis(): axis from formula, or 0. `fol` is RETAINED. */ @@ -239,48 +381,97 @@ _cj_find_warm(u3_noun loc) } } -/* _cj_spot(): find location of cor. expensive. cor is RETAINED. - */ +static u3_weak _cj_spot(u3_noun cor, u3_weak bas); + static u3_weak -_cj_spot(u3_noun cor) +_cj_reg_find(u3_noun reg, u3_noun cor) { - u3_weak reg = _cj_find_cold(u3h(cor)); - if ( u3_none == reg ) { - return u3_none; + u3_noun rut = u3h(reg), + pas = u3t(reg), + rum = u3qdb_get(rut, u3t(cor)); + if ( u3_nul != rum ) { + u3_noun loc = u3k(u3t(rum)); + u3z(rum); + return loc; } else { - u3_noun rut = u3h(reg), - pas = u3t(reg), - rum = u3qdb_get(rut, u3t(cor)); - if ( u3_nul != rum ) { - u3_noun loc = u3k(u3t(rum)); - u3z(rum); u3z(reg); - return loc; - } - else { - while ( u3_nul != pas ) { - u3_noun pap = u3h(pas), - axe = u3h(pap), - lol = u3t(pap); - u3_weak par = u3r_at(axe, cor), - pel; - if ( u3_none != par ) { - pel = _cj_spot(par); - if ( u3_none != pel ) { - u3_noun nit = u3qdb_get(lol, pel); - u3z(pel); - if ( u3_nul != nit ) { - u3_noun loc = u3k(u3t(nit)); - u3z(nit); u3z(reg); - return loc; - } + while ( u3_nul != pas ) { + u3_noun pap = u3h(pas), + axe = u3h(pap), + lol = u3t(pap); + u3_weak par = u3r_at(axe, cor), + pel; + if ( u3_none != par ) { + pel = _cj_spot(par, u3_none); + if ( u3_none != pel ) { + u3_noun nit = u3qdb_get(lol, pel); + u3z(pel); + if ( u3_nul != nit ) { + u3_noun loc = u3k(u3t(nit)); + u3z(nit); + return loc; } } - pas = u3t(pas); } - u3z(reg); + pas = u3t(pas); + } + return u3_none; + } +} + +/* _cj_jit(): generate arbitrary warm jet-associated data. RETAIN. +*/ +static u3_noun +_cj_jit(c3_l jax_l, u3_noun bat) +{ + return u3_nul; +} + +/* _cj_spot(): find location of cor. expensive. cor is RETAINED. + * bas is an optional cached battery hash for the hot lookup, + * and is TRANSFERRED if not u3_none. + */ +static u3_weak +_cj_spot(u3_noun cor, u3_weak bas) +{ + u3_weak reg = _cj_find_cold(u3h(cor)); + u3_weak act = u3_none; + + if ( u3_none == reg ) { + u3_noun hot; + /* reconstruct from hot data */ + if ( u3_none == bas ) { + bas = _cj_bash(u3h(cor)); + } + hot = u3h_get(u3D.hot_p, bas); + if ( u3_none == hot ) { return u3_none; } + else { + u3_noun jax, hap, bal; + c3_l jax_l; + u3x_qual(hot, ®, &jax, &hap, &bal); + jax_l = (c3_l) jax; + act = u3nq(jax_l, u3k(hap), u3k(bal), _cj_jit(jax_l, u3h(cor))); + u3z(hot); + u3h_put(u3R->jed.cod_p, u3h(cor), u3k(reg)); + } + } + + if ( u3_none != bas ) { + u3z(bas); + } + + { + u3_weak loc = _cj_reg_find(reg, cor); + if ( u3_none != loc && u3_none != act ) { + // caution: could overwrites old value, debug batteries etc. + // old value contains old _cj_jit (from different + // battery). if we change jit to (map battery *), + // will need to merge with that map here. + u3h_put(u3R->jed.war_p, loc, act); + } + return loc; } } @@ -385,7 +576,7 @@ _cj_nail(u3_noun loc, u3_noun axe, static c3_o _cj_scan(u3_noun cor) { - u3_weak loc = _cj_spot(cor); + u3_weak loc = _cj_spot(cor, u3_none); c3_o reg_o = (u3_none == loc) ? c3n : c3y; u3z(loc); return reg_o; @@ -489,7 +680,8 @@ u3j_boot(void) u3D.ray_u = (u3j_core*) malloc(u3D.all_l * sizeof(u3j_core)); memset(u3D.ray_u, 0, (u3D.all_l * sizeof(u3j_core))); - jax_l = _cj_install(u3D.ray_u, 1, u3D.dev_u); + u3D.hot_p = u3h_new(); + jax_l = _cj_install(u3D.ray_u, 1, (c3_l) (long long) u3D.ray_u[0].par_u, u3_nul, u3D.dev_u); fprintf(stderr, "boot: installed %d jets\n", jax_l); } @@ -608,7 +800,7 @@ _cj_hook_in(u3_noun cor, return u3m_bail(c3__fail); } - loc = _cj_spot(cor); + loc = _cj_spot(cor, u3_none); if ( u3_none == loc ) { return u3m_bail(c3__fail); } @@ -808,7 +1000,8 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) return u3m_bail(c3__fail); } - if ( u3_none == (col = loc = _cj_spot(cor)) ) { + sit_u->bas = _cj_bash(u3h(cor)); + if ( u3_none == (col = loc = _cj_spot(cor, u3k(sit_u->bas))) ) { return u3m_bail(c3__fail); } @@ -872,7 +1065,7 @@ u3_weak u3j_kick(u3_noun cor, u3_noun axe) { u3t_on(glu_o); - u3_weak loc = _cj_spot(cor); + u3_weak loc = _cj_spot(cor, u3_none); if ( u3_none == loc ) { u3t_off(glu_o); return u3_none; @@ -1022,6 +1215,7 @@ u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o) } else { dst_u->bat = u3_none; + dst_u->bas = u3_none; dst_u->pog_p = 0; dst_u->loc = u3_none; dst_u->lab = u3_none; @@ -1167,7 +1361,10 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) } if ( u3_none == loc ) { - loc = _cj_spot(cor); + if ( u3_none == sit_u->bas ) { + sit_u->bas = _cj_bash(u3h(cor)); + } + loc = _cj_spot(cor, u3k(sit_u->bas)); if ( u3_none != loc ) { u3p(u3j_fink) fon_p = 0; u3_weak lod = u3_none; @@ -1289,7 +1486,7 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) sit_u->axe = 2; sit_u->bat = cor; // a lie, this isn't really the battery! sit_u->pog_p = _cj_prog(u3h(cor)); - if ( u3_none != (loc = sit_u->loc = _cj_spot(cor)) ) { + if ( u3_none != (loc = sit_u->loc = _cj_spot(cor, u3_none)) ) { u3_noun pax = u3h(u3t(loc)), pay = u3qc_cap(pax), pam = u3qc_mas(pax); @@ -1342,71 +1539,6 @@ u3j_gate_lose(u3j_site* sit_u) } } -/* _cj_jit(): generate arbitrary warm jet-associated data. RETAIN. -*/ -static u3_noun -_cj_jit(c3_l jax_l, u3_noun bat) -{ - return u3_nul; -} - -/* _cj_mine_par_old(): register hooks and parent location within existing - * axis in ancestor list or u3_none. RETAIN. - */ -static u3_weak -_cj_mine_par_old(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) -{ - u3_noun par; - if ( u3_nul == lan ) { - return u3_none; - } - else if ( c3y == u3r_sing(axe, u3h(par = u3h(lan))) ) { - u3_noun lol = u3qdb_put(u3t(par), pel, loc), - rap = u3nc(u3k(axe), lol); - return u3nc(rap, u3k(u3t(lan))); - } - else { - u3_weak nex = _cj_mine_par_old(u3t(lan), axe, pel, loc); - if ( u3_none == nex ) { - return u3_none; - } - else { - return u3nc(u3k(par), nex); - } - } -} - -/* _cj_mine_par_new(): insert ancestor within lan at sorted index. RETAIN. - */ -static u3_noun -_cj_mine_par_new(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) -{ - u3_noun par; - if ( (u3_nul == lan) || (c3y == u3qa_lth(axe, u3h(u3h(lan)))) ) { - par = u3nc(u3k(axe), u3qdb_put(u3_nul, pel, loc)); - return u3nc(par, u3k(lan)); - } - else { - return u3nc(u3k(u3h(lan)), - _cj_mine_par_new(u3t(lan), axe, pel, loc)); - } -} - -/* _cj_mine_par(): register a location as an ancestor in a list of ancestors. - * RETAIN. - */ -static u3_noun -_cj_mine_par(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) -{ - u3_weak old = _cj_mine_par_old(lan, axe, pel, loc); - if ( u3_none != old ) { - return old; - } - else { - return _cj_mine_par_new(lan, axe, pel, loc); - } -} - /* _cj_mine(): declare a core and produce location. RETAIN. */ static u3_weak @@ -1414,24 +1546,17 @@ _cj_mine(u3_noun cey, u3_noun cor) { c3_l par_l, jax_l; u3_noun bat = u3h(cor), - hap, reg, loc, bal, act, nam, axe, huc, ger; + pel, hap, reg, loc, bal, act, nam, axe, huc; u3x_trel(cey, &nam, &axe, &huc); if ( 0 == axe ) { - u3_noun pay = u3t(cor); - reg = _cj_find_cold(bat); - loc = u3nt(u3nt(c3y, c3y, u3k(pay)), u3k(nam), u3k(huc)); - if ( u3_none == reg ) { - reg = u3nc(u3_nul, u3_nul); - } - ger = u3nc(u3qdb_put(u3h(reg), pay, loc), u3k(u3t(reg))); - u3z(reg); - reg = ger; + pel = u3k(u3t(cor)); + loc = u3nt(u3nt(c3y, c3y, u3k(pel)), u3k(nam), u3k(huc)); bal = u3nc(u3k(nam), u3_nul); par_l = 0; } else { - u3_weak par, pel, pac; + u3_weak par, pac; u3_noun pat; par = u3r_at(axe, cor); @@ -1439,7 +1564,7 @@ _cj_mine(u3_noun cey, u3_noun cor) fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(nam)); return u3_none; } - pel = _cj_spot(par); + pel = _cj_spot(par, u3_none); if ( u3_none == pel ) { fprintf(stderr, "fund: in %s, parent %x not found at %d\r\n", u3r_string(nam), @@ -1456,15 +1581,8 @@ _cj_mine(u3_noun cey, u3_noun cor) ? u3nt(c3y, c3n, u3k(pel)) : u3nt(c3n, u3k(axe), u3k(pel)); loc = u3nt(pat, u3k(nam), u3k(huc)); - reg = _cj_find_cold(bat); - if ( u3_none == reg ) { - reg = u3nc(u3_nul, u3_nul); - } - ger = u3nc(u3k(u3h(reg)), - _cj_mine_par(u3t(reg), axe, pel, loc)); - u3z(pel); u3z(reg); - reg = ger; } + reg = _cj_gust(_cj_find_cold(bat), u3k(axe), pel, u3k(loc)); jax_l = _cj_hot_mean(par_l, nam); #if 0 u3m_p("new jet", bal); @@ -1473,7 +1591,36 @@ _cj_mine(u3_noun cey, u3_noun cor) hap = _cj_warm_hump(jax_l, huc); act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); u3h_put(u3R->jed.cod_p, bat, reg); - u3h_put(u3R->jed.war_p, loc, act); + u3h_put(u3R->jed.war_p, loc, act); // see note in _cj_spot + + { + u3_noun bas = _cj_bash(bat); + u3_noun hot = u3h_get(u3D.hot_p, bas); + c3_o hav_o = c3n; + + if ( u3_none == hot ) { + u3m_p("unregistered battery", bal); + } + else { + u3_noun hol = _cj_reg_find(hot, cor); + if ( hol != u3_none ) { + if ( c3n == u3r_sing(loc, hol) ) { + u3m_p("bogus hot location", hol); + u3m_p("registered as", loc); + } + else { + hav_o = c3y; + } + } + u3z(hol); + u3z(hot); + } + + if ( c3n == hav_o ) { + fprintf(stderr, "hash: %x\r\n", bas); + } + u3z(bas); + } return loc; } @@ -1505,7 +1652,7 @@ _cj_mile(u3_noun clu, u3_noun cor) u3z(cor); } else { - loc = _cj_spot(cor); + loc = _cj_spot(cor, u3_none); if ( u3_none == loc ) { loc = _cj_moan(clu, cor); } @@ -1522,6 +1669,7 @@ _cj_mile(u3_noun clu, u3_noun cor) void u3j_mine(u3_noun clu, u3_noun cor) { + // TODO: bail early unless developer mode is set u3t_on(glu_o); if ( (c3n == u3du(cor)) || (c3y == _cj_scan(cor)) ) { u3z(clu); @@ -1541,6 +1689,7 @@ u3j_mine(u3_noun clu, u3_noun cor) void u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) { + // TODO: bail early unless developer mode is set c3_t non_t; u3t_on(glu_o); diff --git a/noun/nock.c b/noun/nock.c index 555a8c4db..f133a0434 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -896,6 +896,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) sit_u->axe = u3k(u3t(op)); sit_u->pog_p = 0; sit_u->bat = u3_none; + sit_u->bas = u3_none; sit_u->loc = u3_none; sit_u->lab = u3_none; sit_u->jet_o = c3n; From 109ad54c53258448eade30278b4862725215835c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 8 May 2018 18:30:19 -0700 Subject: [PATCH 099/221] booting and verifying - pasting in hashes now --- include/noun/jets.h | 9 +++- jets/tree.c | 127 +++++++++++++++++++++++++++++++++++++------- noun/jets.c | 47 +++++++++------- 3 files changed, 141 insertions(+), 42 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 772c287ef..0732aaade 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -21,9 +21,14 @@ jit=* :: FIXME: should probably be (map battery *) :: since there can be multiple batteries per location == -:: ++= hot-info $: reg=registry + hot-index=@ud + drivers=(map axis @ud) + label=path + == += bash mug=@ :: later, noun-flavored sha256 -+= hot (map bash registry) +:: ++= hot (map bash hot-info) += cold (map battery=^ registry) += warm (map location activation) #endif diff --git a/jets/tree.c b/jets/tree.c index 8d0287507..e9917a08d 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -217,8 +217,12 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__cold_fun_a[] = {{".2", u3we_cold_fun}, {}}; + static c3_c* _143_qua__cold_fun_ha[] = { + "7a6d3682", + 0, + }; static u3j_core _143_qua__cold_d[] = - { { "fun", 7, _143_qua__cold_fun_a }, + { { "fun", 7, _143_qua__cold_fun_a, 0, _143_qua__cold_fun_ha }, {} }; @@ -235,8 +239,12 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__easy_fun_a[] = {{".2", u3we_easy_fun}, {}}; + static c3_c* _143_qua__easy_fun_ha[] = { + "13cb0749", + 0, + }; static u3j_core _143_qua__easy_d[] = - { { "fun", 7, _143_qua__easy_fun_a }, + { { "fun", 7, _143_qua__easy_fun_a, 0, _143_qua__easy_fun_ha }, {} }; @@ -253,20 +261,32 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__just_fun_a[] = {{".2", u3we_just_fun}, {}}; + static c3_c* _143_qua__just_fun_ha[] = { + "50d2f368", + 0, + }; static u3j_core _143_qua__just_d[] = - { { "fun", 7, _143_qua__just_fun_a }, + { { "fun", 7, _143_qua__just_fun_a, 0, _143_qua__just_fun_ha }, {} }; static u3j_harm _143_qua__mask_fun_a[] = {{".2", u3we_mask_fun}, {}}; + static c3_c* _143_qua__mask_fun_ha[] = { + "5fb25be8", + 0, + }; static u3j_core _143_qua__mask_d[] = - { { "fun", 7, _143_qua__mask_fun_a }, + { { "fun", 7, _143_qua__mask_fun_a, 0, _143_qua__mask_fun_ha }, {} }; static u3j_harm _143_qua__shim_fun_a[] = {{".2", u3we_shim_fun}, {}}; + static c3_c* _143_qua__shim_fun_ha[] = { + "61c4cfac", + 0, + }; static u3j_core _143_qua__shim_d[] = - { { "fun", 7, _143_qua__shim_fun_a }, + { { "fun", 7, _143_qua__shim_fun_a, 0, _143_qua__shim_fun_ha }, {} }; @@ -283,8 +303,12 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__stir_fun_a[] = {{".2", u3we_stir_fun}, {}}; + static c3_c* _143_qua__stir_fun_ha[] = { + "261f565a", + 0, + }; static u3j_core _143_qua__stir_d[] = - { { "fun", 7, _143_qua__stir_fun_a }, + { { "fun", 7, _143_qua__stir_fun_a, 0, _143_qua__stir_fun_ha }, {} }; @@ -296,26 +320,64 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua_mink_a[] = {{".2", u3we_mink}, {}}; static u3j_harm _143_qua_mule_a[] = {{".2", u3we_mule}, {}}; +static c3_c* _143_pen_ha[] = { + "4fcd534d", + 0, +}; +static c3_c* _143_qua_trip_ha[] = { + "2988e186", + 0, +}; +static c3_c* _143_qua__cold_ha[] = { + "7881e709", + 0, +}; +static c3_c* _143_qua__easy_ha[] = { + "7c0caf1b", + 0, +}; +static c3_c* _143_qua__just_ha[] = { + "295a2fbe", + 0, +}; +static c3_c* _143_qua__mask_ha[] = { + "25f3cc5e", + 0, +}; +static c3_c* _143_qua__shim_ha[] = { + "53e64202", + 0, +}; +static c3_c* _143_qua__stir_ha[] = { + "1e2b7159", + 0, +}; +static u3j_hood _143_pen_ho[] = { + { "al", 350 }, + { "ap", 24412 }, + { "ut", 11262 }, + {}, +}; static u3j_core _143_qua_d[] = - { { "pen", 3, 0, _143_pen_d }, + { { "pen", 3, 0, _143_pen_d, _143_pen_ha, _143_pen_ho }, { "po", 7, 0, _143_qua__po_d }, - { "trip", 7, _143_qua_trip_a }, + { "trip", 7, _143_qua_trip_a, 0, _143_qua_trip_ha }, { "bend", 7, 0, _143_qua__bend_d }, - { "cold", 7, 0, _143_qua__cold_d }, + { "cold", 7, 0, _143_qua__cold_d, _143_qua__cold_ha }, { "comp", 7, 0, _143_qua__comp_d }, { "cook", 7, 0, _143_qua__cook_d }, - { "easy", 7, 0, _143_qua__easy_d }, + { "easy", 7, 0, _143_qua__easy_d, _143_qua__easy_ha }, { "glue", 7, 0, _143_qua__glue_d }, { "here", 7, 0, _143_qua__here_d }, - { "just", 7, 0, _143_qua__just_d }, - { "mask", 7, 0, _143_qua__mask_d }, - { "shim", 7, 0, _143_qua__shim_d }, + { "just", 7, 0, _143_qua__just_d, _143_qua__just_ha }, + { "mask", 7, 0, _143_qua__mask_d, _143_qua__mask_ha }, + { "shim", 7, 0, _143_qua__shim_d, _143_qua__shim_ha }, { "stag", 7, 0, _143_qua__stag_d }, { "stew", 7, 0, _143_qua__stew_d }, - { "stir", 7, 0, _143_qua__stir_d }, + { "stir", 7, 0, _143_qua__stir_d, _143_qua__stir_ha }, { "pfix", 7, _143_qua_pfix_a }, { "plug", 7, _143_qua_plug_a }, @@ -451,9 +513,17 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri_shas_a[] = {{".2", u3we_shas}, {}}; static u3j_harm _143_tri_shal_a[] = {{".2", u3we_shal}, {}}; +static c3_c* _143_qua_ha[] = { + "7f2af46e", + 0, +}; +static u3j_hood _143_qua_ho[] = { + { "mute", 0x17dfc }, + { "show", 0x2fbbaba }, + {}, +}; static u3j_core _143_tri_d[] = - { { "qua", 3, 0, _143_qua_d }, - + { { "qua", 3, 0, _143_qua_d, _143_qua_ha, _143_qua_ho }, { "cofl", 7, 0, _143_tri__cofl_d }, { "rd", 7, 0, _143_tri__rd_d }, { "rs", 7, 0, _143_tri__rs_d }, @@ -569,8 +639,12 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_mat_a[] = {{".2", u3we_mat}, {}}; static u3j_harm _143_two_rub_a[] = {{".2", u3we_rub}, {}}; +static c3_c* _143_tri_ha[] = { + "6cc318e2", + 0, +}; static u3j_core _143_two_d[] = - { { "tri", 3, 0, _143_tri_d }, + { { "tri", 3, 0, _143_tri_d, _143_tri_ha }, { "flop", 7, _143_two_flop_a }, { "lent", 7, _143_two_lent_a }, { "levy", 7, _143_two_levy_a }, @@ -646,8 +720,12 @@ static u3j_core _143_two_d[] = static u3j_harm _143_one_peg_a[] = {{".2", u3wc_peg, c3y}, {}}; static u3j_harm _143_one_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; +static c3_c* _143_two_ha[] = { + "613c4d6d", + 0, +}; static u3j_core _143_one_d[] = - { { "two", 3, 0, _143_two_d }, + { { "two", 3, 0, _143_two_d, _143_two_ha }, { "add", 7, _143_one_add_a }, { "dec", 7, _143_one_dec_a }, { "div", 7, _143_one_div_a }, @@ -666,13 +744,22 @@ static u3j_core _143_one_d[] = {} }; + +static c3_c* _143_one_ha[] = { + "c4b5bd8", + 0, +}; u3j_core _k143_d[] = - { { "one", 3, 0, _143_one_d }, + { { "one", 3, 0, _143_one_d, _143_one_ha }, {} }; +static c3_c* _k143_h[] = { + "13e199f7", + 0 +}; static u3j_core _d[] = { - { "k143", 0, 0, _k143_d, 0, 0, (u3j_core*) 143, 0}, + { "k143", 0, 0, _k143_d, _k143_h, 0, (u3j_core*) 143, 0}, {} }; diff --git a/noun/jets.c b/noun/jets.c index 8dda1b89b..eca786121 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -51,13 +51,13 @@ _cj_core_loc(u3_noun pel, u3j_core* cop_u) for ( i_w = 0; 0 != cop_u->huc_u[i_w].nam_c; ++i_w ) { huc = u3kdb_put(huc, u3i_string(cop_u->huc_u[i_w].nam_c), - cop_u->huc_u[i_w].axe_l); + u3nq(9, cop_u->huc_u[i_w].axe_l, 0, 1)); } } pat = ( 0 == cop_u->axe_l ) ? u3nt(c3y, c3y, pel) - : ( (3 == cop_u->axe_l) && (c3y == u3h(pel)) ) + : ( (3 == cop_u->axe_l) && (c3y == u3h(u3h(pel))) ) ? u3nt(c3y, c3n, pel) : u3nt(c3n, cop_u->axe_l, pel); @@ -70,7 +70,7 @@ static u3_noun _cj_hash(c3_c* has_c) { c3_l mug; - sscanf(has_c, "%d", &mug); + sscanf(has_c, "%x", &mug); return mug; } @@ -177,8 +177,9 @@ _cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev c3_w j_w; for ( j_w = 0; 0 != kid_u->bas_u[j_w]; j_w++ ) { u3_noun key = _cj_hash(kid_u->bas_u[j_w]), - reg = _cj_gust(u3h_get(u3D.hot_p, key), - kid_u->axe_l, u3k(pel), u3k(loc)); + hot = u3h_get(u3D.hot_p, key), + old = ( u3_none == hot ) ? u3_none : u3k(u3h(hot)), + reg = _cj_gust(old, kid_u->axe_l, u3k(pel), u3k(loc)); u3h_put(u3D.hot_p, key, u3nq(reg, jax_l, u3k(u3t(u3t(loc))), u3k(bal))); u3z(key); @@ -681,7 +682,7 @@ u3j_boot(void) memset(u3D.ray_u, 0, (u3D.all_l * sizeof(u3j_core))); u3D.hot_p = u3h_new(); - jax_l = _cj_install(u3D.ray_u, 1, (c3_l) (long long) u3D.ray_u[0].par_u, u3_nul, u3D.dev_u); + jax_l = _cj_install(u3D.ray_u, 1, (c3_l) (long long) u3D.dev_u[0].par_u, u3_nul, u3D.dev_u); fprintf(stderr, "boot: installed %d jets\n", jax_l); } @@ -1594,22 +1595,24 @@ _cj_mine(u3_noun cey, u3_noun cor) u3h_put(u3R->jed.war_p, loc, act); // see note in _cj_spot { - u3_noun bas = _cj_bash(bat); - u3_noun hot = u3h_get(u3D.hot_p, bas); + u3_noun bas = _cj_bash(bat), + hot = u3h_get(u3D.hot_p, bas); c3_o hav_o = c3n; if ( u3_none == hot ) { u3m_p("unregistered battery", bal); } else { - u3_noun hol = _cj_reg_find(hot, cor); + u3_noun her = u3h(hot), + hol = _cj_reg_find(her, cor); if ( hol != u3_none ) { if ( c3n == u3r_sing(loc, hol) ) { - u3m_p("bogus hot location", hol); + u3m_p("bogus hot loc", hol); u3m_p("registered as", loc); } else { hav_o = c3y; + fprintf(stderr, "dev mode match: %x\r\n", bas); } } u3z(hol); @@ -1652,14 +1655,17 @@ _cj_mile(u3_noun clu, u3_noun cor) u3z(cor); } else { - loc = _cj_spot(cor, u3_none); - if ( u3_none == loc ) { - loc = _cj_moan(clu, cor); - } - else { - u3z(clu); - u3z(cor); - } + loc = _cj_moan(clu, cor); + // don't early terminate for located cores, + // that's handled at rites (fine checks) + //loc = _cj_spot(cor, u3_none); + //if ( u3_none == loc ) { + // loc = _cj_moan(clu, cor); + //} + //else { + // u3z(clu); + // u3z(cor); + //} } return loc; } @@ -1669,9 +1675,11 @@ _cj_mile(u3_noun clu, u3_noun cor) void u3j_mine(u3_noun clu, u3_noun cor) { - // TODO: bail early unless developer mode is set u3t_on(glu_o); if ( (c3n == u3du(cor)) || (c3y == _cj_scan(cor)) ) { + // this path (not called by bytecode interpreter) will not + // verify (as u3j_rite_mine does) that hot registration + // matches hinted registration. u3z(clu); u3z(cor); } @@ -1689,7 +1697,6 @@ u3j_mine(u3_noun clu, u3_noun cor) void u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) { - // TODO: bail early unless developer mode is set c3_t non_t; u3t_on(glu_o); From 9070375c4c125d5ea0f0ed7920450c6875df4540 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 9 May 2018 11:07:48 -0700 Subject: [PATCH 100/221] more hashes --- jets/tree.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index e9917a08d..d62edd869 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -233,8 +233,12 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__comp_fun_a[] = {{".2", u3we_comp_fun}, {}}; + static c3_c* _143_qua__comp_fun_ha[] = { + "5a71faf5", + 0, + }; static u3j_core _143_qua__comp_d[] = - { { "fun", 7, _143_qua__comp_fun_a }, + { { "fun", 7, _143_qua__comp_fun_a, 0, _143_qua__comp_fun_ha }, {} }; @@ -332,6 +336,10 @@ static c3_c* _143_qua__cold_ha[] = { "7881e709", 0, }; +static c3_c* _143_qua__comp_ha[] = { + "ff1d7ca", + 0, +}; static c3_c* _143_qua__easy_ha[] = { "7c0caf1b", 0, @@ -367,7 +375,7 @@ static u3j_core _143_qua_d[] = { "bend", 7, 0, _143_qua__bend_d }, { "cold", 7, 0, _143_qua__cold_d, _143_qua__cold_ha }, - { "comp", 7, 0, _143_qua__comp_d }, + { "comp", 7, 0, _143_qua__comp_d, _143_qua__comp_ha }, { "cook", 7, 0, _143_qua__cook_d }, { "easy", 7, 0, _143_qua__easy_d, _143_qua__easy_ha }, { "glue", 7, 0, _143_qua__glue_d }, From 956ecdbeaa590ebedbfc65bdf7bda91a548caf6d Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 10 May 2018 14:06:07 -0700 Subject: [PATCH 101/221] more hashes, clarify _cj_spot with hot fallback --- jets/tree.c | 48 +++++-- noun/jets.c | 385 +++++++++++++++++++++++++++------------------------- 2 files changed, 243 insertions(+), 190 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index d62edd869..4e567c70f 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -651,6 +651,18 @@ static c3_c* _143_tri_ha[] = { "6cc318e2", 0, }; +static c3_c* _143_two_met_ha[] = { + "51509f40", + 0, +}; +static c3_c* _143_two_rsh_ha[] = { + "7c0c8df2", + 0, +}; +static c3_c* _143_two_bex_ha[] = { + "6c223bad", + 0, +}; static u3j_core _143_two_d[] = { { "tri", 3, 0, _143_tri_d, _143_tri_ha }, { "flop", 7, _143_two_flop_a }, @@ -672,7 +684,7 @@ static u3j_core _143_two_d[] = { "turn", 7, _143_two_turn_a }, { "weld", 7, _143_two_weld_a }, - { "bex", 7, _143_two_bex_a }, + { "bex", 7, _143_two_bex_a, 0, _143_two_bex_ha }, { "cat", 7, _143_two_cat_a }, { "can", 7, _143_two_can_a }, { "cap", 7, _143_two_cap_a }, @@ -689,14 +701,14 @@ static u3j_core _143_two_d[] = { "lsh", 7, _143_two_lsh_a }, { "mas", 7, _143_two_mas_a }, { "mat", 7, _143_two_mat_a }, - { "met", 7, _143_two_met_a }, + { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, { "mix", 7, _143_two_mix_a }, { "mug", 7, _143_two_mug_a }, { "muk", 7, _143_two_muk_a }, { "rap", 7, _143_two_rap_a }, { "rep", 7, _143_two_rep_a }, { "rip", 7, _143_two_rip_a }, - { "rsh", 7, _143_two_rsh_a }, + { "rsh", 7, _143_two_rsh_a, 0, _143_two_rsh_ha }, { "rub", 7, _143_two_rub_a }, { "peg", 7, _143_two_peg_a }, { "pow", 7, _143_two_pow_a }, @@ -732,18 +744,38 @@ static c3_c* _143_two_ha[] = { "613c4d6d", 0, }; +static c3_c* _143_one_div_ha[] = { + "3457adb3", + 0, +}; +static c3_c* _143_one_mul_ha[] = { + "679b5099", + 0, +}; +static c3_c* _143_one_dec_ha[] = { + "ce60540", + 0, +}; +static c3_c* _143_one_add_ha[] = { + "68a25eb6", + 0, +}; +static c3_c* _143_one_lth_ha[] = { + "ef85ae3", + 0, +}; static u3j_core _143_one_d[] = { { "two", 3, 0, _143_two_d, _143_two_ha }, - { "add", 7, _143_one_add_a }, - { "dec", 7, _143_one_dec_a }, - { "div", 7, _143_one_div_a }, + { "add", 7, _143_one_add_a, 0, _143_one_add_ha }, + { "dec", 7, _143_one_dec_a, 0, _143_one_dec_ha }, + { "div", 7, _143_one_div_a, 0, _143_one_div_ha }, { "dvr", 7, _143_one_dvr_a }, { "gte", 7, _143_one_gte_a }, { "gth", 7, _143_one_gth_a }, { "lte", 7, _143_one_lte_a }, - { "lth", 7, _143_one_lth_a }, + { "lth", 7, _143_one_lth_a, 0, _143_one_lth_ha }, { "mod", 7, _143_one_mod_a }, - { "mul", 7, _143_one_mul_a }, + { "mul", 7, _143_one_mul_a, 0, _143_one_mul_ha }, { "sub", 7, _143_one_sub_a }, { "cap", 7, _143_one_cap_a }, diff --git a/noun/jets.c b/noun/jets.c index eca786121..e17bd65ca 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -160,43 +160,6 @@ _cj_gust(u3_weak reg, u3_noun axe, u3_noun pel, u3_noun loc) return ger; } -/* _cj_install(): install dashboard entries. -*/ -static c3_w -_cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev_u) -{ - c3_w i_w; - - if ( dev_u ) { - for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) { - u3j_core* kid_u = &dev_u[i_w]; - u3_noun loc = _cj_core_loc(u3k(pel), kid_u), - bal = u3nc(u3k(u3h(u3t(loc))), u3k(lab)); - - if ( kid_u->bas_u ) { - c3_w j_w; - for ( j_w = 0; 0 != kid_u->bas_u[j_w]; j_w++ ) { - u3_noun key = _cj_hash(kid_u->bas_u[j_w]), - hot = u3h_get(u3D.hot_p, key), - old = ( u3_none == hot ) ? u3_none : u3k(u3h(hot)), - reg = _cj_gust(old, kid_u->axe_l, u3k(pel), u3k(loc)); - u3h_put(u3D.hot_p, key, - u3nq(reg, jax_l, u3k(u3t(u3t(loc))), u3k(bal))); - u3z(key); - } - } - - kid_u->jax_l = jax_l; - ray_u[jax_l++] = *kid_u; - - jax_l = _cj_install(ray_u, jax_l, loc, bal, kid_u->dev_u); - } - u3z(pel); - u3z(lab); - } - return jax_l; -} - /* _cj_axis(): axis from formula, or 0. `fol` is RETAINED. */ static c3_l @@ -229,6 +192,94 @@ _cj_axis(u3_noun fol) } } +/* _cj_warm_hump(): generate axis-to-arm map. RETAIN. +*/ +static u3_noun +_cj_warm_hump(c3_l jax_l, u3_noun huc) +{ + u3_noun hap = u3_nul; + u3j_core* cop_u; + + /* Compute axes of all correctly declared arms. + */ + if ( jax_l && (cop_u = &u3D.ray_u[jax_l])->arm_u ) { + u3j_harm* jet_u; + c3_l i_l; + + for ( i_l = 0; (jet_u = &cop_u->arm_u[i_l])->fcs_c; i_l++ ) { + c3_l axe_l = 0; + + if ( '.' == *(jet_u->fcs_c) ) { + c3_d axe_d = 0; + + if ( (1 != sscanf(jet_u->fcs_c+1, "%" SCNu64, &axe_d)) || + axe_d >> 32ULL || + ((1 << 31) & (axe_l = (c3_w)axe_d)) || + (axe_l < 2) ) + { + fprintf(stderr, "jets: activate: bad fcs %s\r\n", jet_u->fcs_c); + } + } + else { + u3_noun nam = u3i_string(jet_u->fcs_c); + u3_noun fol = u3kdb_get(u3k(huc), nam); + + if ( u3_none == fol ) { + fprintf(stderr, "jets: activate: bad fcs %s\r\n", jet_u->fcs_c); + } + else { + axe_l = _cj_axis(fol); + u3z(fol); + } + } + if ( 0 != axe_l ) { + hap = u3kdb_put(hap, axe_l, i_l); + } + } + } + return hap; +} + + +/* _cj_install(): install dashboard entries. +*/ +static c3_w +_cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev_u) +{ + c3_w i_w; + + if ( dev_u ) { + for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) { + u3j_core* kid_u = &dev_u[i_w]; + u3_noun loc = _cj_core_loc(u3k(pel), kid_u), + bal = u3nc(u3k(u3h(u3t(loc))), u3k(lab)); + + kid_u->jax_l = jax_l; + ray_u[jax_l] = *kid_u; + + if ( kid_u->bas_u ) { + c3_w j_w; + for ( j_w = 0; 0 != kid_u->bas_u[j_w]; j_w++ ) { + u3_noun key = _cj_hash(kid_u->bas_u[j_w]), + hot = u3h_get(u3D.hot_p, key), + old = ( u3_none == hot ) ? u3_none : u3k(u3h(hot)), + reg = _cj_gust(old, kid_u->axe_l, u3k(pel), u3k(loc)), + huc = u3t(u3t(loc)), + hap = _cj_warm_hump(jax_l, huc); + + u3h_put(u3D.hot_p, key, u3nq(reg, jax_l, hap, u3k(bal))); + u3z(key); + } + } + + jax_l = _cj_install(ray_u, ++jax_l, loc, bal, kid_u->dev_u); + } + u3z(pel); + u3z(lab); + } + return jax_l; +} + #if 0 /* _cj_by_gut(): (~(get by a) b), unifying; RETAINS a, b, AND result. */ @@ -384,6 +435,8 @@ _cj_find_warm(u3_noun loc) static u3_weak _cj_spot(u3_noun cor, u3_weak bas); +/* _cj_reg_find(): locate core within registry. + */ static u3_weak _cj_reg_find(u3_noun reg, u3_noun cor) { @@ -428,52 +481,86 @@ _cj_jit(c3_l jax_l, u3_noun bat) return u3_nul; } -/* _cj_spot(): find location of cor. expensive. cor is RETAINED. - * bas is an optional cached battery hash for the hot lookup, - * and is TRANSFERRED if not u3_none. +/* _cj_loc_axe(): axis-within-core from location (0 for root) + */ +static u3_noun +_cj_loc_axe(u3_noun loc) +{ + u3_noun pat = u3h(loc); + return ( c3n == u3h(pat) ) + ? u3k(u3h(u3t(pat))) + : (c3y == u3h(u3t(pat))) ? 0 : 3; +} + +/* _cj_loc_pel(): parent location (or root noun, if root) of loc + */ +static u3_noun +_cj_loc_pel(u3_noun loc) +{ + return u3k(u3t(u3t(u3h(loc)))); +} + +/* _cj_spot_cold(): spot, cold dashboard only. *reg is set to + * the registry found for battery. RETAIN. + */ +static u3_weak +_cj_spot_cold(u3_noun cor, u3_noun* reg) +{ + *reg = _cj_find_cold(u3h(cor)); + return ( u3_none == *reg ) ? u3_none : _cj_reg_find(*reg, cor); +} + +/* _cj_spot_hot(): try to locate core by hot dashboard. if found, + * the activation (warm state) is returned and the + * location is produced at *loc. + */ +static u3_weak +_cj_spot_hot(u3_noun cor, u3_weak bas, u3_noun* loc) +{ + u3_noun bat = u3h(cor); + u3_noun has = ( u3_none == bas ) ? _cj_bash(bat) : u3k(bas); + u3_weak act = u3_none, + hot = u3h_get(u3D.hot_p, has); + if ( u3_none != hot ) { + u3_noun reg, jax, hap, bal; + c3_l jax_l; + u3x_qual(hot, ®, &jax, &hap, &bal); + jax_l = (c3_l) jax; + if ( u3_none != (*loc = _cj_reg_find(reg, cor)) ) { + act = u3nq(jax_l, u3k(hap), u3k(bal), _cj_jit(jax_l, bat)); + } + u3z(hot); + } + u3z(has); + return act; +} + +/* _cj_spot(): find location of cor. expensive. RETAIN. + * bas is an optional cached battery hash for the hot lookup. */ static u3_weak _cj_spot(u3_noun cor, u3_weak bas) { - u3_weak reg = _cj_find_cold(u3h(cor)); - u3_weak act = u3_none; + u3_weak reg = u3_none, + loc = _cj_spot_cold(cor, ®); - if ( u3_none == reg ) { - u3_noun hot; - /* reconstruct from hot data */ - if ( u3_none == bas ) { - bas = _cj_bash(u3h(cor)); - } - hot = u3h_get(u3D.hot_p, bas); - if ( u3_none == hot ) { - return u3_none; - } - else { - u3_noun jax, hap, bal; - c3_l jax_l; - u3x_qual(hot, ®, &jax, &hap, &bal); - jax_l = (c3_l) jax; - act = u3nq(jax_l, u3k(hap), u3k(bal), _cj_jit(jax_l, u3h(cor))); - u3z(hot); + if ( u3_none == loc ) { + u3_weak act = _cj_spot_hot(cor, bas, &loc); + if ( u3_none != act ) { + reg = _cj_gust(reg, _cj_loc_axe(loc), _cj_loc_pel(loc), u3k(loc)); u3h_put(u3R->jed.cod_p, u3h(cor), u3k(reg)); - } - } - - if ( u3_none != bas ) { - u3z(bas); - } - - { - u3_weak loc = _cj_reg_find(reg, cor); - if ( u3_none != loc && u3_none != act ) { - // caution: could overwrites old value, debug batteries etc. - // old value contains old _cj_jit (from different - // battery). if we change jit to (map battery *), - // will need to merge with that map here. + /* caution: could overwrites old value, debug batteries etc. + ** old value contains old _cj_jit (from different + ** battery). if we change jit to (map battery *), + ** will need to merge with that map here. + */ u3h_put(u3R->jed.war_p, loc, act); } - return loc; } + if ( u3_none != reg ) { + u3z(reg); + } + return loc; } /* _cj_cast(): create a u3j_fink that can be used to efficiently verify @@ -572,65 +659,6 @@ _cj_nail(u3_noun loc, u3_noun axe, return ret_o; } -/* _cj_scan(): has this core been registered? RETAIN. - */ -static c3_o -_cj_scan(u3_noun cor) -{ - u3_weak loc = _cj_spot(cor, u3_none); - c3_o reg_o = (u3_none == loc) ? c3n : c3y; - u3z(loc); - return reg_o; -} - -/* _cj_warm_hump(): generate axis-to-arm map. RETAIN. -*/ -static u3_noun -_cj_warm_hump(c3_l jax_l, u3_noun huc) -{ - u3_noun hap = u3_nul; - u3j_core* cop_u; - - /* Compute axes of all correctly declared arms. - */ - if ( jax_l && (cop_u = &u3D.ray_u[jax_l])->arm_u ) { - u3j_harm* jet_u; - c3_l i_l; - - for ( i_l = 0; (jet_u = &cop_u->arm_u[i_l])->fcs_c; i_l++ ) { - c3_l axe_l = 0; - - if ( '.' == *(jet_u->fcs_c) ) { - c3_d axe_d = 0; - - if ( (1 != sscanf(jet_u->fcs_c+1, "%" SCNu64, &axe_d)) || - axe_d >> 32ULL || - ((1 << 31) & (axe_l = (c3_w)axe_d)) || - (axe_l < 2) ) - { - fprintf(stderr, "jets: activate: bad fcs %s\r\n", jet_u->fcs_c); - } - } - else { - u3_noun nam = u3i_string(jet_u->fcs_c); - u3_noun fol = u3kdb_get(u3k(huc), nam); - - if ( u3_none == fol ) { - fprintf(stderr, "jets: activate: bad fcs %s\r\n", jet_u->fcs_c); - } - else { - axe_l = _cj_axis(fol); - u3z(fol); - } - } - if ( 0 != axe_l ) { - hap = u3kdb_put(hap, axe_l, i_l); - } - } - } - return hap; -} - /* _cj_hot_mean(): in parent, declare a core. RETAINS. */ static c3_l @@ -1002,7 +1030,7 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) } sit_u->bas = _cj_bash(u3h(cor)); - if ( u3_none == (col = loc = _cj_spot(cor, u3k(sit_u->bas))) ) { + if ( u3_none == (col = loc = _cj_spot(cor, sit_u->bas)) ) { return u3m_bail(c3__fail); } @@ -1365,7 +1393,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) if ( u3_none == sit_u->bas ) { sit_u->bas = _cj_bash(u3h(cor)); } - loc = _cj_spot(cor, u3k(sit_u->bas)); + loc = _cj_spot(cor, sit_u->bas); if ( u3_none != loc ) { u3p(u3j_fink) fon_p = 0; u3_weak lod = u3_none; @@ -1585,7 +1613,7 @@ _cj_mine(u3_noun cey, u3_noun cor) } reg = _cj_gust(_cj_find_cold(bat), u3k(axe), pel, u3k(loc)); jax_l = _cj_hot_mean(par_l, nam); -#if 0 +#if 1 u3m_p("new jet", bal); fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); #endif @@ -1594,53 +1622,55 @@ _cj_mine(u3_noun cey, u3_noun cor) u3h_put(u3R->jed.cod_p, bat, reg); u3h_put(u3R->jed.war_p, loc, act); // see note in _cj_spot + /* { u3_noun bas = _cj_bash(bat), hot = u3h_get(u3D.hot_p, bas); c3_o hav_o = c3n; - if ( u3_none == hot ) { - u3m_p("unregistered battery", bal); - } - else { + if ( u3_none != hot ) { u3_noun her = u3h(hot), hol = _cj_reg_find(her, cor); if ( hol != u3_none ) { - if ( c3n == u3r_sing(loc, hol) ) { - u3m_p("bogus hot loc", hol); - u3m_p("registered as", loc); - } - else { - hav_o = c3y; - fprintf(stderr, "dev mode match: %x\r\n", bas); - } + hav_o = c3y; + u3z(hol); } - u3z(hol); u3z(hot); } if ( c3n == hav_o ) { + u3m_p("unregistered battery", bal); fprintf(stderr, "hash: %x\r\n", bas); } u3z(bas); } + */ return loc; } -/* _cj_moan(): register core known to be unregistered, returning - * location. clu and cor are TRANSFERRED. - */ static u3_weak -_cj_moan(u3_noun clu, u3_noun cor) +_cj_audit(u3_noun loc, u3_noun cey, u3_noun cor) { - u3_weak cey = _cj_je_fsck(clu); - u3_weak loc = u3_none; - if ( u3_none != cey ) { + u3_noun pat, nam, huc, cax, can, cuc, pax; + + u3x_trel(loc, &pat, &nam, &huc); + u3x_trel(cey, &can, &cax, &cuc); + + pax = _cj_loc_axe(loc); + + if ( (c3n == u3r_sing(nam, can)) || + (c3n == u3r_sing(pax, cax)) || + (c3n == u3r_sing(huc, cuc)) ) { + u3_noun bog = loc; loc = _cj_mine(cey, cor); - u3z(cey); + u3m_p("bogus location", bog); + u3m_p("registered new", loc); + u3z(bog); } - u3z(cor); + + u3z(pax); + return loc; } @@ -1655,17 +1685,18 @@ _cj_mile(u3_noun clu, u3_noun cor) u3z(cor); } else { - loc = _cj_moan(clu, cor); - // don't early terminate for located cores, - // that's handled at rites (fine checks) - //loc = _cj_spot(cor, u3_none); - //if ( u3_none == loc ) { - // loc = _cj_moan(clu, cor); - //} - //else { - // u3z(clu); - // u3z(cor); - //} + u3_weak cey = _cj_je_fsck(clu); + if ( u3_none != cey ) { + loc = _cj_spot(cor, u3_none); + if ( u3_none == loc ) { + loc = _cj_mine(cey, cor); + } + else { + loc = _cj_audit(loc, cey, cor); + } + u3z(cey); + } + u3z(cor); } return loc; } @@ -1675,20 +1706,10 @@ _cj_mile(u3_noun clu, u3_noun cor) void u3j_mine(u3_noun clu, u3_noun cor) { + u3_weak loc; u3t_on(glu_o); - if ( (c3n == u3du(cor)) || (c3y == _cj_scan(cor)) ) { - // this path (not called by bytecode interpreter) will not - // verify (as u3j_rite_mine does) that hot registration - // matches hinted registration. - u3z(clu); - u3z(cor); - } - else { - u3_weak loc = _cj_moan(clu, cor); - if ( u3_none != loc ) { - u3z(loc); - } - } + loc = _cj_mile(clu, cor); + u3z(loc); u3t_off(glu_o); } From 540dca94011c8b72f6c60e20c049824cb37798db Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 12 May 2018 12:15:17 -0700 Subject: [PATCH 102/221] no remarry --- noun/jets.c | 66 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index e17bd65ca..25b4a8ffa 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1758,77 +1758,15 @@ _cj_warm_reap(u3_noun kev) u3z(loc); } -/* _cj_uni_jun(): merge junior map into senior map. - * sem is TRANSFERRED. - * jum is RETAINED. - */ -static u3_noun -_cj_uni_jun(u3_noun sem, u3_noun jum) -{ - if ( u3_nul == jum ) { - return sem; - } - else { - u3_noun n, l, r; - u3x_trel(jum, &n, &l, &r); - sem = _cj_uni_jun(sem, l); - sem = _cj_uni_jun(sem, r); - return u3kdb_put(sem, u3a_take(u3h(n)), u3a_take(u3t(n))); - } -} - -/* _cj_remarry(): merge parent lists. - * sel is TRANSFERRED. - * jul is RETAINED. - */ -static u3_noun -_cj_remarry(u3_noun sel, u3_noun jul) -{ - if ( u3_nul == sel ) { - return u3a_take(jul); - } - else if ( u3_nul == jul ) { - return sel; - } - else { - u3_noun sap = u3h(sel), - jup = u3h(jul), - sax = u3h(sap), - jux = u3h(jup); - if ( c3y == u3r_sing(sax, jux) ) { - u3_noun lol = _cj_uni_jun(u3k(u3t(sap)), u3t(jup)), - par = u3nc(u3k(u3h(sap)), lol), - nex = _cj_remarry(u3k(u3t(sel)), u3t(jul)), - pro = u3nc(par, nex); - u3z(sel); - return pro; - } - else if ( c3y == u3qa_lth(sax, jux) ) { - u3_noun nex = _cj_remarry(u3k(u3t(sel)), jul), - pro = u3nc(u3k(sap), nex); - u3z(sel); - return pro; - } - else { - return u3nc(u3a_take(jup), _cj_remarry(sel, u3t(jul))); - } - } -} - /* _cj_cold_reap(): reap cold dashboard entries. */ static void _cj_cold_reap(u3_noun kev) { - u3_noun jur = u3t(kev); u3_noun bat = u3a_take(u3h(kev)); - u3_weak ser = _cj_find_cold(bat); - u3_noun reg = ( u3_none == ser ) - ? u3a_take(jur) - : u3nc(_cj_uni_jun(u3k(u3h(ser)), u3h(jur)), - _cj_remarry(u3k(u3t(ser)), u3t(jur))); + u3_noun reg = u3a_take(u3t(kev)); u3h_put(u3R->jed.cod_p, bat, reg); - u3z(ser); u3z(bat); + u3z(bat); } /* _cj_hank_reap(): reap hook resolutions. From a431d2efbb46b0a3c71d43dc0a1b7f1e6d89177f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 12 May 2018 12:16:12 -0700 Subject: [PATCH 103/221] more hashes --- jets/tree.c | 108 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 18 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 4e567c70f..fa068455a 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -211,8 +211,12 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__bend_fun_a[] = {{".2", u3we_bend_fun}, {}}; + static c3_c* _143_qua__bend_fun_ha[] = { + "708e40b", + 0, + }; static u3j_core _143_qua__bend_d[] = - { { "fun", 7, _143_qua__bend_fun_a }, + { { "fun", 7, _143_qua__bend_fun_a, 0, _143_qua__bend_fun_ha }, {} }; @@ -227,8 +231,12 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__cook_fun_a[] = {{".2", u3we_cook_fun}, {}}; + static c3_c* _143_qua__cook_fun_ha[] = { + "725a3063", + 0, + }; static u3j_core _143_qua__cook_d[] = - { { "fun", 7, _143_qua__cook_fun_a }, + { { "fun", 7, _143_qua__cook_fun_a, 0, _143_qua__cook_fun_ha }, {} }; @@ -259,8 +267,12 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__here_fun_a[] = {{".2", u3we_here_fun}, {}}; + static c3_c* _143_qua__here_fun_ha[] = { + "72522b7d", + 0, + }; static u3j_core _143_qua__here_d[] = - { { "fun", 7, _143_qua__here_fun_a }, + { { "fun", 7, _143_qua__here_fun_a, 0, _143_qua__here_fun_ha }, {} }; @@ -295,14 +307,22 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__stag_fun_a[] = {{".2", u3we_stag_fun}, {}}; + static c3_c* _143_qua__stag_fun_ha[] = { + "5347a0fe", + 0, + }; static u3j_core _143_qua__stag_d[] = - { { "fun", 7, _143_qua__stag_fun_a }, + { { "fun", 7, _143_qua__stag_fun_a, 0, _143_qua__stag_fun_ha }, {} }; static u3j_harm _143_qua__stew_fun_a[] = {{".2", u3we_stew_fun}, {}}; + static c3_c* _143_qua__stew_fun_ha[] = { + "74d4c941", + 0, + }; static u3j_core _143_qua__stew_d[] = - { { "fun", 7, _143_qua__stew_fun_a }, + { { "fun", 31, _143_qua__stew_fun_a, 0, _143_qua__stew_fun_ha }, {} }; @@ -360,6 +380,34 @@ static c3_c* _143_qua__stir_ha[] = { "1e2b7159", 0, }; +static c3_c* _143_qua__pose_ha[] = { + "6fb235ed", + 0, +}; +static c3_c* _143_qua__plug_ha[] = { + "11b6a2f8", + 0, +}; +static c3_c* _143_qua__cook_ha[] = { + "7b58b2c3", + 0, +}; +static c3_c* _143_qua__stag_ha[] = { + "50e7e0d9", + 0, +}; +static c3_c* _143_qua__here_ha[] = { + "6392963e", + 0, +}; +static c3_c* _143_qua__bend_ha[] = { + "36e4e2fb", + 0, +}; +static c3_c* _143_qua__stew_ha[] = { + "23a21615", + 0, +}; static u3j_hood _143_pen_ho[] = { { "al", 350 }, { "ap", 24412 }, @@ -373,23 +421,23 @@ static u3j_core _143_qua_d[] = { "trip", 7, _143_qua_trip_a, 0, _143_qua_trip_ha }, - { "bend", 7, 0, _143_qua__bend_d }, + { "bend", 7, 0, _143_qua__bend_d, _143_qua__bend_ha }, { "cold", 7, 0, _143_qua__cold_d, _143_qua__cold_ha }, { "comp", 7, 0, _143_qua__comp_d, _143_qua__comp_ha }, - { "cook", 7, 0, _143_qua__cook_d }, + { "cook", 7, 0, _143_qua__cook_d, _143_qua__cook_ha }, { "easy", 7, 0, _143_qua__easy_d, _143_qua__easy_ha }, { "glue", 7, 0, _143_qua__glue_d }, - { "here", 7, 0, _143_qua__here_d }, + { "here", 7, 0, _143_qua__here_d, _143_qua__here_ha }, { "just", 7, 0, _143_qua__just_d, _143_qua__just_ha }, { "mask", 7, 0, _143_qua__mask_d, _143_qua__mask_ha }, { "shim", 7, 0, _143_qua__shim_d, _143_qua__shim_ha }, - { "stag", 7, 0, _143_qua__stag_d }, - { "stew", 7, 0, _143_qua__stew_d }, + { "stag", 7, 0, _143_qua__stag_d, _143_qua__stag_ha }, + { "stew", 7, 0, _143_qua__stew_d, _143_qua__stew_ha }, { "stir", 7, 0, _143_qua__stir_d, _143_qua__stir_ha }, { "pfix", 7, _143_qua_pfix_a }, - { "plug", 7, _143_qua_plug_a }, - { "pose", 7, _143_qua_pose_a }, + { "plug", 7, _143_qua_plug_a, 0, _143_qua__plug_ha }, + { "pose", 7, _143_qua_pose_a, 0, _143_qua__pose_ha }, { "sfix", 7, _143_qua_sfix_a }, { "mink", 7, _143_qua_mink_a }, @@ -623,6 +671,10 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}}; static u3j_harm _143_two__by_dif_a[] = {{".2", u3wdb_dif, c3y}, {}}; static u3j_harm _143_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}}; + static c3_c* _143_two__by_gas_ha[] = { + "5a8a7e7d", + 0, + }; static u3j_harm _143_two__by_get_a[] = {{".2", u3wdb_get, c3y}, {}}; static u3j_harm _143_two__by_has_a[] = {{".2", u3wdb_has, c3y}, {}}; // static u3j_harm _143_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; @@ -632,7 +684,7 @@ static u3j_core _143_tri_d[] = static u3j_core _143_two__by_d[] = { { "bif", 7, _143_two__by_bif_a }, { "dif", 7, _143_two__by_dif_a }, - { "gas", 7, _143_two__by_gas_a }, + { "gas", 7, _143_two__by_gas_a, 0, _143_two__by_gas_ha }, { "get", 7, _143_two__by_get_a }, { "has", 7, _143_two__by_has_a }, // { "int", 7, _143_two__by_int_a }, @@ -655,25 +707,45 @@ static c3_c* _143_two_met_ha[] = { "51509f40", 0, }; +static c3_c* _143_two_lsh_ha[] = { + "41b3a4c7", + 0, +}; static c3_c* _143_two_rsh_ha[] = { "7c0c8df2", 0, }; +static c3_c* _143_two_vor_ha[] = { + "2b05b267", + 0, +}; static c3_c* _143_two_bex_ha[] = { "6c223bad", 0, }; +static c3_c* _143_two_lent_ha[] = { + "1dfd0931", + 0, +}; +static c3_c* _143_two_roll_ha[] = { + "3c16e592", + 0, +}; +static c3_c* _143_two__by_ha[] = { + "76d3df01", + 0, +}; static u3j_core _143_two_d[] = { { "tri", 3, 0, _143_tri_d, _143_tri_ha }, { "flop", 7, _143_two_flop_a }, - { "lent", 7, _143_two_lent_a }, + { "lent", 7, _143_two_lent_a, 0, _143_two_lent_ha }, { "levy", 7, _143_two_levy_a }, { "lien", 7, _143_two_lien_a }, { "murn", 7, _143_two_murn_a }, { "need", 7, _143_two_need_a }, { "reap", 7, _143_two_reap_a }, { "reel", 7, _143_two_reel_a }, - { "roll", 7, _143_two_roll_a }, + { "roll", 7, _143_two_roll_a, 0, _143_two_roll_ha }, { "skid", 7, _143_two_skid_a }, { "skim", 7, _143_two_skim_a }, { "skip", 7, _143_two_skip_a }, @@ -698,7 +770,7 @@ static u3j_core _143_two_d[] = { "gor", 7, _143_two_gor_a }, { "hor", 7, _143_two_hor_a }, { "jam", 7, _143_two_jam_a }, - { "lsh", 7, _143_two_lsh_a }, + { "lsh", 7, _143_two_lsh_a, 0, _143_two_lsh_ha }, { "mas", 7, _143_two_mas_a }, { "mat", 7, _143_two_mat_a }, { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, @@ -713,10 +785,10 @@ static u3j_core _143_two_d[] = { "peg", 7, _143_two_peg_a }, { "pow", 7, _143_two_pow_a }, { "sqt", 7, _143_two_sqt_a }, - { "vor", 7, _143_two_vor_a }, + { "vor", 7, _143_two_vor_a, 0, _143_two_vor_ha }, { "xeb", 7, _143_two_xeb_a }, - { "by", 7, 0, _143_two__by_d }, + { "by", 7, 0, _143_two__by_d, _143_two__by_ha }, { "in", 7, 0, _143_two__in_d }, {}, }; From 2ace4f723a8bea484e394771664eb77ff80ecf4f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 12 May 2018 12:16:36 -0700 Subject: [PATCH 104/221] better auditing --- noun/jets.c | 128 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 47 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 25b4a8ffa..2693ed43c 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -265,9 +265,10 @@ _cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev old = ( u3_none == hot ) ? u3_none : u3k(u3h(hot)), reg = _cj_gust(old, kid_u->axe_l, u3k(pel), u3k(loc)), huc = u3t(u3t(loc)), - hap = _cj_warm_hump(jax_l, huc); + hap = _cj_warm_hump(jax_l, huc), + toh = u3nq(reg, jax_l, hap, u3k(bal)); - u3h_put(u3D.hot_p, key, u3nq(reg, jax_l, hap, u3k(bal))); + u3h_put(u3D.hot_p, key, toh); u3z(key); } } @@ -481,7 +482,7 @@ _cj_jit(c3_l jax_l, u3_noun bat) return u3_nul; } -/* _cj_loc_axe(): axis-within-core from location (0 for root) +/* _cj_loc_axe(): axis-within-core from location (0 for root). RETAIN. */ static u3_noun _cj_loc_axe(u3_noun loc) @@ -492,7 +493,7 @@ _cj_loc_axe(u3_noun loc) : (c3y == u3h(u3t(pat))) ? 0 : 3; } -/* _cj_loc_pel(): parent location (or root noun, if root) of loc +/* _cj_loc_pel(): parent location (or root noun, if root) of loc. RETAIN. */ static u3_noun _cj_loc_pel(u3_noun loc) @@ -1568,24 +1569,19 @@ u3j_gate_lose(u3j_site* sit_u) } } -/* _cj_mine(): declare a core and produce location. RETAIN. -*/ +/* _cj_minx(): produce location of core from fsck'd clue. RETAIN. + */ static u3_weak -_cj_mine(u3_noun cey, u3_noun cor) +_cj_minx(u3_noun cey, u3_noun cor) { - c3_l par_l, jax_l; - u3_noun bat = u3h(cor), - pel, hap, reg, loc, bal, act, nam, axe, huc; - + u3_noun nam, axe, huc; u3x_trel(cey, &nam, &axe, &huc); + if ( 0 == axe ) { - pel = u3k(u3t(cor)); - loc = u3nt(u3nt(c3y, c3y, u3k(pel)), u3k(nam), u3k(huc)); - bal = u3nc(u3k(nam), u3_nul); - par_l = 0; + return u3nt(u3nt(c3y, c3y, u3k(u3t(cor))), u3k(nam), u3k(huc)); } else { - u3_weak par, pac; + u3_weak par, pel; u3_noun pat; par = u3r_at(axe, cor); @@ -1601,28 +1597,71 @@ _cj_mine(u3_noun cey, u3_noun cor) axe); return u3_none; } - pac = _cj_find_warm(pel); - c3_assert(u3_none != pac); - par_l = u3h(pac); - bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); - u3z(pac); pat = ( ( 3 == axe ) && (c3y == u3h(u3h(pel))) ) - ? u3nt(c3y, c3n, u3k(pel)) - : u3nt(c3n, u3k(axe), u3k(pel)); - loc = u3nt(pat, u3k(nam), u3k(huc)); + ? u3nt(c3y, c3n, pel) + : u3nt(c3n, u3k(axe), pel); + return u3nt(pat, u3k(nam), u3k(huc)); } - reg = _cj_gust(_cj_find_cold(bat), u3k(axe), pel, u3k(loc)); - jax_l = _cj_hot_mean(par_l, nam); -#if 1 - u3m_p("new jet", bal); - fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); -#endif - hap = _cj_warm_hump(jax_l, huc); - act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); - u3h_put(u3R->jed.cod_p, bat, reg); - u3h_put(u3R->jed.war_p, loc, act); // see note in _cj_spot +} - /* +static void +_cj_print_tas(FILE* fh, u3_noun tas) +{ + c3_w met_w = u3r_met(3, tas); + c3_c* str_c = alloca(met_w + 1); + u3r_bytes(0, met_w, (c3_y*)str_c, tas); + str_c[met_w] = 0; + fprintf(fh, "/%s", str_c); +} + +/* _cj_mine(): declare a core and produce location. RETAIN. +*/ +static u3_weak +_cj_mine(u3_noun cey, u3_noun cor) +{ + u3_weak loc = _cj_minx(cey, cor); + if ( u3_none != loc ) { + c3_l par_l, jax_l; + u3_noun pel = _cj_loc_pel(loc), + axe = _cj_loc_axe(loc), + bat = u3h(cor), + nam = u3h(u3t(loc)), + reg = _cj_gust(_cj_find_cold(bat), u3k(axe), u3k(pel), u3k(loc)), + hap, bal, act; + if ( 0 == axe ) { + par_l = 0; + bal = u3nc(u3k(nam), u3_nul); + } + else { + u3_weak pac = _cj_find_warm(pel); + c3_assert(u3_none != pac); + par_l = u3h(pac); + bal = u3nc(u3k(nam), u3k(u3h(u3t(u3t(pac))))); + u3z(pac); + } + jax_l = _cj_hot_mean(par_l, nam); +#if 0 + u3m_p("new jet", bal); + fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); +#endif + if ( jax_l ) { + u3_noun i = bal; + fprintf(stderr, "hot jet: "); + while ( i != u3_nul ) { + _cj_print_tas(stderr, u3h(i)); + i = u3t(i); + } + fprintf(stderr, "\r\n bat %x, jax %d\r\n", u3r_mug(bat), jax_l); + } + hap = _cj_warm_hump(jax_l, u3t(u3t(loc))); + act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); + u3h_put(u3R->jed.cod_p, bat, reg); + u3h_put(u3R->jed.war_p, loc, act); // see note in _cj_spot + u3z(pel); u3z(axe); + } + + return loc; +#if 0 { u3_noun bas = _cj_bash(bat), hot = u3h_get(u3D.hot_p, bas); @@ -1644,12 +1683,10 @@ _cj_mine(u3_noun cey, u3_noun cor) } u3z(bas); } - */ - - return loc; +#endif } -static u3_weak +static void _cj_audit(u3_noun loc, u3_noun cey, u3_noun cor) { u3_noun pat, nam, huc, cax, can, cuc, pax; @@ -1662,16 +1699,13 @@ _cj_audit(u3_noun loc, u3_noun cey, u3_noun cor) if ( (c3n == u3r_sing(nam, can)) || (c3n == u3r_sing(pax, cax)) || (c3n == u3r_sing(huc, cuc)) ) { - u3_noun bog = loc; - loc = _cj_mine(cey, cor); - u3m_p("bogus location", bog); - u3m_p("registered new", loc); - u3z(bog); + u3_noun mix = _cj_minx(cey, cor); + u3m_p("bad audit", loc); + u3m_p("hint says", mix); + u3z(mix); } u3z(pax); - - return loc; } /* _cj_mile(): register core for jets, returning location. @@ -1692,7 +1726,7 @@ _cj_mile(u3_noun clu, u3_noun cor) loc = _cj_mine(cey, cor); } else { - loc = _cj_audit(loc, cey, cor); + _cj_audit(loc, cey, cor); } u3z(cey); } From 33195a22ecf630982b32351f5b42cdd43848b05a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 12 May 2018 14:30:59 -0700 Subject: [PATCH 105/221] more hashes, u3j_hood expands to express ut hooks --- include/noun/jets.h | 2 + jets/tree.c | 90 ++++++++++++++++++++++++++++++++++++++++----- noun/jets.c | 9 +++-- 3 files changed, 89 insertions(+), 12 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index 0732aaade..90e1d3b52 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -55,6 +55,8 @@ typedef struct _u3j_hood { c3_c* nam_c; // hook name c3_l axe_l; // hook axis (XX: direct) + c3_o kic_o; // hook is kick (vs. fragment) + c3_l sax_l; // hook subject axis (XX: direct) } u3j_hood; /* u3j_core: driver definition. diff --git a/jets/tree.c b/jets/tree.c index fa068455a..f7f2c0b95 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -169,6 +169,51 @@ static u3j_core _143_hex_d[] = }; #endif +static c3_c* _143_pen__ut_ha[] = { + "c2cda56", + 0, +}; +static u3j_hood _143_pen__ut_ho[] = { + { "fan", 28, c3n }, + { "rib", 58, c3n }, + { "vet", 118, c3n }, + { "fab", 119, c3n }, + + { "blow", 49131 }, + { "burn", 3051 }, + { "busk", 0x5ff57 }, + { "buss", 94 }, + { "crop", 4 }, + { "duck", 48087 }, + { "dune", 1524 }, + { "dunk", 763 }, + { "epla", 12283 }, + { "emin", 5998 }, + { "emul", 86 }, + { "felt", 24046 }, + { "fine", 3004 }, + { "fire", 700 }, + { "fish", 1498 }, + { "fond", 92 }, + { "fund", 1402 }, + { "funk", 0x1757c, c3y, 31 }, + { "fuse", 1534 }, + { "gain", 748 }, + { "lose", 22 }, + { "mint", 0x17fd4 }, + { "moot", 2807 }, + { "mull", 11995 }, + { "nest", 380 }, + { "peel", 5999 }, + { "play", 12022 }, + { "peek", 5996 }, + { "repo", 3050 }, + { "rest", 382 }, + { "tack", 351 }, + { "toss", 24042 }, + { "wrap", 6143 }, + {}, +}; static u3j_core _143_pen_d[] = { { "hex", 0, 0, _143_hex_d }, @@ -189,8 +234,7 @@ static u3j_core _143_pen_d[] = // { "ap", _143_pen__ap_a }, // { "al", _143_pen__al_a }, - { "ut", 15, _143_pen__ut_a, _143_pen__ut_d }, - + { "ut", 15, _143_pen__ut_a, _143_pen__ut_d, _143_pen__ut_ha, _143_pen__ut_ho }, {} }; @@ -654,6 +698,10 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; static u3j_harm _143_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; static u3j_harm _143_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; + static c3_c* _143_two__in_uni_ha[] = { + "26e34913", + 0, + }; static u3j_core _143_two__in_d[] = { { "bif", 7, _143_two__in_bif_a }, { "dif", 7, _143_two__in_dif_a }, @@ -664,7 +712,7 @@ static u3j_core _143_tri_d[] = { "put", 7, _143_two__in_put_a }, { "tap", 7, _143_two__in_tap_a }, { "wyt", 7, _143_two__in_wyt_a }, - { "uni", 7, _143_two__in_uni_a }, + { "uni", 7, _143_two__in_uni_a, 0, _143_two__in_uni_ha }, {} }; @@ -707,6 +755,14 @@ static c3_c* _143_two_met_ha[] = { "51509f40", 0, }; +static c3_c* _143_two_mix_ha[] = { + "76bbeb8a", + 0, +}; +static c3_c* _143_two_rap_ha[] = { + "7a6875bb", + 0, +}; static c3_c* _143_two_lsh_ha[] = { "41b3a4c7", 0, @@ -715,6 +771,10 @@ static c3_c* _143_two_rsh_ha[] = { "7c0c8df2", 0, }; +static c3_c* _143_two_rip_ha[] = { + "54970200", + 0, +}; static c3_c* _143_two_vor_ha[] = { "2b05b267", 0, @@ -723,6 +783,10 @@ static c3_c* _143_two_bex_ha[] = { "6c223bad", 0, }; +static c3_c* _143_two_end_ha[] = { + "3fb28e44", + 0, +}; static c3_c* _143_two_lent_ha[] = { "1dfd0931", 0, @@ -735,6 +799,10 @@ static c3_c* _143_two__by_ha[] = { "76d3df01", 0, }; +static c3_c* _143_two__in_ha[] = { + "51074d19", + 0, +}; static u3j_core _143_two_d[] = { { "tri", 3, 0, _143_tri_d, _143_tri_ha }, { "flop", 7, _143_two_flop_a }, @@ -766,7 +834,7 @@ static u3j_core _143_two_d[] = { "dis", 7, _143_two_dis_a }, { "dor", 7, _143_two_dor_a }, { "dvr", 7, _143_two_dvr_a }, - { "end", 7, _143_two_end_a }, + { "end", 7, _143_two_end_a, 0, _143_two_end_ha }, { "gor", 7, _143_two_gor_a }, { "hor", 7, _143_two_hor_a }, { "jam", 7, _143_two_jam_a }, @@ -774,12 +842,12 @@ static u3j_core _143_two_d[] = { "mas", 7, _143_two_mas_a }, { "mat", 7, _143_two_mat_a }, { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, - { "mix", 7, _143_two_mix_a }, + { "mix", 7, _143_two_mix_a, 0, _143_two_mix_ha }, { "mug", 7, _143_two_mug_a }, { "muk", 7, _143_two_muk_a }, - { "rap", 7, _143_two_rap_a }, + { "rap", 7, _143_two_rap_a, 0, _143_two_rap_ha }, { "rep", 7, _143_two_rep_a }, - { "rip", 7, _143_two_rip_a }, + { "rip", 7, _143_two_rip_a, 0, _143_two_rip_ha }, { "rsh", 7, _143_two_rsh_a, 0, _143_two_rsh_ha }, { "rub", 7, _143_two_rub_a }, { "peg", 7, _143_two_peg_a }, @@ -789,7 +857,7 @@ static u3j_core _143_two_d[] = { "xeb", 7, _143_two_xeb_a }, { "by", 7, 0, _143_two__by_d, _143_two__by_ha }, - { "in", 7, 0, _143_two__in_d }, + { "in", 7, 0, _143_two__in_d, _143_two__in_ha }, {}, }; @@ -824,6 +892,10 @@ static c3_c* _143_one_mul_ha[] = { "679b5099", 0, }; +static c3_c* _143_one_sub_ha[] = { + "5e25e8d4", + 0, +}; static c3_c* _143_one_dec_ha[] = { "ce60540", 0, @@ -848,7 +920,7 @@ static u3j_core _143_one_d[] = { "lth", 7, _143_one_lth_a, 0, _143_one_lth_ha }, { "mod", 7, _143_one_mod_a }, { "mul", 7, _143_one_mul_a, 0, _143_one_mul_ha }, - { "sub", 7, _143_one_sub_a }, + { "sub", 7, _143_one_sub_a, 0, _143_one_sub_ha }, { "cap", 7, _143_one_cap_a }, { "mas", 7, _143_one_mas_a }, diff --git a/noun/jets.c b/noun/jets.c index 2693ed43c..fd787fe74 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -49,9 +49,12 @@ _cj_core_loc(u3_noun pel, u3j_core* cop_u) if ( cop_u->huc_u ) { for ( i_w = 0; 0 != cop_u->huc_u[i_w].nam_c; ++i_w ) { - huc = u3kdb_put(huc, - u3i_string(cop_u->huc_u[i_w].nam_c), - u3nq(9, cop_u->huc_u[i_w].axe_l, 0, 1)); + u3j_hood* huc_u = &(cop_u->huc_u[i_w]); + u3_noun fol = ( c3n == huc_u->kic_o ) + ? u3nc(0, huc_u->axe_l) + : u3nt(9, huc_u->axe_l, u3nc(0, + (0 == huc_u->sax_l) ? 1 : huc_u->sax_l)); + huc = u3kdb_put(huc, u3i_string(huc_u->nam_c), fol); } } From 1273595afca192eba204c9ad6201a46d14242cd7 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 12 May 2018 14:58:09 -0700 Subject: [PATCH 106/221] couple more hashes, some organization --- jets/tree.c | 442 +++++++++++++++++++++++++++------------------------- 1 file changed, 232 insertions(+), 210 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index f7f2c0b95..1b35e07a9 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -121,9 +121,17 @@ static u3j_core _143_hex_d[] = static u3j_harm _143_pen__ut_crop_a[] = {{".2", u3wfu_crop}, {}}; // static u3j_harm _143_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; static u3j_harm _143_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}}; + static c3_c* _143_pen__ut_fond_ha[] = { + "32d3327a", + 0, + }; static u3j_harm _143_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; static u3j_harm _143_pen__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}}; static u3j_harm _143_pen__ut_mint_a[] = {{".2", u3wfu_mint}, {}}; + static c3_c* _143_pen__ut_mint_ha[] = { + "48723fb5", + 0, + }; static u3j_harm _143_pen__ut_mull_a[] = {{".2", u3wfu_mull}, {}}; static u3j_harm _143_pen__ut_nest_a[] = {{".2", u3wfu_nest}, {}}; static u3j_harm _143_pen__ut_peek_a[] = {{".2", u3wfu_peek}, {}}; @@ -131,16 +139,62 @@ static u3j_core _143_hex_d[] = static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; static u3j_harm _143_pen__ut_toss_a[] = {{".2", u3wfu_toss}, {}}; static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; + + static c3_c* _143_pen__ut_ha[] = { + "c2cda56", + 0, + }; + static u3j_hood _143_pen__ut_ho[] = { + { "fan", 28, c3n }, + { "rib", 58, c3n }, + { "vet", 118, c3n }, + { "fab", 119, c3n }, + + { "blow", 49131 }, + { "burn", 3051 }, + { "busk", 0x5ff57 }, + { "buss", 94 }, + { "crop", 4 }, + { "duck", 48087 }, + { "dune", 1524 }, + { "dunk", 763 }, + { "epla", 12283 }, + { "emin", 5998 }, + { "emul", 86 }, + { "felt", 24046 }, + { "fine", 3004 }, + { "fire", 700 }, + { "fish", 1498 }, + { "fond", 92 }, + { "fund", 1402 }, + { "funk", 0x1757c, c3y, 31 }, + { "fuse", 1534 }, + { "gain", 748 }, + { "lose", 22 }, + { "mint", 0x17fd4 }, + { "moot", 2807 }, + { "mull", 11995 }, + { "nest", 380 }, + { "peel", 5999 }, + { "play", 12022 }, + { "peek", 5996 }, + { "repo", 3050 }, + { "rest", 382 }, + { "tack", 351 }, + { "toss", 24042 }, + { "wrap", 6143 }, + {}, + }; static u3j_core _143_pen__ut_d[] = { { "burn", 7, _143_pen__ut_burn_a }, { "conk", 7, _143_pen__ut_conk_a }, { "crop", 7, _143_pen__ut_crop_a }, - { "fond", 7, _143_pen__ut_fond_a }, + { "fond", 7, _143_pen__ut_fond_a, 0, _143_pen__ut_fond_ha }, // { "fire", 7, _143_pen__ut_fire_a }, { "fish", 7, _143_pen__ut_fish_a }, { "fuse", 7, _143_pen__ut_fuse_a }, - { "mint", 7, _143_pen__ut_mint_a }, + { "mint", 7, _143_pen__ut_mint_a, 0, _143_pen__ut_mint_ha }, { "mull", 7, _143_pen__ut_mull_a }, { "nest", 7, _143_pen__ut_nest_a }, { "peek", 7, _143_pen__ut_peek_a }, @@ -169,49 +223,15 @@ static u3j_core _143_hex_d[] = }; #endif -static c3_c* _143_pen__ut_ha[] = { - "c2cda56", + +static c3_c* _143_pen_ha[] = { + "4fcd534d", 0, }; -static u3j_hood _143_pen__ut_ho[] = { - { "fan", 28, c3n }, - { "rib", 58, c3n }, - { "vet", 118, c3n }, - { "fab", 119, c3n }, - - { "blow", 49131 }, - { "burn", 3051 }, - { "busk", 0x5ff57 }, - { "buss", 94 }, - { "crop", 4 }, - { "duck", 48087 }, - { "dune", 1524 }, - { "dunk", 763 }, - { "epla", 12283 }, - { "emin", 5998 }, - { "emul", 86 }, - { "felt", 24046 }, - { "fine", 3004 }, - { "fire", 700 }, - { "fish", 1498 }, - { "fond", 92 }, - { "fund", 1402 }, - { "funk", 0x1757c, c3y, 31 }, - { "fuse", 1534 }, - { "gain", 748 }, - { "lose", 22 }, - { "mint", 0x17fd4 }, - { "moot", 2807 }, - { "mull", 11995 }, - { "nest", 380 }, - { "peel", 5999 }, - { "play", 12022 }, - { "peek", 5996 }, - { "repo", 3050 }, - { "rest", 382 }, - { "tack", 351 }, - { "toss", 24042 }, - { "wrap", 6143 }, +static u3j_hood _143_pen_ho[] = { + { "al", 350 }, + { "ap", 24412 }, + { "ut", 11262 }, {}, }; static u3j_core _143_pen_d[] = @@ -241,6 +261,10 @@ static u3j_core _143_pen_d[] = /* layer four */ static u3j_harm _143_qua_trip_a[] = {{".2", u3we_trip}, {}}; + static c3_c* _143_qua_trip_ha[] = { + "2988e186", + 0, + }; static u3j_harm _143_qua__po_ind_a[] = {{".2", u3wcp_ind}, {}}; static u3j_harm _143_qua__po_ins_a[] = {{".2", u3wcp_ins}, {}}; @@ -255,6 +279,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__bend_fun_a[] = {{".2", u3we_bend_fun}, {}}; + static c3_c* _143_qua__bend_ha[] = { + "36e4e2fb", + 0, + }; static c3_c* _143_qua__bend_fun_ha[] = { "708e40b", 0, @@ -265,6 +293,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__cold_fun_a[] = {{".2", u3we_cold_fun}, {}}; + static c3_c* _143_qua__cold_ha[] = { + "7881e709", + 0, + }; static c3_c* _143_qua__cold_fun_ha[] = { "7a6d3682", 0, @@ -275,6 +307,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__cook_fun_a[] = {{".2", u3we_cook_fun}, {}}; + static c3_c* _143_qua__cook_ha[] = { + "7b58b2c3", + 0, + }; static c3_c* _143_qua__cook_fun_ha[] = { "725a3063", 0, @@ -285,6 +321,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__comp_fun_a[] = {{".2", u3we_comp_fun}, {}}; + static c3_c* _143_qua__comp_ha[] = { + "ff1d7ca", + 0, + }; static c3_c* _143_qua__comp_fun_ha[] = { "5a71faf5", 0, @@ -295,6 +335,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__easy_fun_a[] = {{".2", u3we_easy_fun}, {}}; + static c3_c* _143_qua__easy_ha[] = { + "7c0caf1b", + 0, + }; static c3_c* _143_qua__easy_fun_ha[] = { "13cb0749", 0, @@ -311,6 +355,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__here_fun_a[] = {{".2", u3we_here_fun}, {}}; + static c3_c* _143_qua__here_ha[] = { + "6392963e", + 0, + }; static c3_c* _143_qua__here_fun_ha[] = { "72522b7d", 0, @@ -321,6 +369,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__just_fun_a[] = {{".2", u3we_just_fun}, {}}; + static c3_c* _143_qua__just_ha[] = { + "295a2fbe", + 0, + }; static c3_c* _143_qua__just_fun_ha[] = { "50d2f368", 0, @@ -331,6 +383,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__mask_fun_a[] = {{".2", u3we_mask_fun}, {}}; + static c3_c* _143_qua__mask_ha[] = { + "25f3cc5e", + 0, + }; static c3_c* _143_qua__mask_fun_ha[] = { "5fb25be8", 0, @@ -341,6 +397,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__shim_fun_a[] = {{".2", u3we_shim_fun}, {}}; + static c3_c* _143_qua__shim_ha[] = { + "53e64202", + 0, + }; static c3_c* _143_qua__shim_fun_ha[] = { "61c4cfac", 0, @@ -351,6 +411,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__stag_fun_a[] = {{".2", u3we_stag_fun}, {}}; + static c3_c* _143_qua__stag_ha[] = { + "50e7e0d9", + 0, + }; static c3_c* _143_qua__stag_fun_ha[] = { "5347a0fe", 0, @@ -361,6 +425,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__stew_fun_a[] = {{".2", u3we_stew_fun}, {}}; + static c3_c* _143_qua__stew_ha[] = { + "23a21615", + 0, + }; static c3_c* _143_qua__stew_fun_ha[] = { "74d4c941", 0, @@ -371,6 +439,10 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__stir_fun_a[] = {{".2", u3we_stir_fun}, {}}; + static c3_c* _143_qua__stir_ha[] = { + "1e2b7159", + 0, + }; static c3_c* _143_qua__stir_fun_ha[] = { "261f565a", 0, @@ -382,80 +454,27 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua_pfix_a[] = {{".2", u3we_pfix}, {}}; static u3j_harm _143_qua_plug_a[] = {{".2", u3we_plug}, {}}; + static c3_c* _143_qua__plug_ha[] = { + "11b6a2f8", + 0, + }; static u3j_harm _143_qua_pose_a[] = {{".2", u3we_pose}, {}}; + static c3_c* _143_qua__pose_ha[] = { + "6fb235ed", + 0, + }; static u3j_harm _143_qua_sfix_a[] = {{".2", u3we_sfix}, {}}; static u3j_harm _143_qua_mink_a[] = {{".2", u3we_mink}, {}}; static u3j_harm _143_qua_mule_a[] = {{".2", u3we_mule}, {}}; -static c3_c* _143_pen_ha[] = { - "4fcd534d", +static c3_c* _143_qua_ha[] = { + "7f2af46e", 0, }; -static c3_c* _143_qua_trip_ha[] = { - "2988e186", - 0, -}; -static c3_c* _143_qua__cold_ha[] = { - "7881e709", - 0, -}; -static c3_c* _143_qua__comp_ha[] = { - "ff1d7ca", - 0, -}; -static c3_c* _143_qua__easy_ha[] = { - "7c0caf1b", - 0, -}; -static c3_c* _143_qua__just_ha[] = { - "295a2fbe", - 0, -}; -static c3_c* _143_qua__mask_ha[] = { - "25f3cc5e", - 0, -}; -static c3_c* _143_qua__shim_ha[] = { - "53e64202", - 0, -}; -static c3_c* _143_qua__stir_ha[] = { - "1e2b7159", - 0, -}; -static c3_c* _143_qua__pose_ha[] = { - "6fb235ed", - 0, -}; -static c3_c* _143_qua__plug_ha[] = { - "11b6a2f8", - 0, -}; -static c3_c* _143_qua__cook_ha[] = { - "7b58b2c3", - 0, -}; -static c3_c* _143_qua__stag_ha[] = { - "50e7e0d9", - 0, -}; -static c3_c* _143_qua__here_ha[] = { - "6392963e", - 0, -}; -static c3_c* _143_qua__bend_ha[] = { - "36e4e2fb", - 0, -}; -static c3_c* _143_qua__stew_ha[] = { - "23a21615", - 0, -}; -static u3j_hood _143_pen_ho[] = { - { "al", 350 }, - { "ap", 24412 }, - { "ut", 11262 }, +static u3j_hood _143_qua_ho[] = { + { "mute", 0x17dfc }, + { "show", 0x2fbbaba }, {}, }; static u3j_core _143_qua_d[] = @@ -613,15 +632,10 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri_shas_a[] = {{".2", u3we_shas}, {}}; static u3j_harm _143_tri_shal_a[] = {{".2", u3we_shal}, {}}; -static c3_c* _143_qua_ha[] = { - "7f2af46e", +static c3_c* _143_tri_ha[] = { + "6cc318e2", 0, }; -static u3j_hood _143_qua_ho[] = { - { "mute", 0x17dfc }, - { "show", 0x2fbbaba }, - {}, -}; static u3j_core _143_tri_d[] = { { "qua", 3, 0, _143_qua_d, _143_qua_ha, _143_qua_ho }, { "cofl", 7, 0, _143_tri__cofl_d }, @@ -640,7 +654,15 @@ static u3j_core _143_tri_d[] = /* layer two */ static u3j_harm _143_two_flop_a[] = {{".2", u3wb_flop, c3y}, {}}; + static c3_c* _143_two_flop_ha[] = { + "41e43e64", + 0, + }; static u3j_harm _143_two_lent_a[] = {{".2", u3wb_lent, c3y}, {}}; + static c3_c* _143_two_lent_ha[] = { + "1dfd0931", + 0, + }; static u3j_harm _143_two_levy_a[] = {{".2", u3wb_levy, c3y}, {}}; static u3j_harm _143_two_lien_a[] = {{".2", u3wb_lien, c3y}, {}}; static u3j_harm _143_two_murn_a[] = {{".2", u3wb_murn, c3y}, {}}; @@ -648,6 +670,10 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_reap_a[] = {{".2", u3wb_reap, c3y}, {}}; static u3j_harm _143_two_reel_a[] = {{".2", u3wb_reel, c3y}, {}}; static u3j_harm _143_two_roll_a[] = {{".2", u3wb_roll, c3y}, {}}; + static c3_c* _143_two_roll_ha[] = { + "3c16e592", + 0, + }; static u3j_harm _143_two_skid_a[] = {{".2", u3wb_skid, c3y}, {}}; static u3j_harm _143_two_skim_a[] = {{".2", u3wb_skim, c3y}, {}}; static u3j_harm _143_two_skip_a[] = {{".2", u3wb_skip, c3y}, {}}; @@ -659,6 +685,10 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; static u3j_harm _143_two_bex_a[] = {{".2", u3wc_bex, c3y}, {}}; + static c3_c* _143_two_bex_ha[] = { + "6c223bad", + 0, + }; static u3j_harm _143_two_can_a[] = {{".2", u3wc_can, c3y}, {}}; static u3j_harm _143_two_cap_a[] = {{".2", u3wc_cap, c3y}, {}}; static u3j_harm _143_two_cat_a[] = {{".2", u3wc_cat, c3y}, {}}; @@ -668,22 +698,53 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_dor_a[] = {{".2", u3wc_dor, c3y}, {}}; static u3j_harm _143_two_dvr_a[] = {{".2", u3wc_dvr, c3y}, {}}; static u3j_harm _143_two_end_a[] = {{".2", u3wc_end, c3y}, {}}; + static c3_c* _143_two_end_ha[] = { + "3fb28e44", + 0, + }; static u3j_harm _143_two_gor_a[] = {{".2", u3wc_gor, c3y}, {}}; static u3j_harm _143_two_hor_a[] = {{".2", u3wc_hor, c3y}, {}}; static u3j_harm _143_two_lsh_a[] = {{".2", u3wc_lsh, c3y}, {}}; + static c3_c* _143_two_lsh_ha[] = { + "41b3a4c7", + 0, + }; static u3j_harm _143_two_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; static u3j_harm _143_two_met_a[] = {{".2", u3wc_met, c3y}, {}}; + static c3_c* _143_two_met_ha[] = { + "51509f40", + 0, + }; static u3j_harm _143_two_mix_a[] = {{".2", u3wc_mix, c3y}, {}}; + static c3_c* _143_two_mix_ha[] = { + "76bbeb8a", + 0, + }; static u3j_harm _143_two_mug_a[] = {{".2", u3wc_mug, c3y}, {}}; static u3j_harm _143_two_muk_a[] = {{".2", u3wc_muk, c3y}, {}}; - static u3j_harm _143_two_peg_a[] = {{".2", u3wc_peg, c3y}, {}}; static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}}; + static c3_c* _143_two_rap_ha[] = { + "7a6875bb", + 0, + }; static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}}; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; + static c3_c* _143_two_rip_ha[] = { + "54970200", + 0, + }; static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}}; + static c3_c* _143_two_rsh_ha[] = { + "7c0c8df2", + 0, + }; static u3j_harm _143_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static u3j_harm _143_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; + static c3_c* _143_two_vor_ha[] = { + "2b05b267", + 0, + }; static u3j_harm _143_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; @@ -696,12 +757,21 @@ static u3j_core _143_tri_d[] = // static u3j_harm _143_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _143_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static u3j_harm _143_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; + static c3_c* _143_two__in_tap_ha[] = { + "70881f1a", + 0, + }; static u3j_harm _143_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; static u3j_harm _143_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static c3_c* _143_two__in_uni_ha[] = { "26e34913", 0, }; + + static c3_c* _143_two__in_ha[] = { + "51074d19", + 0, + }; static u3j_core _143_two__in_d[] = { { "bif", 7, _143_two__in_bif_a }, { "dif", 7, _143_two__in_dif_a }, @@ -710,7 +780,7 @@ static u3j_core _143_tri_d[] = { "mer", 7, _143_two__in_mer_a }, // { "int", 7, _143_two__in_int_a }, { "put", 7, _143_two__in_put_a }, - { "tap", 7, _143_two__in_tap_a }, + { "tap", 7, _143_two__in_tap_a, 0, _143_two__in_tap_ha }, { "wyt", 7, _143_two__in_wyt_a }, { "uni", 7, _143_two__in_uni_a, 0, _143_two__in_uni_ha }, {} @@ -729,6 +799,11 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; static u3j_harm _143_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; // static u3j_harm _143_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; + + static c3_c* _143_two__by_ha[] = { + "76d3df01", + 0, + }; static u3j_core _143_two__by_d[] = { { "bif", 7, _143_two__by_bif_a }, { "dif", 7, _143_two__by_dif_a }, @@ -747,65 +822,13 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_mat_a[] = {{".2", u3we_mat}, {}}; static u3j_harm _143_two_rub_a[] = {{".2", u3we_rub}, {}}; -static c3_c* _143_tri_ha[] = { - "6cc318e2", - 0, -}; -static c3_c* _143_two_met_ha[] = { - "51509f40", - 0, -}; -static c3_c* _143_two_mix_ha[] = { - "76bbeb8a", - 0, -}; -static c3_c* _143_two_rap_ha[] = { - "7a6875bb", - 0, -}; -static c3_c* _143_two_lsh_ha[] = { - "41b3a4c7", - 0, -}; -static c3_c* _143_two_rsh_ha[] = { - "7c0c8df2", - 0, -}; -static c3_c* _143_two_rip_ha[] = { - "54970200", - 0, -}; -static c3_c* _143_two_vor_ha[] = { - "2b05b267", - 0, -}; -static c3_c* _143_two_bex_ha[] = { - "6c223bad", - 0, -}; -static c3_c* _143_two_end_ha[] = { - "3fb28e44", - 0, -}; -static c3_c* _143_two_lent_ha[] = { - "1dfd0931", - 0, -}; -static c3_c* _143_two_roll_ha[] = { - "3c16e592", - 0, -}; -static c3_c* _143_two__by_ha[] = { - "76d3df01", - 0, -}; -static c3_c* _143_two__in_ha[] = { - "51074d19", +static c3_c* _143_two_ha[] = { + "613c4d6d", 0, }; static u3j_core _143_two_d[] = { { "tri", 3, 0, _143_tri_d, _143_tri_ha }, - { "flop", 7, _143_two_flop_a }, + { "flop", 7, _143_two_flop_a, 0, _143_two_flop_ha }, { "lent", 7, _143_two_lent_a, 0, _143_two_lent_ha }, { "levy", 7, _143_two_levy_a }, { "lien", 7, _143_two_lien_a }, @@ -850,7 +873,6 @@ static u3j_core _143_two_d[] = { "rip", 7, _143_two_rip_a, 0, _143_two_rip_ha }, { "rsh", 7, _143_two_rsh_a, 0, _143_two_rsh_ha }, { "rub", 7, _143_two_rub_a }, - { "peg", 7, _143_two_peg_a }, { "pow", 7, _143_two_pow_a }, { "sqt", 7, _143_two_sqt_a }, { "vor", 7, _143_two_vor_a, 0, _143_two_vor_ha }, @@ -865,47 +887,51 @@ static u3j_core _143_two_d[] = /* layer one */ static u3j_harm _143_one_add_a[] = {{".2", u3wa_add, c3y}, {}}; + static c3_c* _143_one_add_ha[] = { + "68a25eb6", + 0, + }; static u3j_harm _143_one_dec_a[] = {{".2", u3wa_dec, c3y}, {}}; + static c3_c* _143_one_dec_ha[] = { + "ce60540", + 0, + }; static u3j_harm _143_one_div_a[] = {{".2", u3wa_div, c3y}, {}}; + static c3_c* _143_one_div_ha[] = { + "3457adb3", + 0, + }; static u3j_harm _143_one_dvr_a[] = {{".2", u3wc_dvr, c3y}, {}}; static u3j_harm _143_one_gte_a[] = {{".2", u3wa_gte, c3y}, {}}; static u3j_harm _143_one_gth_a[] = {{".2", u3wa_gth, c3y}, {}}; static u3j_harm _143_one_lte_a[] = {{".2", u3wa_lte, c3y}, {}}; static u3j_harm _143_one_lth_a[] = {{".2", u3wa_lth, c3y}, {}}; + static c3_c* _143_one_lth_ha[] = { + "ef85ae3", + 0, + }; static u3j_harm _143_one_mod_a[] = {{".2", u3wa_mod, c3y}, {}}; static u3j_harm _143_one_mul_a[] = {{".2", u3wa_mul, c3y}, {}}; + static c3_c* _143_one_mul_ha[] = { + "679b5099", + 0, + }; static u3j_harm _143_one_sub_a[] = {{".2", u3wa_sub, c3y}, {}}; - + static c3_c* _143_one_sub_ha[] = { + "5e25e8d4", + 0, + }; static u3j_harm _143_one_cap_a[] = {{".2", u3wc_cap, c3y}, {}}; static u3j_harm _143_one_peg_a[] = {{".2", u3wc_peg, c3y}, {}}; + static c3_c* _143_one_peg_ha[] = { + "4ecc0289", + 0, + }; static u3j_harm _143_one_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; -static c3_c* _143_two_ha[] = { - "613c4d6d", - 0, -}; -static c3_c* _143_one_div_ha[] = { - "3457adb3", - 0, -}; -static c3_c* _143_one_mul_ha[] = { - "679b5099", - 0, -}; -static c3_c* _143_one_sub_ha[] = { - "5e25e8d4", - 0, -}; -static c3_c* _143_one_dec_ha[] = { - "ce60540", - 0, -}; -static c3_c* _143_one_add_ha[] = { - "68a25eb6", - 0, -}; -static c3_c* _143_one_lth_ha[] = { - "ef85ae3", + +static c3_c* _143_one_ha[] = { + "c4b5bd8", 0, }; static u3j_core _143_one_d[] = @@ -924,26 +950,22 @@ static u3j_core _143_one_d[] = { "cap", 7, _143_one_cap_a }, { "mas", 7, _143_one_mas_a }, - { "peg", 7, _143_one_peg_a }, + { "peg", 7, _143_one_peg_a, 0, _143_one_peg_ha }, {} }; -static c3_c* _143_one_ha[] = { - "c4b5bd8", - 0, +static c3_c* _k143_ha[] = { + "13e199f7", + 0 }; u3j_core _k143_d[] = { { "one", 3, 0, _143_one_d, _143_one_ha }, {} }; -static c3_c* _k143_h[] = { - "13e199f7", - 0 -}; static u3j_core _d[] = { - { "k143", 0, 0, _k143_d, _k143_h, 0, (u3j_core*) 143, 0}, + { "k143", 0, 0, _k143_d, _k143_ha, 0, (u3j_core*) 143, 0}, {} }; From 2a96e8c60e67832c5e35378562fdfd576a01e6a7 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 14 May 2018 08:47:52 -0700 Subject: [PATCH 107/221] hashes through arvo-assembly --- jets/tree.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 1b35e07a9..f2d15433f 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -112,7 +112,16 @@ static u3j_core _143_hex_d[] = static u3j_harm _143_pen_flip_a[] = {{".2", u3wf_flip}, {}}; static u3j_harm _143_pen_flor_a[] = {{".2", u3wf_flor}, {}}; static u3j_harm _143_pen_fork_a[] = {{".2", u3wf_fork}, {}}; + static c3_c* _143_pen_fork_ha[] = { + "6c3239f5", + 0, + }; + static u3j_harm _143_pen_hike_a[] = {{".2", u3wf_hike}, {}}; + static c3_c* _143_pen_hike_ha[] = { + "65731f61", + 0, + }; static u3j_harm _143_pen_look_a[] = {{".2", u3wf_look}, {}}; static u3j_harm _143_pen_loot_a[] = {{".2", u3wf_loot}, {}}; @@ -134,6 +143,10 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_mull_a[] = {{".2", u3wfu_mull}, {}}; static u3j_harm _143_pen__ut_nest_a[] = {{".2", u3wfu_nest}, {}}; + static c3_c* _143_pen__ut_nest_ha[] = { + "4512a8f4", + 0, + }; static u3j_harm _143_pen__ut_peek_a[] = {{".2", u3wfu_peek}, {}}; static u3j_harm _143_pen__ut_play_a[] = {{".2", u3wfu_play}, {}}; static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; @@ -196,7 +209,7 @@ static u3j_core _143_hex_d[] = { "fuse", 7, _143_pen__ut_fuse_a }, { "mint", 7, _143_pen__ut_mint_a, 0, _143_pen__ut_mint_ha }, { "mull", 7, _143_pen__ut_mull_a }, - { "nest", 7, _143_pen__ut_nest_a }, + { "nest", 7, _143_pen__ut_nest_a, 0, _143_pen__ut_nest_ha }, { "peek", 7, _143_pen__ut_peek_a }, { "play", 7, _143_pen__ut_play_a }, { "rest", 7, _143_pen__ut_rest_a }, @@ -246,9 +259,9 @@ static u3j_core _143_pen_d[] = { "flan", 7, _143_pen_flan_a }, { "flip", 7, _143_pen_flip_a }, { "flor", 7, _143_pen_flor_a }, - { "fork", 7, _143_pen_fork_a }, + { "fork", 7, _143_pen_fork_a, 0, _143_pen_fork_ha }, { "help", 7, _143_pen_help_a }, - { "hike", 7, _143_pen_hike_a }, + { "hike", 7, _143_pen_hike_a, 0, _143_pen_hike_ha }, { "look", 7, _143_pen_look_a }, { "loot", 7, _143_pen_loot_a }, @@ -682,6 +695,10 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_snag_a[] = {{".2", u3wb_snag, c3y}, {}}; // static u3j_harm _143_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; static u3j_harm _143_two_turn_a[] = {{".2", u3wb_turn, c3y}, {}}; + static c3_c* _143_two_turn_ha[] = { + "6edb42", + 0, + }; static u3j_harm _143_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; static u3j_harm _143_two_bex_a[] = {{".2", u3wc_bex, c3y}, {}}; @@ -844,7 +861,7 @@ static u3j_core _143_two_d[] = { "slag", 7, _143_two_slag_a }, { "snag", 7, _143_two_snag_a }, // { "sort", 7, _143_two_sort_a }, - { "turn", 7, _143_two_turn_a }, + { "turn", 7, _143_two_turn_a, 0, _143_two_turn_ha }, { "weld", 7, _143_two_weld_a }, { "bex", 7, _143_two_bex_a, 0, _143_two_bex_ha }, @@ -905,6 +922,10 @@ static u3j_core _143_two_d[] = static u3j_harm _143_one_gte_a[] = {{".2", u3wa_gte, c3y}, {}}; static u3j_harm _143_one_gth_a[] = {{".2", u3wa_gth, c3y}, {}}; static u3j_harm _143_one_lte_a[] = {{".2", u3wa_lte, c3y}, {}}; + static c3_c* _143_one_lte_ha[] = { + "6fc5ac17", + 0, + }; static u3j_harm _143_one_lth_a[] = {{".2", u3wa_lth, c3y}, {}}; static c3_c* _143_one_lth_ha[] = { "ef85ae3", @@ -942,7 +963,7 @@ static u3j_core _143_one_d[] = { "dvr", 7, _143_one_dvr_a }, { "gte", 7, _143_one_gte_a }, { "gth", 7, _143_one_gth_a }, - { "lte", 7, _143_one_lte_a }, + { "lte", 7, _143_one_lte_a, 0, _143_one_lte_ha }, { "lth", 7, _143_one_lth_a, 0, _143_one_lth_ha }, { "mod", 7, _143_one_mod_a }, { "mul", 7, _143_one_mul_a, 0, _143_one_mul_ha }, From 13400a6f478cf5c5c740866daa4e55b199453c94 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 14 May 2018 09:27:16 -0700 Subject: [PATCH 108/221] jacked --- jets/tree.c | 101 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 21 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index f2d15433f..b8f20af67 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -89,6 +89,10 @@ static u3j_core _143_hex_coed_d[] = {} }; +static c3_c* _143_hex_ha[] = { + "2fd207b3", + 0, +}; static u3j_core _143_hex_d[] = { { "down", 31337, 0, _143_hex_down_d }, { "lore", 7, _143_hex_lore_a }, @@ -102,11 +106,23 @@ static u3j_core _143_hex_d[] = /* layer five */ static u3j_harm _143_pen_cell_a[] = {{".2", u3wf_cell}, {}}; + static c3_c* _143_pen_cell_ha[] = { + "6bfc1bca", + 0, + }; static u3j_harm _143_pen_comb_a[] = {{".2", u3wf_comb}, {}}; static u3j_harm _143_pen_cons_a[] = {{".2", u3wf_cons}, {}}; static u3j_harm _143_pen_core_a[] = {{".2", u3wf_core}, {}}; + static c3_c* _143_pen_core_ha[] = { + "5c37f17b", + 0, + }; static u3j_harm _143_pen_help_a[] = {{".2", u3wf_help}, {}}; static u3j_harm _143_pen_face_a[] = {{".2", u3wf_face}, {}}; + static c3_c* _143_pen_face_ha[] = { + "742c24f0", + 0, + }; static u3j_harm _143_pen_fitz_a[] = {{".2", u3wf_fitz}, {}}; static u3j_harm _143_pen_flan_a[] = {{".2", u3wf_flan}, {}}; static u3j_harm _143_pen_flip_a[] = {{".2", u3wf_flip}, {}}; @@ -148,9 +164,21 @@ static u3j_core _143_hex_d[] = 0, }; static u3j_harm _143_pen__ut_peek_a[] = {{".2", u3wfu_peek}, {}}; + static c3_c* _143_pen__ut_peek_ha[] = { + "3c631b7d", + 0, + }; static u3j_harm _143_pen__ut_play_a[] = {{".2", u3wfu_play}, {}}; + static c3_c* _143_pen__ut_play_ha[] = { + "e276a30", + 0, + }; static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; static u3j_harm _143_pen__ut_toss_a[] = {{".2", u3wfu_toss}, {}}; + static c3_c* _143_pen__ut_toss_ha[] = { + "54362dd", + 0, + }; static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; static c3_c* _143_pen__ut_ha[] = { @@ -210,10 +238,10 @@ static u3j_core _143_hex_d[] = { "mint", 7, _143_pen__ut_mint_a, 0, _143_pen__ut_mint_ha }, { "mull", 7, _143_pen__ut_mull_a }, { "nest", 7, _143_pen__ut_nest_a, 0, _143_pen__ut_nest_ha }, - { "peek", 7, _143_pen__ut_peek_a }, - { "play", 7, _143_pen__ut_play_a }, + { "peek", 7, _143_pen__ut_peek_a, 0, _143_pen__ut_peek_ha }, + { "play", 7, _143_pen__ut_play_a, 0, _143_pen__ut_play_ha }, { "rest", 7, _143_pen__ut_rest_a }, - { "toss", 7, _143_pen__ut_toss_a }, + { "toss", 7, _143_pen__ut_toss_a, 0, _143_pen__ut_toss_ha }, { "wrap", 7, _143_pen__ut_wrap_a }, {} }; @@ -248,13 +276,13 @@ static u3j_hood _143_pen_ho[] = { {}, }; static u3j_core _143_pen_d[] = - { { "hex", 0, 0, _143_hex_d }, + { { "hex", 3, 0, _143_hex_d, _143_hex_ha }, - { "cell", 7, _143_pen_cell_a }, + { "cell", 7, _143_pen_cell_a, 0, _143_pen_cell_ha }, { "comb", 7, _143_pen_comb_a }, { "cons", 7, _143_pen_cons_a }, - { "core", 7, _143_pen_core_a }, - { "face", 7, _143_pen_face_a }, + { "core", 7, _143_pen_core_a, 0, _143_pen_core_ha }, + { "face", 7, _143_pen_face_a, 0, _143_pen_face_ha }, { "fitz", 7, _143_pen_fitz_a }, { "flan", 7, _143_pen_flan_a }, { "flip", 7, _143_pen_flip_a }, @@ -691,7 +719,15 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_skim_a[] = {{".2", u3wb_skim, c3y}, {}}; static u3j_harm _143_two_skip_a[] = {{".2", u3wb_skip, c3y}, {}}; static u3j_harm _143_two_scag_a[] = {{".2", u3wb_scag, c3y}, {}}; + static c3_c* _143_two_scag_ha[] = { + "6d492573", + 0, + }; static u3j_harm _143_two_slag_a[] = {{".2", u3wb_slag, c3y}, {}}; + static c3_c* _143_two_slag_ha[] = { + "6a9fe551", + 0, + }; static u3j_harm _143_two_snag_a[] = {{".2", u3wb_snag, c3y}, {}}; // static u3j_harm _143_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; static u3j_harm _143_two_turn_a[] = {{".2", u3wb_turn, c3y}, {}}; @@ -700,6 +736,10 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; + static c3_c* _143_two_weld_ha[] = { + "752d9421", + 0, + }; static u3j_harm _143_two_bex_a[] = {{".2", u3wc_bex, c3y}, {}}; static c3_c* _143_two_bex_ha[] = { @@ -707,7 +747,6 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two_can_a[] = {{".2", u3wc_can, c3y}, {}}; - static u3j_harm _143_two_cap_a[] = {{".2", u3wc_cap, c3y}, {}}; static u3j_harm _143_two_cat_a[] = {{".2", u3wc_cat, c3y}, {}}; static u3j_harm _143_two_con_a[] = {{".2", u3wc_con, c3y}, {}}; static u3j_harm _143_two_cut_a[] = {{".2", u3wc_cut, c3y}, {}}; @@ -726,7 +765,6 @@ static u3j_core _143_tri_d[] = "41b3a4c7", 0, }; - static u3j_harm _143_two_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; static u3j_harm _143_two_met_a[] = {{".2", u3wc_met, c3y}, {}}; static c3_c* _143_two_met_ha[] = { "51509f40", @@ -770,9 +808,17 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__in_dif_a[] = {{".2", u3wdi_dif}, {}}; static u3j_harm _143_two__in_gas_a[] = {{".2", u3wdi_gas}, {}}; static u3j_harm _143_two__in_has_a[] = {{".2", u3wdi_has}, {}}; + static c3_c* _143_two__in_has_ha[] = { + "39a46ced", + 0, + }; static u3j_harm _143_two__in_mer_a[] = {{".2", u3wdi_mer}, {}}; // static u3j_harm _143_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _143_two__in_put_a[] = {{".2", u3wdi_put}, {}}; + static c3_c* _143_two__in_put_ha[] = { + "57cf34a9", + 0, + }; static u3j_harm _143_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; static c3_c* _143_two__in_tap_ha[] = { "70881f1a", @@ -793,10 +839,10 @@ static u3j_core _143_tri_d[] = { { "bif", 7, _143_two__in_bif_a }, { "dif", 7, _143_two__in_dif_a }, { "gas", 7, _143_two__in_gas_a }, - { "has", 7, _143_two__in_has_a }, + { "has", 7, _143_two__in_has_a, 0, _143_two__in_has_ha }, { "mer", 7, _143_two__in_mer_a }, // { "int", 7, _143_two__in_int_a }, - { "put", 7, _143_two__in_put_a }, + { "put", 7, _143_two__in_put_a, 0, _143_two__in_put_ha }, { "tap", 7, _143_two__in_tap_a, 0, _143_two__in_tap_ha }, { "wyt", 7, _143_two__in_wyt_a }, { "uni", 7, _143_two__in_uni_a, 0, _143_two__in_uni_ha }, @@ -814,6 +860,10 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__by_has_a[] = {{".2", u3wdb_has, c3y}, {}}; // static u3j_harm _143_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; static u3j_harm _143_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; + static c3_c* _143_two__by_put_ha[] = { + "2c511da5", + 0, + }; static u3j_harm _143_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; // static u3j_harm _143_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; @@ -828,7 +878,7 @@ static u3j_core _143_tri_d[] = { "get", 7, _143_two__by_get_a }, { "has", 7, _143_two__by_has_a }, // { "int", 7, _143_two__by_int_a }, - { "put", 7, _143_two__by_put_a }, + { "put", 7, _143_two__by_put_a, 0, _143_two__by_put_ha }, { "tap", 7, _143_two__by_tap_a }, // { "uni", _143_two__by_uni_a }, {} @@ -857,17 +907,16 @@ static u3j_core _143_two_d[] = { "skid", 7, _143_two_skid_a }, { "skim", 7, _143_two_skim_a }, { "skip", 7, _143_two_skip_a }, - { "scag", 7, _143_two_scag_a }, - { "slag", 7, _143_two_slag_a }, + { "scag", 7, _143_two_scag_a, 0, _143_two_scag_ha }, + { "slag", 7, _143_two_slag_a, 0, _143_two_slag_ha }, { "snag", 7, _143_two_snag_a }, // { "sort", 7, _143_two_sort_a }, { "turn", 7, _143_two_turn_a, 0, _143_two_turn_ha }, - { "weld", 7, _143_two_weld_a }, + { "weld", 7, _143_two_weld_a, 0, _143_two_weld_ha }, { "bex", 7, _143_two_bex_a, 0, _143_two_bex_ha }, { "cat", 7, _143_two_cat_a }, { "can", 7, _143_two_can_a }, - { "cap", 7, _143_two_cap_a }, { "con", 7, _143_two_con_a }, { "cue", 7, _143_two_cue_a }, { "cut", 7, _143_two_cut_a }, @@ -879,7 +928,6 @@ static u3j_core _143_two_d[] = { "hor", 7, _143_two_hor_a }, { "jam", 7, _143_two_jam_a }, { "lsh", 7, _143_two_lsh_a, 0, _143_two_lsh_ha }, - { "mas", 7, _143_two_mas_a }, { "mat", 7, _143_two_mat_a }, { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, { "mix", 7, _143_two_mix_a, 0, _143_two_mix_ha }, @@ -921,6 +969,10 @@ static u3j_core _143_two_d[] = static u3j_harm _143_one_dvr_a[] = {{".2", u3wc_dvr, c3y}, {}}; static u3j_harm _143_one_gte_a[] = {{".2", u3wa_gte, c3y}, {}}; static u3j_harm _143_one_gth_a[] = {{".2", u3wa_gth, c3y}, {}}; + static c3_c* _143_one_gth_ha[] = { + "7555a49a", + 0, + }; static u3j_harm _143_one_lte_a[] = {{".2", u3wa_lte, c3y}, {}}; static c3_c* _143_one_lte_ha[] = { "6fc5ac17", @@ -943,13 +995,20 @@ static u3j_core _143_two_d[] = 0, }; static u3j_harm _143_one_cap_a[] = {{".2", u3wc_cap, c3y}, {}}; + static c3_c* _143_one_cap_ha[] = { + "7d28acf4", + 0, + }; static u3j_harm _143_one_peg_a[] = {{".2", u3wc_peg, c3y}, {}}; static c3_c* _143_one_peg_ha[] = { "4ecc0289", 0, }; static u3j_harm _143_one_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; - + static c3_c* _143_one_mas_ha[] = { + "611f2aab", + 0, + }; static c3_c* _143_one_ha[] = { "c4b5bd8", @@ -962,15 +1021,15 @@ static u3j_core _143_one_d[] = { "div", 7, _143_one_div_a, 0, _143_one_div_ha }, { "dvr", 7, _143_one_dvr_a }, { "gte", 7, _143_one_gte_a }, - { "gth", 7, _143_one_gth_a }, + { "gth", 7, _143_one_gth_a, 0, _143_one_gth_ha }, { "lte", 7, _143_one_lte_a, 0, _143_one_lte_ha }, { "lth", 7, _143_one_lth_a, 0, _143_one_lth_ha }, { "mod", 7, _143_one_mod_a }, { "mul", 7, _143_one_mul_a, 0, _143_one_mul_ha }, { "sub", 7, _143_one_sub_a, 0, _143_one_sub_ha }, - { "cap", 7, _143_one_cap_a }, - { "mas", 7, _143_one_mas_a }, + { "cap", 7, _143_one_cap_a, 0, _143_one_cap_ha }, + { "mas", 7, _143_one_mas_a, 0, _143_one_mas_ha }, { "peg", 7, _143_one_peg_a, 0, _143_one_peg_ha }, {} From 7664b9175b6747e81b620906884030e1fa3417ef Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 14 May 2018 10:03:20 -0700 Subject: [PATCH 109/221] one finished, most of two --- jets/tree.c | 190 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 157 insertions(+), 33 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index b8f20af67..23e4acce4 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -705,19 +705,57 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two_levy_a[] = {{".2", u3wb_levy, c3y}, {}}; + static c3_c* _143_two_levy_ha[] = { + "35460246", + 0, + }; static u3j_harm _143_two_lien_a[] = {{".2", u3wb_lien, c3y}, {}}; + static c3_c* _143_two_lien_ha[] = { + "26fe83d7", + 0, + }; static u3j_harm _143_two_murn_a[] = {{".2", u3wb_murn, c3y}, {}}; + static c3_c* _143_two_murn_ha[] = { + "7267235b", + 0, + }; +/* XX: no hint static u3j_harm _143_two_need_a[] = {{".2", u3wb_need, c3y}, {}}; + static c3_c* _143_two_need_ha[] = { + "", + 0, + }; +*/ static u3j_harm _143_two_reap_a[] = {{".2", u3wb_reap, c3y}, {}}; + static c3_c* _143_two_reap_ha[] = { + "1808a81d", + 0, + }; static u3j_harm _143_two_reel_a[] = {{".2", u3wb_reel, c3y}, {}}; + static c3_c* _143_two_reel_ha[] = { + "660c4ee9", + 0, + }; static u3j_harm _143_two_roll_a[] = {{".2", u3wb_roll, c3y}, {}}; static c3_c* _143_two_roll_ha[] = { "3c16e592", 0, }; static u3j_harm _143_two_skid_a[] = {{".2", u3wb_skid, c3y}, {}}; + static c3_c* _143_two_skid_ha[] = { + "3dc45cc", + 0, + }; static u3j_harm _143_two_skim_a[] = {{".2", u3wb_skim, c3y}, {}}; + static c3_c* _143_two_skim_ha[] = { + "36892702", + 0, + }; static u3j_harm _143_two_skip_a[] = {{".2", u3wb_skip, c3y}, {}}; + static c3_c* _143_two_skip_ha[] = { + "580714ad", + 0, + }; static u3j_harm _143_two_scag_a[] = {{".2", u3wb_scag, c3y}, {}}; static c3_c* _143_two_scag_ha[] = { "6d492573", @@ -729,6 +767,10 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two_snag_a[] = {{".2", u3wb_snag, c3y}, {}}; + static c3_c* _143_two_snag_ha[] = { + "da6440d", + 0, + }; // static u3j_harm _143_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; static u3j_harm _143_two_turn_a[] = {{".2", u3wb_turn, c3y}, {}}; static c3_c* _143_two_turn_ha[] = { @@ -747,19 +789,50 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two_can_a[] = {{".2", u3wc_can, c3y}, {}}; + static c3_c* _143_two_can_ha[] = { + "6039dee0", + 0, + }; static u3j_harm _143_two_cat_a[] = {{".2", u3wc_cat, c3y}, {}}; + static c3_c* _143_two_cat_ha[] = { + "408a97e8", + 0, + }; static u3j_harm _143_two_con_a[] = {{".2", u3wc_con, c3y}, {}}; + static c3_c* _143_two_con_ha[] = { + "49ff881", + 0, + }; static u3j_harm _143_two_cut_a[] = {{".2", u3wc_cut, c3y}, {}}; + static c3_c* _143_two_cut_ha[] = { + "2c8d7897", + 0, + }; static u3j_harm _143_two_dis_a[] = {{".2", u3wc_dis, c3y}, {}}; + static c3_c* _143_two_dis_ha[] = { + "135fb298", + 0, + }; static u3j_harm _143_two_dor_a[] = {{".2", u3wc_dor, c3y}, {}}; - static u3j_harm _143_two_dvr_a[] = {{".2", u3wc_dvr, c3y}, {}}; + static c3_c* _143_two_dor_ha[] = { + "5c0d99f7", + 0, + }; static u3j_harm _143_two_end_a[] = {{".2", u3wc_end, c3y}, {}}; static c3_c* _143_two_end_ha[] = { "3fb28e44", 0, }; static u3j_harm _143_two_gor_a[] = {{".2", u3wc_gor, c3y}, {}}; + static c3_c* _143_two_gor_ha[] = { + "17eba2b9", + 0, + }; static u3j_harm _143_two_hor_a[] = {{".2", u3wc_hor, c3y}, {}}; + static c3_c* _143_two_hor_ha[] = { + "4a7e5d16", + 0, + }; static u3j_harm _143_two_lsh_a[] = {{".2", u3wc_lsh, c3y}, {}}; static c3_c* _143_two_lsh_ha[] = { "41b3a4c7", @@ -776,14 +849,30 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two_mug_a[] = {{".2", u3wc_mug, c3y}, {}}; + static c3_c* _143_two_mug_ha[] = { + "11404a2", + 0, + }; static u3j_harm _143_two_muk_a[] = {{".2", u3wc_muk, c3y}, {}}; + static c3_c* _143_two_muk_ha[] = { + "482e58af", + 0, + }; static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; + static c3_c* _143_two_pow_ha[] = { + "4a70ddfe", + 0, + }; static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}}; static c3_c* _143_two_rap_ha[] = { "7a6875bb", 0, }; static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}}; + static c3_c* _143_two_rep_ha[] = { + "53e80eb3", + 0, + }; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; static c3_c* _143_two_rip_ha[] = { "54970200", @@ -795,12 +884,20 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; + static c3_c* _143_two_sqt_ha[] = { + "50929e0b", + 0, + }; static u3j_harm _143_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _143_two_vor_ha[] = { "2b05b267", 0, }; static u3j_harm _143_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; + static c3_c* _143_two_xeb_ha[] = { + "5e2bcea8", + 0, + }; @@ -885,9 +982,25 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_cue_a[] = {{".2", u3we_cue}, {}}; + static c3_c* _143_two_cue_ha[] = { + "6f20da6b", + 0, + }; static u3j_harm _143_two_jam_a[] = {{".2", u3we_jam}, {}}; + static c3_c* _143_two_jam_ha[] = { + "4103997f", + 0, + }; static u3j_harm _143_two_mat_a[] = {{".2", u3we_mat}, {}}; + static c3_c* _143_two_mat_ha[] = { + "1a2c351b", + 0, + }; static u3j_harm _143_two_rub_a[] = {{".2", u3we_rub}, {}}; + static c3_c* _143_two_rub_ha[] = { + "56b1242e", + 0, + }; static c3_c* _143_two_ha[] = { "613c4d6d", @@ -897,51 +1010,50 @@ static u3j_core _143_two_d[] = { { "tri", 3, 0, _143_tri_d, _143_tri_ha }, { "flop", 7, _143_two_flop_a, 0, _143_two_flop_ha }, { "lent", 7, _143_two_lent_a, 0, _143_two_lent_ha }, - { "levy", 7, _143_two_levy_a }, - { "lien", 7, _143_two_lien_a }, - { "murn", 7, _143_two_murn_a }, - { "need", 7, _143_two_need_a }, - { "reap", 7, _143_two_reap_a }, - { "reel", 7, _143_two_reel_a }, + { "levy", 7, _143_two_levy_a, 0, _143_two_levy_ha }, + { "lien", 7, _143_two_lien_a, 0, _143_two_lien_ha }, + { "murn", 7, _143_two_murn_a, 0, _143_two_murn_ha }, +// { "need", 7, _143_two_need_a, 0, _143_two_need_ha }, + { "reap", 7, _143_two_reap_a, 0, _143_two_reap_ha }, + { "reel", 7, _143_two_reel_a, 0, _143_two_reel_ha }, { "roll", 7, _143_two_roll_a, 0, _143_two_roll_ha }, - { "skid", 7, _143_two_skid_a }, - { "skim", 7, _143_two_skim_a }, - { "skip", 7, _143_two_skip_a }, + { "skid", 7, _143_two_skid_a, 0, _143_two_skid_ha }, + { "skim", 7, _143_two_skim_a, 0, _143_two_skim_ha }, + { "skip", 7, _143_two_skip_a, 0, _143_two_skip_ha }, { "scag", 7, _143_two_scag_a, 0, _143_two_scag_ha }, { "slag", 7, _143_two_slag_a, 0, _143_two_slag_ha }, - { "snag", 7, _143_two_snag_a }, + { "snag", 7, _143_two_snag_a, 0, _143_two_snag_ha }, // { "sort", 7, _143_two_sort_a }, { "turn", 7, _143_two_turn_a, 0, _143_two_turn_ha }, { "weld", 7, _143_two_weld_a, 0, _143_two_weld_ha }, { "bex", 7, _143_two_bex_a, 0, _143_two_bex_ha }, - { "cat", 7, _143_two_cat_a }, - { "can", 7, _143_two_can_a }, - { "con", 7, _143_two_con_a }, - { "cue", 7, _143_two_cue_a }, - { "cut", 7, _143_two_cut_a }, - { "dis", 7, _143_two_dis_a }, - { "dor", 7, _143_two_dor_a }, - { "dvr", 7, _143_two_dvr_a }, + { "cat", 7, _143_two_cat_a, 0, _143_two_cat_ha }, + { "can", 7, _143_two_can_a, 0, _143_two_can_ha }, + { "con", 7, _143_two_con_a, 0, _143_two_con_ha }, + { "cue", 7, _143_two_cue_a, 0, _143_two_cue_ha }, + { "cut", 7, _143_two_cut_a, 0, _143_two_cut_ha }, + { "dis", 7, _143_two_dis_a, 0, _143_two_dis_ha }, + { "dor", 7, _143_two_dor_a, 0, _143_two_dor_ha }, { "end", 7, _143_two_end_a, 0, _143_two_end_ha }, - { "gor", 7, _143_two_gor_a }, - { "hor", 7, _143_two_hor_a }, - { "jam", 7, _143_two_jam_a }, + { "gor", 7, _143_two_gor_a, 0, _143_two_gor_ha }, + { "hor", 7, _143_two_hor_a, 0, _143_two_hor_ha }, + { "jam", 7, _143_two_jam_a, 0, _143_two_jam_ha }, { "lsh", 7, _143_two_lsh_a, 0, _143_two_lsh_ha }, - { "mat", 7, _143_two_mat_a }, + { "mat", 7, _143_two_mat_a, 0, _143_two_mat_ha }, { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, { "mix", 7, _143_two_mix_a, 0, _143_two_mix_ha }, - { "mug", 7, _143_two_mug_a }, - { "muk", 7, _143_two_muk_a }, + { "mug", 7, _143_two_mug_a, 0, _143_two_mug_ha }, + { "muk", 7, _143_two_muk_a, 0, _143_two_muk_ha }, { "rap", 7, _143_two_rap_a, 0, _143_two_rap_ha }, - { "rep", 7, _143_two_rep_a }, + { "rep", 7, _143_two_rep_a, 0, _143_two_rep_ha }, { "rip", 7, _143_two_rip_a, 0, _143_two_rip_ha }, { "rsh", 7, _143_two_rsh_a, 0, _143_two_rsh_ha }, - { "rub", 7, _143_two_rub_a }, - { "pow", 7, _143_two_pow_a }, - { "sqt", 7, _143_two_sqt_a }, + { "rub", 7, _143_two_rub_a, 0, _143_two_rub_ha }, + { "pow", 7, _143_two_pow_a, 0, _143_two_pow_ha }, + { "sqt", 7, _143_two_sqt_a, 0, _143_two_sqt_ha }, { "vor", 7, _143_two_vor_a, 0, _143_two_vor_ha }, - { "xeb", 7, _143_two_xeb_a }, + { "xeb", 7, _143_two_xeb_a, 0, _143_two_xeb_ha }, { "by", 7, 0, _143_two__by_d, _143_two__by_ha }, { "in", 7, 0, _143_two__in_d, _143_two__in_ha }, @@ -967,7 +1079,15 @@ static u3j_core _143_two_d[] = 0, }; static u3j_harm _143_one_dvr_a[] = {{".2", u3wc_dvr, c3y}, {}}; + static c3_c* _143_one_dvr_ha[] = { + "20cdcad0", + 0, + }; static u3j_harm _143_one_gte_a[] = {{".2", u3wa_gte, c3y}, {}}; + static c3_c* _143_one_gte_ha[] = { + "8542678", + 0, + }; static u3j_harm _143_one_gth_a[] = {{".2", u3wa_gth, c3y}, {}}; static c3_c* _143_one_gth_ha[] = { "7555a49a", @@ -984,6 +1104,10 @@ static u3j_core _143_two_d[] = 0, }; static u3j_harm _143_one_mod_a[] = {{".2", u3wa_mod, c3y}, {}}; + static c3_c* _143_one_mod_ha[] = { + "1ccddd83", + 0, + }; static u3j_harm _143_one_mul_a[] = {{".2", u3wa_mul, c3y}, {}}; static c3_c* _143_one_mul_ha[] = { "679b5099", @@ -1019,12 +1143,12 @@ static u3j_core _143_one_d[] = { "add", 7, _143_one_add_a, 0, _143_one_add_ha }, { "dec", 7, _143_one_dec_a, 0, _143_one_dec_ha }, { "div", 7, _143_one_div_a, 0, _143_one_div_ha }, - { "dvr", 7, _143_one_dvr_a }, - { "gte", 7, _143_one_gte_a }, + { "dvr", 7, _143_one_dvr_a, 0, _143_one_dvr_ha }, + { "gte", 7, _143_one_gte_a, 0, _143_one_gte_ha }, { "gth", 7, _143_one_gth_a, 0, _143_one_gth_ha }, { "lte", 7, _143_one_lte_a, 0, _143_one_lte_ha }, { "lth", 7, _143_one_lth_a, 0, _143_one_lth_ha }, - { "mod", 7, _143_one_mod_a }, + { "mod", 7, _143_one_mod_a, 0, _143_one_mod_ha }, { "mul", 7, _143_one_mul_a, 0, _143_one_mul_ha }, { "sub", 7, _143_one_sub_a, 0, _143_one_sub_ha }, From 4ee14f4c59668a5cb7487e874e9fcea4738a7ac5 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 14 May 2018 10:46:34 -0700 Subject: [PATCH 110/221] print axe on hot jet, more hashes --- jets/tree.c | 105 ++++++++++++++++++++++++++++++++++++++++++---------- noun/jets.c | 2 +- 2 files changed, 87 insertions(+), 20 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 23e4acce4..a8894a0a3 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -663,15 +663,42 @@ static u3j_core _143_qua_d[] = }; static u3j_harm _143_tri__og_raw_a[] = {{".2", u3weo_raw}, {}}; + static c3_c* _143_tri__og_raw_ha[] = { + "2b65a131", + 0, + }; + + static c3_c* _143_tri__og_ha[] = { + "65c7f2b6", + 0, + }; static u3j_core _143_tri__og_d[] = - { { "raw", 7, _143_tri__og_raw_a }, + { { "raw", 7, _143_tri__og_raw_a, 0, _143_tri__og_raw_ha }, {} }; static u3j_harm _143_tri_shax_a[] = {{".2", u3we_shax}, {}}; + static c3_c* _143_tri_shax_ha[] = { + "2d81b3eb", + 0, + }; static u3j_harm _143_tri_shay_a[] = {{".2", u3we_shay}, {}}; + static c3_c* _143_tri_shay_ha[] = { + "3081f15b", + 0, + }; +/* XX: no hint static u3j_harm _143_tri_shas_a[] = {{".2", u3we_shas}, {}}; + static c3_c* _143_tri_shas_ha[] = { + "", + 0, + }; +*/ static u3j_harm _143_tri_shal_a[] = {{".2", u3we_shal}, {}}; + static c3_c* _143_tri_shal_ha[] = { + "63ea0b00", + 0, + }; static c3_c* _143_tri_ha[] = { "6cc318e2", @@ -684,11 +711,11 @@ static u3j_core _143_tri_d[] = { "rs", 7, 0, _143_tri__rs_d }, { "rq", 7, 0, _143_tri__rq_d }, { "rh", 7, 0, _143_tri__rh_d }, - { "og", 7, 0, _143_tri__og_d }, - { "shax", 7, _143_tri_shax_a }, - { "shay", 7, _143_tri_shay_a }, - { "shas", 7, _143_tri_shas_a }, - { "shal", 7, _143_tri_shal_a }, + { "og", 7, 0, _143_tri__og_d, _143_tri__og_ha }, + { "shax", 7, _143_tri_shax_a, 0, _143_tri_shax_ha }, + { "shay", 7, _143_tri_shay_a, 0, _143_tri_shay_ha }, +// { "shas", 7, _143_tri_shas_a, 0, _143_tri_shas_ha }, + { "shal", 7, _143_tri_shal_a, 0, _143_tri_shal_ha }, {} }; @@ -899,17 +926,33 @@ static u3j_core _143_tri_d[] = 0, }; - - static u3j_harm _143_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; + static c3_c* _143_two__in_bif_ha[] = { + "16e17df9", + 0, + }; static u3j_harm _143_two__in_dif_a[] = {{".2", u3wdi_dif}, {}}; + static c3_c* _143_two__in_dif_ha[] = { + "4ced9091", + 0, + }; static u3j_harm _143_two__in_gas_a[] = {{".2", u3wdi_gas}, {}}; + static c3_c* _143_two__in_gas_ha[] = { + "4dbdbab4", + 0, + }; static u3j_harm _143_two__in_has_a[] = {{".2", u3wdi_has}, {}}; static c3_c* _143_two__in_has_ha[] = { "39a46ced", 0, }; +/* XX: mer doesn't exist any more? static u3j_harm _143_two__in_mer_a[] = {{".2", u3wdi_mer}, {}}; + static c3_c* _143_two__in_mer_ha[] = { + "", + 0, + }; +*/ // static u3j_harm _143_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _143_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static c3_c* _143_two__in_put_ha[] = { @@ -922,6 +965,10 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; + static c3_c* _143_two__in_wyt_ha[] = { + "71887a13", + 0, + }; static u3j_harm _143_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static c3_c* _143_two__in_uni_ha[] = { "26e34913", @@ -933,28 +980,44 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_core _143_two__in_d[] = - { { "bif", 7, _143_two__in_bif_a }, - { "dif", 7, _143_two__in_dif_a }, - { "gas", 7, _143_two__in_gas_a }, + { { "bif", 7, _143_two__in_bif_a, 0, _143_two__in_bif_ha }, + { "dif", 7, _143_two__in_dif_a, 0, _143_two__in_dif_ha }, + { "gas", 7, _143_two__in_gas_a, 0, _143_two__in_gas_ha }, { "has", 7, _143_two__in_has_a, 0, _143_two__in_has_ha }, - { "mer", 7, _143_two__in_mer_a }, + // { "mer", 7, _143_two__in_mer_a }, // { "int", 7, _143_two__in_int_a }, { "put", 7, _143_two__in_put_a, 0, _143_two__in_put_ha }, { "tap", 7, _143_two__in_tap_a, 0, _143_two__in_tap_ha }, - { "wyt", 7, _143_two__in_wyt_a }, + { "wyt", 3, _143_two__in_wyt_a, 0, _143_two__in_wyt_ha }, { "uni", 7, _143_two__in_uni_a, 0, _143_two__in_uni_ha }, {} }; static u3j_harm _143_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}}; + static c3_c* _143_two__by_bif_ha[] = { + "4e6aedd2", + 0, + }; static u3j_harm _143_two__by_dif_a[] = {{".2", u3wdb_dif, c3y}, {}}; + static c3_c* _143_two__by_dif_ha[] = { + "1388fad7", + 0, + }; static u3j_harm _143_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}}; static c3_c* _143_two__by_gas_ha[] = { "5a8a7e7d", 0, }; static u3j_harm _143_two__by_get_a[] = {{".2", u3wdb_get, c3y}, {}}; + static c3_c* _143_two__by_get_ha[] = { + "ece3b4d", + 0, + }; static u3j_harm _143_two__by_has_a[] = {{".2", u3wdb_has, c3y}, {}}; + static c3_c* _143_two__by_has_ha[] = { + "373d538d", + 0, + }; // static u3j_harm _143_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; static u3j_harm _143_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; static c3_c* _143_two__by_put_ha[] = { @@ -962,6 +1025,10 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_harm _143_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; + static c3_c* _143_two__by_tap_ha[] = { + "70881f1a", + 0, + }; // static u3j_harm _143_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; static c3_c* _143_two__by_ha[] = { @@ -969,14 +1036,14 @@ static u3j_core _143_tri_d[] = 0, }; static u3j_core _143_two__by_d[] = - { { "bif", 7, _143_two__by_bif_a }, - { "dif", 7, _143_two__by_dif_a }, + { { "bif", 7, _143_two__by_bif_a, 0, _143_two__by_bif_ha }, + { "dif", 7, _143_two__by_dif_a, 0, _143_two__by_dif_ha }, { "gas", 7, _143_two__by_gas_a, 0, _143_two__by_gas_ha }, - { "get", 7, _143_two__by_get_a }, - { "has", 7, _143_two__by_has_a }, + { "get", 7, _143_two__by_get_a, 0, _143_two__by_get_ha }, + { "has", 7, _143_two__by_has_a, 0, _143_two__by_has_ha }, // { "int", 7, _143_two__by_int_a }, { "put", 7, _143_two__by_put_a, 0, _143_two__by_put_ha }, - { "tap", 7, _143_two__by_tap_a }, + { "tap", 7, _143_two__by_tap_a, 0, _143_two__by_tap_ha }, // { "uni", _143_two__by_uni_a }, {} }; @@ -1044,7 +1111,7 @@ static u3j_core _143_two_d[] = { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, { "mix", 7, _143_two_mix_a, 0, _143_two_mix_ha }, { "mug", 7, _143_two_mug_a, 0, _143_two_mug_ha }, - { "muk", 7, _143_two_muk_a, 0, _143_two_muk_ha }, + { "muk", 59, _143_two_muk_a, 0, _143_two_muk_ha }, { "rap", 7, _143_two_rap_a, 0, _143_two_rap_ha }, { "rep", 7, _143_two_rep_a, 0, _143_two_rep_ha }, { "rip", 7, _143_two_rip_a, 0, _143_two_rip_ha }, diff --git a/noun/jets.c b/noun/jets.c index fd787fe74..9afff64d0 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1654,7 +1654,7 @@ _cj_mine(u3_noun cey, u3_noun cor) _cj_print_tas(stderr, u3h(i)); i = u3t(i); } - fprintf(stderr, "\r\n bat %x, jax %d\r\n", u3r_mug(bat), jax_l); + fprintf(stderr, "\r\n bat %x, axe %d, jax %d\r\n", u3r_mug(bat), axe, jax_l); } hap = _cj_warm_hump(jax_l, u3t(u3t(loc))); act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); From 55b990cd3836e8e1aed65f1e20bff62b8325d0c2 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 14 May 2018 13:59:17 -0700 Subject: [PATCH 111/221] layer three --- jets/tree.c | 317 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 264 insertions(+), 53 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index a8894a0a3..8e20756f0 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -552,113 +552,323 @@ static u3j_core _143_qua_d[] = /* layer three */ static u3j_harm _143_tri__cofl__drg_a[] = {{".2", u3wef_drg}, {}}; + static c3_c* _143_tri__cofl__drg_ha[] = { + "6bc6a27f", + 0, + }; static u3j_harm _143_tri__cofl__lug_a[] = {{".2", u3wef_lug}, {}}; + static c3_c* _143_tri__cofl__lug_ha[] = { + "6a832f4a", + 0, + }; + + static c3_c* _143_tri__cofl_ha[] = { + "40faaf3d", + 0, + }; static u3j_core _143_tri__cofl_d[] = - { { "drg", 7, _143_tri__cofl__drg_a }, - { "lug", 7, _143_tri__cofl__lug_a }, + { { "drg", 7, _143_tri__cofl__drg_a, 0, _143_tri__cofl__drg_ha }, + { "lug", 7, _143_tri__cofl__lug_a, 0, _143_tri__cofl__lug_ha }, {} }; static u3j_harm _143_tri__rd_add_a[] = {{".2", u3wer_add}, {}}; + static c3_c* _143_tri__rd_add_ha[] = { + "7048f323", + 0, + }; static u3j_harm _143_tri__rd_sub_a[] = {{".2", u3wer_sub}, {}}; + static c3_c* _143_tri__rd_sub_ha[] = { + "1ad8be65", + 0, + }; static u3j_harm _143_tri__rd_mul_a[] = {{".2", u3wer_mul}, {}}; + static c3_c* _143_tri__rd_mul_ha[] = { + "3e41a14c", + 0, + }; static u3j_harm _143_tri__rd_div_a[] = {{".2", u3wer_div}, {}}; + static c3_c* _143_tri__rd_div_ha[] = { + "3de7319", + 0, + }; static u3j_harm _143_tri__rd_sqt_a[] = {{".2", u3wer_sqt}, {}}; + static c3_c* _143_tri__rd_sqt_ha[] = { + "18702e43", + 0, + }; static u3j_harm _143_tri__rd_fma_a[] = {{".2", u3wer_fma}, {}}; + static c3_c* _143_tri__rd_fma_ha[] = { + "53a45898", + 0, + }; static u3j_harm _143_tri__rd_lth_a[] = {{".2", u3wer_lth}, {}}; + static c3_c* _143_tri__rd_lth_ha[] = { + "36d33edb", + 0, + }; static u3j_harm _143_tri__rd_lte_a[] = {{".2", u3wer_lte}, {}}; + static c3_c* _143_tri__rd_lte_ha[] = { + "491cde75", + 0, + }; static u3j_harm _143_tri__rd_equ_a[] = {{".2", u3wer_equ}, {}}; + static c3_c* _143_tri__rd_equ_ha[] = { + "78a6abee", + 0, + }; static u3j_harm _143_tri__rd_gte_a[] = {{".2", u3wer_gte}, {}}; + static c3_c* _143_tri__rd_gte_ha[] = { + "126a123a", + 0, + }; static u3j_harm _143_tri__rd_gth_a[] = {{".2", u3wer_gth}, {}}; + static c3_c* _143_tri__rd_gth_ha[] = { + "715df27e", + 0, + }; + + static c3_c* _143_tri__rd_ha[] = { + "4ffd8caa", + 0, + }; static u3j_core _143_tri__rd_d[] = - { { "add", 7, _143_tri__rd_add_a }, - { "sub", 7, _143_tri__rd_sub_a }, - { "mul", 7, _143_tri__rd_mul_a }, - { "div", 7, _143_tri__rd_div_a }, - { "sqt", 7, _143_tri__rd_sqt_a }, - { "fma", 7, _143_tri__rd_fma_a }, - { "lth", 7, _143_tri__rd_lth_a }, - { "lte", 7, _143_tri__rd_lte_a }, - { "equ", 7, _143_tri__rd_equ_a }, - { "gte", 7, _143_tri__rd_gte_a }, - { "gth", 7, _143_tri__rd_gth_a }, + { { "add", 7, _143_tri__rd_add_a, 0, _143_tri__rd_add_ha }, + { "sub", 7, _143_tri__rd_sub_a, 0, _143_tri__rd_sub_ha }, + { "mul", 7, _143_tri__rd_mul_a, 0, _143_tri__rd_mul_ha }, + { "div", 7, _143_tri__rd_div_a, 0, _143_tri__rd_div_ha }, + { "sqt", 7, _143_tri__rd_sqt_a, 0, _143_tri__rd_sqt_ha }, + { "fma", 7, _143_tri__rd_fma_a, 0, _143_tri__rd_fma_ha }, + { "lth", 7, _143_tri__rd_lth_a, 0, _143_tri__rd_lth_ha }, + { "lte", 7, _143_tri__rd_lte_a, 0, _143_tri__rd_lte_ha }, + { "equ", 7, _143_tri__rd_equ_a, 0, _143_tri__rd_equ_ha }, + { "gte", 7, _143_tri__rd_gte_a, 0, _143_tri__rd_gte_ha }, + { "gth", 7, _143_tri__rd_gth_a, 0, _143_tri__rd_gth_ha }, {} }; + static u3j_harm _143_tri__rs_add_a[] = {{".2", u3wet_add}, {}}; + static c3_c* _143_tri__rs_add_ha[] = { + "5caecd3f", + 0, + }; static u3j_harm _143_tri__rs_sub_a[] = {{".2", u3wet_sub}, {}}; + static c3_c* _143_tri__rs_sub_ha[] = { + "173e6bad", + 0, + }; static u3j_harm _143_tri__rs_mul_a[] = {{".2", u3wet_mul}, {}}; + static c3_c* _143_tri__rs_mul_ha[] = { + "415d9955", + 0, + }; static u3j_harm _143_tri__rs_div_a[] = {{".2", u3wet_div}, {}}; + static c3_c* _143_tri__rs_div_ha[] = { + "3329bdd5", + 0, + }; static u3j_harm _143_tri__rs_sqt_a[] = {{".2", u3wet_sqt}, {}}; + static c3_c* _143_tri__rs_sqt_ha[] = { + "49532826", + 0, + }; static u3j_harm _143_tri__rs_fma_a[] = {{".2", u3wet_fma}, {}}; + static c3_c* _143_tri__rs_fma_ha[] = { + "49982fc4", + 0, + }; static u3j_harm _143_tri__rs_lth_a[] = {{".2", u3wet_lth}, {}}; + static c3_c* _143_tri__rs_lth_ha[] = { + "66b83fc2", + 0, + }; static u3j_harm _143_tri__rs_lte_a[] = {{".2", u3wet_lte}, {}}; + static c3_c* _143_tri__rs_lte_ha[] = { + "1b9b2138", + 0, + }; static u3j_harm _143_tri__rs_equ_a[] = {{".2", u3wet_equ}, {}}; + static c3_c* _143_tri__rs_equ_ha[] = { + "7c8d7e92", + 0, + }; static u3j_harm _143_tri__rs_gte_a[] = {{".2", u3wet_gte}, {}}; + static c3_c* _143_tri__rs_gte_ha[] = { + "108efdb2", + 0, + }; static u3j_harm _143_tri__rs_gth_a[] = {{".2", u3wet_gth}, {}}; + static c3_c* _143_tri__rs_gth_ha[] = { + "234b18f2", + 0, + }; + + static c3_c* _143_tri__rs_ha[] = { + "17be2d00", + 0, + }; static u3j_core _143_tri__rs_d[] = - { { "add", 7, _143_tri__rs_add_a }, - { "sub", 7, _143_tri__rs_sub_a }, - { "mul", 7, _143_tri__rs_mul_a }, - { "div", 7, _143_tri__rs_div_a }, - { "sqt", 7, _143_tri__rs_sqt_a }, - { "fma", 7, _143_tri__rs_fma_a }, - { "lth", 7, _143_tri__rs_lth_a }, - { "lte", 7, _143_tri__rs_lte_a }, - { "equ", 7, _143_tri__rs_equ_a }, - { "gte", 7, _143_tri__rs_gte_a }, - { "gth", 7, _143_tri__rs_gth_a }, + { { "add", 7, _143_tri__rs_add_a, 0, _143_tri__rs_add_ha }, + { "sub", 7, _143_tri__rs_sub_a, 0, _143_tri__rs_sub_ha }, + { "mul", 7, _143_tri__rs_mul_a, 0, _143_tri__rs_mul_ha }, + { "div", 7, _143_tri__rs_div_a, 0, _143_tri__rs_div_ha }, + { "sqt", 7, _143_tri__rs_sqt_a, 0, _143_tri__rs_sqt_ha }, + { "fma", 7, _143_tri__rs_fma_a, 0, _143_tri__rs_fma_ha }, + { "lth", 7, _143_tri__rs_lth_a, 0, _143_tri__rs_lth_ha }, + { "lte", 7, _143_tri__rs_lte_a, 0, _143_tri__rs_lte_ha }, + { "equ", 7, _143_tri__rs_equ_a, 0, _143_tri__rs_equ_ha }, + { "gte", 7, _143_tri__rs_gte_a, 0, _143_tri__rs_gte_ha }, + { "gth", 7, _143_tri__rs_gth_a, 0, _143_tri__rs_gth_ha }, {} }; static u3j_harm _143_tri__rq_add_a[] = {{".2", u3weq_add}, {}}; + static c3_c* _143_tri__rq_add_ha[] = { + "4e9ad2ff", + 0, + }; static u3j_harm _143_tri__rq_sub_a[] = {{".2", u3weq_sub}, {}}; + static c3_c* _143_tri__rq_sub_ha[] = { + "790f27d0", + 0, + }; static u3j_harm _143_tri__rq_mul_a[] = {{".2", u3weq_mul}, {}}; + static c3_c* _143_tri__rq_mul_ha[] = { + "2736c015", + 0, + }; static u3j_harm _143_tri__rq_div_a[] = {{".2", u3weq_div}, {}}; + static c3_c* _143_tri__rq_div_ha[] = { + "3e712c94", + 0, + }; static u3j_harm _143_tri__rq_sqt_a[] = {{".2", u3weq_sqt}, {}}; + static c3_c* _143_tri__rq_sqt_ha[] = { + "3ab76743", + 0, + }; static u3j_harm _143_tri__rq_fma_a[] = {{".2", u3weq_fma}, {}}; + static c3_c* _143_tri__rq_fma_ha[] = { + "43a1789d", + 0, + }; static u3j_harm _143_tri__rq_lth_a[] = {{".2", u3weq_lth}, {}}; + static c3_c* _143_tri__rq_lth_ha[] = { + "496728a7", + 0, + }; static u3j_harm _143_tri__rq_lte_a[] = {{".2", u3weq_lte}, {}}; + static c3_c* _143_tri__rq_lte_ha[] = { + "69e67508", + 0, + }; static u3j_harm _143_tri__rq_equ_a[] = {{".2", u3weq_equ}, {}}; + static c3_c* _143_tri__rq_equ_ha[] = { + "10df371e", + 0, + }; static u3j_harm _143_tri__rq_gte_a[] = {{".2", u3weq_gte}, {}}; + static c3_c* _143_tri__rq_gte_ha[] = { + "2d2bc726", + 0, + }; static u3j_harm _143_tri__rq_gth_a[] = {{".2", u3weq_gth}, {}}; + static c3_c* _143_tri__rq_gth_ha[] = { + "409446ea", + 0, + }; + + static c3_c* _143_tri__rq_ha[] = { + "70532c78", + 0, + }; static u3j_core _143_tri__rq_d[] = - { { "add", 7, _143_tri__rq_add_a }, - { "sub", 7, _143_tri__rq_sub_a }, - { "mul", 7, _143_tri__rq_mul_a }, - { "div", 7, _143_tri__rq_div_a }, - { "sqt", 7, _143_tri__rq_sqt_a }, - { "fma", 7, _143_tri__rq_fma_a }, - { "lth", 7, _143_tri__rq_lth_a }, - { "lte", 7, _143_tri__rq_lte_a }, - { "equ", 7, _143_tri__rq_equ_a }, - { "gte", 7, _143_tri__rq_gte_a }, - { "gth", 7, _143_tri__rq_gth_a }, + { { "add", 7, _143_tri__rq_add_a, 0, _143_tri__rq_add_ha }, + { "sub", 7, _143_tri__rq_sub_a, 0, _143_tri__rq_sub_ha }, + { "mul", 7, _143_tri__rq_mul_a, 0, _143_tri__rq_mul_ha }, + { "div", 7, _143_tri__rq_div_a, 0, _143_tri__rq_div_ha }, + { "sqt", 7, _143_tri__rq_sqt_a, 0, _143_tri__rq_sqt_ha }, + { "fma", 7, _143_tri__rq_fma_a, 0, _143_tri__rq_fma_ha }, + { "lth", 7, _143_tri__rq_lth_a, 0, _143_tri__rq_lth_ha }, + { "lte", 7, _143_tri__rq_lte_a, 0, _143_tri__rq_lte_ha }, + { "equ", 7, _143_tri__rq_equ_a, 0, _143_tri__rq_equ_ha }, + { "gte", 7, _143_tri__rq_gte_a, 0, _143_tri__rq_gte_ha }, + { "gth", 7, _143_tri__rq_gth_a, 0, _143_tri__rq_gth_ha }, {} }; static u3j_harm _143_tri__rh_add_a[] = {{".2", u3wes_add}, {}}; + static c3_c* _143_tri__rh_add_ha[] = { + "3ca2bbf6", + 0, + }; static u3j_harm _143_tri__rh_sub_a[] = {{".2", u3wes_sub}, {}}; + static c3_c* _143_tri__rh_sub_ha[] = { + "6873f5b9", + 0, + }; static u3j_harm _143_tri__rh_mul_a[] = {{".2", u3wes_mul}, {}}; + static c3_c* _143_tri__rh_mul_ha[] = { + "26ac0f6c", + 0, + }; static u3j_harm _143_tri__rh_div_a[] = {{".2", u3wes_div}, {}}; + static c3_c* _143_tri__rh_div_ha[] = { + "284818ec", + 0, + }; static u3j_harm _143_tri__rh_sqt_a[] = {{".2", u3wes_sqt}, {}}; + static c3_c* _143_tri__rh_sqt_ha[] = { + "50a508d3", + 0, + }; static u3j_harm _143_tri__rh_fma_a[] = {{".2", u3wes_fma}, {}}; + static c3_c* _143_tri__rh_fma_ha[] = { + "6ee2c6f8", + 0, + }; static u3j_harm _143_tri__rh_lth_a[] = {{".2", u3wes_lth}, {}}; + static c3_c* _143_tri__rh_lth_ha[] = { + "95c5f8a", + 0, + }; static u3j_harm _143_tri__rh_lte_a[] = {{".2", u3wes_lte}, {}}; + static c3_c* _143_tri__rh_lte_ha[] = { + "5671246d", + 0, + }; static u3j_harm _143_tri__rh_equ_a[] = {{".2", u3wes_equ}, {}}; + static c3_c* _143_tri__rh_equ_ha[] = { + "55ba38f6", + 0, + }; static u3j_harm _143_tri__rh_gte_a[] = {{".2", u3wes_gte}, {}}; + static c3_c* _143_tri__rh_gte_ha[] = { + "7ca6938e", + 0, + }; static u3j_harm _143_tri__rh_gth_a[] = {{".2", u3wes_gth}, {}}; + static c3_c* _143_tri__rh_gth_ha[] = { + "5df9d6aa", + 0, + }; + + static c3_c* _143_tri__rh_ha[] = { + "240f9e45", + 0, + }; static u3j_core _143_tri__rh_d[] = - { { "add", 7, _143_tri__rh_add_a }, - { "sub", 7, _143_tri__rh_sub_a }, - { "mul", 7, _143_tri__rh_mul_a }, - { "div", 7, _143_tri__rh_div_a }, - { "sqt", 7, _143_tri__rh_sqt_a }, - { "fma", 7, _143_tri__rh_fma_a }, - { "lth", 7, _143_tri__rh_lth_a }, - { "lte", 7, _143_tri__rh_lte_a }, - { "equ", 7, _143_tri__rh_equ_a }, - { "gte", 7, _143_tri__rh_gte_a }, - { "gth", 7, _143_tri__rh_gth_a }, + { { "add", 7, _143_tri__rh_add_a, 0, _143_tri__rh_add_ha }, + { "sub", 7, _143_tri__rh_sub_a, 0, _143_tri__rh_sub_ha }, + { "mul", 7, _143_tri__rh_mul_a, 0, _143_tri__rh_mul_ha }, + { "div", 7, _143_tri__rh_div_a, 0, _143_tri__rh_div_ha }, + { "sqt", 7, _143_tri__rh_sqt_a, 0, _143_tri__rh_sqt_ha }, + { "fma", 7, _143_tri__rh_fma_a, 0, _143_tri__rh_fma_ha }, + { "lth", 7, _143_tri__rh_lth_a, 0, _143_tri__rh_lth_ha }, + { "lte", 7, _143_tri__rh_lte_a, 0, _143_tri__rh_lte_ha }, + { "equ", 7, _143_tri__rh_equ_a, 0, _143_tri__rh_equ_ha }, + { "gte", 7, _143_tri__rh_gte_a, 0, _143_tri__rh_gte_ha }, + { "gth", 7, _143_tri__rh_gth_a, 0, _143_tri__rh_gth_ha }, {} }; @@ -705,13 +915,14 @@ static c3_c* _143_tri_ha[] = { 0, }; static u3j_core _143_tri_d[] = - { { "qua", 3, 0, _143_qua_d, _143_qua_ha, _143_qua_ho }, - { "cofl", 7, 0, _143_tri__cofl_d }, - { "rd", 7, 0, _143_tri__rd_d }, - { "rs", 7, 0, _143_tri__rs_d }, - { "rq", 7, 0, _143_tri__rq_d }, - { "rh", 7, 0, _143_tri__rh_d }, - { "og", 7, 0, _143_tri__og_d, _143_tri__og_ha }, + { { "qua", 3, 0, _143_qua_d, _143_qua_ha, _143_qua_ho }, + { "cofl", 7, 0, _143_tri__cofl_d, _143_tri__cofl_ha }, + { "rd", 7, 0, _143_tri__rd_d, _143_tri__rd_ha }, + { "rs", 7, 0, _143_tri__rs_d, _143_tri__rs_ha }, + { "rq", 7, 0, _143_tri__rq_d, _143_tri__rq_ha }, + { "rh", 7, 0, _143_tri__rh_d, _143_tri__rh_ha }, + { "og", 7, 0, _143_tri__og_d, _143_tri__og_ha }, + { "shax", 7, _143_tri_shax_a, 0, _143_tri_shax_ha }, { "shay", 7, _143_tri_shay_a, 0, _143_tri_shay_ha }, // { "shas", 7, _143_tri_shas_a, 0, _143_tri_shas_ha }, From 678baf41bbc110b99cf64e33f6f542c397259e14 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 14 May 2018 15:13:37 -0700 Subject: [PATCH 112/221] layer five --- jets/tree.c | 161 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 129 insertions(+), 32 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 8e20756f0..807368dfc 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -111,22 +111,50 @@ static u3j_core _143_hex_d[] = 0, }; static u3j_harm _143_pen_comb_a[] = {{".2", u3wf_comb}, {}}; + static c3_c* _143_pen_comb_ha[] = { + "1fe51547", + 0, + }; static u3j_harm _143_pen_cons_a[] = {{".2", u3wf_cons}, {}}; + static c3_c* _143_pen_cons_ha[] = { + "2e91771e", + 0, + }; static u3j_harm _143_pen_core_a[] = {{".2", u3wf_core}, {}}; static c3_c* _143_pen_core_ha[] = { "5c37f17b", 0, }; static u3j_harm _143_pen_help_a[] = {{".2", u3wf_help}, {}}; + static c3_c* _143_pen_help_ha[] = { + "3df833f", + 0, + }; static u3j_harm _143_pen_face_a[] = {{".2", u3wf_face}, {}}; static c3_c* _143_pen_face_ha[] = { "742c24f0", 0, }; static u3j_harm _143_pen_fitz_a[] = {{".2", u3wf_fitz}, {}}; + static c3_c* _143_pen_fitz_ha[] = { + "464c37aa", + 0, + }; static u3j_harm _143_pen_flan_a[] = {{".2", u3wf_flan}, {}}; + static c3_c* _143_pen_flan_ha[] = { + "19b65692", + 0, + }; static u3j_harm _143_pen_flip_a[] = {{".2", u3wf_flip}, {}}; + static c3_c* _143_pen_flip_ha[] = { + "2da932", + 0, + }; static u3j_harm _143_pen_flor_a[] = {{".2", u3wf_flor}, {}}; + static c3_c* _143_pen_flor_ha[] = { + "53d48f74", + 0, + }; static u3j_harm _143_pen_fork_a[] = {{".2", u3wf_fork}, {}}; static c3_c* _143_pen_fork_ha[] = { "6c3239f5", @@ -139,11 +167,23 @@ static u3j_core _143_hex_d[] = 0, }; static u3j_harm _143_pen_look_a[] = {{".2", u3wf_look}, {}}; + static c3_c* _143_pen_look_ha[] = { + "1a7dc705", + 0, + }; static u3j_harm _143_pen_loot_a[] = {{".2", u3wf_loot}, {}}; + static c3_c* _143_pen_loot_ha[] = { + "13234213", + 0, + }; - static u3j_harm _143_pen__ut_burn_a[] = {{".2", u3wfu_burn}, {}}; - static u3j_harm _143_pen__ut_conk_a[] = {{".2", u3wfu_conk}, {}}; + //static u3j_harm _143_pen__ut_burn_a[] = {{".2", u3wfu_burn}, {}}; + //static u3j_harm _143_pen__ut_conk_a[] = {{".2", u3wfu_conk}, {}}; static u3j_harm _143_pen__ut_crop_a[] = {{".2", u3wfu_crop}, {}}; + static c3_c* _143_pen__ut_crop_ha[] = { + "1b098a6e", + 0, + }; // static u3j_harm _143_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; static u3j_harm _143_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}}; static c3_c* _143_pen__ut_fond_ha[] = { @@ -151,13 +191,25 @@ static u3j_core _143_hex_d[] = 0, }; static u3j_harm _143_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; + static c3_c* _143_pen__ut_fish_ha[] = { + "4027d168", + 0, + }; static u3j_harm _143_pen__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}}; + static c3_c* _143_pen__ut_fuse_ha[] = { + "6f74b82e", + 0, + }; static u3j_harm _143_pen__ut_mint_a[] = {{".2", u3wfu_mint}, {}}; static c3_c* _143_pen__ut_mint_ha[] = { "48723fb5", 0, }; static u3j_harm _143_pen__ut_mull_a[] = {{".2", u3wfu_mull}, {}}; + static c3_c* _143_pen__ut_mull_ha[] = { + "1d7c97bc", + 0, + }; static u3j_harm _143_pen__ut_nest_a[] = {{".2", u3wfu_nest}, {}}; static c3_c* _143_pen__ut_nest_ha[] = { "4512a8f4", @@ -174,12 +226,20 @@ static u3j_core _143_hex_d[] = 0, }; static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; + static c3_c* _143_pen__ut_rest_ha[] = { + "6e47044e", + 0, + }; static u3j_harm _143_pen__ut_toss_a[] = {{".2", u3wfu_toss}, {}}; static c3_c* _143_pen__ut_toss_ha[] = { "54362dd", 0, }; static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; + static c3_c* _143_pen__ut_wrap_ha[] = { + "f15623c", + 0, + }; static c3_c* _143_pen__ut_ha[] = { "c2cda56", @@ -228,21 +288,21 @@ static u3j_core _143_hex_d[] = }; static u3j_core _143_pen__ut_d[] = { - { "burn", 7, _143_pen__ut_burn_a }, - { "conk", 7, _143_pen__ut_conk_a }, - { "crop", 7, _143_pen__ut_crop_a }, + // { "burn", 7, _143_pen__ut_burn_a }, + // { "conk", 7, _143_pen__ut_conk_a }, + { "crop", 7, _143_pen__ut_crop_a, 0, _143_pen__ut_crop_ha }, { "fond", 7, _143_pen__ut_fond_a, 0, _143_pen__ut_fond_ha }, // { "fire", 7, _143_pen__ut_fire_a }, - { "fish", 7, _143_pen__ut_fish_a }, - { "fuse", 7, _143_pen__ut_fuse_a }, + { "fish", 7, _143_pen__ut_fish_a, 0, _143_pen__ut_fish_ha }, + { "fuse", 7, _143_pen__ut_fuse_a, 0, _143_pen__ut_fuse_ha }, { "mint", 7, _143_pen__ut_mint_a, 0, _143_pen__ut_mint_ha }, - { "mull", 7, _143_pen__ut_mull_a }, + { "mull", 7, _143_pen__ut_mull_a, 0, _143_pen__ut_mull_ha }, { "nest", 7, _143_pen__ut_nest_a, 0, _143_pen__ut_nest_ha }, { "peek", 7, _143_pen__ut_peek_a, 0, _143_pen__ut_peek_ha }, { "play", 7, _143_pen__ut_play_a, 0, _143_pen__ut_play_ha }, - { "rest", 7, _143_pen__ut_rest_a }, + { "rest", 7, _143_pen__ut_rest_a, 0, _143_pen__ut_rest_ha }, { "toss", 7, _143_pen__ut_toss_a, 0, _143_pen__ut_toss_ha }, - { "wrap", 7, _143_pen__ut_wrap_a }, + { "wrap", 7, _143_pen__ut_wrap_a, 0, _143_pen__ut_wrap_ha }, {} }; static u3j_harm _143_pen__ut_a[] = @@ -279,19 +339,19 @@ static u3j_core _143_pen_d[] = { { "hex", 3, 0, _143_hex_d, _143_hex_ha }, { "cell", 7, _143_pen_cell_a, 0, _143_pen_cell_ha }, - { "comb", 7, _143_pen_comb_a }, - { "cons", 7, _143_pen_cons_a }, + { "comb", 7, _143_pen_comb_a, 0, _143_pen_comb_ha }, + { "cons", 7, _143_pen_cons_a, 0, _143_pen_cons_ha }, { "core", 7, _143_pen_core_a, 0, _143_pen_core_ha }, { "face", 7, _143_pen_face_a, 0, _143_pen_face_ha }, - { "fitz", 7, _143_pen_fitz_a }, - { "flan", 7, _143_pen_flan_a }, - { "flip", 7, _143_pen_flip_a }, - { "flor", 7, _143_pen_flor_a }, + { "fitz", 7, _143_pen_fitz_a, 0, _143_pen_fitz_ha }, + { "flan", 7, _143_pen_flan_a, 0, _143_pen_flan_ha }, + { "flip", 7, _143_pen_flip_a, 0, _143_pen_flip_ha }, + { "flor", 7, _143_pen_flor_a, 0, _143_pen_flor_ha }, { "fork", 7, _143_pen_fork_a, 0, _143_pen_fork_ha }, - { "help", 7, _143_pen_help_a }, + { "help", 7, _143_pen_help_a, 0, _143_pen_help_ha }, { "hike", 7, _143_pen_hike_a, 0, _143_pen_hike_ha }, - { "look", 7, _143_pen_look_a }, - { "loot", 7, _143_pen_loot_a }, + { "look", 7, _143_pen_look_a, 0, _143_pen_look_ha }, + { "loot", 7, _143_pen_loot_a, 0, _143_pen_loot_ha }, // { "ap", _143_pen__ap_a }, // { "al", _143_pen__al_a }, @@ -308,14 +368,35 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__po_ind_a[] = {{".2", u3wcp_ind}, {}}; + static c3_c* _143_qua__po_ind_ha[] = { + "45bf22f6", + 0, + }; static u3j_harm _143_qua__po_ins_a[] = {{".2", u3wcp_ins}, {}}; + static c3_c* _143_qua__po_ins_ha[] = { + "2c82c596", + 0, + }; static u3j_harm _143_qua__po_tod_a[] = {{".2", u3wcp_tod}, {}}; + static c3_c* _143_qua__po_tod_ha[] = { + "692b7953", + 0, + }; static u3j_harm _143_qua__po_tos_a[] = {{".2", u3wcp_tos}, {}}; + static c3_c* _143_qua__po_tos_ha[] = { + "473d8e66", + 0, + }; + + static c3_c* _143_qua__po_ha[] = { + "19535663", + 0, + }; static u3j_core _143_qua__po_d[] = - { { "ind", 7, _143_qua__po_ind_a }, - { "ins", 7, _143_qua__po_ins_a }, - { "tod", 7, _143_qua__po_tod_a }, - { "tos", 7, _143_qua__po_tos_a }, + { { "ind", 7, _143_qua__po_ind_a, 0, _143_qua__po_ind_ha }, + { "ins", 7, _143_qua__po_ins_a, 0, _143_qua__po_ins_ha }, + { "tod", 7, _143_qua__po_tod_a, 0, _143_qua__po_tod_ha }, + { "tos", 7, _143_qua__po_tos_a, 0, _143_qua__po_tos_ha }, {} }; @@ -390,8 +471,16 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__glue_fun_a[] = {{".2", u3we_glue_fun}, {}}; + static c3_c* _143_qua__glue_ha[] = { + "7bf23949", + 0, + }; + static c3_c* _143_qua__glue_fun_ha[] = { + "7d709001", + 0, + }; static u3j_core _143_qua__glue_d[] = - { { "fun", 7, _143_qua__glue_fun_a }, + { { "fun", 7, _143_qua__glue_fun_a, 0, _143_qua__glue_fun_ha }, {} }; @@ -493,7 +582,7 @@ static u3j_core _143_pen_d[] = {} }; - static u3j_harm _143_qua_pfix_a[] = {{".2", u3we_pfix}, {}}; + // static u3j_harm _143_qua_pfix_a[] = {{".2", u3we_pfix}, {}}; static u3j_harm _143_qua_plug_a[] = {{".2", u3we_plug}, {}}; static c3_c* _143_qua__plug_ha[] = { "11b6a2f8", @@ -504,10 +593,18 @@ static u3j_core _143_pen_d[] = "6fb235ed", 0, }; - static u3j_harm _143_qua_sfix_a[] = {{".2", u3we_sfix}, {}}; + //static u3j_harm _143_qua_sfix_a[] = {{".2", u3we_sfix}, {}}; static u3j_harm _143_qua_mink_a[] = {{".2", u3we_mink}, {}}; + static c3_c* _143_qua_mink_ha[] = { + "43ee7fca", + 0, + }; static u3j_harm _143_qua_mule_a[] = {{".2", u3we_mule}, {}}; + static c3_c* _143_qua_mule_ha[] = { + "49cb9b2d", + 0, + }; static c3_c* _143_qua_ha[] = { "7f2af46e", @@ -521,7 +618,7 @@ static u3j_hood _143_qua_ho[] = { static u3j_core _143_qua_d[] = { { "pen", 3, 0, _143_pen_d, _143_pen_ha, _143_pen_ho }, - { "po", 7, 0, _143_qua__po_d }, + { "po", 7, 0, _143_qua__po_d, _143_qua__po_ha }, { "trip", 7, _143_qua_trip_a, 0, _143_qua_trip_ha }, @@ -530,7 +627,7 @@ static u3j_core _143_qua_d[] = { "comp", 7, 0, _143_qua__comp_d, _143_qua__comp_ha }, { "cook", 7, 0, _143_qua__cook_d, _143_qua__cook_ha }, { "easy", 7, 0, _143_qua__easy_d, _143_qua__easy_ha }, - { "glue", 7, 0, _143_qua__glue_d }, + { "glue", 7, 0, _143_qua__glue_d, _143_qua__glue_ha }, { "here", 7, 0, _143_qua__here_d, _143_qua__here_ha }, { "just", 7, 0, _143_qua__just_d, _143_qua__just_ha }, { "mask", 7, 0, _143_qua__mask_d, _143_qua__mask_ha }, @@ -539,13 +636,13 @@ static u3j_core _143_qua_d[] = { "stew", 7, 0, _143_qua__stew_d, _143_qua__stew_ha }, { "stir", 7, 0, _143_qua__stir_d, _143_qua__stir_ha }, - { "pfix", 7, _143_qua_pfix_a }, + // { "pfix", 7, _143_qua_pfix_a }, { "plug", 7, _143_qua_plug_a, 0, _143_qua__plug_ha }, { "pose", 7, _143_qua_pose_a, 0, _143_qua__pose_ha }, - { "sfix", 7, _143_qua_sfix_a }, + // { "sfix", 7, _143_qua_sfix_a }, - { "mink", 7, _143_qua_mink_a }, - { "mule", 7, _143_qua_mule_a }, + { "mink", 7, _143_qua_mink_a, 0, _143_qua_mink_ha }, + { "mule", 7, _143_qua_mule_a, 0, _143_qua_mule_ha }, {} }; From 7e945b8449525815812b0e394d360fa606eae333 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 14 May 2018 16:53:32 -0700 Subject: [PATCH 113/221] all jets? --- jets/tree.c | 184 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 154 insertions(+), 30 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 807368dfc..78c0b80a4 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -3,89 +3,211 @@ #include "all.h" static u3j_harm _143_hex_aes_ecba_en_a[] = {{".2", u3wea_ecba_en}, {}}; + static c3_c* _143_hex_aes_ecba_en_ha[] = { + "7622dfdb", + 0, + }; static u3j_harm _143_hex_aes_ecba_de_a[] = {{".2", u3wea_ecba_de}, {}}; + static c3_c* _143_hex_aes_ecba_de_ha[] = { + "35592db7", + 0, + }; static u3j_harm _143_hex_aes_ecbb_en_a[] = {{".2", u3wea_ecbb_en}, {}}; + static c3_c* _143_hex_aes_ecbb_en_ha[] = { + "2f1dbee2", + 0, + }; static u3j_harm _143_hex_aes_ecbb_de_a[] = {{".2", u3wea_ecbb_de}, {}}; + static c3_c* _143_hex_aes_ecbb_de_ha[] = { + "5211dc92", + 0, + }; static u3j_harm _143_hex_aes_ecbc_en_a[] = {{".2", u3wea_ecbc_en}, {}}; + static c3_c* _143_hex_aes_ecbc_en_ha[] = { + "70caa183", + 0, + }; static u3j_harm _143_hex_aes_ecbc_de_a[] = {{".2", u3wea_ecbc_de}, {}}; + static c3_c* _143_hex_aes_ecbc_de_ha[] = { + "3433e46b", + 0, + }; static u3j_harm _143_hex_aes_cbca_en_a[] = {{".2", u3wea_cbca_en}, {}}; + static c3_c* _143_hex_aes_cbca_en_ha[] = { + "69ac3685", + 0, + }; static u3j_harm _143_hex_aes_cbca_de_a[] = {{".2", u3wea_cbca_de}, {}}; + static c3_c* _143_hex_aes_cbca_de_ha[] = { + "2057b875", + 0, + }; static u3j_harm _143_hex_aes_cbcb_en_a[] = {{".2", u3wea_cbcb_en}, {}}; + static c3_c* _143_hex_aes_cbcb_en_ha[] = { + "1f286963", + 0, + }; static u3j_harm _143_hex_aes_cbcb_de_a[] = {{".2", u3wea_cbcb_de}, {}}; + static c3_c* _143_hex_aes_cbcb_de_ha[] = { + "654074e5", + 0, + }; static u3j_harm _143_hex_aes_cbcc_en_a[] = {{".2", u3wea_cbcc_en}, {}}; + static c3_c* _143_hex_aes_cbcc_en_ha[] = { + "503ec5ac", + 0, + }; static u3j_harm _143_hex_aes_cbcc_de_a[] = {{".2", u3wea_cbcc_de}, {}}; + static c3_c* _143_hex_aes_cbcc_de_ha[] = { + "f67b27f", + 0, + }; + static c3_c* _143_hex_aes_ecba_ha[] = { + "30bd6d60", + 0, + }; static u3j_core _143_hex_aes_ecba_d[] = - { { "en", 7, _143_hex_aes_ecba_en_a }, - { "de", 7, _143_hex_aes_ecba_de_a }, + { { "en", 7, _143_hex_aes_ecba_en_a, 0, _143_hex_aes_ecba_en_ha }, + { "de", 7, _143_hex_aes_ecba_de_a, 0, _143_hex_aes_ecba_de_ha }, {} }; + static c3_c* _143_hex_aes_ecbb_ha[] = { + "121ef659", + 0, + }; static u3j_core _143_hex_aes_ecbb_d[] = - { { "en", 7, _143_hex_aes_ecbb_en_a }, - { "de", 7, _143_hex_aes_ecbb_de_a }, + { { "en", 7, _143_hex_aes_ecbb_en_a, 0, _143_hex_aes_ecbb_en_ha }, + { "de", 7, _143_hex_aes_ecbb_de_a, 0, _143_hex_aes_ecbb_de_ha }, {} }; + static c3_c* _143_hex_aes_ecbc_ha[] = { + "572e5931", + 0, + }; static u3j_core _143_hex_aes_ecbc_d[] = - { { "en", 7, _143_hex_aes_ecbc_en_a }, - { "de", 7, _143_hex_aes_ecbc_de_a }, + { { "en", 7, _143_hex_aes_ecbc_en_a, 0, _143_hex_aes_ecbc_en_ha }, + { "de", 7, _143_hex_aes_ecbc_de_a, 0, _143_hex_aes_ecbc_de_ha }, {} }; + static c3_c* _143_hex_aes_cbca_ha[] = { + "12d2f4d8", + 0, + }; static u3j_core _143_hex_aes_cbca_d[] = - { { "en", 7, _143_hex_aes_cbca_en_a }, - { "de", 7, _143_hex_aes_cbca_de_a }, + { { "en", 7, _143_hex_aes_cbca_en_a, 0, _143_hex_aes_cbca_en_ha }, + { "de", 7, _143_hex_aes_cbca_de_a, 0, _143_hex_aes_cbca_de_ha }, {} }; + static c3_c* _143_hex_aes_cbcb_ha[] = { + "30361963", + 0, + }; static u3j_core _143_hex_aes_cbcb_d[] = - { { "en", 7, _143_hex_aes_cbcb_en_a }, - { "de", 7, _143_hex_aes_cbcb_de_a }, + { { "en", 7, _143_hex_aes_cbcb_en_a, 0, _143_hex_aes_cbcb_en_ha }, + { "de", 7, _143_hex_aes_cbcb_de_a, 0, _143_hex_aes_cbcb_de_ha }, {} }; + static c3_c* _143_hex_aes_cbcc_ha[] = { + "3e4cfab8", + 0, + }; static u3j_core _143_hex_aes_cbcc_d[] = - { { "en", 7, _143_hex_aes_cbcc_en_a }, - { "de", 7, _143_hex_aes_cbcc_de_a }, + { { "en", 7, _143_hex_aes_cbcc_en_a, 0, _143_hex_aes_cbcc_en_ha }, + { "de", 7, _143_hex_aes_cbcc_de_a, 0, _143_hex_aes_cbcc_de_ha }, {} }; + static c3_c* _143_hex_aes_ha[] = { + "385d228e", + 0, + }; static u3j_core _143_hex_aes_d[] = - { { "ecba", 7, 0, _143_hex_aes_ecba_d }, - { "ecbb", 7, 0, _143_hex_aes_ecbb_d }, - { "ecbc", 7, 0, _143_hex_aes_ecbc_d }, - { "cbca", 7, 0, _143_hex_aes_cbca_d }, - { "cbcb", 7, 0, _143_hex_aes_cbcb_d }, - { "cbcc", 7, 0, _143_hex_aes_cbcc_d }, + { { "ecba", 7, 0, _143_hex_aes_ecba_d, _143_hex_aes_ecba_ha }, + { "ecbb", 7, 0, _143_hex_aes_ecbb_d, _143_hex_aes_ecbb_ha }, + { "ecbc", 7, 0, _143_hex_aes_ecbc_d, _143_hex_aes_ecbc_ha }, + { "cbca", 7, 0, _143_hex_aes_cbca_d, _143_hex_aes_cbca_ha }, + { "cbcb", 7, 0, _143_hex_aes_cbcb_d, _143_hex_aes_cbcb_ha }, + { "cbcc", 7, 0, _143_hex_aes_cbcc_d, _143_hex_aes_cbcc_ha }, {} }; static u3j_harm _143_hex_down_mark_a[] = {{".2", u3wg_down, c3y}, {}}; + static c3_c* _143_hex_down_mark_ha[] = { + "2a57366e", + 0, + }; + + static c3_c* _143_hex_down_ha[] = { + "7b4e149a", + 0, + }; static u3j_core _143_hex_down_d[] = - { { "mark", 7, _143_hex_down_mark_a }, + { { "mark", 7, _143_hex_down_mark_a, 0, _143_hex_down_mark_ha }, {} }; static u3j_harm _143_hex_lore_a[] = {{".2", u3we_lore}, {}}; + static c3_c* _143_hex_lore_ha[] = { + "71d2c115", + 0, + }; static u3j_harm _143_hex_loss_a[] = {{".2", u3we_loss}, {}}; + static c3_c* _143_hex_loss_ha[] = { + "1fc16691", + 0, + }; static u3j_harm _143_hex_lune_a[] = {{".2", u3we_lune}, {}}; + static c3_c* _143_hex_lune_ha[] = { + "12455182", + 0, + }; static u3j_harm _143_hex_coed__ed_puck_a[] = {{".2", u3wee_puck}, {}}; + static c3_c* _143_hex_coed__ed_puck_ha[] = { + "2ed1b9e8", + 0, + }; static u3j_harm _143_hex_coed__ed_sign_a[] = {{".2", u3wee_sign}, {}}; + static c3_c* _143_hex_coed__ed_sign_ha[] = { + "d0277fd", + 0, + }; static u3j_harm _143_hex_coed__ed_veri_a[] = {{".2", u3wee_veri}, {}}; + static c3_c* _143_hex_coed__ed_veri_ha[] = { + "5c991b1", + 0, + }; static u3j_harm _143_hex_coed__ed_shar_a[] = {{".2", u3wee_shar}, {}}; + static c3_c* _143_hex_coed__ed_shar_ha[] = { + "78a7b7cc", + 0, + }; + static c3_c* _143_hex_coed__ed_ha[] = { + "46800d16", + 0, + }; static u3j_core _143_hex_coed__ed_d[] = - { { "sign", 7, _143_hex_coed__ed_sign_a }, - { "puck", 7, _143_hex_coed__ed_puck_a }, - { "veri", 7, _143_hex_coed__ed_veri_a }, - { "shar", 7, _143_hex_coed__ed_shar_a }, + { { "sign", 7, _143_hex_coed__ed_sign_a, 0, _143_hex_coed__ed_sign_ha }, + { "puck", 7, _143_hex_coed__ed_puck_a, 0, _143_hex_coed__ed_puck_ha }, + { "veri", 7, _143_hex_coed__ed_veri_a, 0, _143_hex_coed__ed_veri_ha }, + { "shar", 7, _143_hex_coed__ed_shar_a, 0, _143_hex_coed__ed_shar_ha }, {} }; + +static c3_c* _143_hex_coed_ha[] = { + "7f0356e", + 0, +}; static u3j_core _143_hex_coed_d[] = - { { "ed", 3, 0, _143_hex_coed__ed_d }, + { { "ed", 3, 0, _143_hex_coed__ed_d, _143_hex_coed__ed_ha }, {} }; @@ -94,12 +216,14 @@ static c3_c* _143_hex_ha[] = { 0, }; static u3j_core _143_hex_d[] = - { { "down", 31337, 0, _143_hex_down_d }, - { "lore", 7, _143_hex_lore_a }, - { "loss", 7, _143_hex_loss_a }, - { "lune", 7, _143_hex_lune_a }, - { "coed", 31337, 0, _143_hex_coed_d }, - { "aes", 31337, 0, _143_hex_aes_d }, + { { "down", 8063, 0, _143_hex_down_d, _143_hex_down_ha }, + + { "lore", 63, _143_hex_lore_a, 0, _143_hex_lore_ha }, + { "loss", 63, _143_hex_loss_a, 0, _143_hex_loss_ha }, + { "lune", 127, _143_hex_lune_a, 0, _143_hex_lune_ha }, + + { "coed", 63, 0, _143_hex_coed_d, _143_hex_coed_ha }, + { "aes", 31, 0, _143_hex_aes_d, _143_hex_aes_ha }, {} }; From b9bf443b17f697b71a37462b51d7a04634be12d6 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 15 May 2018 21:59:00 -0700 Subject: [PATCH 114/221] fix leaks in _cj_install, mark hot_p --- noun/jets.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 9afff64d0..a59f29544 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -272,15 +272,15 @@ _cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev toh = u3nq(reg, jax_l, hap, u3k(bal)); u3h_put(u3D.hot_p, key, toh); - u3z(key); + u3z(key); u3z(hot); } } jax_l = _cj_install(ray_u, ++jax_l, loc, bal, kid_u->dev_u); } - u3z(pel); - u3z(lab); } + u3z(pel); + u3z(lab); return jax_l; } @@ -1981,6 +1981,9 @@ u3j_site_lose(u3j_site* sit_u) if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); } + if ( u3_none != sit_u->bas ) { + u3z(sit_u->bas); + } if ( u3_none != sit_u->loc ) { u3z(sit_u->loc); u3z(sit_u->lab); @@ -2023,6 +2026,9 @@ u3j_site_mark(u3j_site* sit_u) if ( u3_none != sit_u->bat ) { tot_w += u3a_mark_noun(sit_u->bat); } + if ( u3_none != sit_u->bas ) { + tot_w += u3a_mark_noun(sit_u->bas); + } if ( u3_none != sit_u->loc ) { tot_w += u3a_mark_noun(sit_u->loc); tot_w += u3a_mark_noun(sit_u->lab); @@ -2057,6 +2063,9 @@ u3j_mark(void) tot_w += u3h_mark(u3R->jed.cod_p); tot_w += u3h_mark(u3R->jed.han_p); u3h_walk_with(u3R->jed.han_p, _cj_mark_hank, &tot_w); + if ( u3R == &(u3H->rod_u) ) { + tot_w += u3h_mark(u3D.hot_p); + } return tot_w; } @@ -2082,5 +2091,8 @@ u3j_free(void) u3h_free(u3R->jed.war_p); u3h_free(u3R->jed.cod_p); u3h_free(u3R->jed.han_p); + if ( u3R == &(u3H->rod_u) ) { + u3h_free(u3D.hot_p); + } } From 8417f4b7c53706d7a3d5bbaaa41d61623ecd2986 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 16 May 2018 09:41:49 -0700 Subject: [PATCH 115/221] ownership audit --- noun/jets.c | 68 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index a59f29544..abfca798c 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -37,7 +37,7 @@ _cj_count(u3j_core* par_u, u3j_core* dev_u) return 1 + len_l; } -/* _cj_core_loc(): location noun from u3j_core. pel is TRANSFERRED. +/* _cj_core_loc(): location noun from u3j_core. */ static u3_noun _cj_core_loc(u3_noun pel, u3j_core* cop_u) @@ -77,7 +77,7 @@ _cj_hash(c3_c* has_c) return mug; } -/* _cj_bash(): battery hash. +/* _cj_bash(): battery hash. RETAIN. */ static u3_noun _cj_bash(u3_noun bat) @@ -86,55 +86,66 @@ _cj_bash(u3_noun bat) } /* _cj_mine_par_old(): register hooks and parent location within existing - * axis in ancestor list or u3_none. RETAIN. + * axis in ancestor list or u3_none. */ static u3_weak _cj_mine_par_old(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) { u3_noun par; + u3_weak pro; + if ( u3_nul == lan ) { - return u3_none; + pro = u3_none; + u3z(axe); u3z(pel); u3z(loc); } else if ( c3y == u3r_sing(axe, u3h(par = u3h(lan))) ) { - u3_noun lol = u3qdb_put(u3t(par), pel, loc), - rap = u3nc(u3k(axe), lol); - return u3nc(rap, u3k(u3t(lan))); + u3_noun lol = u3kdb_put(u3k(u3t(par)), pel, loc), + rap = u3nc(axe, lol); + pro = u3nc(rap, u3k(u3t(lan))); } else { - u3_weak nex = _cj_mine_par_old(u3t(lan), axe, pel, loc); + u3_weak nex = _cj_mine_par_old(u3k(u3t(lan)), axe, pel, loc); if ( u3_none == nex ) { - return u3_none; + pro = u3_none; } else { - return u3nc(u3k(par), nex); + pro = u3nc(u3k(par), nex); } } + + u3z(lan); + return pro; } -/* _cj_mine_par_new(): insert ancestor within lan at sorted index. RETAIN. +/* _cj_mine_par_new(): insert ancestor within lan at sorted index. */ static u3_noun _cj_mine_par_new(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) { - u3_noun par; + u3_weak pro; + if ( (u3_nul == lan) || (c3y == u3qa_lth(axe, u3h(u3h(lan)))) ) { - par = u3nc(u3k(axe), u3qdb_put(u3_nul, pel, loc)); - return u3nc(par, u3k(lan)); + u3_noun par = u3nc(axe, u3kdb_put(u3_nul, pel, loc)); + pro = u3nc(par, lan); } else { - return u3nc(u3k(u3h(lan)), - _cj_mine_par_new(u3t(lan), axe, pel, loc)); + pro = u3nc(u3k(u3h(lan)), + _cj_mine_par_new(u3k(u3t(lan)), axe, pel, loc)); + u3z(lan); } + + return pro; } -/* _cj_mine_par(): register a location as an ancestor in a list of ancestors. - * RETAIN. +/* _cj_mine_par(): register a location as an ancestor + * in a list of ancestors. */ static u3_noun _cj_mine_par(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) { - u3_weak old = _cj_mine_par_old(lan, axe, pel, loc); + u3_weak old = _cj_mine_par_old(u3k(lan), u3k(axe), u3k(pel), u3k(loc)); if ( u3_none != old ) { + u3z(lan); u3z(axe); u3z(pel); u3z(loc); return old; } else { @@ -143,7 +154,8 @@ _cj_mine_par(u3_noun lan, u3_noun axe, u3_noun pel, u3_noun loc) } -/* _cj_gust(): add location to registry. TRANSFER. */ +/* _cj_gust(): add location to registry. +*/ static u3_noun _cj_gust(u3_weak reg, u3_noun axe, u3_noun pel, u3_noun loc) { @@ -153,13 +165,10 @@ _cj_gust(u3_weak reg, u3_noun axe, u3_noun pel, u3_noun loc) } ger = ( 0 == axe ) - ? u3nc(u3qdb_put(u3h(reg), pel, loc), u3k(u3t(reg))) - : u3nc(u3k(u3h(reg)), _cj_mine_par(u3t(reg), axe, pel, loc)); + ? u3nc(u3kdb_put(u3k(u3h(reg)), pel, loc), u3k(u3t(reg))) + : u3nc(u3k(u3h(reg)), _cj_mine_par(u3k(u3t(reg)), axe, pel, loc)); u3z(reg); - u3z(pel); - u3z(loc); - u3z(axe); return ger; } @@ -243,7 +252,6 @@ _cj_warm_hump(c3_l jax_l, u3_noun huc) return hap; } - /* _cj_install(): install dashboard entries. */ static c3_w @@ -439,7 +447,7 @@ _cj_find_warm(u3_noun loc) static u3_weak _cj_spot(u3_noun cor, u3_weak bas); -/* _cj_reg_find(): locate core within registry. +/* _cj_reg_find(): locate core within registry. RETAIN. */ static u3_weak _cj_reg_find(u3_noun reg, u3_noun cor) @@ -516,7 +524,7 @@ _cj_spot_cold(u3_noun cor, u3_noun* reg) /* _cj_spot_hot(): try to locate core by hot dashboard. if found, * the activation (warm state) is returned and the - * location is produced at *loc. + * location is produced at *loc. RETAIN. */ static u3_weak _cj_spot_hot(u3_noun cor, u3_weak bas, u3_noun* loc) @@ -568,7 +576,7 @@ _cj_spot(u3_noun cor, u3_weak bas) } /* _cj_cast(): create a u3j_fink that can be used to efficiently verify - * that another core is located where this one is. + * that another core is located where this one is. RETAIN. */ static u3p(u3j_fink) _cj_cast(u3_noun cor, u3_noun loc) @@ -606,7 +614,7 @@ _cj_cast(u3_noun cor, u3_noun loc) return u3of(u3j_fink, fin_u); } -/* _cj_fine(): check that a core matches a u3j_fink +/* _cj_fine(): check that a core matches a u3j_fink. RETAIN. */ static c3_o _cj_fine(u3_noun cor, u3p(u3j_fink) fin_p) From f2f6a04cc51982933a8de589c88fee96adada1c8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 16 May 2018 11:49:08 -0700 Subject: [PATCH 116/221] bash batteries for gate prep/lose --- noun/jets.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/noun/jets.c b/noun/jets.c index abfca798c..ff308b964 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1525,9 +1525,10 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) return; } sit_u->axe = 2; + sit_u->bas = _cj_bash(u3h(cor)); sit_u->bat = cor; // a lie, this isn't really the battery! sit_u->pog_p = _cj_prog(u3h(cor)); - if ( u3_none != (loc = sit_u->loc = _cj_spot(cor, u3_none)) ) { + if ( u3_none != (loc = sit_u->loc = _cj_spot(cor, sit_u->bas)) ) { u3_noun pax = u3h(u3t(loc)), pay = u3qc_cap(pax), pam = u3qc_mas(pax); @@ -1574,6 +1575,7 @@ void u3j_gate_lose(u3j_site* sit_u) { u3z(sit_u->bat); + u3z(sit_u->bas); if ( u3_none != sit_u->loc ) { u3z(sit_u->loc); u3z(sit_u->lab); From 21637cdca9144bde086d3a3c19d90814503d30c6 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 16 May 2018 13:45:40 -0700 Subject: [PATCH 117/221] fix bug in u3j_gate_prep and move hot_p to home road --- include/noun/allocate.h | 1 + include/noun/jets.h | 3 +-- noun/allocate.c | 2 +- noun/jets.c | 34 ++++++++++++++++++++++------------ noun/manage.c | 2 +- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 58f4a1c8f..9c02c12c1 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -128,6 +128,7 @@ } all; struct { // jet dashboard + u3p(u3h_root) hot_p; // hot state (home road only) u3p(u3h_root) war_p; // warm state u3p(u3h_root) cod_p; // cold state u3p(u3h_root) han_p; // hank cache diff --git a/include/noun/jets.h b/include/noun/jets.h index 90e1d3b52..0a7af872b 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -79,7 +79,6 @@ c3_l len_l; // dynamic array length c3_l all_l; // allocated length u3j_core* ray_u; // dynamic array by axis - u3p(u3h_root) hot_p; // driver info by pasted hash } u3j_dash; /* u3j_fist: a single step in a fine check. @@ -134,7 +133,7 @@ /* u3j_boot(): initialize jet system. */ void - u3j_boot(void); + u3j_boot(c3_o nuu_o); /* u3j_clear(): clear jet table to re-register. */ diff --git a/noun/allocate.c b/noun/allocate.c index ddb0e0cdd..588b93190 100644 --- a/noun/allocate.c +++ b/noun/allocate.c @@ -1737,7 +1737,7 @@ u3a_sweep(void) box_u->use_w); u3a_print_memory("leak (minimum)", box_u->siz_w); // fprintf(stderr, "\r\n\r\n"); - // u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); + u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); // fprintf(stderr, "\r\n\r\n"); leq_w += box_u->siz_w; } diff --git a/noun/jets.c b/noun/jets.c index ff308b964..4ec77e462 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -258,6 +258,7 @@ static c3_w _cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev_u) { c3_w i_w; + c3_assert(u3R == &(u3H->rod_u)); if ( dev_u ) { for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) { @@ -272,14 +273,14 @@ _cj_install(u3j_core* ray_u, c3_w jax_l, u3_noun pel, u3_noun lab, u3j_core* dev c3_w j_w; for ( j_w = 0; 0 != kid_u->bas_u[j_w]; j_w++ ) { u3_noun key = _cj_hash(kid_u->bas_u[j_w]), - hot = u3h_get(u3D.hot_p, key), + hot = u3h_get(u3R->jed.hot_p, key), old = ( u3_none == hot ) ? u3_none : u3k(u3h(hot)), reg = _cj_gust(old, kid_u->axe_l, u3k(pel), u3k(loc)), huc = u3t(u3t(loc)), hap = _cj_warm_hump(jax_l, huc), toh = u3nq(reg, jax_l, hap, u3k(bal)); - u3h_put(u3D.hot_p, key, toh); + u3h_put(u3R->jed.hot_p, key, toh); u3z(key); u3z(hot); } } @@ -532,7 +533,7 @@ _cj_spot_hot(u3_noun cor, u3_weak bas, u3_noun* loc) u3_noun bat = u3h(cor); u3_noun has = ( u3_none == bas ) ? _cj_bash(bat) : u3k(bas); u3_weak act = u3_none, - hot = u3h_get(u3D.hot_p, has); + hot = u3h_get(u3H->rod_u.jed.hot_p, has); if ( u3_none != hot ) { u3_noun reg, jax, hap, bal; c3_l jax_l; @@ -711,9 +712,10 @@ _cj_hot_mean(c3_l par_l, u3_noun nam) /* u3j_boot(): initialize jet system. */ void -u3j_boot(void) +u3j_boot(c3_o nuu_o) { c3_w jax_l; + c3_assert(u3R == &(u3H->rod_u)); u3D.len_l =_cj_count(0, u3D.dev_u); u3D.all_l = (2 * u3D.len_l) + 1024; // horrid heuristic @@ -721,7 +723,10 @@ u3j_boot(void) u3D.ray_u = (u3j_core*) malloc(u3D.all_l * sizeof(u3j_core)); memset(u3D.ray_u, 0, (u3D.all_l * sizeof(u3j_core))); - u3D.hot_p = u3h_new(); + if ( c3n == nuu_o ) { + u3h_free(u3R->jed.hot_p); + } + u3R->jed.hot_p = u3h_new(); jax_l = _cj_install(u3D.ray_u, 1, (c3_l) (long long) u3D.dev_u[0].par_u, u3_nul, u3D.dev_u); fprintf(stderr, "boot: installed %d jets\n", jax_l); } @@ -1529,18 +1534,23 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) sit_u->bat = cor; // a lie, this isn't really the battery! sit_u->pog_p = _cj_prog(u3h(cor)); if ( u3_none != (loc = sit_u->loc = _cj_spot(cor, sit_u->bas)) ) { - u3_noun pax = u3h(u3t(loc)), + u3_noun pax = _cj_loc_axe(loc), pay = u3qc_cap(pax), pam = u3qc_mas(pax); - if ( pam < 4 || 3 != pay || 3 != u3qc_cap(pam) ) { - // parent axis includes sample :( + if ( 3 != pay || 2 == pam || (3 != pam && 3 != u3qc_cap(pam)) ) { + fprintf(stderr, "u3j_gate_prep(): parent axis includes sample\r\n"); + u3m_p("axis", pax); + u3_weak act = _cj_find_warm(loc); + c3_assert( u3_none != act ); sit_u->jet_o = c3n; + sit_u->lab = u3k(u3h(u3t(u3t(act)))); + u3z(act); } else { sit_u->jet_o = _cj_nail(loc, 2, &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); } - u3z(pam); + u3z(pam); u3z(pax); } u3t_off(glu_o); } @@ -1957,9 +1967,9 @@ void u3j_ream(void) { u3_noun rel = u3_nul; + c3_assert(u3R == &(u3H->rod_u)); u3h_free(u3R->jed.war_p); u3R->jed.war_p = u3h_new(); - c3_assert(u3R == &(u3H->rod_u)); u3h_walk_with(u3R->jed.cod_p, _cj_warm_tap, &rel); _cj_ream(rel); u3z(rel); @@ -2074,7 +2084,7 @@ u3j_mark(void) tot_w += u3h_mark(u3R->jed.han_p); u3h_walk_with(u3R->jed.han_p, _cj_mark_hank, &tot_w); if ( u3R == &(u3H->rod_u) ) { - tot_w += u3h_mark(u3D.hot_p); + tot_w += u3h_mark(u3R->jed.hot_p); } return tot_w; } @@ -2102,7 +2112,7 @@ u3j_free(void) u3h_free(u3R->jed.cod_p); u3h_free(u3R->jed.han_p); if ( u3R == &(u3H->rod_u) ) { - u3h_free(u3D.hot_p); + u3h_free(u3R->jed.hot_p); } } diff --git a/noun/manage.c b/noun/manage.c index 35e5a90d0..dff24440d 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -1671,7 +1671,7 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, /* Initialize the jet system. */ - u3j_boot(); + u3j_boot(nuu_o); /* Install or reactivate the kernel. */ From a0819e41f8865547a2128cafab06d69aca119711 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 16 May 2018 15:18:17 -0700 Subject: [PATCH 118/221] remove superflous profiling quals --- noun/jets.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 4ec77e462..128bfbbf0 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1102,6 +1102,21 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) } } +/* _cj_sink(): kick by nock. + */ +static u3_noun +_cj_sink(u3_noun cor, u3_noun axe) +{ + u3_weak fol = u3r_at(axe, cor); + if ( u3_none == fol ) { + return u3m_bail(c3__exit); + } + else { + u3z(axe); + return u3n_nock_on(cor, u3k(fol)); + } +} + /* u3j_kick(): new kick. ** ** `axe` is RETAINED by the caller; `cor` is RETAINED iff there @@ -1139,7 +1154,7 @@ u3j_kick(u3_noun cor, u3_noun axe) } u3z(act); if ( _(pof_o) ) { - u3_noun pro = u3n_nock_on(cor, u3nq(9, u3k(axe), 0, 1)); + u3_noun pro = _cj_sink(cor, u3k(axe)); u3t_flee(); return pro; @@ -1165,7 +1180,7 @@ u3j_kick(u3_noun cor, u3_noun axe) if ( u3_none == pro ) { if ( _(pof_o) ) { - pro = u3n_nock_on(cor, u3nq(9, u3k(axe), 0, 1)); + pro = _cj_sink(cor, u3k(axe)); u3t_flee(); return pro; @@ -1507,13 +1522,7 @@ u3j_kink(u3_noun cor, u3_noun axe) return pro; } else { - u3_weak fol = u3r_at(axe, cor); - if ( u3_none == fol ) { - return u3m_bail(c3__exit); - } - else { - return u3n_nock_on(cor, u3k(fol)); - } + return _cj_sink(cor, axe); } } From 83f698ab448341232a60b445267f4e3f7c4fa8a0 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 23 May 2018 15:13:00 -0700 Subject: [PATCH 119/221] mux jet --- include/jets/q.h | 1 + include/jets/w.h | 1 + jets/c/mux.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ jets/tree.c | 5 +++ 4 files changed, 92 insertions(+) create mode 100644 jets/c/mux.c diff --git a/include/jets/q.h b/include/jets/q.h index 48db0ea5e..89ccd1ad6 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -60,6 +60,7 @@ u3_noun u3qc_met(u3_atom, u3_atom); u3_noun u3qc_mix(u3_atom, u3_atom); u3_noun u3qc_muk(u3_atom, u3_atom, u3_atom); + u3_noun u3qc_mux(u3_noun, u3_noun, u3_noun); u3_noun u3qc_peg(u3_atom, u3_atom); u3_noun u3qc_pow(u3_atom, u3_atom); u3_noun u3qc_rap(u3_atom, u3_noun); diff --git a/include/jets/w.h b/include/jets/w.h index 693cff4ba..5080e3c2c 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -59,6 +59,7 @@ u3_noun u3wc_met(u3_noun); u3_noun u3wc_mix(u3_noun); u3_noun u3wc_mug(u3_noun); + u3_noun u3wc_mux(u3_noun); u3_noun u3wc_muk(u3_noun); u3_noun u3wc_peg(u3_noun); u3_noun u3wc_pow(u3_noun); diff --git a/jets/c/mux.c b/jets/c/mux.c new file mode 100644 index 000000000..54f4b570f --- /dev/null +++ b/jets/c/mux.c @@ -0,0 +1,85 @@ +/* j/3/mux.c +** +*/ +#include "all.h" + +static u3_atom +_ham(void* has_u, u3_atom a) +{ + u3j_site *sit_u = has_u; + return u3j_gate_slam(sit_u, a); +} + +static u3_atom +_mam(void* mis_u, u3_atom a, u3_atom b) +{ + u3j_site *sit_u = mis_u; + u3_noun sam = u3nc(a, b); + return u3j_gate_slam(sit_u, sam); +} + +static u3_noun +_mux_in(u3p(u3h_root) cax_p, u3_noun a, + u3_atom (*hat)(void*, u3_atom), void* has_u, + u3_atom (*mix)(void*, u3_atom, u3_atom), void* mis_u) +{ + u3_weak got = u3h_get(cax_p, a); + u3_atom pro; + + if ( u3_none != got ) { + pro = got; + } + else { + if ( c3y == u3ud(a) ) { + pro = hat(has_u, u3k(a)); + } + else { + u3_atom lef = _mux_in(cax_p, u3k(u3h(a)), hat, has_u, mix, mis_u), + rit = _mux_in(cax_p, u3k(u3t(a)), hat, has_u, mix, mis_u); + pro = mix(mis_u, lef, rit); + } + u3h_put(cax_p, a, u3k(pro)); + } + + u3z(a); + return pro; +} + +/* functions +*/ + u3_noun + u3kc_mux_f(u3_noun a, + u3_atom (*hat)(void*, u3_atom), void* has_u, + u3_atom (*mix)(void*, u3_atom, u3_atom), void* mis_u) + { + u3p(u3h_root) cax_p = u3h_new(); + u3_noun pro = _mux_in(cax_p, a, hat, has_u, mix, mis_u); + u3h_free(cax_p); + return pro; + } + u3_noun + u3qc_mux(u3_noun a, u3_noun hat, u3_noun mix) + { + u3_noun pro; + u3j_site hat_u, mix_u; + u3j_gate_prep(&hat_u, u3k(hat)); + u3j_gate_prep(&mix_u, u3k(mix)); + pro = u3kc_mux_f(u3k(a), _ham, &hat_u, _mam, &mix_u); + u3j_gate_lose(&mix_u); + u3j_gate_lose(&hat_u); + return pro; + } + u3_noun + u3wc_mux(u3_noun cor) + { + u3_noun sam; + + if ( u3_none == (sam = u3r_at(u3x_sam, cor)) ) { + return u3m_bail(c3__exit); + } + else { + u3_noun a, hat, mix; + u3x_trel(sam, &a, &hat, &mix); + return u3qc_mux(a, hat, mix); + } + } diff --git a/jets/tree.c b/jets/tree.c index 78c0b80a4..13e7d1e83 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -1317,6 +1317,10 @@ static u3j_core _143_tri_d[] = "482e58af", 0, }; + static u3j_harm _143_two_mux_a[] = {{".2", u3wc_mux, c3n}, {}}; + static c3_c* _143_two_mux_ha[] = { + 0, + }; static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; static c3_c* _143_two_pow_ha[] = { "4a70ddfe", @@ -1543,6 +1547,7 @@ static u3j_core _143_two_d[] = { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, { "mix", 7, _143_two_mix_a, 0, _143_two_mix_ha }, { "mug", 7, _143_two_mug_a, 0, _143_two_mug_ha }, + { "mux", 7, _143_two_mux_a, 0, _143_two_mux_ha }, { "muk", 59, _143_two_muk_a, 0, _143_two_muk_ha }, { "rap", 7, _143_two_rap_a, 0, _143_two_rap_ha }, { "rep", 7, _143_two_rep_a, 0, _143_two_rep_ha }, From 46747b9ce32d2154d48990f81c726d3bd10decac Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 23 May 2018 15:39:22 -0700 Subject: [PATCH 120/221] shux jet --- include/jets/k.h | 7 +++++++ include/jets/q.h | 1 + include/jets/w.h | 1 + jets/tree.c | 7 ++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/jets/k.h b/include/jets/k.h index d9171a511..e49e5a98f 100644 --- a/include/jets/k.h +++ b/include/jets/k.h @@ -28,6 +28,13 @@ u3_noun u3kc_rsh(u3_noun a, u3_noun b, u3_noun c); + /* u3kc_mux_f(): mux with function pointers. + */ + u3_noun + u3kc_mux_f(u3_noun a, + u3_atom (*hat)(void*, u3_atom), void* has_u, + u3_atom (*mix)(void*, u3_atom, u3_atom), void* mis_u); + /* u3kd: tier 4 functions */ /* u3kdb_get(): map get for key `b` in map `a` with u3_none. diff --git a/include/jets/q.h b/include/jets/q.h index 89ccd1ad6..fd4e7a5c0 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -133,6 +133,7 @@ u3_noun u3qe_shay(u3_atom, u3_atom); u3_noun u3qe_shas(u3_atom, u3_atom); u3_noun u3qe_shal(u3_atom, u3_atom); + u3_noun u3qe_shux(u3_atom); u3_noun u3qeo_raw(u3_atom, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index 5080e3c2c..8c7d0a17f 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -144,6 +144,7 @@ u3_noun u3we_shay(u3_noun); u3_noun u3we_shas(u3_noun); u3_noun u3we_shal(u3_noun); + u3_noun u3we_shux(u3_noun); u3_noun u3weo_raw(u3_noun); diff --git a/jets/tree.c b/jets/tree.c index 13e7d1e83..682ee7e4d 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -1130,6 +1130,10 @@ static u3j_core _143_qua_d[] = "63ea0b00", 0, }; + static u3j_harm _143_tri_shux_a[] = {{".2", u3we_shux}, {}}; + static c3_c* _143_tri_shux_ha[] = { + 0, + }; static c3_c* _143_tri_ha[] = { "6cc318e2", @@ -1148,6 +1152,7 @@ static u3j_core _143_tri_d[] = { "shay", 7, _143_tri_shay_a, 0, _143_tri_shay_ha }, // { "shas", 7, _143_tri_shas_a, 0, _143_tri_shas_ha }, { "shal", 7, _143_tri_shal_a, 0, _143_tri_shal_ha }, + { "shux", 7, _143_tri_shux_a, 0, _143_tri_shux_ha }, {} }; @@ -1317,7 +1322,7 @@ static u3j_core _143_tri_d[] = "482e58af", 0, }; - static u3j_harm _143_two_mux_a[] = {{".2", u3wc_mux, c3n}, {}}; + static u3j_harm _143_two_mux_a[] = {{".2", u3wc_mux, c3y}, {}}; static c3_c* _143_two_mux_ha[] = { 0, }; From 8c4fd067de4240959ca9f394fada981ffda2eb0a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 25 May 2018 17:53:36 -0700 Subject: [PATCH 121/221] general battery hash caching --- include/noun/allocate.h | 1 + include/noun/jets.h | 2 +- noun/jets.c | 268 +++++++++++++++++++++++++++++++++++++++- noun/manage.c | 4 +- 4 files changed, 270 insertions(+), 5 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 9c02c12c1..d2a8a55b6 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -132,6 +132,7 @@ u3p(u3h_root) war_p; // warm state u3p(u3h_root) cod_p; // cold state u3p(u3h_root) han_p; // hank cache + u3p(u3h_root) bas_p; // battery hashes } jed; struct { // bytecode state diff --git a/include/noun/jets.h b/include/noun/jets.h index 0a7af872b..f98d847ba 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -193,7 +193,7 @@ /* u3j_reap(): promote jet state. RETAINS. */ void - u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p); + u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p, u3p(u3h_root) bas_p); /* u3j_rite_mine(): mine cor with clu, using u3j_rite for caching */ diff --git a/noun/jets.c b/noun/jets.c index 128bfbbf0..eebe49a6c 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -3,6 +3,12 @@ */ #include "all.h" +#if defined(U3_OS_osx) +#include +#else +#include +#endif + /** Data structures. **/ @@ -77,14 +83,252 @@ _cj_hash(c3_c* has_c) return mug; } +typedef struct { +#if defined(U3_OS_osx) + CC_SHA256_CTX ctx_h; +#else + SHA256_CTX ctx_h; +#endif + c3_s inx_s; + c3_y buf_y[65536]; +} _cj_sha; + +static void +_cj_digest_update(_cj_sha* sha_u, c3_y* byt_y, c3_w len_w) +{ +#if defined(U3_OS_osx) + CC_SHA256_Update(&(sha_u->ctx_h), &byt_y, len_w); +#else + SHA256_Update(&(sha_u->ctx_h), &byt_y, len_w); +#endif +} + +static void +_cj_digest_flush(_cj_sha* sha_u) +{ + if ( sha_u->inx_s ) { + _cj_digest_update(sha_u, sha_u->buf_y, sha_u->inx_s); + sha_u->inx_s = 0; + } +} + +static void +_cj_digest_write(_cj_sha* sha_u, u3_atom a) +{ + c3_w met_w = u3r_met(3, a), + law_w = u3r_met(3, met_w); + + if ( (law_w + met_w) > 65536 ) { + c3_y* big_y = u3a_malloc(met_w); + u3r_bytes(0, met_w, big_y, a); + _cj_digest_flush(sha_u); + _cj_digest_update(sha_u, big_y, met_w); + u3a_free(big_y); + } + else { + if ( (sha_u->inx_s + met_w + law_w ) > 65536 ) { + _cj_digest_flush(sha_u); + } + u3r_bytes(0, law_w, sha_u->buf_y + sha_u->inx_s, law_w); + sha_u->inx_s += (c3_s) law_w; + u3r_bytes(0, met_w, sha_u->buf_y + sha_u->inx_s, a); + sha_u->inx_s += (c3_s) met_w; + } +} + +u3_noun +_cj_digest_final(_cj_sha* sha_u) +{ + c3_y dig_y[32]; +#if defined(U3_OS_osx) + CC_SHA256_Final(dig_y, &(sha_u->ctx_h)); +#else + SHA256_Final(dig_y, &(sha_u->ctx_h)); +#endif + return u3i_bytes(32, dig_y); +} + +static void +_cj_digest_init(_cj_sha* sha_u) +{ +#if defined(U3_OS_osx) + CC_SHA256_Init(&(sha_u->ctx_h)); +#else + SHA256_Init(&(sha_u->ctx_h)); +#endif +} + +u3_noun +_cj_digest(u3_noun a) +{ + u3_noun *don, *top; + c3_y wis_y = c3_wiseof(u3_noun); + c3_o nor_o = u3a_is_north(u3R); + c3_ys mov = (c3y == nor_o) ? -wis_y : wis_y; + c3_ys off = (c3y == nor_o) ? 0 : -wis_y; + + u3p(u3h_root) har_p = u3h_new(); + c3_w inx_w = 0; + c3_l pre_l; + _cj_sha sha_u; + + _cj_digest_init(&sha_u); + don = u3to(u3_noun, u3R->cap_p + off); + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = a; + + while ( top != don ) { + a = *top; + pre_l = u3h_git(har_p, a); + if ( u3_none != pre_l ) { + _cj_digest_write(&sha_u, 2); + _cj_digest_write(&sha_u, pre_l); + u3R->cap_p -= mov; + top = u3to(u3_noun, u3R->cap_p + off); + } + else { + u3h_put(har_p, a, inx_w++); + c3_assert( c3y == u3a_is_cat(inx_w) ); + if ( c3y == u3du(a) ) { + _cj_digest_write(&sha_u, 1); + *top = u3h(a); + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = u3t(a); + } + else { + _cj_digest_write(&sha_u, 0); + _cj_digest_write(&sha_u, a); + u3R->cap_p -= mov; + top = u3to(u3_noun, u3R->cap_p + off); + } + } + } + + u3h_free(har_p); + _cj_digest_flush(&sha_u); + return _cj_digest_final(&sha_u); +} + /* _cj_bash(): battery hash. RETAIN. */ static u3_noun _cj_bash(u3_noun bat) { - return u3r_mug(bat); + u3_weak pro; + u3a_road* rod_u = u3R; + while ( 1 ) { + pro = u3h_get(rod_u->jed.bas_p, bat); + + if ( u3_none != pro ) { + break; + } + + if ( rod_u->par_p ) { + rod_u = u3to(u3_road, rod_u->par_p); + } + else { + /* + u3_noun jan = u3qe_jam(bat); + pro = u3qe_shax(jan); + u3z(jan); + */ + fprintf(stderr, "-%x", bat); + pro = _cj_digest(bat); + fprintf(stderr, "-+"); + u3h_put(u3R->jed.bas_p, bat, u3k(pro)); + break; + } + } + return pro; } +/* + + //u3_noun pro = u3qe_shux(bat); + u3_noun jan = u3qe_jam(bat); + u3_noun pro = u3qe_shax(jan); + u3z(jan); + + * + u3_noun a, pro, *top, *don; + + c3_w met_w; + + c3_y wis_y = c3_wiseof(u3_noun); + c3_o nor_o = u3a_is_north(u3R); + c3_ys mov = (c3y == nor_o) ? -wis_y : wis_y; + c3_ys off = (c3y == nor_o) ? 0 : -wis_y; + + c3_y cel_y = 1; + c3_y buf_y[1024]; + c3_w siz_w = 1024; + c3_y* byt_y = buf_y; + c3_o all_o = c3n; + + +#if defined(U3_OS_osx) + CC_SHA256_CTX ctx_h; + CC_SHA256_Init(&ctx_h); +#else + SHA256_CTX ctx_h; + SHA256_Init(&ctx_h); +#endif + + don = u3to(u3_noun, u3R->cap_p + off); + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + + while ( top != don ) { + a = *top; + if ( c3y == u3du(a) ) { + *top = u3h(a); + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = u3t(a); +#if defined(U3_OS_osx) + CC_SHA256_Update(&ctx_h, &cel_y, 1); +#else + SHA256_Update(&ctx_h, &cel_y, 1); +#endif + } + else { + top = u3to(u3_noun, (u3R->cap_p -= mov) + off); + met_w = u3r_met(3, a); + if ( met_w > siz_w ) { + if ( c3y == all_o ) { + u3a_free(byt_y); + } + else { + all_o = c3y; + } + byt_y = u3a_malloc(met_w); + siz_w = met_w; + } + u3r_bytes(0, met_w, byt_y, a); +#if defined(U3_OS_osx) + CC_SHA256_Update(&ctx_h, &byt_y, met_w); +#else + SHA256_Update(&ctx_h, &byt_y, met_w); +#endif + } + } + + if ( c3y == all_o ) { + u3a_free(byt_y); + } + +#if defined(U3_OS_osx) + CC_SHA256_Final(buf_y, &ctx_h); +#else + SHA256_Final(buf_y, &ctx_h); +#endif + pro = u3i_bytes(32, buf_y); + return pro; +} +*/ + /* _cj_mine_par_old(): register hooks and parent location within existing * axis in ancestor list or u3_none. */ @@ -1678,12 +1922,16 @@ _cj_mine(u3_noun cey, u3_noun cor) #endif if ( jax_l ) { u3_noun i = bal; + u3_noun bas; fprintf(stderr, "hot jet: "); while ( i != u3_nul ) { _cj_print_tas(stderr, u3h(i)); i = u3t(i); } - fprintf(stderr, "\r\n bat %x, axe %d, jax %d\r\n", u3r_mug(bat), axe, jax_l); + fprintf(stderr, "\r\n axe %d, jax %d\r\n", axe, jax_l); + bas = _cj_bash(bat); + u3m_p("bash", bas); + u3z(bas); } hap = _cj_warm_hump(jax_l, u3t(u3t(loc))); act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); @@ -1835,6 +2083,17 @@ _cj_cold_reap(u3_noun kev) u3z(bat); } +/* _cj_bash_reap(): reap battery hashes. + */ +static void +_cj_bash_reap(u3_noun kev) +{ + u3_noun key = u3a_take(u3h(kev)), + val = u3a_take(u3t(kev)); + u3h_put(u3R->jed.bas_p, key, val); + u3z(key); +} + /* _cj_hank_reap(): reap hook resolutions. */ static void @@ -1870,11 +2129,12 @@ _cj_hank_reap(u3_noun kev) /* u3j_reap(): promote jet state. */ void -u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p) +u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p, u3p(u3h_root) bas_p) { u3h_walk(cod_p, _cj_cold_reap); u3h_walk(war_p, _cj_warm_reap); u3h_walk(han_p, _cj_hank_reap); + u3h_walk(bas_p, _cj_bash_reap); } /* _cj_ream(): ream list of battery registry pairs. RETAIN. @@ -2091,6 +2351,7 @@ u3j_mark(void) tot_w += u3h_mark(u3R->jed.war_p); tot_w += u3h_mark(u3R->jed.cod_p); tot_w += u3h_mark(u3R->jed.han_p); + tot_w += u3h_mark(u3R->jed.bas_p); u3h_walk_with(u3R->jed.han_p, _cj_mark_hank, &tot_w); if ( u3R == &(u3H->rod_u) ) { tot_w += u3h_mark(u3R->jed.hot_p); @@ -2120,6 +2381,7 @@ u3j_free(void) u3h_free(u3R->jed.war_p); u3h_free(u3R->jed.cod_p); u3h_free(u3R->jed.han_p); + u3h_free(u3R->jed.bas_p); if ( u3R == &(u3H->rod_u) ) { u3h_free(u3R->jed.hot_p); } diff --git a/noun/manage.c b/noun/manage.c index dff24440d..cb336b6ae 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -461,6 +461,7 @@ _pave_parts(void) u3R->jed.war_p = u3h_new(); u3R->jed.cod_p = u3h_new(); u3R->jed.han_p = u3h_new(); + u3R->jed.bas_p = u3h_new(); u3R->byc.har_p = u3h_new(); } @@ -799,13 +800,14 @@ u3m_love(u3_noun pro) u3p(u3h_root) cod_p = u3R->jed.cod_p; u3p(u3h_root) war_p = u3R->jed.war_p; u3p(u3h_root) han_p = u3R->jed.han_p; + u3p(u3h_root) bas_p = u3R->jed.bas_p; u3p(u3h_root) byc_p = u3R->byc.har_p; u3m_fall(); pro = u3a_take(pro); - u3j_reap(cod_p, war_p, han_p); + u3j_reap(cod_p, war_p, han_p, bas_p); u3n_reap(byc_p); u3R->cap_p = u3R->ear_p; From 56ff1520bfa89f70b76968282219b0052c7d3872 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 25 May 2018 17:54:03 -0700 Subject: [PATCH 122/221] bug in _box_slot --- noun/allocate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noun/allocate.c b/noun/allocate.c index 588b93190..fa33b10df 100644 --- a/noun/allocate.c +++ b/noun/allocate.c @@ -31,7 +31,7 @@ _box_count(c3_ws siz_ws) { } static c3_w _box_slot(c3_w siz_w) { - if ( siz_w < 8 ) { + if ( siz_w < u3a_minimum ) { return 0; } else { From 7fe3eee82a703fc5944700a54151a9ac382f4a65 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 25 May 2018 18:17:19 -0700 Subject: [PATCH 123/221] program splitting for located cores --- include/noun/nock.h | 5 +++-- noun/jets.c | 31 ++++++++++++++++--------------- noun/nock.c | 27 +++++++++++++++++---------- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 5914f413c..06730be4b 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -46,10 +46,11 @@ u3_noun 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) - u3n_find(u3_noun fol); + u3n_find(u3_weak key, u3_noun fol); /* u3n_burn(): execute u3n_prog with bus as subject. */ diff --git a/noun/jets.c b/noun/jets.c index eebe49a6c..2910f521b 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1198,11 +1198,11 @@ u3j_hook(u3_noun cor, /* _cj_prog(): stop tracing glu and find a nock program */ static u3p(u3n_prog) -_cj_prog(u3_noun fol) +_cj_prog(u3_weak loc, u3_noun fol) { u3p(u3n_prog) pog_p; u3t_off(glu_o); - pog_p = u3n_find(fol); + pog_p = u3n_find(loc, fol); u3t_on(glu_o); 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; if ( 0 == (sit_u->axe = _cj_axis(fol)) ) { sit_u->jet_o = c3n; - sit_u->pog_p = _cj_prog(fol); + sit_u->pog_p = _cj_prog(loc, fol); } 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, &(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 */ 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) && (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { 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 ) { u3z(sit_u->bat); } @@ -1611,7 +1611,7 @@ _cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) ** (no validity checks). */ 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; 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); } if ( u3_none == pro ) { - _cj_site_lock(cor, sit_u); + _cj_site_lock(loc, cor, sit_u); } } else { @@ -1637,7 +1637,7 @@ _cj_site_kick_hot(u3_noun cor, u3j_site* sit_u) u3t_on(glu_o); } 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); } 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) ) { loc = sit_u->loc; 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->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 { pro = u3_none; @@ -1707,7 +1707,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) } if ( u3_none == pro ) { - _cj_site_lock(cor, sit_u); + _cj_site_lock(loc, cor, sit_u); } return pro; @@ -1785,8 +1785,9 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) sit_u->axe = 2; sit_u->bas = _cj_bash(u3h(cor)); sit_u->bat = cor; // a lie, this isn't really the battery! - sit_u->pog_p = _cj_prog(u3h(cor)); - if ( u3_none != (loc = sit_u->loc = _cj_spot(cor, sit_u->bas)) ) { + sit_u->loc = 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), pay = u3qc_cap(pax), pam = u3qc_mas(pax); @@ -1823,7 +1824,7 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam) sam, u3k(u3t(u3t(sit_u->bat)))); 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 ) { pro = _cj_burn(sit_u->pog_p, cor); diff --git a/noun/nock.c b/noun/nock.c index f133a0434..d7191ad44 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1442,17 +1442,21 @@ _n_bite(u3_noun fol) { /* _n_find(): return prog for given formula. fol is RETAINED. */ 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 ) { + u3z(key); return u3to(u3n_prog, pog); } else if ( u3R != &u3H->rod_u ) { u3a_road* rod_u = u3R; while ( 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 ) { c3_w i_w; 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->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; } } @@ -1474,19 +1479,21 @@ _n_find(u3_noun 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; } } -/* 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) -u3n_find(u3_noun fol) +u3n_find(u3_weak key, u3_noun fol) { u3p(u3n_prog) pog_p; 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); 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; _n_push(mov, off, x); nock_out: - pog_u = _n_find(o); + pog_u = _n_find(u3_none, o); pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG @@ -2189,7 +2196,7 @@ u3n_burn(u3p(u3n_prog) pog_p, u3_noun bus) static u3_noun _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); return _n_burn_out(bus, pog_u); From 1486aec8353ad7657f893e6510918d9429b4dc3b Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sat, 26 May 2018 12:03:09 -0700 Subject: [PATCH 124/221] better bash conveyance --- include/noun/jets.h | 4 +- noun/jets.c | 206 ++++++++++++++++---------------------------- 2 files changed, 75 insertions(+), 135 deletions(-) diff --git a/include/noun/jets.h b/include/noun/jets.h index f98d847ba..16c318c29 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -26,10 +26,10 @@ drivers=(map axis @ud) label=path == -+= bash mug=@ :: later, noun-flavored sha256 ++= bash @ :: battery hash (sha-256 based) :: += hot (map bash hot-info) -+= cold (map battery=^ registry) ++= cold (map battery=^ (pair bash registry)) += warm (map location activation) #endif diff --git a/noun/jets.c b/noun/jets.c index 2910f521b..be14b3e36 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -229,14 +229,7 @@ _cj_bash(u3_noun bat) rod_u = u3to(u3_road, rod_u->par_p); } else { - /* - u3_noun jan = u3qe_jam(bat); - pro = u3qe_shax(jan); - u3z(jan); - */ - fprintf(stderr, "-%x", bat); pro = _cj_digest(bat); - fprintf(stderr, "-+"); u3h_put(u3R->jed.bas_p, bat, u3k(pro)); break; } @@ -244,91 +237,6 @@ _cj_bash(u3_noun bat) return pro; } -/* - - //u3_noun pro = u3qe_shux(bat); - u3_noun jan = u3qe_jam(bat); - u3_noun pro = u3qe_shax(jan); - u3z(jan); - - * - u3_noun a, pro, *top, *don; - - c3_w met_w; - - c3_y wis_y = c3_wiseof(u3_noun); - c3_o nor_o = u3a_is_north(u3R); - c3_ys mov = (c3y == nor_o) ? -wis_y : wis_y; - c3_ys off = (c3y == nor_o) ? 0 : -wis_y; - - c3_y cel_y = 1; - c3_y buf_y[1024]; - c3_w siz_w = 1024; - c3_y* byt_y = buf_y; - c3_o all_o = c3n; - - -#if defined(U3_OS_osx) - CC_SHA256_CTX ctx_h; - CC_SHA256_Init(&ctx_h); -#else - SHA256_CTX ctx_h; - SHA256_Init(&ctx_h); -#endif - - don = u3to(u3_noun, u3R->cap_p + off); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - - while ( top != don ) { - a = *top; - if ( c3y == u3du(a) ) { - *top = u3h(a); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = u3t(a); -#if defined(U3_OS_osx) - CC_SHA256_Update(&ctx_h, &cel_y, 1); -#else - SHA256_Update(&ctx_h, &cel_y, 1); -#endif - } - else { - top = u3to(u3_noun, (u3R->cap_p -= mov) + off); - met_w = u3r_met(3, a); - if ( met_w > siz_w ) { - if ( c3y == all_o ) { - u3a_free(byt_y); - } - else { - all_o = c3y; - } - byt_y = u3a_malloc(met_w); - siz_w = met_w; - } - u3r_bytes(0, met_w, byt_y, a); -#if defined(U3_OS_osx) - CC_SHA256_Update(&ctx_h, &byt_y, met_w); -#else - SHA256_Update(&ctx_h, &byt_y, met_w); -#endif - } - } - - if ( c3y == all_o ) { - u3a_free(byt_y); - } - -#if defined(U3_OS_osx) - CC_SHA256_Final(buf_y, &ctx_h); -#else - SHA256_Final(buf_y, &ctx_h); -#endif - pro = u3i_bytes(32, buf_y); - return pro; -} -*/ - /* _cj_mine_par_old(): register hooks and parent location within existing * axis in ancestor list or u3_none. */ @@ -646,7 +554,7 @@ _cj_je_fsck(u3_noun clu) return u3nt(u3i_string(nam_c), axe_l, huk); } -/* _cj_find_cold(): search cold state for `bat`s registry. +/* _cj_find_cold(): search cold state for `bat`s [bash registry]. * RETAIN. */ static u3_weak @@ -655,10 +563,10 @@ _cj_find_cold(u3_noun bat) u3a_road* rod_u = u3R; while ( 1 ) { - u3_weak reg = u3h_gut(rod_u->jed.cod_p, bat); + u3_weak bar = u3h_gut(rod_u->jed.cod_p, bat); - if ( u3_none != reg ) { - return reg; + if ( u3_none != bar ) { + return bar; } if ( rod_u->par_p ) { @@ -690,7 +598,7 @@ _cj_find_warm(u3_noun loc) } } -static u3_weak _cj_spot(u3_noun cor, u3_weak bas); +static u3_weak _cj_spot(u3_noun cor, u3_weak* bas); /* _cj_reg_find(): locate core within registry. RETAIN. */ @@ -713,7 +621,7 @@ _cj_reg_find(u3_noun reg, u3_noun cor) u3_weak par = u3r_at(axe, cor), pel; if ( u3_none != par ) { - pel = _cj_spot(par, u3_none); + pel = _cj_spot(par, NULL); if ( u3_none != pel ) { u3_noun nit = u3qdb_get(lol, pel); u3z(pel); @@ -757,14 +665,19 @@ _cj_loc_pel(u3_noun loc) return u3k(u3t(u3t(u3h(loc)))); } -/* _cj_spot_cold(): spot, cold dashboard only. *reg is set to - * the registry found for battery. RETAIN. +/* _cj_spot_cold(): spot, cold dashboard only. *bar is set to + * the [bash registry] found for battery. RETAIN. */ static u3_weak -_cj_spot_cold(u3_noun cor, u3_noun* reg) +_cj_spot_cold(u3_noun cor, u3_weak* bar) { - *reg = _cj_find_cold(u3h(cor)); - return ( u3_none == *reg ) ? u3_none : _cj_reg_find(*reg, cor); + *bar = _cj_find_cold(u3h(cor)); + if ( u3_none == *bar ) { + return u3_none; + } + else { + return _cj_reg_find(u3t(*bar), cor); + } } /* _cj_spot_hot(): try to locate core by hot dashboard. if found, @@ -772,12 +685,11 @@ _cj_spot_cold(u3_noun cor, u3_noun* reg) * location is produced at *loc. RETAIN. */ static u3_weak -_cj_spot_hot(u3_noun cor, u3_weak bas, u3_noun* loc) +_cj_spot_hot(u3_noun cor, u3_noun bas, u3_noun* loc) { u3_noun bat = u3h(cor); - u3_noun has = ( u3_none == bas ) ? _cj_bash(bat) : u3k(bas); u3_weak act = u3_none, - hot = u3h_get(u3H->rod_u.jed.hot_p, has); + hot = u3h_get(u3H->rod_u.jed.hot_p, bas); if ( u3_none != hot ) { u3_noun reg, jax, hap, bal; c3_l jax_l; @@ -788,21 +700,41 @@ _cj_spot_hot(u3_noun cor, u3_weak bas, u3_noun* loc) } u3z(hot); } - u3z(has); return act; } /* _cj_spot(): find location of cor. expensive. RETAIN. - * bas is an optional cached battery hash for the hot lookup. + * bas is complicated to make it easy to cache bashes. + * you can safely ignore it by passing NULL. Otherwise, + * if it points to u3_none, and no location is found, + * a bash will be PRODUCED there. if it contains a bash, + * that will be used instead of calling _cj_bash. */ static u3_weak -_cj_spot(u3_noun cor, u3_weak bas) +_cj_spot(u3_noun cor, u3_weak* bas) { - u3_weak reg = u3_none, - loc = _cj_spot_cold(cor, ®); + u3_weak bak = u3_none, + bar = u3_none, + reg = u3_none, + loc = _cj_spot_cold(cor, &bar); + + if ( NULL == bas ) { + bas = &bak; + } + + if ( u3_none != bar ) { + if ( (u3_none == *bas) ) { + *bas = u3k(u3h(bar)); + } + reg = u3k(u3t(bar)); + u3z(bar); + } if ( u3_none == loc ) { - u3_weak act = _cj_spot_hot(cor, bas, &loc); + if ( u3_none == *bas ) { + *bas = _cj_bash(u3h(cor)); + } + u3_weak act = _cj_spot_hot(cor, *bas, &loc); if ( u3_none != act ) { reg = _cj_gust(reg, _cj_loc_axe(loc), _cj_loc_pel(loc), u3k(loc)); u3h_put(u3R->jed.cod_p, u3h(cor), u3k(reg)); @@ -814,6 +746,9 @@ _cj_spot(u3_noun cor, u3_weak bas) u3h_put(u3R->jed.war_p, loc, act); } } + if ( u3_none != bak ) { + u3z(bak); + } if ( u3_none != reg ) { u3z(reg); } @@ -1090,7 +1025,7 @@ _cj_hook_in(u3_noun cor, return u3m_bail(c3__fail); } - loc = _cj_spot(cor, u3_none); + loc = _cj_spot(cor, NULL); if ( u3_none == loc ) { return u3m_bail(c3__fail); } @@ -1290,8 +1225,8 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) return u3m_bail(c3__fail); } - sit_u->bas = _cj_bash(u3h(cor)); - if ( u3_none == (col = loc = _cj_spot(cor, sit_u->bas)) ) { + sit_u->bas = u3_none; + if ( u3_none == (col = loc = _cj_spot(cor, NULL)) ) { return u3m_bail(c3__fail); } @@ -1370,7 +1305,7 @@ u3_weak u3j_kick(u3_noun cor, u3_noun axe) { u3t_on(glu_o); - u3_weak loc = _cj_spot(cor, u3_none); + u3_weak loc = _cj_spot(cor, NULL); if ( u3_none == loc ) { u3t_off(glu_o); return u3_none; @@ -1666,10 +1601,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) } if ( u3_none == loc ) { - if ( u3_none == sit_u->bas ) { - sit_u->bas = _cj_bash(u3h(cor)); - } - loc = _cj_spot(cor, sit_u->bas); + loc = _cj_spot(cor, &(sit_u->bas)); if ( u3_none != loc ) { u3p(u3j_fink) fon_p = 0; u3_weak lod = u3_none; @@ -1782,10 +1714,10 @@ u3j_gate_prep(u3j_site* sit_u, u3_noun cor) u3m_bail(c3__exit); return; } + sit_u->bas = u3_none; sit_u->axe = 2; - sit_u->bas = _cj_bash(u3h(cor)); sit_u->bat = cor; // a lie, this isn't really the battery! - sit_u->loc = loc = _cj_spot(cor, sit_u->bas); + sit_u->loc = 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), @@ -1866,7 +1798,7 @@ _cj_minx(u3_noun cey, u3_noun cor) fprintf(stderr, "fund: %s is bogus\r\n", u3r_string(nam)); return u3_none; } - pel = _cj_spot(par, u3_none); + pel = _cj_spot(par, NULL); if ( u3_none == pel ) { fprintf(stderr, "fund: in %s, parent %x not found at %d\r\n", u3r_string(nam), @@ -1894,7 +1826,7 @@ _cj_print_tas(FILE* fh, u3_noun tas) /* _cj_mine(): declare a core and produce location. RETAIN. */ static u3_weak -_cj_mine(u3_noun cey, u3_noun cor) +_cj_mine(u3_noun cey, u3_noun cor, u3_noun bas) { u3_weak loc = _cj_minx(cey, cor); if ( u3_none != loc ) { @@ -1903,8 +1835,16 @@ _cj_mine(u3_noun cey, u3_noun cor) axe = _cj_loc_axe(loc), bat = u3h(cor), nam = u3h(u3t(loc)), - reg = _cj_gust(_cj_find_cold(bat), u3k(axe), u3k(pel), u3k(loc)), - hap, bal, act; + bar = _cj_find_cold(bat), + reg, hap, bal, act; + if ( u3_none == bar ) { + reg = u3_none; + } + else { + reg = u3k(u3t(bar)); + u3z(bar); + } + reg = _cj_gust(reg, u3k(axe), u3k(pel), u3k(loc)); if ( 0 == axe ) { par_l = 0; bal = u3nc(u3k(nam), u3_nul); @@ -1923,20 +1863,18 @@ _cj_mine(u3_noun cey, u3_noun cor) #endif if ( jax_l ) { u3_noun i = bal; - u3_noun bas; fprintf(stderr, "hot jet: "); while ( i != u3_nul ) { _cj_print_tas(stderr, u3h(i)); i = u3t(i); } - fprintf(stderr, "\r\n axe %d, jax %d\r\n", axe, jax_l); - bas = _cj_bash(bat); + fprintf(stderr, "\r\n "); u3m_p("bash", bas); - u3z(bas); + fprintf(stderr, " axe %d, jax %d\r\n", axe, jax_l); } hap = _cj_warm_hump(jax_l, u3t(u3t(loc))); act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); - u3h_put(u3R->jed.cod_p, bat, reg); + u3h_put(u3R->jed.cod_p, bat, u3nc(u3k(bas), reg)); u3h_put(u3R->jed.war_p, loc, act); // see note in _cj_spot u3z(pel); u3z(axe); } @@ -2002,9 +1940,11 @@ _cj_mile(u3_noun clu, u3_noun cor) else { u3_weak cey = _cj_je_fsck(clu); if ( u3_none != cey ) { - loc = _cj_spot(cor, u3_none); + u3_weak bas = u3_none; + loc = _cj_spot(cor, &bas); if ( u3_none == loc ) { - loc = _cj_mine(cey, cor); + loc = _cj_mine(cey, cor, bas); + u3z(bas); } else { _cj_audit(loc, cey, cor); From 06fdf49c5f6eb6181a05bf17363c6b016878999f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 29 May 2018 21:29:53 -0700 Subject: [PATCH 125/221] faster jam --- jets/e/jam.c | 307 +++++++++++++++++++++++++-------------------------- 1 file changed, 153 insertions(+), 154 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 0886dad5a..017b6a4a8 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -3,185 +3,184 @@ */ #include "all.h" -/* functions -*/ +#define JAM_NONE 0 +#define JAM_HEAD 1 +#define JAM_TAIL 2 - static u3_noun - _jam_pair(u3_noun x, u3_noun d, u3_noun e) - { - u3_noun r, p_d, q_d, r_d; - u3x_trel(d, &p_d, &q_d, &r_d); - { - u3_noun y = u3qa_add(x, p_d); - u3_noun p_e, q_e, r_e; +typedef struct { + c3_w a_w; + c3_w b_w; + c3_w bit_w; + c3_w* wor_w; +} _jam_buf; - u3x_trel(e, &p_e, &q_e, &r_e); - { - u3_noun z = u3qa_add(p_d, p_e); +typedef struct { + c3_y sat_y; + u3_noun a; +} _jam_frame; - r = u3nt(u3qa_add(2, z), u3k(q_e), 0); +static void +_jam_buf_grow(_jam_buf* buf_u, c3_w mor_w) +{ + c3_w wan_w = buf_u->bit_w + mor_w; - u3z(z); - } - u3z(y); + if ( wan_w < mor_w ) { + // overflowed c3_w bits + u3m_bail(c3__fail); + } + + if ( wan_w > buf_u->a_w ) { + c3_w old_w, new_w, c_w = 0; + + old_w = buf_u->a_w >> 5; + if ( (old_w << 5) != buf_u->a_w ) { + ++old_w; } - u3z(x); - u3z(d); - u3z(e); - return r; + + // fibonacci growth + while ( c_w < wan_w ) { + c_w = buf_u->a_w + buf_u->b_w; + buf_u->b_w = buf_u->a_w; + buf_u->a_w = c_w; + } + + new_w = c_w >> 5; + if ( (new_w << 5) != c_w ) { + ++new_w; + } + + buf_u->wor_w = u3a_realloc(buf_u->wor_w, new_w * sizeof(c3_w)); + memset(buf_u->wor_w + old_w, 0, (new_w - old_w) * sizeof(c3_w)); } +} - static u3_noun - _jam_flat(u3_atom a, u3_noun l) - { - u3_noun d = u3qe_mat(a); - u3_noun x = u3qa_add(1, u3h(d)); - u3_noun y = u3nt - (u3k(x), u3nc(u3nc(x, u3qc_lsh(0, 1, u3t(d))), u3k(l)), 0); +static void +_jam_buf_chop(_jam_buf* buf_u, c3_w met_w, u3_noun a) +{ + c3_w bit_w = buf_u->bit_w; + _jam_buf_grow(buf_u, met_w); + u3r_chop(0, 0, met_w, bit_w, buf_u->wor_w, a); + buf_u->bit_w += met_w; +} - u3z(d); - u3z(l); +static void +_jam_buf_atom(_jam_buf* buf_u, u3_noun a) +{ + u3_noun mat = u3qe_mat(a); + _jam_buf_chop(buf_u, u3h(mat), u3t(mat)); + u3z(mat); +} - return y; +static u3_noun +_jam_buf_top(u3_noun a) +{ + u3p(u3h_root) har_p = u3h_new(); + c3_o nor_o = u3a_is_north(u3R); + c3_y wis_y = c3_wiseof(_jam_frame); + c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); + c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); + _jam_frame* fam, *don = u3to(_jam_frame, u3R->cap_p + off); + _jam_buf buf_u; + u3_weak c; + c3_o cel_o; + c3_w a_w, c_w, wor_w, len_w, *sal_w; + + buf_u.a_w = 10946; // fib(21) # of bits starting in wor_w + buf_u.b_w = 6765; // fib(20) roughly 1K, a good start + wor_w = (buf_u.a_w>>5); + if ( (wor_w<<5) != buf_u.a_w ) { + ++wor_w; } + buf_u.wor_w = u3a_calloc(wor_w, sizeof(c3_w)); + buf_u.bit_w = 0; - static u3_noun - _jam_ptr(u3_atom u_c, u3_noun l) - { - u3_noun d = u3qe_mat(u_c); - u3_atom x = u3qc_lsh(0, 2, u3t(d)); - u3_atom y = u3qa_add(2, u3h(d)); - u3_noun z = u3nt - (u3k(y), u3nc(u3nc(y, u3qc_mix(3, x)), u3k(l)), 0); + u3R->cap_p += mov; + fam = u3to(_jam_frame, u3R->cap_p + off); + fam->a = a; + fam->sat_y = JAM_NONE; - u3z(d); - u3z(x); - u3z(l); - - return z; - } - - #define JAM_NONE 0 - #define JAM_HEAD 1 - #define JAM_TAIL 2 - - typedef struct { - c3_y sat_y; - u3_noun nun; - u3_noun len; - u3_noun lis; - u3_noun hed; - } jamframe; - - static inline jamframe* - _jam_push(c3_ys mov, c3_ys off) - { - u3R->cap_p += mov; - return u3to(jamframe, u3R->cap_p + off); - } - - static inline jamframe* - _jam_pop(c3_ys mov, c3_ys off) - { - u3R->cap_p -= mov; - return u3to(jamframe, u3R->cap_p + off); - } - - static u3_noun - _jam_cap(u3_atom a) - { - u3p(jamframe) empty = u3R->cap_p; - u3p(u3h_root) har_p = u3h_new(); - c3_o nor_o = u3a_is_north(u3R); - c3_y wis_y = c3_wiseof(jamframe); - c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); - c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); - jamframe* fam = _jam_push(mov, off); - jamframe* don = u3to(jamframe, empty + off); - - fam->sat_y = JAM_NONE; - fam->nun = a; - fam->len = 0; - fam->lis = u3_nul; - - u3_noun q, r = u3_none; - - while ( don != fam ) { - switch ( fam->sat_y ) { - case JAM_NONE: { - u3_noun nun = fam->nun; - u3_noun len = fam->len; - u3_noun lis = fam->lis; - u3_weak got = u3h_get(har_p, nun); - - if ( u3_none == got ) { - u3h_put(har_p, nun, u3k(len)); - if ( c3n == u3du(nun) ) { - r = _jam_flat(nun, lis); - fam = _jam_pop(mov, off); - u3z(len); - } - else { - fam->sat_y = JAM_HEAD; - fam = _jam_push(mov, off); - fam->sat_y = JAM_NONE; - fam->nun = u3h(nun); - fam->len = u3qa_add(2, len); - fam->lis = u3nc(u3nc(2, 1), lis); - } + while ( fam != don ) { + switch ( fam->sat_y ) { + case JAM_NONE: + a = fam->a; + cel_o = u3du(a); + c = u3h_git(har_p, a); + if ( u3_none != c ) { + c_w = u3r_met(0, c); + if ( c3y == cel_o ) { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); } else { - if ( c3y == u3ud(nun) && (u3r_met(0, nun) <= u3r_met(0, got)) ) { - r = _jam_flat(nun, lis); + a_w = u3r_met(0, a); + if ( a_w <= c_w ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); } else { - r = _jam_ptr(got, lis); + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); } - fam = _jam_pop(mov, off); - u3z(len); } - break; + u3R->cap_p -= mov; + fam = u3to(_jam_frame, u3R->cap_p + off); } - case JAM_HEAD: { - u3_noun p_r, q_r, r_r; - u3x_trel(r, &p_r, &q_r, &r_r); - u3_noun nun = fam->nun; - fam->sat_y = JAM_TAIL; - fam->hed = r; - u3_noun z = u3qa_add(2, fam->len); - fam = _jam_push(mov, off); - fam->sat_y = JAM_NONE; - fam->nun = u3t(nun); - fam->len = u3qa_add(z, p_r); - fam->lis = u3k(q_r); - u3z(z); - break; - } - case JAM_TAIL: { - u3_noun len = fam->len; - r = _jam_pair(u3qa_add(2, len), fam->hed, r); - fam = _jam_pop(mov, off); - u3z(len); - break; - } - default: - c3_assert(0); - return u3_none; - } - } + else { + u3h_put(har_p, a, buf_u.bit_w); + if ( c3n == cel_o ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); + u3R->cap_p -= mov; + fam = u3to(_jam_frame, u3R->cap_p + off); + } + else { + fam->sat_y = JAM_HEAD; - q = u3qb_flop(u3h(u3t(r))); - u3z(r); - r = u3qc_can(0, q); - u3z(q); - u3h_free(har_p); - return r; + u3R->cap_p += mov; + fam = u3to(_jam_frame, u3R->cap_p + off); + fam->sat_y = JAM_NONE; + fam->a = u3h(a); + + _jam_buf_chop(&buf_u, 2, 1); + } + } + break; + + case JAM_HEAD: + a = fam->a; + fam->sat_y = JAM_TAIL; + + u3R->cap_p += mov; + fam = u3to(_jam_frame, u3R->cap_p + off); + fam->sat_y = JAM_NONE; + fam->a = u3t(a); + break; + + case JAM_TAIL: + u3R->cap_p -= mov; + fam = u3to(_jam_frame, u3R->cap_p + off); + break; + } } + + len_w = (buf_u.bit_w>>5); + if ( (len_w<<5) != buf_u.bit_w ) { + ++len_w; + } + sal_w = u3a_slab(len_w); + memcpy(sal_w, buf_u.wor_w, len_w<<2); + u3a_free(buf_u.wor_w); + u3h_free(har_p); + return u3a_mint(sal_w, len_w); +} + +/* functions +*/ u3_noun u3qe_jam(u3_atom a) { - return _jam_cap(a); + return _jam_buf_top(a); } u3_noun u3we_jam(u3_noun cor) From d19fde0b5a13432bc8ded2c2b7fe9317a2c60d38 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 29 May 2018 21:32:47 -0700 Subject: [PATCH 126/221] memory bug in ice testing --- noun/jets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noun/jets.c b/noun/jets.c index be14b3e36..725e21d72 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -971,7 +971,7 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) u3_weak pro, ame; ham_u->ice = c3y; - pro = ham_u->fun_f(u3k(cor)); + pro = ham_u->fun_f(cor); ham_u->ice = c3n; #ifdef U3_MEMORY_DEBUG From 402e77357d80417688be78b55bb82ea093003d36 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 29 May 2018 21:33:10 -0700 Subject: [PATCH 127/221] stash - working out which hash to use --- jets/tree.c | 251 +++------------------------------------------------- noun/jets.c | 85 ++++++++++++------ 2 files changed, 69 insertions(+), 267 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 682ee7e4d..7d2ff0adf 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -4,68 +4,55 @@ static u3j_harm _143_hex_aes_ecba_en_a[] = {{".2", u3wea_ecba_en}, {}}; static c3_c* _143_hex_aes_ecba_en_ha[] = { - "7622dfdb", 0, }; static u3j_harm _143_hex_aes_ecba_de_a[] = {{".2", u3wea_ecba_de}, {}}; static c3_c* _143_hex_aes_ecba_de_ha[] = { - "35592db7", 0, }; static u3j_harm _143_hex_aes_ecbb_en_a[] = {{".2", u3wea_ecbb_en}, {}}; static c3_c* _143_hex_aes_ecbb_en_ha[] = { - "2f1dbee2", 0, }; static u3j_harm _143_hex_aes_ecbb_de_a[] = {{".2", u3wea_ecbb_de}, {}}; static c3_c* _143_hex_aes_ecbb_de_ha[] = { - "5211dc92", 0, }; static u3j_harm _143_hex_aes_ecbc_en_a[] = {{".2", u3wea_ecbc_en}, {}}; static c3_c* _143_hex_aes_ecbc_en_ha[] = { - "70caa183", 0, }; static u3j_harm _143_hex_aes_ecbc_de_a[] = {{".2", u3wea_ecbc_de}, {}}; static c3_c* _143_hex_aes_ecbc_de_ha[] = { - "3433e46b", 0, }; static u3j_harm _143_hex_aes_cbca_en_a[] = {{".2", u3wea_cbca_en}, {}}; static c3_c* _143_hex_aes_cbca_en_ha[] = { - "69ac3685", 0, }; static u3j_harm _143_hex_aes_cbca_de_a[] = {{".2", u3wea_cbca_de}, {}}; static c3_c* _143_hex_aes_cbca_de_ha[] = { - "2057b875", 0, }; static u3j_harm _143_hex_aes_cbcb_en_a[] = {{".2", u3wea_cbcb_en}, {}}; static c3_c* _143_hex_aes_cbcb_en_ha[] = { - "1f286963", 0, }; static u3j_harm _143_hex_aes_cbcb_de_a[] = {{".2", u3wea_cbcb_de}, {}}; static c3_c* _143_hex_aes_cbcb_de_ha[] = { - "654074e5", 0, }; static u3j_harm _143_hex_aes_cbcc_en_a[] = {{".2", u3wea_cbcc_en}, {}}; static c3_c* _143_hex_aes_cbcc_en_ha[] = { - "503ec5ac", 0, }; static u3j_harm _143_hex_aes_cbcc_de_a[] = {{".2", u3wea_cbcc_de}, {}}; static c3_c* _143_hex_aes_cbcc_de_ha[] = { - "f67b27f", 0, }; static c3_c* _143_hex_aes_ecba_ha[] = { - "30bd6d60", 0, }; static u3j_core _143_hex_aes_ecba_d[] = @@ -75,7 +62,6 @@ }; static c3_c* _143_hex_aes_ecbb_ha[] = { - "121ef659", 0, }; static u3j_core _143_hex_aes_ecbb_d[] = @@ -85,7 +71,6 @@ }; static c3_c* _143_hex_aes_ecbc_ha[] = { - "572e5931", 0, }; static u3j_core _143_hex_aes_ecbc_d[] = @@ -95,7 +80,6 @@ }; static c3_c* _143_hex_aes_cbca_ha[] = { - "12d2f4d8", 0, }; static u3j_core _143_hex_aes_cbca_d[] = @@ -105,7 +89,6 @@ }; static c3_c* _143_hex_aes_cbcb_ha[] = { - "30361963", 0, }; static u3j_core _143_hex_aes_cbcb_d[] = @@ -115,7 +98,6 @@ }; static c3_c* _143_hex_aes_cbcc_ha[] = { - "3e4cfab8", 0, }; static u3j_core _143_hex_aes_cbcc_d[] = @@ -125,7 +107,6 @@ }; static c3_c* _143_hex_aes_ha[] = { - "385d228e", 0, }; static u3j_core _143_hex_aes_d[] = @@ -140,12 +121,10 @@ static u3j_harm _143_hex_down_mark_a[] = {{".2", u3wg_down, c3y}, {}}; static c3_c* _143_hex_down_mark_ha[] = { - "2a57366e", 0, }; static c3_c* _143_hex_down_ha[] = { - "7b4e149a", 0, }; static u3j_core _143_hex_down_d[] = @@ -155,43 +134,35 @@ static u3j_harm _143_hex_lore_a[] = {{".2", u3we_lore}, {}}; static c3_c* _143_hex_lore_ha[] = { - "71d2c115", 0, }; static u3j_harm _143_hex_loss_a[] = {{".2", u3we_loss}, {}}; static c3_c* _143_hex_loss_ha[] = { - "1fc16691", 0, }; static u3j_harm _143_hex_lune_a[] = {{".2", u3we_lune}, {}}; static c3_c* _143_hex_lune_ha[] = { - "12455182", 0, }; static u3j_harm _143_hex_coed__ed_puck_a[] = {{".2", u3wee_puck}, {}}; static c3_c* _143_hex_coed__ed_puck_ha[] = { - "2ed1b9e8", 0, }; static u3j_harm _143_hex_coed__ed_sign_a[] = {{".2", u3wee_sign}, {}}; static c3_c* _143_hex_coed__ed_sign_ha[] = { - "d0277fd", 0, }; static u3j_harm _143_hex_coed__ed_veri_a[] = {{".2", u3wee_veri}, {}}; static c3_c* _143_hex_coed__ed_veri_ha[] = { - "5c991b1", 0, }; static u3j_harm _143_hex_coed__ed_shar_a[] = {{".2", u3wee_shar}, {}}; static c3_c* _143_hex_coed__ed_shar_ha[] = { - "78a7b7cc", 0, }; static c3_c* _143_hex_coed__ed_ha[] = { - "46800d16", 0, }; static u3j_core _143_hex_coed__ed_d[] = @@ -203,7 +174,6 @@ }; static c3_c* _143_hex_coed_ha[] = { - "7f0356e", 0, }; static u3j_core _143_hex_coed_d[] = @@ -212,7 +182,6 @@ static u3j_core _143_hex_coed_d[] = }; static c3_c* _143_hex_ha[] = { - "2fd207b3", 0, }; static u3j_core _143_hex_d[] = @@ -231,73 +200,59 @@ static u3j_core _143_hex_d[] = */ static u3j_harm _143_pen_cell_a[] = {{".2", u3wf_cell}, {}}; static c3_c* _143_pen_cell_ha[] = { - "6bfc1bca", 0, }; static u3j_harm _143_pen_comb_a[] = {{".2", u3wf_comb}, {}}; static c3_c* _143_pen_comb_ha[] = { - "1fe51547", 0, }; static u3j_harm _143_pen_cons_a[] = {{".2", u3wf_cons}, {}}; static c3_c* _143_pen_cons_ha[] = { - "2e91771e", 0, }; static u3j_harm _143_pen_core_a[] = {{".2", u3wf_core}, {}}; static c3_c* _143_pen_core_ha[] = { - "5c37f17b", 0, }; static u3j_harm _143_pen_help_a[] = {{".2", u3wf_help}, {}}; static c3_c* _143_pen_help_ha[] = { - "3df833f", 0, }; static u3j_harm _143_pen_face_a[] = {{".2", u3wf_face}, {}}; static c3_c* _143_pen_face_ha[] = { - "742c24f0", 0, }; static u3j_harm _143_pen_fitz_a[] = {{".2", u3wf_fitz}, {}}; static c3_c* _143_pen_fitz_ha[] = { - "464c37aa", 0, }; static u3j_harm _143_pen_flan_a[] = {{".2", u3wf_flan}, {}}; static c3_c* _143_pen_flan_ha[] = { - "19b65692", 0, }; static u3j_harm _143_pen_flip_a[] = {{".2", u3wf_flip}, {}}; static c3_c* _143_pen_flip_ha[] = { - "2da932", 0, }; static u3j_harm _143_pen_flor_a[] = {{".2", u3wf_flor}, {}}; static c3_c* _143_pen_flor_ha[] = { - "53d48f74", 0, }; static u3j_harm _143_pen_fork_a[] = {{".2", u3wf_fork}, {}}; static c3_c* _143_pen_fork_ha[] = { - "6c3239f5", 0, }; static u3j_harm _143_pen_hike_a[] = {{".2", u3wf_hike}, {}}; static c3_c* _143_pen_hike_ha[] = { - "65731f61", 0, }; static u3j_harm _143_pen_look_a[] = {{".2", u3wf_look}, {}}; static c3_c* _143_pen_look_ha[] = { - "1a7dc705", 0, }; static u3j_harm _143_pen_loot_a[] = {{".2", u3wf_loot}, {}}; static c3_c* _143_pen_loot_ha[] = { - "13234213", 0, }; @@ -305,68 +260,55 @@ static u3j_core _143_hex_d[] = //static u3j_harm _143_pen__ut_conk_a[] = {{".2", u3wfu_conk}, {}}; static u3j_harm _143_pen__ut_crop_a[] = {{".2", u3wfu_crop}, {}}; static c3_c* _143_pen__ut_crop_ha[] = { - "1b098a6e", 0, }; // static u3j_harm _143_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; static u3j_harm _143_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}}; static c3_c* _143_pen__ut_fond_ha[] = { - "32d3327a", 0, }; static u3j_harm _143_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; static c3_c* _143_pen__ut_fish_ha[] = { - "4027d168", 0, }; static u3j_harm _143_pen__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}}; static c3_c* _143_pen__ut_fuse_ha[] = { - "6f74b82e", 0, }; static u3j_harm _143_pen__ut_mint_a[] = {{".2", u3wfu_mint}, {}}; static c3_c* _143_pen__ut_mint_ha[] = { - "48723fb5", 0, }; static u3j_harm _143_pen__ut_mull_a[] = {{".2", u3wfu_mull}, {}}; static c3_c* _143_pen__ut_mull_ha[] = { - "1d7c97bc", 0, }; static u3j_harm _143_pen__ut_nest_a[] = {{".2", u3wfu_nest}, {}}; static c3_c* _143_pen__ut_nest_ha[] = { - "4512a8f4", 0, }; static u3j_harm _143_pen__ut_peek_a[] = {{".2", u3wfu_peek}, {}}; static c3_c* _143_pen__ut_peek_ha[] = { - "3c631b7d", 0, }; static u3j_harm _143_pen__ut_play_a[] = {{".2", u3wfu_play}, {}}; static c3_c* _143_pen__ut_play_ha[] = { - "e276a30", 0, }; static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; static c3_c* _143_pen__ut_rest_ha[] = { - "6e47044e", 0, }; static u3j_harm _143_pen__ut_toss_a[] = {{".2", u3wfu_toss}, {}}; static c3_c* _143_pen__ut_toss_ha[] = { - "54362dd", 0, }; static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; static c3_c* _143_pen__ut_wrap_ha[] = { - "f15623c", 0, }; static c3_c* _143_pen__ut_ha[] = { - "c2cda56", 0, }; static u3j_hood _143_pen__ut_ho[] = { @@ -450,7 +392,7 @@ static u3j_core _143_hex_d[] = static c3_c* _143_pen_ha[] = { - "4fcd534d", + "93e4cad5f01e16a173f31810ee5ab530a8a760010eb7cc9b451880456f32267e", 0, }; static u3j_hood _143_pen_ho[] = { @@ -487,33 +429,28 @@ static u3j_core _143_pen_d[] = */ static u3j_harm _143_qua_trip_a[] = {{".2", u3we_trip}, {}}; static c3_c* _143_qua_trip_ha[] = { - "2988e186", + "335ad28e7924ee9bdf29050bf2d7b4eebf434dfaaa0f704a689f065eb5c703b0", 0, }; static u3j_harm _143_qua__po_ind_a[] = {{".2", u3wcp_ind}, {}}; static c3_c* _143_qua__po_ind_ha[] = { - "45bf22f6", 0, }; static u3j_harm _143_qua__po_ins_a[] = {{".2", u3wcp_ins}, {}}; static c3_c* _143_qua__po_ins_ha[] = { - "2c82c596", 0, }; static u3j_harm _143_qua__po_tod_a[] = {{".2", u3wcp_tod}, {}}; static c3_c* _143_qua__po_tod_ha[] = { - "692b7953", 0, }; static u3j_harm _143_qua__po_tos_a[] = {{".2", u3wcp_tos}, {}}; static c3_c* _143_qua__po_tos_ha[] = { - "473d8e66", 0, }; static c3_c* _143_qua__po_ha[] = { - "19535663", 0, }; static u3j_core _143_qua__po_d[] = @@ -526,11 +463,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__bend_fun_a[] = {{".2", u3we_bend_fun}, {}}; static c3_c* _143_qua__bend_ha[] = { - "36e4e2fb", 0, }; static c3_c* _143_qua__bend_fun_ha[] = { - "708e40b", 0, }; static u3j_core _143_qua__bend_d[] = @@ -540,11 +475,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__cold_fun_a[] = {{".2", u3we_cold_fun}, {}}; static c3_c* _143_qua__cold_ha[] = { - "7881e709", 0, }; static c3_c* _143_qua__cold_fun_ha[] = { - "7a6d3682", 0, }; static u3j_core _143_qua__cold_d[] = @@ -554,11 +487,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__cook_fun_a[] = {{".2", u3we_cook_fun}, {}}; static c3_c* _143_qua__cook_ha[] = { - "7b58b2c3", 0, }; static c3_c* _143_qua__cook_fun_ha[] = { - "725a3063", 0, }; static u3j_core _143_qua__cook_d[] = @@ -568,11 +499,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__comp_fun_a[] = {{".2", u3we_comp_fun}, {}}; static c3_c* _143_qua__comp_ha[] = { - "ff1d7ca", 0, }; static c3_c* _143_qua__comp_fun_ha[] = { - "5a71faf5", 0, }; static u3j_core _143_qua__comp_d[] = @@ -582,11 +511,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__easy_fun_a[] = {{".2", u3we_easy_fun}, {}}; static c3_c* _143_qua__easy_ha[] = { - "7c0caf1b", + "bbdf198f84a73d758c1ccc5608159c6a1bfa72495fcd963e7327b9ccc26eded3", 0, }; static c3_c* _143_qua__easy_fun_ha[] = { - "13cb0749", + "b4b36293b7e9bfcc9029283fe8b770967073ef18d45f0eb4b90141e9c087ffec", 0, }; static u3j_core _143_qua__easy_d[] = @@ -596,11 +525,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__glue_fun_a[] = {{".2", u3we_glue_fun}, {}}; static c3_c* _143_qua__glue_ha[] = { - "7bf23949", 0, }; static c3_c* _143_qua__glue_fun_ha[] = { - "7d709001", 0, }; static u3j_core _143_qua__glue_d[] = @@ -610,11 +537,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__here_fun_a[] = {{".2", u3we_here_fun}, {}}; static c3_c* _143_qua__here_ha[] = { - "6392963e", 0, }; static c3_c* _143_qua__here_fun_ha[] = { - "72522b7d", 0, }; static u3j_core _143_qua__here_d[] = @@ -624,11 +549,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__just_fun_a[] = {{".2", u3we_just_fun}, {}}; static c3_c* _143_qua__just_ha[] = { - "295a2fbe", 0, }; static c3_c* _143_qua__just_fun_ha[] = { - "50d2f368", 0, }; static u3j_core _143_qua__just_d[] = @@ -638,11 +561,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__mask_fun_a[] = {{".2", u3we_mask_fun}, {}}; static c3_c* _143_qua__mask_ha[] = { - "25f3cc5e", 0, }; static c3_c* _143_qua__mask_fun_ha[] = { - "5fb25be8", 0, }; static u3j_core _143_qua__mask_d[] = @@ -652,11 +573,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__shim_fun_a[] = {{".2", u3we_shim_fun}, {}}; static c3_c* _143_qua__shim_ha[] = { - "53e64202", 0, }; static c3_c* _143_qua__shim_fun_ha[] = { - "61c4cfac", 0, }; static u3j_core _143_qua__shim_d[] = @@ -666,11 +585,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__stag_fun_a[] = {{".2", u3we_stag_fun}, {}}; static c3_c* _143_qua__stag_ha[] = { - "50e7e0d9", 0, }; static c3_c* _143_qua__stag_fun_ha[] = { - "5347a0fe", 0, }; static u3j_core _143_qua__stag_d[] = @@ -680,11 +597,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__stew_fun_a[] = {{".2", u3we_stew_fun}, {}}; static c3_c* _143_qua__stew_ha[] = { - "23a21615", 0, }; static c3_c* _143_qua__stew_fun_ha[] = { - "74d4c941", 0, }; static u3j_core _143_qua__stew_d[] = @@ -694,11 +609,9 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__stir_fun_a[] = {{".2", u3we_stir_fun}, {}}; static c3_c* _143_qua__stir_ha[] = { - "1e2b7159", 0, }; static c3_c* _143_qua__stir_fun_ha[] = { - "261f565a", 0, }; static u3j_core _143_qua__stir_d[] = @@ -709,29 +622,25 @@ static u3j_core _143_pen_d[] = // static u3j_harm _143_qua_pfix_a[] = {{".2", u3we_pfix}, {}}; static u3j_harm _143_qua_plug_a[] = {{".2", u3we_plug}, {}}; static c3_c* _143_qua__plug_ha[] = { - "11b6a2f8", 0, }; static u3j_harm _143_qua_pose_a[] = {{".2", u3we_pose}, {}}; static c3_c* _143_qua__pose_ha[] = { - "6fb235ed", 0, }; //static u3j_harm _143_qua_sfix_a[] = {{".2", u3we_sfix}, {}}; static u3j_harm _143_qua_mink_a[] = {{".2", u3we_mink}, {}}; static c3_c* _143_qua_mink_ha[] = { - "43ee7fca", 0, }; static u3j_harm _143_qua_mule_a[] = {{".2", u3we_mule}, {}}; static c3_c* _143_qua_mule_ha[] = { - "49cb9b2d", 0, }; static c3_c* _143_qua_ha[] = { - "7f2af46e", + "a8e494c95b4f2d7e74100c8aa9d0797ff6a3a9b5e6bd3dfbc0ebe56c2e46b499", 0, }; static u3j_hood _143_qua_ho[] = { @@ -774,17 +683,14 @@ static u3j_core _143_qua_d[] = */ static u3j_harm _143_tri__cofl__drg_a[] = {{".2", u3wef_drg}, {}}; static c3_c* _143_tri__cofl__drg_ha[] = { - "6bc6a27f", 0, }; static u3j_harm _143_tri__cofl__lug_a[] = {{".2", u3wef_lug}, {}}; static c3_c* _143_tri__cofl__lug_ha[] = { - "6a832f4a", 0, }; static c3_c* _143_tri__cofl_ha[] = { - "40faaf3d", 0, }; static u3j_core _143_tri__cofl_d[] = @@ -795,62 +701,50 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rd_add_a[] = {{".2", u3wer_add}, {}}; static c3_c* _143_tri__rd_add_ha[] = { - "7048f323", 0, }; static u3j_harm _143_tri__rd_sub_a[] = {{".2", u3wer_sub}, {}}; static c3_c* _143_tri__rd_sub_ha[] = { - "1ad8be65", 0, }; static u3j_harm _143_tri__rd_mul_a[] = {{".2", u3wer_mul}, {}}; static c3_c* _143_tri__rd_mul_ha[] = { - "3e41a14c", 0, }; static u3j_harm _143_tri__rd_div_a[] = {{".2", u3wer_div}, {}}; static c3_c* _143_tri__rd_div_ha[] = { - "3de7319", 0, }; static u3j_harm _143_tri__rd_sqt_a[] = {{".2", u3wer_sqt}, {}}; static c3_c* _143_tri__rd_sqt_ha[] = { - "18702e43", 0, }; static u3j_harm _143_tri__rd_fma_a[] = {{".2", u3wer_fma}, {}}; static c3_c* _143_tri__rd_fma_ha[] = { - "53a45898", 0, }; static u3j_harm _143_tri__rd_lth_a[] = {{".2", u3wer_lth}, {}}; static c3_c* _143_tri__rd_lth_ha[] = { - "36d33edb", 0, }; static u3j_harm _143_tri__rd_lte_a[] = {{".2", u3wer_lte}, {}}; static c3_c* _143_tri__rd_lte_ha[] = { - "491cde75", 0, }; static u3j_harm _143_tri__rd_equ_a[] = {{".2", u3wer_equ}, {}}; static c3_c* _143_tri__rd_equ_ha[] = { - "78a6abee", 0, }; static u3j_harm _143_tri__rd_gte_a[] = {{".2", u3wer_gte}, {}}; static c3_c* _143_tri__rd_gte_ha[] = { - "126a123a", 0, }; static u3j_harm _143_tri__rd_gth_a[] = {{".2", u3wer_gth}, {}}; static c3_c* _143_tri__rd_gth_ha[] = { - "715df27e", 0, }; static c3_c* _143_tri__rd_ha[] = { - "4ffd8caa", 0, }; static u3j_core _143_tri__rd_d[] = @@ -870,62 +764,50 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rs_add_a[] = {{".2", u3wet_add}, {}}; static c3_c* _143_tri__rs_add_ha[] = { - "5caecd3f", 0, }; static u3j_harm _143_tri__rs_sub_a[] = {{".2", u3wet_sub}, {}}; static c3_c* _143_tri__rs_sub_ha[] = { - "173e6bad", 0, }; static u3j_harm _143_tri__rs_mul_a[] = {{".2", u3wet_mul}, {}}; static c3_c* _143_tri__rs_mul_ha[] = { - "415d9955", 0, }; static u3j_harm _143_tri__rs_div_a[] = {{".2", u3wet_div}, {}}; static c3_c* _143_tri__rs_div_ha[] = { - "3329bdd5", 0, }; static u3j_harm _143_tri__rs_sqt_a[] = {{".2", u3wet_sqt}, {}}; static c3_c* _143_tri__rs_sqt_ha[] = { - "49532826", 0, }; static u3j_harm _143_tri__rs_fma_a[] = {{".2", u3wet_fma}, {}}; static c3_c* _143_tri__rs_fma_ha[] = { - "49982fc4", 0, }; static u3j_harm _143_tri__rs_lth_a[] = {{".2", u3wet_lth}, {}}; static c3_c* _143_tri__rs_lth_ha[] = { - "66b83fc2", 0, }; static u3j_harm _143_tri__rs_lte_a[] = {{".2", u3wet_lte}, {}}; static c3_c* _143_tri__rs_lte_ha[] = { - "1b9b2138", 0, }; static u3j_harm _143_tri__rs_equ_a[] = {{".2", u3wet_equ}, {}}; static c3_c* _143_tri__rs_equ_ha[] = { - "7c8d7e92", 0, }; static u3j_harm _143_tri__rs_gte_a[] = {{".2", u3wet_gte}, {}}; static c3_c* _143_tri__rs_gte_ha[] = { - "108efdb2", 0, }; static u3j_harm _143_tri__rs_gth_a[] = {{".2", u3wet_gth}, {}}; static c3_c* _143_tri__rs_gth_ha[] = { - "234b18f2", 0, }; static c3_c* _143_tri__rs_ha[] = { - "17be2d00", 0, }; static u3j_core _143_tri__rs_d[] = @@ -945,62 +827,50 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rq_add_a[] = {{".2", u3weq_add}, {}}; static c3_c* _143_tri__rq_add_ha[] = { - "4e9ad2ff", 0, }; static u3j_harm _143_tri__rq_sub_a[] = {{".2", u3weq_sub}, {}}; static c3_c* _143_tri__rq_sub_ha[] = { - "790f27d0", 0, }; static u3j_harm _143_tri__rq_mul_a[] = {{".2", u3weq_mul}, {}}; static c3_c* _143_tri__rq_mul_ha[] = { - "2736c015", 0, }; static u3j_harm _143_tri__rq_div_a[] = {{".2", u3weq_div}, {}}; static c3_c* _143_tri__rq_div_ha[] = { - "3e712c94", 0, }; static u3j_harm _143_tri__rq_sqt_a[] = {{".2", u3weq_sqt}, {}}; static c3_c* _143_tri__rq_sqt_ha[] = { - "3ab76743", 0, }; static u3j_harm _143_tri__rq_fma_a[] = {{".2", u3weq_fma}, {}}; static c3_c* _143_tri__rq_fma_ha[] = { - "43a1789d", 0, }; static u3j_harm _143_tri__rq_lth_a[] = {{".2", u3weq_lth}, {}}; static c3_c* _143_tri__rq_lth_ha[] = { - "496728a7", 0, }; static u3j_harm _143_tri__rq_lte_a[] = {{".2", u3weq_lte}, {}}; static c3_c* _143_tri__rq_lte_ha[] = { - "69e67508", 0, }; static u3j_harm _143_tri__rq_equ_a[] = {{".2", u3weq_equ}, {}}; static c3_c* _143_tri__rq_equ_ha[] = { - "10df371e", 0, }; static u3j_harm _143_tri__rq_gte_a[] = {{".2", u3weq_gte}, {}}; static c3_c* _143_tri__rq_gte_ha[] = { - "2d2bc726", 0, }; static u3j_harm _143_tri__rq_gth_a[] = {{".2", u3weq_gth}, {}}; static c3_c* _143_tri__rq_gth_ha[] = { - "409446ea", 0, }; static c3_c* _143_tri__rq_ha[] = { - "70532c78", 0, }; static u3j_core _143_tri__rq_d[] = @@ -1020,62 +890,50 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rh_add_a[] = {{".2", u3wes_add}, {}}; static c3_c* _143_tri__rh_add_ha[] = { - "3ca2bbf6", 0, }; static u3j_harm _143_tri__rh_sub_a[] = {{".2", u3wes_sub}, {}}; static c3_c* _143_tri__rh_sub_ha[] = { - "6873f5b9", 0, }; static u3j_harm _143_tri__rh_mul_a[] = {{".2", u3wes_mul}, {}}; static c3_c* _143_tri__rh_mul_ha[] = { - "26ac0f6c", 0, }; static u3j_harm _143_tri__rh_div_a[] = {{".2", u3wes_div}, {}}; static c3_c* _143_tri__rh_div_ha[] = { - "284818ec", 0, }; static u3j_harm _143_tri__rh_sqt_a[] = {{".2", u3wes_sqt}, {}}; static c3_c* _143_tri__rh_sqt_ha[] = { - "50a508d3", 0, }; static u3j_harm _143_tri__rh_fma_a[] = {{".2", u3wes_fma}, {}}; static c3_c* _143_tri__rh_fma_ha[] = { - "6ee2c6f8", 0, }; static u3j_harm _143_tri__rh_lth_a[] = {{".2", u3wes_lth}, {}}; static c3_c* _143_tri__rh_lth_ha[] = { - "95c5f8a", 0, }; static u3j_harm _143_tri__rh_lte_a[] = {{".2", u3wes_lte}, {}}; static c3_c* _143_tri__rh_lte_ha[] = { - "5671246d", 0, }; static u3j_harm _143_tri__rh_equ_a[] = {{".2", u3wes_equ}, {}}; static c3_c* _143_tri__rh_equ_ha[] = { - "55ba38f6", 0, }; static u3j_harm _143_tri__rh_gte_a[] = {{".2", u3wes_gte}, {}}; static c3_c* _143_tri__rh_gte_ha[] = { - "7ca6938e", 0, }; static u3j_harm _143_tri__rh_gth_a[] = {{".2", u3wes_gth}, {}}; static c3_c* _143_tri__rh_gth_ha[] = { - "5df9d6aa", 0, }; static c3_c* _143_tri__rh_ha[] = { - "240f9e45", 0, }; static u3j_core _143_tri__rh_d[] = @@ -1095,12 +953,10 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__og_raw_a[] = {{".2", u3weo_raw}, {}}; static c3_c* _143_tri__og_raw_ha[] = { - "2b65a131", 0, }; static c3_c* _143_tri__og_ha[] = { - "65c7f2b6", 0, }; static u3j_core _143_tri__og_d[] = @@ -1110,12 +966,10 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri_shax_a[] = {{".2", u3we_shax}, {}}; static c3_c* _143_tri_shax_ha[] = { - "2d81b3eb", 0, }; static u3j_harm _143_tri_shay_a[] = {{".2", u3we_shay}, {}}; static c3_c* _143_tri_shay_ha[] = { - "3081f15b", 0, }; /* XX: no hint @@ -1127,16 +981,11 @@ static u3j_core _143_qua_d[] = */ static u3j_harm _143_tri_shal_a[] = {{".2", u3we_shal}, {}}; static c3_c* _143_tri_shal_ha[] = { - "63ea0b00", - 0, - }; - static u3j_harm _143_tri_shux_a[] = {{".2", u3we_shux}, {}}; - static c3_c* _143_tri_shux_ha[] = { 0, }; static c3_c* _143_tri_ha[] = { - "6cc318e2", + "3532a5d4a01664989f527f0c42399d5a8e6e6e32f2542cde39da918d3b9ec41a", 0, }; static u3j_core _143_tri_d[] = @@ -1152,7 +1001,6 @@ static u3j_core _143_tri_d[] = { "shay", 7, _143_tri_shay_a, 0, _143_tri_shay_ha }, // { "shas", 7, _143_tri_shas_a, 0, _143_tri_shas_ha }, { "shal", 7, _143_tri_shal_a, 0, _143_tri_shal_ha }, - { "shux", 7, _143_tri_shux_a, 0, _143_tri_shux_ha }, {} }; @@ -1160,27 +1008,22 @@ static u3j_core _143_tri_d[] = */ static u3j_harm _143_two_flop_a[] = {{".2", u3wb_flop, c3y}, {}}; static c3_c* _143_two_flop_ha[] = { - "41e43e64", 0, }; static u3j_harm _143_two_lent_a[] = {{".2", u3wb_lent, c3y}, {}}; static c3_c* _143_two_lent_ha[] = { - "1dfd0931", 0, }; static u3j_harm _143_two_levy_a[] = {{".2", u3wb_levy, c3y}, {}}; static c3_c* _143_two_levy_ha[] = { - "35460246", 0, }; static u3j_harm _143_two_lien_a[] = {{".2", u3wb_lien, c3y}, {}}; static c3_c* _143_two_lien_ha[] = { - "26fe83d7", 0, }; static u3j_harm _143_two_murn_a[] = {{".2", u3wb_murn, c3y}, {}}; static c3_c* _143_two_murn_ha[] = { - "7267235b", 0, }; /* XX: no hint @@ -1192,199 +1035,157 @@ static u3j_core _143_tri_d[] = */ static u3j_harm _143_two_reap_a[] = {{".2", u3wb_reap, c3y}, {}}; static c3_c* _143_two_reap_ha[] = { - "1808a81d", 0, }; static u3j_harm _143_two_reel_a[] = {{".2", u3wb_reel, c3y}, {}}; static c3_c* _143_two_reel_ha[] = { - "660c4ee9", 0, }; static u3j_harm _143_two_roll_a[] = {{".2", u3wb_roll, c3y}, {}}; static c3_c* _143_two_roll_ha[] = { - "3c16e592", 0, }; static u3j_harm _143_two_skid_a[] = {{".2", u3wb_skid, c3y}, {}}; static c3_c* _143_two_skid_ha[] = { - "3dc45cc", 0, }; static u3j_harm _143_two_skim_a[] = {{".2", u3wb_skim, c3y}, {}}; static c3_c* _143_two_skim_ha[] = { - "36892702", 0, }; static u3j_harm _143_two_skip_a[] = {{".2", u3wb_skip, c3y}, {}}; static c3_c* _143_two_skip_ha[] = { - "580714ad", 0, }; static u3j_harm _143_two_scag_a[] = {{".2", u3wb_scag, c3y}, {}}; static c3_c* _143_two_scag_ha[] = { - "6d492573", 0, }; static u3j_harm _143_two_slag_a[] = {{".2", u3wb_slag, c3y}, {}}; static c3_c* _143_two_slag_ha[] = { - "6a9fe551", 0, }; static u3j_harm _143_two_snag_a[] = {{".2", u3wb_snag, c3y}, {}}; static c3_c* _143_two_snag_ha[] = { - "da6440d", 0, }; // static u3j_harm _143_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; static u3j_harm _143_two_turn_a[] = {{".2", u3wb_turn, c3y}, {}}; static c3_c* _143_two_turn_ha[] = { - "6edb42", 0, }; static u3j_harm _143_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; static c3_c* _143_two_weld_ha[] = { - "752d9421", 0, }; static u3j_harm _143_two_bex_a[] = {{".2", u3wc_bex, c3y}, {}}; static c3_c* _143_two_bex_ha[] = { - "6c223bad", 0, }; static u3j_harm _143_two_can_a[] = {{".2", u3wc_can, c3y}, {}}; static c3_c* _143_two_can_ha[] = { - "6039dee0", 0, }; static u3j_harm _143_two_cat_a[] = {{".2", u3wc_cat, c3y}, {}}; static c3_c* _143_two_cat_ha[] = { - "408a97e8", 0, }; static u3j_harm _143_two_con_a[] = {{".2", u3wc_con, c3y}, {}}; static c3_c* _143_two_con_ha[] = { - "49ff881", 0, }; static u3j_harm _143_two_cut_a[] = {{".2", u3wc_cut, c3y}, {}}; static c3_c* _143_two_cut_ha[] = { - "2c8d7897", 0, }; static u3j_harm _143_two_dis_a[] = {{".2", u3wc_dis, c3y}, {}}; static c3_c* _143_two_dis_ha[] = { - "135fb298", 0, }; static u3j_harm _143_two_dor_a[] = {{".2", u3wc_dor, c3y}, {}}; static c3_c* _143_two_dor_ha[] = { - "5c0d99f7", 0, }; static u3j_harm _143_two_end_a[] = {{".2", u3wc_end, c3y}, {}}; static c3_c* _143_two_end_ha[] = { - "3fb28e44", 0, }; static u3j_harm _143_two_gor_a[] = {{".2", u3wc_gor, c3y}, {}}; static c3_c* _143_two_gor_ha[] = { - "17eba2b9", 0, }; static u3j_harm _143_two_hor_a[] = {{".2", u3wc_hor, c3y}, {}}; static c3_c* _143_two_hor_ha[] = { - "4a7e5d16", 0, }; static u3j_harm _143_two_lsh_a[] = {{".2", u3wc_lsh, c3y}, {}}; static c3_c* _143_two_lsh_ha[] = { - "41b3a4c7", 0, }; static u3j_harm _143_two_met_a[] = {{".2", u3wc_met, c3y}, {}}; static c3_c* _143_two_met_ha[] = { - "51509f40", 0, }; static u3j_harm _143_two_mix_a[] = {{".2", u3wc_mix, c3y}, {}}; static c3_c* _143_two_mix_ha[] = { - "76bbeb8a", 0, }; static u3j_harm _143_two_mug_a[] = {{".2", u3wc_mug, c3y}, {}}; static c3_c* _143_two_mug_ha[] = { - "11404a2", 0, }; static u3j_harm _143_two_muk_a[] = {{".2", u3wc_muk, c3y}, {}}; static c3_c* _143_two_muk_ha[] = { - "482e58af", - 0, - }; - static u3j_harm _143_two_mux_a[] = {{".2", u3wc_mux, c3y}, {}}; - static c3_c* _143_two_mux_ha[] = { 0, }; static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; static c3_c* _143_two_pow_ha[] = { - "4a70ddfe", 0, }; static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}}; static c3_c* _143_two_rap_ha[] = { - "7a6875bb", 0, }; static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}}; static c3_c* _143_two_rep_ha[] = { - "53e80eb3", 0, }; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; static c3_c* _143_two_rip_ha[] = { - "54970200", 0, }; static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}}; static c3_c* _143_two_rsh_ha[] = { - "7c0c8df2", 0, }; static u3j_harm _143_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static c3_c* _143_two_sqt_ha[] = { - "50929e0b", 0, }; static u3j_harm _143_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _143_two_vor_ha[] = { - "2b05b267", 0, }; static u3j_harm _143_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; static c3_c* _143_two_xeb_ha[] = { - "5e2bcea8", 0, }; static u3j_harm _143_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _143_two__in_bif_ha[] = { - "16e17df9", 0, }; static u3j_harm _143_two__in_dif_a[] = {{".2", u3wdi_dif}, {}}; static c3_c* _143_two__in_dif_ha[] = { - "4ced9091", 0, }; static u3j_harm _143_two__in_gas_a[] = {{".2", u3wdi_gas}, {}}; static c3_c* _143_two__in_gas_ha[] = { - "4dbdbab4", 0, }; static u3j_harm _143_two__in_has_a[] = {{".2", u3wdi_has}, {}}; static c3_c* _143_two__in_has_ha[] = { - "39a46ced", 0, }; /* XX: mer doesn't exist any more? @@ -1397,27 +1198,22 @@ static u3j_core _143_tri_d[] = // static u3j_harm _143_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _143_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static c3_c* _143_two__in_put_ha[] = { - "57cf34a9", 0, }; static u3j_harm _143_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; static c3_c* _143_two__in_tap_ha[] = { - "70881f1a", 0, }; static u3j_harm _143_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; static c3_c* _143_two__in_wyt_ha[] = { - "71887a13", 0, }; static u3j_harm _143_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static c3_c* _143_two__in_uni_ha[] = { - "26e34913", 0, }; static c3_c* _143_two__in_ha[] = { - "51074d19", 0, }; static u3j_core _143_two__in_d[] = @@ -1436,44 +1232,36 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}}; static c3_c* _143_two__by_bif_ha[] = { - "4e6aedd2", 0, }; static u3j_harm _143_two__by_dif_a[] = {{".2", u3wdb_dif, c3y}, {}}; static c3_c* _143_two__by_dif_ha[] = { - "1388fad7", 0, }; static u3j_harm _143_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}}; static c3_c* _143_two__by_gas_ha[] = { - "5a8a7e7d", 0, }; static u3j_harm _143_two__by_get_a[] = {{".2", u3wdb_get, c3y}, {}}; static c3_c* _143_two__by_get_ha[] = { - "ece3b4d", 0, }; static u3j_harm _143_two__by_has_a[] = {{".2", u3wdb_has, c3y}, {}}; static c3_c* _143_two__by_has_ha[] = { - "373d538d", 0, }; // static u3j_harm _143_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; static u3j_harm _143_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; static c3_c* _143_two__by_put_ha[] = { - "2c511da5", 0, }; static u3j_harm _143_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; static c3_c* _143_two__by_tap_ha[] = { - "70881f1a", 0, }; // static u3j_harm _143_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; static c3_c* _143_two__by_ha[] = { - "76d3df01", 0, }; static u3j_core _143_two__by_d[] = @@ -1491,27 +1279,23 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_cue_a[] = {{".2", u3we_cue}, {}}; static c3_c* _143_two_cue_ha[] = { - "6f20da6b", 0, }; static u3j_harm _143_two_jam_a[] = {{".2", u3we_jam}, {}}; static c3_c* _143_two_jam_ha[] = { - "4103997f", 0, }; static u3j_harm _143_two_mat_a[] = {{".2", u3we_mat}, {}}; static c3_c* _143_two_mat_ha[] = { - "1a2c351b", 0, }; static u3j_harm _143_two_rub_a[] = {{".2", u3we_rub}, {}}; static c3_c* _143_two_rub_ha[] = { - "56b1242e", 0, }; static c3_c* _143_two_ha[] = { - "613c4d6d", + "aa20f6b35462ffcf6903536717dccd9f9a77f856ba9eee3a8cd5e39440a479a9", 0, }; static u3j_core _143_two_d[] = @@ -1552,7 +1336,6 @@ static u3j_core _143_two_d[] = { "met", 7, _143_two_met_a, 0, _143_two_met_ha }, { "mix", 7, _143_two_mix_a, 0, _143_two_mix_ha }, { "mug", 7, _143_two_mug_a, 0, _143_two_mug_ha }, - { "mux", 7, _143_two_mux_a, 0, _143_two_mux_ha }, { "muk", 59, _143_two_muk_a, 0, _143_two_muk_ha }, { "rap", 7, _143_two_rap_a, 0, _143_two_rap_ha }, { "rep", 7, _143_two_rep_a, 0, _143_two_rep_ha }, @@ -1574,77 +1357,63 @@ static u3j_core _143_two_d[] = */ static u3j_harm _143_one_add_a[] = {{".2", u3wa_add, c3y}, {}}; static c3_c* _143_one_add_ha[] = { - "68a25eb6", 0, }; static u3j_harm _143_one_dec_a[] = {{".2", u3wa_dec, c3y}, {}}; static c3_c* _143_one_dec_ha[] = { - "ce60540", 0, }; static u3j_harm _143_one_div_a[] = {{".2", u3wa_div, c3y}, {}}; static c3_c* _143_one_div_ha[] = { - "3457adb3", 0, }; static u3j_harm _143_one_dvr_a[] = {{".2", u3wc_dvr, c3y}, {}}; static c3_c* _143_one_dvr_ha[] = { - "20cdcad0", 0, }; static u3j_harm _143_one_gte_a[] = {{".2", u3wa_gte, c3y}, {}}; static c3_c* _143_one_gte_ha[] = { - "8542678", 0, }; static u3j_harm _143_one_gth_a[] = {{".2", u3wa_gth, c3y}, {}}; static c3_c* _143_one_gth_ha[] = { - "7555a49a", 0, }; static u3j_harm _143_one_lte_a[] = {{".2", u3wa_lte, c3y}, {}}; static c3_c* _143_one_lte_ha[] = { - "6fc5ac17", 0, }; static u3j_harm _143_one_lth_a[] = {{".2", u3wa_lth, c3y}, {}}; static c3_c* _143_one_lth_ha[] = { - "ef85ae3", 0, }; static u3j_harm _143_one_mod_a[] = {{".2", u3wa_mod, c3y}, {}}; static c3_c* _143_one_mod_ha[] = { - "1ccddd83", 0, }; static u3j_harm _143_one_mul_a[] = {{".2", u3wa_mul, c3y}, {}}; static c3_c* _143_one_mul_ha[] = { - "679b5099", 0, }; static u3j_harm _143_one_sub_a[] = {{".2", u3wa_sub, c3y}, {}}; static c3_c* _143_one_sub_ha[] = { - "5e25e8d4", 0, }; static u3j_harm _143_one_cap_a[] = {{".2", u3wc_cap, c3y}, {}}; static c3_c* _143_one_cap_ha[] = { - "7d28acf4", 0, }; static u3j_harm _143_one_peg_a[] = {{".2", u3wc_peg, c3y}, {}}; static c3_c* _143_one_peg_ha[] = { - "4ecc0289", 0, }; static u3j_harm _143_one_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; static c3_c* _143_one_mas_ha[] = { - "611f2aab", 0, }; static c3_c* _143_one_ha[] = { - "c4b5bd8", + "f04034ab0335ab53292f74127065b609b8b99bd9905f51a8254ef4580b84aaf3", 0, }; static u3j_core _143_one_d[] = @@ -1669,8 +1438,8 @@ static u3j_core _143_one_d[] = }; static c3_c* _k143_ha[] = { - "13e199f7", - 0 + "11ef831e540bfe588cde998b55e7d8cd58bb35898774b19f9164328c5cb3c637", + 0, }; u3j_core _k143_d[] = { { "one", 3, 0, _143_one_d, _143_one_ha }, diff --git a/noun/jets.c b/noun/jets.c index 725e21d72..15a96fdcf 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -78,19 +78,35 @@ _cj_core_loc(u3_noun pel, u3j_core* cop_u) static u3_noun _cj_hash(c3_c* has_c) { - c3_l mug; - sscanf(has_c, "%x", &mug); - return mug; + c3_w i_w, len_w = strlen(has_c); + if ( 64 != len_w ) { + fprintf(stderr, "bash not 64 characters: %s\r\n", has_c); + c3_assert(0); + } + c3_assert( 64 == len_w ); + c3_y dig_y[32]; + for ( i_w = 0; i_w < 64; ) { + c3_y hi_y = has_c[i_w++], + lo_y = has_c[i_w++], + hid_y = hi_y >= 'a' ? (hi_y - 'a') + 10 : hi_y - '0', + lod_y = lo_y >= 'a' ? (lo_y - 'a') + 10 : lo_y - '0'; + dig_y[32-(i_w>>1)] = hid_y << 4 | lod_y; + } + u3_noun pro = u3i_bytes(32, dig_y); + //fprintf(stderr, "has_c: %s\r\n", has_c); + //u3m_p("pro", pro); + return pro; } +/* typedef struct { #if defined(U3_OS_osx) CC_SHA256_CTX ctx_h; #else SHA256_CTX ctx_h; #endif - c3_s inx_s; - c3_y buf_y[65536]; + c3_w len_w; + c3_w buf_w[65536]; } _cj_sha; static void @@ -107,8 +123,8 @@ static void _cj_digest_flush(_cj_sha* sha_u) { if ( sha_u->inx_s ) { - _cj_digest_update(sha_u, sha_u->buf_y, sha_u->inx_s); - sha_u->inx_s = 0; + _cj_digest_update(sha_u, sha_u->buf_w, sha_u->inx_s); + sha_u->len_w = 0; } } @@ -118,21 +134,29 @@ _cj_digest_write(_cj_sha* sha_u, u3_atom a) c3_w met_w = u3r_met(3, a), law_w = u3r_met(3, met_w); - if ( (law_w + met_w) > 65536 ) { - c3_y* big_y = u3a_malloc(met_w); - u3r_bytes(0, met_w, big_y, a); - _cj_digest_flush(sha_u); - _cj_digest_update(sha_u, big_y, met_w); - u3a_free(big_y); - } - else { - if ( (sha_u->inx_s + met_w + law_w ) > 65536 ) { + if ( 0 == law_w ) { + if ( sha_u->inx_s == 65535 ) { _cj_digest_flush(sha_u); } - u3r_bytes(0, law_w, sha_u->buf_y + sha_u->inx_s, law_w); - sha_u->inx_s += (c3_s) law_w; - u3r_bytes(0, met_w, sha_u->buf_y + sha_u->inx_s, a); - sha_u->inx_s += (c3_s) met_w; + sha_u->buf_y[sha_u->inx_s++] = 0; + } + else { + if ( (law_w + met_w) > 65536 ) { + c3_y* big_y = u3a_malloc(met_w); + u3r_bytes(0, met_w, big_y, a); + _cj_digest_flush(sha_u); + _cj_digest_update(sha_u, big_y, met_w); + u3a_free(big_y); + } + else { + if ( (sha_u->inx_s + met_w + law_w ) > 65536 ) { + _cj_digest_flush(sha_u); + } + u3r_bytes(0, law_w, sha_u->buf_y + sha_u->inx_s, law_w); + sha_u->inx_s += (c3_s) law_w; + u3r_bytes(0, met_w, sha_u->buf_y + sha_u->inx_s, a); + sha_u->inx_s += (c3_s) met_w; + } } } @@ -148,6 +172,7 @@ _cj_digest_final(_cj_sha* sha_u) return u3i_bytes(32, dig_y); } + static void _cj_digest_init(_cj_sha* sha_u) { @@ -210,6 +235,7 @@ _cj_digest(u3_noun a) _cj_digest_flush(&sha_u); return _cj_digest_final(&sha_u); } +*/ /* _cj_bash(): battery hash. RETAIN. */ @@ -229,8 +255,11 @@ _cj_bash(u3_noun bat) rod_u = u3to(u3_road, rod_u->par_p); } else { - pro = _cj_digest(bat); + u3_noun jan = u3qe_jam(bat); + pro = u3qe_shax(jan); + //pro = u3qe_sham(bat); u3h_put(u3R->jed.bas_p, bat, u3k(pro)); + u3z(jan); break; } } @@ -737,7 +766,7 @@ _cj_spot(u3_noun cor, u3_weak* bas) u3_weak act = _cj_spot_hot(cor, *bas, &loc); if ( u3_none != act ) { reg = _cj_gust(reg, _cj_loc_axe(loc), _cj_loc_pel(loc), u3k(loc)); - u3h_put(u3R->jed.cod_p, u3h(cor), u3k(reg)); + u3h_put(u3R->jed.cod_p, u3h(cor), u3nc(u3k(*bas), u3k(reg))); /* caution: could overwrites old value, debug batteries etc. ** old value contains old _cj_jit (from different ** battery). if we change jit to (map battery *), @@ -951,7 +980,6 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) strncpy(soc_c, cop_u->cos_c, 5); soc_c[5] = 0; cod_w = u3i_string(soc_c); - cod_w = u3a_lush(cod_w); } #endif @@ -1862,15 +1890,20 @@ _cj_mine(u3_noun cey, u3_noun cor, u3_noun bas) fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); #endif if ( jax_l ) { + c3_y dig_y[32]; + c3_w i_w; u3_noun i = bal; fprintf(stderr, "hot jet: "); while ( i != u3_nul ) { _cj_print_tas(stderr, u3h(i)); i = u3t(i); } - fprintf(stderr, "\r\n "); - u3m_p("bash", bas); - fprintf(stderr, " axe %d, jax %d\r\n", axe, jax_l); + fprintf(stderr, "\r\n axe %d, jax %d,\r\n bash ", axe, jax_l); + u3r_bytes(0, 32, dig_y, bas); + for ( i_w = 32; i_w > 0; ) { + fprintf(stderr, "%02x", dig_y[--i_w]); + } + fprintf(stderr, "\r\n"); } hap = _cj_warm_hump(jax_l, u3t(u3t(loc))); act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); From 9fdf806f1421f5549aa937c06110ec95295e3160 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 29 May 2018 21:52:07 -0700 Subject: [PATCH 128/221] start with a bigger buffer for jam --- jets/e/jam.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 017b6a4a8..99ada12ad 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -85,8 +85,8 @@ _jam_buf_top(u3_noun a) c3_o cel_o; c3_w a_w, c_w, wor_w, len_w, *sal_w; - buf_u.a_w = 10946; // fib(21) # of bits starting in wor_w - buf_u.b_w = 6765; // fib(20) roughly 1K, a good start + buf_u.a_w = 14930352; // fib(36) # of bits starting in wor_w + buf_u.b_w = 9227465; // fib(35) wor_w = (buf_u.a_w>>5); if ( (wor_w<<5) != buf_u.a_w ) { ++wor_w; From d4e27d38a0b3f9919ea25cc81c6408737dc2d6f3 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 May 2018 09:49:04 -0700 Subject: [PATCH 129/221] simplify _jam_buf_top --- jets/e/jam.c | 120 +++++++++++++++++++-------------------------------- 1 file changed, 45 insertions(+), 75 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 99ada12ad..b5d61a568 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -14,11 +14,6 @@ typedef struct { c3_w* wor_w; } _jam_buf; -typedef struct { - c3_y sat_y; - u3_noun a; -} _jam_frame; - static void _jam_buf_grow(_jam_buf* buf_u, c3_w mor_w) { @@ -76,96 +71,71 @@ _jam_buf_top(u3_noun a) { u3p(u3h_root) har_p = u3h_new(); c3_o nor_o = u3a_is_north(u3R); - c3_y wis_y = c3_wiseof(_jam_frame); + c3_y wis_y = c3_wiseof(u3_noun); c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); - _jam_frame* fam, *don = u3to(_jam_frame, u3R->cap_p + off); + u3_noun* top, *don = u3to(u3_noun, u3R->cap_p + off); _jam_buf buf_u; u3_weak c; c3_o cel_o; - c3_w a_w, c_w, wor_w, len_w, *sal_w; + c3_w* sal_w, len_w; buf_u.a_w = 14930352; // fib(36) # of bits starting in wor_w buf_u.b_w = 9227465; // fib(35) - wor_w = (buf_u.a_w>>5); - if ( (wor_w<<5) != buf_u.a_w ) { - ++wor_w; + len_w = buf_u.a_w >> 5; + if ( (len_w << 5) != buf_u.a_w ) { + ++len_w; } - buf_u.wor_w = u3a_calloc(wor_w, sizeof(c3_w)); + buf_u.wor_w = u3a_calloc(len_w, sizeof(c3_w)); buf_u.bit_w = 0; u3R->cap_p += mov; - fam = u3to(_jam_frame, u3R->cap_p + off); - fam->a = a; - fam->sat_y = JAM_NONE; + top = u3to(u3_noun, u3R->cap_p + off); + *top = a; - while ( fam != don ) { - switch ( fam->sat_y ) { - case JAM_NONE: - a = fam->a; - cel_o = u3du(a); - c = u3h_git(har_p, a); - if ( u3_none != c ) { - c_w = u3r_met(0, c); - if ( c3y == cel_o ) { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); - } - else { - a_w = u3r_met(0, a); - if ( a_w <= c_w ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); - } - else { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); - } - } - u3R->cap_p -= mov; - fam = u3to(_jam_frame, u3R->cap_p + off); + while ( top != don ) { + a = *top; + cel_o = u3du(a); + c = u3h_git(har_p, a); + if ( u3_none != c ) { + if ( c3y == cel_o ) { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); + } + else { + if ( u3r_met(0, a) <= u3r_met(0, c) ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); } else { - u3h_put(har_p, a, buf_u.bit_w); - if ( c3n == cel_o ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); - u3R->cap_p -= mov; - fam = u3to(_jam_frame, u3R->cap_p + off); - } - else { - fam->sat_y = JAM_HEAD; - - u3R->cap_p += mov; - fam = u3to(_jam_frame, u3R->cap_p + off); - fam->sat_y = JAM_NONE; - fam->a = u3h(a); - - _jam_buf_chop(&buf_u, 2, 1); - } + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); } - break; - - case JAM_HEAD: - a = fam->a; - fam->sat_y = JAM_TAIL; - - u3R->cap_p += mov; - fam = u3to(_jam_frame, u3R->cap_p + off); - fam->sat_y = JAM_NONE; - fam->a = u3t(a); - break; - - case JAM_TAIL: + } + u3R->cap_p -= mov; + top = u3to(u3_noun, u3R->cap_p + off); + } + else { + u3h_put(har_p, a, buf_u.bit_w); + if ( c3n == cel_o ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); u3R->cap_p -= mov; - fam = u3to(_jam_frame, u3R->cap_p + off); - break; + top = u3to(u3_noun, u3R->cap_p + off); + } + else { + _jam_buf_chop(&buf_u, 2, 1); + *top = u3t(a); + + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = u3h(a); + } } } - - len_w = (buf_u.bit_w>>5); - if ( (len_w<<5) != buf_u.bit_w ) { + len_w = buf_u.bit_w >> 5; + if ( (len_w << 5) != buf_u.bit_w ) { ++len_w; } sal_w = u3a_slab(len_w); From aaac65446eade4121da67515b6d02192887aa37c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 May 2018 11:10:58 -0700 Subject: [PATCH 130/221] actually smaller buffers to begin works better for small inputs --- jets/e/jam.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index b5d61a568..616c7b3c8 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -3,10 +3,6 @@ */ #include "all.h" -#define JAM_NONE 0 -#define JAM_HEAD 1 -#define JAM_TAIL 2 - typedef struct { c3_w a_w; c3_w b_w; @@ -80,8 +76,8 @@ _jam_buf_top(u3_noun a) c3_o cel_o; c3_w* sal_w, len_w; - buf_u.a_w = 14930352; // fib(36) # of bits starting in wor_w - buf_u.b_w = 9227465; // fib(35) + buf_u.a_w = 144; // fib(12) is small enough to be reasonably fast to allocate. + buf_u.b_w = 89; // fib(11) is needed to get fib(13). len_w = buf_u.a_w >> 5; if ( (len_w << 5) != buf_u.a_w ) { ++len_w; @@ -139,7 +135,7 @@ _jam_buf_top(u3_noun a) ++len_w; } sal_w = u3a_slab(len_w); - memcpy(sal_w, buf_u.wor_w, len_w<<2); + memcpy(sal_w, buf_u.wor_w, len_w*sizeof(c3_w)); u3a_free(buf_u.wor_w); u3h_free(har_p); return u3a_mint(sal_w, len_w); From c8f5fbe29fd640dd3de554536d89a7e1a0a6ba58 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 May 2018 11:22:59 -0700 Subject: [PATCH 131/221] moot, since we have already measured --- jets/e/jam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 616c7b3c8..908556736 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -138,7 +138,7 @@ _jam_buf_top(u3_noun a) memcpy(sal_w, buf_u.wor_w, len_w*sizeof(c3_w)); u3a_free(buf_u.wor_w); u3h_free(har_p); - return u3a_mint(sal_w, len_w); + return u3a_moot(sal_w); } /* functions From 88b7d23ed862b212f44f921b8838445f373c2e5e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 May 2018 11:32:10 -0700 Subject: [PATCH 132/221] fix reaming after changing cold dash --- noun/jets.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 15a96fdcf..3246c43ee 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1026,7 +1026,7 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) } else { -#if 0 +#if 1 fprintf(stderr, "test: %s %s\r\n", cop_u->cos_c, (!strcmp(".2", ham_u->fcs_c)) ? "$" : ham_u->fcs_c); @@ -2111,7 +2111,7 @@ u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p, u3p(u3h_ u3h_walk(bas_p, _cj_bash_reap); } -/* _cj_ream(): ream list of battery registry pairs. RETAIN. +/* _cj_ream(): ream list of battery [bash registry] pairs. RETAIN. */ static void _cj_ream(u3_noun all) @@ -2124,7 +2124,7 @@ _cj_ream(u3_noun all) for ( i = all, lop = u3_nul; i != u3_nul; i = u3t(i) ) { kev = u3h(i); bat = u3h(kev); - reg = u3t(kev); + reg = u3t(u3t(kev)); rut = u3h(reg); // register roots From cd013b9f4756280b15cbdc4848c1872c3824eaad Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 May 2018 13:33:13 -0700 Subject: [PATCH 133/221] adding some hashes --- jets/tree.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 124 insertions(+), 9 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 7d2ff0adf..950d1d141 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -134,6 +134,7 @@ static u3j_harm _143_hex_lore_a[] = {{".2", u3we_lore}, {}}; static c3_c* _143_hex_lore_ha[] = { + "2abdf1dd2b9e30333451a49c7a5890ab27c77603d4210aa4d1b8016d7bb730a7", 0, }; static u3j_harm _143_hex_loss_a[] = {{".2", u3we_loss}, {}}; @@ -147,10 +148,12 @@ static u3j_harm _143_hex_coed__ed_puck_a[] = {{".2", u3wee_puck}, {}}; static c3_c* _143_hex_coed__ed_puck_ha[] = { + "1327f1c0b31be786c5185086186814bbb6d8b44bc8ad26e651ad027e0e62844d", 0, }; static u3j_harm _143_hex_coed__ed_sign_a[] = {{".2", u3wee_sign}, {}}; static c3_c* _143_hex_coed__ed_sign_ha[] = { + "18c4367cbc8990c70610c6d43a42ab69693952997b4ff58eb675f1f14249bd0b", 0, }; static u3j_harm _143_hex_coed__ed_veri_a[] = {{".2", u3wee_veri}, {}}; @@ -163,6 +166,7 @@ }; static c3_c* _143_hex_coed__ed_ha[] = { + "aa922a96a00ba63a328b9f67c814e0cd006b830481834101de4b92e36533914c", 0, }; static u3j_core _143_hex_coed__ed_d[] = @@ -174,6 +178,7 @@ }; static c3_c* _143_hex_coed_ha[] = { + "84efc127c57ffa5ee61c12737816ef42e067fd64f8262f3df93481d8c905b2bf", 0, }; static u3j_core _143_hex_coed_d[] = @@ -182,6 +187,7 @@ static u3j_core _143_hex_coed_d[] = }; static c3_c* _143_hex_ha[] = { + "9cf8c9378dbb910e1130eb5aa30d12573943388613018c05a32f3d7d1d6c5ca2", 0, }; static u3j_core _143_hex_d[] = @@ -200,6 +206,7 @@ static u3j_core _143_hex_d[] = */ static u3j_harm _143_pen_cell_a[] = {{".2", u3wf_cell}, {}}; static c3_c* _143_pen_cell_ha[] = { + "1f3485acbf3f0159facb1e450bdcb67604fef3ebac979b7b78e254c2d4a9f81a", 0, }; static u3j_harm _143_pen_comb_a[] = {{".2", u3wf_comb}, {}}; @@ -212,14 +219,17 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen_core_a[] = {{".2", u3wf_core}, {}}; static c3_c* _143_pen_core_ha[] = { + "0b222d63259aba485c1ccede583507b6bba49bcceed4a89ad76f3bd9a37913bb", 0, }; static u3j_harm _143_pen_help_a[] = {{".2", u3wf_help}, {}}; static c3_c* _143_pen_help_ha[] = { + "fdf6593bc217b85d5ad2d9554af56d8c967f31215dc54a2195a1a131b876866b", 0, }; static u3j_harm _143_pen_face_a[] = {{".2", u3wf_face}, {}}; static c3_c* _143_pen_face_ha[] = { + "327dd91a9bdb8b70bd275d2ddeb688de0d9723d62605fe78f9557f77a9cbf8c9", 0, }; static u3j_harm _143_pen_fitz_a[] = {{".2", u3wf_fitz}, {}}; @@ -240,11 +250,13 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen_fork_a[] = {{".2", u3wf_fork}, {}}; static c3_c* _143_pen_fork_ha[] = { + "4b7999c53d8a82a5bab869ee9675c979138b8c9ad1cfaa44b0d67dec5cb56966", 0, }; static u3j_harm _143_pen_hike_a[] = {{".2", u3wf_hike}, {}}; static c3_c* _143_pen_hike_ha[] = { + "7503dc65fe3164b3e95f81b51afd64ab615e26516b60df95241244e2b793d024", 0, }; static u3j_harm _143_pen_look_a[] = {{".2", u3wf_look}, {}}; @@ -260,11 +272,13 @@ static u3j_core _143_hex_d[] = //static u3j_harm _143_pen__ut_conk_a[] = {{".2", u3wfu_conk}, {}}; static u3j_harm _143_pen__ut_crop_a[] = {{".2", u3wfu_crop}, {}}; static c3_c* _143_pen__ut_crop_ha[] = { + "7a0dc306776c8603556558009749aa0dd6d6077994d949fc29e5386ee1fb0ca7", 0, }; // static u3j_harm _143_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; static u3j_harm _143_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}}; static c3_c* _143_pen__ut_fond_ha[] = { + "e6f0ac3a903d7462a998093ee8772648dfa5f349c1a92c722c47236173780584", 0, }; static u3j_harm _143_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; @@ -273,26 +287,32 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}}; static c3_c* _143_pen__ut_fuse_ha[] = { + "492e29ce02a6440977dcb189d5bd892c4fed9f8c586a83f6f1a7973cf0c26c83", 0, }; static u3j_harm _143_pen__ut_mint_a[] = {{".2", u3wfu_mint}, {}}; static c3_c* _143_pen__ut_mint_ha[] = { + "fd9a27632b1c345625a3965cde12371bd444c3e0132dfa6d663aa82b9392dd1b", 0, }; static u3j_harm _143_pen__ut_mull_a[] = {{".2", u3wfu_mull}, {}}; static c3_c* _143_pen__ut_mull_ha[] = { + "0edf5ab7ce7fc7893ced2184df6b7b218dc371dad43e4f545281fedea272bbfd", 0, }; static u3j_harm _143_pen__ut_nest_a[] = {{".2", u3wfu_nest}, {}}; static c3_c* _143_pen__ut_nest_ha[] = { + "3e74b022bc38641cedc3dbb9a78384d4325d9227b1517c83411b83f2ea79f048", 0, }; static u3j_harm _143_pen__ut_peek_a[] = {{".2", u3wfu_peek}, {}}; static c3_c* _143_pen__ut_peek_ha[] = { + "acdf38ab8c65c15fd4d84f1d63607b6870cc030cd696f6197a7f815bcd87b4ec", 0, }; static u3j_harm _143_pen__ut_play_a[] = {{".2", u3wfu_play}, {}}; static c3_c* _143_pen__ut_play_ha[] = { + "2a2495a5b697aee9e5c66e08cf7a1808c29984b397f06fb82d30e4315d57aff2", 0, }; static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; @@ -301,6 +321,7 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_toss_a[] = {{".2", u3wfu_toss}, {}}; static c3_c* _143_pen__ut_toss_ha[] = { + "08d3c163f0f3e375595761129b07a7de81314fc0d5c864d343b920f5af2d3e8a", 0, }; static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; @@ -309,6 +330,7 @@ static u3j_core _143_hex_d[] = }; static c3_c* _143_pen__ut_ha[] = { + "353a299bfb10d1e68b34dd5c2950a26efdfb9ed07af221232341158590f5e755", 0, }; static u3j_hood _143_pen__ut_ho[] = { @@ -392,7 +414,7 @@ static u3j_core _143_hex_d[] = static c3_c* _143_pen_ha[] = { - "93e4cad5f01e16a173f31810ee5ab530a8a760010eb7cc9b451880456f32267e", + "b5e8b2005ffc86fc51f84be2042eed1bd45eddf51dd4e4e5d3a97290eb22ba8a", 0, }; static u3j_hood _143_pen_ho[] = { @@ -429,28 +451,33 @@ static u3j_core _143_pen_d[] = */ static u3j_harm _143_qua_trip_a[] = {{".2", u3we_trip}, {}}; static c3_c* _143_qua_trip_ha[] = { - "335ad28e7924ee9bdf29050bf2d7b4eebf434dfaaa0f704a689f065eb5c703b0", + "5c85bf1a1e5cf0049d758c0549a4c5738e8064160f11692ce85c56f77a40430f", 0, }; static u3j_harm _143_qua__po_ind_a[] = {{".2", u3wcp_ind}, {}}; static c3_c* _143_qua__po_ind_ha[] = { + "ac8d03331537ca664a44ea42427f944078d57f669568315843aad6c4038113a9", 0, }; static u3j_harm _143_qua__po_ins_a[] = {{".2", u3wcp_ins}, {}}; static c3_c* _143_qua__po_ins_ha[] = { + "8a116a57268df234f621370d9aa1983ca15bbb49bba2e8384a8b90430f3b325a", 0, }; static u3j_harm _143_qua__po_tod_a[] = {{".2", u3wcp_tod}, {}}; static c3_c* _143_qua__po_tod_ha[] = { + "a57c4f9d5678f8e46590603da2e385f6f5d9f62997e911933dcb1dea3de343b4", 0, }; static u3j_harm _143_qua__po_tos_a[] = {{".2", u3wcp_tos}, {}}; static c3_c* _143_qua__po_tos_ha[] = { + "fec59aa7f960f453d931e21fa17f877e0d1d58a98891277aa6372c42874936e3", 0, }; static c3_c* _143_qua__po_ha[] = { + "7aea092b4dc4ed511aeb60b9669319c64516120113ffd3cf18edf55044957679", 0, }; static u3j_core _143_qua__po_d[] = @@ -463,9 +490,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__bend_fun_a[] = {{".2", u3we_bend_fun}, {}}; static c3_c* _143_qua__bend_ha[] = { + "0a0fa420f15155cc780d3bee1b614f7dba587ea12ad3d216f8a9bcd06c6a549f", 0, }; static c3_c* _143_qua__bend_fun_ha[] = { + "27906ec8a1d10c15e976245064ea5b0868608c92f58c7cf60afcd3fae0193b25", 0, }; static u3j_core _143_qua__bend_d[] = @@ -475,9 +504,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__cold_fun_a[] = {{".2", u3we_cold_fun}, {}}; static c3_c* _143_qua__cold_ha[] = { + "b3eeada7d2d7ce063830b7cbc9f7d36b2a2b9101e9c36a7b03eaebf2d1598389", 0, }; static c3_c* _143_qua__cold_fun_ha[] = { + "b628559bb6eb765bd439454c582bd8adb9595075aed10b157e2fa7b4193248ab", 0, }; static u3j_core _143_qua__cold_d[] = @@ -487,9 +518,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__cook_fun_a[] = {{".2", u3we_cook_fun}, {}}; static c3_c* _143_qua__cook_ha[] = { + "762985e18fe1c7007c6ad51445e449d24b1cec693294c8edc89da3bbb4f9f441", 0, }; static c3_c* _143_qua__cook_fun_ha[] = { + "9b23b8aeadf056cee3f092468f70211b453ba4bdefc9229021800055bd47ea61", 0, }; static u3j_core _143_qua__cook_d[] = @@ -499,9 +532,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__comp_fun_a[] = {{".2", u3we_comp_fun}, {}}; static c3_c* _143_qua__comp_ha[] = { + "eb085cbf01982751994cbaafc9ed7efe80758682af6d67aab646a972239401a0", 0, }; static c3_c* _143_qua__comp_fun_ha[] = { + "e7d29e21ffd7e0d89a3408ef78ab5350516896c671e8fc240726f0d64fbad29b", 0, }; static u3j_core _143_qua__comp_d[] = @@ -511,11 +546,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__easy_fun_a[] = {{".2", u3we_easy_fun}, {}}; static c3_c* _143_qua__easy_ha[] = { - "bbdf198f84a73d758c1ccc5608159c6a1bfa72495fcd963e7327b9ccc26eded3", + "a30bd1a1006a06ca6cd6f01909f8745272d65739944425c1fd9682a6bed44999", 0, }; static c3_c* _143_qua__easy_fun_ha[] = { - "b4b36293b7e9bfcc9029283fe8b770967073ef18d45f0eb4b90141e9c087ffec", + "4bbbc43ece463d961e572301d0824d3e3cab3ba09ec2756cbefae63ee106044b", 0, }; static u3j_core _143_qua__easy_d[] = @@ -525,9 +560,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__glue_fun_a[] = {{".2", u3we_glue_fun}, {}}; static c3_c* _143_qua__glue_ha[] = { + "0b4722d874b19c25fad7f5630b8e46a46ea86d54e1db1600d7ebebf373dc44a5", 0, }; static c3_c* _143_qua__glue_fun_ha[] = { + "ef2b7e80475e0e6aca6a8248a40829c382b262213594f6b9db1e990b5c3792af", 0, }; static u3j_core _143_qua__glue_d[] = @@ -537,9 +574,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__here_fun_a[] = {{".2", u3we_here_fun}, {}}; static c3_c* _143_qua__here_ha[] = { + "1f7fe1031a68621b04bacad1bf3a39a8358e74f41db12969d7f39ddabe9eab1a", 0, }; static c3_c* _143_qua__here_fun_ha[] = { + "25df3d2c1a0d9b809beaec9662a0f17c4f7762250c7675a7315216b97bb8767f", 0, }; static u3j_core _143_qua__here_d[] = @@ -549,9 +588,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__just_fun_a[] = {{".2", u3we_just_fun}, {}}; static c3_c* _143_qua__just_ha[] = { + "48aa6959752752a63c2dd6d5064312755d57415df3fa7fbfc038466f5aa6874c", 0, }; static c3_c* _143_qua__just_fun_ha[] = { + "287a8ed9a6b7bb26be684ac6ef095433f6d2ca5eaa6e71c3113553c8c897860b", 0, }; static u3j_core _143_qua__just_d[] = @@ -561,9 +602,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__mask_fun_a[] = {{".2", u3we_mask_fun}, {}}; static c3_c* _143_qua__mask_ha[] = { + "cd12b6930b293cb898713870d9048ec4c598ef018427173f2c1a3a92a356dcb5", 0, }; static c3_c* _143_qua__mask_fun_ha[] = { + "cf9868ba0b5eb8555846bf9436fb2aaf508d8cb283e10574f85d41fc0d1b6162", 0, }; static u3j_core _143_qua__mask_d[] = @@ -573,9 +616,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__shim_fun_a[] = {{".2", u3we_shim_fun}, {}}; static c3_c* _143_qua__shim_ha[] = { + "0c204d6f7e7f105a5c2b64f77fa0bfb0ba6246a293868dcc63dbed00aa1c159d", 0, }; static c3_c* _143_qua__shim_fun_ha[] = { + "3954cabbffe0576646976f16cf4333d72b636b7b5e1de6b4689da6d950530715", 0, }; static u3j_core _143_qua__shim_d[] = @@ -585,9 +630,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__stag_fun_a[] = {{".2", u3we_stag_fun}, {}}; static c3_c* _143_qua__stag_ha[] = { + "b0cf7747e734c4565467fa2702c37efcfd0ae19c59bd92f115a32d2f3200fedf", 0, }; static c3_c* _143_qua__stag_fun_ha[] = { + "a2c40563eafd02090845b3250009239e98356f987908d3c4491a95007a433a02", 0, }; static u3j_core _143_qua__stag_d[] = @@ -597,9 +644,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__stew_fun_a[] = {{".2", u3we_stew_fun}, {}}; static c3_c* _143_qua__stew_ha[] = { + "c444fd202534a0026defd2ee2ff283fee2a5d52ca4f4075bd0290164ae59cddd", 0, }; static c3_c* _143_qua__stew_fun_ha[] = { + "673727e5a6ca9414042cf72f794b8fb4c014111aaf43d056554e0f5c5a429967", 0, }; static u3j_core _143_qua__stew_d[] = @@ -609,9 +658,11 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__stir_fun_a[] = {{".2", u3we_stir_fun}, {}}; static c3_c* _143_qua__stir_ha[] = { + "9dd5a6197336769883ca246dab71cc7ea9997d355172891607f0cc6720b73e39", 0, }; static c3_c* _143_qua__stir_fun_ha[] = { + "13f5792ea114749b242fe03ea6012cff3a8e435f06033df059c398023c8f706e", 0, }; static u3j_core _143_qua__stir_d[] = @@ -622,25 +673,29 @@ static u3j_core _143_pen_d[] = // static u3j_harm _143_qua_pfix_a[] = {{".2", u3we_pfix}, {}}; static u3j_harm _143_qua_plug_a[] = {{".2", u3we_plug}, {}}; static c3_c* _143_qua__plug_ha[] = { + "13088844b6585a6fbfc46de42d49dda8830e4db2cc90b12451f761064c9536e1", 0, }; static u3j_harm _143_qua_pose_a[] = {{".2", u3we_pose}, {}}; static c3_c* _143_qua__pose_ha[] = { + "7a80993302f8966d651a56fe46fd88e30a02d13d2f7ac5d472e6c6a66332e066", 0, }; //static u3j_harm _143_qua_sfix_a[] = {{".2", u3we_sfix}, {}}; static u3j_harm _143_qua_mink_a[] = {{".2", u3we_mink}, {}}; static c3_c* _143_qua_mink_ha[] = { + "22517aa2c9e97f80de47307cc8d26ced480b10104a189bdbd478d842fa04d2fc", 0, }; static u3j_harm _143_qua_mule_a[] = {{".2", u3we_mule}, {}}; static c3_c* _143_qua_mule_ha[] = { + "690c6603a5d64e3bd15df17d7c736ac8a7acbab3c869211cc133fda65506a4a3", 0, }; static c3_c* _143_qua_ha[] = { - "a8e494c95b4f2d7e74100c8aa9d0797ff6a3a9b5e6bd3dfbc0ebe56c2e46b499", + "5b402d501f23c2965a4cf270a6c7cad8898d1b25e9679ea419dbf6663edace4e", 0, }; static u3j_hood _143_qua_ho[] = { @@ -966,6 +1021,7 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri_shax_a[] = {{".2", u3we_shax}, {}}; static c3_c* _143_tri_shax_ha[] = { + "6fd600b0b160128df4dc4cdd119a415e22ed864c7d90e985f960af4814d8ec02", 0, }; static u3j_harm _143_tri_shay_a[] = {{".2", u3we_shay}, {}}; @@ -981,11 +1037,12 @@ static u3j_core _143_qua_d[] = */ static u3j_harm _143_tri_shal_a[] = {{".2", u3we_shal}, {}}; static c3_c* _143_tri_shal_ha[] = { + "379203099b3e98165af1cdcc224e85da97889d8883c7732f8ba2cc71abcec1ac", 0, }; static c3_c* _143_tri_ha[] = { - "3532a5d4a01664989f527f0c42399d5a8e6e6e32f2542cde39da918d3b9ec41a", + "e19e164d1591dda79642169f894a6129d9effc76668a0218046ea512291b99e2", 0, }; static u3j_core _143_tri_d[] = @@ -1008,14 +1065,17 @@ static u3j_core _143_tri_d[] = */ static u3j_harm _143_two_flop_a[] = {{".2", u3wb_flop, c3y}, {}}; static c3_c* _143_two_flop_ha[] = { + "facc483d8c2911821dffb6a36dabbacab99dd2e4141e37ddb3e19c42de5a99e3", 0, }; static u3j_harm _143_two_lent_a[] = {{".2", u3wb_lent, c3y}, {}}; static c3_c* _143_two_lent_ha[] = { + "ecf53a78c22d98e2dfb7dbe44169a6d6665d167821696f89c1c3176aa79bcc0b", 0, }; static u3j_harm _143_two_levy_a[] = {{".2", u3wb_levy, c3y}, {}}; static c3_c* _143_two_levy_ha[] = { + "8f02ef06c48cc4fb63648546b3f805d19401ed30d83976b04983c2f44c81f3f5", 0, }; static u3j_harm _143_two_lien_a[] = {{".2", u3wb_lien, c3y}, {}}; @@ -1024,6 +1084,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_murn_a[] = {{".2", u3wb_murn, c3y}, {}}; static c3_c* _143_two_murn_ha[] = { + "7c675855df3726786a9678309b0aec910227e77d73bc4a9b75152ff75d2ff995", 0, }; /* XX: no hint @@ -1039,68 +1100,84 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_reel_a[] = {{".2", u3wb_reel, c3y}, {}}; static c3_c* _143_two_reel_ha[] = { + "d2a4bd27dad0931e082629bb64a7144b4dd5aa53cab045dfaceae54ff6e3ab3b", 0, }; static u3j_harm _143_two_roll_a[] = {{".2", u3wb_roll, c3y}, {}}; static c3_c* _143_two_roll_ha[] = { + "44e12087e29a5e025e45589a0ef923fe6df8b8f49d735af4167c8eb5ab68080e", 0, }; static u3j_harm _143_two_skid_a[] = {{".2", u3wb_skid, c3y}, {}}; static c3_c* _143_two_skid_ha[] = { + "60f95e823597e3385f7472edec19d90c85aeffc4b8bcbcf1d54b365ce6c5aa23", 0, }; static u3j_harm _143_two_skim_a[] = {{".2", u3wb_skim, c3y}, {}}; static c3_c* _143_two_skim_ha[] = { + "de6ee398b8264fe4e77ed63007a7b5f92dc81d1613da7d6e31003f5fa74ee12b", 0, }; static u3j_harm _143_two_skip_a[] = {{".2", u3wb_skip, c3y}, {}}; static c3_c* _143_two_skip_ha[] = { + "90e9162bb117cb9a68939d6910eb854663cd6aff03c530dd9654628480469cfc", 0, }; static u3j_harm _143_two_scag_a[] = {{".2", u3wb_scag, c3y}, {}}; static c3_c* _143_two_scag_ha[] = { + "c910ee62801c9113c9f689515defdf8b159b35f593eee8e396b4b5e4017c7b40", 0, }; static u3j_harm _143_two_slag_a[] = {{".2", u3wb_slag, c3y}, {}}; static c3_c* _143_two_slag_ha[] = { + "95b4e2050be824e44f4baaa951d1cc191f116a846711cd7329c9cbd88f965a09", 0, }; static u3j_harm _143_two_snag_a[] = {{".2", u3wb_snag, c3y}, {}}; static c3_c* _143_two_snag_ha[] = { + "d6d4dbda4f29b3cde0a3d2bc3c59df4f1eddcc22810bfbf3130f0a1e14fe2c80", 0, }; // static u3j_harm _143_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; static u3j_harm _143_two_turn_a[] = {{".2", u3wb_turn, c3y}, {}}; static c3_c* _143_two_turn_ha[] = { + "7ca8d0d1e9b5fc3ab9cce9ceba83a170a7298be4a92b58b58354585ce71c75c9", 0, }; static u3j_harm _143_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}}; static c3_c* _143_two_weld_ha[] = { + "82fb71bd085c6657ce1eecc399143e35588fb10c02db6b7ab2bf2a0adabff49e", 0, }; static u3j_harm _143_two_bex_a[] = {{".2", u3wc_bex, c3y}, {}}; static c3_c* _143_two_bex_ha[] = { + "c9738c81e31bd813c9b53c2a99c426f67769cb55ebd0186b48b482cc22115ccd", 0, }; static u3j_harm _143_two_can_a[] = {{".2", u3wc_can, c3y}, {}}; static c3_c* _143_two_can_ha[] = { + "7c8a43f690431660885ecf336f567ba405466404bbdf4057da0eb8b2f56f295c", 0, }; static u3j_harm _143_two_cat_a[] = {{".2", u3wc_cat, c3y}, {}}; static c3_c* _143_two_cat_ha[] = { + "82ce75876bb5c44812c78264598d61acf4679b401a9a12130acb2d5f20beb9d5", 0, }; static u3j_harm _143_two_con_a[] = {{".2", u3wc_con, c3y}, {}}; static c3_c* _143_two_con_ha[] = { + "f78cb0e4959ae6b4449a0dc7d3cdc0629718bb7a153838c1777f91e8000feea9", 0, }; static u3j_harm _143_two_cut_a[] = {{".2", u3wc_cut, c3y}, {}}; static c3_c* _143_two_cut_ha[] = { + "b55a0ffd9320c44b5050ea6103abf2da309d7ee2c86d9463cdf0ad45e21bdbb9", 0, }; static u3j_harm _143_two_dis_a[] = {{".2", u3wc_dis, c3y}, {}}; static c3_c* _143_two_dis_ha[] = { + "a64330428923afdf18b8a5e2a4b6cb8370cf07428055539d43e4cc98f6a3996f", 0, }; static u3j_harm _143_two_dor_a[] = {{".2", u3wc_dor, c3y}, {}}; @@ -1109,26 +1186,32 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_end_a[] = {{".2", u3wc_end, c3y}, {}}; static c3_c* _143_two_end_ha[] = { + "e24495cc46efa7cf294477301c5fe35a289e503a104c01eca92edb692881bb49", 0, }; static u3j_harm _143_two_gor_a[] = {{".2", u3wc_gor, c3y}, {}}; static c3_c* _143_two_gor_ha[] = { + "30ff6eb815ffa5ed1ba120143906d2de4bb8095099b616d35641a46f21646a84", 0, }; static u3j_harm _143_two_hor_a[] = {{".2", u3wc_hor, c3y}, {}}; static c3_c* _143_two_hor_ha[] = { + "7d65051bf64017bac1199427ec4338e898b8522b8263e7e82e24dc7aec534a6f", 0, }; static u3j_harm _143_two_lsh_a[] = {{".2", u3wc_lsh, c3y}, {}}; static c3_c* _143_two_lsh_ha[] = { + "67d04cf1cc99459994d7b157771cdb2918c7c416cf3aebf8fb1600167e136563", 0, }; static u3j_harm _143_two_met_a[] = {{".2", u3wc_met, c3y}, {}}; static c3_c* _143_two_met_ha[] = { + "87dc9967fe71315464bf2d626d68641c1ff2eb08e765e182e8c64054e7e31d09", 0, }; static u3j_harm _143_two_mix_a[] = {{".2", u3wc_mix, c3y}, {}}; static c3_c* _143_two_mix_ha[] = { + "7cd98d76ba4af2461bc5fad2e0ccb7ca65161aca7205945709cd8a04961778a5", 0, }; static u3j_harm _143_two_mug_a[] = {{".2", u3wc_mug, c3y}, {}}; @@ -1137,6 +1220,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_muk_a[] = {{".2", u3wc_muk, c3y}, {}}; static c3_c* _143_two_muk_ha[] = { + "d10798c3330555c586b63dec9e55aabc8fb06f1dacc0a4eccddb73a8fc32fa32", 0, }; static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; @@ -1145,6 +1229,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}}; static c3_c* _143_two_rap_ha[] = { + "92a44a93ee7824201abddf126339a1ecd3b9057f73d2788043693e712a41cdcd", 0, }; static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}}; @@ -1153,10 +1238,12 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; static c3_c* _143_two_rip_ha[] = { + "8c4888f617dc007aad1d661fcbff97d3a4539e3aa56a9c36cd550b637cf3d976", 0, }; static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}}; static c3_c* _143_two_rsh_ha[] = { + "4f9ed2377189bbbd4c1f6b50d99e3a8b3609a4e4dc35f294e01bcd5a5445cec6", 0, }; static u3j_harm _143_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; @@ -1165,6 +1252,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _143_two_vor_ha[] = { + "929c18cae2ce59b33e39d7d9108e4f22a4b0fb346d626aeeb50fe35a38db18ee", 0, }; static u3j_harm _143_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; @@ -1182,10 +1270,12 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two__in_gas_a[] = {{".2", u3wdi_gas}, {}}; static c3_c* _143_two__in_gas_ha[] = { + "bed276f4863f42ab18dd56609b739ab858c5880b330b1d8db9a0ee630a1b0ef3", 0, }; static u3j_harm _143_two__in_has_a[] = {{".2", u3wdi_has}, {}}; static c3_c* _143_two__in_has_ha[] = { + "9bf14a279421b5f09a7ee0864082a2d8e9149e18112574ceaceeb436c49c03af", 0, }; /* XX: mer doesn't exist any more? @@ -1198,22 +1288,27 @@ static u3j_core _143_tri_d[] = // static u3j_harm _143_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _143_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static c3_c* _143_two__in_put_ha[] = { + "ff02e2bf371279c4658420d0b973bd981d297222702ed59174d936c0aca00142", 0, }; static u3j_harm _143_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; static c3_c* _143_two__in_tap_ha[] = { + "2ce39c34e5306fccf83db8035bdeb0e50d254d6f62017369546916519d58a49b", 0, }; static u3j_harm _143_two__in_wyt_a[] = {{".2", u3wdi_wyt}, {}}; static c3_c* _143_two__in_wyt_ha[] = { + "9ad9a550c586148279ea523f58bbe3360821fe3b0d1b93bdd0f87bfd51c80bd3", 0, }; static u3j_harm _143_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static c3_c* _143_two__in_uni_ha[] = { + "36c5a475b7e6a1c991b206e0e40e8e2b439c6ef4a01ae210bdcbc1d18bcd779a", 0, }; static c3_c* _143_two__in_ha[] = { + "8fe005605f2949e9004684e261ec821dfa2974f2d802d9dc0812b17f975594d1", 0, }; static u3j_core _143_two__in_d[] = @@ -1240,28 +1335,34 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}}; static c3_c* _143_two__by_gas_ha[] = { + "f5e0ed0062a29e1f6215d7d2a707933b04fdc1e69c762a06fdd50f491ce360d8", 0, }; static u3j_harm _143_two__by_get_a[] = {{".2", u3wdb_get, c3y}, {}}; static c3_c* _143_two__by_get_ha[] = { + "8bc3d77b5044e488ee8ee0b80fca18f53a2116282f603211c4ee2e8e58a08623", 0, }; static u3j_harm _143_two__by_has_a[] = {{".2", u3wdb_has, c3y}, {}}; static c3_c* _143_two__by_has_ha[] = { + "2483675ead9aa11d3454fa22c1c7be9464261bbd20eb8981b68ac149a595bd0d", 0, }; // static u3j_harm _143_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; static u3j_harm _143_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; static c3_c* _143_two__by_put_ha[] = { + "a6019be8da4c18a336b4a1aeb1d3c4956764a54f3c2383417ba1747707bdd9f0", 0, }; static u3j_harm _143_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; static c3_c* _143_two__by_tap_ha[] = { + "2ce39c34e5306fccf83db8035bdeb0e50d254d6f62017369546916519d58a49b", 0, }; // static u3j_harm _143_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; static c3_c* _143_two__by_ha[] = { + "ea6f795e84e7a982595e3713241181072e8c2254c122c9bec6c176a44d74be38", 0, }; static u3j_core _143_two__by_d[] = @@ -1283,6 +1384,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_jam_a[] = {{".2", u3we_jam}, {}}; static c3_c* _143_two_jam_ha[] = { + "4fdc5aff57adf3b0665dbf3f7cae00c92b0470ee74f79c054e63ed9b2c2a3761", 0, }; static u3j_harm _143_two_mat_a[] = {{".2", u3we_mat}, {}}; @@ -1295,7 +1397,7 @@ static u3j_core _143_tri_d[] = }; static c3_c* _143_two_ha[] = { - "aa20f6b35462ffcf6903536717dccd9f9a77f856ba9eee3a8cd5e39440a479a9", + "961d066b817b1dcac58e175d2bc49745ff096b39a9f81ae7c50bd4f69ed60673", 0, }; static u3j_core _143_two_d[] = @@ -1357,14 +1459,17 @@ static u3j_core _143_two_d[] = */ static u3j_harm _143_one_add_a[] = {{".2", u3wa_add, c3y}, {}}; static c3_c* _143_one_add_ha[] = { + "f56080814115fa58aa5b4c21948bd5f36587cf8b24a66b64d95665c7b34adbf3", 0, }; static u3j_harm _143_one_dec_a[] = {{".2", u3wa_dec, c3y}, {}}; static c3_c* _143_one_dec_ha[] = { + "036cac68adadd083df7a426ea1ee974f84823e3d3a840fec31c7610f19688fe7", 0, }; static u3j_harm _143_one_div_a[] = {{".2", u3wa_div, c3y}, {}}; static c3_c* _143_one_div_ha[] = { + "b9bdb2e64a1f585509a5b3883f8d7dba1471fea38ff316cf7b2b970ba60def49", 0, }; static u3j_harm _143_one_dvr_a[] = {{".2", u3wc_dvr, c3y}, {}}; @@ -1373,47 +1478,57 @@ static u3j_core _143_two_d[] = }; static u3j_harm _143_one_gte_a[] = {{".2", u3wa_gte, c3y}, {}}; static c3_c* _143_one_gte_ha[] = { + "4fa8535a1650ca96d16e17a9f4e77b779fe017f4585a6397370c4251057c439c", 0, }; static u3j_harm _143_one_gth_a[] = {{".2", u3wa_gth, c3y}, {}}; static c3_c* _143_one_gth_ha[] = { + "042b58314829f4d8af8747b330e3c10a4d02ed574e99b996a9cc46c4a53588a1", 0, }; static u3j_harm _143_one_lte_a[] = {{".2", u3wa_lte, c3y}, {}}; static c3_c* _143_one_lte_ha[] = { + "892702a3bf38377ad877b43effe6e9cc428d398beb0793bcefae7c5d06d10477", 0, }; static u3j_harm _143_one_lth_a[] = {{".2", u3wa_lth, c3y}, {}}; static c3_c* _143_one_lth_ha[] = { + "637fcd910ab0e253640efa6a473b5fec809fb8ab9326dab987f9b361b1378ffa", 0, }; static u3j_harm _143_one_mod_a[] = {{".2", u3wa_mod, c3y}, {}}; static c3_c* _143_one_mod_ha[] = { + "175121db3c63288c435b860d6e793f9155b19ae5a9b0659f19ce05826c131588", 0, }; static u3j_harm _143_one_mul_a[] = {{".2", u3wa_mul, c3y}, {}}; static c3_c* _143_one_mul_ha[] = { + "5417b2b3c5fdf39f4717e37bd9f833262ca6ae893d691f5e1f0962fd90ed3a6e", 0, }; static u3j_harm _143_one_sub_a[] = {{".2", u3wa_sub, c3y}, {}}; static c3_c* _143_one_sub_ha[] = { + "448497a0aecbf1a0858b307415adad729db64a55f42c9f57085b8e561557f71c", 0, }; static u3j_harm _143_one_cap_a[] = {{".2", u3wc_cap, c3y}, {}}; static c3_c* _143_one_cap_ha[] = { + "60a1602892f3295d380d51ab567b128c6cfc740b154f40c465b4bc4eec49eec9", 0, }; static u3j_harm _143_one_peg_a[] = {{".2", u3wc_peg, c3y}, {}}; static c3_c* _143_one_peg_ha[] = { + "520eb037f25f74439b80cb3de5081c4b6dcdee3e929d2c7803d79abe8fe3e7c1", 0, }; static u3j_harm _143_one_mas_a[] = {{".2", u3wc_mas, c3y}, {}}; static c3_c* _143_one_mas_ha[] = { + "350a2bf08b62e53e3911ea3b0587f871c80625fc1fb969ce794618910a9ef11d", 0, }; static c3_c* _143_one_ha[] = { - "f04034ab0335ab53292f74127065b609b8b99bd9905f51a8254ef4580b84aaf3", + "694fc75229f41568a9679c8606c61c881c4e2662c481ca3f0cea0c682a42e1d7", 0, }; static u3j_core _143_one_d[] = @@ -1438,7 +1553,7 @@ static u3j_core _143_one_d[] = }; static c3_c* _k143_ha[] = { - "11ef831e540bfe588cde998b55e7d8cd58bb35898774b19f9164328c5cb3c637", + "9b82a903093c077afb3f0b9d4e95e1a9c9789d1ca605b57bbacf79857e3d5c52", 0, }; u3j_core _k143_d[] = From 8f72dbcd9de6af07a31e6fda3fc2b4e623731a01 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 May 2018 14:07:25 -0700 Subject: [PATCH 134/221] update pill/arvo hashes --- jets/tree.c | 90 ++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 950d1d141..814a428b0 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -134,7 +134,7 @@ static u3j_harm _143_hex_lore_a[] = {{".2", u3we_lore}, {}}; static c3_c* _143_hex_lore_ha[] = { - "2abdf1dd2b9e30333451a49c7a5890ab27c77603d4210aa4d1b8016d7bb730a7", + "2cad8eefaa6c476fb4fefe529eb55d46aac374b67a429bd4fa8d6a34d1a8f050", 0, }; static u3j_harm _143_hex_loss_a[] = {{".2", u3we_loss}, {}}; @@ -148,12 +148,12 @@ static u3j_harm _143_hex_coed__ed_puck_a[] = {{".2", u3wee_puck}, {}}; static c3_c* _143_hex_coed__ed_puck_ha[] = { - "1327f1c0b31be786c5185086186814bbb6d8b44bc8ad26e651ad027e0e62844d", + "7ef96640de06004fe356a94d2a6a6a45ea2f933b386485bbfb9802452749d2ae", 0, }; static u3j_harm _143_hex_coed__ed_sign_a[] = {{".2", u3wee_sign}, {}}; static c3_c* _143_hex_coed__ed_sign_ha[] = { - "18c4367cbc8990c70610c6d43a42ab69693952997b4ff58eb675f1f14249bd0b", + "dd5f03b0e804b36800b5c18a8a2986a76d1ed3e2e0d7d4940e550379ca40cb1e", 0, }; static u3j_harm _143_hex_coed__ed_veri_a[] = {{".2", u3wee_veri}, {}}; @@ -166,7 +166,7 @@ }; static c3_c* _143_hex_coed__ed_ha[] = { - "aa922a96a00ba63a328b9f67c814e0cd006b830481834101de4b92e36533914c", + "3502d9b800dad3256f0cf584cb8755cf299263ccbc0258041ce25a2fdea9126a", 0, }; static u3j_core _143_hex_coed__ed_d[] = @@ -178,7 +178,7 @@ }; static c3_c* _143_hex_coed_ha[] = { - "84efc127c57ffa5ee61c12737816ef42e067fd64f8262f3df93481d8c905b2bf", + "f59d0fd6f25ed52ff0f05b773287821602eb0f35baf2d9ed5b0cc9a71ca1c43a", 0, }; static u3j_core _143_hex_coed_d[] = @@ -187,7 +187,7 @@ static u3j_core _143_hex_coed_d[] = }; static c3_c* _143_hex_ha[] = { - "9cf8c9378dbb910e1130eb5aa30d12573943388613018c05a32f3d7d1d6c5ca2", + "c9f0e422b3a11ed08098fa0626ad6c6b0bffec5e6249b6ccebbaea93231d90af", 0, }; static u3j_core _143_hex_d[] = @@ -278,7 +278,7 @@ static u3j_core _143_hex_d[] = // static u3j_harm _143_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}}; static u3j_harm _143_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}}; static c3_c* _143_pen__ut_fond_ha[] = { - "e6f0ac3a903d7462a998093ee8772648dfa5f349c1a92c722c47236173780584", + "468e7e16343b54a13113ab87e285791a2cc4d1bdb87e1124d955b58ac51ce548", 0, }; static u3j_harm _143_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; @@ -292,7 +292,7 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_mint_a[] = {{".2", u3wfu_mint}, {}}; static c3_c* _143_pen__ut_mint_ha[] = { - "fd9a27632b1c345625a3965cde12371bd444c3e0132dfa6d663aa82b9392dd1b", + "81b7f5e3d592d4f7cc05218e588aec11c0c6819560c9d3901aab733b3bc628a7", 0, }; static u3j_harm _143_pen__ut_mull_a[] = {{".2", u3wfu_mull}, {}}; @@ -312,7 +312,7 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_play_a[] = {{".2", u3wfu_play}, {}}; static c3_c* _143_pen__ut_play_ha[] = { - "2a2495a5b697aee9e5c66e08cf7a1808c29984b397f06fb82d30e4315d57aff2", + "5c095ce320b440d0af7e94906d20ffb395c500a3d66be95efcad97c2b4a2e6b3", 0, }; static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; @@ -321,7 +321,7 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_toss_a[] = {{".2", u3wfu_toss}, {}}; static c3_c* _143_pen__ut_toss_ha[] = { - "08d3c163f0f3e375595761129b07a7de81314fc0d5c864d343b920f5af2d3e8a", + "b6d11182fbbca2555cafffef7517d613431888115a11480fe3dcb631e99e8d3b", 0, }; static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; @@ -330,7 +330,7 @@ static u3j_core _143_hex_d[] = }; static c3_c* _143_pen__ut_ha[] = { - "353a299bfb10d1e68b34dd5c2950a26efdfb9ed07af221232341158590f5e755", + "fb7c6d5a59356f0052960ad157a850dbcdf08c65fca0a30c4132a1d23fd0542b", 0, }; static u3j_hood _143_pen__ut_ho[] = { @@ -414,7 +414,7 @@ static u3j_core _143_hex_d[] = static c3_c* _143_pen_ha[] = { - "b5e8b2005ffc86fc51f84be2042eed1bd45eddf51dd4e4e5d3a97290eb22ba8a", + "609e4716505444cc4c9a1abc47d67606514113e249d5d123c887f3a1eb050033", 0, }; static u3j_hood _143_pen_ho[] = { @@ -451,7 +451,7 @@ static u3j_core _143_pen_d[] = */ static u3j_harm _143_qua_trip_a[] = {{".2", u3we_trip}, {}}; static c3_c* _143_qua_trip_ha[] = { - "5c85bf1a1e5cf0049d758c0549a4c5738e8064160f11692ce85c56f77a40430f", + "dc4da0a175609933760f651908afe2605b6daf2ad9618e554083b5c456724610", 0, }; @@ -467,17 +467,17 @@ static u3j_core _143_pen_d[] = }; static u3j_harm _143_qua__po_tod_a[] = {{".2", u3wcp_tod}, {}}; static c3_c* _143_qua__po_tod_ha[] = { - "a57c4f9d5678f8e46590603da2e385f6f5d9f62997e911933dcb1dea3de343b4", + "2aa4ca408583a7edbb28ad31b1447e9bd0d7b30babadad20d54d356470066f25", 0, }; static u3j_harm _143_qua__po_tos_a[] = {{".2", u3wcp_tos}, {}}; static c3_c* _143_qua__po_tos_ha[] = { - "fec59aa7f960f453d931e21fa17f877e0d1d58a98891277aa6372c42874936e3", + "f49735e576e16d5f85a532687e20266fda3fd234afc177d8002ba49347021b5b", 0, }; static c3_c* _143_qua__po_ha[] = { - "7aea092b4dc4ed511aeb60b9669319c64516120113ffd3cf18edf55044957679", + "2780e6430733e37b753c84505f68a3388051e13a7d26c8340df98cfd1fcf3400", 0, }; static u3j_core _143_qua__po_d[] = @@ -490,7 +490,7 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__bend_fun_a[] = {{".2", u3we_bend_fun}, {}}; static c3_c* _143_qua__bend_ha[] = { - "0a0fa420f15155cc780d3bee1b614f7dba587ea12ad3d216f8a9bcd06c6a549f", + "2ff8d33c4aeca4eb06950970f281068f72e851f8ed1e48c2cb547022f0e938f7", 0, }; static c3_c* _143_qua__bend_fun_ha[] = { @@ -532,7 +532,7 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__comp_fun_a[] = {{".2", u3we_comp_fun}, {}}; static c3_c* _143_qua__comp_ha[] = { - "eb085cbf01982751994cbaafc9ed7efe80758682af6d67aab646a972239401a0", + "86807213096ca2a8eae46602a84b2c114cc1d6f640daec688b67be62c7e8531e", 0, }; static c3_c* _143_qua__comp_fun_ha[] = { @@ -560,7 +560,7 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__glue_fun_a[] = {{".2", u3we_glue_fun}, {}}; static c3_c* _143_qua__glue_ha[] = { - "0b4722d874b19c25fad7f5630b8e46a46ea86d54e1db1600d7ebebf373dc44a5", + "0962f2da17ecaf704f891b915a42ead2f8acc3d8dbaa8ea7a694a3369b9acd21", 0, }; static c3_c* _143_qua__glue_fun_ha[] = { @@ -644,7 +644,7 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua__stew_fun_a[] = {{".2", u3we_stew_fun}, {}}; static c3_c* _143_qua__stew_ha[] = { - "c444fd202534a0026defd2ee2ff283fee2a5d52ca4f4075bd0290164ae59cddd", + "ecd266a550c1675667905593d63d102513c4784a221fbc39a7dbc4604d9c0744", 0, }; static c3_c* _143_qua__stew_fun_ha[] = { @@ -685,7 +685,7 @@ static u3j_core _143_pen_d[] = static u3j_harm _143_qua_mink_a[] = {{".2", u3we_mink}, {}}; static c3_c* _143_qua_mink_ha[] = { - "22517aa2c9e97f80de47307cc8d26ced480b10104a189bdbd478d842fa04d2fc", + "c5be5f0ebbbed2903a0f0f6c85acf4e9577ade6c996d0a9e8d26df890a0ea8fe", 0, }; static u3j_harm _143_qua_mule_a[] = {{".2", u3we_mule}, {}}; @@ -695,7 +695,7 @@ static u3j_core _143_pen_d[] = }; static c3_c* _143_qua_ha[] = { - "5b402d501f23c2965a4cf270a6c7cad8898d1b25e9679ea419dbf6663edace4e", + "2c0ea395849a6425bf0db683fa3e0a2749d72625a0c7802509c4f1dfd287780c", 0, }; static u3j_hood _143_qua_ho[] = { @@ -1021,7 +1021,7 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri_shax_a[] = {{".2", u3we_shax}, {}}; static c3_c* _143_tri_shax_ha[] = { - "6fd600b0b160128df4dc4cdd119a415e22ed864c7d90e985f960af4814d8ec02", + "96e65913f7bae0c7241bdd228bfc46e0722ef7364b84a111e5f4e38597dcca04", 0, }; static u3j_harm _143_tri_shay_a[] = {{".2", u3we_shay}, {}}; @@ -1037,12 +1037,12 @@ static u3j_core _143_qua_d[] = */ static u3j_harm _143_tri_shal_a[] = {{".2", u3we_shal}, {}}; static c3_c* _143_tri_shal_ha[] = { - "379203099b3e98165af1cdcc224e85da97889d8883c7732f8ba2cc71abcec1ac", + "0347a578e1f5ad78703c2b93c1db7d5e96924850b31cf9491d6faff154e6c3c4", 0, }; static c3_c* _143_tri_ha[] = { - "e19e164d1591dda79642169f894a6129d9effc76668a0218046ea512291b99e2", + "11de2846e11fc5803152876ef536794bf375c58212934b27d2b3be7d749551e3", 0, }; static u3j_core _143_tri_d[] = @@ -1157,7 +1157,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_can_a[] = {{".2", u3wc_can, c3y}, {}}; static c3_c* _143_two_can_ha[] = { - "7c8a43f690431660885ecf336f567ba405466404bbdf4057da0eb8b2f56f295c", + "40e0bf12e43d139d9a7da412d2ab62eff70a010aa79317d891a183de4d736a26", 0, }; static u3j_harm _143_two_cat_a[] = {{".2", u3wc_cat, c3y}, {}}; @@ -1167,17 +1167,17 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_con_a[] = {{".2", u3wc_con, c3y}, {}}; static c3_c* _143_two_con_ha[] = { - "f78cb0e4959ae6b4449a0dc7d3cdc0629718bb7a153838c1777f91e8000feea9", + "b113371b187e1b1bf784a27126e06a9e9e65635ee030de0ede9bc0440d5b232f", 0, }; static u3j_harm _143_two_cut_a[] = {{".2", u3wc_cut, c3y}, {}}; static c3_c* _143_two_cut_ha[] = { - "b55a0ffd9320c44b5050ea6103abf2da309d7ee2c86d9463cdf0ad45e21bdbb9", + "4cccc8a6b70f628e6cd295753e8cf2a33e32d2f2d6acdd0eb475159d133dece5", 0, }; static u3j_harm _143_two_dis_a[] = {{".2", u3wc_dis, c3y}, {}}; static c3_c* _143_two_dis_ha[] = { - "a64330428923afdf18b8a5e2a4b6cb8370cf07428055539d43e4cc98f6a3996f", + "061a2e8e043e1472bf974048786f7d92ca19b8d21ff88809f8f2b660e1bce5c4", 0, }; static u3j_harm _143_two_dor_a[] = {{".2", u3wc_dor, c3y}, {}}; @@ -1186,12 +1186,12 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_end_a[] = {{".2", u3wc_end, c3y}, {}}; static c3_c* _143_two_end_ha[] = { - "e24495cc46efa7cf294477301c5fe35a289e503a104c01eca92edb692881bb49", + "568825dab31a139e37427763494537f7ed6f0913e8e36ff9fe32e9503aec0e92", 0, }; static u3j_harm _143_two_gor_a[] = {{".2", u3wc_gor, c3y}, {}}; static c3_c* _143_two_gor_ha[] = { - "30ff6eb815ffa5ed1ba120143906d2de4bb8095099b616d35641a46f21646a84", + "cc875b441f2f1f4251f3ebadc4cac1f14aa3e52af4567213349cd09d37ec5347", 0, }; static u3j_harm _143_two_hor_a[] = {{".2", u3wc_hor, c3y}, {}}; @@ -1201,7 +1201,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_lsh_a[] = {{".2", u3wc_lsh, c3y}, {}}; static c3_c* _143_two_lsh_ha[] = { - "67d04cf1cc99459994d7b157771cdb2918c7c416cf3aebf8fb1600167e136563", + "00692776be6f25567e6e0c1207d3a9fb9f128bba981b769009e8fe5ce877ddfe", 0, }; static u3j_harm _143_two_met_a[] = {{".2", u3wc_met, c3y}, {}}; @@ -1211,7 +1211,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_mix_a[] = {{".2", u3wc_mix, c3y}, {}}; static c3_c* _143_two_mix_ha[] = { - "7cd98d76ba4af2461bc5fad2e0ccb7ca65161aca7205945709cd8a04961778a5", + "e01fdbf15db1e617062a0ecbec6bddc9895258fd86cfe6c6d51bb7a750b291e6", 0, }; static u3j_harm _143_two_mug_a[] = {{".2", u3wc_mug, c3y}, {}}; @@ -1220,7 +1220,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_muk_a[] = {{".2", u3wc_muk, c3y}, {}}; static c3_c* _143_two_muk_ha[] = { - "d10798c3330555c586b63dec9e55aabc8fb06f1dacc0a4eccddb73a8fc32fa32", + "29ba1b590c4550fb2bdd2d40b80b2986ed429bf73a65234524d25677fdbdbae5", 0, }; static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; @@ -1238,12 +1238,12 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; static c3_c* _143_two_rip_ha[] = { - "8c4888f617dc007aad1d661fcbff97d3a4539e3aa56a9c36cd550b637cf3d976", + "7cb8f403f7ee5a4aea5c341f6f2873b03d12afbf38260511fc6108a12b3b0413", 0, }; static u3j_harm _143_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}}; static c3_c* _143_two_rsh_ha[] = { - "4f9ed2377189bbbd4c1f6b50d99e3a8b3609a4e4dc35f294e01bcd5a5445cec6", + "6601a8048b9577b91ab66836cc6a24e17a9b36335abf104812bdaa1de1cd0745", 0, }; static u3j_harm _143_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; @@ -1252,7 +1252,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _143_two_vor_ha[] = { - "929c18cae2ce59b33e39d7d9108e4f22a4b0fb346d626aeeb50fe35a38db18ee", + "08b9d822d2975e2db3a4de17c1b98234ed6a5f9792f3f57ae774a102283d0dba", 0, }; static u3j_harm _143_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; @@ -1275,7 +1275,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two__in_has_a[] = {{".2", u3wdi_has}, {}}; static c3_c* _143_two__in_has_ha[] = { - "9bf14a279421b5f09a7ee0864082a2d8e9149e18112574ceaceeb436c49c03af", + "d914519602ca46108bfd89fd62114772ba0a2fb163886e98d20fd08ef63f55c1", 0, }; /* XX: mer doesn't exist any more? @@ -1288,7 +1288,7 @@ static u3j_core _143_tri_d[] = // static u3j_harm _143_two__in_int_a[] = {{".2", u3wdi_int}, {}}; static u3j_harm _143_two__in_put_a[] = {{".2", u3wdi_put}, {}}; static c3_c* _143_two__in_put_ha[] = { - "ff02e2bf371279c4658420d0b973bd981d297222702ed59174d936c0aca00142", + "d8b17f9e8eb12ddd59d0dc7db56a5289973d1f3d24a4ee52cdbe1dc5a5a74079", 0, }; static u3j_harm _143_two__in_tap_a[] = {{".2", u3wdi_tap}, {}}; @@ -1303,12 +1303,12 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two__in_uni_a[] = {{".2", u3wdi_uni}, {}}; static c3_c* _143_two__in_uni_ha[] = { - "36c5a475b7e6a1c991b206e0e40e8e2b439c6ef4a01ae210bdcbc1d18bcd779a", + "9d2552738845644c76dab789a701f1fc6fa20310c2524c53ac27d4b61b2862af", 0, }; static c3_c* _143_two__in_ha[] = { - "8fe005605f2949e9004684e261ec821dfa2974f2d802d9dc0812b17f975594d1", + "115c86a4c61be30b1af582150499e5ecad6ff31529438dd962a21bff44df3be6", 0, }; static u3j_core _143_two__in_d[] = @@ -1351,7 +1351,7 @@ static u3j_core _143_tri_d[] = // static u3j_harm _143_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}}; static u3j_harm _143_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}}; static c3_c* _143_two__by_put_ha[] = { - "a6019be8da4c18a336b4a1aeb1d3c4956764a54f3c2383417ba1747707bdd9f0", + "09f94e66c53f55bad8bb34dc832cc0d8565772cac697baeeb0c91f25b11b9277", 0, }; static u3j_harm _143_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}}; @@ -1362,7 +1362,7 @@ static u3j_core _143_tri_d[] = // static u3j_harm _143_two__by_uni_a[] = {{".2", u3wdb_uni, c3y}, {}}; static c3_c* _143_two__by_ha[] = { - "ea6f795e84e7a982595e3713241181072e8c2254c122c9bec6c176a44d74be38", + "ccf722c0fd9202327321307792d32f41ce68823f68ce98cd05905024cd1a2c98", 0, }; static u3j_core _143_two__by_d[] = @@ -1384,7 +1384,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_jam_a[] = {{".2", u3we_jam}, {}}; static c3_c* _143_two_jam_ha[] = { - "4fdc5aff57adf3b0665dbf3f7cae00c92b0470ee74f79c054e63ed9b2c2a3761", + "113e6ad2b21a06f809b0bac45240790cf912b10a06b5d95c85135c4303622a7c", 0, }; static u3j_harm _143_two_mat_a[] = {{".2", u3we_mat}, {}}; @@ -1397,7 +1397,7 @@ static u3j_core _143_tri_d[] = }; static c3_c* _143_two_ha[] = { - "961d066b817b1dcac58e175d2bc49745ff096b39a9f81ae7c50bd4f69ed60673", + "3255442cf9f44198dc529194424716523b2673652fd331c2b554cb072357fc0a", 0, }; static u3j_core _143_two_d[] = From 3fcd769e66a35729365148f581ac8f1bb2a3548e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 May 2018 17:33:33 -0700 Subject: [PATCH 135/221] more hashes --- jets/tree.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/jets/tree.c b/jets/tree.c index 814a428b0..8cf3e1bdb 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -738,14 +738,17 @@ static u3j_core _143_qua_d[] = */ static u3j_harm _143_tri__cofl__drg_a[] = {{".2", u3wef_drg}, {}}; static c3_c* _143_tri__cofl__drg_ha[] = { + "7614819fdd9fa447c589ad876071ba29b2b8f18533d4141c3f5c7a52d21195ff", 0, }; static u3j_harm _143_tri__cofl__lug_a[] = {{".2", u3wef_lug}, {}}; static c3_c* _143_tri__cofl__lug_ha[] = { + "50ea42e22dd7abb3a77c922960666902c02b4310e87bb7071dd9d7663a4bfbe0", 0, }; static c3_c* _143_tri__cofl_ha[] = { + "8b32e7338afa615b685d5956fbf2b942f01dcbd531b355454aa9d057cced14e6", 0, }; static u3j_core _143_tri__cofl_d[] = @@ -756,50 +759,62 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rd_add_a[] = {{".2", u3wer_add}, {}}; static c3_c* _143_tri__rd_add_ha[] = { + "02ec82eeaa72c9333829552c687f5b6ed4311603f9a05eaf2185cc8d6c350e20", 0, }; static u3j_harm _143_tri__rd_sub_a[] = {{".2", u3wer_sub}, {}}; static c3_c* _143_tri__rd_sub_ha[] = { + "a8dbeba83d5639b6e677dc20855af3e5aa2d3d960a886018e9e70169148c4a36", 0, }; static u3j_harm _143_tri__rd_mul_a[] = {{".2", u3wer_mul}, {}}; static c3_c* _143_tri__rd_mul_ha[] = { + "6fdd62baf5580d8178da235b7400d4271baeb8b3ff9fcab9356e406d3a63df8c", 0, }; static u3j_harm _143_tri__rd_div_a[] = {{".2", u3wer_div}, {}}; static c3_c* _143_tri__rd_div_ha[] = { + "a1150c2f7337b2fabd7f363766f601fc2c9784576c5be8b6fb609f16580ab759", 0, }; static u3j_harm _143_tri__rd_sqt_a[] = {{".2", u3wer_sqt}, {}}; static c3_c* _143_tri__rd_sqt_ha[] = { + "8d92b959de510af5f3656beae77b1b55f6e7d72191bf40d89703b1133e646b27", 0, }; static u3j_harm _143_tri__rd_fma_a[] = {{".2", u3wer_fma}, {}}; static c3_c* _143_tri__rd_fma_ha[] = { + "245af9eb82a22764c4e54836b40964594d3a22ead6b4ed0375ce77178bae1e52", 0, }; static u3j_harm _143_tri__rd_lth_a[] = {{".2", u3wer_lth}, {}}; static c3_c* _143_tri__rd_lth_ha[] = { + "4def08f8b1022e29e50e91e670e5b1876e9883544daae0a33022af4c9c02133f", 0, }; static u3j_harm _143_tri__rd_lte_a[] = {{".2", u3wer_lte}, {}}; static c3_c* _143_tri__rd_lte_ha[] = { + "e13df8510840263cd7853c0c66193da8d238cdff7b16cf3d79a59949697e1f78", 0, }; static u3j_harm _143_tri__rd_equ_a[] = {{".2", u3wer_equ}, {}}; static c3_c* _143_tri__rd_equ_ha[] = { + "e232288aa48a8469ed1659e2fb4cc44a32402728113f167328c737dcc61c3365", 0, }; static u3j_harm _143_tri__rd_gte_a[] = {{".2", u3wer_gte}, {}}; static c3_c* _143_tri__rd_gte_ha[] = { + "e381073446c4d67867c06442b02e04639964e65a03b7e183629e787879372329", 0, }; static u3j_harm _143_tri__rd_gth_a[] = {{".2", u3wer_gth}, {}}; static c3_c* _143_tri__rd_gth_ha[] = { + "1c5f47081be13bf818464e24bc17620ff2d2321d4e5f6051d023b8f4d51b2b9b", 0, }; static c3_c* _143_tri__rd_ha[] = { + "694f1ec148486510e502b35189399dd380d012c7b5d0b863f05f4808397af577", 0, }; static u3j_core _143_tri__rd_d[] = @@ -819,50 +834,62 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rs_add_a[] = {{".2", u3wet_add}, {}}; static c3_c* _143_tri__rs_add_ha[] = { + "281fe156bca117c526a41506e49f74e7f08589778fccf57dd531e8804e54b04c", 0, }; static u3j_harm _143_tri__rs_sub_a[] = {{".2", u3wet_sub}, {}}; static c3_c* _143_tri__rs_sub_ha[] = { + "ff6d088e884125fd40e32729999a1de92f1f4428c11313a21949471255395861", 0, }; static u3j_harm _143_tri__rs_mul_a[] = {{".2", u3wet_mul}, {}}; static c3_c* _143_tri__rs_mul_ha[] = { + "770165f6ca38d3e72fdb61e76c608f6cd333087ccdff39a824e26bd271a66d61", 0, }; static u3j_harm _143_tri__rs_div_a[] = {{".2", u3wet_div}, {}}; static c3_c* _143_tri__rs_div_ha[] = { + "571dbb99f1ad72e1b04c5c6eebaefdf82b9ac9db7afb848d9776883a59bc9f2c", 0, }; static u3j_harm _143_tri__rs_sqt_a[] = {{".2", u3wet_sqt}, {}}; static c3_c* _143_tri__rs_sqt_ha[] = { + "73ce6a7fbd34af63d1414b8b616e637a69a2142dcf551f429b45ca3c0d8b91b7", 0, }; static u3j_harm _143_tri__rs_fma_a[] = {{".2", u3wet_fma}, {}}; static c3_c* _143_tri__rs_fma_ha[] = { + "d967ec4c8b3271aa3fe314f35540ad5697d73806342f04dce458b463b25a59ab", 0, }; static u3j_harm _143_tri__rs_lth_a[] = {{".2", u3wet_lth}, {}}; static c3_c* _143_tri__rs_lth_ha[] = { + "44efcd45efcd8d723544afc0100a523605e7cb260700c50ceb62422f2568faeb", 0, }; static u3j_harm _143_tri__rs_lte_a[] = {{".2", u3wet_lte}, {}}; static c3_c* _143_tri__rs_lte_ha[] = { + "4fd0536b05593f7063b5736f2d1d3e8e126c634af7af96e21487bb98d70a5303", 0, }; static u3j_harm _143_tri__rs_equ_a[] = {{".2", u3wet_equ}, {}}; static c3_c* _143_tri__rs_equ_ha[] = { + "120b4ccf1fbfc1edcbc1f7164a4d8633f0fadbaa54d5126a6e2ef140e4974088", 0, }; static u3j_harm _143_tri__rs_gte_a[] = {{".2", u3wet_gte}, {}}; static c3_c* _143_tri__rs_gte_ha[] = { + "70bf3002041177614e33dcaec9f9fb98b92dd3aba81db9fcc50d08e2f53feff7", 0, }; static u3j_harm _143_tri__rs_gth_a[] = {{".2", u3wet_gth}, {}}; static c3_c* _143_tri__rs_gth_ha[] = { + "d46d70bde9f731f56f4a9fa55086b97405452c277779a1d827de015030501592", 0, }; static c3_c* _143_tri__rs_ha[] = { + "01dd4560646a9e22112ff0683b9202ea13c1f8b95928320930268721c265d0da", 0, }; static u3j_core _143_tri__rs_d[] = @@ -882,50 +909,62 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rq_add_a[] = {{".2", u3weq_add}, {}}; static c3_c* _143_tri__rq_add_ha[] = { + "964f77e06cba18815f195dccec308cef73ae57eacb4b820a138e29808fab1434", 0, }; static u3j_harm _143_tri__rq_sub_a[] = {{".2", u3weq_sub}, {}}; static c3_c* _143_tri__rq_sub_ha[] = { + "399f1d38e0332a93f7b5d4181a5821281de2ae4d9230569ad48024e809efc88b", 0, }; static u3j_harm _143_tri__rq_mul_a[] = {{".2", u3weq_mul}, {}}; static c3_c* _143_tri__rq_mul_ha[] = { + "deb02a650961cec4782fde277fea76618bc76127c4f00f31071745b2e6abf64f", 0, }; static u3j_harm _143_tri__rq_div_a[] = {{".2", u3weq_div}, {}}; static c3_c* _143_tri__rq_div_ha[] = { + "2ee326263988d79524480987cda056725de79dbdf1d01299f4687a6e231e78aa", 0, }; static u3j_harm _143_tri__rq_sqt_a[] = {{".2", u3weq_sqt}, {}}; static c3_c* _143_tri__rq_sqt_ha[] = { + "e04f087ebfdb9ca1d5ab4057e839af3a38ca2dd0751d88eef5f946831a73b364", 0, }; static u3j_harm _143_tri__rq_fma_a[] = {{".2", u3weq_fma}, {}}; static c3_c* _143_tri__rq_fma_ha[] = { + "6bca0ae8bc19e25043dc3ea9b8d3ffe47d15150756b7bea57c69ff7a966b9d0f", 0, }; static u3j_harm _143_tri__rq_lth_a[] = {{".2", u3weq_lth}, {}}; static c3_c* _143_tri__rq_lth_ha[] = { + "57953e78fa1241008e36f48099826d5d627dd5909853ffaea196091329e8d203", 0, }; static u3j_harm _143_tri__rq_lte_a[] = {{".2", u3weq_lte}, {}}; static c3_c* _143_tri__rq_lte_ha[] = { + "a987fc885c6bb2a400011f304d3a4003a32ad9a8e5a639494dc2784dcff9d40b", 0, }; static u3j_harm _143_tri__rq_equ_a[] = {{".2", u3weq_equ}, {}}; static c3_c* _143_tri__rq_equ_ha[] = { + "51d8f1534220514f8abcc6cb4d7062208d4317af9fa258b5042d902ca4f59372", 0, }; static u3j_harm _143_tri__rq_gte_a[] = {{".2", u3weq_gte}, {}}; static c3_c* _143_tri__rq_gte_ha[] = { + "e95247e5a582e316db55e289c7b4d7823056e20a20560cc55b3cc331990f3c68", 0, }; static u3j_harm _143_tri__rq_gth_a[] = {{".2", u3weq_gth}, {}}; static c3_c* _143_tri__rq_gth_ha[] = { + "27f08cbb2cbec8861e0e3ff4a5e17996a635c7eada6b96bf32dc8d761489acbc", 0, }; static c3_c* _143_tri__rq_ha[] = { + "9f1ac5b7535fc7f056deec44eeff4e042fb8ba4776000fba08715369f16fcbcd", 0, }; static u3j_core _143_tri__rq_d[] = @@ -945,50 +984,62 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__rh_add_a[] = {{".2", u3wes_add}, {}}; static c3_c* _143_tri__rh_add_ha[] = { + "d385c3b37b42155819be2341212546817e63afb1832caee17828f336cc9a935e", 0, }; static u3j_harm _143_tri__rh_sub_a[] = {{".2", u3wes_sub}, {}}; static c3_c* _143_tri__rh_sub_ha[] = { + "1f86d3837744e41a9cd27542e6313cb3072b96a3f30955da4a288bb0b8441924", 0, }; static u3j_harm _143_tri__rh_mul_a[] = {{".2", u3wes_mul}, {}}; static c3_c* _143_tri__rh_mul_ha[] = { + "0fbdae58bb34f4f367b8f79f8053179a299754f062d50783cad6aa5ac4e83d90", 0, }; static u3j_harm _143_tri__rh_div_a[] = {{".2", u3wes_div}, {}}; static c3_c* _143_tri__rh_div_ha[] = { + "82425f3e2c0ea76cace6bc3230ed99b685965f814244d5a31da8a93abe25f6ef", 0, }; static u3j_harm _143_tri__rh_sqt_a[] = {{".2", u3wes_sqt}, {}}; static c3_c* _143_tri__rh_sqt_ha[] = { + "c4eddd8fa7a9793e5a3508bc485541453ee866503d9f61de8bbd9cf8fdfd047c", 0, }; static u3j_harm _143_tri__rh_fma_a[] = {{".2", u3wes_fma}, {}}; static c3_c* _143_tri__rh_fma_ha[] = { + "604dac6ec7e580005d3884550538cbc5bbd61a540b0005c1e2dc1dc51adee9ff", 0, }; static u3j_harm _143_tri__rh_lth_a[] = {{".2", u3wes_lth}, {}}; static c3_c* _143_tri__rh_lth_ha[] = { + "6e4a43b6b1b9d86c9fd28c0bf587654baf17aac67588dcfa6cbf41ee7ed06ce8", 0, }; static u3j_harm _143_tri__rh_lte_a[] = {{".2", u3wes_lte}, {}}; static c3_c* _143_tri__rh_lte_ha[] = { + "85bdcdfe5d7c1b6375c82aa431d9135c564c6c5d059ce85d3a9ba6105a4dadd2", 0, }; static u3j_harm _143_tri__rh_equ_a[] = {{".2", u3wes_equ}, {}}; static c3_c* _143_tri__rh_equ_ha[] = { + "e00b1ea7903ee591f6d98784521db7261ab9e44bb6c6c55c57dd118a593417f2", 0, }; static u3j_harm _143_tri__rh_gte_a[] = {{".2", u3wes_gte}, {}}; static c3_c* _143_tri__rh_gte_ha[] = { + "fcfdb0e5e1e33c3b81b8a37409da00af8b0214005327e1a0fa729908a3d4d0b3", 0, }; static u3j_harm _143_tri__rh_gth_a[] = {{".2", u3wes_gth}, {}}; static c3_c* _143_tri__rh_gth_ha[] = { + "82bc230d89a180d216395f5b59f88300699271716a320c106a35b145d5a30b08", 0, }; static c3_c* _143_tri__rh_ha[] = { + "0b75eaabe45b35c5ef5ffa537bf40ef4adf91be8387dc31c82ccfe9d6d0b8a34", 0, }; static u3j_core _143_tri__rh_d[] = @@ -1008,10 +1059,12 @@ static u3j_core _143_qua_d[] = static u3j_harm _143_tri__og_raw_a[] = {{".2", u3weo_raw}, {}}; static c3_c* _143_tri__og_raw_ha[] = { + "b085fb693d157c2179f4aa1218dfb8e11a1169357e9128662f82cb0924f39f47", 0, }; static c3_c* _143_tri__og_ha[] = { + "4c67cb34175486a73c0e26eaf28325a21c0dc408f36fccefe58c32678f56ebea", 0, }; static u3j_core _143_tri__og_d[] = @@ -1026,6 +1079,7 @@ static u3j_core _143_qua_d[] = }; static u3j_harm _143_tri_shay_a[] = {{".2", u3we_shay}, {}}; static c3_c* _143_tri_shay_ha[] = { + "ad8ab5b9c64d1322cb64c9ab72af4fc6a87dfef8eead312ff478db5356acd650", 0, }; /* XX: no hint @@ -1080,6 +1134,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_lien_a[] = {{".2", u3wb_lien, c3y}, {}}; static c3_c* _143_two_lien_ha[] = { + "ceb4d5785cce59c4abd937e029988a00b2471be1b98a2dcb4c6639c5a9ac56b3", 0, }; static u3j_harm _143_two_murn_a[] = {{".2", u3wb_murn, c3y}, {}}; @@ -1096,6 +1151,7 @@ static u3j_core _143_tri_d[] = */ static u3j_harm _143_two_reap_a[] = {{".2", u3wb_reap, c3y}, {}}; static c3_c* _143_two_reap_ha[] = { + "d6c61900427fb756ea5a6162360d901408caf6d15f272fcdf487c528dc6edb3a", 0, }; static u3j_harm _143_two_reel_a[] = {{".2", u3wb_reel, c3y}, {}}; @@ -1182,6 +1238,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_dor_a[] = {{".2", u3wc_dor, c3y}, {}}; static c3_c* _143_two_dor_ha[] = { + "9a1f35386e4a24f71e71d83d4d426391a50fd4b6c2afa821a0cc54a5e506b3ab", 0, }; static u3j_harm _143_two_end_a[] = {{".2", u3wc_end, c3y}, {}}; @@ -1216,6 +1273,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_mug_a[] = {{".2", u3wc_mug, c3y}, {}}; static c3_c* _143_two_mug_ha[] = { + "bd9e1654a2f1af3ada44dd4f8bf57259615c41c46b85c51e067e9925f7c251ec", 0, }; static u3j_harm _143_two_muk_a[] = {{".2", u3wc_muk, c3y}, {}}; @@ -1225,6 +1283,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_pow_a[] = {{".2", u3wc_pow, c3y}, {}}; static c3_c* _143_two_pow_ha[] = { + "2673cff9ea43cf530ff724b5e0d3e982e5fc92c3222eab935f02f665cf2c0766", 0, }; static u3j_harm _143_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}}; @@ -1234,6 +1293,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}}; static c3_c* _143_two_rep_ha[] = { + "6eae8bfbcecc81cac614df04a09b321ff07ec9ee829e177767a025ccea9dfb87", 0, }; static u3j_harm _143_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}}; @@ -1248,6 +1308,7 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static c3_c* _143_two_sqt_ha[] = { + "1a5b05e2d0a86f227e76cfc22b4cab73c78fa2920961e04c97c198a66a003fac", 0, }; static u3j_harm _143_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; @@ -1257,15 +1318,18 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; static c3_c* _143_two_xeb_ha[] = { + "e7c7de452e43d0d149a3deddd0918667ef4e28f444f6dd4c8f4e41dd716bf19b", 0, }; static u3j_harm _143_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _143_two__in_bif_ha[] = { + "415dc99db82581fb32bdd7a3ec5e727d921e571395819cbc166fed8209ce5fed", 0, }; static u3j_harm _143_two__in_dif_a[] = {{".2", u3wdi_dif}, {}}; static c3_c* _143_two__in_dif_ha[] = { + "16e7bc8f531cc440ca3c653fabe321cc45de0c3b88167abf0a6a0aeb96e70cab", 0, }; static u3j_harm _143_two__in_gas_a[] = {{".2", u3wdi_gas}, {}}; @@ -1327,10 +1391,12 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}}; static c3_c* _143_two__by_bif_ha[] = { + "96742bb746aca4f38c75f607a1c1d2f698e4c64874b7f096c97a3356cb611a53", 0, }; static u3j_harm _143_two__by_dif_a[] = {{".2", u3wdb_dif, c3y}, {}}; static c3_c* _143_two__by_dif_ha[] = { + "da58e8407f13cfe2e8b7c724f8904efe1ecef121c169bf494a4610be2734b9d6", 0, }; static u3j_harm _143_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}}; @@ -1380,6 +1446,7 @@ static u3j_core _143_tri_d[] = static u3j_harm _143_two_cue_a[] = {{".2", u3we_cue}, {}}; static c3_c* _143_two_cue_ha[] = { + "4c2dbaa3a07d1624b19150839d61fa9f7f253be28689b7dcbaff914e9f9febe7", 0, }; static u3j_harm _143_two_jam_a[] = {{".2", u3we_jam}, {}}; @@ -1389,10 +1456,12 @@ static u3j_core _143_tri_d[] = }; static u3j_harm _143_two_mat_a[] = {{".2", u3we_mat}, {}}; static c3_c* _143_two_mat_ha[] = { + "521e7604b7a2be6c66e5571634d6b58722dfd0ea897e6f359e054e91d9e19acf", 0, }; static u3j_harm _143_two_rub_a[] = {{".2", u3we_rub}, {}}; static c3_c* _143_two_rub_ha[] = { + "fe76c277cafeb535538d4f9b51d5052313efd2201c14c729a7c4c1b4e4120dc6", 0, }; From 7bc52ec13dc80fb70ca0a03de67d91a9abf363ad Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 4 Jun 2018 12:10:02 -0700 Subject: [PATCH 136/221] all hashes --- jets/tree.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/jets/tree.c b/jets/tree.c index 8cf3e1bdb..6ca70d218 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -4,55 +4,68 @@ static u3j_harm _143_hex_aes_ecba_en_a[] = {{".2", u3wea_ecba_en}, {}}; static c3_c* _143_hex_aes_ecba_en_ha[] = { + "4f5e9d7eb3531b05755659872d2e4a097b3f54716e9e6f234541a714b7a418b2", 0, }; static u3j_harm _143_hex_aes_ecba_de_a[] = {{".2", u3wea_ecba_de}, {}}; static c3_c* _143_hex_aes_ecba_de_ha[] = { + "704ea7c1d4e8dec87475b356d388d45230c3e5f35e5c66838e1c5e8922408df2", 0, }; static u3j_harm _143_hex_aes_ecbb_en_a[] = {{".2", u3wea_ecbb_en}, {}}; static c3_c* _143_hex_aes_ecbb_en_ha[] = { + "f5409685e5087f2c83773ed920e27b056aabc4cb4176fa8d4895c5c242cff91f", 0, }; static u3j_harm _143_hex_aes_ecbb_de_a[] = {{".2", u3wea_ecbb_de}, {}}; static c3_c* _143_hex_aes_ecbb_de_ha[] = { + "33acc3a8c43b611cbc58aee7f926c2d3e9c83b2a6140a02b486f2085253d5d42", 0, }; static u3j_harm _143_hex_aes_ecbc_en_a[] = {{".2", u3wea_ecbc_en}, {}}; static c3_c* _143_hex_aes_ecbc_en_ha[] = { + "57c51ecd280e1edf09d6711af54c1959f2a6905b5809aecd97f1813b91d4093a", 0, }; static u3j_harm _143_hex_aes_ecbc_de_a[] = {{".2", u3wea_ecbc_de}, {}}; static c3_c* _143_hex_aes_ecbc_de_ha[] = { + "2ceb401083da36d0110d61f9b6840b44107c47e81e8e9dd3a9bb382d8db4fa23", 0, }; static u3j_harm _143_hex_aes_cbca_en_a[] = {{".2", u3wea_cbca_en}, {}}; static c3_c* _143_hex_aes_cbca_en_ha[] = { + "ec565c28e441da6f7d2d8c592934c2ab32b0a14b9238da547103b70e08289f5a", 0, }; static u3j_harm _143_hex_aes_cbca_de_a[] = {{".2", u3wea_cbca_de}, {}}; static c3_c* _143_hex_aes_cbca_de_ha[] = { + "d2c5d26648661a570cb58dba3cf09a3461daa0003ebb64edb89435651776e5f2", 0, }; static u3j_harm _143_hex_aes_cbcb_en_a[] = {{".2", u3wea_cbcb_en}, {}}; static c3_c* _143_hex_aes_cbcb_en_ha[] = { + "8811d4efd2d794648bff6001c9650034ec2511c7ae975923b0edd0d972ae88e1", 0, }; static u3j_harm _143_hex_aes_cbcb_de_a[] = {{".2", u3wea_cbcb_de}, {}}; static c3_c* _143_hex_aes_cbcb_de_ha[] = { + "00dabc4df21329f5eb2e1c9778a0f9213fcb4b5ca5c548a126ae1fea29fea6ce", 0, }; static u3j_harm _143_hex_aes_cbcc_en_a[] = {{".2", u3wea_cbcc_en}, {}}; static c3_c* _143_hex_aes_cbcc_en_ha[] = { + "145288884d5734080b7c30f65ba601d732f36d78d406867fa65b628b062c25e5", 0, }; static u3j_harm _143_hex_aes_cbcc_de_a[] = {{".2", u3wea_cbcc_de}, {}}; static c3_c* _143_hex_aes_cbcc_de_ha[] = { + "d2d1e86a94e5bc7309dc3b2ec2d34d70dc97f7db3be8e0ffde4b63c1652b8f60", 0, }; static c3_c* _143_hex_aes_ecba_ha[] = { + "9440c9ad46812d2de13a39ff6fdc5e1b458d8afceca1394f812a2ae79572384a", 0, }; static u3j_core _143_hex_aes_ecba_d[] = @@ -62,6 +75,7 @@ }; static c3_c* _143_hex_aes_ecbb_ha[] = { + "15b8fa23e81ece402dd41322478bb27a6b32ff7d45460bde0d00abf7b30c0bc8", 0, }; static u3j_core _143_hex_aes_ecbb_d[] = @@ -71,6 +85,7 @@ }; static c3_c* _143_hex_aes_ecbc_ha[] = { + "c87392cd881c3a207cc946b26c2c0652e86a2020069f89ce16c1834af75d616d", 0, }; static u3j_core _143_hex_aes_ecbc_d[] = @@ -80,6 +95,7 @@ }; static c3_c* _143_hex_aes_cbca_ha[] = { + "43c8292ecd269beceaa01a21e56f3d3e3c481e79788a4ef6ac5373e8fb38c1b3", 0, }; static u3j_core _143_hex_aes_cbca_d[] = @@ -89,6 +105,7 @@ }; static c3_c* _143_hex_aes_cbcb_ha[] = { + "a45c280e129255a2a0d0dcfbdb762798a29e66c919bdd6d1ce26b7fdad977ae6", 0, }; static u3j_core _143_hex_aes_cbcb_d[] = @@ -98,6 +115,7 @@ }; static c3_c* _143_hex_aes_cbcc_ha[] = { + "75c439055a56d7b71c2b25bd9892dcb3704865031bdc9036725eb6e11f7ac019", 0, }; static u3j_core _143_hex_aes_cbcc_d[] = @@ -107,6 +125,7 @@ }; static c3_c* _143_hex_aes_ha[] = { + "03907323dc614d077b52350166c9133bff41e6a849a51910006a4b0a94605b5a", 0, }; static u3j_core _143_hex_aes_d[] = @@ -121,10 +140,12 @@ static u3j_harm _143_hex_down_mark_a[] = {{".2", u3wg_down, c3y}, {}}; static c3_c* _143_hex_down_mark_ha[] = { + "1dc0f701ed9a36334e16db42abdbf74f729f6fa95114b5a89b4104aff5ec9386", 0, }; static c3_c* _143_hex_down_ha[] = { + "a25f392e687ea36ad222f8237814b74dad76ad78cf31908f126f021fadec620b", 0, }; static u3j_core _143_hex_down_d[] = @@ -139,10 +160,12 @@ }; static u3j_harm _143_hex_loss_a[] = {{".2", u3we_loss}, {}}; static c3_c* _143_hex_loss_ha[] = { + "abbaf2b75606b28b348d78bc1061cfaba39013f8641066ecd4b6430e8ca435e2", 0, }; static u3j_harm _143_hex_lune_a[] = {{".2", u3we_lune}, {}}; static c3_c* _143_hex_lune_ha[] = { + "1231de7d07e2f205c902126c9730f2b8a2ddf69ad6a7e1386a184e318a704316", 0, }; @@ -158,10 +181,12 @@ }; static u3j_harm _143_hex_coed__ed_veri_a[] = {{".2", u3wee_veri}, {}}; static c3_c* _143_hex_coed__ed_veri_ha[] = { + "521318797629b5bb523df49d6536c4b9b29fe672f24d4eef8aadcbc613cee556", 0, }; static u3j_harm _143_hex_coed__ed_shar_a[] = {{".2", u3wee_shar}, {}}; static c3_c* _143_hex_coed__ed_shar_ha[] = { + "8b156d563fc827ec6937a7a742408ad1bfe44e43e8e3f52bcfad5073146911d9", 0, }; @@ -211,10 +236,12 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen_comb_a[] = {{".2", u3wf_comb}, {}}; static c3_c* _143_pen_comb_ha[] = { + "24eab5e6a9a14e3000cda839c0663c21acf862f2e4f38a1375e13d10f936b1c2", 0, }; static u3j_harm _143_pen_cons_a[] = {{".2", u3wf_cons}, {}}; static c3_c* _143_pen_cons_ha[] = { + "0d7b708f9ad993dc8f46b476acae6c3fcf861d80dfbaff755c3d14b0d40d5f7e", 0, }; static u3j_harm _143_pen_core_a[] = {{".2", u3wf_core}, {}}; @@ -234,18 +261,22 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen_fitz_a[] = {{".2", u3wf_fitz}, {}}; static c3_c* _143_pen_fitz_ha[] = { + "66c86529da6c7913bf33581997f2b5d6b5b99ed04ecf5167e5a33549bf99bbca", 0, }; static u3j_harm _143_pen_flan_a[] = {{".2", u3wf_flan}, {}}; static c3_c* _143_pen_flan_ha[] = { + "3af6da0c7b43f5cbe84db737a23852c64ffce334f6fed22d299f07a770ed7c78", 0, }; static u3j_harm _143_pen_flip_a[] = {{".2", u3wf_flip}, {}}; static c3_c* _143_pen_flip_ha[] = { + "e724e80309c6526e0eb6c10b73f2053280d33e8de3015db06dfae819f1509946", 0, }; static u3j_harm _143_pen_flor_a[] = {{".2", u3wf_flor}, {}}; static c3_c* _143_pen_flor_ha[] = { + "38d6711c674b8f5b168b68d1d5b63a1fb5d45f4fb5dd7c2116a60147f6f88597", 0, }; static u3j_harm _143_pen_fork_a[] = {{".2", u3wf_fork}, {}}; @@ -261,10 +292,12 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen_look_a[] = {{".2", u3wf_look}, {}}; static c3_c* _143_pen_look_ha[] = { + "04349d58bcb1317eba57eed8011c27a3ef7c3332c6595e45307a2d06bfc0e8d0", 0, }; static u3j_harm _143_pen_loot_a[] = {{".2", u3wf_loot}, {}}; static c3_c* _143_pen_loot_ha[] = { + "f6084db81e47663103dbbff6aa2e4a48e6d40b047f379e3498075b3d845150f8", 0, }; @@ -283,6 +316,7 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}}; static c3_c* _143_pen__ut_fish_ha[] = { + "d920476bfcbaf49fede0fda6b0ab82359de5ab8a34794db9c812342ad2e023ea", 0, }; static u3j_harm _143_pen__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}}; @@ -317,6 +351,7 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_rest_a[] = {{".2", u3wfu_rest}, {}}; static c3_c* _143_pen__ut_rest_ha[] = { + "f472c273c935495e76ae163c55219c30b28187209cc38e7193458ec6061a58f2", 0, }; static u3j_harm _143_pen__ut_toss_a[] = {{".2", u3wfu_toss}, {}}; @@ -326,6 +361,7 @@ static u3j_core _143_hex_d[] = }; static u3j_harm _143_pen__ut_wrap_a[] = {{".2", u3wfu_wrap}, {}}; static c3_c* _143_pen__ut_wrap_ha[] = { + "5ccb56efe139ebd3933f3b03f24e4a1900f3f12521bc6953d7f2ffd204be382d", 0, }; From 667ecc80f8937eac74962aa74f7d5b30e61f73b8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 4 Jun 2018 12:20:01 -0700 Subject: [PATCH 137/221] for posterity --- jets/e/shux.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 jets/e/shux.c diff --git a/jets/e/shux.c b/jets/e/shux.c new file mode 100644 index 000000000..4f1af9917 --- /dev/null +++ b/jets/e/shux.c @@ -0,0 +1,41 @@ +/* j/5/shux.c +** +*/ +#include "all.h" + +static u3_atom +_shux_shax(void* dat_u, u3_atom a) +{ + u3_atom pro = u3qe_shax(a); + u3z(a); + return pro; +} + +static u3_atom +_shux_mix(void* dat_u, u3_atom a, u3_atom b) +{ + u3_atom tac = u3qc_cat(8, a, b), + pro = u3qe_shay(32, tac); + u3z(a); u3z(b); u3z(tac); + return pro; +} + +/* functions +*/ + u3_noun + u3qe_shux(u3_atom a) + { + return u3kc_mux_f(u3k(a), _shux_shax, NULL, _shux_mix, NULL); + } + u3_noun + u3we_shux(u3_noun cor) + { + u3_noun sam; + + if ( u3_none == (sam = u3r_at(u3x_sam, cor)) ) { + return u3m_bail(c3__exit); + } + else { + return u3qe_shux(sam); + } + } From 38e7ab0ea87fc671bb30b64340af3a37a9aca3d5 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 4 Jun 2018 12:21:13 -0700 Subject: [PATCH 138/221] kill mux and shux jets, whose services are no longer required --- jets/c/mux.c | 85 --------------------------------------------------- jets/e/shux.c | 41 ------------------------- 2 files changed, 126 deletions(-) delete mode 100644 jets/c/mux.c delete mode 100644 jets/e/shux.c diff --git a/jets/c/mux.c b/jets/c/mux.c deleted file mode 100644 index 54f4b570f..000000000 --- a/jets/c/mux.c +++ /dev/null @@ -1,85 +0,0 @@ -/* j/3/mux.c -** -*/ -#include "all.h" - -static u3_atom -_ham(void* has_u, u3_atom a) -{ - u3j_site *sit_u = has_u; - return u3j_gate_slam(sit_u, a); -} - -static u3_atom -_mam(void* mis_u, u3_atom a, u3_atom b) -{ - u3j_site *sit_u = mis_u; - u3_noun sam = u3nc(a, b); - return u3j_gate_slam(sit_u, sam); -} - -static u3_noun -_mux_in(u3p(u3h_root) cax_p, u3_noun a, - u3_atom (*hat)(void*, u3_atom), void* has_u, - u3_atom (*mix)(void*, u3_atom, u3_atom), void* mis_u) -{ - u3_weak got = u3h_get(cax_p, a); - u3_atom pro; - - if ( u3_none != got ) { - pro = got; - } - else { - if ( c3y == u3ud(a) ) { - pro = hat(has_u, u3k(a)); - } - else { - u3_atom lef = _mux_in(cax_p, u3k(u3h(a)), hat, has_u, mix, mis_u), - rit = _mux_in(cax_p, u3k(u3t(a)), hat, has_u, mix, mis_u); - pro = mix(mis_u, lef, rit); - } - u3h_put(cax_p, a, u3k(pro)); - } - - u3z(a); - return pro; -} - -/* functions -*/ - u3_noun - u3kc_mux_f(u3_noun a, - u3_atom (*hat)(void*, u3_atom), void* has_u, - u3_atom (*mix)(void*, u3_atom, u3_atom), void* mis_u) - { - u3p(u3h_root) cax_p = u3h_new(); - u3_noun pro = _mux_in(cax_p, a, hat, has_u, mix, mis_u); - u3h_free(cax_p); - return pro; - } - u3_noun - u3qc_mux(u3_noun a, u3_noun hat, u3_noun mix) - { - u3_noun pro; - u3j_site hat_u, mix_u; - u3j_gate_prep(&hat_u, u3k(hat)); - u3j_gate_prep(&mix_u, u3k(mix)); - pro = u3kc_mux_f(u3k(a), _ham, &hat_u, _mam, &mix_u); - u3j_gate_lose(&mix_u); - u3j_gate_lose(&hat_u); - return pro; - } - u3_noun - u3wc_mux(u3_noun cor) - { - u3_noun sam; - - if ( u3_none == (sam = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__exit); - } - else { - u3_noun a, hat, mix; - u3x_trel(sam, &a, &hat, &mix); - return u3qc_mux(a, hat, mix); - } - } diff --git a/jets/e/shux.c b/jets/e/shux.c deleted file mode 100644 index 4f1af9917..000000000 --- a/jets/e/shux.c +++ /dev/null @@ -1,41 +0,0 @@ -/* j/5/shux.c -** -*/ -#include "all.h" - -static u3_atom -_shux_shax(void* dat_u, u3_atom a) -{ - u3_atom pro = u3qe_shax(a); - u3z(a); - return pro; -} - -static u3_atom -_shux_mix(void* dat_u, u3_atom a, u3_atom b) -{ - u3_atom tac = u3qc_cat(8, a, b), - pro = u3qe_shay(32, tac); - u3z(a); u3z(b); u3z(tac); - return pro; -} - -/* functions -*/ - u3_noun - u3qe_shux(u3_atom a) - { - return u3kc_mux_f(u3k(a), _shux_shax, NULL, _shux_mix, NULL); - } - u3_noun - u3we_shux(u3_noun cor) - { - u3_noun sam; - - if ( u3_none == (sam = u3r_at(u3x_sam, cor)) ) { - return u3m_bail(c3__exit); - } - else { - return u3qe_shux(sam); - } - } From a8d7d79b0cd7078360b68cc947b22240d8f2700d Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 4 Jun 2018 13:53:41 -0700 Subject: [PATCH 139/221] use nul prefix for regular (no loc) nock formulas, fix memory leak in _cj_mile, delete unused code --- include/noun/nock.h | 4 +- noun/allocate.c | 4 +- noun/jets.c | 154 ++------------------------------------------ noun/nock.c | 17 +++-- 4 files changed, 15 insertions(+), 164 deletions(-) diff --git a/include/noun/nock.h b/include/noun/nock.h index 06730be4b..ff376a875 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -47,10 +47,10 @@ u3n_nock_on(u3_noun bus, u3_noun fol); /* u3n_find(): return prog for given formula, - * split by key (can be u3_none). RETAIN. + * split by key (u3_nul for none). RETAIN. */ u3p(u3n_prog) - u3n_find(u3_weak key, u3_noun fol); + u3n_find(u3_noun key, u3_noun fol); /* u3n_burn(): execute u3n_prog with bus as subject. */ diff --git a/noun/allocate.c b/noun/allocate.c index fa33b10df..cca4163bc 100644 --- a/noun/allocate.c +++ b/noun/allocate.c @@ -1736,9 +1736,7 @@ u3a_sweep(void) : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w)))), box_u->use_w); u3a_print_memory("leak (minimum)", box_u->siz_w); - // fprintf(stderr, "\r\n\r\n"); - u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); - // fprintf(stderr, "\r\n\r\n"); + // u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w)))); leq_w += box_u->siz_w; } if ( box_u->cod_w ) { diff --git a/noun/jets.c b/noun/jets.c index 3246c43ee..00fe06f24 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -3,12 +3,6 @@ */ #include "all.h" -#if defined(U3_OS_osx) -#include -#else -#include -#endif - /** Data structures. **/ @@ -93,150 +87,9 @@ _cj_hash(c3_c* has_c) dig_y[32-(i_w>>1)] = hid_y << 4 | lod_y; } u3_noun pro = u3i_bytes(32, dig_y); - //fprintf(stderr, "has_c: %s\r\n", has_c); - //u3m_p("pro", pro); return pro; } -/* -typedef struct { -#if defined(U3_OS_osx) - CC_SHA256_CTX ctx_h; -#else - SHA256_CTX ctx_h; -#endif - c3_w len_w; - c3_w buf_w[65536]; -} _cj_sha; - -static void -_cj_digest_update(_cj_sha* sha_u, c3_y* byt_y, c3_w len_w) -{ -#if defined(U3_OS_osx) - CC_SHA256_Update(&(sha_u->ctx_h), &byt_y, len_w); -#else - SHA256_Update(&(sha_u->ctx_h), &byt_y, len_w); -#endif -} - -static void -_cj_digest_flush(_cj_sha* sha_u) -{ - if ( sha_u->inx_s ) { - _cj_digest_update(sha_u, sha_u->buf_w, sha_u->inx_s); - sha_u->len_w = 0; - } -} - -static void -_cj_digest_write(_cj_sha* sha_u, u3_atom a) -{ - c3_w met_w = u3r_met(3, a), - law_w = u3r_met(3, met_w); - - if ( 0 == law_w ) { - if ( sha_u->inx_s == 65535 ) { - _cj_digest_flush(sha_u); - } - sha_u->buf_y[sha_u->inx_s++] = 0; - } - else { - if ( (law_w + met_w) > 65536 ) { - c3_y* big_y = u3a_malloc(met_w); - u3r_bytes(0, met_w, big_y, a); - _cj_digest_flush(sha_u); - _cj_digest_update(sha_u, big_y, met_w); - u3a_free(big_y); - } - else { - if ( (sha_u->inx_s + met_w + law_w ) > 65536 ) { - _cj_digest_flush(sha_u); - } - u3r_bytes(0, law_w, sha_u->buf_y + sha_u->inx_s, law_w); - sha_u->inx_s += (c3_s) law_w; - u3r_bytes(0, met_w, sha_u->buf_y + sha_u->inx_s, a); - sha_u->inx_s += (c3_s) met_w; - } - } -} - -u3_noun -_cj_digest_final(_cj_sha* sha_u) -{ - c3_y dig_y[32]; -#if defined(U3_OS_osx) - CC_SHA256_Final(dig_y, &(sha_u->ctx_h)); -#else - SHA256_Final(dig_y, &(sha_u->ctx_h)); -#endif - return u3i_bytes(32, dig_y); -} - - -static void -_cj_digest_init(_cj_sha* sha_u) -{ -#if defined(U3_OS_osx) - CC_SHA256_Init(&(sha_u->ctx_h)); -#else - SHA256_Init(&(sha_u->ctx_h)); -#endif -} - -u3_noun -_cj_digest(u3_noun a) -{ - u3_noun *don, *top; - c3_y wis_y = c3_wiseof(u3_noun); - c3_o nor_o = u3a_is_north(u3R); - c3_ys mov = (c3y == nor_o) ? -wis_y : wis_y; - c3_ys off = (c3y == nor_o) ? 0 : -wis_y; - - u3p(u3h_root) har_p = u3h_new(); - c3_w inx_w = 0; - c3_l pre_l; - _cj_sha sha_u; - - _cj_digest_init(&sha_u); - don = u3to(u3_noun, u3R->cap_p + off); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = a; - - while ( top != don ) { - a = *top; - pre_l = u3h_git(har_p, a); - if ( u3_none != pre_l ) { - _cj_digest_write(&sha_u, 2); - _cj_digest_write(&sha_u, pre_l); - u3R->cap_p -= mov; - top = u3to(u3_noun, u3R->cap_p + off); - } - else { - u3h_put(har_p, a, inx_w++); - c3_assert( c3y == u3a_is_cat(inx_w) ); - if ( c3y == u3du(a) ) { - _cj_digest_write(&sha_u, 1); - *top = u3h(a); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = u3t(a); - } - else { - _cj_digest_write(&sha_u, 0); - _cj_digest_write(&sha_u, a); - u3R->cap_p -= mov; - top = u3to(u3_noun, u3R->cap_p + off); - } - } - } - - u3h_free(har_p); - _cj_digest_flush(&sha_u); - return _cj_digest_final(&sha_u); -} -*/ - /* _cj_bash(): battery hash. RETAIN. */ static u3_noun @@ -257,7 +110,6 @@ _cj_bash(u3_noun bat) else { u3_noun jan = u3qe_jam(bat); pro = u3qe_shax(jan); - //pro = u3qe_sham(bat); u3h_put(u3R->jed.bas_p, bat, u3k(pro)); u3z(jan); break; @@ -1165,7 +1017,7 @@ _cj_prog(u3_weak loc, u3_noun fol) { u3p(u3n_prog) pog_p; u3t_off(glu_o); - pog_p = u3n_find(loc, fol); + pog_p = u3n_find((loc == u3_none ? u3_nul : loc), fol); u3t_on(glu_o); return pog_p; } @@ -1977,12 +1829,14 @@ _cj_mile(u3_noun clu, u3_noun cor) loc = _cj_spot(cor, &bas); if ( u3_none == loc ) { loc = _cj_mine(cey, cor, bas); - u3z(bas); } else { _cj_audit(loc, cey, cor); } u3z(cey); + if ( u3_none != bas ) { + u3z(bas); + } } u3z(cor); } diff --git a/noun/nock.c b/noun/nock.c index d7191ad44..89ebaa4e5 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1439,14 +1439,13 @@ _n_bite(u3_noun fol) { return _n_prog_from_ops(ops); } -/* _n_find(): return prog for given formula. fol is RETAINED. +/* _n_find(): return prog for given formula with prefix (u3_nul for none). + * RETAIN. */ static u3n_prog* -_n_find(u3_weak key, u3_noun fol) +_n_find(u3_noun pre, u3_noun fol) { - key = (u3_none == key) - ? u3k(fol) - : u3nc(u3k(key), u3k(fol)); + u3_noun key = u3nc(u3k(pre), u3k(fol)); u3_weak pog = u3h_git(u3R->byc.har_p, key); if ( u3_none != pog ) { u3z(key); @@ -1486,10 +1485,10 @@ _n_find(u3_weak key, u3_noun fol) } /* u3n_find(): return prog for given formula, - * split by key (can be u3_none). RETAIN. + * split by key (u3_nul for no key). RETAIN. */ u3p(u3n_prog) -u3n_find(u3_weak key, u3_noun fol) +u3n_find(u3_noun key, u3_noun fol) { u3p(u3n_prog) pog_p; u3t_on(noc_o); @@ -1800,7 +1799,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) fam->pog_u = pog_u; _n_push(mov, off, x); nock_out: - pog_u = _n_find(u3_none, o); + pog_u = _n_find(u3_nul, o); pog = pog_u->byc_u.ops_y; ip_w = 0; #ifdef U3_CPU_DEBUG @@ -2196,7 +2195,7 @@ u3n_burn(u3p(u3n_prog) pog_p, u3_noun bus) static u3_noun _n_burn_on(u3_noun bus, u3_noun fol) { - u3n_prog* pog_u = _n_find(u3_none, fol); + u3n_prog* pog_u = _n_find(u3_nul, fol); u3z(fol); return _n_burn_out(bus, pog_u); From c8da5efe2bdea0f0b6a0d224339a00692a3f59b5 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 10 Jun 2018 10:39:36 -0700 Subject: [PATCH 140/221] first pass at nock 12 impl --- noun/nock.c | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/noun/nock.c b/noun/nock.c index 89ebaa4e5..10124cd43 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -526,6 +526,23 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIB 70 #define SLIS 71 #define SAVE 72 +// nock 12 +#define MUTH 73 +#define KUTH 74 +#define MUTT 75 +#define KUTT 76 +#define MUSM 77 +#define KUSM 78 +#define MUCS 79 +#define KUCS 80 +#define MUTB 81 +#define MUTS 82 +#define MITB 83 +#define MITS 84 +#define KUTB 85 +#define KUTS 86 +#define KITB 87 +#define KITS 88 /* _n_arg(): return the size (in bytes) of an opcode's argument */ @@ -538,6 +555,7 @@ _n_arg(c3_y cod_y) case SAMB: case SANB: case SBIP: case SBIN: case SLIB: case SKIB: case KICB: case TICB: case BUSH: case BAST: case BALT: + case KITB: case MITB: return sizeof(c3_y); case FASK: case FASL: case FISL: case FISK: @@ -545,6 +563,7 @@ _n_arg(c3_y cod_y) case SAMS: case SANS: case SIPS: case SINS: case SLIS: case SKIS: case KICS: case TICS: case SUSH: case SAST: case SALT: + case KITS: case MITS: return sizeof(c3_s); case SWIP: case SWIN: @@ -657,6 +676,7 @@ _n_melt(u3_noun ops, c3_w* byc_w, c3_w* cal_w, case BUSH: case FIBK: case FIBL: case SANB: case LIBL: case LIBK: + case KITB: case MITB: a_w = (*lit_w)++; if ( a_w <= 0xFF ) { siz_y[i_w] = 2; @@ -885,6 +905,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) case FIBK: case FIBL: case LIBK: case LIBL: case BUSH: case SANB: + case KITB: case MITB: _n_prog_asm_inx(buf_y, &i_w, lit_s, cod); pog_u->lit_u.non[lit_s++] = u3k(u3t(op)); break; @@ -992,6 +1013,10 @@ static char* opcode_names[] = { "balt", "salt", "skib", "skis", "slib", "slis", "save", + "muth", "kuth", "mutt", "kutt", + "musm", "kusm", "mucs", "kucs", + "mutb", "muts", "mitb", "mits", + "kutb", "kuts", "kitb", "kits", }; #endif @@ -1289,6 +1314,42 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; + case 12: { + u3_noun axe, nef; + u3x_cell(arg, &hed, &tel); + u3x_cell(hed, &axe, &nef); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, nef, c3n, c3n); + + ++tot_w; + switch ( axe ) { + case 2: + _n_emit(ops, (c3y == los_o) ? MUTH : KUTH); + break; + + case 3: + _n_emit(ops, (c3y == los_o) ? MUTT : KUTT); + break; + + case u3x_sam: + _n_emit(ops, (c3y == los_o) ? MUSM : KUSM); + break; + + case u3x_con_sam: + _n_emit(ops, (c3y == los_o) ? MUCS : KUCS); + break; + + default: + op_y = (c3y == los_o) + ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITL + : (axe <= 0xFF) ? KUTB : (axe <= 0xFFFF) ? KUTS : KITB; // overflows to KITS + _n_emit(ops, u3nc(op_y, axe)); + break; + } + break; + } + default: u3m_bail(c3__exit); return 0; @@ -1533,6 +1594,26 @@ _n_kale(u3_noun a) return a; } + +/* _n_edit(): PRODUCE a modified big with its axe axis + * changed to som. axe is RETAINED. + */ +static u3_noun +_n_edit(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + return u3i_molt(big, axe, som, 0); + } + else { + u3_noun mor = u3qc_mas(axe); + u3_noun pro = ( 2 == u3qc_cap(axe) ) + ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) + : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); + u3z(mor); + return pro; + } +} + typedef struct { u3n_prog* pog_u; c3_w ip_w; @@ -1573,6 +1654,10 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) &&do_balt, &&do_salt, &&do_skib, &&do_skis, &&do_slib, &&do_slis, &&do_save, + &&do_muth, &&do_kuth, &&do_mutt, &&do_kutt, + &&do_musm, &&do_kusm, &&do_mucs, &&do_kucs, + &&do_mutb, &&do_muts, &&do_mitb, &&do_mits, + &&do_kutb, &&do_kuts, &&do_kitb, &&do_kits, }; u3j_site* sit_u; @@ -2158,6 +2243,104 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) *top = x; u3z(o); BURN(); + + do_kuth: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto muth_in; + do_muth: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + muth_in: + o = *top; + *top = u3nc(x, u3k(u3t(o))); + u3z(o); + BURN(); + + do_kutt: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto mutt_in; + do_mutt: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + mutt_in: + o = *top; + *top = u3nc(u3k(u3h(o)), x); + u3z(o); + BURN(); + + do_kusm: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto musm_in; + do_musm: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + musm_in: + o = *top; + *top = u3nt(u3k(u3h(o)), x, u3k(u3t(u3t(o)))); + u3z(o); + BURN(); + + do_kucs: + x = _n_pep(mov, off); + top = _n_swap(mov, off); + goto mucs_in; + do_mucs: + x = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + mucs_in: + o = *top; + *top = u3nc(u3k(u3h(o)), + u3nt(u3k(u3h(u3t(o))), x, u3k(u3t(u3t(u3t(o)))))); + u3z(o); + BURN(); + + do_kitb: + x = pog_u->lit_u.non[pog[ip_w++]]; + goto kut_in; + + do_kits: + x = pog_u->lit_u.non[_n_resh(pog, &ip_w)]; + goto kut_in; + + do_kuts: + x = _n_resh(pog, &ip_w); + goto kut_in; + + do_kutb: + x = pog[ip_w++]; + kut_in: + o = _n_pep(mov, off); + top = _n_swap(mov, off); + goto edit_in; + + do_mitb: + x = pog_u->lit_u.non[pog[ip_w++]]; + goto mut_in; + + do_mits: + x = pog_u->lit_u.non[_n_resh(pog, &ip_w)]; + goto mut_in; + + do_muts: + x = _n_resh(pog, &ip_w); + goto mut_in; + + do_mutb: + x = pog[ip_w++]; + mut_in: + o = _n_pep(mov, off); + _n_toss(mov, off); + top = _n_peek(off); + edit_in: + *top = _n_edit(*top, x, o); + BURN(); } } From 0c64dabc972a26e82276198b9e8866424874a1f8 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Sun, 10 Jun 2018 14:02:07 -0700 Subject: [PATCH 141/221] bugfixes --- noun/jets.c | 16 ++++++++++++---- noun/nock.c | 13 ++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 00fe06f24..e186b4a1b 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1399,15 +1399,23 @@ u3j_site_ream(u3j_site* sit_u) static void _cj_site_lock(u3_noun loc, u3_noun cor, u3j_site* sit_u) { + u3_weak fol; if ( (u3_none != sit_u->bat) && (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { return; } - sit_u->pog_p = _cj_prog(loc, u3r_at(sit_u->axe, cor)); - if ( u3_none != sit_u->bat ) { - u3z(sit_u->bat); + + fol = u3r_at(sit_u->axe, cor); + if ( u3_none == fol ) { + u3m_bail(c3__exit); + } + else { + sit_u->pog_p = _cj_prog(loc, fol); + if ( u3_none != sit_u->bat ) { + u3z(sit_u->bat); + } + sit_u->bat = u3k(u3h(cor)); } - sit_u->bat = u3k(u3h(cor)); } /* _cj_burn(): stop tracing glu and call a nock program diff --git a/noun/nock.c b/noun/nock.c index 10124cd43..c63a466c3 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -543,6 +543,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define KUTS 86 #define KITB 87 #define KITS 88 +#define LAST 89 /* _n_arg(): return the size (in bytes) of an opcode's argument */ @@ -555,7 +556,7 @@ _n_arg(c3_y cod_y) case SAMB: case SANB: case SBIP: case SBIN: case SLIB: case SKIB: case KICB: case TICB: case BUSH: case BAST: case BALT: - case KITB: case MITB: + case MUTB: case KUTB: case MITB: case KITB: return sizeof(c3_y); case FASK: case FASL: case FISL: case FISK: @@ -563,14 +564,14 @@ _n_arg(c3_y cod_y) case SAMS: case SANS: case SIPS: case SINS: case SLIS: case SKIS: case KICS: case TICS: case SUSH: case SAST: case SALT: - case KITS: case MITS: + case MUTS: case KUTS: case MITS: case KITS: return sizeof(c3_s); case SWIP: case SWIN: return sizeof(c3_l); default: - c3_assert( cod_y <= SAVE ); + c3_assert( cod_y < LAST ); return 0; } } @@ -874,6 +875,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) /* 8-bit direct args */ case FABK: case FABL: case LITB: case LILB: + case MUTB: case KUTB: case SAMB: buf_y[i_w--] = (c3_y) u3t(op); buf_y[i_w] = (c3_y) cod; @@ -882,6 +884,7 @@ _n_prog_asm(u3_noun ops, u3n_prog* pog_u, u3_noun sip) /* 16-bit direct args */ case FASK: case FASL: case LILS: case LITS: + case MUTS: case KUTS: case SAMS: case SIPS: case SINS: { c3_s off_s = u3t(op); buf_y[i_w--] = (c3_y) (off_s >> 8); @@ -1342,9 +1345,9 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) default: op_y = (c3y == los_o) - ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITL + ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITS : (axe <= 0xFF) ? KUTB : (axe <= 0xFFFF) ? KUTS : KITB; // overflows to KITS - _n_emit(ops, u3nc(op_y, axe)); + _n_emit(ops, u3nc(op_y, u3k(axe))); break; } break; From 61f9a39f3551cc1266f383119c028043cb0f183b Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Mon, 11 Jun 2018 15:04:49 -0700 Subject: [PATCH 142/221] disable hike jet, kill errant and unneccessary mutate-context-sample opcodes --- jets/f/hike.c | 1 + jets/tree.c | 4 +++- noun/nock.c | 43 +++++++++++-------------------------------- 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/jets/f/hike.c b/jets/f/hike.c index 567b1ca0d..6b1bb5b36 100644 --- a/jets/f/hike.c +++ b/jets/f/hike.c @@ -89,6 +89,7 @@ u3qf_hike(u3_noun axe, u3_noun pac) { + c3_assert(0); if ( (u3_nul == pac) ) { return u3nc(0, u3k(axe)); } diff --git a/jets/tree.c b/jets/tree.c index 6ca70d218..cf490820f 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -285,11 +285,13 @@ static u3j_core _143_hex_d[] = 0, }; +/* hike disabled while implementing edit static u3j_harm _143_pen_hike_a[] = {{".2", u3wf_hike}, {}}; static c3_c* _143_pen_hike_ha[] = { "7503dc65fe3164b3e95f81b51afd64ab615e26516b60df95241244e2b793d024", 0, }; +*/ static u3j_harm _143_pen_look_a[] = {{".2", u3wf_look}, {}}; static c3_c* _143_pen_look_ha[] = { "04349d58bcb1317eba57eed8011c27a3ef7c3332c6595e45307a2d06bfc0e8d0", @@ -473,7 +475,7 @@ static u3j_core _143_pen_d[] = { "flor", 7, _143_pen_flor_a, 0, _143_pen_flor_ha }, { "fork", 7, _143_pen_fork_a, 0, _143_pen_fork_ha }, { "help", 7, _143_pen_help_a, 0, _143_pen_help_ha }, - { "hike", 7, _143_pen_hike_a, 0, _143_pen_hike_ha }, +// { "hike", 7, _143_pen_hike_a, 0, _143_pen_hike_ha }, { "look", 7, _143_pen_look_a, 0, _143_pen_look_ha }, { "loot", 7, _143_pen_loot_a, 0, _143_pen_loot_ha }, diff --git a/noun/nock.c b/noun/nock.c index c63a466c3..ca9506920 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -533,17 +533,15 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define KUTT 76 #define MUSM 77 #define KUSM 78 -#define MUCS 79 -#define KUCS 80 -#define MUTB 81 -#define MUTS 82 -#define MITB 83 -#define MITS 84 -#define KUTB 85 -#define KUTS 86 -#define KITB 87 -#define KITS 88 -#define LAST 89 +#define MUTB 79 +#define MUTS 80 +#define MITB 81 +#define MITS 82 +#define KUTB 83 +#define KUTS 84 +#define KITB 85 +#define KITS 86 +#define LAST 87 /* _n_arg(): return the size (in bytes) of an opcode's argument */ @@ -1017,7 +1015,7 @@ static char* opcode_names[] = { "skib", "skis", "slib", "slis", "save", "muth", "kuth", "mutt", "kutt", - "musm", "kusm", "mucs", "kucs", + "musm", "kusm", "mutb", "muts", "mitb", "mits", "kutb", "kuts", "kitb", "kits", }; @@ -1339,10 +1337,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) _n_emit(ops, (c3y == los_o) ? MUSM : KUSM); break; - case u3x_con_sam: - _n_emit(ops, (c3y == los_o) ? MUCS : KUCS); - break; - default: op_y = (c3y == los_o) ? (axe <= 0xFF) ? MUTB : (axe <= 0xFFFF) ? MUTS : MITB // overflows to MITS @@ -1658,7 +1652,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) &&do_skib, &&do_skis, &&do_slib, &&do_slis, &&do_save, &&do_muth, &&do_kuth, &&do_mutt, &&do_kutt, - &&do_musm, &&do_kusm, &&do_mucs, &&do_kucs, + &&do_musm, &&do_kusm, &&do_mutb, &&do_muts, &&do_mitb, &&do_mits, &&do_kutb, &&do_kuts, &&do_kitb, &&do_kits, }; @@ -2289,21 +2283,6 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) u3z(o); BURN(); - do_kucs: - x = _n_pep(mov, off); - top = _n_swap(mov, off); - goto mucs_in; - do_mucs: - x = _n_pep(mov, off); - _n_toss(mov, off); - top = _n_peek(off); - mucs_in: - o = *top; - *top = u3nc(u3k(u3h(o)), - u3nt(u3k(u3h(u3t(o))), x, u3k(u3t(u3t(u3t(o)))))); - u3z(o); - BURN(); - do_kitb: x = pog_u->lit_u.non[pog[ip_w++]]; goto kut_in; From 0fe4157b8252d9965356a1e9134b94d62ae6aeba Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 12 Jun 2018 10:23:47 -0700 Subject: [PATCH 143/221] small memory leak for large edits --- noun/nock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/noun/nock.c b/noun/nock.c index ca9506920..a2e3a9194 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1607,6 +1607,7 @@ _n_edit(u3_noun big, u3_noun axe, u3_noun som) ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); u3z(mor); + u3z(big); return pro; } } From a3f27a6a39c55d5430689bfd1a18a31673da078e Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 12 Jun 2018 10:24:36 -0700 Subject: [PATCH 144/221] bypass mat and chop directly in jam --- jets/e/jam.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 908556736..209b9e0f1 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -57,9 +57,17 @@ _jam_buf_chop(_jam_buf* buf_u, c3_w met_w, u3_noun a) static void _jam_buf_atom(_jam_buf* buf_u, u3_noun a) { - u3_noun mat = u3qe_mat(a); - _jam_buf_chop(buf_u, u3h(mat), u3t(mat)); - u3z(mat); + if ( 0 == a ) { + _jam_buf_chop(buf_u, 1, 1); + } + else { + c3_w b_w = u3r_met(0, a), + c_w = u3r_met(0, b_w); + c3_assert(c_w <= 32); + _jam_buf_chop(buf_u, c_w+1, 1 << c_w); + _jam_buf_chop(buf_u, c_w-1, b_w & ((1 << (c_w-1)) - 1)); + _jam_buf_chop(buf_u, b_w, a); + } } static u3_noun From e629272ac6aa8931a7e2994aaecaccfc71a00c3c Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 14 Jun 2018 11:36:56 -0700 Subject: [PATCH 145/221] avoid allocating an atom for _cj_bash --- jets/e/jam.c | 144 +++++++++++++++++++++++++++------------------------ noun/jets.c | 39 ++++++++++++-- 2 files changed, 112 insertions(+), 71 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 209b9e0f1..5869d657b 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -40,7 +40,7 @@ _jam_buf_grow(_jam_buf* buf_u, c3_w mor_w) ++new_w; } - buf_u->wor_w = u3a_realloc(buf_u->wor_w, new_w * sizeof(c3_w)); + buf_u->wor_w = u3a_wealloc(buf_u->wor_w, new_w); memset(buf_u->wor_w + old_w, 0, (new_w - old_w) * sizeof(c3_w)); } } @@ -70,91 +70,99 @@ _jam_buf_atom(_jam_buf* buf_u, u3_noun a) } } -static u3_noun -_jam_buf_top(u3_noun a) -{ - u3p(u3h_root) har_p = u3h_new(); - c3_o nor_o = u3a_is_north(u3R); - c3_y wis_y = c3_wiseof(u3_noun); - c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); - c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); - u3_noun* top, *don = u3to(u3_noun, u3R->cap_p + off); - _jam_buf buf_u; - u3_weak c; - c3_o cel_o; - c3_w* sal_w, len_w; +/* functions +*/ + /* u3qe_jam_buf(): jam without atom allocation. returns + * atom-suitable words, and *bit_w will + * have the length (in bits). return should + * be freed with u3a_wfree(). + */ + c3_w* + u3qe_jam_buf(u3_noun a, c3_w* bit_w) + { + u3p(u3h_root) har_p = u3h_new(); + c3_o nor_o = u3a_is_north(u3R); + c3_y wis_y = c3_wiseof(u3_noun); + c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); + c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); + u3_noun* top, *don = u3to(u3_noun, u3R->cap_p + off); + u3_weak c; + c3_o cel_o; + c3_w len_w; + _jam_buf buf_u; - buf_u.a_w = 144; // fib(12) is small enough to be reasonably fast to allocate. - buf_u.b_w = 89; // fib(11) is needed to get fib(13). - len_w = buf_u.a_w >> 5; - if ( (len_w << 5) != buf_u.a_w ) { - ++len_w; - } - buf_u.wor_w = u3a_calloc(len_w, sizeof(c3_w)); - buf_u.bit_w = 0; + buf_u.a_w = 144; // fib(12) is small enough to be reasonably fast to allocate. + buf_u.b_w = 89; // fib(11) is needed to get fib(13). + len_w = buf_u.a_w >> 5; + if ( (len_w << 5) != buf_u.a_w ) { + ++len_w; + } + buf_u.wor_w = u3a_walloc(len_w); + buf_u.bit_w = 0; + memset(buf_u.wor_w, 0, len_w * sizeof(c3_w)); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = a; + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = a; - while ( top != don ) { - a = *top; - cel_o = u3du(a); - c = u3h_git(har_p, a); - if ( u3_none != c ) { - if ( c3y == cel_o ) { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); - } - else { - if ( u3r_met(0, a) <= u3r_met(0, c) ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); + while ( top != don ) { + a = *top; + cel_o = u3du(a); + c = u3h_git(har_p, a); + if ( u3_none != c ) { + if ( c3y == cel_o ) { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); } else { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); + if ( u3r_met(0, a) <= u3r_met(0, c) ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); + } + else { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); + } } - } - u3R->cap_p -= mov; - top = u3to(u3_noun, u3R->cap_p + off); - } - else { - u3h_put(har_p, a, buf_u.bit_w); - if ( c3n == cel_o ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); u3R->cap_p -= mov; top = u3to(u3_noun, u3R->cap_p + off); } else { - _jam_buf_chop(&buf_u, 2, 1); - *top = u3t(a); + u3h_put(har_p, a, buf_u.bit_w); + if ( c3n == cel_o ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); + u3R->cap_p -= mov; + top = u3to(u3_noun, u3R->cap_p + off); + } + else { + _jam_buf_chop(&buf_u, 2, 1); + *top = u3t(a); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = u3h(a); + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = u3h(a); + } } } - } - len_w = buf_u.bit_w >> 5; - if ( (len_w << 5) != buf_u.bit_w ) { - ++len_w; + *bit_w = buf_u.bit_w; + u3h_free(har_p); + return buf_u.wor_w; } - sal_w = u3a_slab(len_w); - memcpy(sal_w, buf_u.wor_w, len_w*sizeof(c3_w)); - u3a_free(buf_u.wor_w); - u3h_free(har_p); - return u3a_moot(sal_w); -} - -/* functions -*/ u3_noun u3qe_jam(u3_atom a) { - return _jam_buf_top(a); + c3_w bit_w, *sal_w; + c3_w* wor_w = u3qe_jam_buf(a, &bit_w); + c3_w len_w = bit_w >> 5; + if ( (len_w << 5) != bit_w ) { + ++len_w; + } + sal_w = u3a_slab(len_w); + memcpy(sal_w, wor_w, len_w*sizeof(c3_w)); + u3a_wfree(wor_w); + return u3a_moot(sal_w); } u3_noun u3we_jam(u3_noun cor) diff --git a/noun/jets.c b/noun/jets.c index e186b4a1b..5da4c3b56 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -3,6 +3,12 @@ */ #include "all.h" +#if defined(U3_OS_osx) +#include +#else +#include +#endif + /** Data structures. **/ @@ -90,6 +96,9 @@ _cj_hash(c3_c* has_c) return pro; } +// in the jam jet file +c3_w* u3qe_jam_buf(u3_noun, c3_w* bit_w); + /* _cj_bash(): battery hash. RETAIN. */ static u3_noun @@ -108,10 +117,34 @@ _cj_bash(u3_noun bat) rod_u = u3to(u3_road, rod_u->par_p); } else { - u3_noun jan = u3qe_jam(bat); - pro = u3qe_shax(jan); + c3_w bit_w, met_w; + c3_w* wor_w; + c3_y* fat_y; + c3_y dig_y[32]; + + wor_w = u3qe_jam_buf(bat, &bit_w); + met_w = bit_w >> 3; + if ( bit_w != met_w << 3 ) { + ++met_w; + } + // assume little-endian + fat_y = (c3_y*) wor_w; +#if defined(U3_OS_osx) + CC_SHA256_CTX ctx_h; + + CC_SHA256_Init(&ctx_h); + CC_SHA256_Update(&ctx_h, fat_y, met_w); + CC_SHA256_Final(dig_y, &ctx_h); +#else + SHA256_CTX ctx_h; + + SHA256_Init(&ctx_h); + SHA256_Update(&ctx_h, fat_y, met_w); + SHA256_Final(dig_y, &ctx_h); +#endif + pro = u3i_bytes(32, dig_y); u3h_put(u3R->jed.bas_p, bat, u3k(pro)); - u3z(jan); + u3a_wfree(wor_w); break; } } From 6ce5fb681ea4f5ab442c6c7c877c5a31f74aef76 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 14 Jun 2018 12:25:45 -0700 Subject: [PATCH 146/221] bail in _n_edit on invalid path --- noun/nock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/noun/nock.c b/noun/nock.c index a2e3a9194..1ac6de74f 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1603,6 +1603,9 @@ _n_edit(u3_noun big, u3_noun axe, u3_noun som) } else { u3_noun mor = u3qc_mas(axe); + if ( c3n == u3du(big) ) { + u3m_bail(c3__exit); + } u3_noun pro = ( 2 == u3qc_cap(axe) ) ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); From dca55cf921a96a51cfcf483e68f224f2398257c7 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 12 Jun 2018 10:24:36 -0700 Subject: [PATCH 147/221] bypass mat and chop directly in jam --- jets/e/jam.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 908556736..209b9e0f1 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -57,9 +57,17 @@ _jam_buf_chop(_jam_buf* buf_u, c3_w met_w, u3_noun a) static void _jam_buf_atom(_jam_buf* buf_u, u3_noun a) { - u3_noun mat = u3qe_mat(a); - _jam_buf_chop(buf_u, u3h(mat), u3t(mat)); - u3z(mat); + if ( 0 == a ) { + _jam_buf_chop(buf_u, 1, 1); + } + else { + c3_w b_w = u3r_met(0, a), + c_w = u3r_met(0, b_w); + c3_assert(c_w <= 32); + _jam_buf_chop(buf_u, c_w+1, 1 << c_w); + _jam_buf_chop(buf_u, c_w-1, b_w & ((1 << (c_w-1)) - 1)); + _jam_buf_chop(buf_u, b_w, a); + } } static u3_noun From 07e524532f396cd47191abc645fe684435d5f8fd Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Thu, 14 Jun 2018 11:36:56 -0700 Subject: [PATCH 148/221] avoid allocating an atom for _cj_bash --- jets/e/jam.c | 144 +++++++++++++++++++++++++++------------------------ noun/jets.c | 39 ++++++++++++-- 2 files changed, 112 insertions(+), 71 deletions(-) diff --git a/jets/e/jam.c b/jets/e/jam.c index 209b9e0f1..5869d657b 100644 --- a/jets/e/jam.c +++ b/jets/e/jam.c @@ -40,7 +40,7 @@ _jam_buf_grow(_jam_buf* buf_u, c3_w mor_w) ++new_w; } - buf_u->wor_w = u3a_realloc(buf_u->wor_w, new_w * sizeof(c3_w)); + buf_u->wor_w = u3a_wealloc(buf_u->wor_w, new_w); memset(buf_u->wor_w + old_w, 0, (new_w - old_w) * sizeof(c3_w)); } } @@ -70,91 +70,99 @@ _jam_buf_atom(_jam_buf* buf_u, u3_noun a) } } -static u3_noun -_jam_buf_top(u3_noun a) -{ - u3p(u3h_root) har_p = u3h_new(); - c3_o nor_o = u3a_is_north(u3R); - c3_y wis_y = c3_wiseof(u3_noun); - c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); - c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); - u3_noun* top, *don = u3to(u3_noun, u3R->cap_p + off); - _jam_buf buf_u; - u3_weak c; - c3_o cel_o; - c3_w* sal_w, len_w; +/* functions +*/ + /* u3qe_jam_buf(): jam without atom allocation. returns + * atom-suitable words, and *bit_w will + * have the length (in bits). return should + * be freed with u3a_wfree(). + */ + c3_w* + u3qe_jam_buf(u3_noun a, c3_w* bit_w) + { + u3p(u3h_root) har_p = u3h_new(); + c3_o nor_o = u3a_is_north(u3R); + c3_y wis_y = c3_wiseof(u3_noun); + c3_ys mov = ( c3y == nor_o ? -wis_y : wis_y ); + c3_ys off = ( c3y == nor_o ? 0 : -wis_y ); + u3_noun* top, *don = u3to(u3_noun, u3R->cap_p + off); + u3_weak c; + c3_o cel_o; + c3_w len_w; + _jam_buf buf_u; - buf_u.a_w = 144; // fib(12) is small enough to be reasonably fast to allocate. - buf_u.b_w = 89; // fib(11) is needed to get fib(13). - len_w = buf_u.a_w >> 5; - if ( (len_w << 5) != buf_u.a_w ) { - ++len_w; - } - buf_u.wor_w = u3a_calloc(len_w, sizeof(c3_w)); - buf_u.bit_w = 0; + buf_u.a_w = 144; // fib(12) is small enough to be reasonably fast to allocate. + buf_u.b_w = 89; // fib(11) is needed to get fib(13). + len_w = buf_u.a_w >> 5; + if ( (len_w << 5) != buf_u.a_w ) { + ++len_w; + } + buf_u.wor_w = u3a_walloc(len_w); + buf_u.bit_w = 0; + memset(buf_u.wor_w, 0, len_w * sizeof(c3_w)); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = a; + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = a; - while ( top != don ) { - a = *top; - cel_o = u3du(a); - c = u3h_git(har_p, a); - if ( u3_none != c ) { - if ( c3y == cel_o ) { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); - } - else { - if ( u3r_met(0, a) <= u3r_met(0, c) ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); + while ( top != don ) { + a = *top; + cel_o = u3du(a); + c = u3h_git(har_p, a); + if ( u3_none != c ) { + if ( c3y == cel_o ) { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); } else { - _jam_buf_chop(&buf_u, 2, 3); - _jam_buf_atom(&buf_u, c); + if ( u3r_met(0, a) <= u3r_met(0, c) ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); + } + else { + _jam_buf_chop(&buf_u, 2, 3); + _jam_buf_atom(&buf_u, c); + } } - } - u3R->cap_p -= mov; - top = u3to(u3_noun, u3R->cap_p + off); - } - else { - u3h_put(har_p, a, buf_u.bit_w); - if ( c3n == cel_o ) { - _jam_buf_chop(&buf_u, 1, 0); - _jam_buf_atom(&buf_u, a); u3R->cap_p -= mov; top = u3to(u3_noun, u3R->cap_p + off); } else { - _jam_buf_chop(&buf_u, 2, 1); - *top = u3t(a); + u3h_put(har_p, a, buf_u.bit_w); + if ( c3n == cel_o ) { + _jam_buf_chop(&buf_u, 1, 0); + _jam_buf_atom(&buf_u, a); + u3R->cap_p -= mov; + top = u3to(u3_noun, u3R->cap_p + off); + } + else { + _jam_buf_chop(&buf_u, 2, 1); + *top = u3t(a); - u3R->cap_p += mov; - top = u3to(u3_noun, u3R->cap_p + off); - *top = u3h(a); + u3R->cap_p += mov; + top = u3to(u3_noun, u3R->cap_p + off); + *top = u3h(a); + } } } - } - len_w = buf_u.bit_w >> 5; - if ( (len_w << 5) != buf_u.bit_w ) { - ++len_w; + *bit_w = buf_u.bit_w; + u3h_free(har_p); + return buf_u.wor_w; } - sal_w = u3a_slab(len_w); - memcpy(sal_w, buf_u.wor_w, len_w*sizeof(c3_w)); - u3a_free(buf_u.wor_w); - u3h_free(har_p); - return u3a_moot(sal_w); -} - -/* functions -*/ u3_noun u3qe_jam(u3_atom a) { - return _jam_buf_top(a); + c3_w bit_w, *sal_w; + c3_w* wor_w = u3qe_jam_buf(a, &bit_w); + c3_w len_w = bit_w >> 5; + if ( (len_w << 5) != bit_w ) { + ++len_w; + } + sal_w = u3a_slab(len_w); + memcpy(sal_w, wor_w, len_w*sizeof(c3_w)); + u3a_wfree(wor_w); + return u3a_moot(sal_w); } u3_noun u3we_jam(u3_noun cor) diff --git a/noun/jets.c b/noun/jets.c index 00fe06f24..c9f89ad4c 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -3,6 +3,12 @@ */ #include "all.h" +#if defined(U3_OS_osx) +#include +#else +#include +#endif + /** Data structures. **/ @@ -90,6 +96,9 @@ _cj_hash(c3_c* has_c) return pro; } +// in the jam jet file +c3_w* u3qe_jam_buf(u3_noun, c3_w* bit_w); + /* _cj_bash(): battery hash. RETAIN. */ static u3_noun @@ -108,10 +117,34 @@ _cj_bash(u3_noun bat) rod_u = u3to(u3_road, rod_u->par_p); } else { - u3_noun jan = u3qe_jam(bat); - pro = u3qe_shax(jan); + c3_w bit_w, met_w; + c3_w* wor_w; + c3_y* fat_y; + c3_y dig_y[32]; + + wor_w = u3qe_jam_buf(bat, &bit_w); + met_w = bit_w >> 3; + if ( bit_w != met_w << 3 ) { + ++met_w; + } + // assume little-endian + fat_y = (c3_y*) wor_w; +#if defined(U3_OS_osx) + CC_SHA256_CTX ctx_h; + + CC_SHA256_Init(&ctx_h); + CC_SHA256_Update(&ctx_h, fat_y, met_w); + CC_SHA256_Final(dig_y, &ctx_h); +#else + SHA256_CTX ctx_h; + + SHA256_Init(&ctx_h); + SHA256_Update(&ctx_h, fat_y, met_w); + SHA256_Final(dig_y, &ctx_h); +#endif + pro = u3i_bytes(32, dig_y); u3h_put(u3R->jed.bas_p, bat, u3k(pro)); - u3z(jan); + u3a_wfree(wor_w); break; } } From 7dcc2303d119b42389e4a07bd3ab0ab50888a33a Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 26 Jun 2018 11:49:15 -0700 Subject: [PATCH 149/221] mutating edit --- include/noun/allocate.h | 9 +++ include/noun/imprison.h | 8 +++ noun/imprison.c | 144 ++++++++++++++++++++++++++++++++++++++++ noun/nock.c | 26 +------- 4 files changed, 162 insertions(+), 25 deletions(-) diff --git a/include/noun/allocate.h b/include/noun/allocate.h index d2a8a55b6..8533158d9 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -256,6 +256,15 @@ ? u3a_north_is_senior(r, som) \ : u3a_south_is_senior(r, som) ) +# define u3a_is_mutable(r, som) \ + ( _(u3a_is_atom(som)) \ + ? c3n \ + : _(u3a_is_senior(r, som)) \ + ? c3n \ + : _(u3a_is_junior(r, som)) \ + ? c3n \ + : (u3a_botox(u3a_to_ptr(som))->use_w == 1) \ + ? c3y : c3n ) /** Globals. **/ diff --git a/include/noun/imprison.h b/include/noun/imprison.h index efda35fab..f552c87f5 100644 --- a/include/noun/imprison.h +++ b/include/noun/imprison.h @@ -55,6 +55,14 @@ u3_noun u3i_qual(u3_noun a, u3_noun b, u3_noun c, u3_noun d); + /* u3i_edit(): + ** + ** Mutate `big` at axis `axe` with new value `som` + ** `axe` is RETAINED. + */ + u3_noun + u3i_edit(u3_noun big, u3_noun axe, u3_noun som); + /* u3i_string(): ** ** Produce an LSB-first atom from the C string `a`. diff --git a/noun/imprison.c b/noun/imprison.c index c08e967f4..c0d16c3dc 100644 --- a/noun/imprison.c +++ b/noun/imprison.c @@ -262,6 +262,150 @@ u3i_qual(u3_noun a, u3_noun b, u3_noun c, u3_noun d) return u3i_cell(a, u3i_trel(b, c, d)); } +static u3_noun +_edit_cat(u3_noun big, c3_l axe_l, u3_noun som) +{ + if ( c3n == u3du(big) ) { + return u3m_bail(c3__exit); + } + else { + u3_noun pro; + switch ( axe_l ) { + case 2: + pro = u3nc(som, u3k(u3t(big))); + break; + case 3: + pro = u3nc(u3k(u3h(big)), som); + break; + default: { + c3_l mor_l = u3x_mas(axe_l); + pro = ( 2 == u3x_cap(axe_l) ) + ? u3nc(_edit_cat(u3k(u3h(big)), mor_l, som), u3k(u3t(big))) + : u3nc(u3k(u3h(big)), _edit_cat(u3k(u3t(big)), mor_l, som)); + break; + } + } + u3z(big); + return pro; + } +} + +static u3_noun +_edit(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + return _edit_cat(big, (c3_l) axe, som); + } + else if ( c3n == u3du(big) ) { + return u3m_bail(c3__exit); + } + else { + u3_noun mor = u3qc_mas(axe), + pro = ( 2 == u3qc_cap(axe) ) + ? u3nc(_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) + : u3nc(u3k(u3h(big)), _edit(u3k(u3t(big)), mor, som)); + u3z(mor); + u3z(big); + return pro; + } +} + +static u3_noun _edit_or_mutate_cat(u3_noun, c3_l, u3_noun); +static u3_noun _edit_or_mutate(u3_noun, u3_noun, u3_noun); + +static void +_mutate_cat(u3_noun big, c3_l axe_l, u3_noun som) +{ + if ( c3n == u3du(big) ) { + u3m_bail(c3__exit); + } + else { + u3a_cell* cel_u = (void*) u3a_to_ptr(big); + switch ( axe_l ) { + case 2: + u3z(cel_u->hed); + cel_u->hed = som; + break; + case 3: + u3z(cel_u->tel); + cel_u->tel = som; + break; + default: { + u3_noun* tar = ( 2 == u3x_cap(axe_l) ) + ? &(cel_u->hed) + : &(cel_u->tel); + *tar = _edit_or_mutate_cat(*tar, u3x_mas(axe_l), som); + } + } + } +} + +static void +_mutate(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + _mutate_cat(big, (c3_l) axe, som); + } + else if ( c3n == u3du(big) ) { + u3m_bail(c3__exit); + } + else { + u3a_cell* cel_u = (void*) u3a_to_ptr(big); + u3_noun mor = u3qc_mas(axe); + u3_noun* tar = ( 2 == u3qc_cap(axe) ) + ? &(cel_u->hed) + : &(cel_u->tel); + *tar = _edit_or_mutate(*tar, mor, som); + u3z(mor); + } +} + +static u3_noun +_edit_or_mutate_cat(u3_noun big, c3_l axe_l, u3_noun som) +{ + if ( c3y == u3a_is_mutable(u3R, big) ) { + _mutate_cat(big, axe_l, som); + return big; + } + else { + return _edit_cat(big, axe_l, som); + } +} + +static u3_noun +_edit_or_mutate(u3_noun big, u3_noun axe, u3_noun som) +{ + if ( c3y == u3a_is_cat(axe) ) { + return _edit_or_mutate_cat(big, (c3_l) axe, som); + } + else if ( c3y == u3a_is_mutable(u3R, big) ) { + _mutate(big, axe, som); + return big; + } + else { + return _edit(big, axe, som); + } +} + +/* u3i_edit(): +** +** Mutate `big` at axis `axe` with new value `som`. +** `axe` is RETAINED. +*/ +u3_noun +u3i_edit(u3_noun big, u3_noun axe, u3_noun som) +{ + switch ( axe ) { + case 0: + return u3m_bail(c3__exit); + case 1: + u3z(big); + return som; + default: + return _edit_or_mutate(big, axe, som); + } +} + /* u3i_string(): ** ** Produce an LSB-first atom from the C string `a`. diff --git a/noun/nock.c b/noun/nock.c index 1ac6de74f..2150ae223 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1591,30 +1591,6 @@ _n_kale(u3_noun a) return a; } - -/* _n_edit(): PRODUCE a modified big with its axe axis - * changed to som. axe is RETAINED. - */ -static u3_noun -_n_edit(u3_noun big, u3_noun axe, u3_noun som) -{ - if ( c3y == u3a_is_cat(axe) ) { - return u3i_molt(big, axe, som, 0); - } - else { - u3_noun mor = u3qc_mas(axe); - if ( c3n == u3du(big) ) { - u3m_bail(c3__exit); - } - u3_noun pro = ( 2 == u3qc_cap(axe) ) - ? u3nc(_n_edit(u3k(u3h(big)), mor, som), u3k(u3t(big))) - : u3nc(u3k(u3h(big)), _n_edit(u3k(u3t(big)), mor, som)); - u3z(mor); - u3z(big); - return pro; - } -} - typedef struct { u3n_prog* pog_u; c3_w ip_w; @@ -2325,7 +2301,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off) _n_toss(mov, off); top = _n_peek(off); edit_in: - *top = _n_edit(*top, x, o); + *top = u3i_edit(*top, x, o); BURN(); } } From 8de9a059cef465f84ed554e3f6277c7174fc7751 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Sep 2018 21:40:13 -0400 Subject: [PATCH 150/221] fixes leak in _http_serv_start_all by removing calls to u3_lo_open and u3_lo_shut --- vere/http.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vere/http.c b/vere/http.c index ddd509a80..c3ee073a7 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1383,7 +1383,8 @@ _http_serv_start_all(void) c3_assert( 0 != for_u ); - u3_lo_open(); + // disabled, as this causes a memory leak + // u3_lo_open(); // if the SSL_CTX existed, it'll be freed with the servers u3_Host.tls_u = 0; @@ -1444,7 +1445,8 @@ _http_serv_start_all(void) _http_write_ports_file(u3_Host.dir_c); _http_form_free(); - u3_lo_shut(c3y); + // disabled, see above + // u3_lo_shut(c3y); } /* _http_serv_restart(): gracefully shutdown, then start servers. From 34570e428e209946a75d5fce3e4ef1566d02d64d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Sep 2018 21:41:48 -0400 Subject: [PATCH 151/221] fixes leak in proxy when networking is disabled --- vere/http.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vere/http.c b/vere/http.c index c3ee073a7..87596fc4e 100644 --- a/vere/http.c +++ b/vere/http.c @@ -2861,6 +2861,7 @@ u3_http_ef_that(u3_noun tat) if ( c3n == u3_Host.ops_u.net ) { cli_u->ipf_w = INADDR_LOOPBACK; _proxy_ward_connect(cli_u); + u3z(tat); return; } From 8affdf44ea86049cb3d4107c3d274ba2c16e9170 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Sep 2018 21:44:04 -0400 Subject: [PATCH 152/221] refactors http card validation in u3_http_ef_that and u3_http_ef_form --- vere/http.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/vere/http.c b/vere/http.c index 87596fc4e..2741ad1d9 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1501,15 +1501,26 @@ _http_form_free(void) void u3_http_ef_form(u3_noun fig) { - // XX validate / test axes? - u3_noun sec = u3h(fig); - u3_noun lob = u3t(fig); + u3_noun sec, pro, log, red; + + if ( (c3n == u3r_qual(fig, &sec, &pro, &log, &red) ) || + // confirm sec is a valid (unit ^) + !( u3_nul == sec || ( c3y == u3du(sec) && + c3y == u3du(u3t(sec)) && + u3_nul == u3h(sec) ) ) || + // confirm valid flags ("loobeans") + !( c3y == pro || c3n == pro ) || + !( c3y == log || c3n == log ) || + !( c3y == red || c3n == red ) ) { + uL(fprintf(uH, "http: form: invalid card\n")); + u3z(fig); + return; + } u3_form* for_u = c3_malloc(sizeof(*for_u)); - - for_u->pro = (c3_o)u3h(lob); - for_u->log = (c3_o)u3h(u3t(lob)); - for_u->red = (c3_o)u3t(u3t(lob)); + for_u->pro = (c3_o)pro; + for_u->log = (c3_o)log; + for_u->red = (c3_o)red; if ( u3_nul != sec ) { u3_noun key = u3h(u3t(sec)); @@ -2813,15 +2824,13 @@ _proxy_serv_start(u3_prox* lis_u) void u3_http_ef_that(u3_noun tat) { - u3_noun sip = u3h(tat); - u3_noun por = u3h(u3t(tat)); - u3_noun sec = u3h(u3t(u3t(tat))); - u3_noun non = u3t(u3t(u3t(tat))); + u3_noun sip, por, sec, non; - if( c3n == u3ud(sip) || - c3n == u3a_is_cat(por) || - !( c3y == sec || c3n == sec ) || - c3n == u3ud(non) ) { + if ( ( c3n == u3r_qual(tat, &sip, &por, &sec, &non) ) || + ( c3n == u3ud(sip) ) || + ( c3n == u3a_is_cat(por) ) || + !( c3y == sec || c3n == sec ) || + ( c3n == u3ud(non) ) ) { uL(fprintf(uH, "http: that: invalid card\n")); u3z(tat); return; From 9302d4708c97fbbde8751a5c3e14795c693fc675 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Sep 2018 22:52:19 -0400 Subject: [PATCH 153/221] adds meson option (-Dgc=true) to set U3_MEMORY_DEBUG --- include/config.h.in | 2 ++ include/noun/allocate.h | 6 ------ meson.build | 1 + meson_options.txt | 2 ++ 4 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 meson_options.txt diff --git a/include/config.h.in b/include/config.h.in index 66f778309..d2d7baff8 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -10,4 +10,6 @@ #mesondefine U3_OS_ENDIAN_little #mesondefine U3_OS_ENDIAN_big +#mesondefine U3_MEMORY_DEBUG + #endif /*CONFIG_H*/ diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 075b12d2f..efce7ed97 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -2,12 +2,6 @@ ** ** This file is in the public domain. */ - /** Options. - **/ - /* U3_MEMORY_DEBUG: add debugging information to heap. Breaks image. - */ -# undef U3_MEMORY_DEBUG - /** Constants. **/ /* u3a_bits: number of bits in word-addressed pointer. 29 == 2GB. diff --git a/meson.build b/meson.build index 2fc9b1453..d8c17808c 100644 --- a/meson.build +++ b/meson.build @@ -264,6 +264,7 @@ incdir = include_directories('include/') conf_data = configuration_data() conf_data.set('URBIT_VERSION', '"0.6.0"') +conf_data.set('U3_MEMORY_DEBUG', get_option('gc')) osdet = build_machine.system() os_c_flags = ['-funsigned-char','-ffast-math'] diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000..4f9bb057a --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('gc', type : 'boolean', value : false, + description : 'Add debugging information to heap. Run with -g. Breaks image.') From 7a2705bb6dd1583150666103ea8a706b49bceb9f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 28 Sep 2018 22:57:31 -0400 Subject: [PATCH 154/221] adds meson option (-Dprof=true) to set U3_CPU_DEBUG --- include/config.h.in | 1 + include/noun/trace.h | 6 ------ meson.build | 1 + meson_options.txt | 2 ++ 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/config.h.in b/include/config.h.in index d2d7baff8..e8063e87e 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -11,5 +11,6 @@ #mesondefine U3_OS_ENDIAN_big #mesondefine U3_MEMORY_DEBUG +#mesondefine U3_CPU_DEBUG #endif /*CONFIG_H*/ diff --git a/include/noun/trace.h b/include/noun/trace.h index 5b847f521..838ce835f 100644 --- a/include/noun/trace.h +++ b/include/noun/trace.h @@ -2,12 +2,6 @@ ** ** This file is in the public domain. */ - /** Options. - **/ - /* U3_CPU_DEBUG: activate profiling. - */ -# undef U3_CPU_DEBUG - /** Data structures. **/ /* u3t_trace: fast execution flags. diff --git a/meson.build b/meson.build index d8c17808c..4cefeff2f 100644 --- a/meson.build +++ b/meson.build @@ -265,6 +265,7 @@ incdir = include_directories('include/') conf_data = configuration_data() conf_data.set('URBIT_VERSION', '"0.6.0"') conf_data.set('U3_MEMORY_DEBUG', get_option('gc')) +conf_data.set('U3_CPU_DEBUG', get_option('prof')) osdet = build_machine.system() os_c_flags = ['-funsigned-char','-ffast-math'] diff --git a/meson_options.txt b/meson_options.txt index 4f9bb057a..a4dd84385 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,4 @@ option('gc', type : 'boolean', value : false, description : 'Add debugging information to heap. Run with -g. Breaks image.') +option('prof', type : 'boolean', value : false, + description : 'Activate profiling. Run with -P.') From 8d9f2fac890e723b8221f1bcd8f02fbe145ec646 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 27 Sep 2018 16:20:55 -0400 Subject: [PATCH 155/221] fixes u3n_prog pointers in u3n_ream() --- noun/nock.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/noun/nock.c b/noun/nock.c index 89ebaa4e5..c784d87ab 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -2346,6 +2346,14 @@ _n_ream(u3_noun kev) { c3_w i_w; u3n_prog* pog_u = u3to(u3n_prog, u3t(kev)); + + // fix up pointers for loom portability + pog_u->byc_u.ops_y = (c3_y*) _n_prog_dat(pog_u); + pog_u->lit_u.non = (u3_noun*) (pog_u->byc_u.ops_y + pog_u->byc_u.len_w); + pog_u->mem_u.sot_u = (u3n_memo*) (pog_u->lit_u.non + pog_u->lit_u.len_w); + pog_u->cal_u.sit_u = (u3j_site*) (pog_u->mem_u.sot_u + pog_u->mem_u.len_w); + pog_u->reg_u.rit_u = (u3j_rite*) (pog_u->cal_u.sit_u + pog_u->cal_u.len_w); + for ( i_w = 0; i_w < pog_u->cal_u.len_w; ++i_w ) { u3j_site_ream(&(pog_u->cal_u.sit_u[i_w])); } From b1f8b79992ad62cf31f12cb4da419b7e334031b9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 1 Oct 2018 19:56:14 -0400 Subject: [PATCH 156/221] adds -S to skip battery hashes --- include/noun/options.h | 3 ++- include/vere/vere.h | 1 + noun/jets.c | 59 +++++++++++++++++++++++++----------------- vere/main.c | 10 ++++++- 4 files changed, 47 insertions(+), 26 deletions(-) diff --git a/include/noun/options.h b/include/noun/options.h index 8591dfee3..7eb5d540b 100644 --- a/include/noun/options.h +++ b/include/noun/options.h @@ -24,7 +24,8 @@ u3o_check_fatal = 0x8, // check: unrecoverable u3o_verbose = 0x10, // be remarkably wordy u3o_dryrun = 0x20, // don't touch checkpoint - u3o_quiet = 0x40 // disable ~& + u3o_quiet = 0x40, // disable ~& + u3o_hashless = 0x80 // disable hashboard }; /** Globals. diff --git a/include/vere/vere.h b/include/vere/vere.h index ab72c7c4f..0190e8bcf 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -504,6 +504,7 @@ c3_o fak; // -F, fake carrier c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector + c3_o has; // -S, Skip battery hashes c3_o git; // -s, pill url from arvo git hash c3_o mem; // -M, memory madness c3_o net; // -N, remote networking in -F mode diff --git a/noun/jets.c b/noun/jets.c index c9f89ad4c..d17b9fbb2 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -104,6 +104,10 @@ c3_w* u3qe_jam_buf(u3_noun, c3_w* bit_w); static u3_noun _cj_bash(u3_noun bat) { + if ( u3C.wag_w & u3o_hashless ) { + return u3_nul; + } + u3_weak pro; u3a_road* rod_u = u3R; while ( 1 ) { @@ -648,16 +652,19 @@ _cj_spot(u3_noun cor, u3_weak* bas) if ( u3_none == *bas ) { *bas = _cj_bash(u3h(cor)); } - u3_weak act = _cj_spot_hot(cor, *bas, &loc); - if ( u3_none != act ) { - reg = _cj_gust(reg, _cj_loc_axe(loc), _cj_loc_pel(loc), u3k(loc)); - u3h_put(u3R->jed.cod_p, u3h(cor), u3nc(u3k(*bas), u3k(reg))); - /* caution: could overwrites old value, debug batteries etc. - ** old value contains old _cj_jit (from different - ** battery). if we change jit to (map battery *), - ** will need to merge with that map here. - */ - u3h_put(u3R->jed.war_p, loc, act); + + if ( !(u3C.wag_w & u3o_hashless) ) { + u3_weak act = _cj_spot_hot(cor, *bas, &loc); + if ( u3_none != act ) { + reg = _cj_gust(reg, _cj_loc_axe(loc), _cj_loc_pel(loc), u3k(loc)); + u3h_put(u3R->jed.cod_p, u3h(cor), u3nc(u3k(*bas), u3k(reg))); + /* caution: could overwrites old value, debug batteries etc. + ** old value contains old _cj_jit (from different + ** battery). if we change jit to (map battery *), + ** will need to merge with that map here. + */ + u3h_put(u3R->jed.war_p, loc, act); + } } } if ( u3_none != bak ) { @@ -1774,22 +1781,26 @@ _cj_mine(u3_noun cey, u3_noun cor, u3_noun bas) u3m_p("new jet", bal); fprintf(stderr, " bat %x, jax %d\r\n", u3r_mug(bat), jax_l); #endif - if ( jax_l ) { - c3_y dig_y[32]; - c3_w i_w; - u3_noun i = bal; - fprintf(stderr, "hot jet: "); - while ( i != u3_nul ) { - _cj_print_tas(stderr, u3h(i)); - i = u3t(i); + + if ( !(u3C.wag_w & u3o_hashless) ) { + if ( jax_l ) { + c3_y dig_y[32]; + c3_w i_w; + u3_noun i = bal; + fprintf(stderr, "hot jet: "); + while ( i != u3_nul ) { + _cj_print_tas(stderr, u3h(i)); + i = u3t(i); + } + fprintf(stderr, "\r\n axe %d, jax %d,\r\n bash ", axe, jax_l); + u3r_bytes(0, 32, dig_y, bas); + for ( i_w = 32; i_w > 0; ) { + fprintf(stderr, "%02x", dig_y[--i_w]); + } + fprintf(stderr, "\r\n"); } - fprintf(stderr, "\r\n axe %d, jax %d,\r\n bash ", axe, jax_l); - u3r_bytes(0, 32, dig_y, bas); - for ( i_w = 32; i_w > 0; ) { - fprintf(stderr, "%02x", dig_y[--i_w]); - } - fprintf(stderr, "\r\n"); } + hap = _cj_warm_hump(jax_l, u3t(u3t(loc))); act = u3nq(jax_l, hap, bal, _cj_jit(jax_l, bat)); u3h_put(u3R->jed.cod_p, bat, u3nc(u3k(bas), reg)); diff --git a/vere/main.c b/vere/main.c index 6dec6d386..9315269ef 100644 --- a/vere/main.c +++ b/vere/main.c @@ -81,6 +81,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.fog = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; + u3_Host.ops_u.has = c3n; u3_Host.ops_u.net = c3n; u3_Host.ops_u.mem = c3n; u3_Host.ops_u.nuu = c3n; @@ -91,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXR")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -186,6 +187,7 @@ _main_getopt(c3_i argc, c3_c** argv) case 'q': { u3_Host.ops_u.qui = c3y; break; } case 'v': { u3_Host.ops_u.veb = c3y; break; } case 's': { u3_Host.ops_u.git = c3y; break; } + case 'S': { u3_Host.ops_u.has = c3y; break; } case '?': default: { return c3n; } @@ -596,6 +598,12 @@ main(c3_i argc, if ( _(u3_Host.ops_u.dry) ) { u3C.wag_w |= u3o_dryrun; } + + /* Set hashboard flag + */ + if ( _(u3_Host.ops_u.has) ) { + u3C.wag_w |= u3o_hashless; + } } u3m_boot(u3_Host.ops_u.nuu, u3_Host.ops_u.gab, From 7569f8d8ad354284a7f9688a766ee2ceb9a3e4bd Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 20 Jul 2018 01:31:28 +0200 Subject: [PATCH 157/221] Fix issue with trimming >4 character jet names --- noun/jets.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index d17b9fbb2..2cf00d0df 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -866,11 +866,11 @@ _cj_kick_z(u3_noun cor, u3j_core* cop_u, u3j_harm* ham_u, u3_atom axe) c3_w cod_w; { - char soc_c[6]; + char soc_c[5]; - memset(soc_c, 0, 6); - strncpy(soc_c, cop_u->cos_c, 5); - soc_c[5] = 0; + memset(soc_c, 0, 5); + strncpy(soc_c, cop_u->cos_c, 4); + soc_c[4] = 0; cod_w = u3i_string(soc_c); cod_w = u3a_lush(cod_w); } From 1c49b0438acede1d682b08313a3250286efbb69e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 2 Oct 2018 19:36:04 -0400 Subject: [PATCH 158/221] bail %exit in _cj_site_lock if axis is not in core --- noun/jets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noun/jets.c b/noun/jets.c index 2cf00d0df..459617c86 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1443,7 +1443,7 @@ _cj_site_lock(u3_noun loc, u3_noun cor, u3j_site* sit_u) (c3y == u3r_sing(sit_u->bat, u3h(cor))) ) { return; } - sit_u->pog_p = _cj_prog(loc, u3r_at(sit_u->axe, cor)); + sit_u->pog_p = _cj_prog(loc, u3x_at(sit_u->axe, cor)); if ( u3_none != sit_u->bat ) { u3z(sit_u->bat); } From 67968ac5147f227f8761593fa2ab3bf5d2e8e108 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 2 Oct 2018 22:39:36 -0400 Subject: [PATCH 159/221] remove orphaned declarations for mux and shux jets --- include/jets/k.h | 7 ------- include/jets/q.h | 2 -- include/jets/w.h | 2 -- 3 files changed, 11 deletions(-) diff --git a/include/jets/k.h b/include/jets/k.h index e49e5a98f..d9171a511 100644 --- a/include/jets/k.h +++ b/include/jets/k.h @@ -28,13 +28,6 @@ u3_noun u3kc_rsh(u3_noun a, u3_noun b, u3_noun c); - /* u3kc_mux_f(): mux with function pointers. - */ - u3_noun - u3kc_mux_f(u3_noun a, - u3_atom (*hat)(void*, u3_atom), void* has_u, - u3_atom (*mix)(void*, u3_atom, u3_atom), void* mis_u); - /* u3kd: tier 4 functions */ /* u3kdb_get(): map get for key `b` in map `a` with u3_none. diff --git a/include/jets/q.h b/include/jets/q.h index d0ad0e1d2..2acb8eec5 100644 --- a/include/jets/q.h +++ b/include/jets/q.h @@ -60,7 +60,6 @@ u3_noun u3qc_met(u3_atom, u3_atom); u3_noun u3qc_mix(u3_atom, u3_atom); u3_noun u3qc_muk(u3_atom, u3_atom, u3_atom); - u3_noun u3qc_mux(u3_noun, u3_noun, u3_noun); u3_noun u3qc_peg(u3_atom, u3_atom); u3_noun u3qc_pow(u3_atom, u3_atom); u3_noun u3qc_rap(u3_atom, u3_noun); @@ -133,7 +132,6 @@ u3_noun u3qe_shay(u3_atom, u3_atom); u3_noun u3qe_shas(u3_atom, u3_atom); u3_noun u3qe_shal(u3_atom, u3_atom); - u3_noun u3qe_shux(u3_atom); u3_noun u3qeo_raw(u3_atom, u3_atom); diff --git a/include/jets/w.h b/include/jets/w.h index c6b11cdc9..94adfc557 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -59,7 +59,6 @@ u3_noun u3wc_met(u3_noun); u3_noun u3wc_mix(u3_noun); u3_noun u3wc_mug(u3_noun); - u3_noun u3wc_mux(u3_noun); u3_noun u3wc_muk(u3_noun); u3_noun u3wc_peg(u3_noun); u3_noun u3wc_pow(u3_noun); @@ -144,7 +143,6 @@ u3_noun u3we_shay(u3_noun); u3_noun u3we_shas(u3_noun); u3_noun u3we_shal(u3_noun); - u3_noun u3we_shux(u3_noun); u3_noun u3weo_raw(u3_noun); From 9a3608158f9a5d6f6f1ff31757d8c5c608d4b7f7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 3 Oct 2018 11:57:00 -0400 Subject: [PATCH 160/221] adds comments for known-valid u3r_at calls in jets.c --- noun/jets.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 459617c86..f2c475960 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -695,6 +695,7 @@ _cj_cast(u3_noun cor, u3_noun loc) loc = u3t(dyn); pat = u3h(loc); rev = u3nc(u3nc(u3k(bat), u3k(pax)), rev); + // pax already known-valid cor = u3r_at(pax, cor); ++i_w; } @@ -1000,6 +1001,7 @@ _cj_hook_in(u3_noun cor, u3_noun dyn = u3t(pat), axe = u3h(dyn), pel = u3t(dyn); + // axe already known-valid roc = u3k(u3r_at(axe, cor)); u3z(cor); cor = roc; @@ -1165,6 +1167,7 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) sit_u->pog_p = _cj_prog(loc, fol); } else { + // loc already known-valid 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, &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); @@ -1178,6 +1181,7 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) u3_noun dyn = u3t(pat), axe = u3h(dyn), xah; + // axe already known-valid cor = u3r_at(axe, cor); loc = u3t(dyn); xah = u3qc_peg(axe, hax); @@ -1206,14 +1210,9 @@ _cj_hank_fill(_cj_hank* han_u, u3_noun tam, u3_noun cor) static u3_noun _cj_sink(u3_noun cor, u3_noun axe) { - u3_weak fol = u3r_at(axe, cor); - if ( u3_none == fol ) { - return u3m_bail(c3__exit); - } - else { - u3z(axe); - return u3n_nock_on(cor, u3k(fol)); - } + u3_noun fol = u3x_at(axe, cor); + u3z(axe); + return u3n_nock_on(cor, u3k(fol)); } /* u3j_kick(): new kick. From 599b5052eafe688a9270bc9c675c788059f534fd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 3 Oct 2018 11:57:18 -0400 Subject: [PATCH 161/221] uses u3x_at in reel and roll jets --- jets/b/reel.c | 2 +- jets/b/roll.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jets/b/reel.c b/jets/b/reel.c index de963fe34..5cdd9c918 100644 --- a/jets/b/reel.c +++ b/jets/b/reel.c @@ -29,7 +29,7 @@ u3_noun pro; u3j_site sit_u; u3j_gate_prep(&sit_u, u3k(b)); - pro = _reel_in(&sit_u, a, u3k(u3r_at(u3x_sam_3, b))); + pro = _reel_in(&sit_u, a, u3k(u3x_at(u3x_sam_3, b))); u3j_gate_lose(&sit_u); return pro; } diff --git a/jets/b/roll.c b/jets/b/roll.c index 49b7eccf0..a88d4fc1d 100644 --- a/jets/b/roll.c +++ b/jets/b/roll.c @@ -27,7 +27,7 @@ u3_noun pro; u3j_site sit_u; u3j_gate_prep(&sit_u, u3k(b)); - pro = _roll_in(&sit_u, a, u3k(u3r_at(u3x_sam_3, b))); + pro = _roll_in(&sit_u, a, u3k(u3x_at(u3x_sam_3, b))); u3j_gate_lose(&sit_u); return pro; } From 2f92e6409fbd40db048e1a30ca62bba9ef456f20 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Thu, 4 Oct 2018 10:43:21 -0700 Subject: [PATCH 162/221] increased inbound request and ward timeouts to 5 min --- vere/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vere/http.c b/vere/http.c index ddd509a80..32211dfe8 100644 --- a/vere/http.c +++ b/vere/http.c @@ -463,7 +463,7 @@ _http_rec_accept(h2o_handler_t* han_u, h2o_req_t* rec_u) req_u->tim_u = c3_malloc(sizeof(*req_u->tim_u)); req_u->tim_u->data = req_u; uv_timer_init(u3L, req_u->tim_u); - uv_timer_start(req_u->tim_u, _http_req_timer_cb, 30 * 1000, 0); + uv_timer_start(req_u->tim_u, _http_req_timer_cb, 300 * 1000, 0); _http_req_dispatch(req_u, req); @@ -2310,7 +2310,7 @@ _proxy_ward_start(u3_pcon* con_u, u3_noun sip) uv_timer_init(u3L, &rev_u->tim_u); // XX how long? - uv_timer_start(&rev_u->tim_u, _proxy_ward_timer_cb, 120 * 1000, 0); + uv_timer_start(&rev_u->tim_u, _proxy_ward_timer_cb, 300 * 1000, 0); // XX u3_lo_shut(c3y); } From c058bae81cbcb2c1664e8f1876cae3905a33474a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 6 Sep 2018 21:35:17 -0400 Subject: [PATCH 163/221] implements initial version of eth-integrated %dawn boot --- include/c/motes.h | 1 + include/vere/vere.h | 1 + vere/main.c | 20 +++- vere/sist.c | 222 +++++++++++++++++++++++++++++++++++--------- 4 files changed, 198 insertions(+), 46 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 652cfa073..9d0b95b75 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -284,6 +284,7 @@ # define c3__dant c3_s4('d','a','n','t') # define c3__dast c3_s4('d','a','s','t') # define c3__data c3_s4('d','a','t','a') +# define c3__dawn c3_s4('d','a','w','n') # define c3__dbug c3_s4('d','b','u','g') # define c3__dec c3_s3('d','e','c') # define c3__deem c3_s4('d','e','e','m') diff --git a/include/vere/vere.h b/include/vere/vere.h index 8e77d7153..2fbea9f2d 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -587,6 +587,7 @@ c3_c* tic_c; // -t, ticket value c3_c* url_c; // -u, pill url c3_c* who_c; // -w, begin with ticket + c3_c* key_c; // -K, private key file c3_o abo; // -a c3_o bat; // -b, batch create c3_o dem; // -d, daemon diff --git a/vere/main.c b/vere/main.c index 74901d790..fa06b1558 100644 --- a/vere/main.c +++ b/vere/main.c @@ -92,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -145,6 +145,11 @@ _main_getopt(c3_i argc, c3_c** argv) } break; } + case 'K': { + u3_Host.ops_u.key_c = strdup(optarg); + u3_Host.ops_u.nuu = c3y; + break; + } case 'k': { if ( c3n == _main_readw(optarg, 256, &u3_Host.ops_u.kno_w) ) { return c3n; @@ -249,6 +254,11 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } + if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.key_c != 0) { + fprintf(stderr, "-K only makes sense when bootstrapping a new instance\n"); + return c3n; + } + if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.url_c != 0 ) { fprintf(stderr, "-u only makes sense when bootstrapping a new instance\n"); return c3n; @@ -279,6 +289,14 @@ _main_getopt(c3_i argc, c3_c** argv) } } + if ( u3_Host.ops_u.key_c != 0 ) { + struct stat s; + if ( stat(u3_Host.ops_u.key_c, &s) != 0 ) { + fprintf(stderr, "keyfile %s not found\n", u3_Host.ops_u.key_c); + return c3n; + } + } + if ( u3_Host.ops_u.nam_c == 0 ) { u3_Host.ops_u.nam_c = getenv("HOSTNAME"); if ( u3_Host.ops_u.nam_c == 0 ) { diff --git a/vere/sist.c b/vere/sist.c index acd3ac9fd..b04e5c471 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "all.h" @@ -1165,6 +1166,181 @@ _sist_zen() return u3i_words(16, rad_w); } +/* _sist_curl_alloc(): allocate a response buffer for curl +*/ +static size_t +_sist_curl_alloc(void* dat_v, size_t uni_t, size_t mem_t, uv_buf_t* buf_u) +{ + size_t siz_t = uni_t * mem_t; + buf_u->base = realloc(buf_u->base, 1 + siz_t + buf_u->len); + + if ( 0 == buf_u->base ) { + fprintf(stderr, "out of memory\n"); + u3_lo_bail(); + } + + memcpy(buf_u->base + buf_u->len, dat_v, siz_t); + buf_u->len += siz_t; + buf_u->base[buf_u->len] = 0; + + return siz_t; +} + +/* _sist_post_json(): POST JSON to url_c +*/ +static uv_buf_t +_sist_post_json(c3_c* url_c, uv_buf_t lod_u) +{ + CURL *curl; + CURLcode result; + long cod_l; + struct curl_slist* hed_u = 0; + + uv_buf_t buf_u = uv_buf_init(c3_malloc(1), 0); + + if ( !(curl = curl_easy_init()) ) { + fprintf(stderr, "failed to initialize libcurl\n"); + u3_lo_bail(); + } + + hed_u = curl_slist_append(hed_u, "Accept: application/json"); + hed_u = curl_slist_append(hed_u, "Content-Type: application/json"); + hed_u = curl_slist_append(hed_u, "charsets: utf-8"); + + curl_easy_setopt(curl, CURLOPT_URL, url_c); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _sist_curl_alloc); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); + + // note: must be terminated! + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, lod_u.base); + + result = curl_easy_perform(curl); + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &cod_l); + + // XX retry? + if ( CURLE_OK != result ) { + fprintf(stderr, "failed to fetch %s: %s\n", + url_c, curl_easy_strerror(result)); + u3_lo_bail(); + } + if ( 300 <= cod_l ) { + fprintf(stderr, "error fetching %s: HTTP %ld\n", url_c, cod_l); + u3_lo_bail(); + } + + curl_easy_cleanup(curl); + + return buf_u; +} + +/* _sist_oct_to_buf(): +octs to uv_buf_t +*/ +static uv_buf_t +_sist_oct_to_buf(u3_noun oct) +{ + if ( c3n == u3a_is_cat(u3h(oct)) ) { + u3_lo_bail(); + } + + c3_w len_w = u3h(oct); + c3_y* buf_y = c3_malloc(1 + len_w); + buf_y[len_w] = 0; + + u3r_bytes(0, len_w, buf_y, u3t(oct)); + + u3z(oct); + return uv_buf_init((void*)buf_y, len_w); +} + +/* _sist_buf_to_oct(): uv_buf_t to +octs +*/ +static u3_noun +_sist_buf_to_oct(uv_buf_t buf_u) +{ + u3_noun len = u3i_words(1, (c3_w*)&buf_u.len); + + if ( c3n == u3a_is_cat(len) ) { + u3_lo_bail(); + } + + return u3nc(len, u3i_bytes(buf_u.len, (const c3_y*)buf_u.base)); +} + +/* _sist_eth_rpc(): ethereum JSON RPC with request/response as +octs +*/ +static u3_noun +_sist_eth_rpc(c3_c* url_c, u3_noun oct) +{ + return _sist_buf_to_oct(_sist_post_json(url_c, _sist_oct_to_buf(oct))); +} + +/* _sist_dawn(): produce %dawn boot card - validate keys and query contract +*/ +static u3_noun +_sist_dawn(void) +{ + if ( c3y == u3_Host.ops_u.fak ) { + // XX generate fake keys, or use separate fake boot event + } + + if ( 0 == u3_Host.ops_u.key_c ) { + // XX print nice error + u3_lo_bail(); + } + + u3_noun eds = u3m_file(u3_Host.ops_u.key_c); + u3_noun des = u3dc("slaw", c3__uw, eds); + + if ( u3_nul == des ) { + // XX print nice error + u3_lo_bail(); + } + + // +seed:dawn: + // [who=ship lyf=life key=ring sig=(unit oath:pki:jael)] + u3_noun sed = u3ke_cue(u3t(des)); + u3_noun who = u3h(sed); + + // u3_noun lyf = u3h(u3t(sed)); + // u3_noun key = u3h(u3t(u3t(sed))); + // u3_noun sig = u3t(u3t(u3t(sed))); + // u3_noun rac = u3do("clan:title", u3k(who)); + + // XX configure default globally, add cli arg to specify + c3_c* url_c = "http://localhost:8545"; + + u3_noun luh = _sist_eth_rpc(url_c, u3do("hull:give:dawn", u3k(who))); + u3_noun hul = u3dc("hull:take:dawn", u3k(who), luh); + + // XX actually make request + // u3_noun liv = _sist_get_json(parent, /some/url) + u3_noun liv = u3_nul; + + u3_noun sas = u3dt("veri:dawn", sed, hul, liv); + + if ( c3n == u3h(sas) ) { + // XX deconstruct sas, print helpful error messages + u3m_p("pre-boot error", u3t(sas)); + u3_lo_bail(); + } + + // XX slow, temporarily disabled + // XX maybe print messages, spin a cursor, etc. + // u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); + // u3_noun zar = u3do("czar:take:dawn", raz); + u3_noun zar = u3_nul; + + u3_noun fut = _sist_eth_rpc(url_c, u3v_wish("turf:give:dawn")); + u3_noun tuf = u3do("turf:take:dawn", fut); + + // XX extract from sas + // XX or maybe pass entire hull? + u3_noun pon = u3_nul; + + // [%dawn =seed:dawn spon=(unit ship) czar=(map ship [=life =pass]) turf=(list (pair @ud (list @ta)))] + return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); +} + /* u3_sist_boot(): restore or create. */ void @@ -1173,51 +1349,7 @@ u3_sist_boot(void) // uL(fprintf(uH, "sist: booting\n")); if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun pig = u3_none; - - if ( 0 == u3_Host.ops_u.imp_c ) { - u3_noun ten = _sist_zen(); - uL(fprintf(uH, "generating curve25519 key pair...\n")); - - pig = u3nq(c3__make, u3_nul, 11, u3nc(ten, u3_Host.ops_u.fak)); - } - else { - u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); - u3_noun whu = u3dc("slaw", 'p', u3k(imp)); - - if ( (u3_nul == whu) ) { - fprintf(stderr, "czar: incorrect format\r\n"); - u3_lo_bail(); - } - else { - u3_noun gen = u3_nul; - u3_noun gun = u3_nul; - if (c3n == u3_Host.ops_u.fak) { - if ( 0 != u3_Host.ops_u.gen_c) { - gen = u3i_string(u3_Host.ops_u.gen_c); - } - else { - gen = _sist_text("generator"); // XX move to main.c - } - gun = u3dc("slaw", c3__uw, gen); - - if ( u3_nul == gun ) { - fprintf(stderr, "czar: incorrect format\r\n"); - u3_lo_bail(); - } - } - else { - gun = u3nc(u3_nul, u3_nul); - } - pig = u3nq(c3__sith, - u3k(u3t(whu)), - u3k(u3t(gun)), - u3_Host.ops_u.fak); - - u3z(whu); u3z(gun); - } - u3z(imp); - } + u3_noun pig = _sist_dawn(); _sist_make(pig); } else { From 91f2d9ed68c857fc3338c0a5dc88a33705a7dae8 Mon Sep 17 00:00:00 2001 From: Joseph Lukasik Date: Wed, 26 Sep 2018 22:24:50 -0700 Subject: [PATCH 164/221] Disable terminal echo on passcode entry --- vere/sist.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index acd3ac9fd..4244027fe 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -295,14 +295,28 @@ _sist_cask(c3_c* dir_c, u3_noun nun) { c3_c paw_c[60]; u3_noun key; + u3_utty* uty_u = calloc(1, sizeof(u3_utty)); + uty_u->fid_i = 0; uH; + + // disable terminal echo when typing in passcode + if ( 0 != tcgetattr(uty_u->fid_i, &uty_u->bak_u) ) { + c3_assert(!"init-tcgetattr"); + } + uty_u->raw_u = uty_u->bak_u; + uty_u->raw_u.c_lflag &= ~ECHO; + if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->raw_u) ) { + c3_assert(!"init-tcsetattr"); + } + while ( 1 ) { printf("passcode for %s%s? ~", dir_c, (c3y == nun) ? " [none]" : ""); paw_c[0] = 0; c3_fpurge(stdin); fgets(paw_c, 59, stdin); + printf("\n"); if ( '\n' == paw_c[0] ) { if ( c3y == nun ) { @@ -334,6 +348,10 @@ _sist_cask(c3_c* dir_c, u3_noun nun) break; } } + if ( 0 != tcsetattr(uty_u->fid_i, TCSADRAIN, &uty_u->bak_u) ) { + c3_assert(!"init-tcsetattr"); + } + free(uty_u); uL(0); return key; } From 8fc65462b8f5ee494a615bff9a922399a77b1419 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sat, 15 Sep 2018 01:39:13 -0400 Subject: [PATCH 165/221] minimal fake-key boot - galaxies only for now --- include/c/motes.h | 1 + vere/sist.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 9d0b95b75..7914354ca 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -375,6 +375,7 @@ # define c3__face c3_s4('f','a','c','e') # define c3__fail c3_s4('f','a','i','l') # define c3__fair c3_s4('f','a','i','r') +# define c3__fake c3_s4('f','a','k','e') # define c3__fan c3_s3('f','a','n') # define c3__farg c3_s4('f','a','r','g') # define c3__fast c3_s4('f','a','s','t') diff --git a/vere/sist.c b/vere/sist.c index b04e5c471..c1b0a1216 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1279,10 +1279,6 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) static u3_noun _sist_dawn(void) { - if ( c3y == u3_Host.ops_u.fak ) { - // XX generate fake keys, or use separate fake boot event - } - if ( 0 == u3_Host.ops_u.key_c ) { // XX print nice error u3_lo_bail(); @@ -1349,7 +1345,24 @@ u3_sist_boot(void) // uL(fprintf(uH, "sist: booting\n")); if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun pig = _sist_dawn(); + u3_noun pig; + + if ( c3y == u3_Host.ops_u.fak ) { + // XX or who_c + u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); + u3_noun whu = u3dc("slaw", 'p', u3k(imp)); + + if ( (u3_nul == whu) ) { + fprintf(stderr, "czar: incorrect format\r\n"); + u3_lo_bail(); + } + + pig = u3nc(c3__fake, u3t(whu)); + } + else { + pig = _sist_dawn(); + } + _sist_make(pig); } else { From bcc1261009bd6510f72cb9132b9ddf840251811b Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 14 Sep 2018 11:17:16 -0400 Subject: [PATCH 166/221] removes first-boot ticket --- include/vere/vere.h | 6 ------ vere/loop.c | 3 --- vere/main.c | 20 +------------------- vere/term.c | 26 -------------------------- 4 files changed, 1 insertion(+), 54 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 2fbea9f2d..205b03c28 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -584,7 +584,6 @@ c3_c* nam_c; // -n, unix hostname c3_c* pil_c; // -B, bootstrap from c3_c* raf_c; // -r, raft flotilla - c3_c* tic_c; // -t, ticket value c3_c* url_c; // -u, pill url c3_c* who_c; // -w, begin with ticket c3_c* key_c; // -K, private key file @@ -862,11 +861,6 @@ void u3_term_ef_boil(); - /* u3_term_ef_ticket(): initial effects for new ticket. - */ - void - u3_term_ef_ticket(c3_c* who_c, c3_c* tic_c); - /* u3_term_ef_verb(): initial effects for verbose events. */ void diff --git a/vere/loop.c b/vere/loop.c index 03a015b45..d3362efb3 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -685,9 +685,6 @@ u3_lo_lead(void) #endif if ( c3y == u3_Host.ops_u.nuu ) { - if ( u3_Host.ops_u.who_c ) { - u3_term_ef_ticket(u3_Host.ops_u.who_c, u3_Host.ops_u.tic_c); - } u3_term_ef_boil(1); } diff --git a/vere/main.c b/vere/main.c index fa06b1558..98d04b07a 100644 --- a/vere/main.c +++ b/vere/main.c @@ -92,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -127,10 +127,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.url_c = strdup(optarg); break; } - case 't': { - u3_Host.ops_u.tic_c = _main_presig(optarg); - break; - } case 'x': { u3_Host.ops_u.tex = c3y; break; @@ -226,24 +222,11 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.tic_c != 0 && ( u3_Host.ops_u.imp_c != 0 || - u3_Host.ops_u.nuu == c3n ) ) { - fprintf(stderr, "-t only makes sense when creating a new non-galaxy\n"); - return c3n; - } - if ( u3_Host.ops_u.rop_s == 0 && u3_Host.ops_u.raf_c != 0 ) { fprintf(stderr, "The -r flag requires -l.\n"); return c3n; } - if ( u3_Host.ops_u.tic_c == 0 && u3_Host.ops_u.who_c != 0 ) { - c3_c tic_c[29]; - printf("your ticket: ~"); - scanf("%28s",tic_c); - u3_Host.ops_u.tic_c = _main_presig(tic_c); - } - if ( c3y == u3_Host.ops_u.bat ) { u3_Host.ops_u.dem = c3y; u3_Host.ops_u.nuu = c3y; @@ -366,7 +349,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-r host Initial peer address\n", "-R Report urbit build info\n", "-s Pill URL from arvo git hash\n", - "-t ticket Use ~ticket automatically\n", "-u url URL from which to download pill\n", "-v Verbose\n", "-w name Immediately upgrade to ~name\n", diff --git a/vere/term.c b/vere/term.c index c6409d5a7..2736e8314 100644 --- a/vere/term.c +++ b/vere/term.c @@ -1032,32 +1032,6 @@ u3_term_ef_verb(void) u3v_plan(pax, u3nc(c3__verb, u3_nul)); } -/* u3_term_ef_ticket(): initial effects for new ticket. -*/ -void -u3_term_ef_ticket(c3_c* who_c, c3_c* tic_c) -{ - u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul); - u3_noun who, tic; - u3_noun whu, tuc; - - whu = u3dc("slaw", 'p', u3i_string(who_c)); - if ( u3_nul == whu ) { - fprintf(stderr, "ticket: invalid planet '%s'\r\n", who_c); - exit(1); - } - else { who = u3k(u3t(whu)); u3z(whu); } - - tuc = u3dc("slaw", 'p', u3i_string(tic_c)); - if ( u3_nul == tuc ) { - fprintf(stderr, "ticket: invalid secret '%s'\r\n", tic_c); - exit(1); - } - else { tic = u3k(u3t(tuc)); u3z(tuc); } - - u3v_plan(pax, u3nt(c3__tick, who, tic)); -} - /* u3_term_ef_bake(): initial effects for new terminal. */ void From 0b13837bfafdd0d3118dcc0d8880bba061f06847 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 10 Aug 2018 12:58:21 -0400 Subject: [PATCH 167/221] single-home's arvo, refines fake keys --- include/noun/vortex.h | 1 + include/vere/vere.h | 2 +- vere/http.c | 22 +++++++--------------- vere/main.c | 34 ++++++++++++++++++++++++++++------ vere/reck.c | 19 +++++++++---------- vere/sist.c | 39 +++++++++++++++++++++++++++++---------- 6 files changed, 75 insertions(+), 42 deletions(-) diff --git a/include/noun/vortex.h b/include/noun/vortex.h index e750c45b2..b36cd8f25 100644 --- a/include/noun/vortex.h +++ b/include/noun/vortex.h @@ -26,6 +26,7 @@ u3_noun sev_l; // instance number u3_noun sen; // instance string u3_noun own; // owner list + u3_noun fak; // &=fake XX use c3_o? u3_noun sac; // space profiling diff --git a/include/vere/vere.h b/include/vere/vere.h index 205b03c28..ced7474fd 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -591,7 +591,7 @@ c3_o bat; // -b, batch create c3_o dem; // -d, daemon c3_o dry; // -D, dry compute - c3_o fak; // -F, fake carrier + c3_c* fak_c; // -F, fake ship c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector c3_o has; // -S, Skip battery hashes diff --git a/vere/http.c b/vere/http.c index 2741ad1d9..ea2b006da 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1401,7 +1401,7 @@ _http_serv_start_all(void) htp_u = _http_serv_new(por_s, c3y, c3n); htp_u->h2o_u = _http_serv_init_h2o(u3_Host.tls_u, for_u->log, for_u->red); - if ( (c3y == for_u->pro) || (c3y == u3_Host.ops_u.fak) ) { + if ( c3y == for_u->pro ) { htp_u->rox_u = _proxy_serv_new(htp_u, 443, c3y); } @@ -1416,7 +1416,7 @@ _http_serv_start_all(void) htp_u = _http_serv_new(por_s, c3n, c3n); htp_u->h2o_u = _http_serv_init_h2o(0, for_u->log, for_u->red); - if ( (c3y == for_u->pro) || (c3y == u3_Host.ops_u.fak) ) { + if ( c3y == for_u->pro ) { htp_u->rox_u = _proxy_serv_new(htp_u, 80, c3n); } @@ -2571,25 +2571,16 @@ _proxy_dest(u3_pcon* con_u, u3_noun sip) _proxy_loop_connect(con_u); } else { - u3_noun hip = u3k(u3t(sip)); - u3_noun own = u3A->own; - c3_o our = c3n; + u3_noun hip = u3t(sip); - while ( u3_nul != own ) { - if ( c3y == u3r_sing(hip, u3h(own)) ) { - our = c3y; - break; - } - own = u3t(own); - } - - if ( c3y == our ) { + if ( c3y == u3r_sing(u3A->own, hip) ) { _proxy_loop_connect(con_u); } else { // XX check if (sein:title sip) == our // XX check will - _proxy_ward_start(con_u, hip); + // XX extract bytes from hip, this could leak + _proxy_ward_start(con_u, u3k(hip)); } } @@ -2852,6 +2843,7 @@ u3_http_ef_that(u3_noun tat) return; } + // XX extract bytes from sip, this could leak cli_u = _proxy_warc_new(htp_u, (u3_atom)sip, (c3_s)por, (c3_o)sec); // XX add to constructor diff --git a/vere/main.c b/vere/main.c index 98d04b07a..13f164229 100644 --- a/vere/main.c +++ b/vere/main.c @@ -77,7 +77,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.bat = c3n; u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; - u3_Host.ops_u.fak = c3n; u3_Host.ops_u.fog = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -92,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:k:l:n:p:r:NabcdgqsvxFMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -114,10 +113,15 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.dns_c = strdup(optarg); break; } + // XX remove in deference to -K case 'I': { u3_Host.ops_u.imp_c = _main_presig(optarg); break; } + case 'F': { + u3_Host.ops_u.fak_c = _main_presig(optarg); + break; + } case 'w': { u3_Host.ops_u.who_c = _main_presig(optarg); u3_Host.ops_u.nuu = c3y; @@ -177,7 +181,6 @@ _main_getopt(c3_i argc, c3_c** argv) return c3y; } case 'N': { u3_Host.ops_u.net = c3y; break; } - case 'F': { u3_Host.ops_u.fak = c3y; break; } case 'a': { u3_Host.ops_u.abo = c3y; break; } case 'b': { u3_Host.ops_u.bat = c3y; break; } case 'c': { u3_Host.ops_u.nuu = c3y; break; } @@ -195,10 +198,29 @@ _main_getopt(c3_i argc, c3_c** argv) } } - if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3y ) { + // XX remove -I + if ( (0 != u3_Host.ops_u.fak_c) && (0 != u3_Host.ops_u.imp_c) ) { + fprintf(stderr, "-I is redundant with -F\n"); + return c3n; + } + + // set galaxy name + // XX need to do this with -K too + // -A is required when booting a galaxy + if ( (0 != u3_Host.ops_u.fak_c) && (4 == strlen(u3_Host.ops_u.fak_c)) ) { + u3_Host.ops_u.imp_c = strdup(u3_Host.ops_u.fak_c); + } + + if ( (0 != u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.nuu) ) { + fprintf(stderr, "-F only makes sense on initial boot\n"); + return c3n; + } + + // XX revisit + if ( (0 == u3_Host.ops_u.fak_c) && (c3y == u3_Host.ops_u.net) ) { fprintf(stderr, "-N only makes sense with -F\n"); return c3n; - } else if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3n ) { + } else if ( (0 == u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.net) ) { u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } @@ -333,7 +355,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-c pier Create a new urbit in pier/\n", "-d Daemon mode\n", "-D Recompute from events\n", - "-F Fake keys; also disables networking\n", + "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", "-H domain Set ames bootstrap domain (default urbit.org)\n", diff --git a/vere/reck.c b/vere/reck.c index e66363112..6d3379bec 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -100,13 +100,10 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__init: p_fav = u3t(fav); { - u3A->own = u3nc(u3k(p_fav), u3A->own); + c3_assert( u3_none == u3A->own ); + u3A->own = u3k(p_fav); - u3_noun hox = u3dc("scot", 'p', u3k(p_fav)); - c3_c* nam_c = u3r_string(hox); - - // uL(fprintf(uH, "kick: init: %s\n", nam_c)); - free(nam_c); u3z(pox); u3z(hox); u3z(fav); return c3y; + u3z(pox); u3z(fav); return c3y; } break; case c3__mass: p_fav = u3t(fav); @@ -224,11 +221,12 @@ _reck_kick_ames(u3_noun pox, u3_noun fav) switch ( u3h(fav) ) { default: break; + // XX remove case c3__init: p_fav = u3t(fav); { - u3A->own = u3nc(u3k(p_fav), u3A->own); + uL(fprintf(uH, "kick: init: ames\n")); + c3_assert(0); - // uL(fprintf(uH, "kick: init: %d\n", p_fav)); u3z(pox); u3z(fav); return c3y; } break; } @@ -313,11 +311,12 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) } } break; + // XX remove case c3__init: p_fav = u3t(fav); { - u3A->own = u3nc(u3k(p_fav), u3A->own); + uL(fprintf(uH, "kick: init: spec\n")); + c3_assert(0); - // uL(fprintf(uH, "kick: init: %d\n", p_fav)); u3z(pox); u3z(fav); return c3y; } break; diff --git a/vere/sist.c b/vere/sist.c index c1b0a1216..5fe7df0e3 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -261,9 +261,11 @@ _sist_sing(u3_noun ovo) u3_noun fex = u3h(vir); u3_noun fav = u3t(fex); - if ( (c3__init == u3h(fav)) || (c3__inuk == u3h(fav)) ) { - u3A->own = u3nc(u3k(u3t(fav)), u3A->own); + // XX is this now just to support ctrl-z during first boot? + if ( c3__init == u3h(fav) ) { + u3A->own = u3k(u3t(fav)); } + vir = u3t(vir); } u3z(nug); @@ -1342,30 +1344,47 @@ _sist_dawn(void) void u3_sist_boot(void) { - // uL(fprintf(uH, "sist: booting\n")); - if ( c3y == u3_Host.ops_u.nuu ) { u3_noun pig; - if ( c3y == u3_Host.ops_u.fak ) { - // XX or who_c - u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); - u3_noun whu = u3dc("slaw", 'p', u3k(imp)); + if ( 0 != u3_Host.ops_u.fak_c ) { + u3_noun whu = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.fak_c)); if ( (u3_nul == whu) ) { - fprintf(stderr, "czar: incorrect format\r\n"); + fprintf(stderr, "fake: invalid ship: %s\r\n", u3_Host.ops_u.fak_c); u3_lo_bail(); } - pig = u3nc(c3__fake, u3t(whu)); + fprintf(stderr, "fake: %s\r\n", u3_Host.ops_u.fak_c); + + u3A->fak = c3y; + pig = u3nc(c3__fake, u3k(u3t(whu))); + u3z(whu); } else { + u3A->fak = c3n; pig = _sist_dawn(); } + // will be set by %init card in reck.c + u3A->own = u3_none; _sist_make(pig); } else { + if ( c3y == u3A->fak ) { + c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); + fprintf(stderr, "fake: %s\r\n", who_c); + + // XX use clan:title + if ( 4 == strlen(who_c) ) { + u3_Host.ops_u.imp_c = who_c; + } else { + free(who_c); + } + + // XX make conditional + u3_Host.ops_u.net = c3n; + } _sist_rest(); } } From 204cf9be09f78784e0bfa4cee2747022181173dd Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 9 Oct 2018 13:35:25 -0400 Subject: [PATCH 168/221] restores u3A->fak on full event replay --- vere/sist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 5fe7df0e3..3090f836f 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -261,9 +261,10 @@ _sist_sing(u3_noun ovo) u3_noun fex = u3h(vir); u3_noun fav = u3t(fex); - // XX is this now just to support ctrl-z during first boot? if ( c3__init == u3h(fav) ) { u3A->own = u3k(u3t(fav)); + // note: c3__boot == u3h(u3t(ovo)) + u3A->fak = ( c3__fake == u3h(u3t(u3t(ovo))) ) ? c3y : c3n; } vir = u3t(vir); @@ -1064,7 +1065,7 @@ _sist_rest() } u3z(rou); } - uL(fprintf(stderr, "\n---------------- playback complete----------------\n")); + uL(fprintf(stderr, "\n---------------- playback complete----------------\r\n")); #if 0 // If you see this error, your record is totally fscking broken! @@ -1371,6 +1372,8 @@ u3_sist_boot(void) _sist_make(pig); } else { + _sist_rest(); + if ( c3y == u3A->fak ) { c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); fprintf(stderr, "fake: %s\r\n", who_c); @@ -1385,6 +1388,5 @@ u3_sist_boot(void) // XX make conditional u3_Host.ops_u.net = c3n; } - _sist_rest(); } } From 82c89c1696a6a049a3c180c1dd16b89f5a236a90 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 16:25:04 -0400 Subject: [PATCH 169/221] 1. duplicates hint (%10) and wish (%11) at %13 and %14 (nock 4K) --- jets/f/ut_mint.c | 16 ++++++++-------- jets/f/ut_mull.c | 10 +++++----- noun/jets.c | 4 ++-- noun/nock.c | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 7dd189300..5e4f280ca 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -148,16 +148,16 @@ } static u3_noun - _mint_coke(u3_noun nug) + _mint_cove(u3_noun nug) { if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( 10 == u3h(nug) ) { - return _mint_coke(u3t(u3t(nug))); + else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + return _mint_cove(u3t(u3t(nug))); } else { - return u3m_error("mint-coke"); + return u3m_error("mint-cove"); } } @@ -370,7 +370,7 @@ u3_noun wam = u3qfu_play(van, sut, p_gen); u3_noun dok = u3nc(c3__wing, u3k(q_gen)); u3_noun vol = _mint_corn(van, sut, dok); - u3_noun axe = _mint_coke(vol); + u3_noun axe = _mint_cove(vol); ret = u3nc(_mint_nice(van, gol, _mint_bean()), u3qfu_fish(van, wam, axe)); @@ -471,7 +471,7 @@ u3_noun viz = _mint_in(van, sut, c3__noun, q_gen); ret = u3nc(u3k(u3h(nef)), - u3nt(11, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); + u3nt(14, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); u3z(viz); u3z(nef); @@ -683,7 +683,7 @@ _mint_corn(van, sut, u3t(p_gen))); } ret = u3nc(u3k(u3h(hum)), - u3nt(10, bez, u3k(u3t(hum)))); + u3nt(13, bez, u3k(u3t(hum)))); u3z(hum); return ret; @@ -786,7 +786,7 @@ u3_noun hum = _mint_in(van, sut, gol, q_gen); u3_noun bez = u3nt(c3__spot, 1, u3k(p_gen)); - ret = u3nc(u3k(u3h(hum)), u3nt(10, bez, u3k(u3t(hum)))); + ret = u3nc(u3k(u3h(hum)), u3nt(13, bez, u3k(u3t(hum)))); u3z(hum); } u3t_drop(); diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index e07840743..1a00c6099 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -63,16 +63,16 @@ } } static u3_noun - _mull_coke(u3_noun nug) + _mull_cove(u3_noun nug) { if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( 10 == u3h(nug) ) { - return _mull_coke(u3t(u3t(nug))); + else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + return _mull_cove(u3t(u3t(nug))); } else { - return u3m_error("mull-coke"); + return u3m_error("mull-cove"); } } @@ -109,7 +109,7 @@ u3_noun gen) { u3_noun fug = u3qfu_mint(van, sut, c3__noun, gen); - u3_noun axe = _mull_coke(u3t(fug)); + u3_noun axe = _mull_cove(u3t(fug)); u3z(fug); return axe; diff --git a/noun/jets.c b/noun/jets.c index f2c475960..3b27b4a1f 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && (10 == u3h(fol)) ) + while ( _(u3du(fol)) && ((10 == u3h(fol)) || (13 == u3h(fol))) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && (10 == u3h(q_clu)) ) { + while ( _(u3du(q_clu)) && ((10 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index c784d87ab..a2d77fde1 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1289,6 +1289,21 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; + // temporary home for hint + case 13: + u3x_cell(arg, &hed, &tel); + tot_w += _n_bint(ops, hed, tel, los_o, tel_o); + break; + + // temporary home for wish + case 14: + u3x_cell(arg, &hed, &tel); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); + break; + default: u3m_bail(c3__exit); return 0; From f64b5c8f801d4ef64c1c9e0a2e4ceefe159bf9e7 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 18:15:37 -0400 Subject: [PATCH 170/221] 2. removes %10 and %11 (nock 4K) --- jets/f/ut_mint.c | 2 +- jets/f/ut_mull.c | 2 +- noun/jets.c | 4 ++-- noun/nock.c | 13 ------------- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 5e4f280ca..a88d32557 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -153,7 +153,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( (13 == u3h(nug)) ) { return _mint_cove(u3t(u3t(nug))); } else { diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index 1a00c6099..4474f592c 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -68,7 +68,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (10 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( (13 == u3h(nug)) ) { return _mull_cove(u3t(u3t(nug))); } else { diff --git a/noun/jets.c b/noun/jets.c index 3b27b4a1f..9cd1ebebc 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && ((10 == u3h(fol)) || (13 == u3h(fol))) ) + while ( _(u3du(fol)) && ((13 == u3h(fol))) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && ((10 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { + while ( _(u3du(q_clu)) && ((13 == u3h(q_clu))) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index a2d77fde1..73e6b1743 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1276,19 +1276,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } break; - case 10: - u3x_cell(arg, &hed, &tel); - tot_w += _n_bint(ops, hed, tel, los_o, tel_o); - break; - - case 11: - u3x_cell(arg, &hed, &tel); - tot_w += _n_comp(ops, hed, c3n, c3n); - ++tot_w; _n_emit(ops, SWAP); - tot_w += _n_comp(ops, tel, c3n, c3n); - ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); - break; - // temporary home for hint case 13: u3x_cell(arg, &hed, &tel); From 4d6950d68a06f7d8c32eebaa51bbb931c85844f4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 18:40:13 -0400 Subject: [PATCH 171/221] 3. implements hint at %11 and wish at %12 (nock 4K) --- jets/f/ut_mint.c | 2 +- jets/f/ut_mull.c | 2 +- noun/jets.c | 4 ++-- noun/nock.c | 13 +++++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index a88d32557..f63b67eda 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -153,7 +153,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (13 == u3h(nug)) ) { + else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { return _mint_cove(u3t(u3t(nug))); } else { diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index 4474f592c..c22d91cf7 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -68,7 +68,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (13 == u3h(nug)) ) { + else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { return _mull_cove(u3t(u3t(nug))); } else { diff --git a/noun/jets.c b/noun/jets.c index 9cd1ebebc..11df57d4b 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && ((13 == u3h(fol))) ) + while ( _(u3du(fol)) && ((11 == u3h(fol)) || (13 == u3h(fol))) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && ((13 == u3h(q_clu))) ) { + while ( _(u3du(q_clu)) && ((11 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index 73e6b1743..23be93f0b 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1276,6 +1276,19 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } break; + case 11: + u3x_cell(arg, &hed, &tel); + tot_w += _n_bint(ops, hed, tel, los_o, tel_o); + break; + + case 12: + u3x_cell(arg, &hed, &tel); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); + break; + // temporary home for hint case 13: u3x_cell(arg, &hed, &tel); From c3ca5c24b6b346b0d00695217c16f4d224e17653 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 18:44:17 -0400 Subject: [PATCH 172/221] 4. emits %11 and %12 (nock 4K) --- jets/f/ut_mint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index f63b67eda..0d0f54e39 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -471,7 +471,7 @@ u3_noun viz = _mint_in(van, sut, c3__noun, q_gen); ret = u3nc(u3k(u3h(nef)), - u3nt(14, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); + u3nt(12, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); u3z(viz); u3z(nef); @@ -683,7 +683,7 @@ _mint_corn(van, sut, u3t(p_gen))); } ret = u3nc(u3k(u3h(hum)), - u3nt(13, bez, u3k(u3t(hum)))); + u3nt(11, bez, u3k(u3t(hum)))); u3z(hum); return ret; @@ -786,7 +786,7 @@ u3_noun hum = _mint_in(van, sut, gol, q_gen); u3_noun bez = u3nt(c3__spot, 1, u3k(p_gen)); - ret = u3nc(u3k(u3h(hum)), u3nt(13, bez, u3k(u3t(hum)))); + ret = u3nc(u3k(u3h(hum)), u3nt(11, bez, u3k(u3t(hum)))); u3z(hum); } u3t_drop(); From 8f42a29933cae14a0c0f3a039bf996faf9cf6588 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 19:15:35 -0400 Subject: [PATCH 173/221] 5. removes %13 and %14 (nock 4K) --- jets/f/ut_mint.c | 2 +- jets/f/ut_mull.c | 2 +- noun/jets.c | 4 ++-- noun/nock.c | 15 --------------- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 0d0f54e39..117c9c0d1 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -153,7 +153,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( 11 == u3h(nug) ) { return _mint_cove(u3t(u3t(nug))); } else { diff --git a/jets/f/ut_mull.c b/jets/f/ut_mull.c index c22d91cf7..760ebbf1f 100644 --- a/jets/f/ut_mull.c +++ b/jets/f/ut_mull.c @@ -68,7 +68,7 @@ if ( 0 == u3h(nug) ) { return u3k(u3t(nug)); } - else if ( (11 == u3h(nug)) || (13 == u3h(nug)) ) { + else if ( 11 == u3h(nug) ) { return _mull_cove(u3t(u3t(nug))); } else { diff --git a/noun/jets.c b/noun/jets.c index 11df57d4b..40405b543 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -249,7 +249,7 @@ _cj_axis(u3_noun fol) { u3_noun p_fol, q_fol, r_fol; - while ( _(u3du(fol)) && ((11 == u3h(fol)) || (13 == u3h(fol))) ) + while ( _(u3du(fol)) && (11 == u3h(fol)) ) { fol = u3t(u3t(fol)); } if ( !_(u3r_trel(fol, &p_fol, &q_fol, &r_fol)) ) { @@ -436,7 +436,7 @@ _cj_je_fsck(u3_noun clu) if ( 0 == (nam_c = _cj_chum(p_clu)) ) { u3z(clu); return u3_none; } - while ( _(u3du(q_clu)) && ((11 == u3h(q_clu)) || (13 == u3h(q_clu))) ) { + while ( _(u3du(q_clu)) && (11 == u3h(q_clu)) ) { q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { diff --git a/noun/nock.c b/noun/nock.c index 23be93f0b..459f6cb2e 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1289,21 +1289,6 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); break; - // temporary home for hint - case 13: - u3x_cell(arg, &hed, &tel); - tot_w += _n_bint(ops, hed, tel, los_o, tel_o); - break; - - // temporary home for wish - case 14: - u3x_cell(arg, &hed, &tel); - tot_w += _n_comp(ops, hed, c3n, c3n); - ++tot_w; _n_emit(ops, SWAP); - tot_w += _n_comp(ops, tel, c3n, c3n); - ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); - break; - default: u3m_bail(c3__exit); return 0; From 147941ba0774eb0c09ee7a5b79cbc2a1b0bbc7ea Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 19:51:37 -0400 Subject: [PATCH 174/221] 6. implements edit at %10 (nock 4K) --- noun/nock.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index b1af247b7..69a4661d1 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -526,7 +526,7 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIB 70 #define SLIS 71 #define SAVE 72 -// nock 12 +// nock 10 #define MUTH 73 #define KUTH 74 #define MUTT 75 @@ -1302,20 +1302,7 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) } break; - case 11: - u3x_cell(arg, &hed, &tel); - tot_w += _n_bint(ops, hed, tel, los_o, tel_o); - break; - - case 12: - u3x_cell(arg, &hed, &tel); - tot_w += _n_comp(ops, hed, c3n, c3n); - ++tot_w; _n_emit(ops, SWAP); - tot_w += _n_comp(ops, tel, c3n, c3n); - ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); - break; - - case 12: { + case 10: { u3_noun axe, nef; u3x_cell(arg, &hed, &tel); u3x_cell(hed, &axe, &nef); @@ -1347,6 +1334,19 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) break; } + case 11: + u3x_cell(arg, &hed, &tel); + tot_w += _n_bint(ops, hed, tel, los_o, tel_o); + break; + + case 12: + u3x_cell(arg, &hed, &tel); + tot_w += _n_comp(ops, hed, c3n, c3n); + ++tot_w; _n_emit(ops, SWAP); + tot_w += _n_comp(ops, tel, c3n, c3n); + ++tot_w; _n_emit(ops, (c3y == los_o) ? WILS : WISH); + break; + default: u3m_bail(c3__exit); return 0; From 7507de1e6c2eec01a8d2fb41e8895864cbc26ede Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 20:20:05 -0400 Subject: [PATCH 175/221] 7. updates %5 to require two subformulas (nock 4K) --- noun/nock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noun/nock.c b/noun/nock.c index 69a4661d1..adc1cf015 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -1211,8 +1211,8 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o) u3x_cell(arg, &hed, &tel); if ( c3n == u3du(hed) ) { - tot_w += _n_comp(ops, arg, los_o, c3n); - ++tot_w; _n_emit(ops, SAMC); + u3m_bail(c3__exit); + return 0; } else { c3_t hec_t, tec_t; From 898beb29310508cd8a193ffe14483ce0f8b0113f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 20:25:23 -0400 Subject: [PATCH 176/221] 8. updates nock 4K spec --- Spec/nock/4.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Spec/nock/4.txt b/Spec/nock/4.txt index b6dafee9d..3457d6bf6 100644 --- a/Spec/nock/4.txt +++ b/Spec/nock/4.txt @@ -1,5 +1,7 @@ A noun is an atom or a cell. An atom is a natural number. A cell is an ordered pair of nouns. +Reduce by the first matching pattern; variables match any noun. + nock(a) *a [a b c] [a [b c]] @@ -9,7 +11,6 @@ nock(a) *a +a 1 + a =[a a] 0 =[a b] 1 -=a =a /[1 a] a /[2 a b] a @@ -30,15 +31,15 @@ nock(a) *a *[a 2 b c] *[*[a b] *[a c]] *[a 3 b] ?*[a b] *[a 4 b] +*[a b] -*[a 5 b] =*[a b] +*[a 5 b c] =[*[a b] *[a c]] -*[a 6 b c d] *[a 2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b] -*[a 7 b c] *[a 2 b 1 c] -*[a 8 b c] *[a 7 [[7 [0 1] b] 0 1] c] -*[a 9 b c] *[a 7 c 2 [0 1] 0 b] -*[a 10 [b c] d] *[a 8 c 7 [0 3] d] -*[a 10 b c] *[a c] -*[a 12 [b c] d] #[b *[a c] *[a d]] +*[a 6 b c d] *[a *[[c d] 0 *[[2 3] 0 *[a 4 4 b]]]] +*[a 7 b c] *[*[a b] c] +*[a 8 b c] *[[*[a b] a] c] +*[a 9 b c] *[*[a c] 2 [0 1] 0 b] +*[a 10 [b c] d] #[b *[a c] *[a d]] + +*[a 11 [b c] d] *[[*[a c] *[a d]] 0 3] +*[a 11 b c] *[a c] *a *a - From 25bb368243b69030e86bdffe6ca8b149a4bdcb2c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 16 Oct 2018 17:26:41 -0400 Subject: [PATCH 177/221] accepts all (identical) %init cards --- vere/reck.c | 8 ++++---- vere/sist.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/vere/reck.c b/vere/reck.c index 6d3379bec..3a44f2970 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -100,8 +100,8 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__init: p_fav = u3t(fav); { - c3_assert( u3_none == u3A->own ); - u3A->own = u3k(p_fav); + uL(fprintf(uH, "kick: init: term\n")); + c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; } break; @@ -225,7 +225,7 @@ _reck_kick_ames(u3_noun pox, u3_noun fav) case c3__init: p_fav = u3t(fav); { uL(fprintf(uH, "kick: init: ames\n")); - c3_assert(0); + c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; } break; @@ -315,7 +315,7 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) case c3__init: p_fav = u3t(fav); { uL(fprintf(uH, "kick: init: spec\n")); - c3_assert(0); + c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; } break; diff --git a/vere/sist.c b/vere/sist.c index 3090f836f..2804e8e34 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1346,7 +1346,7 @@ void u3_sist_boot(void) { if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun pig; + u3_noun pig, who; if ( 0 != u3_Host.ops_u.fak_c ) { u3_noun whu = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.fak_c)); @@ -1359,16 +1359,17 @@ u3_sist_boot(void) fprintf(stderr, "fake: %s\r\n", u3_Host.ops_u.fak_c); u3A->fak = c3y; - pig = u3nc(c3__fake, u3k(u3t(whu))); + who = u3k(u3t(whu)); + pig = u3nc(c3__fake, who); u3z(whu); } else { u3A->fak = c3n; pig = _sist_dawn(); + who = u3k(u3h(u3h(u3t(pig)))); } - // will be set by %init card in reck.c - u3A->own = u3_none; + u3A->own = who; _sist_make(pig); } else { From 5b33f63f6a82dd6bfcfd6c84efc54672d0a52afa Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 16 Oct 2018 17:38:27 -0400 Subject: [PATCH 178/221] restores %dawn galaxy table --- vere/sist.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 2804e8e34..0e1a09c3b 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1323,11 +1323,8 @@ _sist_dawn(void) u3_lo_bail(); } - // XX slow, temporarily disabled - // XX maybe print messages, spin a cursor, etc. - // u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); - // u3_noun zar = u3do("czar:take:dawn", raz); - u3_noun zar = u3_nul; + u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); + u3_noun zar = u3do("czar:take:dawn", raz); u3_noun fut = _sist_eth_rpc(url_c, u3v_wish("turf:give:dawn")); u3_noun tuf = u3do("turf:take:dawn", fut); From fc6530fa30adbbe425a72cb048062d646fcb300e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 16 Oct 2018 18:02:55 -0400 Subject: [PATCH 179/221] allows -N without -F (temporary, revisit) --- vere/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vere/main.c b/vere/main.c index 13f164229..eced43364 100644 --- a/vere/main.c +++ b/vere/main.c @@ -218,8 +218,8 @@ _main_getopt(c3_i argc, c3_c** argv) // XX revisit if ( (0 == u3_Host.ops_u.fak_c) && (c3y == u3_Host.ops_u.net) ) { - fprintf(stderr, "-N only makes sense with -F\n"); - return c3n; + // fprintf(stderr, "-N only makes sense with -F\n"); + u3_Host.ops_u.net = c3n; } else if ( (0 == u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.net) ) { u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } From 6e77aa110aa3776fed386f5bd8cf3a17d5c7e1bc Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 4 Oct 2018 02:43:08 -0400 Subject: [PATCH 180/221] starts ames on %turf card, removes -H uses ames domain for tcp proxy, and moves czar arvo sync after ames initialization --- include/c/motes.h | 1 + include/vere/vere.h | 8 ++- vere/ames.c | 148 +++++++++++++++++++++++++++++++++++++------- vere/http.c | 18 ++++-- vere/loop.c | 5 ++ vere/main.c | 11 +--- vere/reck.c | 5 ++ vere/sist.c | 22 ------- 8 files changed, 159 insertions(+), 59 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 7914354ca..8cb2dbbc7 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -1141,6 +1141,7 @@ # define c3__tung c3_s4('t','u','n','g') # define c3__tupl c3_s4('t','u','p','l') # define c3__turd c3_s4('t','u','r','d') +# define c3__turf c3_s4('t','u','r','f') # define c3__turn c3_s4('t','u','r','n') # define c3__twig c3_s4('t','w','i','g') # define c3__twix c3_s4('t','w','i','x') diff --git a/include/vere/vere.h b/include/vere/vere.h index ced7474fd..2183d483e 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -254,9 +254,11 @@ uv_handle_t had_u; }; uv_timer_t tim_u; // network timer + c3_o liv; // listener on c3_o alm; // alarm on c3_w law_w; // last wakeup, unix time c3_s por_s; // public IPv4 port + c3_c* dns_c; // domain XX multiple/fallback c3_w imp_w[256]; // imperial IPs time_t imp_t[256]; // imperial IP timestamps } u3_ames; @@ -578,7 +580,6 @@ */ typedef struct _u3_opts { c3_c* arv_c; // -A, initial sync from - c3_c* dns_c; // -H, ames bootstrap domain c3_c* gen_c; // -G, czar generator c3_c* imp_c; // -I, czar name c3_c* nam_c; // -n, unix hostname @@ -938,6 +939,11 @@ u3_ames_ef_send(u3_noun lan, u3_noun pac); + /* u3_ames_ef_turf(): initialize ames I/O on domain(s). + */ + void + u3_ames_ef_turf(u3_noun tuf); + /* u3_ames_io_init(): initialize ames I/O. */ void diff --git a/vere/ames.c b/vere/ames.c index 3a9fc0f16..b04d64ecd 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -197,6 +197,8 @@ _ames_czar(u3_pact* pac_u, c3_c* bos_c) return; } + c3_assert( 0 != bos_c ); + time_t now = time(0); // backoff @@ -269,6 +271,8 @@ _ames_lane_ip(u3_noun lan, c3_s* por_s, c3_w* pip_w) return c3n; } +/* u3_ames_ef_bake(): notify %ames that we're live. +*/ void u3_ames_ef_bake(void) { @@ -303,7 +307,7 @@ u3_ames_ef_send(u3_noun lan, u3_noun pac) if ( (0 == (pac_u->pip_w >> 16)) && (1 == (pac_u->pip_w >> 8)) ) { pac_u->imp_y = (pac_u->pip_w & 0xff); - _ames_czar(pac_u, u3_Host.ops_u.dns_c); + _ames_czar(pac_u, u3_Host.sam_u.dns_c); } else if ( (c3y == u3_Host.ops_u.net) || (0x7f000001 == pac_u->pip_w) ) { _ames_send(pac_u); @@ -326,15 +330,22 @@ static void _ames_time_cb(uv_timer_t* tim_uo) { u3_ames* sam_u = &u3_Host.sam_u; - u3_lo_open(); - sam_u->law_w = time(0); - { - u3v_plan - (u3nt(u3_blip, c3__ames, u3_nul), - u3nc(c3__wake, u3_nul)); + // defer until started via u3_ames_ef_turf() + if ( c3n == sam_u->liv ) { + uv_timer_start(&sam_u->tim_u, _ames_time_cb, 1000, 0); + } + else { + u3_lo_open(); + + sam_u->law_w = time(0); + { + u3v_plan + (u3nt(u3_blip, c3__ames, u3_nul), + u3nc(c3__wake, u3_nul)); + } + u3_lo_shut(c3n); } - u3_lo_shut(c3n); } /* _ames_recv_cb(): receive callback. @@ -376,15 +387,15 @@ _ames_recv_cb(uv_udp_t* wax_u, } } -/* u3_ames_io_init(): initialize ames I/O. +/* _ames_io_start(): initialize ames I/O. */ -void -u3_ames_io_init() +static void +_ames_io_start() { u3_ames* sam_u = &u3_Host.sam_u; - c3_s por_s; + c3_s por_s = u3_Host.ops_u.por_s; - por_s = u3_Host.ops_u.por_s; + // XX use clan:title u3A->own if ( 0 != u3_Host.ops_u.imp_c ) { u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); u3_noun num = u3dc("slaw", 'p', imp); @@ -442,10 +453,103 @@ u3_ames_io_init() sam_u->por_s = ntohs(add_u.sin_port); } - // Timer too. - { - uv_timer_init(u3L, &sam_u->tim_u); + + // uL(fprintf(uH, "ames: on localhost, UDP %d.\n", sam_u->por_s)); + uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); + + sam_u->liv = c3y; +} + +/* _cttp_mcut_char(): measure/cut character. +*/ +static c3_w +_cttp_mcut_char(c3_c* buf_c, c3_w len_w, c3_c chr_c) +{ + if ( buf_c ) { + buf_c[len_w] = chr_c; } + return len_w + 1; +} + +/* _cttp_mcut_cord(): measure/cut cord. +*/ +static c3_w +_cttp_mcut_cord(c3_c* buf_c, c3_w len_w, u3_noun san) +{ + c3_w ten_w = u3r_met(3, san); + + if ( buf_c ) { + u3r_bytes(0, ten_w, (c3_y *)(buf_c + len_w), san); + } + u3z(san); + return (len_w + ten_w); +} + +/* _cttp_mcut_path(): measure/cut cord list. +*/ +static c3_w +_cttp_mcut_path(c3_c* buf_c, c3_w len_w, c3_c sep_c, u3_noun pax) +{ + u3_noun axp = pax; + + while ( u3_nul != axp ) { + u3_noun h_axp = u3h(axp); + + len_w = _cttp_mcut_cord(buf_c, len_w, u3k(h_axp)); + axp = u3t(axp); + + if ( u3_nul != axp ) { + len_w = _cttp_mcut_char(buf_c, len_w, sep_c); + } + } + u3z(pax); + return len_w; +} + +/* _cttp_mcut_host(): measure/cut host. +*/ +static c3_w +_cttp_mcut_host(c3_c* buf_c, c3_w len_w, u3_noun hot) +{ + len_w = _cttp_mcut_path(buf_c, len_w, '.', u3kb_flop(u3k(hot))); + u3z(hot); + return len_w; +} + +/* u3_ames_ef_turf(): initialize ames I/O on domain(s). +*/ +void +u3_ames_ef_turf(u3_noun tuf) +{ + if ( u3_nul != tuf ) { + // XX save all for fallback, not just first + u3_noun hot = u3k(u3h(tuf)); + c3_w len_w = _cttp_mcut_host(0, 0, u3k(hot)); + + u3_Host.sam_u.dns_c = c3_malloc(1 + len_w); + _cttp_mcut_host(u3_Host.sam_u.dns_c, 0, hot); + u3_Host.sam_u.dns_c[len_w] = 0; + + u3z(tuf); + } + else if ( c3n == u3A->fak ) { + // XX assert? + uL(fprintf(uH, "ames: turf: no domains\n")); + } + + if ( c3n == u3_Host.sam_u.liv ) { + _ames_io_start(); + } +} + +/* u3_ames_io_init(): initialize ames I/O. +*/ +void +u3_ames_io_init() +{ + u3_ames* sam_u = &u3_Host.sam_u; + sam_u->liv = c3n; + uv_timer_init(u3L, &sam_u->tim_u); } /* u3_ames_io_talk(): start receiving ames traffic. @@ -453,10 +557,6 @@ u3_ames_io_init() void u3_ames_io_talk() { - u3_ames* sam_u = &u3_Host.sam_u; - - uL(fprintf(uH, "ames: on localhost, UDP %d.\n", sam_u->por_s)); - uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); } /* u3_ames_io_exit(): terminate ames I/O. @@ -466,8 +566,12 @@ u3_ames_io_exit() { u3_ames* sam_u = &u3_Host.sam_u; - // XX close wax_u instead - uv_close(&sam_u->had_u, 0); + uv_close((uv_handle_t*)&sam_u->tim_u, 0); + + if ( c3y == sam_u->liv ) { + // XX remove had_u/wax_u union, cast and close wax_u + uv_close(&sam_u->had_u, 0); + } } /* u3_ames_io_poll(): update ames IO state. diff --git a/vere/http.c b/vere/http.c index ea2b006da..14d5fd4af 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1231,6 +1231,7 @@ _http_release_ports_file(c3_c *pax_c) free(paf_c); } + /* _http_czar_host(): galaxy hostname as (unit host:eyre) */ static u3_noun @@ -1238,6 +1239,8 @@ _http_czar_host(void) { u3_noun dom = u3_nul; + // XX revisit +#if 0 if ( (0 == u3_Host.ops_u.imp_c) || (c3n == u3_Host.ops_u.net) ) { return dom; } @@ -1272,6 +1275,7 @@ _http_czar_host(void) } } } +#endif if ( u3_nul == dom ) { return dom; @@ -2424,12 +2428,15 @@ _proxy_ward_resolve(u3_warc* cli_u) hin_u.ai_protocol = IPPROTO_TCP; if ( 0 == cli_u->hot_c ) { + // XX revisit + c3_assert( 0 != u3_Host.sam_u.dns_c ); + u3_noun sip = u3dc("scot", 'p', u3k(cli_u->sip)); c3_c* sip_c = u3r_string(sip); - c3_w len_w = 1 + strlen(sip_c) + strlen(u3_Host.ops_u.dns_c); + c3_w len_w = 1 + strlen(sip_c) + strlen(u3_Host.sam_u.dns_c); cli_u->hot_c = c3_malloc(len_w); // incremented to skip '~' - snprintf(cli_u->hot_c, len_w, "%s.%s", sip_c + 1, u3_Host.ops_u.dns_c); + snprintf(cli_u->hot_c, len_w, "%s.%s", sip_c + 1, u3_Host.sam_u.dns_c); free(sip_c); u3z(sip); @@ -2541,11 +2548,14 @@ _proxy_parse_ship(c3_c* hot_c) return sip; } + // XX revisit + c3_assert( 0 != u3_Host.sam_u.dns_c ); + c3_w dif_w = dom_c - hot_c; - c3_w dns_w = strlen(u3_Host.ops_u.dns_c); + c3_w dns_w = strlen(u3_Host.sam_u.dns_c); if ( (dns_w != strlen(hot_c) - (dif_w + 1)) || - (0 != strncmp(dom_c + 1, u3_Host.ops_u.dns_c, dns_w)) ) { + (0 != strncmp(dom_c + 1, u3_Host.sam_u.dns_c, dns_w)) ) { return sip; } diff --git a/vere/loop.c b/vere/loop.c index d3362efb3..cac36d6ff 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -667,7 +667,12 @@ u3_lo_lead(void) // Further server configuration. // { + u3_ames_ef_bake(); u3_http_ef_bake(); + + if ( (c3y == u3_Host.ops_u.nuu) && (0 != u3_Host.ops_u.imp_c) ) { + u3_unix_ef_initial_into(); + } } _lo_talk(); diff --git a/vere/main.c b/vere/main.c index eced43364..0f60f735b 100644 --- a/vere/main.c +++ b/vere/main.c @@ -91,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:H:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -109,10 +109,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.arv_c = strdup(optarg); break; } - case 'H': { - u3_Host.ops_u.dns_c = strdup(optarg); - break; - } // XX remove in deference to -K case 'I': { u3_Host.ops_u.imp_c = _main_presig(optarg); @@ -282,10 +278,6 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.dns_c == 0 ) { - u3_Host.ops_u.dns_c = "urbit.org"; - } - if ( u3_Host.ops_u.pil_c != 0 ) { struct stat s; if ( stat(u3_Host.ops_u.pil_c, &s) != 0 ) { @@ -358,7 +350,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", - "-H domain Set ames bootstrap domain (default urbit.org)\n", "-I galaxy Start as ~galaxy\n", "-k stage Start at Hoon kernel version stage\n", "-l port Initial peer port\n", diff --git a/vere/reck.c b/vere/reck.c index 3a44f2970..3515c3268 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -208,6 +208,11 @@ _reck_kick_newt(u3_noun pox, u3_noun fav) u3_ames_ef_send(lan, pac); u3z(pox); u3z(fav); return c3y; } break; + + case c3__turf: { + u3_ames_ef_turf(u3k(u3t(fav))); + u3z(pox); u3z(fav); return c3y; + } break; } u3z(pox); u3z(fav); return c3n; } diff --git a/vere/sist.c b/vere/sist.c index 0e1a09c3b..9986b45a2 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -277,21 +277,6 @@ _sist_sing(u3_noun ovo) } } - -/* _sist_home(): remains of "create ship directory" after refactor to u3m_boot(). -*/ -static void -_sist_home() -{ -#if 1 - // Copy zod files, if we're generating a carrier. - // - if ( u3_Host.ops_u.imp_c ) { - u3_unix_ef_initial_into(); - } -#endif -} - /* _sist_cask(): ask for a passcode. */ static u3_noun @@ -518,10 +503,6 @@ _sist_zest() c3_c ful_c[8193]; c3_l sal_l; - // Create the ship directory. - // - _sist_home(); - // Create the record file. { c3_i pig_i = O_CREAT | O_WRONLY | O_EXCL; @@ -602,9 +583,6 @@ _sist_zest() static void _sist_make(u3_noun fav) { - // Initialize ames - u3_ames_ef_bake(); - // Authenticate and initialize terminal. // u3_term_ef_bake(fav); From 5207c8321f8f8a1f9dbc7915416996f0f4fd1904 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 9 Oct 2018 23:44:00 -0400 Subject: [PATCH 181/221] use +clan:title to detect galaxy --- include/c/motes.h | 1 + vere/ames.c | 25 +++++++++++-------------- vere/loop.c | 10 ++++++++-- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 8cb2dbbc7..6d5dadf76 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -278,6 +278,7 @@ # define c3__ctl c3_s3('c','t','l') # define c3__cut c3_s3('c','u','t') # define c3__cyl c3_s3('c','y','l') +# define c3__czar c3_s4('c','z','a','r') # define c3__d c3_s1('d') # define c3__da c3_s2('d','a') # define c3__dago c3_s4('d','a','g','o') diff --git a/vere/ames.c b/vere/ames.c index b04d64ecd..913c85616 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -394,28 +394,24 @@ _ames_io_start() { u3_ames* sam_u = &u3_Host.sam_u; c3_s por_s = u3_Host.ops_u.por_s; + u3_noun rac = u3do("clan:title", u3k(u3A->own)); - // XX use clan:title u3A->own - if ( 0 != u3_Host.ops_u.imp_c ) { - u3_noun imp = u3i_string(u3_Host.ops_u.imp_c); - u3_noun num = u3dc("slaw", 'p', imp); - c3_y num_y; + if ( c3__czar == rac ) { + u3_noun imp = u3dc("scot", 'p', u3k(u3A->own)); + c3_c* imp_c = u3r_string(imp); + c3_y num_y = u3r_byte(0, u3A->own); - if ( c3n == u3du(num) ) { - uL(fprintf(uH, "malformed emperor: %s\n", u3_Host.ops_u.imp_c)); - exit(1); - } - num_y = u3r_byte(0, u3t(num)); por_s = _ames_czar_port(num_y); if ( c3y == u3_Host.ops_u.net ) { - uL(fprintf(uH, "ames: czar: %s on %d\n", u3_Host.ops_u.imp_c, por_s)); + uL(fprintf(uH, "ames: czar: %s on %d\n", imp_c, por_s)); } else { - uL(fprintf(uH, "ames: czar: %s on %d (localhost only)\n", - u3_Host.ops_u.imp_c, por_s)); + uL(fprintf(uH, "ames: czar: %s on %d (localhost only)\n", imp_c, por_s)); } - u3z(num); + + u3z(imp); + free(imp_c); } int ret; @@ -458,6 +454,7 @@ _ames_io_start() uv_udp_recv_start(&sam_u->wax_u, _ames_alloc, _ames_recv_cb); sam_u->liv = c3y; + u3z(rac); } /* _cttp_mcut_char(): measure/cut character. diff --git a/vere/loop.c b/vere/loop.c index cac36d6ff..ac830936e 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -670,8 +670,14 @@ u3_lo_lead(void) u3_ames_ef_bake(); u3_http_ef_bake(); - if ( (c3y == u3_Host.ops_u.nuu) && (0 != u3_Host.ops_u.imp_c) ) { - u3_unix_ef_initial_into(); + if ( c3y == u3_Host.ops_u.nuu ) { + u3_noun rac = u3do("clan:title", u3k(u3A->own)); + + if ( c3__czar == rac ) { + u3_unix_ef_initial_into(); + } + + u3z(rac); } } From f76f8b5363ed8417659cba3e64af6cf1cbc21a9e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 02:04:46 -0400 Subject: [PATCH 182/221] refactors u3_sist_boot and pre-boot validation --- vere/sist.c | 162 ++++++++++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 74 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 9986b45a2..32d79be53 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -578,20 +578,6 @@ _sist_zest() u3_raft_work(); } -/* _sist_make(): boot from scratch. -*/ -static void -_sist_make(u3_noun fav) -{ - // Authenticate and initialize terminal. - // - u3_term_ef_bake(fav); - - // Create the ship directory. - // - _sist_zest(); -} - /* _sist_rest_nuu(): upgrade log from previous format. */ static void @@ -1258,60 +1244,79 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) /* _sist_dawn(): produce %dawn boot card - validate keys and query contract */ static u3_noun -_sist_dawn(void) +_sist_dawn(u3_noun des) { - if ( 0 == u3_Host.ops_u.key_c ) { - // XX print nice error - u3_lo_bail(); + u3_noun who, sed, pon, zar, tuf; + + { + u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); + + if ( u3_nul == eds ) { + // XX print nice error + u3_lo_bail(); + } + + // +seed:able:jael: private key file + sed = u3ke_cue(u3k(u3t(eds))); + // XX compare against ops_u.who_c + who = u3h(sed); + + u3z(des); u3z(eds); } - u3_noun eds = u3m_file(u3_Host.ops_u.key_c); - u3_noun des = u3dc("slaw", c3__uw, eds); - - if ( u3_nul == des ) { - // XX print nice error - u3_lo_bail(); - } - - // +seed:dawn: - // [who=ship lyf=life key=ring sig=(unit oath:pki:jael)] - u3_noun sed = u3ke_cue(u3t(des)); - u3_noun who = u3h(sed); - - // u3_noun lyf = u3h(u3t(sed)); - // u3_noun key = u3h(u3t(u3t(sed))); - // u3_noun sig = u3t(u3t(u3t(sed))); - // u3_noun rac = u3do("clan:title", u3k(who)); - // XX configure default globally, add cli arg to specify c3_c* url_c = "http://localhost:8545"; - u3_noun luh = _sist_eth_rpc(url_c, u3do("hull:give:dawn", u3k(who))); - u3_noun hul = u3dc("hull:take:dawn", u3k(who), luh); + // XX leaks nock + { + // +hull:constitution:ethe: on-chain state + u3_noun oct = u3do("hull:give:dawn", u3k(who)); + u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); + u3_noun hul = u3dc("hull:take:dawn", u3k(who), u3k(luh)); - // XX actually make request - // u3_noun liv = _sist_get_json(parent, /some/url) - u3_noun liv = u3_nul; + // +live:dawn: network state + // XX actually make request + // u3_noun liv = _sist_get_json(parent, /some/url) + u3_noun liv = u3_nul; - u3_noun sas = u3dt("veri:dawn", sed, hul, liv); + // XX revisit + // (each [seed (unit ship)] [rank @tas]) + u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); - if ( c3n == u3h(sas) ) { - // XX deconstruct sas, print helpful error messages - u3m_p("pre-boot error", u3t(sas)); - u3_lo_bail(); + if ( c3n == u3h(sas) ) { + // XX deconstruct sas, print helpful error messages + u3m_p("pre-boot error", u3t(sas)); + u3_lo_bail(); + } + + // (unit ship): sponsor + // produced by +veri:dawn to avoid coupling to +hull structure + pon = u3k(u3t(u3t(sas))); + + u3z(oct); u3z(luh); u3z(hul); u3z(liv); u3z(sas); } - u3_noun raz = _sist_eth_rpc(url_c, u3v_wish("czar:give:dawn")); - u3_noun zar = u3do("czar:take:dawn", raz); + // XX leaks nock + { + // (map ship [=life =pass]): galaxy table + u3_noun oct = u3v_wish("czar:give:dawn"); + u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); + zar = u3do("czar:take:dawn", u3k(raz)); - u3_noun fut = _sist_eth_rpc(url_c, u3v_wish("turf:give:dawn")); - u3_noun tuf = u3do("turf:take:dawn", fut); + u3z(oct); u3z(raz); + } - // XX extract from sas - // XX or maybe pass entire hull? - u3_noun pon = u3_nul; + // XX leaks nock + { + // (list turf): ames domains + u3_noun oct = u3v_wish("turf:give:dawn"); + u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); + tuf = u3do("turf:take:dawn", u3k(fut)); - // [%dawn =seed:dawn spon=(unit ship) czar=(map ship [=life =pass]) turf=(list (pair @ud (list @ta)))] + u3z(oct); u3z(fut); + } + + // [%dawn seed sponsor galaxies domains] return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); } @@ -1320,7 +1325,19 @@ _sist_dawn(void) void u3_sist_boot(void) { - if ( c3y == u3_Host.ops_u.nuu ) { + if ( c3n == u3_Host.ops_u.nuu ) { + _sist_rest(); + + if ( c3y == u3A->fak ) { + c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); + fprintf(stderr, "fake: %s\r\n", who_c); + free(who_c); + + // XX make conditional + u3_Host.ops_u.net = c3n; + } + } + else { u3_noun pig, who; if ( 0 != u3_Host.ops_u.fak_c ) { @@ -1335,34 +1352,31 @@ u3_sist_boot(void) u3A->fak = c3y; who = u3k(u3t(whu)); - pig = u3nc(c3__fake, who); + pig = u3nc(c3__fake, u3k(who)); + u3z(whu); } else { + if ( 0 == u3_Host.ops_u.key_c ) { + // XX print nice error + u3_lo_bail(); + } + + u3_noun des = u3m_file(u3_Host.ops_u.key_c); + u3A->fak = c3n; - pig = _sist_dawn(); + pig = _sist_dawn(u3k(des)); who = u3k(u3h(u3h(u3t(pig)))); + + u3z(des); } u3A->own = who; - _sist_make(pig); - } - else { - _sist_rest(); - if ( c3y == u3A->fak ) { - c3_c* who_c = u3r_string(u3dc("scot", 'p', u3k(u3A->own))); - fprintf(stderr, "fake: %s\r\n", who_c); + // Authenticate and initialize terminal. + u3_term_ef_bake(pig); - // XX use clan:title - if ( 4 == strlen(who_c) ) { - u3_Host.ops_u.imp_c = who_c; - } else { - free(who_c); - } - - // XX make conditional - u3_Host.ops_u.net = c3n; - } + // Create the ship directory. + _sist_zest(); } } From 4bcfcf0b3a283b3484e536394334b2ac2596d59d Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 02:08:43 -0400 Subject: [PATCH 183/221] completely removes -I --- include/vere/vere.h | 1 - vere/http.c | 3 ++- vere/main.c | 32 +++++++------------------------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 2183d483e..c4c02449f 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -581,7 +581,6 @@ typedef struct _u3_opts { c3_c* arv_c; // -A, initial sync from c3_c* gen_c; // -G, czar generator - c3_c* imp_c; // -I, czar name c3_c* nam_c; // -n, unix hostname c3_c* pil_c; // -B, bootstrap from c3_c* raf_c; // -r, raft flotilla diff --git a/vere/http.c b/vere/http.c index 14d5fd4af..2211ade95 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1238,6 +1238,7 @@ static u3_noun _http_czar_host(void) { u3_noun dom = u3_nul; + return dom; // XX revisit #if 0 @@ -1275,7 +1276,6 @@ _http_czar_host(void) } } } -#endif if ( u3_nul == dom ) { return dom; @@ -1285,6 +1285,7 @@ _http_czar_host(void) dom = u3nc(u3i_string(u3_Host.ops_u.imp_c + 1), u3kb_flop(u3k(dom))); return u3nt(u3_nul, c3y, u3kb_flop(u3k(dom))); +#endif } /* u3_http_ef_bake(): notify %eyre that we're live diff --git a/vere/main.c b/vere/main.c index 0f60f735b..0fbf9783c 100644 --- a/vere/main.c +++ b/vere/main.c @@ -91,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:I:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -109,11 +109,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.arv_c = strdup(optarg); break; } - // XX remove in deference to -K - case 'I': { - u3_Host.ops_u.imp_c = _main_presig(optarg); - break; - } case 'F': { u3_Host.ops_u.fak_c = _main_presig(optarg); break; @@ -143,7 +138,6 @@ _main_getopt(c3_i argc, c3_c** argv) } case 'K': { u3_Host.ops_u.key_c = strdup(optarg); - u3_Host.ops_u.nuu = c3y; break; } case 'k': { @@ -194,18 +188,11 @@ _main_getopt(c3_i argc, c3_c** argv) } } - // XX remove -I - if ( (0 != u3_Host.ops_u.fak_c) && (0 != u3_Host.ops_u.imp_c) ) { - fprintf(stderr, "-I is redundant with -F\n"); - return c3n; + if ( 0 != u3_Host.ops_u.fak_c ) { + u3_Host.ops_u.who_c = strdup(u3_Host.ops_u.fak_c); } - // set galaxy name - // XX need to do this with -K too - // -A is required when booting a galaxy - if ( (0 != u3_Host.ops_u.fak_c) && (4 == strlen(u3_Host.ops_u.fak_c)) ) { - u3_Host.ops_u.imp_c = strdup(u3_Host.ops_u.fak_c); - } + c3_t imp_t = ( (0 != u3_Host.ops_u.who_c) && (4 == strlen(u3_Host.ops_u.who_c)) ); if ( (0 != u3_Host.ops_u.fak_c) && (c3n == u3_Host.ops_u.nuu) ) { fprintf(stderr, "-F only makes sense on initial boot\n"); @@ -220,22 +207,18 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } - if ( u3_Host.ops_u.arv_c != 0 && ( u3_Host.ops_u.imp_c == 0 || - u3_Host.ops_u.nuu == c3n ) ) { + if ( u3_Host.ops_u.arv_c != 0 && !imp_t ) { fprintf(stderr, "-A only makes sense when creating a new galaxy\n"); return c3n; } - if ( u3_Host.ops_u.imp_c != 0 && - u3_Host.ops_u.arv_c == 0 && - u3_Host.ops_u.nuu == c3y ) { + if ( u3_Host.ops_u.arv_c == 0 && imp_t ) { fprintf(stderr, "can't create a new galaxy without specifying " "the initial sync path with -A\n"); return c3n; } - if ( u3_Host.ops_u.gen_c != 0 && ( u3_Host.ops_u.imp_c == 0 || - u3_Host.ops_u.nuu == c3n ) ) { + if ( u3_Host.ops_u.gen_c != 0 && ( !imp_t || u3_Host.ops_u.nuu == c3n ) ) { fprintf(stderr, "-G only makes sense when creating a new galaxy\n"); return c3n; } @@ -350,7 +333,6 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", - "-I galaxy Start as ~galaxy\n", "-k stage Start at Hoon kernel version stage\n", "-l port Initial peer port\n", "-M Memory madness\n", From 178c2212cfef095189412164940ddc77d84ee326 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 11:18:54 -0400 Subject: [PATCH 184/221] adds -e to specify ethereum node url --- include/vere/vere.h | 1 + vere/main.c | 6 +++++- vere/sist.c | 11 ++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index c4c02449f..57a3b346b 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -591,6 +591,7 @@ c3_o bat; // -b, batch create c3_o dem; // -d, daemon c3_o dry; // -D, dry compute + c3_c* eth_c; // -e, ethereum node url c3_c* fak_c; // -F, fake ship c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector diff --git a/vere/main.c b/vere/main.c index 0fbf9783c..470b1fb09 100644 --- a/vere/main.c +++ b/vere/main.c @@ -91,7 +91,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:e:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -109,6 +109,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.arv_c = strdup(optarg); break; } + case 'e': { + u3_Host.ops_u.eth_c = strdup(optarg); + break; + } case 'F': { u3_Host.ops_u.fak_c = _main_presig(optarg); break; diff --git a/vere/sist.c b/vere/sist.c index 32d79be53..8acb9888e 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1174,6 +1174,8 @@ _sist_post_json(c3_c* url_c, uv_buf_t lod_u) hed_u = curl_slist_append(hed_u, "Content-Type: application/json"); hed_u = curl_slist_append(hed_u, "charsets: utf-8"); + // XX require TLS, pin default cert? + curl_easy_setopt(curl, CURLOPT_URL, url_c); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _sist_curl_alloc); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); @@ -1248,6 +1250,10 @@ _sist_dawn(u3_noun des) { u3_noun who, sed, pon, zar, tuf; + c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); + // XX require https? + c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; + { u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); @@ -1264,9 +1270,6 @@ _sist_dawn(u3_noun des) u3z(des); u3z(eds); } - // XX configure default globally, add cli arg to specify - c3_c* url_c = "http://localhost:8545"; - // XX leaks nock { // +hull:constitution:ethe: on-chain state @@ -1316,6 +1319,8 @@ _sist_dawn(u3_noun des) u3z(oct); u3z(fut); } + // XX include ops_u.eth_c if set + // [%dawn seed sponsor galaxies domains] return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); } From ca1259bf70498a285053b995212977c07b7f1231 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 11:29:59 -0400 Subject: [PATCH 185/221] check that -w matches the ship in -K --- vere/sist.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 8acb9888e..52a478179 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1258,16 +1258,40 @@ _sist_dawn(u3_noun des) u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); if ( u3_nul == eds ) { - // XX print nice error + c3_c* sed_c = u3r_string(des); + fprintf(stderr, "dawn: invalid private keys: %s\r\n", sed_c); + free(sed_c); + u3_lo_bail(); + } + + if ( 0 == u3_Host.ops_u.who_c ) { + fprintf(stderr, "dawn: -w required\r\n"); + u3_lo_bail(); + } + + u3_noun woh = u3i_string(u3_Host.ops_u.who_c); + u3_noun whu = u3dc("slaw", 'p', u3k(woh)); + + if ( u3_nul == whu ) { + fprintf(stderr, "dawn: invalid ship specificed with -w %s\r\n", + u3_Host.ops_u.who_c); u3_lo_bail(); } // +seed:able:jael: private key file sed = u3ke_cue(u3k(u3t(eds))); - // XX compare against ops_u.who_c who = u3h(sed); - u3z(des); u3z(eds); + if ( who != u3t(whu) ) { + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", + u3_Host.ops_u.who_c, how_c); + free(how_c); + u3_lo_bail(); + } + + u3z(woh); u3z(whu); u3z(des); u3z(eds); } // XX leaks nock From 4b6c6978146c663d648386982235b3e54e1c4207 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 10 Oct 2018 11:38:32 -0400 Subject: [PATCH 186/221] allows -G as an alternative to -K (temporarily) --- vere/main.c | 4 ++-- vere/sist.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/vere/main.c b/vere/main.c index 470b1fb09..3b793462d 100644 --- a/vere/main.c +++ b/vere/main.c @@ -222,8 +222,8 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } - if ( u3_Host.ops_u.gen_c != 0 && ( !imp_t || u3_Host.ops_u.nuu == c3n ) ) { - fprintf(stderr, "-G only makes sense when creating a new galaxy\n"); + if ( u3_Host.ops_u.gen_c != 0 && u3_Host.ops_u.nuu == c3n ) { + fprintf(stderr, "-G only makes sense when bootstrapping a new instance\n"); return c3n; } diff --git a/vere/sist.c b/vere/sist.c index 52a478179..d9ec09b46 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1386,13 +1386,19 @@ u3_sist_boot(void) u3z(whu); } else { - if ( 0 == u3_Host.ops_u.key_c ) { + u3_noun des = u3_none; + + if ( 0 != u3_Host.ops_u.key_c ) { + des = u3m_file(u3_Host.ops_u.key_c); + } + else if ( 0 != u3_Host.ops_u.gen_c ) { + des = u3i_string(u3_Host.ops_u.gen_c); + } + else { // XX print nice error u3_lo_bail(); } - u3_noun des = u3m_file(u3_Host.ops_u.key_c); - u3A->fak = c3n; pig = _sist_dawn(u3k(des)); who = u3k(u3h(u3h(u3t(pig)))); From f939b63ccae3bdf9040944858da4b1c2ccb04d45 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Fri, 12 Oct 2018 13:45:20 -0400 Subject: [PATCH 187/221] simplifies dawn status noun, improves error messages --- include/c/motes.h | 4 ++++ vere/sist.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/c/motes.h b/include/c/motes.h index 6d5dadf76..52722b371 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -354,9 +354,11 @@ # define c3__dxkt c3_s4('d','x','k','t') # define c3__dub c3_s3('d','u','b') # define c3__duct c3_s4('d','u','c','t') +# define c3__duke c3_s4('d','u','k','e') # define c3__dumb c3_s4('d','u','m','b') # define c3__dump c3_s4('d','u','m','p') # define c3__dust c3_s4('d','u','s','t') +# define c3__earl c3_s4('e','a','r','l') # define c3__east c3_s4('e','a','s','t') # define c3__echo c3_s4('e','c','h','o') # define c3__edge c3_s4('e','d','g','e') @@ -586,6 +588,7 @@ # define c3__kern c3_s4('k','e','r','n') # define c3__kgo c3_s3('k','g','o') # define c3__kick c3_s4('k','i','c','k') +# define c3__king c3_s4('k','i','n','g') # define c3__kit c3_s3('k','i','t') # define c3__knit c3_s4('k','n','i','t') # define c3__kno c3_s3('k','n','o') @@ -803,6 +806,7 @@ # define c3__part c3_s4('p','a','r','t') # define c3__pass c3_s4('p','a','s','s') # define c3__past c3_s4('p','a','s','t') +# define c3__pawn c3_s4('p','a','w','n') # define c3__peek c3_s4('p','e','e','k') # define c3__peep c3_s4('p','e','e','p') # define c3__peft c3_s4('p','e','f','t') diff --git a/vere/sist.c b/vere/sist.c index d9ec09b46..65b74e368 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1287,6 +1287,8 @@ _sist_dawn(u3_noun des) c3_c* how_c = u3r_string(u3k(how)); fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", u3_Host.ops_u.who_c, how_c); + + u3z(how); free(how_c); u3_lo_bail(); } @@ -1306,19 +1308,54 @@ _sist_dawn(u3_noun des) // u3_noun liv = _sist_get_json(parent, /some/url) u3_noun liv = u3_nul; - // XX revisit - // (each [seed (unit ship)] [rank @tas]) + // (each sponsor=(unit ship) error=@tas) u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); if ( c3n == u3h(sas) ) { + u3_noun rac = u3do("clan:title", u3k(who)); + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + + c3_c* rac_c; + + switch (rac) { + default: c3_assert(0); + case c3__czar: { + rac_c = "galaxy"; + break; + } + case c3__king: { + rac_c = "star"; + break; + } + case c3__duke: { + rac_c = "planet"; + break; + } + case c3__earl: { + rac_c = "moon"; + break; + } + case c3__pawn: { + rac_c = "comet"; + break; + } + } + + fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); + // XX deconstruct sas, print helpful error messages u3m_p("pre-boot error", u3t(sas)); + + u3z(rac); + u3z(how); + free(how_c); u3_lo_bail(); } // (unit ship): sponsor // produced by +veri:dawn to avoid coupling to +hull structure - pon = u3k(u3t(u3t(sas))); + pon = u3k(u3t(sas)); u3z(oct); u3z(luh); u3z(hul); u3z(liv); u3z(sas); } From 07c04e32a7626b8ece483a1dca46828d553cba8e Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 17 Oct 2018 11:56:37 -0400 Subject: [PATCH 188/221] initialize %ames (and galxy sync) early on first boot --- vere/ames.c | 3 +-- vere/loop.c | 15 ++++----------- vere/sist.c | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/vere/ames.c b/vere/ames.c index 913c85616..72063ecde 100644 --- a/vere/ames.c +++ b/vere/ames.c @@ -529,8 +529,7 @@ u3_ames_ef_turf(u3_noun tuf) u3z(tuf); } - else if ( c3n == u3A->fak ) { - // XX assert? + else if ( (c3n == u3A->fak) && (0 == u3_Host.sam_u.dns_c) ) { uL(fprintf(uH, "ames: turf: no domains\n")); } diff --git a/vere/loop.c b/vere/loop.c index ac830936e..130ee87fa 100644 --- a/vere/loop.c +++ b/vere/loop.c @@ -667,18 +667,11 @@ u3_lo_lead(void) // Further server configuration. // { - u3_ames_ef_bake(); - u3_http_ef_bake(); - - if ( c3y == u3_Host.ops_u.nuu ) { - u3_noun rac = u3do("clan:title", u3k(u3A->own)); - - if ( c3__czar == rac ) { - u3_unix_ef_initial_into(); - } - - u3z(rac); + if ( c3n == u3_Host.ops_u.nuu ) { + u3_ames_ef_bake(); } + + u3_http_ef_bake(); } _lo_talk(); diff --git a/vere/sist.c b/vere/sist.c index 65b74e368..ddbb9954a 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1445,9 +1445,29 @@ u3_sist_boot(void) u3A->own = who; + // initialize ames + { + u3_noun tuf = (c3y == u3A->fak) ? u3_nul : u3t(u3t(u3t(u3t(pig)))); + // with a fake event to bring up listeners and configure domains + u3_ames_ef_turf(u3k(tuf)); + // and real effect to set the output duct + u3_ames_ef_bake(); + } + // Authenticate and initialize terminal. u3_term_ef_bake(pig); + // queue initial galaxy sync + { + u3_noun rac = u3do("clan:title", u3k(u3A->own)); + + if ( c3__czar == rac ) { + u3_unix_ef_initial_into(); + } + + u3z(rac); + } + // Create the ship directory. _sist_zest(); } From 1f42dfc81203522a72bd08133d7bd198d7628e32 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 17 Oct 2018 17:28:46 -0400 Subject: [PATCH 189/221] documents new cli arguments --- vere/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vere/main.c b/vere/main.c index 3b793462d..b4ef880ce 100644 --- a/vere/main.c +++ b/vere/main.c @@ -334,15 +334,17 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-c pier Create a new urbit in pier/\n", "-d Daemon mode\n", "-D Recompute from events\n", + "-e url Ethereum gateway\n", "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", + "-K keys Private key file\n", "-k stage Start at Hoon kernel version stage\n", "-l port Initial peer port\n", "-M Memory madness\n", "-n host Set unix hostname\n", "-N Enable networking in fake mode (-F)\n", - "-p ames_port Set the HTTP port to bind to\n", + "-p ames_port Set the ames port to bind to\n", "-P Profiling\n", "-q Quiet\n", "-r host Initial peer address\n", @@ -350,7 +352,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-s Pill URL from arvo git hash\n", "-u url URL from which to download pill\n", "-v Verbose\n", - "-w name Immediately upgrade to ~name\n", + "-w name Boot as ~name\n", "-x Exit immediately\n", "-Xwtf Skip last event\n", "\n", From cc8c01ea70bf2fb0672628a2db797725799b186a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 17 Oct 2018 18:56:12 -0400 Subject: [PATCH 190/221] adds comet mining (temporarily hardcoded under ~marzod) --- vere/main.c | 5 ++ vere/sist.c | 181 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 124 insertions(+), 62 deletions(-) diff --git a/vere/main.c b/vere/main.c index b4ef880ce..997a2bd72 100644 --- a/vere/main.c +++ b/vere/main.c @@ -193,6 +193,11 @@ _main_getopt(c3_i argc, c3_c** argv) } if ( 0 != u3_Host.ops_u.fak_c ) { + if ( 28 < strlen(u3_Host.ops_u.fak_c) ) { + fprintf(stderr, "fake comets are disallowed\r\n"); + return c3n; + } + u3_Host.ops_u.who_c = strdup(u3_Host.ops_u.fak_c); } diff --git a/vere/sist.c b/vere/sist.c index ddbb9954a..789500c22 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1122,17 +1122,6 @@ _sist_rest() } } -/* _sist_zen(): get OS entropy. -*/ -static u3_noun -_sist_zen() -{ - c3_w rad_w[16]; - - c3_rand(rad_w); - return u3i_words(16, rad_w); -} - /* _sist_curl_alloc(): allocate a response buffer for curl */ static size_t @@ -1246,56 +1235,16 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) /* _sist_dawn(): produce %dawn boot card - validate keys and query contract */ static u3_noun -_sist_dawn(u3_noun des) +_sist_dawn(u3_noun sed) { - u3_noun who, sed, pon, zar, tuf; + u3_noun pon, zar, tuf; + + u3_noun who = u3h(sed); c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); // XX require https? c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; - { - u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); - - if ( u3_nul == eds ) { - c3_c* sed_c = u3r_string(des); - fprintf(stderr, "dawn: invalid private keys: %s\r\n", sed_c); - free(sed_c); - u3_lo_bail(); - } - - if ( 0 == u3_Host.ops_u.who_c ) { - fprintf(stderr, "dawn: -w required\r\n"); - u3_lo_bail(); - } - - u3_noun woh = u3i_string(u3_Host.ops_u.who_c); - u3_noun whu = u3dc("slaw", 'p', u3k(woh)); - - if ( u3_nul == whu ) { - fprintf(stderr, "dawn: invalid ship specificed with -w %s\r\n", - u3_Host.ops_u.who_c); - u3_lo_bail(); - } - - // +seed:able:jael: private key file - sed = u3ke_cue(u3k(u3t(eds))); - who = u3h(sed); - - if ( who != u3t(whu) ) { - u3_noun how = u3dc("scot", 'p', u3k(who)); - c3_c* how_c = u3r_string(u3k(how)); - fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", - u3_Host.ops_u.who_c, how_c); - - u3z(how); - free(how_c); - u3_lo_bail(); - } - - u3z(woh); u3z(whu); u3z(des); u3z(eds); - } - // XX leaks nock { // +hull:constitution:ethe: on-chain state @@ -1386,6 +1335,103 @@ _sist_dawn(u3_noun des) return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); } +/* _sist_zen(): get OS entropy. +*/ +static u3_noun +_sist_zen(void) +{ + c3_w rad_w[16]; + + c3_rand(rad_w); + return u3i_words(16, rad_w); +} + +/* _sist_come(): mine a comet. +*/ +static u3_noun +_sist_come(void) +{ + u3_noun tar, eny, sed; + + // XX choose from list, at random, &c + tar = u3dc("slav", 'p', u3i_string("~marzod")); + eny = _sist_zen(); + + { + u3_noun sar = u3dc("scot", 'p', u3k(tar)); + c3_c* tar_c = u3r_string(sar); + + fprintf(stderr, "boot: mining a comet under %s\r\n", tar_c); + free(tar_c); + u3z(sar); + } + + sed = u3dc("come:dawn", u3k(tar), u3k(eny)); + + { + u3_noun who = u3dc("scot", 'p', u3k(u3h(sed))); + c3_c* who_c = u3r_string(who); + + fprintf(stderr, "boot: found comet %s\r\n", who_c); + free(who_c); + u3z(who); + } + + u3z(tar); u3z(eny); + + return sed; +} + +/* sist_key(): parse a private key-file. +*/ +static u3_noun +sist_key(u3_noun des) +{ + u3_noun sed, who; + + u3_noun eds = u3dc("slaw", c3__uw, u3k(des)); + + if ( u3_nul == eds ) { + c3_c* sed_c = u3r_string(des); + fprintf(stderr, "dawn: invalid private keys: %s\r\n", sed_c); + free(sed_c); + u3_lo_bail(); + } + + if ( 0 == u3_Host.ops_u.who_c ) { + fprintf(stderr, "dawn: -w required\r\n"); + u3_lo_bail(); + } + + u3_noun woh = u3i_string(u3_Host.ops_u.who_c); + u3_noun whu = u3dc("slaw", 'p', u3k(woh)); + + if ( u3_nul == whu ) { + fprintf(stderr, "dawn: invalid ship specificed with -w %s\r\n", + u3_Host.ops_u.who_c); + u3_lo_bail(); + } + + // +seed:able:jael: private key file + sed = u3ke_cue(u3k(u3t(eds))); + who = u3h(sed); + + if ( c3n == u3r_sing(who, u3t(whu)) ) { + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + fprintf(stderr, "dawn: mismatch between -w %s and -K %s\r\n", + u3_Host.ops_u.who_c, how_c); + + u3z(how); + free(how_c); + u3_lo_bail(); + } + + u3z(woh); u3z(whu); u3z(des); u3z(eds); + + return sed; +} + /* u3_sist_boot(): restore or create. */ void @@ -1413,6 +1459,16 @@ u3_sist_boot(void) fprintf(stderr, "fake: invalid ship: %s\r\n", u3_Host.ops_u.fak_c); u3_lo_bail(); } + else { + u3_noun rac = u3do("clan:title", u3k(u3t(whu))); + + if ( c3__pawn == rac ) { + fprintf(stderr, "fake comets are disallowed\r\n"); + u3_lo_bail(); + } + + u3z(rac); + } fprintf(stderr, "fake: %s\r\n", u3_Host.ops_u.fak_c); @@ -1423,24 +1479,25 @@ u3_sist_boot(void) u3z(whu); } else { - u3_noun des = u3_none; + u3_noun sed; if ( 0 != u3_Host.ops_u.key_c ) { - des = u3m_file(u3_Host.ops_u.key_c); + u3_noun des = u3m_file(u3_Host.ops_u.key_c); + sed = sist_key(des); } else if ( 0 != u3_Host.ops_u.gen_c ) { - des = u3i_string(u3_Host.ops_u.gen_c); + u3_noun des = u3i_string(u3_Host.ops_u.gen_c); + sed = sist_key(des); } else { - // XX print nice error - u3_lo_bail(); + sed = _sist_come(); } u3A->fak = c3n; - pig = _sist_dawn(u3k(des)); + pig = _sist_dawn(u3k(sed)); who = u3k(u3h(u3h(u3t(pig)))); - u3z(des); + u3z(sed); } u3A->own = who; From d9cfb8de356512e6bb6abd69b9af5dcced129a0c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 01:26:50 -0400 Subject: [PATCH 191/221] removes extra %init handlers in reck.c --- vere/reck.c | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/vere/reck.c b/vere/reck.c index 3515c3268..28dba1988 100644 --- a/vere/reck.c +++ b/vere/reck.c @@ -100,7 +100,6 @@ _reck_kick_term(u3_noun pox, c3_l tid_l, u3_noun fav) case c3__init: p_fav = u3t(fav); { - uL(fprintf(uH, "kick: init: term\n")); c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); u3z(pox); u3z(fav); return c3y; @@ -196,6 +195,8 @@ _reck_kick_sync(u3_noun pox, u3_noun fav) u3z(pox); u3z(fav); return c3n; } +/* _reck_kick_newt(): apply packet network outputs. +*/ static u3_noun _reck_kick_newt(u3_noun pox, u3_noun fav) { @@ -217,27 +218,6 @@ _reck_kick_newt(u3_noun pox, u3_noun fav) u3z(pox); u3z(fav); return c3n; } -/* _reck_kick_ames(): apply packet network outputs. -*/ -static u3_noun -_reck_kick_ames(u3_noun pox, u3_noun fav) -{ - u3_noun p_fav; - - switch ( u3h(fav) ) { - default: break; - // XX remove - case c3__init: p_fav = u3t(fav); - { - uL(fprintf(uH, "kick: init: ames\n")); - c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); - - u3z(pox); u3z(fav); return c3y; - } break; - } - u3z(pox); u3z(fav); return c3n; -} - /* _reck_kick_spec(): apply an effect, by path. */ static u3_noun @@ -307,24 +287,6 @@ _reck_kick_spec(u3_noun pox, u3_noun fav) return _reck_kick_newt(pox, fav); } break; - case c3__ames: { - if ( (u3_nul != tt_pox) ) { - u3z(pox); u3z(fav); return c3n; - } - else { - return _reck_kick_ames(pox, fav); - } - } break; - - // XX remove - case c3__init: p_fav = u3t(fav); - { - uL(fprintf(uH, "kick: init: spec\n")); - c3_assert( c3y == u3r_sing(u3A->own, p_fav) ); - - u3z(pox); u3z(fav); return c3y; - } break; - case c3__term: { u3_noun pud = tt_pox; u3_noun p_pud, q_pud; From 37f551d65fc7df662ce985ba992f907cdf8de353 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 14:47:15 -0400 Subject: [PATCH 192/221] adds pre-boot validation status printfs --- vere/sist.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index 789500c22..fb55e0788 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1247,6 +1247,10 @@ _sist_dawn(u3_noun sed) // XX leaks nock { + fprintf(stderr, "boot: retrieving %s's public keys\r\n", + u3_Host.ops_u.who_c); + + // XX check parent if moon // +hull:constitution:ethe: on-chain state u3_noun oct = u3do("hull:give:dawn", u3k(who)); u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); @@ -1257,6 +1261,8 @@ _sist_dawn(u3_noun sed) // u3_noun liv = _sist_get_json(parent, /some/url) u3_noun liv = u3_nul; + fprintf(stderr, "boot: verifying keys\r\n"); + // (each sponsor=(unit ship) error=@tas) u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); @@ -1311,6 +1317,8 @@ _sist_dawn(u3_noun sed) // XX leaks nock { + fprintf(stderr, "boot: retrieving galaxy table\r\n"); + // (map ship [=life =pass]): galaxy table u3_noun oct = u3v_wish("czar:give:dawn"); u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); @@ -1321,6 +1329,8 @@ _sist_dawn(u3_noun sed) // XX leaks nock { + fprintf(stderr, "boot: retrieving network domains\r\n"); + // (list turf): ames domains u3_noun oct = u3v_wish("turf:give:dawn"); u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); From 562c9b310a2b014331864d5135f19e053a50ae44 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 15:13:14 -0400 Subject: [PATCH 193/221] factors out pre-boot verification failure --- vere/sist.c | 88 +++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index fb55e0788..2e6208db2 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1232,6 +1232,50 @@ _sist_eth_rpc(c3_c* url_c, u3_noun oct) return _sist_buf_to_oct(_sist_post_json(url_c, _sist_oct_to_buf(oct))); } +/* _sist_dawn_fail(): pre-boot validation failed +*/ +static void +_sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) +{ + u3_noun how = u3dc("scot", 'p', u3k(who)); + c3_c* how_c = u3r_string(u3k(how)); + + c3_c* rac_c; + + switch (rac) { + default: c3_assert(0); + case c3__czar: { + rac_c = "galaxy"; + break; + } + case c3__king: { + rac_c = "star"; + break; + } + case c3__duke: { + rac_c = "planet"; + break; + } + case c3__earl: { + rac_c = "moon"; + break; + } + case c3__pawn: { + rac_c = "comet"; + break; + } + } + + fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); + + // XX deconstruct sas, print helpful error messages + u3m_p("pre-boot error", u3t(sas)); + + u3z(how); + free(how_c); + u3_lo_bail(); +} + /* _sist_dawn(): produce %dawn boot card - validate keys and query contract */ static u3_noun @@ -1240,6 +1284,7 @@ _sist_dawn(u3_noun sed) u3_noun pon, zar, tuf; u3_noun who = u3h(sed); + u3_noun rac = u3do("clan:title", u3k(who)); c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); // XX require https? @@ -1267,45 +1312,9 @@ _sist_dawn(u3_noun sed) u3_noun sas = u3dt("veri:dawn", u3k(sed), u3k(hul), u3k(liv)); if ( c3n == u3h(sas) ) { - u3_noun rac = u3do("clan:title", u3k(who)); - u3_noun how = u3dc("scot", 'p', u3k(who)); - c3_c* how_c = u3r_string(u3k(how)); - - c3_c* rac_c; - - switch (rac) { - default: c3_assert(0); - case c3__czar: { - rac_c = "galaxy"; - break; - } - case c3__king: { - rac_c = "star"; - break; - } - case c3__duke: { - rac_c = "planet"; - break; - } - case c3__earl: { - rac_c = "moon"; - break; - } - case c3__pawn: { - rac_c = "comet"; - break; - } - } - - fprintf(stderr, "dawn: invalid keys for %s '%s'\r\n", rac_c, how_c); - - // XX deconstruct sas, print helpful error messages - u3m_p("pre-boot error", u3t(sas)); - - u3z(rac); - u3z(how); - free(how_c); - u3_lo_bail(); + // bails, won't return + _sist_dawn_fail(who, rac, sas); + return u3_none; } // (unit ship): sponsor @@ -1339,6 +1348,7 @@ _sist_dawn(u3_noun sed) u3z(oct); u3z(fut); } + u3z(rac); // XX include ops_u.eth_c if set // [%dawn seed sponsor galaxies domains] From 61c1ece9267a62e42a2d33bcfcb80420418fe063 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 18 Oct 2018 15:24:04 -0400 Subject: [PATCH 194/221] corrects public-key retrieval for (parent of) moons --- vere/sist.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index 2e6208db2..715a12586 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1292,14 +1292,42 @@ _sist_dawn(u3_noun sed) // XX leaks nock { - fprintf(stderr, "boot: retrieving %s's public keys\r\n", - u3_Host.ops_u.who_c); - // XX check parent if moon // +hull:constitution:ethe: on-chain state - u3_noun oct = u3do("hull:give:dawn", u3k(who)); - u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); - u3_noun hul = u3dc("hull:take:dawn", u3k(who), u3k(luh)); + u3_noun hul; + + { + if ( c3__pawn == rac ) { + // irrelevant, just bunt +hull + hul = u3v_wish("*hull:constitution:ethe"); + } + else { + u3_noun oct; + + if ( c3__earl == rac ) { + u3_noun seg = u3do("^sein:title", u3k(who)); + u3_noun ges = u3dc("scot", 'p', u3k(seg)); + c3_c* seg_c = u3r_string(ges); + + fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", + seg_c, u3_Host.ops_u.who_c); + oct = u3do("hull:give:dawn", u3k(seg)); + + free(seg_c); + u3z(seg); u3z(ges); + } + else { + fprintf(stderr, "boot: retrieving %s's public keys\r\n", + u3_Host.ops_u.who_c); + oct = u3do("hull:give:dawn", u3k(who)); + } + + u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); + hul = u3dc("hull:take:dawn", u3k(who), u3k(luh)); + + u3z(oct); u3z(luh); + } + } // +live:dawn: network state // XX actually make request @@ -1321,7 +1349,7 @@ _sist_dawn(u3_noun sed) // produced by +veri:dawn to avoid coupling to +hull structure pon = u3k(u3t(sas)); - u3z(oct); u3z(luh); u3z(hul); u3z(liv); u3z(sas); + u3z(hul); u3z(liv); u3z(sas); } // XX leaks nock From 999e82a44a936666248df56413d1e70971cd0342 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 24 Oct 2018 10:38:09 -0700 Subject: [PATCH 195/221] actually send headers --- vere/sist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vere/sist.c b/vere/sist.c index 715a12586..5379c9597 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1168,6 +1168,7 @@ _sist_post_json(c3_c* url_c, uv_buf_t lod_u) curl_easy_setopt(curl, CURLOPT_URL, url_c); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _sist_curl_alloc); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf_u); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, hed_u); // note: must be terminated! curl_easy_setopt(curl, CURLOPT_POSTFIELDS, lod_u.base); @@ -1187,6 +1188,7 @@ _sist_post_json(c3_c* url_c, uv_buf_t lod_u) } curl_easy_cleanup(curl); + curl_slist_free_all(hed_u); return buf_u; } From a8fbd498649bbdb77695dde0ccf9e7788e7cd5ca Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Thu, 25 Oct 2018 17:34:49 -0700 Subject: [PATCH 196/221] converting iron and zinc cores to lead bug In the current release candidate, this happens: ``` > ^?(^|(add)) wrap-gold ford: %slim failed: ford: %ride failed to compute type: ``` This is a jet mismatch from `+wrap`, I believe: https://github.com/urbit/arvo/blob/release-candidate/sys/hoon.hoon#L11139 You should be able to convert iron and zinc cores to lead. --- jets/f/ut_wrap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jets/f/ut_wrap.c b/jets/f/ut_wrap.c index 9ef5c85f8..e51d3843f 100644 --- a/jets/f/ut_wrap.c +++ b/jets/f/ut_wrap.c @@ -41,8 +41,9 @@ if ( c3n == u3r_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut) ) { return u3m_bail(c3__fail); } - else if ( c3__gold != rpq_sut ) { - return u3m_error("wrap-gold"); + else if ( (c3__gold != rpq_sut) && + (c3__lead != yoz) ) { + return u3m_error("wrap-metal"); } else { return u3nt(c3__core, From c198b4ff0c2738054949e3946ce90abfc2b1b0f9 Mon Sep 17 00:00:00 2001 From: Benjamin Summers Date: Fri, 26 Oct 2018 14:51:05 -0700 Subject: [PATCH 197/221] Disabled core hashing on fake ships. --- vere/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vere/main.c b/vere/main.c index 74901d790..9bea0be8c 100644 --- a/vere/main.c +++ b/vere/main.c @@ -197,10 +197,16 @@ _main_getopt(c3_i argc, c3_c** argv) if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3y ) { fprintf(stderr, "-N only makes sense with -F\n"); return c3n; - } else if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3n ) { + } + + if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3n ) { u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } + if ( u3_Host.ops_u.fak == c3y ) { + u3_Host.ops_u.has = c3y; /* no battery hashing on fake ships. */ + } + if ( u3_Host.ops_u.arv_c != 0 && ( u3_Host.ops_u.imp_c == 0 || u3_Host.ops_u.nuu == c3n ) ) { fprintf(stderr, "-A only makes sense when creating a new galaxy\n"); @@ -348,6 +354,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-r host Initial peer address\n", "-R Report urbit build info\n", "-s Pill URL from arvo git hash\n", + "-S Disable battery hashing\n", "-t ticket Use ~ticket automatically\n", "-u url URL from which to download pill\n", "-v Verbose\n", From b88a2b5062decc617bdda630b29bd23dfacce477 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 20:53:02 -0400 Subject: [PATCH 198/221] refactors u3v_wish for clarity --- noun/vortex.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/noun/vortex.c b/noun/vortex.c index eafb3e735..faec49d42 100644 --- a/noun/vortex.c +++ b/noun/vortex.c @@ -89,33 +89,22 @@ u3v_start(u3_noun now) u3_noun u3v_wish(const c3_c* str_c) { - u3_noun exp; + u3_noun txt = u3i_string(str_c); + u3_weak exp = u3kdb_get(u3k(u3A->yot), u3k(txt)); - if ( u3R == &u3H->rod_u ) { - u3_noun txt = u3i_string(str_c); - - exp = u3kdb_get(u3k(u3A->yot), u3k(txt)); + if ( u3_none == exp ) { + exp = _cv_nock_wish(u3k(txt)); - if ( u3_none == exp ) { - exp = _cv_nock_wish(u3k(txt)); + // It's probably not a good idea to use u3v_wish() + // outside the top level... (as the result is uncached) + // + if ( u3R == &u3H->rod_u ) { u3A->yot = u3kdb_put(u3A->yot, u3k(txt), u3k(exp)); } - u3z(txt); - return exp; - } - else { - // It's probably not a good idea to use u3v_wish() - // outside the top level... - // - u3_noun txt = u3i_string(str_c); - u3_noun exp = u3kdb_get(u3A->yot, u3k(txt)); - - if ( u3_none != exp ) { - u3z(txt); - return exp; - } - else return _cv_nock_wish(u3i_string(str_c)); } + + u3z(txt); + return exp; } /* _cv_mung(): formula wrapper with gate and sample. From b7fbd4108ebd38ad3bbecc761d281016154e73d3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 20:50:05 -0400 Subject: [PATCH 199/221] fixes memory leak (temporarily) by disabling +xeb jet --- jets/tree.c | 8 +++++--- vere/sist.c | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jets/tree.c b/jets/tree.c index 8a749fb95..9804473fb 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -788,8 +788,9 @@ static u3j_harm _141_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static c3_c* _141_two_sqt_ha[] = {0}; static u3j_harm _141_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _141_two_vor_ha[] = {0}; -static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; -static c3_c* _141_two_xeb_ha[] = {0}; +// disabled, leaks +// static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; +// static c3_c* _141_two_xeb_ha[] = {0}; static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _141_two__in_bif_ha[] = {0}; @@ -928,7 +929,8 @@ static u3j_core _141_two_d[] = { "pow", 7, _141_two_pow_a, 0, _141_two_pow_ha }, { "sqt", 7, _141_two_sqt_a, 0, _141_two_sqt_ha }, { "vor", 7, _141_two_vor_a, 0, _141_two_vor_ha }, - { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, + // disabled, leaks + // { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, { "by", 7, 0, _141_two__by_d, _141_two__by_ha }, { "in", 7, 0, _141_two__in_d, _141_two__in_ha }, diff --git a/vere/sist.c b/vere/sist.c index 5379c9597..f38b9ace2 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1292,7 +1292,6 @@ _sist_dawn(u3_noun sed) // XX require https? c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; - // XX leaks nock { // XX check parent if moon // +hull:constitution:ethe: on-chain state @@ -1354,7 +1353,6 @@ _sist_dawn(u3_noun sed) u3z(hul); u3z(liv); u3z(sas); } - // XX leaks nock { fprintf(stderr, "boot: retrieving galaxy table\r\n"); @@ -1366,7 +1364,6 @@ _sist_dawn(u3_noun sed) u3z(oct); u3z(raz); } - // XX leaks nock { fprintf(stderr, "boot: retrieving network domains\r\n"); From f8bf9679124799ee80e03a0d18113f2a721e7390 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 21:15:07 -0400 Subject: [PATCH 200/221] rewrites/re-enables +xeb jet --- jets/c/xeb.c | 18 ++++-------------- jets/tree.c | 8 +++----- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/jets/c/xeb.c b/jets/c/xeb.c index 04e6bab2d..f0a191fcb 100644 --- a/jets/c/xeb.c +++ b/jets/c/xeb.c @@ -9,22 +9,12 @@ u3_noun u3qc_xeb(u3_atom a) { - mpz_t a_mp; + c3_w met_w = u3r_met(0, a); - if ( __(u3a_is_dog(a)) ) { - u3r_mp(a_mp, a); - c3_d x = mpz_sizeinbase(a_mp, 2); - mpz_t b_mp; - mpz_init_set_ui(b_mp, x); - return u3i_mp(b_mp); - } - else { - mpz_init_set_ui(a_mp, a); - c3_d x = mpz_sizeinbase(a_mp, 2); - mpz_t b_mp; - mpz_init_set_ui(b_mp, x); - return u3i_mp(b_mp); + if ( !_(u3a_is_cat(met_w)) ) { + return u3i_words(1, &met_w); } + else return met_w; } u3_noun u3wc_xeb(u3_noun cor) diff --git a/jets/tree.c b/jets/tree.c index 9804473fb..8a749fb95 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -788,9 +788,8 @@ static u3j_harm _141_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}}; static c3_c* _141_two_sqt_ha[] = {0}; static u3j_harm _141_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}}; static c3_c* _141_two_vor_ha[] = {0}; -// disabled, leaks -// static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; -// static c3_c* _141_two_xeb_ha[] = {0}; +static u3j_harm _141_two_xeb_a[] = {{".2", u3wc_xeb, c3y}, {}}; +static c3_c* _141_two_xeb_ha[] = {0}; static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}}; static c3_c* _141_two__in_bif_ha[] = {0}; @@ -929,8 +928,7 @@ static u3j_core _141_two_d[] = { "pow", 7, _141_two_pow_a, 0, _141_two_pow_ha }, { "sqt", 7, _141_two_sqt_a, 0, _141_two_sqt_ha }, { "vor", 7, _141_two_vor_a, 0, _141_two_vor_ha }, - // disabled, leaks - // { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, + { "xeb", 7, _141_two_xeb_a, 0, _141_two_xeb_ha }, { "by", 7, 0, _141_two__by_d, _141_two__by_ha }, { "in", 7, 0, _141_two__in_d, _141_two__in_ha }, From 05b4c7726b9b230a30acfad69a31ad0d3316c2fa Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 21:26:42 -0400 Subject: [PATCH 201/221] updates +met jet to always measure only once --- jets/c/met.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/c/met.c b/jets/c/met.c index ee9912602..aff53da18 100644 --- a/jets/c/met.c +++ b/jets/c/met.c @@ -22,7 +22,7 @@ if ( !_(u3a_is_cat(met_w)) ) { return u3i_words(1, &met_w); } - else return u3r_met(a, b); + else return met_w; } } u3_noun From b9668c77f907cc8e544d86523c3d15614bbedf13 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Sun, 28 Oct 2018 21:29:50 -0400 Subject: [PATCH 202/221] corrects boot comments --- vere/sist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index f38b9ace2..a41f779fe 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1293,7 +1293,6 @@ _sist_dawn(u3_noun sed) c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; { - // XX check parent if moon // +hull:constitution:ethe: on-chain state u3_noun hul; @@ -1572,7 +1571,7 @@ u3_sist_boot(void) u3z(rac); } - // Create the ship directory. + // Create the event log _sist_zest(); } } From 68a2963051bfed5f7a0ca086f7898ef44ace8092 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 11:48:05 -0400 Subject: [PATCH 203/221] swaps -K (now kernel stage) and -k (now key-file) --- vere/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vere/main.c b/vere/main.c index 997a2bd72..0af68e5c9 100644 --- a/vere/main.c +++ b/vere/main.c @@ -141,15 +141,15 @@ _main_getopt(c3_i argc, c3_c** argv) break; } case 'K': { - u3_Host.ops_u.key_c = strdup(optarg); - break; - } - case 'k': { if ( c3n == _main_readw(optarg, 256, &u3_Host.ops_u.kno_w) ) { return c3n; } break; } + case 'k': { + u3_Host.ops_u.key_c = strdup(optarg); + break; + } case 'l': { if ( c3n == _main_readw(optarg, 65536, &arg_w) ) { return c3n; @@ -248,7 +248,7 @@ _main_getopt(c3_i argc, c3_c** argv) } if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.key_c != 0) { - fprintf(stderr, "-K only makes sense when bootstrapping a new instance\n"); + fprintf(stderr, "-k only makes sense when bootstrapping a new instance\n"); return c3n; } @@ -343,8 +343,8 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-F ship Fake keys; also disables networking\n", "-f Fuzz testing\n", "-g Set GC flag\n", - "-K keys Private key file\n", - "-k stage Start at Hoon kernel version stage\n", + "-K stage Start at Hoon kernel version stage\n", + "-k keys Private key file\n", "-l port Initial peer port\n", "-M Memory madness\n", "-n host Set unix hostname\n", From 9ebeaeb3dc86f3abf7101e20b099c38892806c5c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 11:52:19 -0400 Subject: [PATCH 204/221] requires ethereum gateway (with -e) for non-fake galaxy boot --- vere/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vere/main.c b/vere/main.c index 0af68e5c9..a50c026c5 100644 --- a/vere/main.c +++ b/vere/main.c @@ -221,6 +221,12 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } + if ( (0 == u3_Host.ops_u.fak_c) && (0 == u3_Host.ops_u.eth_c) && imp_t ) { + fprintf(stderr, "can't create a new galaxy without specifying " + "the Ethereum gateway with -e\n"); + return c3n; + } + if ( u3_Host.ops_u.arv_c == 0 && imp_t ) { fprintf(stderr, "can't create a new galaxy without specifying " "the initial sync path with -A\n"); From 770207e18637fdccdaca4e8408d9c1f87eec0b01 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 14:01:45 -0400 Subject: [PATCH 205/221] pins pre-boot validation eth rpc requests to a single block --- vere/sist.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index a41f779fe..dd288b2bb 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1283,14 +1283,26 @@ _sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) static u3_noun _sist_dawn(u3_noun sed) { - u3_noun pon, zar, tuf; + u3_noun bok, pon, zar, tuf; u3_noun who = u3h(sed); u3_noun rac = u3do("clan:title", u3k(who)); - c3_t eth_t = ( 0 != u3_Host.ops_u.eth_c ); // XX require https? - c3_c* url_c = eth_t ? u3_Host.ops_u.eth_c : "http://localhost:8545"; + c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? + u3_Host.ops_u.eth_c : + "http://localhost:8545"; + + { + fprintf(stderr, "boot: retrieving latest block\r\n"); + + // @ud: block number + u3_noun oct = u3v_wish("bloq:give:dawn"); + u3_noun kob = _sist_eth_rpc(url_c, u3k(oct)); + bok = u3do("bloq:take:dawn", u3k(kob)); + + u3z(oct); u3z(kob); + } { // +hull:constitution:ethe: on-chain state @@ -1311,7 +1323,7 @@ _sist_dawn(u3_noun sed) fprintf(stderr, "boot: retrieving %s's public keys (for %s)\r\n", seg_c, u3_Host.ops_u.who_c); - oct = u3do("hull:give:dawn", u3k(seg)); + oct = u3dc("hull:give:dawn", u3k(bok), u3k(seg)); free(seg_c); u3z(seg); u3z(ges); @@ -1319,7 +1331,7 @@ _sist_dawn(u3_noun sed) else { fprintf(stderr, "boot: retrieving %s's public keys\r\n", u3_Host.ops_u.who_c); - oct = u3do("hull:give:dawn", u3k(who)); + oct = u3dc("hull:give:dawn", u3k(bok), u3k(who)); } u3_noun luh = _sist_eth_rpc(url_c, u3k(oct)); @@ -1356,7 +1368,7 @@ _sist_dawn(u3_noun sed) fprintf(stderr, "boot: retrieving galaxy table\r\n"); // (map ship [=life =pass]): galaxy table - u3_noun oct = u3v_wish("czar:give:dawn"); + u3_noun oct = u3do("czar:give:dawn", u3k(bok)); u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); zar = u3do("czar:take:dawn", u3k(raz)); @@ -1367,7 +1379,7 @@ _sist_dawn(u3_noun sed) fprintf(stderr, "boot: retrieving network domains\r\n"); // (list turf): ames domains - u3_noun oct = u3v_wish("turf:give:dawn"); + u3_noun oct = u3do("turf:give:dawn", u3k(bok)); u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); tuf = u3do("turf:take:dawn", u3k(fut)); @@ -1375,7 +1387,9 @@ _sist_dawn(u3_noun sed) } u3z(rac); - // XX include ops_u.eth_c if set + + // XX include bok (and parsed eth url) + u3z(bok); // [%dawn seed sponsor galaxies domains] return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); From f0efa1ac1211c686cf2da73df0e86b06f91b98df Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 14:58:07 -0400 Subject: [PATCH 206/221] includes block number and ethereum gateway url in boot event --- vere/sist.c | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/vere/sist.c b/vere/sist.c index dd288b2bb..8dff23d63 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1283,7 +1283,7 @@ _sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) static u3_noun _sist_dawn(u3_noun sed) { - u3_noun bok, pon, zar, tuf; + u3_noun url, bok, pon, zar, tuf; u3_noun who = u3h(sed); u3_noun rac = u3do("clan:title", u3k(who)); @@ -1293,6 +1293,43 @@ _sist_dawn(u3_noun sed) u3_Host.ops_u.eth_c : "http://localhost:8545"; + // ethereum gateway as (unit purl) + if ( 0 == u3_Host.ops_u.eth_c ) { + if ( c3__czar == rac ) { + fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + + url = u3_nul; + } + else { + u3_noun par = u3v_wish("auru:de-purl:html"); + u3_noun lur = u3i_string(u3_Host.ops_u.eth_c); + u3_noun rul = u3dc("rush", u3k(lur), u3k(par)); + + if ( u3_nul == rul ) { + if ( c3__czar == rac ) { + fprintf(stderr, "boot: galaxy requires ethereum gateway via -e\r\n"); + // bails, won't return + u3_lo_bail(); + return u3_none; + } + + url = u3_nul; + } + else { + // auru:de-purl:html parses to (pair user purl) + // we need (unit purl) + // (we're using it to avoid the +hoke weirdness) + // XX revisit upon merging with release-candidate + url = u3nc(u3_nul, u3k(u3t(u3t(rul)))); + } + + u3z(par); u3z(lur); u3z(rul); + } + { fprintf(stderr, "boot: retrieving latest block\r\n"); @@ -1388,11 +1425,8 @@ _sist_dawn(u3_noun sed) u3z(rac); - // XX include bok (and parsed eth url) - u3z(bok); - - // [%dawn seed sponsor galaxies domains] - return u3nc(c3__dawn, u3nq(sed, pon, zar, tuf)); + // [%dawn seed sponsor galaxies domains block eth-url] + return u3nc(c3__dawn, u3nq(sed, pon, zar, u3nt(tuf, bok, url))); } /* _sist_zen(): get OS entropy. @@ -1564,7 +1598,7 @@ u3_sist_boot(void) // initialize ames { - u3_noun tuf = (c3y == u3A->fak) ? u3_nul : u3t(u3t(u3t(u3t(pig)))); + u3_noun tuf = (c3y == u3A->fak) ? u3_nul : u3h(u3t(u3t(u3t(u3t(pig))))); // with a fake event to bring up listeners and configure domains u3_ames_ef_turf(u3k(tuf)); // and real effect to set the output duct From d6b9d6088c290a31a8e44c605c7dfcfafd368fcb Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 29 Oct 2018 21:52:46 -0400 Subject: [PATCH 207/221] sets default pre-boot validation ethereum gateway to ropsten infura --- vere/sist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/sist.c b/vere/sist.c index 8dff23d63..291ad8796 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1291,7 +1291,7 @@ _sist_dawn(u3_noun sed) // XX require https? c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? u3_Host.ops_u.eth_c : - "http://localhost:8545"; + "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; // ethereum gateway as (unit purl) if ( 0 == u3_Host.ops_u.eth_c ) { From 0a7d338553cfb88d72efed69a517640d8c33bd86 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 31 Oct 2018 14:02:17 -0500 Subject: [PATCH 208/221] Bug fix for metal-wrapping runes A bug causes this cast to go through: ``` ^+(|=(@ 15) ^&(|=(@ 15))) ``` It should nest-fail. This change makes the cast work correctly with the metal wrapping runes `^&`, `^|`, and `^?`. --- jets/f/ut_mint.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 117c9c0d1..54ff5c466 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -533,7 +533,8 @@ { u3_noun ryd = _mint_in(van, sut, gol, p_gen); u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__iron); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); + u3_noun tyn = _mint_nice(van, gol, tyf); + u3_noun pro = u3nc(tyn, u3k(u3t(ryd))); u3z(ryd); return pro; @@ -545,7 +546,8 @@ { u3_noun ryd = _mint_in(van, sut, gol, p_gen); u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__zinc); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); + u3_noun tyn = _mint_nice(van, gol, tyf); + u3_noun pro = u3nc(tyn, u3k(u3t(ryd))); u3z(ryd); return pro; @@ -556,7 +558,8 @@ { u3_noun ryd = _mint_in(van, sut, gol, p_gen); u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__lead); - u3_noun pro = u3nc(tyf, u3k(u3t(ryd))); + u3_noun tyn = _mint_nice(van, gol, tyf); + u3_noun pro = u3nc(tyn, u3k(u3t(ryd))); u3z(ryd); return pro; From aadd95bf983e5a3d79851829d04891f2be016254 Mon Sep 17 00:00:00 2001 From: Joshua Reagan Date: Wed, 31 Oct 2018 16:40:37 -0500 Subject: [PATCH 209/221] zinc gate casting bug Casting with a `^&` rune example fails because of a minor jet typo: ``` > ^+(^&(|=(@ 15)) |=(@ 15)) -gene.[%ktpd %brts [%base %atom 0] %sand %ud 15] play-open-z ford: %slim failed: ford: %ride failed to compute type: ``` The above cast should go through. This fix makes that happen. --- jets/f/ut_play.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jets/f/ut_play.c b/jets/f/ut_play.c index 8f982c28b..9a300edf4 100644 --- a/jets/f/ut_play.c +++ b/jets/f/ut_play.c @@ -358,7 +358,7 @@ return pro; } - case c3__ktpm: p_gen = u3t(gen); + case c3__ktpd: p_gen = u3t(gen); _play_used(); { u3_noun boc = _play_x(van, sut, p_gen); From 345459e931464abb84dc0be1afeb801bc5b21764 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Wed, 31 Oct 2018 15:19:42 -0700 Subject: [PATCH 210/221] allow booting from ethereum snapshot --- include/vere/vere.h | 2 ++ vere/main.c | 14 +++++++- vere/sist.c | 80 ++++++++++++++++++++++++++++++--------------- 3 files changed, 68 insertions(+), 28 deletions(-) diff --git a/include/vere/vere.h b/include/vere/vere.h index 57a3b346b..dc5912dce 100644 --- a/include/vere/vere.h +++ b/include/vere/vere.h @@ -592,6 +592,8 @@ c3_o dem; // -d, daemon c3_o dry; // -D, dry compute c3_c* eth_c; // -e, ethereum node url + c3_o etn; // -t, use snapshot exclusively to boot + c3_c* ets_c; // -E, eth snapshot c3_c* fak_c; // -F, fake ship c3_o fog; // -X, skip last event c3_o gab; // -g, run with garbage collector diff --git a/vere/main.c b/vere/main.c index a50c026c5..75dc2c908 100644 --- a/vere/main.c +++ b/vere/main.c @@ -77,6 +77,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.bat = c3n; u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; + u3_Host.ops_u.etn = c3n; u3_Host.ops_u.fog = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -91,7 +92,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.veb = c3n; u3_Host.ops_u.kno_w = DefaultKernel; - while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:e:f:F:k:l:n:p:r:NabcdgqsvxMPDXRS")) != -1 ) { + while ( (ch_i=getopt(argc, argv,"G:B:K:A:w:u:e:E:f:F:k:l:n:p:r:NabcdgqstvxMPDXRS")) != -1 ) { switch ( ch_i ) { case 'M': { u3_Host.ops_u.mem = c3y; @@ -113,6 +114,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.eth_c = strdup(optarg); break; } + case 'E': { + u3_Host.ops_u.ets_c = strdup(optarg); + break; + } case 'F': { u3_Host.ops_u.fak_c = _main_presig(optarg); break; @@ -186,6 +191,7 @@ _main_getopt(c3_i argc, c3_c** argv) case 'v': { u3_Host.ops_u.veb = c3y; break; } case 's': { u3_Host.ops_u.git = c3y; break; } case 'S': { u3_Host.ops_u.has = c3y; break; } + case 't': { u3_Host.ops_u.etn = c3y; break; } case '?': default: { return c3n; } @@ -221,6 +227,12 @@ _main_getopt(c3_i argc, c3_c** argv) return c3n; } + if ( u3_Host.ops_u.ets_c == 0 && c3y == u3_Host.ops_u.etn ) { + fprintf(stderr, "can't trust Ethereum snapshot without specifying " + "snapshot with -E\n"); + return c3n; + } + if ( (0 == u3_Host.ops_u.fak_c) && (0 == u3_Host.ops_u.eth_c) && imp_t ) { fprintf(stderr, "can't create a new galaxy without specifying " "the Ethereum gateway with -e\n"); diff --git a/vere/sist.c b/vere/sist.c index 291ad8796..c260b783d 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1283,15 +1283,20 @@ _sist_dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) static u3_noun _sist_dawn(u3_noun sed) { - u3_noun url, bok, pon, zar, tuf; + u3_noun url, bok, pon, zar, tuf, sap; u3_noun who = u3h(sed); u3_noun rac = u3do("clan:title", u3k(who)); - // XX require https? - c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? - u3_Host.ops_u.eth_c : - "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; + // load snapshot if exists + if ( 0 != u3_Host.ops_u.ets_c ) { + fprintf(stderr, "boot: loading ethereum snapshot\r\n"); + u3_noun raw_snap = u3ke_cue(u3m_file(u3_Host.ops_u.ets_c)); + sap = u3nc(u3_nul, raw_snap); + } + else { + sap = u3_nul; + } // ethereum gateway as (unit purl) if ( 0 == u3_Host.ops_u.eth_c ) { @@ -1330,22 +1335,35 @@ _sist_dawn(u3_noun sed) u3z(par); u3z(lur); u3z(rul); } + // XX require https? + c3_c* url_c = ( 0 != u3_Host.ops_u.eth_c ) ? + u3_Host.ops_u.eth_c : + "https://ropsten.infura.io/v3/196a7f37c7d54211b4a07904ec73ad87"; + { fprintf(stderr, "boot: retrieving latest block\r\n"); - // @ud: block number - u3_noun oct = u3v_wish("bloq:give:dawn"); - u3_noun kob = _sist_eth_rpc(url_c, u3k(oct)); - bok = u3do("bloq:take:dawn", u3k(kob)); + if ( c3y == u3_Host.ops_u.etn ) { + bok = u3do("bloq:snap:dawn", u3k(u3t(sap))); + } + else { + // @ud: block number + u3_noun oct = u3v_wish("bloq:give:dawn"); + u3_noun kob = _sist_eth_rpc(url_c, u3k(oct)); + bok = u3do("bloq:take:dawn", u3k(kob)); - u3z(oct); u3z(kob); + u3z(oct); u3z(kob); + } } { // +hull:constitution:ethe: on-chain state u3_noun hul; - { + if ( c3y == u3_Host.ops_u.etn ) { + hul = u3dc("hull:snap:dawn", u3k(who), u3k(u3t(sap))); + } + else { if ( c3__pawn == rac ) { // irrelevant, just bunt +hull hul = u3v_wish("*hull:constitution:ethe"); @@ -1402,31 +1420,39 @@ _sist_dawn(u3_noun sed) } { - fprintf(stderr, "boot: retrieving galaxy table\r\n"); + if ( c3y == u3_Host.ops_u.etn ) { + zar = u3do("czar:snap:dawn", u3k(u3t(sap))); + tuf = u3do("turf:snap:dawn", u3k(u3t(sap))); + } + else { + { + fprintf(stderr, "boot: retrieving galaxy table\r\n"); - // (map ship [=life =pass]): galaxy table - u3_noun oct = u3do("czar:give:dawn", u3k(bok)); - u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); - zar = u3do("czar:take:dawn", u3k(raz)); + // (map ship [=life =pass]): galaxy table + u3_noun oct = u3do("czar:give:dawn", u3k(bok)); + u3_noun raz = _sist_eth_rpc(url_c, u3k(oct)); + zar = u3do("czar:take:dawn", u3k(raz)); - u3z(oct); u3z(raz); - } + u3z(oct); u3z(raz); + } - { - fprintf(stderr, "boot: retrieving network domains\r\n"); + { + fprintf(stderr, "boot: retrieving network domains\r\n"); - // (list turf): ames domains - u3_noun oct = u3do("turf:give:dawn", u3k(bok)); - u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); - tuf = u3do("turf:take:dawn", u3k(fut)); + // (list turf): ames domains + u3_noun oct = u3do("turf:give:dawn", u3k(bok)); + u3_noun fut = _sist_eth_rpc(url_c, u3k(oct)); + tuf = u3do("turf:take:dawn", u3k(fut)); - u3z(oct); u3z(fut); + u3z(oct); u3z(fut); + } + } } u3z(rac); - // [%dawn seed sponsor galaxies domains block eth-url] - return u3nc(c3__dawn, u3nq(sed, pon, zar, u3nt(tuf, bok, url))); + // [%dawn seed sponsor galaxies domains block eth-url snap] + return u3nc(c3__dawn, u3nq(sed, pon, zar, u3nq(tuf, bok, url, sap))); } /* _sist_zen(): get OS entropy. From 7027f43563b6de0480eab2d489cb97eb96807e3a Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 00:43:09 -0400 Subject: [PATCH 211/221] updates fake-zod examples, removing -I --- CONTRIBUTING.md | 5 ++--- vere/main.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 32be479b1..e821af354 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,12 +24,11 @@ path you specify on the command line with the `-A` option. To start a fake `~zod`, the command is: - $ urbit -c -F -I zod -A [arvo checkout] [pier directory] + $ urbit -c -F zod -A [arvo checkout] [pier directory] To resume one that was already created, just as on the live network, remove `-c` and `-A [arvo checkout]` (but leave the rest of the options -there). `-F` uses the fake network, and `-I` starts an "imperial" -instance - that is, an 8-bit galaxy. +there). `-F` uses the fake network. ## Kernel development diff --git a/vere/main.c b/vere/main.c index 75dc2c908..032a2366d 100644 --- a/vere/main.c +++ b/vere/main.c @@ -381,7 +381,7 @@ u3_ve_usage(c3_i argc, c3_c** argv) "\n", "Development Usage:\n", " To create a development ship, use a fakezod:\n", - " %s -FI zod -A /path/to/arvo/folder -B /path/to/pill -c zod\n", + " %s -F zod -A /path/to/arvo/folder -B /path/to/pill -c zod\n", "\n", " For more information about developing on urbit, see:\n", " https://github.com/urbit/urbit/blob/master/CONTRIBUTING.md\n", From f319cd6c8105e5218ca1e433e7da8fc03c0f8814 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 01:18:50 -0400 Subject: [PATCH 212/221] fixes merge conflict resolution in the previous. mea maxima culpa --- vere/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/main.c b/vere/main.c index d7ff119e0..17017fe7c 100644 --- a/vere/main.c +++ b/vere/main.c @@ -222,7 +222,7 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */ } - if ( u3_Host.ops_u.fak == c3y ) { + if ( 0 != u3_Host.ops_u.fak_c ) { u3_Host.ops_u.has = c3y; /* no battery hashing on fake ships. */ } From aa12e760ba33b53ced161141f5c005d3fc4fe1b9 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 15:04:42 -0400 Subject: [PATCH 213/221] fixes profiling of hinted but unjetted arms --- noun/jets.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 40405b543..810665b56 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1465,7 +1465,7 @@ _cj_burn(u3p(u3n_prog) pog_p, u3_noun cor) ** (no validity checks). */ static u3_weak -_cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u) +_cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u, c3_o lok_o) { u3_weak pro = u3_none; c3_o jet_o = sit_u->jet_o; @@ -1480,7 +1480,9 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u) u3t_on(glu_o); } if ( u3_none == pro ) { - _cj_site_lock(loc, cor, sit_u); + if ( c3y == lok_o ) { + _cj_site_lock(loc, cor, sit_u); + } } } else { @@ -1491,7 +1493,9 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u) u3t_on(glu_o); } if ( u3_none == pro ) { - _cj_site_lock(loc, cor, sit_u); + if ( c3y == lok_o ) { + _cj_site_lock(loc, cor, sit_u); + } pro = _cj_burn(sit_u->pog_p, cor); } if ( c3y == pof_o ) { @@ -1513,9 +1517,7 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) if ( u3_none != sit_u->loc ) { if ( c3y == _cj_fine(cor, sit_u->fin_p) ) { loc = sit_u->loc; - if ( c3y == sit_u->jet_o ) { - pro = _cj_site_kick_hot(loc, cor, sit_u); - } + pro = _cj_site_kick_hot(loc, cor, sit_u, c3y); } } @@ -1537,15 +1539,9 @@ _cj_site_kick(u3_noun cor, u3j_site* sit_u) sit_u->loc = loc; sit_u->fin_p = _cj_cast(cor, loc); sit_u->fon_o = c3y; - if ( c3y == - (sit_u->jet_o = _cj_nail(loc, sit_u->axe, - &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u))) ) - { - pro = _cj_site_kick_hot(loc, cor, sit_u); - } - else { - pro = u3_none; - } + sit_u->jet_o = _cj_nail(loc, sit_u->axe, + &(sit_u->lab), &(sit_u->cop_u), &(sit_u->ham_u)); + pro = _cj_site_kick_hot(loc, cor, sit_u, c3y); if ( u3_none != lod ) { u3z(lod); @@ -1674,8 +1670,8 @@ u3j_gate_slam(u3j_site* sit_u, u3_noun sam) cor = u3nt(u3k(u3h(sit_u->bat)), sam, u3k(u3t(u3t(sit_u->bat)))); - if ( (u3_none != sit_u->loc) && (c3y == sit_u->jet_o) ) { - pro = _cj_site_kick_hot(sit_u->loc, cor, sit_u); + if ( u3_none != sit_u->loc ) { + pro = _cj_site_kick_hot(sit_u->loc, cor, sit_u, c3n); } if ( u3_none == pro ) { pro = _cj_burn(sit_u->pog_p, cor); From 63e16f8d64545e273857c0c52348e0240214964f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 1 Nov 2018 16:16:01 -0400 Subject: [PATCH 214/221] removes no-op conditional in _cj_site_kick_hot() --- noun/jets.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/noun/jets.c b/noun/jets.c index 810665b56..e17cf6006 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -1471,10 +1471,7 @@ _cj_site_kick_hot(u3_noun loc, u3_noun cor, u3j_site* sit_u, c3_o lok_o) c3_o jet_o = sit_u->jet_o; c3_o pof_o = __(u3C.wag_w & u3o_debug_cpu); if ( c3n == pof_o ) { - if ( c3n == jet_o ) { - pro = u3_none; - } - else { + if ( c3y == jet_o ) { u3t_off(glu_o); pro = _cj_kick_z(cor, sit_u->cop_u, sit_u->ham_u, sit_u->axe); u3t_on(glu_o); From 2c30ab9ec7c51dea851f4f1a800200ea5ef5bb85 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 5 Nov 2018 23:14:33 -0500 Subject: [PATCH 215/221] [CI] enable GC and profiling, boot from pill and run tests --- .travis.yml | 20 +- .travis/.gitattributes | 2 + .travis/.gitignore | 1 + .travis/package-lock.json | 753 ++++++++++++++++++++++++++++++++++++ .travis/package.json | 14 + .travis/pin-arvo-commit.txt | 1 + .travis/test.js | 23 ++ 7 files changed, 812 insertions(+), 2 deletions(-) create mode 100644 .travis/.gitattributes create mode 100644 .travis/.gitignore create mode 100644 .travis/package-lock.json create mode 100644 .travis/package.json create mode 100644 .travis/pin-arvo-commit.txt create mode 100644 .travis/test.js diff --git a/.travis.yml b/.travis.yml index 3380299c7..dca4d038d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,15 @@ -language: c -script: meson build && cd ./build && ninja +language: node_js +node_js: +- 4 + +script: + - meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true + - cd ./build + - ninja + - sudo ninja install + - cd ../.travis + - npm install + - npm run test # Uncomment me if this gets annoying # @@ -10,8 +20,14 @@ before_install: - wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip - unzip ninja-linux.zip - sudo mv ninja /usr/bin/ + install: + # pwd: ~/urbit - pip3 install --user -I meson==0.44.1 + - git clone https://github.com/urbit/arvo + - cd ./arvo + - git checkout $(cat ../.travis/pin-arvo-commit.txt) + - cd .. addons: apt: diff --git a/.travis/.gitattributes b/.travis/.gitattributes new file mode 100644 index 000000000..c1611b63d --- /dev/null +++ b/.travis/.gitattributes @@ -0,0 +1,2 @@ +# Don't show in diffs or auto-merge +package-lock.json binary diff --git a/.travis/.gitignore b/.travis/.gitignore new file mode 100644 index 000000000..c2658d7d1 --- /dev/null +++ b/.travis/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.travis/package-lock.json b/.travis/package-lock.json new file mode 100644 index 000000000..1330fa852 --- /dev/null +++ b/.travis/package-lock.json @@ -0,0 +1,753 @@ +{ + "name": "vere-tests", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "array-differ": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", + "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=" + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "requires": { + "array-uniq": "^1.0.1" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=" + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "bluebird": { + "version": "2.11.0", + "resolved": "http://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", + "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "colors": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.2.tgz", + "integrity": "sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ==" + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "core-js": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "requires": { + "globby": "^5.0.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "rimraf": "^2.2.8" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "emitter-mixin": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/emitter-mixin/-/emitter-mixin-0.0.3.tgz", + "integrity": "sha1-WUjLKG8uSO3DslGnz8H3iDOW1lw=" + }, + "errno": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "requires": { + "prr": "~1.0.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "extend": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-1.2.1.tgz", + "integrity": "sha1-oPX9bPyDpf5J72mNYOyKYk3UV2w=" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "requires": { + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", + "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", + "requires": { + "ajv": "^5.3.0", + "har-schema": "^2.0.0" + } + }, + "hoek": { + "version": "4.2.1", + "resolved": "http://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==" + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=" + }, + "is-path-in-cwd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", + "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", + "requires": { + "is-path-inside": "^1.0.0" + } + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "requires": { + "path-is-inside": "^1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isemail": { + "version": "2.2.1", + "resolved": "http://registry.npmjs.org/isemail/-/isemail-2.2.1.tgz", + "integrity": "sha1-A1PT2aYpUQgMJiwqoKQrjqjp4qY=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "items": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/items/-/items-2.1.1.tgz", + "integrity": "sha1-i9FtnIOxlSneWuoyGsqtp4NkoZg=" + }, + "joi": { + "version": "9.2.0", + "resolved": "http://registry.npmjs.org/joi/-/joi-9.2.0.tgz", + "integrity": "sha1-M4WseQGSEwy+Iw6ALsAskhW7/to=", + "requires": { + "hoek": "4.x.x", + "isemail": "2.x.x", + "items": "2.x.x", + "moment": "2.x.x", + "topo": "2.x.x" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "junk": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/junk/-/junk-1.0.3.tgz", + "integrity": "sha1-h75jSIZJy9ym9Tqzm+yczSNH9ZI=" + }, + "maximatch": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/maximatch/-/maximatch-0.1.0.tgz", + "integrity": "sha1-hs2NawTJ8wfAWmuUGZBtA2D7E6I=", + "requires": { + "array-differ": "^1.0.0", + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "minimatch": "^3.0.0" + } + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "requires": { + "mime-db": "~1.37.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "moment": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + }, + "nan": { + "version": "2.3.5", + "resolved": "http://registry.npmjs.org/nan/-/nan-2.3.5.tgz", + "integrity": "sha1-gioNwmYpDOTNOhIoLKPn42Rmigg=" + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "^2.0.0" + } + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "~2.0.3" + } + }, + "promise-streams": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/promise-streams/-/promise-streams-2.1.1.tgz", + "integrity": "sha1-cwnx02mDMOp/rasZIvE5iSKayFo=", + "requires": { + "bluebird": "^2.10.2" + } + }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=" + }, + "psl": { + "version": "1.1.29", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", + "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + }, + "pty.js": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pty.js/-/pty.js-0.3.1.tgz", + "integrity": "sha1-gfW+0zLW5eeraFaI0boDc0ENUbU=", + "requires": { + "extend": "~1.2.1", + "nan": "2.3.5" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "recursive-copy": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/recursive-copy/-/recursive-copy-2.0.9.tgz", + "integrity": "sha512-0AkHV+QtfS/1jW01z3m2t/TRTW56Fpc+xYbsoa/bqn8BCYPwmsaNjlYmUU/dyGg9w8MmGoUWihU5W+s+qjxvBQ==", + "requires": { + "del": "^2.2.0", + "emitter-mixin": "0.0.3", + "errno": "^0.1.2", + "graceful-fs": "^4.1.4", + "junk": "^1.0.1", + "maximatch": "^0.1.0", + "mkdirp": "^0.5.1", + "pify": "^2.3.0", + "promise": "^7.0.1", + "slash": "^1.0.0" + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + } + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "^7.0.5" + } + }, + "rx": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", + "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=" + }, + "split": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "requires": { + "through": "2" + } + }, + "sshpk": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz", + "integrity": "sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA==", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stream-snitch": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/stream-snitch/-/stream-snitch-0.0.3.tgz", + "integrity": "sha1-iXp48TonFPqESqd74VR3qJbYUqk=" + }, + "through": { + "version": "2.3.8", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "topo": { + "version": "2.0.2", + "resolved": "http://registry.npmjs.org/topo/-/topo-2.0.2.tgz", + "integrity": "sha1-zVYVdSU5BXwNwEkaYhw7xvvh0YI=", + "requires": { + "hoek": "4.x.x" + } + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" + }, + "urbit-runner": { + "version": "github:urbit/runner-js#ee2455015dc4ea243d0e0ec623975632c9249c4e", + "from": "github:urbit/runner-js#ee24550", + "requires": { + "colors": "^1.1.2", + "escape-string-regexp": "^1.0.5", + "once": "^1.4.0", + "promise-streams": "^2.1.1", + "pty.js": "^0.3.1", + "recursive-copy": "^2.0.7", + "split": "^1.0.1", + "stream-snitch": "0.0.3", + "wait-on": "^2.0.2" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "wait-on": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-2.1.2.tgz", + "integrity": "sha512-Jm6pzZkbswtcRUXohxY1Ek5MrL16AwHj83drgW2FTQuglHuhZhVMyBLPIYG0rL1wvr5rdC1uzRuU/7Bc+B9Pwg==", + "requires": { + "core-js": "^2.4.1", + "joi": "^9.2.0", + "minimist": "^1.2.0", + "request": "^2.78.0", + "rx": "^4.1.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/.travis/package.json b/.travis/package.json new file mode 100644 index 000000000..a5e7e46f0 --- /dev/null +++ b/.travis/package.json @@ -0,0 +1,14 @@ +{ + "name": "vere-tests", + "version": "1.0.0", + "description": "Test harness for the Urbit runtime", + "scripts": { + "test": "node test.js" + }, + "private": true, + "author": "~fyr", + "license": "MIT", + "dependencies": { + "urbit-runner": "github:urbit/runner-js#ee24550" + } +} diff --git a/.travis/pin-arvo-commit.txt b/.travis/pin-arvo-commit.txt new file mode 100644 index 000000000..0f6ede735 --- /dev/null +++ b/.travis/pin-arvo-commit.txt @@ -0,0 +1 @@ +6deeb7dee9f3d47e4458fac3a0518dcde429ef73 \ No newline at end of file diff --git a/.travis/test.js b/.travis/test.js new file mode 100644 index 000000000..8d7287717 --- /dev/null +++ b/.travis/test.js @@ -0,0 +1,23 @@ +'use strict'; + +var runner = require('urbit-runner') +var Urbit = runner.Urbit; +var ERROR = runner.ERROR; +var actions = runner.actions + +var args = ['-A', '../arvo', '-csgPSF', 'zod', 'zod']; +var urbit = new Urbit(args); + +Promise.resolve(urbit) +.then(actions.safeBoot) +.then(actions.test) +.then(function(){ + return urbit.exit(0); +}) +.catch(function(err){ + return urbit.waitSilent() + .then(function(){ + urbit.warn("Test aborted:", err); + return urbit.exit(1); + }); +}); From a356a8306637dafac194590cf3764aceaae2f6df Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Nov 2018 00:16:26 -0500 Subject: [PATCH 216/221] [CI] print backtrace on bail --- .travis.yml | 8 +++++++- .travis/test.js | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dca4d038d..cc27f8f22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,13 @@ script: - ninja - sudo ninja install - cd ../.travis + - ulimit -c unlimited -S - npm install - - npm run test + # || true so we continue + - npm run -s test || RESULT=$? + - if [[ ${RESULT} -eq 0 ]]; then exit 0; else for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi; + - echo "build failed with status code $RESULT" + - exit $RESULT # Uncomment me if this gets annoying # @@ -47,6 +52,7 @@ addons: - re2c - libcurl4-gnutls-dev - unzip + - gdb # before_deploy: "make deb" # TODO deploy: skip_cleanup: true diff --git a/.travis/test.js b/.travis/test.js index 8d7287717..e957ac7b8 100644 --- a/.travis/test.js +++ b/.travis/test.js @@ -17,7 +17,8 @@ Promise.resolve(urbit) .catch(function(err){ return urbit.waitSilent() .then(function(){ - urbit.warn("Test aborted:", err); - return urbit.exit(1); + urbit.warn("Arvo test aborted:", err); + // we still exit 0, it's not our fault ... + return urbit.exit(0); }); }); From 21233db91ef2f7fc9f5008cce2347b7c144c87a1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Nov 2018 02:27:56 -0500 Subject: [PATCH 217/221] [CI] sends ctrl-z to work around profiling output hang --- .travis/test.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.travis/test.js b/.travis/test.js index e957ac7b8..4afc09417 100644 --- a/.travis/test.js +++ b/.travis/test.js @@ -8,17 +8,28 @@ var actions = runner.actions var args = ['-A', '../arvo', '-csgPSF', 'zod', 'zod']; var urbit = new Urbit(args); +// vere hangs (always?) with run in travis-ci with -P +// so we send ^Z if we hang for ~s30 +function exit() { + setTimeout(function(){ + urbit.pty.write('\x1a'); + urbit.pty.on('exit', function(code, signal){ + process.exit(0); + }) + }, 30 * 1000); + + return urbit.exit(0); +} + Promise.resolve(urbit) .then(actions.safeBoot) .then(actions.test) -.then(function(){ - return urbit.exit(0); -}) +.then(exit) .catch(function(err){ + // we still exit 0, Arvo errors are not our fault ... return urbit.waitSilent() .then(function(){ - urbit.warn("Arvo test aborted:", err); - // we still exit 0, it's not our fault ... - return urbit.exit(0); - }); + return urbit.warn("Arvo test aborted:", err); + }) + .then(exit); }); From db46b2d798f90045652901b5919b2711ba3c3f68 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Nov 2018 11:16:58 -0500 Subject: [PATCH 218/221] make implicit -S persist across fake-keyed restarts --- vere/sist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vere/sist.c b/vere/sist.c index dbb66962f..91891a36c 100644 --- a/vere/sist.c +++ b/vere/sist.c @@ -1583,8 +1583,13 @@ u3_sist_boot(void) fprintf(stderr, "fake: %s\r\n", who_c); free(who_c); - // XX make conditional + // XX review persistent options + + // disable networking u3_Host.ops_u.net = c3n; + // disable battery hashes + u3_Host.ops_u.has = c3y; + u3C.wag_w |= u3o_hashless; } } else { From 07b6cf807b05578d8ae37112631c9afec6fb99ee Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 31 Oct 2018 14:04:29 -0400 Subject: [PATCH 219/221] bumps http client request timeout to 5 minutes --- vere/cttp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vere/cttp.c b/vere/cttp.c index 92b213138..0d131e775 100644 --- a/vere/cttp.c +++ b/vere/cttp.c @@ -934,7 +934,7 @@ _cttp_init_h2o() { h2o_timeout_t* tim_u = c3_malloc(sizeof(*tim_u)); - h2o_timeout_init(u3L, tim_u, 120 * 1000); + h2o_timeout_init(u3L, tim_u, 300 * 1000); h2o_http1client_ctx_t* ctx_u = c3_calloc(sizeof(*ctx_u)); ctx_u->loop = u3L; From ebeb785ef313b683830ef8abfb53049363e036b3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Nov 2018 19:43:13 -0500 Subject: [PATCH 220/221] adds more specific error messages to proxy write callbacks --- vere/http.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/vere/http.c b/vere/http.c index 39ab7ef48..3f3ff83d1 100644 --- a/vere/http.c +++ b/vere/http.c @@ -1823,17 +1823,40 @@ _proxy_conn_new(u3_proxy_type typ_e, void* src_u) return con_u; } +typedef struct _proxy_write_ctx { + u3_pcon* con_u; + uv_stream_t* str_u; + c3_c* buf_c; +} proxy_write_ctx; + /* _proxy_write_cb(): free uv_write_t and linked buffer. */ static void _proxy_write_cb(uv_write_t* wri_u, c3_i sas_i) { if ( 0 != sas_i ) { - uL(fprintf(uH, "proxy: write: %s\n", uv_strerror(sas_i))); + if ( 0 != wri_u->data ) { + proxy_write_ctx* ctx_u = wri_u->data; + + if ( ctx_u->str_u == (uv_stream_t*)ctx_u->con_u->upt_u ) { + uL(fprintf(uH, "proxy: write upstream: %s\n", uv_strerror(sas_i))); + } + else if ( ctx_u->str_u == (uv_stream_t*)&(ctx_u->con_u->don_u) ) { + uL(fprintf(uH, "proxy: write downstream: %s\n", uv_strerror(sas_i))); + } + else { + uL(fprintf(uH, "proxy: write: %s\n", uv_strerror(sas_i))); + } + } + else { + uL(fprintf(uH, "proxy: write: %s\n", uv_strerror(sas_i))); + } } if ( 0 != wri_u->data ) { - free(wri_u->data); + proxy_write_ctx* ctx_u = wri_u->data; + free(ctx_u->buf_c); + free(ctx_u); } free(wri_u); @@ -1845,7 +1868,12 @@ static c3_i _proxy_write(u3_pcon* con_u, uv_stream_t* str_u, uv_buf_t buf_u) { uv_write_t* wri_u = c3_malloc(sizeof(*wri_u)); - wri_u->data = buf_u.base; + + proxy_write_ctx* ctx_u = c3_malloc(sizeof(*ctx_u)); + ctx_u->con_u = con_u; + ctx_u->str_u = str_u; + ctx_u->buf_c = buf_u.base; + wri_u->data = ctx_u; c3_i sas_i; if ( 0 != (sas_i = uv_write(wri_u, str_u, &buf_u, 1, _proxy_write_cb)) ) { From a348fae40116154ee75b7a8170a5292ee02defc4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 6 Nov 2018 20:35:13 -0500 Subject: [PATCH 221/221] adds perror() calls for u3_term_io_hija/loja i/o errors --- vere/term.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vere/term.c b/vere/term.c index 2736e8314..4782e34bf 100644 --- a/vere/term.c +++ b/vere/term.c @@ -1186,15 +1186,19 @@ u3_term_io_hija(void) else { if ( c3n == u3_Host.ops_u.dem ) { if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->bak_u) ) { + perror("hija-tcsetattr-1"); c3_assert(!"hija-tcsetattr"); } if ( -1 == fcntl(1, F_SETFL, uty_u->cug_i) ) { + perror("hija-fcntl-1"); c3_assert(!"hija-fcntl"); } if ( 0 != tcsetattr(0, TCSADRAIN, &uty_u->bak_u) ) { + perror("hija-tcsetattr-0"); c3_assert(!"hija-tcsetattr"); } if ( -1 == fcntl(0, F_SETFL, uty_u->cug_i) ) { + perror("hija-fcntl-0"); c3_assert(!"hija-fcntl"); } write(uty_u->fid_i, "\r", 1); @@ -1227,15 +1231,19 @@ u3_term_io_loja(int x) } else { if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->raw_u) ) { + perror("loja-tcsetattr-1"); c3_assert(!"loja-tcsetattr"); } if ( -1 == fcntl(1, F_SETFL, uty_u->nob_i) ) { + perror("hija-fcntl-1"); c3_assert(!"loja-fcntl"); } if ( 0 != tcsetattr(0, TCSADRAIN, &uty_u->raw_u) ) { + perror("loja-tcsetattr-0"); c3_assert(!"loja-tcsetattr"); } if ( -1 == fcntl(0, F_SETFL, uty_u->nob_i) ) { + perror("hija-fcntl-0"); c3_assert(!"loja-fcntl"); } _term_it_refresh_line(uty_u);