summaryrefslogtreecommitdiff
path: root/libguile/continuations.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2014-04-14 16:31:02 +0200
committerAndy Wingo <wingo@pobox.com>2014-04-14 16:31:02 +0200
commit3b14dd2f272920854565011d82b41df1237a2213 (patch)
treee336aaa9e7865db533ac003a8193c377b9aa6436 /libguile/continuations.c
parent8de051da47e8f0f56a13bde6a4b37ece5f9c81cf (diff)
downloadguile-3b14dd2f272920854565011d82b41df1237a2213.tar.gz
Optimize make-stack
* libguile/continuations.h: * libguile/continuations.c (scm_i_continuation_to_frame): Operate on low-level C structures instead of heap objects. * libguile/frames.h: * libguile/frames.c (frame_offset, frame_stack_base): Const args. (scm_c_frame_closure): New helper. (scm_frame_procedure): Use the new helper. * libguile/stacks.c (stack_depth, narrow_stack, scm_make_stack): Rework to avoid allocating frames as we traverse the stack, and to avoid an n**2 case where there are outer cuts.
Diffstat (limited to 'libguile/continuations.c')
-rw-r--r--libguile/continuations.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/libguile/continuations.c b/libguile/continuations.c
index 62a9b7f1a..8dca62e2d 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -168,8 +168,8 @@ scm_i_make_continuation (int *first, struct scm_vm *vp, SCM vm_cont)
}
#undef FUNC_NAME
-SCM
-scm_i_continuation_to_frame (SCM continuation)
+int
+scm_i_continuation_to_frame (SCM continuation, struct scm_frame *frame)
{
SCM contregs;
scm_t_contregs *cont;
@@ -179,18 +179,17 @@ scm_i_continuation_to_frame (SCM continuation)
if (scm_is_true (cont->vm_cont))
{
- struct scm_frame frame;
struct scm_vm_cont *data = SCM_VM_CONT_DATA (cont->vm_cont);
- frame.stack_holder = data;
- frame.fp_offset = (data->fp + data->reloc) - data->stack_base;
- frame.sp_offset = (data->sp + data->reloc) - data->stack_base;
- frame.ip = data->ra;
+ frame->stack_holder = data;
+ frame->fp_offset = (data->fp + data->reloc) - data->stack_base;
+ frame->sp_offset = (data->sp + data->reloc) - data->stack_base;
+ frame->ip = data->ra;
- return scm_c_make_frame (SCM_VM_FRAME_KIND_CONT, &frame);
+ return 1;
}
else
- return SCM_BOOL_F;
+ return 0;
}
struct scm_vm *