summaryrefslogtreecommitdiff
path: root/libguile/dynstack.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-02-12 18:22:44 +0100
committerAndy Wingo <wingo@pobox.com>2017-02-12 20:31:14 +0100
commit00ed4043c258b35d9200b9be3070c24355e46b63 (patch)
tree332112a2bbd70ef49c11e708d99dfc9c49e55da1 /libguile/dynstack.c
parent5048a8afbc00e3e0a65a5d2ffccfec666ec5a68b (diff)
downloadguile-00ed4043c258b35d9200b9be3070c24355e46b63.tar.gz
VM continuations store FP/SP by offset
* libguile/continuations.c (scm_i_continuation_to_frame): * libguile/stacks.c (scm_make_stack): * libguile/vm.c (scm_i_vm_cont_to_frame, scm_i_vm_capture_stack): (vm_return_to_continuation_inner) (struct vm_reinstate_partial_continuation_data): (vm_reinstate_partial_continuation_inner): (vm_reinstate_partial_continuation): * libguile/vm.h (sstruct scm_vm_cont): Simplify VM continuations by recording the top FP by offset, not value + reloc. * libguile/frames.c (frame_offset, scm_i_vm_frame_offset): Remove unused functions. * libguile/frames.h (SCM_VALIDATE_VM_FRAME, scm_i_vm_frame_offset): Remove. * libguile/control.c (reify_partial_continuation): Once we know the base_fp, relocate the dynamic stack. * libguile/dynstack.h: * libguile/dynstack.c (scm_dynstack_relocate_prompts): New function. (scm_dynstack_wind_prompt): Adapt to add new fp offset.
Diffstat (limited to 'libguile/dynstack.c')
-rw-r--r--libguile/dynstack.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/libguile/dynstack.c b/libguile/dynstack.c
index 1eb1dcf38..7448a9ab5 100644
--- a/libguile/dynstack.c
+++ b/libguile/dynstack.c
@@ -37,7 +37,9 @@
#define PROMPT_WORDS 5
#define PROMPT_KEY(top) (SCM_PACK ((top)[0]))
#define PROMPT_FP(top) ((scm_t_ptrdiff) ((top)[1]))
+#define SET_PROMPT_FP(top, fp) do { top[1] = (scm_t_bits)(fp); } while (0)
#define PROMPT_SP(top) ((scm_t_ptrdiff) ((top)[2]))
+#define SET_PROMPT_SP(top, sp) do { top[2] = (scm_t_bits)(sp); } while (0)
#define PROMPT_IP(top) ((scm_t_uint32 *) ((top)[3]))
#define PROMPT_JMPBUF(top) ((scm_i_jmp_buf *) ((top)[4]))
@@ -288,6 +290,24 @@ scm_dynstack_capture (scm_t_dynstack *dynstack, scm_t_bits *item)
}
void
+scm_dynstack_relocate_prompts (scm_t_dynstack *dynstack, scm_t_ptrdiff base)
+{
+ scm_t_bits *walk;
+
+ /* Relocate prompts. */
+ for (walk = dynstack->top; walk; walk = SCM_DYNSTACK_PREV (walk))
+ {
+ scm_t_bits tag = SCM_DYNSTACK_TAG (walk);
+
+ if (SCM_DYNSTACK_TAG_TYPE (tag) == SCM_DYNSTACK_TYPE_PROMPT)
+ {
+ SET_PROMPT_FP (walk, PROMPT_FP (walk) - base);
+ SET_PROMPT_SP (walk, PROMPT_SP (walk) - base);
+ }
+ }
+}
+
+void
scm_dynstack_wind_1 (scm_t_dynstack *dynstack, scm_t_bits *item)
{
scm_t_bits tag = SCM_DYNSTACK_TAG (item);
@@ -556,7 +576,8 @@ scm_dynstack_find_old_fluid_value (scm_t_dynstack *dynstack, SCM fluid,
void
scm_dynstack_wind_prompt (scm_t_dynstack *dynstack, scm_t_bits *item,
- scm_t_ptrdiff reloc, scm_i_jmp_buf *registers)
+ scm_t_ptrdiff base_fp_offset,
+ scm_i_jmp_buf *registers)
{
scm_t_bits tag = SCM_DYNSTACK_TAG (item);
@@ -566,8 +587,8 @@ scm_dynstack_wind_prompt (scm_t_dynstack *dynstack, scm_t_bits *item,
scm_dynstack_push_prompt (dynstack,
SCM_DYNSTACK_TAG_FLAGS (tag),
PROMPT_KEY (item),
- PROMPT_FP (item) - reloc,
- PROMPT_SP (item) - reloc,
+ PROMPT_FP (item) + base_fp_offset,
+ PROMPT_SP (item) + base_fp_offset,
PROMPT_IP (item),
registers);
}