u3: removes/disables obsolete road stack overflow checks

This commit is contained in:
Joe Bryan 2022-07-07 01:15:01 -04:00
parent 350406c9e1
commit f0fa528f3b
7 changed files with 14 additions and 95 deletions

View File

@ -397,14 +397,10 @@
u3a_push(const u3a_pile* pil_u) u3a_push(const u3a_pile* pil_u)
{ {
u3R->cap_p += pil_u->mov_ws; u3R->cap_p += pil_u->mov_ws;
return u3a_peek(pil_u);
}
/* u3a_pile_sane(): bail on invalid road stack state. // XX define symbol to control guard page
*/ //
inline void #if 0
u3a_pile_sane(const u3a_pile* pil_u)
{
// !off means we're on a north road // !off means we're on a north road
// //
if ( !pil_u->off_ws ) { if ( !pil_u->off_ws ) {
@ -423,10 +419,13 @@
c3_assert( pil_u->top_p <= u3R->cap_p ); c3_assert( pil_u->top_p <= u3R->cap_p );
#endif #endif
} }
#endif
#ifdef U3_MEMORY_DEBUG #ifdef U3_MEMORY_DEBUG
c3_assert( pil_u->rod_u == u3R ); c3_assert( pil_u->rod_u == u3R );
#endif #endif
return u3a_peek(pil_u);
} }
/* u3a_pile_done(): assert valid upon completion. /* u3a_pile_done(): assert valid upon completion.
@ -708,14 +707,6 @@
void (*pat_f)(u3_atom, void*), void (*pat_f)(u3_atom, void*),
c3_o (*cel_f)(u3_noun, void*)); c3_o (*cel_f)(u3_noun, void*));
/* u3a_walk_fore_unsafe(): u3a_walk_fore(), without overflow checks
*/
void
u3a_walk_fore_unsafe(u3_noun a,
void* ptr_v,
void (*pat_f)(u3_atom, void*),
c3_o (*cel_f)(u3_noun, void*));
/* u3a_string(): `a` as an on-loom c-string. /* u3a_string(): `a` as an on-loom c-string.
*/ */
c3_c* c3_c*

View File

@ -27,7 +27,6 @@
*top = i; *top = i;
} while ( u3_nul != t ); } while ( u3_nul != t );
u3a_pile_sane(&pil_u);
u3j_gate_prep(&sit_u, u3k(b)); u3j_gate_prep(&sit_u, u3k(b));
while ( c3n == u3a_pile_done(&pil_u) ) { while ( c3n == u3a_pile_done(&pil_u) ) {

View File

@ -984,10 +984,6 @@
u3j_site raq_u; u3j_site raq_u;
u3j_gate_prep(&raq_u, u3k(raq)); u3j_gate_prep(&raq_u, u3k(raq));
// check for stack overflow
//
u3a_pile_sane(&pil_u);
while ( c3n == u3a_pile_done(&pil_u) ) { while ( c3n == u3a_pile_done(&pil_u) ) {
p_wag = _last_k(par_u->har, p_wag); p_wag = _last_k(par_u->har, p_wag);
puq_wag = u3j_gate_slam(&raq_u, u3nc(par_u->res, puq_wag)); puq_wag = u3j_gate_slam(&raq_u, u3nc(par_u->res, puq_wag));

View File

@ -13,8 +13,6 @@ void*
u3a_pop(const u3a_pile* pil_u); u3a_pop(const u3a_pile* pil_u);
void* void*
u3a_push(const u3a_pile* pil_u); u3a_push(const u3a_pile* pil_u);
void
u3a_pile_sane(const u3a_pile* pil_u);
c3_o c3_o
u3a_pile_done(const u3a_pile* pil_u); u3a_pile_done(const u3a_pile* pil_u);
@ -1176,7 +1174,6 @@ _ca_take_next_north(u3a_pile* pil_u, u3_noun veb)
else { else {
u3a_cell* old_u = (u3a_cell*)veb_u; u3a_cell* old_u = (u3a_cell*)veb_u;
_ca_take* fam_u = u3a_push(pil_u); _ca_take* fam_u = u3a_push(pil_u);
u3a_pile_sane(pil_u);
fam_u->hed = u3_none; fam_u->hed = u3_none;
fam_u->old = veb; fam_u->old = veb;
@ -1232,7 +1229,6 @@ _ca_take_next_south(u3a_pile* pil_u, u3_noun veb)
else { else {
u3a_cell* old_u = (u3a_cell*)veb_u; u3a_cell* old_u = (u3a_cell*)veb_u;
_ca_take* fam_u = u3a_push(pil_u); _ca_take* fam_u = u3a_push(pil_u);
u3a_pile_sane(pil_u);
fam_u->hed = u3_none; fam_u->hed = u3_none;
fam_u->old = veb; fam_u->old = veb;
@ -2656,50 +2652,6 @@ u3a_walk_fore(u3_noun a,
else { else {
*top = u3t(a); *top = u3t(a);
top = u3a_push(&pil_u); top = u3a_push(&pil_u);
u3a_pile_sane(&pil_u);
*top = u3h(a);
}
a = *top;
}
}
/* u3a_walk_fore_unsafe(): u3a_walk_fore(), without overflow checks
*/
void
u3a_walk_fore_unsafe(u3_noun a,
void* ptr_v,
void (*pat_f)(u3_atom, void*),
c3_o (*cel_f)(u3_noun, void*))
{
u3_noun* top;
u3a_pile pil_u;
// initialize stack control; push argument
//
u3a_pile_prep(&pil_u, sizeof(u3_noun));
top = u3a_push(&pil_u);
*top = a;
while ( c3n == u3a_pile_done(&pil_u) ) {
// visit an atom, then pop the stack
//
if ( c3y == u3a_is_atom(a) ) {
pat_f(a, ptr_v);
top = u3a_pop(&pil_u);
}
// vist a cell, if c3n, pop the stack
//
else if ( c3n == cel_f(a, ptr_v) ) {
top = u3a_pop(&pil_u);
}
// otherwise, push the tail and continue into the head
//
else {
*top = u3t(a);
// NB: overflow check elided here
//
top = u3a_push(&pil_u);
*top = u3h(a); *top = u3h(a);
} }

View File

@ -1444,7 +1444,8 @@ _n_push(c3_ys mov, c3_ys off, u3_noun a)
{ {
u3R->cap_p += mov; u3R->cap_p += mov;
// XX stack sanity-check disabled for performance // XX define symbol to control guard page
// or switch to u3a_push()
// //
#if 0 #if 0
if ( 0 == off ) { if ( 0 == off ) {

View File

@ -1732,10 +1732,6 @@ _cr_mug_next(u3a_pile* pil_u, u3_noun veb)
u3a_cell* cel_u = (u3a_cell*)veb_u; u3a_cell* cel_u = (u3a_cell*)veb_u;
_cr_mugf* fam_u = u3a_push(pil_u); _cr_mugf* fam_u = u3a_push(pil_u);
// check for overflow
//
u3a_pile_sane(pil_u);
fam_u->mug_l = 0; fam_u->mug_l = 0;
fam_u->cel = veb; fam_u->cel = veb;

View File

@ -158,15 +158,9 @@ u3s_jam_fib(u3i_slab* sab_u, u3_noun a)
fib_u.bit_w = 0; fib_u.bit_w = 0;
u3i_slab_init(sab_u, 0, fib_u.a_w); u3i_slab_init(sab_u, 0, fib_u.a_w);
// as this is a hot path, we unsafely elide overflow checks u3a_walk_fore(a, &fib_u, _cs_jam_fib_atom_cb, _cs_jam_fib_cell_cb);
//
// a page-fault overflow detection system is urgently needed ...
//
u3a_walk_fore_unsafe(a, &fib_u, _cs_jam_fib_atom_cb,
_cs_jam_fib_cell_cb);
u3h_free(fib_u.har_p); u3h_free(fib_u.har_p);
return fib_u.bit_w; return fib_u.bit_w;
} }
@ -270,18 +264,11 @@ u3s_jam_xeno(u3_noun a, c3_d* len_d, c3_y** byt_y)
{ {
_jam_xeno_t jam_u = {0}; _jam_xeno_t jam_u = {0};
ur_bsw_init(&jam_u.rit_u, ur_fib11, ur_fib12); ur_bsw_init(&jam_u.rit_u, ur_fib11, ur_fib12);
jam_u.har_p = u3h_new(); jam_u.har_p = u3h_new();
// as this is a hot path, we unsafely elide overflow checks u3a_walk_fore(a, &jam_u, _cs_jam_xeno_atom, _cs_jam_xeno_cell);
//
// a page-fault overflow detection system is urgently needed ...
//
u3a_walk_fore_unsafe(a, &jam_u, _cs_jam_xeno_atom,
_cs_jam_xeno_cell);
u3h_free(jam_u.har_p); u3h_free(jam_u.har_p);
return ur_bsw_done(&jam_u.rit_u, len_d, byt_y); return ur_bsw_done(&jam_u.rit_u, len_d, byt_y);
} }
@ -360,7 +347,6 @@ _cs_cue_next(u3a_pile* pil_u,
// //
else { else {
_cs_cue* fam_u = u3a_push(pil_u); _cs_cue* fam_u = u3a_push(pil_u);
u3a_pile_sane(pil_u);
// NB: fam_u->wid unused in head-frame // NB: fam_u->wid unused in head-frame
// //
@ -472,7 +458,6 @@ _cs_cue_xeno_next(u3a_pile* pil_u,
case ur_jam_cell: { case ur_jam_cell: {
_cue_frame_t* fam_u = u3a_push(pil_u); _cue_frame_t* fam_u = u3a_push(pil_u);
u3a_pile_sane(pil_u);
fam_u->ref = u3_none; fam_u->ref = u3_none;
fam_u->bit_d = bit_d; fam_u->bit_d = bit_d;
@ -731,7 +716,6 @@ _cs_cue_bytes_next(u3a_pile* pil_u,
case ur_jam_cell: { case ur_jam_cell: {
_cue_frame_t* fam_u = u3a_push(pil_u); _cue_frame_t* fam_u = u3a_push(pil_u);
u3a_pile_sane(pil_u);
fam_u->ref = u3_none; fam_u->ref = u3_none;
fam_u->bit_d = bit_d; fam_u->bit_d = bit_d;