1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 18:20:22 +02:00

Clean up stack after calls

This commit is contained in:
Andy Wingo 2019-04-03 12:09:38 +02:00
parent 99b4fd2d79
commit 573af9c19b
2 changed files with 21 additions and 1 deletions

2
jit.h
View file

@ -170,7 +170,7 @@ JIT_API void jit_patch_here(jit_state_t*, jit_reloc_t);
JIT_API void jit_patch_there(jit_state_t*, jit_reloc_t, jit_pointer_t);
/* Note that all functions that take jit_arg_t args[] use the args as scratch
space. */
space while shuffling values into position. */
JIT_API void jit_calli(jit_state_t *, jit_pointer_t f,
size_t argc, const jit_arg_abi_t abi[],
jit_arg_t args[]);

View file

@ -735,6 +735,22 @@ prepare_args(jit_state_t *_jit, size_t argc, const jit_arg_abi_t abi[],
}
}
static void
cleanup_stack_after_call(jit_state_t *_jit, size_t argc,
const jit_arg_abi_t abi[])
{
jit_arg_t scratch;
struct abi_arg_iterator iter;
// Compute stack arg size.
reset_abi_arg_iterator(&iter, argc, abi);
for (size_t i = 0; i < argc; i++)
next_abi_arg(&iter, &scratch);
if (iter.stack_size)
jit_addi(_jit, JIT_SP, JIT_SP, iter.stack_size);
}
void
jit_calli(jit_state_t *_jit, jit_pointer_t f,
size_t argc, const jit_arg_abi_t abi[], jit_arg_t args[])
@ -742,6 +758,8 @@ jit_calli(jit_state_t *_jit, jit_pointer_t f,
prepare_args(_jit, argc, abi, args);
calli(_jit, (jit_word_t)f);
cleanup_stack_after_call(_jit, argc, abi);
}
void
@ -751,6 +769,8 @@ jit_callr(jit_state_t *_jit, jit_gpr_t f,
prepare_args(_jit, argc, abi, args);
callr(_jit, rn(f));
cleanup_stack_after_call(_jit, argc, abi);
}
void