OCamlPro / flambda-task-force

13 stars 1 forks source link

Disentangle function declarations and sets of closures #128

Open mshinwell opened 8 years ago

mshinwell commented 8 years ago

At the moment we end up generating lots of duplicate functions (e.g. partial application wrappers that get duplicated by inlining). The code for these functions is the same up to alpha, but they are often closed over different external variables.

One way of dealing with this would be to introduce a new constant_defining_value (call it Code) that holds function bodies and parameters, etc. Then the Set_of_closures constructor (for constant_defining_value only) would take a different type that references the relevant function bodies. Inline_and_simplify would then need changing to record whether any change had been made to the input expression, in order to not create duplicate Code construtions.

Something like this may be worth doing before 4.03. I think I could do it fairly quickly.

mshinwell commented 8 years ago

I will try to do this for toplevel closures if possible before 4.03.

mshinwell commented 8 years ago

(For non-constant closures difficulties include having the wrong names in the code when looking through a particular set of closures; and ensuring that closure layouts are identical)