Lines Matching refs:function

136         (* This transforms the body of a "small" recursive function replacing any reference
142 | repEntry(Eval { function = Extract LoadRecursive, argList, resultType }) =
160 (* If we have a tail recursive function we can replace the tail calls
187 (* If we have a small recursive function where some arguments are passed
198 (* This is the argument from the outer function. It is either added
199 to the closure or passed to the inner function. *)
221 function = Extract LoadRecursive, argList = l, resultType = t
223 isInline = DontInline, (* Don't inline this function. *)
231 function = subFunction,
238 (* If the function arguments are used in a way that could be optimised the
307 (* If we have an argument that is a curried function we
343 there isn't (unless the function is actually polymorphic). *)
365 (* If the result is just a function where all the arguments are simple
379 In the case of the function body we can check that the body does
381 function arguments we have to check how it is applied. *)
386 if the function is ever applied to a tuple. This is rather different
389 arguments within the function. *)
407 (* If the result of a function contains a tuple but it is not detupled on
436 (* If the usage indicates that the body of the function should be transformed
442 (* The function returns a tuple or at least the uses of the function take apart a tuple.
453 (* The main function performs the previous computation but puts the result into
481 (* The shim function creates a container, passes it to the main function and then
487 function = Extract(LoadClosure 0),
506 (* We need to construct an inline "shim" function that
508 calls the transformed main function.
510 main function. That needs, for example, to unpack tuples
513 function. This needs, for example, to pack the arguments
532 (* It's a function that returns a tuple. The function must not be curried because
533 otherwise it returns a function not a tuple. *)
574 is only safe if the function is applied immediately to all the arguments.
579 (* We have a function that takes a series of curried argument.
580 Change that so that the function takes a list of arguments. *)
582 (* In the main function we are expecting to call the argument in a curried
583 fashion. We need to construct a function that packages up the
589 (* We're ready to call the function. We now need to unpack any
612 Eval { function = Extract(hd fnclosure), resultType = GeneralType,
619 Eval { function = Extract(hd fnclosure), resultType = GeneralType,
650 (* In the shim function, i.e. the inline function outside, we have
651 a lambda that will be called when the main function wants to
652 call its argument function. This is provided with all the arguments
666 Eval{function=c, resultType = GeneralType, argList=args})
675 If the function is returning a tuple we have an extra argument for
713 (* The argument types for the main function have the tuples expanded, Functions
735 Eval { function = Extract(LoadClosure 0), argList = transArgs, resultType = resultType }
740 (* TODO: We have two copies of the shim function here. *)
759 (* The main function calls the original body as a function. The body
776 Eval{ function = transBody, resultType = subResultType,
787 (* The inner shim closure contains the main function and the outer arguments. *)
790 function = Extract(LoadClosure 0),
792 (* Calls main function with both sets of args. *)
846 (* Immediate call to a function. We may be able to expand this inline unless it
848 | optimise (context, use) (Eval {function = Lambda lambda, argList, resultType}) =
853 val call = Eval { function=newLambda, argList=args, resultType = resultType }
858 | optimise (context as { reprocess, ...}, use) (Eval {function = Cond(i, t, e), argList, resultType}) =
862 (* We duplicate the function arguments which could cause the size of the code
865 mapCodetree (optimise(context, use)) (Eval{function=l, argList=argList, resultType=resultType})
871 | optimise (context, use) (Eval {function, argList, resultType}) =
873 the function and arguments and we don't simply pass the original. *)
880 function= mapCodetree (optimise (context, [UseApply(use, argTuples)])) function,
915 1. A lambda that simply calls another function with all its own arguments
916 can be replaced by a reference to the function provided the "function"
920 an argument is a function with tupled or curried arguments into a pair
921 of an inline function with the original argument set and a new "main"
922 function with register/stack arguments.
925 (* The overall use of the function is the context plus the recursive use. *)
927 (* Check if it's a call to another function with all the original arguments.
929 another function and really only when we have produced a shim function
930 that has been inline expanded. Otherwise this will be a "small" function
934 (Eval { function, argList, resultType=callresult }, false) =>
948 case function of
949 (* This could be any function which has neither side-effects nor
953 in simple cases that arise as a result of using a "shim" function
1004 inside an inline function). *)
1029 (* See if it should be transformed. We only do this if the function is not going
1032 inlining we may not actually call the function and instead pass it as an
1035 function anyway. *)
1043 (* The function is always called with at least two curried arguments.
1044 We can decurry the function if the body is applicative - typically
1049 a body that is a lambda. The result is a function and therefore
1065 (* The function is always applied at least to the first set of arguments.
1066 (It's never just passed). Merge the applications of the function
1068 function unless the function takes apart a tuple but no
1091 if the function was exported. This caused an infinite loop
1108 (* Function has an arg that is a function that returns a tuple.
1109 It must not be curried otherwise it returns a function not a tuple. *)
1112 (* Function has an arg that is a curried function. *)
1114 (* Function has an arg that is a function that
1235 closure the free variables have to remain on the stack until the function returns. *)
1241 then be inserted directly in references to the function. In general