Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/noun/allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ u3a_wealloc(void* lag_v, c3_w len_w)
/* u3a_pile_prep(): initialize stack control.
*/
void
u3a_pile_prep(u3a_pile* pil_u, c3_w len_w)
u3a_pile_prep(u3a_pile* pil_u, c3_w len_w, c3_w lin_w)
{
c3_w pad_w = -(uintptr_t)len_w & (lin_w - 1);

// frame size, in words
//
c3_w wor_w = (len_w + 3) >> 2;
c3_w wor_w = (len_w + 3 + pad_w) >> 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want or need to change the frame size to accomplish alignment. The frame size (in words) is the sizeof (in bytes), so it already accounts for any padding necessary to align an array of these frames. What's missing is the initial alignment of the base pointer (ie, cap_p). That needs to happen, and the result stored in top_p. The pile also needs an additional member to track and restore (in u3a_pile_done() the original, un-aligned cap.

c3_o nor_o = u3a_is_north(u3R);

pil_u->mov_ws = (c3y == nor_o) ? -wor_w : wor_w;
Expand Down Expand Up @@ -691,7 +693,7 @@ _ca_take_north(u3_noun veb)
u3_noun pro;
_ca_take* fam_u;
u3a_pile pil_u;
u3a_pile_prep(&pil_u, sizeof(*fam_u));
u3a_pile_prep(&pil_u, sizeof(*fam_u), _Alignof(*fam_u));

// commence taking
//
Expand Down Expand Up @@ -731,7 +733,7 @@ _ca_take_south(u3_noun veb)
u3_noun pro;
_ca_take* fam_u;
u3a_pile pil_u;
u3a_pile_prep(&pil_u, sizeof(*fam_u));
u3a_pile_prep(&pil_u, sizeof(*fam_u), _Alignof(*fam_u));

// commence taking
//
Expand Down Expand Up @@ -1966,7 +1968,7 @@ u3a_walk_fore(u3_noun a,

// initialize stack control; push argument
//
u3a_pile_prep(&pil_u, sizeof(u3_noun));
u3a_pile_prep(&pil_u, sizeof(u3_noun), _Alignof(u3_noun));
top = u3a_push(&pil_u);
*top = a;

Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ u3a_post_info(u3_post);
/* u3a_pile_prep(): initialize stack control.
*/
void
u3a_pile_prep(u3a_pile* pil_u, c3_w len_w);
u3a_pile_prep(u3a_pile* pil_u, c3_w len_w, c3_w lin_w);

/* C-style aligned allocation - *not* compatible with above.
*/
Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/jets/b/reel.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
u3_noun* top;
u3_noun i, t = a;

u3a_pile_prep(&pil_u, sizeof(u3_noun));
u3a_pile_prep(&pil_u, sizeof(u3_noun), _Alignof(u3_noun));

// push list onto road stack
//
Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/jets/e/json_de.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ _parse(u3_atom txt)
}
json_open_buffer(sam_u, byt_y, len_w);
json_set_allocator(sam_u, &loc_u);
u3a_pile_prep(pil_u, sizeof(u3qedj_coll));
u3a_pile_prep(pil_u, sizeof(u3qedj_coll), _Alignof(u3qedj_coll));

//
// core logic
Expand Down
5 changes: 2 additions & 3 deletions pkg/noun/jets/e/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
u3nc(u3k(p_tub),
u3k(pquq_vex)),
u3k(puq_vex));

u3k(p_vex);
u3k(quq_vex);
wag = u3n_slam_on(u3k(hez), gud);
Expand Down Expand Up @@ -975,7 +975,7 @@
_stir_pair* par_u;
u3_noun p_wag, puq_wag, quq_wag;

u3a_pile_prep(&pil_u, sizeof(*par_u));
u3a_pile_prep(&pil_u, sizeof(*par_u), _Alignof(*par_u));

// push incremental, successful [fel] parse results onto road stack
//
Expand Down Expand Up @@ -1049,4 +1049,3 @@

#undef _p
#undef _q

7 changes: 4 additions & 3 deletions pkg/noun/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ _cm_signal_handle(c3_l sig_l)
static void
#ifndef U3_OS_windows
_cm_signal_handle_over(int emergency, stackoverflow_context_t scp)
#else
#else
_cm_signal_handle_over(int x)
#endif
{
Expand Down Expand Up @@ -1032,7 +1032,8 @@ u3m_leap(c3_w pad_w)
{
u3a_pile pil_u;
c3_p ptr_p;
u3a_pile_prep(&pil_u, sizeof(u3a_road) + 15); // XX refactor to wiseof
// u3a_pile_prep(&pil_u, sizeof(u3a_road) + 15); // XX refactor to wiseof
u3a_pile_prep(&pil_u, sizeof(u3a_road), _Alignof(u3a_road));
ptr_p = (c3_p)u3a_push(&pil_u);

// XX add push_once, push_once_aligned
Expand Down Expand Up @@ -1138,7 +1139,7 @@ u3m_leap(c3_w pad_w)
if ( NULL != stk_u ) {
rod_u->off_w = stk_u->off_w;
rod_u->fow_w = stk_u->fow_w;
}
}

/* Set up the new road.
*/
Expand Down
6 changes: 3 additions & 3 deletions pkg/noun/retrieve.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ _cr_sing(u3_noun a, u3_noun b)

// initialize stack control, push arguments onto the stack (none-frame)
//
u3a_pile_prep(&pil_u, sizeof(eqframe));
u3a_pile_prep(&pil_u, sizeof(eqframe), _Alignof(eqframe));
fam_u = _cr_sing_push(&pil_u, a, b);

// loop while arguments are on the stack
Expand Down Expand Up @@ -1803,7 +1803,7 @@ u3r_mug(u3_noun veb)
//
u3_assert( u3_none != veb );

u3a_pile_prep(&pil_u, sizeof(*fam_u));
u3a_pile_prep(&pil_u, sizeof(*fam_u), _Alignof(*fam_u));

// commence mugging
//
Expand Down Expand Up @@ -1887,7 +1887,7 @@ u3r_safe(u3_noun fol, u3_weak* out)
case 0:
*out = u3_none;
return __(1 == t_fol);

case 1:
*out = t_fol;
return c3y;
Expand Down
6 changes: 3 additions & 3 deletions pkg/noun/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ u3s_cue(u3_atom a)

// initialize stack control
//
u3a_pile_prep(&pil_u, sizeof(*fam_u));
u3a_pile_prep(&pil_u, sizeof(*fam_u), _Alignof(*fam_u));

// commence cueing at bit-position 0
//
Expand Down Expand Up @@ -589,7 +589,7 @@ _cs_cue_xeno(u3_cue_xeno* sil_u,

// initialize stack control
//
u3a_pile_prep(&pil_u, sizeof(*fam_u));
u3a_pile_prep(&pil_u, sizeof(*fam_u), _Alignof(*fam_u));

// init bitstream-reader
//
Expand Down Expand Up @@ -824,7 +824,7 @@ u3s_cue_bytes(c3_d len_d, const c3_y* byt_y)

// initialize stack control
//
u3a_pile_prep(&pil_u, sizeof(*fam_u));
u3a_pile_prep(&pil_u, sizeof(*fam_u), _Alignof(*fam_u));

// initialize a hash table for dereferencing backrefs
//
Expand Down