[cvs-nhc98] patch applied (hat): Added the
application-of-function-of-known-arity optimisation to Hat.
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Tue Oct 10 07:23:23 EDT 2006
Thu Jan 16 06:31:36 PST 2003 olaf
* Added the application-of-function-of-known-arity optimisation to Hat.
If a function of known arity n is applied to n arguments, then instead of the apn/uapn combinators the new appn/uappn combinators are used (0 < n <= 5). If function and application are trusted, then even only a uWrapForward combinator is used. All these combinators do not use the wrapper of a function, but directly the worker. Thus time for some wrapping and unwrapping is saved.
With optimisation the same *.hat file is produced as without. A speedup of 15-20% was measured for adjoxo edgecorner1.in and mate ellerman.
A hack is used to avoid ambiguous type variables in the transformed program: a type declaration of a function is transformed into type declarations for the wrapper function. There are no type declarations for worker functions, type inference might yield a rather general type and then direct use of a worker by the new combinators may yield to an ambiguous type variable error. Constructing a type declaration for a worker would be hard; in general it would be necessary to expand type synonyms. Hence the transformation adds a bogus last equation to the worker definition (because of "| False =" it can never be taken) which contains a call of the wrapper. Thus the worker inherits the type of its wrapper.
A worker definition used to be local to its wrapper definition. Because workers may now be called directly, they are now defined in the same scope. The exceptions are class/instance methods, because no additional definitions are allowed there. However, workers of methods are never directly called anyway, because methods do not have a fixed arity.
Corrected that the arity of the predefined function composition (.) had wrongly been set to 2 instead of 3.
M ./src/hatlib/Hat/Hat.hs +87
M ./src/hatlib/PreludeBuiltinTypes.hx -21 +21
M ./src/hattrans/AuxFile.hs -37 +44
M ./src/hattrans/AuxLabelAST.hs -197 +220
M ./src/hattrans/AuxTypes.hs -3 +25
M ./src/hattrans/TraceDerive.hs -1 +3
M ./src/hattrans/TraceId.hs -56 +90
M ./src/hattrans/TraceTrans.hs -80 +133
More information about the Cvs-nhc98
mailing list