1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 01:30:27 +02:00

dynamic-wind in terms of wind and unwind; remove <dynwind>, @dynamic-wind

* doc/ref/compiler.texi: Remove mention of <dynwind>.
* libguile/eval.c (eval): Remove SCM_M_DYNWIND case.
* libguile/expand.c: Remove scm_sym_at_dynamic_wind.
* libguile/memoize.c (do_wind, do_unwind): A couple of hacky subrs.  If
  we see a wind or unwind primcall, we expand to a call of a quoted subr
  value.  It works and removes a kind of memoized value from the
  interpreter.  For the compiler,primcalls to wind and unwind are
  handled specially.
  (MAKMEMO_DYNWIND): Remove.
  (scm_tc16_memoizer): Remove.  Yay!
  (memoize): Remove speculative lookup for toplevels to see if they are
  memoizers: there are no more memoizers.  Memoize calls to the wind and
  unwind primitives.
  (m_dynamic_wind): Remove.
  (unmemoize): Remove dynwind case.
  (scm_init_memoize): Add wind and unwind local definitions.

* module/ice-9/boot-9.scm (dynamic-wind): Reimplement in terms of "wind"
  and "unwind" primitives.  These primitives are not exposed to other
  modules.

* module/ice-9/eval.scm (primitive-eval): Remove dynwind case.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynwind cases.

* module/language/tree-il.scm: Remove <dynwind>.  Yaaay!

* module/language/tree-il/analyze.scm (analyze-lexicals): Remove dynwind
  cases.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add wind
  and unwind.
  (flatten-lambda-case): Remove dynwind case.  Yay!

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (singly-valued-expression?, peval):
  Remove <dywind> cases.  Inline primcalls to dynamic-wind.  Add
  constant folding for thunk?.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Remove @dynamic-wind, and add procedure? and thunk?.
  (*effect+exception-free-primitives*): Add procedure? and thunk?.
  (*multiply-valued-primitives*): Remove @dynamic-wind.
  Remove @dynamic-wind expander.

* test-suite/tests/peval.test ("partial evaluation"): Update tests for
  dynwind desugaring.
This commit is contained in:
Andy Wingo 2013-06-27 18:49:21 +02:00
parent 0fcc39a0a9
commit bb97e4abd4
17 changed files with 108 additions and 280 deletions

View file

@ -1070,42 +1070,48 @@
;; the dynwind; alack.
(dynamic-wind foo (lambda () bar) baz)
(let (tmp tmp) (_ _) ((toplevel foo) (toplevel baz))
(seq (call (lexical tmp _))
(let (tmp) (_) ((dynwind (lexical tmp _)
(toplevel bar)
(lexical tmp _)))
(seq (call (lexical tmp _))
(seq (seq (if (primcall thunk? (lexical tmp _))
(call (lexical tmp _))
(primcall scm-error . _))
(primcall wind (lexical tmp _) (lexical tmp _)))
(let (tmp) (_) ((toplevel bar))
(seq (seq (primcall unwind)
(call (lexical tmp _)))
(lexical tmp _))))))
(pass-if-peval
;; Constant guards don't need lexical bindings.
;; Constant guards don't need lexical bindings or thunk? checks.
(dynamic-wind (lambda () foo) (lambda () bar) (lambda () baz))
(seq (toplevel foo)
(let (tmp) (_) ((dynwind (lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel foo))))
(toplevel bar)
(lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel baz))))))
(seq (toplevel baz)
(seq (seq (toplevel foo)
(primcall wind
(lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel foo))))
(lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel baz))))))
(let (tmp) (_) ((toplevel bar))
(seq (seq (primcall unwind)
(toplevel baz))
(lexical tmp _)))))
(pass-if-peval
;; Dynwind bodies that return an unknown number of values need a
;; let-values.
(dynamic-wind (lambda () foo) (lambda () (bar)) (lambda () baz))
(seq (toplevel foo)
(let-values (dynwind (lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel foo))))
(call (toplevel bar))
(lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel baz)))))
(seq (seq (toplevel foo)
(primcall wind
(lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel foo))))
(lambda ()
(lambda-case
((() #f #f #f () ()) (toplevel baz))))))
(let-values (call (toplevel bar))
(lambda-case
((() #f vals #f () (_))
(seq (toplevel baz)
(seq (seq (primcall unwind)
(toplevel baz))
(primcall apply (primitive values) (lexical vals _))))))))
(pass-if-peval