Skip to content

Commit 4df0e4f

Browse files
committed
fix regression test, starting to add linear match expr handling
1 parent 0a6764a commit 4df0e4f

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/fsharp/IlxGen.fs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,8 +1913,7 @@ let CodeGenThen cenv mgbuf (entryPointInfo, methodName, eenv, alreadyUsedArgs, c
19131913
(* Call the given code generator *)
19141914
codeGenFunction cgbuf { eenv with withinSEH = false
19151915
liveLocals = IntMap.empty()
1916-
innerVals = innerVals
1917-
inLoop = false }
1916+
innerVals = innerVals }
19181917

19191918
let locals, maxStack, lab2pc, code, exnSpecs, hasSequencePoints = cgbuf.Close()
19201919

@@ -2212,6 +2211,15 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel =
22122211
| None ->
22132212

22142213
match expr with
2214+
// Most generation of linear expressions is implemented routinely using tailcalls and the correct sequels.
2215+
// This is because the element of expansion happens to be the final thing generated in most cases. However
2216+
// for large lists we have to process the linearity separately
2217+
| Expr.Sequential _
2218+
| Expr.Let _
2219+
| LinearOpExpr _
2220+
| LinearMatchExpr _ ->
2221+
GenLinearExpr cenv cgbuf eenv sp expr sequel (* canProcessSequencePoint *) false id |> ignore<FakeUnit>
2222+
22152223
| Expr.Const (c, m, ty) ->
22162224
GenConstant cenv cgbuf eenv (c, m, ty) sequel
22172225
| Expr.Match (spBind, exprm, tree, targets, m, ty) ->
@@ -2235,14 +2243,6 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel =
22352243
| Expr.Val (v, _, m) ->
22362244
GenGetVal cenv cgbuf eenv (v, m) sequel
22372245

2238-
// Most generation of linear expressions is implemented routinely using tailcalls and the correct sequels.
2239-
// This is because the element of expansion happens to be the final thing generated in most cases. However
2240-
// for large lists we have to process the linearity separately
2241-
| Expr.Sequential _
2242-
| Expr.Let _
2243-
| LinearOpExpr _ ->
2244-
GenLinearExpr cenv cgbuf eenv sp expr sequel (* canProcessSequencePoint *) false id |> ignore<FakeUnit>
2245-
22462246
| Expr.Op (op, tyargs, args, m) ->
22472247
match op, args, tyargs with
22482248
| TOp.ExnConstr c, _, _ ->
@@ -2555,6 +2555,10 @@ and GenAllocUnionCase cenv cgbuf eenv (c,tyargs,args,m) sequel =
25552555

25562556
and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: FakeUnit -> FakeUnit) =
25572557
let expr = stripExpr expr
2558+
2559+
if canProcessSequencePoint then
2560+
ProcessSequencePointForExpr cenv cgbuf sp expr
2561+
25582562
match expr with
25592563
| LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) ->
25602564
GenExprs cenv cgbuf eenv argsFront
@@ -2564,9 +2568,6 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf:
25642568
Fake))
25652569

25662570
| Expr.Sequential (e1, e2, specialSeqFlag, spSeq, _) ->
2567-
if canProcessSequencePoint then
2568-
ProcessSequencePointForExpr cenv cgbuf sp expr
2569-
25702571
// Compiler generated sequential executions result in suppressions of sequence points on both
25712572
// left and right of the sequence
25722573
let spAction, spExpr =
@@ -2585,9 +2586,6 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf:
25852586
contf Fake
25862587

25872588
| Expr.Let (bind, body, _, _) ->
2588-
if canProcessSequencePoint then
2589-
ProcessSequencePointForExpr cenv cgbuf sp expr
2590-
25912589
// This case implemented here to get a guaranteed tailcall
25922590
// Make sure we generate the sequence point outside the scope of the variable
25932591
let startScope, endScope as scopeMarks = StartDelayedLocalScope "let" cgbuf
@@ -2609,6 +2607,11 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf:
26092607
// Generate the body
26102608
GenLinearExpr cenv cgbuf eenv spBody body (EndLocalScope(sequel, endScope)) (* canProcessSequencePoint *) true contf
26112609

2610+
| LinearMatchExpr (spBind, exprm, tree, tg1, e2, spTg2, m, ty) ->
2611+
GenMatch cenv cgbuf eenv (spBind, exprm, tree, [|tg1;TTarget([], e2, spTg2)|], m, ty) sequel
2612+
contf Fake
2613+
//| Expr.Match (spBind, exprm, tree, targets, m, ty) ->
2614+
// GenMatch cenv cgbuf eenv (spBind, exprm, tree, targets, m, ty) sequel
26122615
| _ ->
26132616
GenExpr cenv cgbuf eenv sp expr sequel
26142617
contf Fake

0 commit comments

Comments
 (0)