@@ -2480,40 +2480,40 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel =
24802480
24812481 // Generate laterArgs (for effects) and save
24822482 LocalScope " callstack" cgbuf ( fun scopeMarks ->
2483- let whereSaved , eenv =
2484- ( eenv, laterArgs) ||> List.mapFold ( fun eenv laterArg ->
2485- // Only save arguments that have effects
2486- if Optimizer.ExprHasEffect cenv.g laterArg then
2487- let ilTy = laterArg |> tyOfExpr cenv.g |> GenType cenv.amap m cenv.g eenv.tyenv
2488- let loc , eenv = AllocLocal cenv cgbuf eenv true ( ilxgenGlobalNng.FreshCompilerGeneratedName ( " arg" , m), ilTy) scopeMarks
2489- GenExpr cenv cgbuf eenv SPSuppress laterArg Continue
2490- EmitSetLocal cgbuf loc
2491- Choice1Of2 ( ilTy, loc), eenv
2492- else
2493- Choice2Of2 laterArg, eenv)
2494-
2495- let nargs = mspec.FormalArgTypes.Length
2496- CG.EmitInstr cgbuf ( pop ( nargs + ( if mspec.CallingConv.IsStatic || newobj then 0 else 1 )))
2497- ( if mustGenerateUnitAfterCall || isSuperInit || isSelfInit then Push0 else ( Push [( GenType cenv.amap m cenv.g eenv.tyenv actualRetTy)])) callInstr;
2498-
2499- // For isSuperInit, load the 'this' pointer as the pretend 'result' of the operation. It will be popped again in most cases
2500- if isSuperInit then CG.EmitInstrs cgbuf ( pop 0 ) ( Push [ mspec.EnclosingType]) [ mkLdarg0 ] ;
2501-
2502- // When generating debug code, generate a 'nop' after a 'call' that returns 'void'
2503- // This is what C# does, as it allows the call location to be maintained correctly in the stack frame
2504- if cenv.opts.generateDebugSymbols && mustGenerateUnitAfterCall && ( isTailCall = Normalcall) then
2505- CG.EmitInstrs cgbuf ( pop 0 ) Push0 [ AI_ nop ] ;
2506-
2507- if isNil laterArgs then
2508- assert isNil whereSaved
2509- // Generate the "unit" value if necessary
2510- CommitCallSequel cenv eenv m eenv.cloc cgbuf mustGenerateUnitAfterCall sequel
2511- else
2512- //printfn "%d EXTRA ARGS IN TOP APP at %s" laterArgs.Length (stringOfRange m)
2513- whereSaved |> List.iter ( function
2514- | Choice1Of2 ( ilTy, loc) -> EmitGetLocal cgbuf ilTy loc
2515- | Choice2Of2 expr -> GenExpr cenv cgbuf eenv SPSuppress expr Continue)
2516- GenIndirectCall cenv cgbuf eenv ( actualRetTy,[], laterArgs, m) sequel)
2483+ let whereSaved , eenv =
2484+ ( eenv, laterArgs) ||> List.mapFold ( fun eenv laterArg ->
2485+ // Only save arguments that have effects
2486+ if Optimizer.ExprHasEffect cenv.g laterArg then
2487+ let ilTy = laterArg |> tyOfExpr cenv.g |> GenType cenv.amap m cenv.g eenv.tyenv
2488+ let loc , eenv = AllocLocal cenv cgbuf eenv true ( ilxgenGlobalNng.FreshCompilerGeneratedName ( " arg" , m), ilTy) scopeMarks
2489+ GenExpr cenv cgbuf eenv SPSuppress laterArg Continue
2490+ EmitSetLocal cgbuf loc
2491+ Choice1Of2 ( ilTy, loc), eenv
2492+ else
2493+ Choice2Of2 laterArg, eenv)
2494+
2495+ let nargs = mspec.FormalArgTypes.Length
2496+ CG.EmitInstr cgbuf ( pop ( nargs + ( if mspec.CallingConv.IsStatic || newobj then 0 else 1 )))
2497+ ( if mustGenerateUnitAfterCall || isSuperInit || isSelfInit then Push0 else ( Push [( GenType cenv.amap m cenv.g eenv.tyenv actualRetTy)])) callInstr;
2498+
2499+ // For isSuperInit, load the 'this' pointer as the pretend 'result' of the operation. It will be popped again in most cases
2500+ if isSuperInit then CG.EmitInstrs cgbuf ( pop 0 ) ( Push [ mspec.EnclosingType]) [ mkLdarg0 ] ;
2501+
2502+ // When generating debug code, generate a 'nop' after a 'call' that returns 'void'
2503+ // This is what C# does, as it allows the call location to be maintained correctly in the stack frame
2504+ if cenv.opts.generateDebugSymbols && mustGenerateUnitAfterCall && ( isTailCall = Normalcall) then
2505+ CG.EmitInstrs cgbuf ( pop 0 ) Push0 [ AI_ nop ]
2506+
2507+ if isNil laterArgs then
2508+ assert isNil whereSaved
2509+ // Generate the "unit" value if necessary
2510+ CommitCallSequel cenv eenv m eenv.cloc cgbuf mustGenerateUnitAfterCall sequel
2511+ else
2512+ //printfn "%d EXTRA ARGS IN TOP APP at %s" laterArgs.Length (stringOfRange m)
2513+ whereSaved |> List.iter ( function
2514+ | Choice1Of2 ( ilTy, loc) -> EmitGetLocal cgbuf ilTy loc
2515+ | Choice2Of2 expr -> GenExpr cenv cgbuf eenv SPSuppress expr Continue)
2516+ GenIndirectCall cenv cgbuf eenv ( actualRetTy,[], laterArgs, m) sequel)
25172517
25182518 | _ -> failwith " ??"
25192519
0 commit comments