diff options
author | Andy Wingo <wingo@pobox.com> | 2015-10-18 22:59:23 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2015-10-21 11:49:20 +0200 |
commit | 72353de77d0a06f158d8af66a2540015658e2574 (patch) | |
tree | 01347b554843ae90551d63f5240e21dce8b57072 /libguile/vm.c | |
parent | 8f027385db228d68193ad7316cf0b79489ac038b (diff) | |
download | guile-72353de77d0a06f158d8af66a2540015658e2574.tar.gz |
Replace dynamic link on stack with previous frame size
* libguile/frames.h (SCM_FRAME_DYNAMIC_LINK)
(SCM_FRAME_SET_DYNAMIC_LINK): Instead of storing the absolute value of
the previous FP, store its offset from the current FP. This allows us
to avoid relinking when composing continuations or when relocating the
stack.
* libguile/frames.c (scm_frame_dynamic_link, scm_c_frame_previous): No
need to relocate the dynamic link.
* libguile/vm.c (vm_return_to_continuation_inner):
(vm_reinstate_partial_continuation_inner, vm_expand_stack_inner):
Don't relocate the frame pointer chain.
(scm_i_vm_mark_stack): Terminate when FP is above stack_top, not when
0.
(make_vm): Init FP to stack_top.
Diffstat (limited to 'libguile/vm.c')
-rw-r--r-- | libguile/vm.c | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/libguile/vm.c b/libguile/vm.c index bc9f29080..2db079550 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -179,21 +179,6 @@ vm_return_to_continuation_inner (void *data_ptr) cp->stack_size * sizeof (*cp->stack_bottom)); vm_restore_sp (vp, vp->stack_top - cp->stack_size); - if (reloc) - { - union scm_vm_stack_element *fp = vp->fp; - while (fp) - { - union scm_vm_stack_element *next_fp = SCM_FRAME_DYNAMIC_LINK (fp); - if (next_fp) - { - next_fp += reloc; - SCM_FRAME_SET_DYNAMIC_LINK (fp, next_fp); - } - fp = next_fp; - } - } - return NULL; } @@ -385,13 +370,6 @@ vm_reinstate_partial_continuation_inner (void *data_ptr) vp->fp = cp->fp + reloc; vp->ip = cp->ra; - /* now relocate frame pointers */ - { - union scm_vm_stack_element *fp; - for (fp = vp->fp; fp < base_fp; fp = SCM_FRAME_DYNAMIC_LINK (fp)) - SCM_FRAME_SET_DYNAMIC_LINK (fp, SCM_FRAME_DYNAMIC_LINK (fp) + reloc); - } - data->reloc = reloc; return NULL; @@ -876,7 +854,7 @@ make_vm (void) vp->ip = NULL; vp->sp = vp->stack_top; vp->sp_min_since_gc = vp->sp; - vp->fp = NULL; + vp->fp = vp->stack_top; vp->engine = vm_default_engine; vp->trace_level = 0; for (i = 0; i < SCM_VM_NUM_HOOKS; i++) @@ -967,7 +945,9 @@ scm_i_vm_mark_stack (struct scm_vm *vp, struct GC_ms_entry *mark_stack_ptr, memset (&cache, 0, sizeof (cache)); - for (fp = vp->fp, sp = vp->sp; fp; fp = SCM_FRAME_DYNAMIC_LINK (fp)) + for (fp = vp->fp, sp = vp->sp; + fp < vp->stack_top; + fp = SCM_FRAME_DYNAMIC_LINK (fp)) { scm_t_ptrdiff nlocals = SCM_FRAME_NUM_LOCALS (fp, sp); size_t slot = nlocals - 1; @@ -1047,24 +1027,9 @@ vm_expand_stack_inner (void *data_ptr) vp->stack_limit = vp->stack_bottom; reloc = vp->stack_top - old_top; - if (reloc) - { - union scm_vm_stack_element *fp; - if (vp->fp) - vp->fp += reloc; - data->new_sp += reloc; - fp = vp->fp; - while (fp) - { - union scm_vm_stack_element *next_fp = SCM_FRAME_DYNAMIC_LINK (fp); - if (next_fp) - { - next_fp += reloc; - SCM_FRAME_SET_DYNAMIC_LINK (fp, next_fp); - } - fp = next_fp; - } - } + if (vp->fp) + vp->fp += reloc; + data->new_sp += reloc; return new_bottom; } |