1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 01:30:27 +02:00

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.
This commit is contained in:
Andy Wingo 2015-10-18 22:59:23 +02:00
parent 8f027385db
commit 72353de77d
3 changed files with 12 additions and 55 deletions

View file

@ -309,8 +309,6 @@ SCM_DEFINE (scm_frame_return_address, "frame-return-address", 1, 0, 0,
}
#undef FUNC_NAME
#define RELOC(kind, frame, val) ((val) + frame_offset (kind, frame))
SCM_DEFINE (scm_frame_dynamic_link, "frame-dynamic-link", 1, 0, 0,
(SCM frame),
"")
@ -320,8 +318,7 @@ SCM_DEFINE (scm_frame_dynamic_link, "frame-dynamic-link", 1, 0, 0,
/* fixme: munge fp if holder is a continuation */
return scm_from_uintptr_t
((scm_t_uintptr)
RELOC (SCM_VM_FRAME_KIND (frame), SCM_VM_FRAME_DATA (frame),
SCM_FRAME_DYNAMIC_LINK (SCM_VM_FRAME_FP (frame))));
SCM_FRAME_DYNAMIC_LINK (SCM_VM_FRAME_FP (frame)));
}
#undef FUNC_NAME
@ -339,12 +336,7 @@ scm_c_frame_previous (enum scm_vm_frame_kind kind, struct scm_frame *frame)
new_fp = SCM_FRAME_DYNAMIC_LINK (this_fp);
if (!new_fp)
return 0;
new_fp = RELOC (kind, frame, new_fp);
if (new_fp > stack_top)
if (new_fp >= stack_top)
return 0;
new_sp = SCM_FRAME_PREVIOUS_SP (this_fp);