summaryrefslogtreecommitdiff
path: root/libguile/frames.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-11-21 11:20:19 +0100
committerAndy Wingo <wingo@pobox.com>2013-11-21 11:20:19 +0100
commit89b235afd34482f2e7d2af553f43d0744895ee83 (patch)
tree520831cc6c7c85e5994bc253e02a4a200fcaef47 /libguile/frames.h
parenteadd9eb4c9f658c9a6081d1b644c7c472d241061 (diff)
Scheme frame objects hold relative stack offsets
* libguile/frames.h: Wrap the C interface to VM frames in BUILDING_LIBGUILE. Change VM frames to record relative offsets into a stack held by some other object, so that if the stack moves they will remain valid. * libguile/frames.c (scm_c_make_frame): Remove offset argument. (scm_i_frame_offset): Instead, compute the offset from the stack holder. (scm_i_frame_stack_base): New helper. (scm_frame_previous): Adapt. * libguile/stacks.c (scm_make_stack) * libguile/vm.c (vm_dispatch_hook): * libguile/continuations.c (scm_i_continuation_to_frame): Adapt.
Diffstat (limited to 'libguile/frames.h')
-rw-r--r--libguile/frames.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/libguile/frames.h b/libguile/frames.h
index d425b9439..bd85b7e89 100644
--- a/libguile/frames.h
+++ b/libguile/frames.h
@@ -136,26 +136,33 @@ struct scm_vm_frame
* Heap frames
*/
+#ifdef BUILDING_LIBGUILE
+
struct scm_frame
{
SCM stack_holder;
- SCM *fp;
- SCM *sp;
+ scm_t_ptrdiff fp_offset;
+ scm_t_ptrdiff sp_offset;
scm_t_uint32 *ip;
- scm_t_ptrdiff offset;
};
#define SCM_VM_FRAME_P(x) (SCM_HAS_TYP7 (x, scm_tc7_frame))
#define SCM_VM_FRAME_DATA(x) ((struct scm_frame*)SCM_CELL_WORD_1 (x))
#define SCM_VM_FRAME_STACK_HOLDER(f) SCM_VM_FRAME_DATA(f)->stack_holder
-#define SCM_VM_FRAME_FP(f) SCM_VM_FRAME_DATA(f)->fp
-#define SCM_VM_FRAME_SP(f) SCM_VM_FRAME_DATA(f)->sp
+#define SCM_VM_FRAME_FP(f) (SCM_VM_FRAME_DATA(f)->fp_offset + scm_i_frame_stack_base(f))
+#define SCM_VM_FRAME_SP(f) (SCM_VM_FRAME_DATA(f)->sp_offset + scm_i_frame_stack_base(f))
#define SCM_VM_FRAME_IP(f) SCM_VM_FRAME_DATA(f)->ip
-#define SCM_VM_FRAME_OFFSET(f) SCM_VM_FRAME_DATA(f)->offset
+#define SCM_VM_FRAME_OFFSET(f) scm_i_frame_offset (f)
#define SCM_VALIDATE_VM_FRAME(p,x) SCM_MAKE_VALIDATE (p, x, VM_FRAME_P)
-SCM_API SCM scm_c_make_frame (SCM stack_holder, SCM *fp, SCM *sp,
- scm_t_uint32 *ip, scm_t_ptrdiff offset);
+SCM_INTERNAL SCM* scm_i_frame_stack_base (SCM frame);
+SCM_INTERNAL scm_t_ptrdiff scm_i_frame_offset (SCM frame);
+
+SCM_INTERNAL SCM scm_c_make_frame (SCM stack_holder, scm_t_ptrdiff fp_offset,
+ scm_t_ptrdiff sp_offset, scm_t_uint32 *ip);
+
+#endif
+
SCM_API SCM scm_frame_p (SCM obj);
SCM_API SCM scm_frame_procedure (SCM frame);
SCM_API SCM scm_frame_arguments (SCM frame);