From: Simon Helsen <helsen@informatik.uni-freiburg.de>
To: Andrew Kennedy <akenn@microsoft.com>
Cc: "'Markus Mottl'" <mottl@miss.wu-wien.ac.at>, caml-list@inria.fr
Subject: RE: optimization and purity
Date: Fri, 23 Jul 1999 19:49:48 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.3.96.990723192317.1838M-100000@punaluu.informatik.uni-freiburg.de> (raw)
In-Reply-To: <7CD674FF54FBD21181D800805F57CD5488B073@RED-MSG-44>
Hi,
>You are indeed correct that knowing the purity of functions would permit a
>number of optimisations such as the loop-hoisting example you present. There
>was quite a bit of work on "effect inference" a few years back, though much
>of it had a different motivation, namely to permit more expressions to be
>given polymorphic types in the let construct (e.g. in the current revision
>of Standard ML -- sorry I don't know the situation for CAML -- the
>expression let val x = rev [] in (1::x, true::x) end is ill-typed even
>though it would be sound to assign it the obvious type). I believe that the
indeed, there used to be a semantic-based approach to figure out about
polymorphic references (using imperative variables), but they did not say
anything about the purity of a function. Moreover, the scheme was
difficult to use and hence abandoned (see earlier discussions on this list
and comp.lang.ml - subject value polymorphism)
>MLj compiler, of which I am a developer, is the only ML compiler that
>currently performs type-based effect inference and uses the results to
>optimise code (I'd be happy to be contradicted here!). At present we have a
It depends on how you view it. The ML Kit also performs a region/type
based effect analysis, but to implement compile-time garbage collection.
I don't know if they use it to perform low-level optimisations
However, quite related to compilation is partial evaluation (or program
specialisation). There you can use an effect analysis to classify more
program parts as static, i.e. executable at partial evaluation time.
Indeed, such a technique has been incorporated in the PGG system, a
partial evaluator for the full Scheme language
(http://www.informatik.uni-freiburg.de/proglang/software/pgg/). It is the
only PE system (of which I know of) which uses such a type-based effect
analysis to specialize impure code at partial evaluation time. In fact, we
are now exploring new opportunities in Region/Effect analysis to produce a
powerful partial evaluator for (Standard - sorry) ML.
>Note that the problem with many effect analyses of the past is that they
>didn't consider termination. This is unfortunate, for you need to know
>whether or not something might loop to use (for example) the first two of
>the rewrites above. However, it's very hard to do a good job of inferring
>termination behaviour -- in MLj, we basically assume that any recursive
>function might loop. Notice also that recursion (and hence looping) can get
>in by the back door -- two well-known routes are via recursive types and via
The problem of termination is equally there in partial evaluation. In PE
this issue is treated separately from impurity though, as it may occur in
pure code as well. Moreover, as you indicate, it is substantially more
difficult. In general, a partial evaluator guarantees to preserve
the semantics (including termination behaviour). What it usually does not
guarantee is to terminate itself. This is something where PE departs from
standard compilation and that may have consequences to what level of
optimisations you can put through. In fact, a PE system can be considered
an aggresive program optimizer which performs function unfolding and
aggressive constant propagation.
cheers,
Simon
next prev parent reply other threads:[~1999-07-23 21:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-23 15:48 Andrew Kennedy
1999-07-23 17:49 ` Simon Helsen [this message]
1999-07-23 21:37 ` Pierre Weis
1999-07-24 12:45 ` John Skaller
-- strict thread matches above, loose matches on Subject: below --
1999-07-18 18:57 Markus Mottl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.3.96.990723192317.1838M-100000@punaluu.informatik.uni-freiburg.de \
--to=helsen@informatik.uni-freiburg.de \
--cc=akenn@microsoft.com \
--cc=caml-list@inria.fr \
--cc=mottl@miss.wu-wien.ac.at \
--cc=shelsen@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox