/* u2_bx_post(): export and reset the performance log. ** ** zat: source position stack (on shed) ** zof: programer action stack (on shed) ** sap: number of steps ** cop: number of words copied ** det: number of identical nouns compared ** jax: number of jet activations ** use: number of user counts ** wax: maximum depth of C stack ** viq: words in wire allocated ** zor: words in basket allocated ** ums: number of milliseconds consumed */ u2_bean u2_bx_post(u2_ray wir_r, u2_noun* zat, u2_noun* zof, c3_d* sap_d, c3_d* cop_d, c3_d* det_d, c3_d* jax_d, c3_d* use_d, c3_w* wax_w, c3_ws* viq_ws, c3_ws* zor_ws, c3_w* ums_w) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return u2_no; } else { c3_w sec_w, usc_w; *zat = u2_benx_at(bex_r, zat); *zof = u2_benx_at(bex_r, zof); *sap_d = u2_benx_be(bex_r, c3_d, sap_d); *cop_d = u2_benx_be(bex_r, c3_d, cop_d); *det_d = u2_benx_be(bex_r, c3_d, det_d); *jax_d = u2_benx_be(bex_r, c3_d, jax_d); *use_d = u2_benx_be(bex_r, c3_d, use_d); *wax_w = u2_benx_at(bex_r, wax_w); *viq_ws = u2_soup_liv_w(u2_rail_rut_r(wir_r)) - u2_benx_be(bex_r, c3_w, lif_w); *zor_ws = u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))) - u2_benx_be(bex_r, c3_w, bos_w); sec_w = u2_benx_at(bex_r, sec_w); usc_w = u2_benx_at(bex_r, usc_w); u2_bx_boot(wir_r); /* Measure and return time change. */ { c3_d old_d, new_d; old_d = sec_w; old_d *= 1000000ULL; old_d += usc_w; new_d = u2_benx_at(bex_r, sec_w); new_d *= 1000000ULL; new_d += u2_benx_at(bex_r, usc_w); *ums_w = (c3_w) (((new_d - old_d) + 999ULL) / 1000ULL); } return u2_yes; } }
/* u2_bx_boot(): reset the performance log. */ void u2_bx_boot(u2_ray wir_r) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return; } else { u2_benx_at(bex_r, zat) = u2_nul; u2_benx_at(bex_r, zof) = u2_nul; u2_benx_be(bex_r, c3_d, sap_d) = 0; u2_benx_be(bex_r, c3_d, cop_d) = 0; u2_benx_be(bex_r, c3_d, det_d) = 0; u2_benx_be(bex_r, c3_d, jax_d) = 0; u2_benx_be(bex_r, c3_d, use_d) = 0; u2_benx_be(bex_r, c3_w, wac_w) = 0; u2_benx_be(bex_r, c3_w, wax_w) = 0; u2_benx_be(bex_r, c3_w, lif_w) = u2_soup_liv_w(u2_rail_rut_r(wir_r)); u2_benx_be(bex_r, c3_w, bos_w) = u2_soup_liv_w(u2_rail_rut_r(u2_wire_bas_r(wir_r))); { struct timeval tv; gettimeofday(&tv, 0); u2_benx_at(bex_r, sec_w) = tv.tv_sec; u2_benx_at(bex_r, usc_w) = tv.tv_usec; } } }
/* u2_bx_bean_ent(), u2_bx_bean_out(): enter and exit source position. */ void u2_bx_bean_ent(u2_ray wir_r, u2_noun hod) // transfer { u2_ray bex_r, bas_r; if ( (0 == (bex_r = u2_wire_bex_r(wir_r))) || (0 == (bas_r = u2_wire_bas_r(wir_r))) ) { u2_rl_lose(wir_r, hod); return; } else { u2_noun naz = u2_rl_uniq(wir_r, hod); u2_rl_lose(wir_r, hod); if ( u2_none != naz ) { u2_noun zof = u2_rc (bas_r, u2_rx(bas_r, naz), u2_rx(bas_r, u2_benx_at(bex_r, zof))); if ( u2_none != zof ) { u2_rl_lose(bas_r, u2_benx_at(bex_r, zof)); u2_benx_at(bex_r, zof) = zof; } } } }
/* u2_bx_spot(): declare source position. */ void u2_bx_spot(u2_ray wir_r, u2_noun hod) // transfer { u2_ray bex_r, bas_r; if ( (0 == (bex_r = u2_wire_bex_r(wir_r))) || (0 == (bas_r = u2_wire_bas_r(wir_r))) ) { u2_rl_lose(wir_r, hod); return; } else { u2_noun sud = u2_rl_take(bas_r, hod); u2_rl_lose(wir_r, hod); if ( u2_none == sud ) { return; } else { u2_rl_lose(wir_r, u2_benx_at(bex_r, zat)); u2_benx_at(bex_r, zat) = sud; } } }
/* u2_bx_rise(): go shallower (return) in the C stack. */ void u2_bx_rise(u2_ray wir_r) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return; } else { u2_benx_at(bex_r, wac_w) -= 1; } }
/* u2_bx_flew(): report a jet activation. */ void u2_bx_flew(u2_ray wir_r) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return; } else { u2_benx_be(bex_r, c3_d, jax_d) += (c3_d) 1; } }
/* u2_bx_step(): note interpreter step. */ void u2_bx_step(u2_ray wir_r) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return; } else { u2_benx_be(bex_r, c3_d, sap_d) += (c3_d) 1; } }
/* u2_bx_dent(): note `det` identical comparisons. */ void u2_bx_dent(u2_ray wir_r, c3_w det_w) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return; } else { u2_benx_be(bex_r, c3_d, det_d) += (c3_d) det_w; } }
/* u2_bx_copy(): note `cop` copied words. */ void u2_bx_copy(u2_ray wir_r, c3_w cop_w) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return; } else { u2_benx_be(bex_r, c3_d, cop_d) += (c3_d) cop_w; } }
/* u2_bx_sink(): go deeper (call) in the C stack. */ void u2_bx_sink(u2_ray wir_r) { u2_ray bex_r; if ( 0 == (bex_r = u2_wire_bex_r(wir_r)) ) { return; } else { u2_benx_at(bex_r, wac_w) += 1; if ( u2_benx_at(bex_r, wac_w) > u2_benx_at(bex_r, wax_w) ) { u2_benx_at(bex_r, wax_w) = u2_benx_at(bex_r, wac_w); } } }
void u2_bx_bean_out(u2_ray wir_r) { u2_ray bex_r, bas_r; if ( (0 == (bex_r = u2_wire_bex_r(wir_r))) || (0 == (bas_r = u2_wire_bas_r(wir_r))) ) { return; } else { u2_noun zof = u2_benx_at(bex_r, zof); c3_assert(u2_nul != zof); u2_benx_at(bex_r, zof) = u2_rx(bas_r, u2_t(zof)); u2_rl_lose(bas_r, zof); } }
void u2_bx_spot_out(u2_ray wir_r) { u2_ray bex_r, bas_r; if ( (0 == (bex_r = u2_wire_bex_r(wir_r))) || (0 == (bas_r = u2_wire_bas_r(wir_r))) ) { return; } else { u2_noun zat = u2_benx_at(bex_r, zat); c3_assert(u2_nul != zat); u2_benx_at(bex_r, zat) = u2_t(zat); u2_rl_lose(wir_r, zat); } }
/* u2_wr_init(): ** ** Install an empty wire within `hat_r` and `mat_r` in the loom, ** with memory model `hip`. ** ** Returns ray to wire, which always equalls the passed `mat_r`. */ u2_ray u2_wr_init(c3_m hip_m, u2_ray hat_r, u2_ray mat_r) { u2_ray wir_r; wir_r = u2_rl_init(hip_m, hat_r, mat_r); u2_rail_hat_r(wir_r) += (c3_wiseof(u2_loom_wire) - c3_wiseof(u2_loom_rail)); #if 1 u2_wire_bas_r(wir_r) = 0; #endif u2_wire_kit_r(wir_r) = 0; u2_cs_init(u2_wire_des_r(wir_r)); /* Trace stack, garbage. */ { u2_wire_tax(wir_r) = u2_nul; u2_wire_lan(wir_r) = u2_yes; } /* Permanent basket = 1/16 of address space. */ { u2_ray bas_r; bas_r = u2_rl_leap_part(wir_r, c3__sand, 1, 16, 0); u2_wire_bas_r(wir_r) = bas_r; #if 0 fprintf(stderr, "bas_r %d, hat %d, mat %d, cap %d, rut %d\n", bas_r >> LoomPageWords, u2_rail_hat_r(bas_r) >> LoomPageWords, u2_rail_mat_r(bas_r) >> LoomPageWords, u2_rail_cap_r(bas_r) >> LoomPageWords, u2_rail_rut_r(bas_r) >> LoomPageWords); fprintf(stderr, "wir_r %d, hat %d, mat %d, cap %d, rut %d\n", wir_r >> LoomPageWords, u2_rail_hat_r(wir_r) >> LoomPageWords, u2_rail_mat_r(wir_r) >> LoomPageWords, u2_rail_cap_r(wir_r) >> LoomPageWords, u2_rail_rut_r(wir_r) >> LoomPageWords); #endif // u2_ba_init(wir_r, 0); } #if 1 /* Host control. */ { u2_ho_push(); } #endif /* Basic performance tracking. */ { u2_wire_bex_r(wir_r) = u2_rl_ralloc(wir_r, c3_wiseof(u2_loom_benx)); u2_bx_boot(wir_r); } /* New performance tracking. */ { u2_wire_rac_r(wir_r) = u2_tx_init(wir_r); } /* Global namespace. */ { u2_wire_hev_r(wir_r) = u2_hv_init(wir_r); } /* OS kernel. */ { u2_wire_arv_r(wir_r) = u2_rl_ralloc(wir_r, c3_wiseof(u2_reck)); } return wir_r; }