guile-commits
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]