Skip to content

Commit

Permalink
Inline-expand with-exception-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
shirok committed Nov 30, 2024
1 parent 52e4d9a commit b31ae01
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
2024-11-29 Shiro Kawai <shiro@acm.org>

* 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:
Expand Down
11 changes: 11 additions & 0 deletions src/compile-i.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/libalpha.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b31ae01

Please sign in to comment.