Skip to content

Commit ce50c16

Browse files
committed
temp
1 parent 460b7f7 commit ce50c16

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs

+21-16
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ module Pass1_DetermineTLRAndArities =
196196
let arity = Operators.min nFormals nMaxApplied
197197
if atTopLevel then
198198
Some (f, arity)
199-
elif g.realsig then
200-
None
199+
//elif g.realsig then
200+
// None
201201
else if arity<>0 || not (isNil tps) then
202202
Some (f, arity)
203203
else
@@ -217,28 +217,32 @@ module Pass1_DetermineTLRAndArities =
217217

218218
let DetermineTLRAndArities g expr =
219219
let xinfo = GetUsageInfoOfImplFile g expr
220-
let fArities = Zmap.chooseL (SelectTLRVals g xinfo) xinfo.Defns
221-
let fArities = List.filter (fst >> IsValueRecursionFree xinfo) fArities
222-
// Do not TLR v if it is bound under a shouldinline defn
223-
// There is simply no point - the original value will be duplicated and TLR'd anyway
224-
let rejectS = GetValsBoundUnderShouldInline xinfo
225-
let fArities = List.filter (fun (v, _) -> not (Zset.contains v rejectS)) fArities
226-
(*-*)
227-
let tlrS = Zset.ofList valOrder (List.map fst fArities)
228-
let topValS = xinfo.TopLevelBindings (* genuinely top level *)
229-
let topValS = Zset.filter (IsMandatoryNonTopLevel g >> not) topValS (* restrict *)
220+
let rejects = GetValsBoundUnderShouldInline xinfo
221+
let fArities =
222+
xinfo.Defns
223+
|> Zmap.chooseL (SelectTLRVals g xinfo)
224+
|> List.filter (fst >> IsValueRecursionFree xinfo)
225+
// Do not TLR v if it is bound under a shouldinline defn
226+
// There is simply no point - the original value will be duplicated and TLR'd anyway
227+
|> List.filter (fun (v, _) -> not (Zset.contains v rejects))
228+
229+
let tlrs = Zset.ofList valOrder (List.map fst fArities)
230+
let topVals =
231+
xinfo.TopLevelBindings // genuinely top level *)
232+
|> Zset.filter (IsMandatoryNonTopLevel g >> not) // restrict
233+
230234
#if DEBUG
231235
(* REPORT MISSED CASES *)
232236
if verboseTLR then
233-
let missed = Zset.diff xinfo.TopLevelBindings tlrS
237+
let missed = Zset.diff xinfo.TopLevelBindings tlrs
234238
missed |> Zset.iter (fun v -> dprintf "TopLevel but not TLR = %s\n" v.LogicalName)
235239
(* REPORT OVER *)
236240
#endif
237241
let arityM = Zmap.ofList valOrder fArities
238242
#if DEBUG
239243
if verboseTLR then DumpArity arityM
240244
#endif
241-
tlrS, topValS, arityM
245+
tlrs, topVals, arityM
242246

243247
(* NOTES:
244248
For constants,
@@ -760,7 +764,6 @@ let FlatEnvPacks g fclassM topValS declist (reqdItemsMap: Zmap<BindingGroupShari
760764
let aenvExprFor v = exprForVal env.m (aenvFor v)
761765

762766
// build PackedReqdItems
763-
let reqdTypars = env.reqdTypars
764767
let aenvs = Zmap.values cmap
765768
let pack = cmapPairs |> List.map (fun (v, aenv) -> mkInvisibleBind aenv (exprForVal env.m v))
766769
let unpack =
@@ -785,7 +788,7 @@ let FlatEnvPacks g fclassM topValS declist (reqdItemsMap: Zmap<BindingGroupShari
785788
dprintf "tlr: packEnv unpack =%s\n" (showL (listL bindingL unpack))
786789

787790
// result
788-
(fc, { ep_etps = Zset.elements reqdTypars
791+
(fc, { ep_etps = [] //Zset.elements env.reqdTypars
789792
ep_aenvs = aenvs
790793
ep_pack = pack
791794
ep_unpack = unpack}), carrierMaps
@@ -996,6 +999,7 @@ module Pass4_RewriteAssembly =
996999
fBind
9971000

9981001
let fHatNewBinding (shortRecBinds: Bindings) (TBind(f, b, letSeqPtOpt)) =
1002+
printfn $"fHatNewBinding: f:{f} b:{b}"
9991003
let wf = Zmap.force f penv.arityM ("fHatNewBinding - arityM", nameOfVal)
10001004
let fHat = Zmap.force f penv.fHatM ("fHatNewBinding - fHatM", nameOfVal)
10011005

@@ -1092,6 +1096,7 @@ module Pass4_RewriteAssembly =
10921096
/// At free vals, fixup 0-call if it is an arity-met constant.
10931097
/// Other cases rewrite structurally.
10941098
let rec TransExpr (penv: RewriteContext) (z: RewriteState) expr: Expr * RewriteState =
1099+
10951100
penv.stackGuard.Guard <| fun () ->
10961101

10971102
match expr with

0 commit comments

Comments
 (0)