/* Unwind once more, beyond the prompt. */
winds = SCM_CDR (winds), delta++;
-
+
/* Unwind */
scm_dowinds (winds, delta);
+ /* Unwinding may have changed the current thread's VM, so use the
+ new one. */
+ vm = scm_the_vm ();
+
/* Restore VM regs */
SCM_VM_DATA (vm)->fp = SCM_PROMPT_REGISTERS (prompt)->fp;
SCM_VM_DATA (vm)->sp = SCM_PROMPT_REGISTERS (prompt)->sp;
(define-module (test-suite test-control)
#:use-module (ice-9 control)
+ #:use-module (system vm vm)
#:use-module (srfi srfi-11)
#:use-module (test-suite lib))
(with-test-prefix "abort to unknown prompt"
(pass-if-exception "foo" '(misc-error . "^Abort to unknown prompt")
(abort-to-prompt 'does-not-exist)))
+
+(with-test-prefix "the-vm"
+
+ (pass-if "unwind changes VMs"
+ (let ((new-vm (make-vm))
+ (prev-vm (the-vm))
+ (proc (lambda (x y)
+ (expt x y)))
+ (call (lambda (p x y)
+ (p x y))))
+ (catch 'foo
+ (lambda ()
+ (dynamic-wind
+ (lambda ()
+ (set-thread-vm! (current-thread) new-vm))
+ (lambda ()
+ (vm-apply new-vm
+ (lambda () (throw 'foo (the-vm)))
+ '()))
+ (lambda ()
+ (set-thread-vm! (current-thread) prev-vm))))
+ (lambda (key vm)
+ (and (eq? key 'foo)
+ (eq? vm new-vm)
+ (eq? (the-vm) prev-vm)))))))