diff options
author | Andy Wingo <wingo@pobox.com> | 2012-03-07 10:27:16 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2012-03-07 10:27:16 +0100 |
commit | 9d381ba4788b4d447acd3238c2fc8b86da4998b2 (patch) | |
tree | 5fd37ed1b9d73a20dbfadce6c4681bba8f05c75e /libguile/eval.c | |
parent | 3c12fc359561aedb179a524667ba03481333f482 (diff) | |
download | guile-9d381ba4788b4d447acd3238c2fc8b86da4998b2.tar.gz |
dynstack: pushing a prompt no longer allocates memory
* libguile/control.h: Remove scm_t_prompt_registers and
scm_c_make_prompt_registers.
(scm_c_abort): Take a pointer to a jmpbuf instead of a cookie. It
will serve the same purpose.
* libguile/control.c (reify_partial_continuation, scm_at_abort): Adapt
to new prompt representation.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_prompt): Prompts now have 5
words instead of 2, as they now push the fp, sp, ip, and jmpbuf on the
stack separately. This avoids allocation.
(scm_dynstack_find_prompt): Likewise, add return values for fp, sp,
etc.
(scm_dynstack_wind_prompt): Replaces scm_dynstack_relocate_prompt.
* libguile/eval.c (eval):
* libguile/stacks.c (find_prompt):
* libguile/throw.c (pre_init_catch): Adapt to the new prompt mechanism.
* libguile/vm-engine.c (vm_engine): Setjmp an on-stack jmpbuf every time
the VM enters. We can then re-use that jmpbuf for all prompts in that
invocation.
* libguile/vm-i-system.c (partial_cont_call): Adapt to change in prompt
representation. We don't need to wind here any more, since we pass in
the prompt's jmpbuf.
(prompt): Adapt to scm_dynstack_push_prompt change.
(abort): Adapt to vm_abort change.
* libguile/vm.h (struct scm_vm): No more cookie.
* libguile/vm.c (vm_abort): Adapt to scm_c_abort change.
(vm_reinstate_partial_continuation): Rewind the dynamic stack here,
now that we do have a valid jmpbuf.
(make_vm): No need to initialize a cookie.
Diffstat (limited to 'libguile/eval.c')
-rw-r--r-- | libguile/eval.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/libguile/eval.c b/libguile/eval.c index 142d20abf..d7ab5627f 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -438,8 +438,7 @@ eval (SCM x, SCM env) case SCM_M_PROMPT: { SCM vm, k, res; - scm_t_dynstack_prompt_flags flags; - scm_t_prompt_registers *regs; + scm_i_jmp_buf registers; /* We need the handler after nonlocal return to the setjmp, so make sure it is volatile. */ volatile SCM handler; @@ -449,15 +448,15 @@ eval (SCM x, SCM env) vm = scm_the_vm (); /* Push the prompt onto the dynamic stack. */ - regs = scm_c_make_prompt_registers (SCM_VM_DATA (vm)->fp, - SCM_VM_DATA (vm)->sp, - SCM_VM_DATA (vm)->ip, - -1); - flags = SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY; scm_dynstack_push_prompt (&SCM_I_CURRENT_THREAD->dynstack, - flags, k, regs); - - if (SCM_I_SETJMP (regs->regs)) + SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY, + k, + SCM_VM_DATA (vm)->fp, + SCM_VM_DATA (vm)->sp, + SCM_VM_DATA (vm)->ip, + ®isters); + + if (SCM_I_SETJMP (registers)) { /* The prompt exited nonlocally. */ proc = handler; |