From 1080fec868a71a3502109d2178718c82ed1e7b69 Mon Sep 17 00:00:00 2001 From: Alain Frisch Date: Mar 10 2014 10:05:02 +0000 Subject: Optimization: if a function doesn't use its environment, one can do as if it it doesn't have any free variables, and its closure can be statically allocated (we could be more precise and remove unused free variables from the closure). git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14453 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- diff --git a/asmcomp/closure.ml b/asmcomp/closure.ml index 51add10..faa3a81 100644 --- a/asmcomp/closure.ml +++ b/asmcomp/closure.ml @@ -864,6 +864,7 @@ and close_functions fenv cenv fun_defs = (* Return the Uclosure node and the list of all identifiers defined, with offsets and approximations. *) let (clos, infos) = List.split clos_info_list in + let fv = if !useless_env then [] else fv in (Uclosure(clos, List.map (close_var fenv cenv) fv), infos) (* Same, for one non-recursive function *)