diff options
-rw-r--r-- | bytecomp/bytegen.ml | 18 | ||||
-rw-r--r-- | bytecomp/translcore.ml | 2 |
2 files changed, 9 insertions, 11 deletions
diff --git a/bytecomp/bytegen.ml b/bytecomp/bytegen.ml index 8052c8446..f2b2956b0 100644 --- a/bytecomp/bytegen.ml +++ b/bytecomp/bytegen.ml @@ -98,18 +98,14 @@ let add_const_unit = function (**** Auxiliary for compiling "let rec" ****) let rec size_of_lambda = function - Lfunction(kind, params, body) as funct -> + | Lfunction(kind, params, body) as funct -> 1 + IdentSet.cardinal(free_variables funct) - | Lprim(Pmakeblock(tag, mut), args) -> - List.length args - | Lprim(Pmakearray kind, args) -> - List.length args - | Llet(str, id, arg, body) -> - size_of_lambda body - | Lletrec(bindings, body) -> - size_of_lambda body - | _ -> - fatal_error "Bytegen.size_of_lambda" + | Lprim(Pmakeblock(tag, mut), args) -> List.length args + | Lprim(Pmakearray kind, args) -> List.length args + | Llet(str, id, arg, body) -> size_of_lambda body + | Lletrec(bindings, body) -> size_of_lambda body + | Levent (lam, _) -> size_of_lambda lam + | _ -> fatal_error "Bytegen.size_of_lambda" (**** Compilation of a lambda expression ****) diff --git a/bytecomp/translcore.ml b/bytecomp/translcore.ml index be890b39f..cf2b78820 100644 --- a/bytecomp/translcore.ml +++ b/bytecomp/translcore.ml @@ -260,6 +260,7 @@ let check_recursive_lambda idlist lam = | Llet(str, id, arg, body) -> check arg & check_top body | Lletrec(bindings, body) -> List.for_all (fun (id, arg) -> check arg) bindings & check_top body + | Levent (lam, _) -> check_top lam | _ -> false and check = function Lvar _ -> true @@ -270,6 +271,7 @@ let check_recursive_lambda idlist lam = List.for_all (fun (id, arg) -> check arg) bindings & check body | Lprim(Pmakeblock(tag, mut), args) -> List.for_all check args | Lprim(Pmakearray kind, args) -> List.for_all check args + | Levent (lam, _) -> check lam | lam -> let fv = free_variables lam in List.for_all (fun id -> not(IdentSet.mem id fv)) idlist |