1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00
Commit graph

18 commits

Author SHA1 Message Date
Andy Wingo
863dd87362 Effects analysis distinguishes between struct fields
* module/language/tree-il/effects.scm (compile-time-cond):
  (define-effects): Make the effects analysis more precise,
  distinguishing between different kinds of mutable data.  On 64-bit
  systems we take advantage of the additional bits to be even more
  precise.
  (make-effects-analyzer): Inline handlers for all "accessor" primitives
  and their corresponding mutators.

* module/language/tree-il/peval.scm (peval): Reflow to remove use of the
  "accessor-primitive?" predicate.

* module/language/tree-il/primitives.scm (accessor-primitive?): Remove.
2013-11-10 12:05:35 +01:00
Andy Wingo
a2972c195d Effects analysis sees match-error, throw-bad-structs as bailouts
* module/language/tree-il/effects.scm (make-effects-analyzer): Allow
  module-ref calls to be treated as bailouts, if the procedure has the
  "definite-bailout?" property.  Perhaps this should be renamed.

* module/ice-9/match.upstream.scm (match-error):
* module/srfi/srfi-9.scm (throw-bad-struct): Give these procedures the
  definite-bailout? property.
2013-11-10 10:17:44 +01:00
Andy Wingo
178a40928a <prompt> body and handler are lambdas; add escape-only? field
* module/language/tree-il.scm (<prompt>): Change to have the body and
  handler be lambdas, and add an "escape-only?" field.  This will make
  generic prompts work better in CPS or ANF with the RTL VM, as it
  doesn't make sense in that context to capture only part of a frame.
  Escape-only prompts can still be fully inlined.
  (parse-tree-il, unparse-tree-il): Add escape-only? to the
  serialization.
  (make-tree-il-folder, pre-post-order): Deal with escape-only?.

* module/language/tree-il/analyze.scm (analyze-lexicals): Handle
  escape-only?, and the new expectations for the body and handler.

* module/language/tree-il/canonicalize.scm (canonicalize): Ensure that
  the body of an escape-only continuation is a thunk, and that the
  handler is always a lambda.
* module/language/tree-il/debug.scm (verify-tree-il): Assert that
  escape-only? is a boolean.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
* test-suite/tests/peval.test ("partial evaluation"):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Adapt
  to <prompt> change.
2013-07-06 20:27:21 +09:00
Andy Wingo
c32b7c4cef Remove with-fluids; replaced by with-fluid* and inlined push-fluid primops
* libguile/vm-i-system.c (push-fluid, pop-fluid):
* doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids
  to push-fluid, and unwind-fluids to pop-fluid.  They now only work on
  one fluid binding at a time.

* module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of
  primcalls to push-fluid and pop-fluid.
  (custom-throw-handler, catch, with-throw-handler): Use with-fluid*
  instead of with-fluids, as with-fluids is no longer available before
  psyntax is loaded.
  (with-fluids): Define in Scheme in terms of with-fluid*.

* libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and
  don't expose to Scheme.

* libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case.
* libguile/expand.c (expand_with_fluids): Remove with-fluids syntax.
  (DYNLET): Remove, no longer defining dynlet in the %expanded-vtables.
* libguile/expand.h: Remove dynlet definitions.
* module/ice-9/eval.scm (primitive-eval): Remove with-fluids case.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive
  helpers, like wind and unwind.
  (memoize): Memoize wind and unwind primcalls.  Don't memoize dynlet to
  with-fluids.
  (scm_init_memoize): Initialize push_fluid and pop_fluid here.
* libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition.

* module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported
  with-fluids, which is now defined in boot-9.
* module/ice-9/psyntax-pp.scm: Regenerate.

* doc/ref/compiler.texi (Tree-IL):
* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/canonicalize.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/cse.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/effects.scm: Remove <dynlet>.  Add cases for
  primcalls to push-fluid and pop-fluid in compile-glil.scm and
  effects.scm.

* module/language/tree-il/peval.scm (peval): Factor out
  with-temporaries; probably a bad idea, but works for now.  Factor out
  make-begin0 (a better idea).  Inline primcalls to with-fluid*, and
  remove dynlet cases.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Add with-fluid*.
2013-06-28 19:52:09 +02:00
Andy Wingo
5e0253f19e replace <dynset> with primcalls to fluid-set!
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynset>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynset.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
  (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
  <dynset>.

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

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  fluid-set!.
  (flatten-lambda-case): Remove <dynset> case.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynset>
  cases.

* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
  <dynset> case.  Add a primcall fluid-set! case.

* module/language/tree-il/peval.scm (peval): Remove dynset cases.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove fluid-set! -> dynset transformation.
2013-06-27 22:02:43 +02:00
Andy Wingo
86d0eb31df replace <dynref> with primcalls to fluid-ref
* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynref>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynref.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
  (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
  <dynref>.

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

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  fluid-ref.
  (flatten-lambda-case): Remove <dynref> case.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynref>
  cases.

* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
  <dynref> case.  Add a primcall fluid-ref case.

* module/language/tree-il/peval.scm (peval): Remove dynref cases.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove fluid-ref -> dynref transformation.
2013-06-27 22:02:43 +02:00
Andy Wingo
bb97e4abd4 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.
2013-06-27 22:02:43 +02:00
Andy Wingo
9b965638e9 <dynwind> no longer has "pre" or "post" fields
* module/language/tree-il.scm (<tree-il>): Remove pre and post fields
  from <dynwind>.  A dynwind now assumes that in normal entry and exit,
  that the code runs the winders and unwinders using <seq> and
  <let-values> and such things.
  (parse-tree-il, unparse-tree-il, make-tree-il-folder, pre-post-order):
  Adapt <dynwind> users.

* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
* 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): Adapt.

* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Produce tree-il that calls the winder and unwinder.  Recognize
  singly-valued dynamic-wind expressions.

* test-suite/tests/peval.test ("partial evaluation"): Add tests.
2013-06-16 16:51:28 +02:00
Mark H Weaver
26d148066f Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
	libguile/deprecated.c
	libguile/deprecated.h
	libguile/filesys.h
	libguile/fluids.c
	libguile/fports.c
	libguile/gc.c
	libguile/guile.c
	libguile/numbers.c
	libguile/objcodes.c
	libguile/r6rs-ports.c
	libguile/smob.c
	libguile/socket.c
	libguile/threads.h
	module/language/scheme/decompile-tree-il.scm
	module/language/tree-il/peval.scm
	test-suite/tests/syncase.test
2013-03-28 05:09:53 -04:00
Andy Wingo
19113f1ca7 allow case-lambda expressions with no clauses
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm (case-lambda, case-lambda*): Allow 0
  clauses.

* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names):
* module/language/tree-il.scm (unparse-tree-il):
  (tree-il-fold, post-order!, pre-order!):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/peval.scm (peval): Allow for lambda-body to be
  #f.

* libguile/memoize.c (memoize):
* module/language/tree-il/canonicalize.scm (canonicalize!): Give a body
  to empty case-lambda before evaluating it or compiling it,
  respectively.

* test-suite/tests/optargs.test ("case-lambda", "case-lambda*"): Add
  tests.
2013-03-09 11:16:31 +01:00
Andy Wingo
2aed2667fc Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/expand.c
	libguile/hashtab.c
	libguile/ports.c
	libguile/vectors.c
	libguile/weaks.c
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-07-06 16:52:54 +02:00
Andy Wingo
37081d5d4b fix bugs in effects analysis of "effect+exception-free-primitives"
* module/language/tree-il/effects.scm (make-effects-analyzer): Be more
  precise regarding the effects of the so-called
  effect+exception-free-primitives: now we check their arities.

* test-suite/tests/cse.test ("cse"): Add a test that we don't
  elide (cons 1 2 3) in effect context.
2012-07-05 20:34:28 +02:00
Andy Wingo
74bbb99457 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	module/language/tree-il/analyze.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/cse.test
	test-suite/tests/peval.test
2012-05-21 19:20:27 +02:00
Andy Wingo
83bd53abb6 better effects analysis for calls to lexically bound procedures
* module/language/tree-il/effects.scm (make-effects-analyzer): The
  analyzer will take an optional second argument, a lookup procedure of
  type sym -> exp.  This can let the analyzer dig into calls to
  lexically bound procedures.
2012-05-15 17:22:05 +02:00
Andy Wingo
9d8a10a94c Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	test-suite/tests/cse.test
2012-04-26 23:40:57 +02:00
Andy Wingo
79d29f96c7 Merge commit '1cd63115be'
Conflicts:
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-04-26 23:08:14 +02:00
Andy Wingo
036c366dc2 more inlining in effects.scm
* module/language/tree-il/effects.scm (define-effects)
  (&no-effects, &all-effects-but-bailout):
  (cause, &depends-on, &causes, depends-on-effects?)
  (causes-effects?, effects-commute?): Add ham-fisted inlining.
2012-04-23 21:52:24 +02:00
Andy Wingo
da9b2b71f7 add effects
* module/language/tree-il/effects.scm: New module, for effects
  analysis.
* module/Makefile.am: Adapt.
2012-04-23 21:52:23 +02:00