mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
VM does not initialize stack frames
* libguile/jit.c (compile_alloc_frame): Stop initializing locals. (compile_bind_rest): Use emit_alloc_frame. * libguile/vm-engine.c (assert_nargs_ee_locals, allocate_frame): Don't initialize locals. (bind_rest): Don't initialize locals, and assert that the locals count has a minimum.
This commit is contained in:
parent
c86758c298
commit
f07fadc72e
2 changed files with 10 additions and 51 deletions
|
@ -1851,38 +1851,8 @@ compile_assert_nargs_le (scm_jit_state *j, uint32_t nlocals)
|
||||||
static void
|
static void
|
||||||
compile_alloc_frame (scm_jit_state *j, uint32_t nlocals)
|
compile_alloc_frame (scm_jit_state *j, uint32_t nlocals)
|
||||||
{
|
{
|
||||||
jit_gpr_t t = T0, saved_frame_size = T1_PRESERVED;
|
|
||||||
|
|
||||||
if (j->frame_size_min != j->frame_size_max)
|
|
||||||
jit_subr (j->jit, saved_frame_size, FP, SP);
|
|
||||||
|
|
||||||
/* This will clear the regalloc, so no need to track clobbers. */
|
/* This will clear the regalloc, so no need to track clobbers. */
|
||||||
emit_alloc_frame (j, t, nlocals);
|
emit_alloc_frame (j, T0, nlocals);
|
||||||
|
|
||||||
if (j->frame_size_min == j->frame_size_max)
|
|
||||||
{
|
|
||||||
int32_t slots = nlocals - j->frame_size_min;
|
|
||||||
|
|
||||||
if (slots > 0)
|
|
||||||
{
|
|
||||||
jit_movi (j->jit, t, SCM_UNPACK (SCM_UNDEFINED));
|
|
||||||
while (slots-- > 0)
|
|
||||||
emit_sp_set_scm (j, slots, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
jit_gpr_t walk = saved_frame_size;
|
|
||||||
|
|
||||||
jit_subr (j->jit, walk, FP, saved_frame_size);
|
|
||||||
jit_reloc_t k = jit_bler (j->jit, walk, SP);
|
|
||||||
jit_movi (j->jit, t, SCM_UNPACK (SCM_UNDEFINED));
|
|
||||||
void *head = jit_address (j->jit);
|
|
||||||
jit_subi (j->jit, walk, walk, sizeof (union scm_vm_stack_element));
|
|
||||||
jit_str (j->jit, walk, t);
|
|
||||||
jit_patch_there (j->jit, jit_bner (j->jit, walk, SP), head);
|
|
||||||
jit_patch_here (j->jit, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
j->frame_size_min = j->frame_size_max = nlocals;
|
j->frame_size_min = j->frame_size_max = nlocals;
|
||||||
}
|
}
|
||||||
|
@ -2007,7 +1977,7 @@ compile_bind_rest (scm_jit_state *j, uint32_t dst)
|
||||||
|
|
||||||
cons = emit_branch_if_frame_locals_count_greater_than (j, t, dst);
|
cons = emit_branch_if_frame_locals_count_greater_than (j, t, dst);
|
||||||
|
|
||||||
compile_alloc_frame (j, dst + 1);
|
emit_alloc_frame (j, t, dst + 1);
|
||||||
emit_movi (j, t, SCM_UNPACK (SCM_EOL));
|
emit_movi (j, t, SCM_UNPACK (SCM_EOL));
|
||||||
emit_sp_set_scm (j, 0, t);
|
emit_sp_set_scm (j, 0, t);
|
||||||
k = jit_jmp (j->jit);
|
k = jit_jmp (j->jit);
|
||||||
|
|
|
@ -649,8 +649,6 @@ VM_NAME (scm_thread *thread)
|
||||||
VM_ASSERT (FRAME_LOCALS_COUNT () == expected,
|
VM_ASSERT (FRAME_LOCALS_COUNT () == expected,
|
||||||
CALL_INTRINSIC (error_wrong_num_args, (thread)));
|
CALL_INTRINSIC (error_wrong_num_args, (thread)));
|
||||||
ALLOC_FRAME (expected + nlocals);
|
ALLOC_FRAME (expected + nlocals);
|
||||||
while (nlocals--)
|
|
||||||
SP_SET (nlocals, SCM_UNDEFINED);
|
|
||||||
|
|
||||||
NEXT (1);
|
NEXT (1);
|
||||||
}
|
}
|
||||||
|
@ -773,53 +771,44 @@ VM_NAME (scm_thread *thread)
|
||||||
VM_DEFINE_OP (17, bind_rest, "bind-rest", DOP1 (X8_F24))
|
VM_DEFINE_OP (17, bind_rest, "bind-rest", DOP1 (X8_F24))
|
||||||
{
|
{
|
||||||
uint32_t dst, nargs;
|
uint32_t dst, nargs;
|
||||||
SCM rest = SCM_EOL;
|
|
||||||
|
|
||||||
UNPACK_24 (op, dst);
|
UNPACK_24 (op, dst);
|
||||||
nargs = FRAME_LOCALS_COUNT ();
|
nargs = FRAME_LOCALS_COUNT ();
|
||||||
|
|
||||||
if (nargs <= dst)
|
if (nargs <= dst)
|
||||||
{
|
{
|
||||||
|
VM_ASSERT (nargs == dst, abort ());
|
||||||
ALLOC_FRAME (dst + 1);
|
ALLOC_FRAME (dst + 1);
|
||||||
while (nargs < dst)
|
SP_SET (0, SCM_EOL);
|
||||||
FP_SET (nargs++, SCM_UNDEFINED);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SYNC_IP ();
|
SYNC_IP ();
|
||||||
rest = CALL_INTRINSIC (cons_rest, (thread, dst));
|
SCM rest = CALL_INTRINSIC (cons_rest, (thread, dst));
|
||||||
RESET_FRAME (dst + 1);
|
RESET_FRAME (dst + 1);
|
||||||
|
SP_SET (0, rest);
|
||||||
}
|
}
|
||||||
|
|
||||||
FP_SET (dst, rest);
|
|
||||||
|
|
||||||
NEXT (1);
|
NEXT (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* alloc-frame nlocals:24
|
/* alloc-frame nlocals:24
|
||||||
*
|
*
|
||||||
* Ensure that there is space on the stack for NLOCALS local variables.
|
* Ensure that there is space on the stack for NLOCALS local variables.
|
||||||
* setting any new stack slots to SCM_UNDEFINED.
|
|
||||||
*/
|
*/
|
||||||
VM_DEFINE_OP (18, alloc_frame, "alloc-frame", OP1 (X8_C24))
|
VM_DEFINE_OP (18, alloc_frame, "alloc-frame", OP1 (X8_C24))
|
||||||
{
|
{
|
||||||
uint32_t nlocals, nargs;
|
uint32_t nlocals;
|
||||||
UNPACK_24 (op, nlocals);
|
UNPACK_24 (op, nlocals);
|
||||||
|
|
||||||
nargs = FRAME_LOCALS_COUNT ();
|
|
||||||
ALLOC_FRAME (nlocals);
|
ALLOC_FRAME (nlocals);
|
||||||
while (nlocals-- > nargs)
|
|
||||||
FP_SET (nlocals, SCM_UNDEFINED);
|
|
||||||
|
|
||||||
NEXT (1);
|
NEXT (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset-frame nlocals:24
|
/* reset-frame nlocals:24
|
||||||
*
|
*
|
||||||
* Like alloc-frame, but doesn't check that the stack is big enough,
|
* Like alloc-frame, but doesn't check that the stack is big enough.
|
||||||
* and doesn't reset stack slots to SCM_UNDEFINED. Used to reset the
|
* Used to reset the frame size to something less than the size that
|
||||||
* frame size to something less than the size that was previously set
|
* was previously set via alloc-frame.
|
||||||
* via alloc-frame.
|
|
||||||
*/
|
*/
|
||||||
VM_DEFINE_OP (19, reset_frame, "reset-frame", OP1 (X8_C24))
|
VM_DEFINE_OP (19, reset_frame, "reset-frame", OP1 (X8_C24))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue