[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 26/26: Allow abort_to_prompt to avoid a longjmp
From: |
Andy Wingo |
Subject: |
[Guile-commits] 26/26: Allow abort_to_prompt to avoid a longjmp |
Date: |
Tue, 26 Jun 2018 11:26:15 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 51e71a473f8ff114522a1b6fa054bdebeefb0575
Author: Andy Wingo <address@hidden>
Date: Tue Jun 26 17:16:19 2018 +0200
Allow abort_to_prompt to avoid a longjmp
* libguile/vm-engine.c (abort):
* libguile/vm.c (abort_to_prompt): Allow fallthrough if longjmp isn't
needed.
---
libguile/vm-engine.c | 8 ++++++--
libguile/vm.c | 10 +++++-----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 7fc5499..71b3dfd 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -788,8 +788,12 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int
resume)
SYNC_IP ();
scm_vm_intrinsics.abort_to_prompt (thread, registers);
- /* vm_abort should not return */
- abort ();
+ /* If abort_to_prompt returned, that means there were no
+ intervening C frames to jump over, so we just continue
+ directly. */
+ CACHE_REGISTER ();
+ ABORT_CONTINUATION_HOOK ();
+ NEXT (0);
}
/* builtin-ref dst:12 idx:12
diff --git a/libguile/vm.c b/libguile/vm.c
index 0d424ec..4504099 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -1403,11 +1403,11 @@ abort_to_prompt (scm_thread *thread, jmp_buf
*current_registers)
vp->sp = sp;
vp->ip = ip;
- /* Jump! */
- longjmp (*registers, 1);
-
- /* Shouldn't get here */
- abort ();
+ /* If there are intervening C frames, then jump over them, making a
+ nonlocal exit. Otherwise fall through and let the VM pick up where
+ it left off. */
+ if (current_registers != registers)
+ longjmp (*registers, 1);
}
SCM
- [Guile-commits] 17/26: Foreign-call intrinsic boxes errno, (continued)
- [Guile-commits] 17/26: Foreign-call intrinsic boxes errno, Andy Wingo, 2018/06/26
- [Guile-commits] 25/26: Optimize abort-to-prompt to avoid alloca, Andy Wingo, 2018/06/26
- [Guile-commits] 15/26: Most header files use forward decl for union scm_vm_stack_element, Andy Wingo, 2018/06/26
- [Guile-commits] 14/26: Add intrinsic for foreign-call, Andy Wingo, 2018/06/26
- [Guile-commits] 11/26: Move VM keyword argument parsing to happen via an intrinsic, Andy Wingo, 2018/06/26
- [Guile-commits] 22/26: Add rest-arg-length intrinsic., Andy Wingo, 2018/06/26
- [Guile-commits] 16/26: Reinstating undelimited continuations uses intrinsic, Andy Wingo, 2018/06/26
- [Guile-commits] 24/26: Refactors to abort-to-prompt implementation, Andy Wingo, 2018/06/26
- [Guile-commits] 12/26: Add push-interrupt-frame VM intrinsic, Andy Wingo, 2018/06/26
- [Guile-commits] 13/26: Give multiple-values objects a tc7, Andy Wingo, 2018/06/26
- [Guile-commits] 26/26: Allow abort_to_prompt to avoid a longjmp,
Andy Wingo <=
- [Guile-commits] 21/26: compose-continuation uses an intrinsic, Andy Wingo, 2018/06/26
- [Guile-commits] 23/26: abort-to-prompt uses an intrinsic, Andy Wingo, 2018/06/26
- [Guile-commits] 19/26: Rename scm_i_thread to scm_thread, Andy Wingo, 2018/06/26
- [Guile-commits] 02/26: Replace uses of scm_t_int8, scm_t_uintmax, etc with stdint types, Andy Wingo, 2018/06/26