diff --git a/ChangeLog b/ChangeLog index 00c296926..275544af3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2024-11-29 Shiro Kawai + * src/compile-i.scm (with-exception-handler): Inline expand + it to $DYNENV IForm when the body is a literal lambda. + This speeds up a lot. + https://github.com/shirok/Gauche/issues/1083 + * src/compile*.scm: Additional work to enhance $DYNENV. * src/Makefile.in, src/core.c, lib/gauche/version-alist.scm: diff --git a/src/compile-i.scm b/src/compile-i.scm index 6ca396c2d..7c949c416 100644 --- a/src/compile-i.scm +++ b/src/compile-i.scm @@ -290,6 +290,17 @@ [() ($asm src `(,CURERR) '())] [else (undefined)]))) +(define-builtin-inliner with-exception-handler + (^[src args] + (match args + [(handler (? (cut has-tag? <> $LAMBDA) lmda)) + ($dynenv src + (list ($call #f ($gref %exception-handler-mark-key.) '()) + handler + '(push)) + ($lambda-body lmda))] + [else (undefined)]))) + (define-builtin-inliner dynamic-wind (^[src args] (match args diff --git a/src/libalpha.scm b/src/libalpha.scm index 165b86747..5a0993a0f 100644 --- a/src/libalpha.scm +++ b/src/libalpha.scm @@ -50,6 +50,8 @@ (select-module gauche.internal) (define-cproc %expression-name-mark-key () (return (Scm__GetDenvKey SCM_DENV_KEY_EXPRESSION_NAME))) +(define-cproc %exception-handler-mark-key () + (return (Scm__GetDenvKey SCM_DENV_KEY_EXCEPTION_HANDLER))) ;;; ;;; errors