1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +02:00

Better compilation of calls to raise-exception

Recognize `raise-exception` in the same way we recognize `throw`, though
it is a bit less optimized and the boot story is not as complicated.

* doc/ref/vm.texi (Non-Local Control Flow Instructions):
* libguile/jit.c (compile_unreachable):
(compile_unreachable_slow):
* libguile/vm-engine.c (VM_NAME):
* module/language/cps/compile-bytecode.scm (compile-function):
* module/system/vm/assembler.scm (emit-unreachable): Add new
"unreachable" instruction, inserted after a call to non-continuable
`raise-exception`.
* module/language/tree-il/compile-cps.scm (raise-exception):
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Recognize raise-exception, and if it is
called with just one argument, prune that branch of the control-flow
graph.
This commit is contained in:
Andy Wingo 2023-08-28 12:03:17 +02:00
parent a52c9cf7c3
commit c2cba86785
8 changed files with 67 additions and 8 deletions

View file

@ -1,4 +1,4 @@
/* Copyright 2001,2009-2015,2017-2021
/* Copyright 2001,2009-2015,2017-2021,2023
Free Software Foundation, Inc.
This file is part of Guile.
@ -3478,7 +3478,17 @@ VM_NAME (scm_thread *thread)
NEXT (4);
}
VM_DEFINE_OP (167, unused_167, NULL, NOP)
/* unreachable _:24
*
* Abort the process. Guile's compiler emits these bytecodes where it
* knows that control cannot continue, for example after a call to
* non-continuing `raise-exception'.
*/
VM_DEFINE_OP (167, unreachable, "unreachable", OP1 (X32))
{
abort (); /* never reached */
}
VM_DEFINE_OP (168, unused_168, NULL, NOP)
VM_DEFINE_OP (169, unused_169, NULL, NOP)
VM_DEFINE_OP (170, unused_170, NULL, NOP)