comparison src/mono_reduce.sml @ 1854:bddd0ec5d3da

Tweak to 'let' inlining behavior
author Adam Chlipala <adam@chlipala.net>
date Sun, 02 Jun 2013 10:17:52 -0400
parents 3c93e91e97da
children 0480b8f29a47
comparison
equal deleted inserted replaced
1853:f405dfe1f1e1 1854:bddd0ec5d3da
562 ("b", MonoPrint.p_exp (E.pushERel env x t NONE) b), 562 ("b", MonoPrint.p_exp (E.pushERel env x t NONE) b),
563 ("r", MonoPrint.p_exp env r)];*) 563 ("r", MonoPrint.p_exp env r)];*)
564 #1 (reduceExp env r) 564 #1 (reduceExp env r)
565 end 565 end
566 566
567 fun trySub () = 567 fun trySub pure =
568 ((*Print.prefaces "trySub" 568 ((*Print.prefaces "trySub"
569 [("e", MonoPrint.p_exp env (e, ErrorMsg.dummySpan))];*) 569 [("e", MonoPrint.p_exp env (e, ErrorMsg.dummySpan))];*)
570 case t of 570 case t of
571 (TFfi ("Basis", "string"), _) => doSub () 571 (TFfi ("Basis", "string"), _) => doSub ()
572 | (TSignal _, _) => e 572 | (TSignal _, _) => e
573 | _ => 573 | _ =>
574 case e' of 574 if pure then
575 (ECase _, _) => e 575 doSub ()
576 | _ => doSub ()) 576 else
577 case e' of
578 (ECase _, _) => e
579 | _ => doSub ())
577 in 580 in
578 if impure env e' then 581 if impure env e' then
579 let 582 let
580 val effs_e' = summarize 0 e' 583 val effs_e' = summarize 0 e'
581 val effs_e' = List.filter (fn x => x <> UseRel) effs_e' 584 val effs_e' = List.filter (fn x => x <> UseRel) effs_e'
626 orelse (case effs_b of 629 orelse (case effs_b of
627 UseRel :: effs => List.all verifyUnused effs 630 UseRel :: effs => List.all verifyUnused effs
628 | _ => false)) 631 | _ => false))
629 andalso countFree 0 0 b = 1 632 andalso countFree 0 0 b = 1
630 andalso not (freeInAbs b) then 633 andalso not (freeInAbs b) then
631 trySub () 634 trySub (List.null effs_e')
632 else 635 else
633 e 636 e
634 end 637 end
635 else if countFree 0 0 b > 1 andalso not (!fullMode) andalso not (passive e') then 638 else if countFree 0 0 b > 1 andalso not (!fullMode) andalso not (passive e') then
636 e 639 e
637 else 640 else
638 trySub () 641 trySub true
639 end 642 end
640 643
641 val r = 644 val r =
642 case e of 645 case e of
643 ERel n => 646 ERel n =>