The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #14368 from stedolan/simplif-under-lambda-fix

Avoid substituting under letrec lambdas in Simplif

authored by

Gabriel Scherer and committed by
GitHub
5f9cb866 5bdf43c6

+30 -3
+4
Changes
··· 1189 1189 - #14287: Bugfix for GC root mishandling in memprof.c 1190 1190 (Stephen Dolan, review by Leo White) 1191 1191 1192 + - #14368: Bugfix for Simplif substituting under lambda 1193 + (Stephen Dolan, review by Vincent Laviron 1194 + and Gabriel Scherer) 1195 + 1192 1196 OCaml 5.3.0 (8 January 2025) 1193 1197 ---------------------------- 1194 1198
+6 -3
lambda/simplif.ml
··· 417 417 end 418 418 | _ -> no_opt () 419 419 end 420 - | Lfunction {body} -> 421 - count Ident.Map.empty body 420 + | Lfunction fn -> 421 + count_lfunction fn 422 422 | Llet(_str, _k, v, Lvar w, l2) when optimize -> 423 423 (* v will be replaced by w in l2, so each occurrence of v in l2 424 424 increases w's refcount *) ··· 432 432 count bv l1; 433 433 count bv l2 434 434 | Lletrec(bindings, body) -> 435 - List.iter (fun { def } -> count bv def.body) bindings; 435 + List.iter (fun { def } -> count_lfunction def) bindings; 436 436 count bv body 437 437 | Lprim(_p, ll, _) -> List.iter (count bv) ll 438 438 | Lswitch(l, sw, _loc) -> ··· 467 467 | Levent(l, _) -> count bv l 468 468 | Lifused(v, l) -> 469 469 if count_var v > 0 then count bv l 470 + 471 + and count_lfunction fn = 472 + count Ident.Map.empty fn.body 470 473 471 474 and count_default bv sw = match sw.sw_failaction with 472 475 | None -> ()
+18
testsuite/tests/basic-more/simplif_under_lambda.ml
··· 1 + (* TEST *) 2 + 3 + let f () = 4 + let junk = ref 42 in 5 + Gc.finalise_last (fun () -> print_endline "collected") junk; 6 + let tuple = Sys.opaque_identity (junk, "ok") in 7 + match tuple with 8 + | _, ok -> 9 + let rec loop () = 10 + print_endline ok; 11 + if false then loop () 12 + in 13 + loop 14 + 15 + let () = 16 + let fn = f () in 17 + Gc.full_major (); 18 + fn ()
+2
testsuite/tests/basic-more/simplif_under_lambda.reference
··· 1 + collected 2 + ok