From c5d8397eb399131837d7205eae3740a033196d66 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 14 Sep 2012 07:35:48 -0400 Subject: Reduce default inlining thresholds; improve a let-substitution optimization to compensate --- src/mono_reduce.sml | 30 ++++++++++++++++++++++++------ src/settings.sml | 4 ++-- 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mono_reduce.sml b/src/mono_reduce.sml index af61489c..c633bfce 100644 --- a/src/mono_reduce.sml +++ b/src/mono_reduce.sml @@ -313,10 +313,28 @@ fun reduce file = val (timpures, impures, absCounts) = foldl (fn ((d, _), (timpures, impures, absCounts)) => let - fun countAbs (e, _) = - case e of - EAbs (_, _, _, e) => 1 + countAbs e - | _ => 0 + fun countAbs env e = + case #1 e of + EAbs (x, t, _, e) => 1 + countAbs (E.pushERel env x t NONE) e + | _ => + let + fun remaining e = + case #1 e of + ENamed n => IM.find (absCounts, n) + | EApp (e, arg) => + if simpleImpure (timpures, impures) env arg then + NONE + else + (case remaining e of + NONE => NONE + | SOME n => if n > 0 then + SOME (n - 1) + else + NONE) + | _ => NONE + in + getOpt (remaining e, 0) + end in case d of DDatatype dts => @@ -335,7 +353,7 @@ fun reduce file = IS.add (impures, n) else impures, - IM.insert (absCounts, n, countAbs e)) + IM.insert (absCounts, n, countAbs E.empty e)) | DValRec vis => (timpures, if List.exists (fn (_, _, _, e, _) => simpleImpure (timpures, impures) E.empty e) vis then @@ -344,7 +362,7 @@ fun reduce file = else impures, foldl (fn ((x, n, _, e, _), absCounts) => - IM.insert (absCounts, n, countAbs e)) + IM.insert (absCounts, n, countAbs E.empty e)) absCounts vis) | _ => (timpures, impures, absCounts) end) diff --git a/src/settings.sml b/src/settings.sml index 45e8640a..6839d39e 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -615,11 +615,11 @@ val sql = ref (NONE : string option) fun setSql so = sql := so fun getSql () = !sql -val coreInline = ref 20 +val coreInline = ref 5 fun setCoreInline n = coreInline := n fun getCoreInline () = !coreInline -val monoInline = ref 100 +val monoInline = ref 5 fun setMonoInline n = monoInline := n fun getMonoInline () = !monoInline -- cgit v1.2.3