summaryrefslogtreecommitdiff
path: root/libguile/frames.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-11-15 17:13:10 +0100
committerAndy Wingo <wingo@pobox.com>2013-11-15 17:13:27 +0100
commitf8085163d6c457e79d3f54934723707260ac8dd8 (patch)
treeedc28ec3fd02c183a92894ab4124831f4f36e80b /libguile/frames.c
parent840ec33422e7ccae5ac158584e5587d88ff42d85 (diff)
downloadguile-f8085163d6c457e79d3f54934723707260ac8dd8.tar.gz
Remove MVRA from VM frames
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for frame layout change. * libguile/frames.c: Update some static checks. (scm_frame_num_locals, scm_frame_local_ref, scm_frame_local_set_x): Update to not skip over uninitialized frames, as that's not a thing any more. * libguile/frames.h: Update to remove MVRA. Woo! * libguile/vm-engine.c (ALLOC_FRAME, RETURN_ONE_VALUE): (rtl_vm_engine): Update for 3 words per frame instead of 4. * libguile/vm.c (vm_return_to_continuation): Likewise. * module/language/cps/slot-allocation.scm (allocate-slots): 3 words per frame, not 4. * module/system/vm/assembler.scm (*bytecode-minor-version*): Bump. Also remove a couple of tc7's that aren't around any more.
Diffstat (limited to 'libguile/frames.c')
-rw-r--r--libguile/frames.c50
1 files changed, 10 insertions, 40 deletions
diff --git a/libguile/frames.c b/libguile/frames.c
index 979468e75..5ba600bd6 100644
--- a/libguile/frames.c
+++ b/libguile/frames.c
@@ -28,7 +28,7 @@
/* Make sure assumptions on the layout of `struct scm_vm_frame' hold. */
verify (sizeof (SCM) == sizeof (SCM *));
-verify (sizeof (struct scm_vm_frame) == 5 * sizeof (SCM));
+verify (sizeof (struct scm_vm_frame) == 4 * sizeof (SCM));
verify (offsetof (struct scm_vm_frame, dynamic_link) == 0);
@@ -110,39 +110,28 @@ SCM_DEFINE (scm_frame_source, "frame-source", 1, 0, 0,
}
#undef FUNC_NAME
-/* The number of locals would be a simple thing to compute, if it weren't for
- the presence of not-yet-active frames on the stack. So we have a cheap
- heuristic to detect not-yet-active frames, and skip over them. Perhaps we
- should represent them more usefully.
-*/
SCM_DEFINE (scm_frame_num_locals, "frame-num-locals", 1, 0, 0,
(SCM frame),
"")
#define FUNC_NAME s_scm_frame_num_locals
{
SCM *sp, *p;
- unsigned int n = 0;
SCM_VALIDATE_VM_FRAME (1, frame);
sp = SCM_VM_FRAME_SP (frame);
p = SCM_FRAME_STACK_ADDRESS (SCM_VM_FRAME_FP (frame));
- /* The frame size of an RTL program is fixed, except in the case of
- passing a wrong number of arguments to the program. So we do
- need to use an SP for determining the number of locals. */
return scm_from_ptrdiff_t (sp + 1 - p);
}
#undef FUNC_NAME
-/* Need same not-yet-active frame logic here as in frame-num-locals */
SCM_DEFINE (scm_frame_local_ref, "frame-local-ref", 2, 0, 0,
(SCM frame, SCM index),
"")
#define FUNC_NAME s_scm_frame_local_ref
{
SCM *sp, *p;
- unsigned int n = 0;
unsigned int i;
SCM_VALIDATE_VM_FRAME (1, frame);
@@ -150,19 +139,10 @@ SCM_DEFINE (scm_frame_local_ref, "frame-local-ref", 2, 0, 0,
sp = SCM_VM_FRAME_SP (frame);
p = SCM_FRAME_STACK_ADDRESS (SCM_VM_FRAME_FP (frame));
- while (p <= sp)
- {
- if (SCM_UNPACK (p[0]) == 0)
- /* skip over not-yet-active frame */
- p += 3;
- else if (n == i)
- return *p;
- else
- {
- p++;
- n++;
- }
- }
+
+ if (p + i <= sp)
+ return SCM_FRAME_VARIABLE (SCM_VM_FRAME_FP (frame), i);
+
SCM_OUT_OF_RANGE (SCM_ARG2, index);
}
#undef FUNC_NAME
@@ -174,7 +154,6 @@ SCM_DEFINE (scm_frame_local_set_x, "frame-local-set!", 3, 0, 0,
#define FUNC_NAME s_scm_frame_local_set_x
{
SCM *sp, *p;
- unsigned int n = 0;
unsigned int i;
SCM_VALIDATE_VM_FRAME (1, frame);
@@ -182,22 +161,13 @@ SCM_DEFINE (scm_frame_local_set_x, "frame-local-set!", 3, 0, 0,
sp = SCM_VM_FRAME_SP (frame);
p = SCM_FRAME_STACK_ADDRESS (SCM_VM_FRAME_FP (frame));
- while (p <= sp)
+
+ if (p + i <= sp)
{
- if (SCM_UNPACK (p[0]) == 0)
- /* skip over not-yet-active frame */
- p += 3;
- else if (n == i)
- {
- *p = val;
- return SCM_UNSPECIFIED;
- }
- else
- {
- p++;
- n++;
- }
+ SCM_FRAME_VARIABLE (SCM_VM_FRAME_FP (frame), i) = val;
+ return SCM_UNSPECIFIED;
}
+
SCM_OUT_OF_RANGE (SCM_ARG2, index);
}
#undef FUNC_NAME