@@ -196,8 +196,8 @@ module Pass1_DetermineTLRAndArities =
196
196
let arity = Operators.min nFormals nMaxApplied
197
197
if atTopLevel then
198
198
Some ( f, arity)
199
- elif g.realsig then
200
- None
199
+ // elif g.realsig then
200
+ // None
201
201
else if arity<> 0 || not ( isNil tps) then
202
202
Some ( f, arity)
203
203
else
@@ -217,28 +217,32 @@ module Pass1_DetermineTLRAndArities =
217
217
218
218
let DetermineTLRAndArities g expr =
219
219
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
+
230
234
#if DEBUG
231
235
(* REPORT MISSED CASES *)
232
236
if verboseTLR then
233
- let missed = Zset.diff xinfo.TopLevelBindings tlrS
237
+ let missed = Zset.diff xinfo.TopLevelBindings tlrs
234
238
missed |> Zset.iter ( fun v -> dprintf " TopLevel but not TLR = %s \n " v.LogicalName)
235
239
(* REPORT OVER *)
236
240
#endif
237
241
let arityM = Zmap.ofList valOrder fArities
238
242
#if DEBUG
239
243
if verboseTLR then DumpArity arityM
240
244
#endif
241
- tlrS , topValS , arityM
245
+ tlrs , topVals , arityM
242
246
243
247
(* NOTES:
244
248
For constants,
@@ -760,7 +764,6 @@ let FlatEnvPacks g fclassM topValS declist (reqdItemsMap: Zmap<BindingGroupShari
760
764
let aenvExprFor v = exprForVal env.m ( aenvFor v)
761
765
762
766
// build PackedReqdItems
763
- let reqdTypars = env.reqdTypars
764
767
let aenvs = Zmap.values cmap
765
768
let pack = cmapPairs |> List.map ( fun ( v , aenv ) -> mkInvisibleBind aenv ( exprForVal env.m v))
766
769
let unpack =
@@ -785,7 +788,7 @@ let FlatEnvPacks g fclassM topValS declist (reqdItemsMap: Zmap<BindingGroupShari
785
788
dprintf " tlr: packEnv unpack =%s \n " ( showL ( listL bindingL unpack))
786
789
787
790
// result
788
- ( fc, { ep_ etps = Zset.elements reqdTypars
791
+ ( fc, { ep_ etps = [] // Zset.elements env. reqdTypars
789
792
ep_ aenvs = aenvs
790
793
ep_ pack = pack
791
794
ep_ unpack = unpack}), carrierMaps
@@ -996,6 +999,7 @@ module Pass4_RewriteAssembly =
996
999
fBind
997
1000
998
1001
let fHatNewBinding ( shortRecBinds : Bindings ) ( TBind ( f , b , letSeqPtOpt )) =
1002
+ printfn $" fHatNewBinding: f:{f} b:{b}"
999
1003
let wf = Zmap.force f penv.arityM ( " fHatNewBinding - arityM" , nameOfVal)
1000
1004
let fHat = Zmap.force f penv.fHatM ( " fHatNewBinding - fHatM" , nameOfVal)
1001
1005
@@ -1092,6 +1096,7 @@ module Pass4_RewriteAssembly =
1092
1096
/// At free vals, fixup 0-call if it is an arity-met constant.
1093
1097
/// Other cases rewrite structurally.
1094
1098
let rec TransExpr ( penv : RewriteContext ) ( z : RewriteState ) expr : Expr * RewriteState =
1099
+
1095
1100
penv.stackGuard.Guard <| fun () ->
1096
1101
1097
1102
match expr with
0 commit comments