Various fixes and improvements...

This commit is contained in:
C. Guy Yarvin 2013-11-08 15:37:38 -08:00
parent f9c368d856
commit 91fe182f81
9 changed files with 82 additions and 37 deletions

View File

@ -895,7 +895,7 @@ u2_rl_gain(u2_ray ral_r,
#if 0
if ( LEAK && (som_r == LEAKY) ) {
printf("LEAK: gain %x, use %d\n", som, use_w);
// if ( LEAK == 2 ) c3_assert(0);
// if ( LEAK == XXXX ) c3_assert(0);
LEAK++;
}
#endif
@ -1635,9 +1635,8 @@ u2_rl_gc_sweep(u2_ray ral_r, c3_w sav_w)
c3_ws use_ws = (c3_ws) use_w;
if ( use_ws > 0 ) {
#if 0
#if 1
fprintf(stderr, "leak: box %x, siz %d, use %d\r\n", box_r, siz_w, use_w);
c3_assert(0);
#endif
lek_w += siz_w;
u2_rail_box_use(box_r) = 0;

View File

@ -98,6 +98,11 @@
# define u2_rail_hut_pre(hut) *u2_at(hut, u2_loom_rail_hut, pre_r)
# define u2_rail_hut_nex(hut) *u2_at(hut, u2_loom_rail_hut, nex_r)
# define u2_rail_box(som) \
( u2_fly_is_cat(som) \
? 0 \
: (u2_dog_a(som) - c3_wiseof(u2_loom_rail_box)) )
/** Abbreviations.
**/
# define u2_rc(ral_r, a, b) u2_rl_cell(ral_r, a, b)

View File

@ -722,10 +722,10 @@
void
u2_lo_sway(c3_l tab_l, u2_noun tax);
/* u2_lo_grab(): garbage-collect the world, plus roots.
/* u2_lo_grab(): garbage-collect the world, plus roots; end with u2_none
*/
void
u2_lo_grab(u2_noun som, ...);
u2_lo_grab(c3_c* cap_c, u2_noun som, ...);
/* u2_lo_open(): begin callback processing.
*/

View File

@ -194,6 +194,7 @@ _lo_poll(void)
u2_batz_io_poll();
}
#if 0
/* _lo_how(): print how.
*/
static const c3_c*
@ -211,6 +212,7 @@ _lo_how(u2_noun how)
case c3__unix: return "unix";
}
}
#endif
/* u2_lo_bail(): clean up all event state.
*/
@ -397,6 +399,7 @@ _lo_soft(u2_reck* rec_u, c3_w sec_w, u2_funk fun_f, u2_noun arg)
return pro;
}
#if 0
/* _lo_hard(): standard hard wrapper. Produces result and/or asserts.
*/
static u2_noun
@ -415,6 +418,7 @@ _lo_hard(u2_reck* rec_u, u2_funk fun_f, u2_noun arg)
c3_assert(0);
}
}
#endif
/* _lo_mung(): formula wrapper with gate and sample.
*/
@ -610,11 +614,14 @@ _lo_sure(u2_reck* rec_u, u2_noun ovo, u2_noun vir, u2_noun cor)
// Evaluate external side effects. Not allowed to fail.
//
{
u2_noun hux = vir;
while ( u2_nul != vir ) {
u2_noun ovo = u2k(u2h(vir));
u2_noun nex = u2k(u2t(vir));
c3_c* hed_c = u2_cr_string(u2h(u2t(ovo)));
while ( u2_nul != hux ) {
u2_reck_kick(rec_u, u2k(u2h(hux)));
hux = u2t(hux);
u2z(vir); vir = nex;
u2_reck_kick(rec_u, ovo);
}
u2z(vir);
}
@ -741,9 +748,10 @@ _lo_punk(u2_reck* rec_u, u2_noun ovo)
{
// c3_c* txt_c = u2_cr_string(u2h(u2t(ovo)));
c3_w sec_w;
// static c3_w num_w;
u2_noun gon;
// uL(fprintf(uH, "punk in %s\n", txt_c));
// uL(fprintf(uH, "punk: %s: %d\n", u2_cr_string(u2h(u2t(ovo))), num_w++));
// XX this is wrong - the timer should be on the original hose.
//
@ -755,26 +763,35 @@ _lo_punk(u2_reck* rec_u, u2_noun ovo)
gon = _lo_soft(rec_u, sec_w, u2_reck_poke, u2k(ovo));
if ( u2_blip != u2h(gon) ) {
_lo_lame(rec_u, ovo, u2k(u2h(gon)), u2k(u2t(gon)));
u2_noun why = u2k(u2h(gon));
u2_noun tan = u2k(u2t(gon));
u2z(gon);
_lo_lame(rec_u, ovo, why, tan);
}
else {
u2_noun vir = u2k(u2h(u2t(gon)));
u2_noun cor = u2k(u2t(u2t(gon)));
u2_noun nug = _lo_nick(rec_u, vir, cor);
u2_noun nug;
u2z(gon);
nug = _lo_nick(rec_u, vir, cor);
if ( u2_blip != u2h(nug) ) {
_lo_lame(rec_u, ovo, u2k(u2h(nug)), u2k(u2t(nug)));
u2_noun why = u2k(u2h(nug));
u2_noun tan = u2k(u2t(nug));
u2z(nug);
_lo_lame(rec_u, ovo, why, tan);
}
else {
vir = u2k(u2h(u2t(nug)));
cor = u2k(u2t(u2t(nug)));
u2z(nug);
_lo_sure(rec_u, ovo, vir, cor);
}
u2z(nug);
}
u2z(gon);
// uL(fprintf(uH, "punk oot %s\n", txt_c));
}
@ -795,11 +812,11 @@ _lo_work(u2_reck* rec_u)
free(egg_u);
{
u2_noun old, new;
// c3_c* her_c = u2_cr_string(u2h(u2t(egg)));
uint8_t her_t = (c3__hear == u2h(u2t(egg)));
#if 0
// u2_noun old, new;
// c3_c* her_c = u2_cr_string(u2h(u2t(egg)));
// uint8_t her_t = (c3__hear == u2h(u2t(egg)));
if ( her_t ) {
u2_reck_time(u2A);
old = u2k(u2A->now);
@ -832,6 +849,8 @@ _lo_work(u2_reck* rec_u)
void
u2_lo_open(void)
{
// u2_lo_grab("lo_open", u2_none);
// update time
//
u2_reck_time(u2A);
@ -1084,6 +1103,7 @@ _lo_text(u2_reck* rec_u, c3_c* pom_c)
return say;
}
#if 0
/* _lo_bask(): ask a yes or no question.
*/
static u2_bean
@ -1111,6 +1131,7 @@ _lo_bask(c3_c* pop_c, u2_bean may)
uL(0);
return yam;
}
#endif
/* _lo_rand(): fill a 256-bit (8-word) buffer.
*/
@ -1653,7 +1674,6 @@ _lo_boot(void)
if ( u2_yes == u2_Host.ops_u.nuu ) {
u2_noun pig;
if ( 0 == u2_Host.ops_u.imp_c ) {
u2_noun ten = _lo_zen(u2A);
uL(fprintf(uH, "generating 2048-bit RSA pair...\n"));
@ -1689,6 +1709,7 @@ _lo_boot(void)
}
}
#if 0
// _lo_bench_noop(): benchmark no-op events.
//
static void
@ -1803,6 +1824,7 @@ _lo_bench(const c3_c* lab_c, void (*fun)(c3_w), c3_w num_w)
}
}
}
#endif
/* u2_lo_show(): generic noun print.
*/
@ -1944,7 +1966,7 @@ _lo_word(c3_w wod_w)
/* u2_lo_grab(): garbage-collect the world, plus roots.
*/
void
u2_lo_grab(u2_noun som, ...)
u2_lo_grab(c3_c* cap_c, u2_noun som, ...)
{
c3_w siz_w, lec_w;
@ -1955,10 +1977,10 @@ u2_lo_grab(u2_noun som, ...)
va_start(vap, som);
if ( som != 0 ) {
if ( som != u2_none ) {
siz_w += u2_cm_mark_noun(som);
while ( 0 != (tur = va_arg(vap, u2_noun)) ) {
while ( u2_none != (tur = va_arg(vap, u2_noun)) ) {
siz_w += u2_cm_mark_noun(tur);
}
}
@ -1966,14 +1988,25 @@ u2_lo_grab(u2_noun som, ...)
}
lec_w = u2_cm_sweep(siz_w);
if ( lec_w || (u2_yes == u2_Flag_Verbose) ) {
uL(fprintf(uH, "%s: gc: ", u2_Local));
if ( lec_w || (u2_yes == u2_Flag_Verbose) )
// if ( lec_w )
{
uL(fprintf(uH, "%s: gc: ", cap_c));
if ( lec_w ) {
_lo_word(4 * lec_w);
uL(fprintf(uH, " bytes shed; "));
}
_lo_word(4 * siz_w);
uL(fprintf(uH, " bytes live\n"));
#if 0
if ( lec_w ) {
uL(fprintf(uH, "zero garbage tolerance!\n"));
_lo_exit();
c3_assert(0);
exit(1);
}
#endif
}
u2_wire_lan(u2_Wire) = u2_yes;
}

View File

@ -331,7 +331,7 @@ main(c3_i argc,
#endif
}
u2_lo_grab(0);
u2_lo_grab("main", u2_none);
u2_lo_loop(u2_Host.arv_u);
return 0;

View File

@ -126,6 +126,7 @@ _reck_scot(u2_reck* rec_u, u2_noun dim)
return u2_do("scot", dim);
}
#if 0
/* _reck_spoo(): noun path from c, kind of a hack.
*/
static u2_noun
@ -150,6 +151,7 @@ _reck_spoo(c3_c* pax_c)
}
}
}
#endif
/* _reck_load_arvo(): read an arvo file.
*/
@ -829,7 +831,6 @@ u2_reck_boot(u2_reck* rec_u)
memset(rec_u, 0, sizeof *rec_u);
if ( 0 != (hoe = u2_cm_trap()) ) {
u2_cm_purge();
u2_lo_grab(hoe, 0);
u2_lo_sway(2, u2_ckb_flop(u2k(u2t(hoe))));
u2z(hoe);
@ -863,7 +864,6 @@ u2_reck_prick(u2_reck* rec_u, u2_noun our, u2_noun hap)
if ( 0 != (hoe = u2_cm_trap()) ) {
u2_cm_purge();
u2_lo_grab(hoe, 0);
u2_lo_sway(2, u2_ckb_flop(u2k(u2t(hoe))));
u2z(hoe);
@ -875,9 +875,6 @@ u2_reck_prick(u2_reck* rec_u, u2_noun our, u2_noun hap)
u2_cm_done();
u2_cm_purge();
if ( (u2_yes == u2_Flag_Garbage) || (u2_no == u2_wire_lan(u2_Wire)) ) {
u2_lo_grab(0);
}
}
return que;
}

View File

@ -717,11 +717,15 @@ _term_poll_cb(uv_poll_t* pol_u, c3_i sas_i, c3_i evt_i)
if ( (siz_i = write(uty_u->fid_i,
uty_u->out_u->hun_y,
uty_u->out_u->len_w)) < 0 ) {
#if 0
if ( EAGAIN == errno ) {
break;
} else {
c3_assert(!"term: write");
}
#else
break;
#endif
}
if ( siz_i < out_u->len_w ) {
_term_it_clip(out_u, siz_i);

View File

@ -157,6 +157,7 @@ u2_time_gap_ms(u2_noun now, u2_noun wen)
c3_d fsc_d = u2_cr_chub(0, dif);
c3_d sec_d = u2_cr_chub(1, dif);
u2z(dif);
return (sec_d * 1000ULL) + u2_time_msc_out(fsc_d);
}
}

View File

@ -760,7 +760,7 @@ _unix_desk_sync_into(u2_noun who,
u2_noun xun, bur, doz, fav, pax;
xun = _unix_dir_ankh(dir_u);
bur = _unix_desk_peek(u2k(who), hox, syd, u2k(u2A->wen));
bur = _unix_desk_peek(u2k(who), hox, u2k(syd), u2k(u2A->wen));
if ( u2_no == u2_sing(xun, bur) ) {
doz = u2_dc("cost", xun, bur);
@ -771,7 +771,7 @@ _unix_desk_sync_into(u2_noun who,
u2_reck_plan(u2A, pax, fav);
}
else {
u2z(xun); u2z(bur);
u2z(who); u2z(syd); u2z(xun); u2z(bur);
}
}
@ -816,7 +816,7 @@ _unix_ship_update(u2_uhot* hot_u)
static void
_unix_hot_gain(u2_noun who, u2_bean mek)
{
u2_noun hox = u2_dc("scot", 'p', who);
u2_noun hox = u2_dc("scot", 'p', u2k(who));
c3_c* hox_c = u2_cr_string(hox);
c3_c* pax_c = _unix_down(u2_Host.ops_u.hom_c, hox_c + 1);
DIR* rid_u = opendir(pax_c);
@ -824,7 +824,11 @@ _unix_hot_gain(u2_noun who, u2_bean mek)
if ( !rid_u ) {
if ( u2_yes == mek ) {
_unix_mkdir(pax_c);
} else return;
} else {
u2z(who);
u2z(hox);
return;
}
} else closedir(rid_u);
// uL(fprintf(uH, "GAIN %s\n", pax_c));
@ -838,6 +842,8 @@ _unix_hot_gain(u2_noun who, u2_bean mek)
_unix_dir_watch(&hot_u->dir_u, 0, pax_c);
u2_cr_mp(hot_u->who_mp, who);
u2z(who);
hot_u->nex_u = u2_Host.unx_u.hot_u;
u2_Host.unx_u.hot_u = hot_u;
}