[mercury-users] threading states

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jul 27 15:52:52 AEST 2000


On 26-Jul-2000, Michael Day <mcda at students.cs.mu.oz.au> wrote:
> 
> If an argument similar to io:state is threaded through code to ensure a
> particular order of operation, can the passing and copying of this
> argument be optimised away completely if the state is a "unit" type?
> 
> :- type state ---> state.
> 
> :- pred transform(args ... , state, state).
> :- mode transform(modes ... , di, uo) is det.
> 
> Can the compiler optimise away the state argument altogether?

For abstract types, doing such optimizations is difficult in the
presence of separate compilation.  But for the case where the state
type is not an abstract type, there is no reason why the compiler
couldn't do that.

However the current compiler does not do so.
The old LLDS-based back-end does not optimize such types at all
(except for code using the C interface).
The new MLDS-based back-end optimizes away the passing of
`io__state' and `store__store(S)', but it does not do so
for user-defined unit types.

But even without optimizing them away, the cost of such arguments is
very small.  The main reason that we haven't bothered optimizing them
away is that we haven't found any important programs for which it
would make a significant difference.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list