More profiling updates.

This commit is contained in:
C. Guy Yarvin 2014-12-02 16:26:30 -08:00
parent 11c02c11d9
commit f50b3b3c3c
5 changed files with 61 additions and 13 deletions

23
i/n/t.h
View File

@ -21,19 +21,32 @@
/** Macros.
**/
# define u3t_off(var) \
(u3T.var = (u3C.wag_w & u3o_debug_cpu) \
? (c3y == u3T.var) ? c3n : (abort(), 0) \
: u3T.var)
# ifdef U3_CPU_DEBUG
# define u3t_on(var) \
(u3T.var = (u3C.wag_w & u3o_debug_cpu) \
? (c3n == u3T.var) ? c3y : (abort(), 0) \
: u3T.var)
# else
# define u3t_on(var)
#endif
# ifdef U3_CPU_DEBUG
# define u3t_off(var) \
(u3T.var = (u3C.wag_w & u3o_debug_cpu) \
? (c3y == u3T.var) ? c3n : (abort(), 0) \
: u3T.var)
# else
# define u3t_off(var)
#endif
/** Functions.
**/
/* u3t_init(): initialize tracing layer.
*/
void
u3t_init(void);
/* u3t_push(): push on trace stack.
*/
void

8
n/a.c
View File

@ -1182,7 +1182,7 @@ top:
u3_noun
u3a_gain(u3_noun som)
{
u3t_on(mal_o);
// u3t_on(mal_o);
c3_assert(u3_none != som);
if ( !_(u3a_is_cat(som)) ) {
@ -1190,7 +1190,7 @@ u3a_gain(u3_noun som)
? _me_gain_north(som)
: _me_gain_south(som);
}
u3t_off(mal_o);
// u3t_off(mal_o);
return som;
}
@ -1200,7 +1200,7 @@ u3a_gain(u3_noun som)
void
u3a_lose(u3_noun som)
{
u3t_on(mal_o);
// u3t_on(mal_o);
if ( !_(u3a_is_cat(som)) ) {
if ( _(u3a_is_north(u3R)) ) {
_me_lose_north(som);
@ -1208,7 +1208,7 @@ u3a_lose(u3_noun som)
_me_lose_south(som);
}
}
u3t_off(mal_o);
// u3t_off(mal_o);
}
/* u3a_use(): reference count.

12
n/m.c
View File

@ -808,6 +808,10 @@ u3m_soft_top(c3_w sec_w, // timer seconds
_cm_signal_deep(0);
if ( 0 != (sig_l = sigsetjmp(u3_Signal, 1)) ) {
// reinitialize trace state
//
u3t_init();
// return to blank state
//
_cm_signal_done();
@ -927,6 +931,8 @@ u3m_soft_run(u3_noun fly,
pro = u3nc(0, u3m_love(pro));
}
else {
u3t_init();
/* Produce - or fall again.
*/
{
@ -1011,6 +1017,8 @@ u3m_soft_esc(u3_noun sam)
pro = u3m_love(pro);
}
else {
u3t_init();
/* Push the error back up to the calling context - not the run we
** are in, but the caller of the run, matching pure nock semantics.
*/
@ -1431,6 +1439,10 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c)
*/
nuu_o = u3e_live(nuu_o, dir_c);
/* Activate tracing.
*/
u3t_init();
/* Construct or activate the allocator.
*/
_cm_pave(nuu_o, bug_o);

14
n/n.c
View File

@ -47,7 +47,9 @@ _n_hint(u3_noun zep,
}
case c3__slog: {
u3t_off(noc_o);
u3t_slog(hod);
u3t_on(noc_o);
return _n_nock_on(bus, nex);
}
@ -253,7 +255,11 @@ _n_nock_on(u3_noun bus, u3_noun fol)
u3x_cell(gal, &b_gal, &c_gal);
{
u3_noun seb = _n_nock_on(bus, u3k(c_gal));
u3_noun pro = u3j_kick(seb, b_gal);
u3_noun pro;
u3t_off(noc_o);
pro = u3j_kick(seb, b_gal);
u3t_on(noc_o);
if ( u3_none != pro ) {
u3a_lose(fol);
@ -308,7 +314,11 @@ _n_nock_on(u3_noun bus, u3_noun fol)
case 11: {
u3_noun gof = _n_nock_on(bus, u3k(gal));
u3_noun val = u3m_soft_esc(u3k(gof));
u3_noun val;
u3t_off(noc_o);
val = u3m_soft_esc(u3k(gof));
u3t_on(noc_o);
if ( !_(u3du(val)) ) {
u3m_bail(u3nt(1, gof, 0));

17
n/t.c
View File

@ -184,6 +184,8 @@ _t_samp_process(u3_road* rod_u)
void
u3t_samp(void)
{
u3C.wag_w &= ~u3o_debug_cpu;
// Profile sampling, because it allocates on the home road,
// only works on when we're not at home.
//
@ -221,6 +223,7 @@ u3t_samp(void)
}
u3R = rod_u;
}
u3C.wag_w |= u3o_debug_cpu;
}
/* u3t_come(): push on profile stack; return yes if active push. RETAIN.
@ -273,13 +276,23 @@ void _ct_sigaction(c3_i x_i)
u3t_samp();
}
/* u3t_init(): initialize tracing layer.
*/
void
u3t_init(void)
{
u3T.noc_o = c3n;
u3T.glu_o = c3n;
u3T.mal_o = c3n;
u3T.far_o = c3n;
}
/* u3t_boot(): turn sampling on.
*/
void
u3t_boot(void)
{
if ( u3C.wag_w & u3o_debug_cpu ) {
if ( u3C.wag_w & u3o_debug_cpu ) {
#if defined(U3_OS_osx)
#if 1
{