Fix profile bug.

This commit is contained in:
C. Guy Yarvin 2014-12-01 14:05:09 -08:00
parent 3453a8ba5c
commit ee5ef2e7ed
4 changed files with 48 additions and 18 deletions

7
n/a.c
View File

@ -4,6 +4,8 @@
*/
#include "all.h"
extern int SAM, SAZ;
/* _box_slot(): select the right free list to search for a block.
*/
c3_w
@ -330,8 +332,6 @@ _ca_willoc(c3_w len_w, c3_w ald_w, c3_w alp_w)
}
}
extern int SUB;
/* _ca_walloc(): u3a_walloc() internals.
*/
static void*
@ -339,6 +339,9 @@ _ca_walloc(c3_w len_w, c3_w ald_w, c3_w alp_w)
{
void* ptr_v = _ca_willoc(len_w, ald_w, alp_w);
if ( SAM ) {
SAZ += len_w;
}
#if 0
if ( SUB ) {
fprintf(stderr, "sub: at %p; kid %p\r\n",

37
n/j.c
View File

@ -533,12 +533,17 @@ _cj_fine(u3_noun cup, u3_noun mop, u3_noun cor)
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 {
@ -735,13 +740,16 @@ _cj_mine(u3_noun cey, u3_noun cor)
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, "mug %x\r\n", u3r_mug(bal));
fprintf(stderr, "label %x, batt %x\r\n", u3r_mug(bal), u3r_mug(bat));
#endif
u3h_put(u3R->jed.har_p,
bat,
u3nt(u3nq(jax_l,
_cj_warm_hump(jax_l, r_cey),
u3nc(u3k(p_cey), lab),
bal,
_cj_jit(jax_l, bat)),
u3nc(soh, mop),
cuz));
@ -845,17 +853,24 @@ _cj_warm_reap(u3_noun kev)
u3_noun cax = u3t(kev);
if ( _(u3a_left(bat)) ) {
u3_noun tab = u3a_take(bat);
u3_noun xac = u3a_take(cax);
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));
}
else {
u3_noun tab = u3a_take(bat);
u3_noun xac = u3a_take(cax);
#if 0
fprintf(stderr, "reap: bat %x (%d, %d), cax %x\r\n",
u3r_mug(tab),
u3a_is_junior(u3R, bat),
u3a_use(tab),
u3r_mug(xac));
fprintf(stderr, "reap to %p: bat %x (%d, %d), cax %x\r\n",
u3R,
u3r_mug(tab),
u3a_is_junior(u3R, bat),
u3a_use(tab),
u3r_mug(xac));
#endif
u3h_put(u3R->jed.har_p, tab, xac);
u3z(tab);
u3h_put(u3R->jed.har_p, tab, xac);
u3z(tab);
}
}
}

13
n/m.c
View File

@ -540,6 +540,10 @@ u3m_bail(u3_noun how)
if ( c3__foul == how ) {
abort();
}
if ( c3__meme == how ) {
abort();
}
/* Printf some metadata.
*/
if ( c3__exit != how ) {
@ -634,7 +638,6 @@ u3m_leap(c3_w pad_w)
u3m_bail(c3__meme);
}
len_w = u3a_open(u3R) - (pad_w + c3_wiseof(u3a_road));
// fprintf(stderr, "leap: pad %d, len %x\r\n", pad_w, len_w);
}
/* Allocate a region on the cap.
@ -861,7 +864,7 @@ u3m_soft_top(c3_w sec_w, // timer seconds
u3_noun
u3m_soft_sure(u3_funk fun_f, u3_noun arg)
{
u3_noun pro, pru = u3m_soft_top(0, (1 << 17), fun_f, arg);
u3_noun pro, pru = u3m_soft_top(0, (1 << 18), fun_f, arg);
c3_assert(_(u3du(pru)));
pro = u3k(u3t(pru));
@ -900,7 +903,7 @@ u3m_soft_run(u3_noun fly,
/* Record the cap, and leap.
*/
u3m_hate(1 << 17);
u3m_hate(1 << 18);
/* Configure the new road.
*/
@ -988,7 +991,7 @@ u3m_soft_esc(u3_noun sam)
/* Record the cap, and leap.
*/
u3m_hate(1 << 17);
u3m_hate(1 << 18);
/* Configure the new road.
*/
@ -1062,7 +1065,7 @@ u3m_soft(c3_w sec_w,
{
u3_noun why;
why = u3m_soft_top(sec_w, (1 << 17), fun_f, arg); // 512K pad
why = u3m_soft_top(sec_w, (1 << 18), fun_f, arg); // 512K pad
if ( 0 == u3h(why) ) {
return why;

9
n/t.c
View File

@ -179,6 +179,9 @@ _t_samp_process(u3_road* rod_u)
}
#endif
int SAM;
int SAZ;
/* u3t_samp(): sample.
*/
void
@ -187,6 +190,10 @@ u3t_samp(void)
// Profile sampling, because it allocates on the home road,
// only works on when we're not at home.
//
c3_assert(!SAM);
SAM = 1;
SAZ = 0;
if ( &(u3H->rod_u) != u3R ) {
u3a_road* rod_u;
@ -203,6 +210,7 @@ u3t_samp(void)
}
u3R = rod_u;
}
SAM = 0;
}
/* u3t_come(): push on profile stack; return yes if active push. RETAIN.
@ -264,6 +272,7 @@ u3t_boot(void)
#if defined(U3_OS_osx)
#if 1
{
SAZ = 0;
struct itimerval itm_v;
struct sigaction sig_s;
sigset_t set;