F # Compiler Questions

A few questions about the F # compiler

1) What does --noframework do? I compiled with it, but I still need .Net 4.0 (I thought maybe this allowed the port for an earlier version?) Does it remove the F # dependency?

2) What optimizers activate F # --optimize +? All of them? if so, what are all of them?

3) What are the advantages / disadvantages of --tailcall? I know that x64 sometimes ignored .tailcall, I was curious if there are other problems or if these problems persist.

4) What is -crossoptimize and what does it do?

5) is there really a quick sublanguage or is something really old?

+4
source share
2 answers

Here are some quick answers based on memory. (For more information, you can contact the compiler for help.)

1) It allows you to configure different frameworks without trying to implicitly use any mscorlib / FSharp.Core assemblies. This way you use this when, for example, you explicitly reference Silverlight mscorlib / FSharp.Core for the target Silverlight.

2) Yes, almost all of them, and I do not know what it is. You can look at opt.fs.

3) Debugging - when using VS in the "Debugging" --tailcalls- , --tailcalls- is transmitted to disable tailcalls and save all frames of the stack to simplify debugging.

4) FSharp can perform embedding and other optimizations at assembly boundaries. This can be dangerous for published libraries, because if A links B and A were compiled using crossoptimize and then deployed and then someone changes / redeploys B, perhaps A will “call” the method in the “old” B because it is the code from B that was inserted into and therefore A still has the code of the “old B” if A is not recompiled. This is rarely the case in practice, but a “typical” scenario, if you have several dependent, but independently distributed F # libraries, you want to disable crossoptimize to get rid of fragile dependencies.

5) It no longer exists.

+5
source

Here is a more detailed answer to question 2. The F # compiler has many optimization options, and -optimize + allows most of them.

Reading from the compiler source, here is a list of things --optimize + enable. I also give you hidden flags if you want to play with them. Of course, since it is not hidden and not documented, this may change in the next version:

  • JIT optimization (--jit-optimize)
  • local optimizations (--local-optimize), such as eliminating dead closed bindings.
  • cross-module optimization (--crossoptimize +)
  • allow you to embed lambda functions (- by default: 6). Large functions larger than the specified three hundred will not be nested.
  • sets ignoreSymbolStoreSequencePoints (there is no flag for this)
  • exclude tuples allocated on call sites due to idle functions (-detuple: 1). See detuple.fs for more details.
  • do TLR (--tlr: 1). I do not know what it is, but there are many comments in tlr.fs
  • final simplify pass (-finalSimplify: 1) applies some of the optimizations a second time (after going through other optimizations).

It seems that the --extraoptimizationloops: 1 flag is not enabled --optimize +. It performs the same optimization as the final simplified pass, but at a different time. May be useless.

For question 3, tail call optimization is very useful for prevention (when you make many tail recursive calls). This complicates debugging, so sometimes you can turn it off (this is the default value in VS, in debug mode).

+7
source

Source: https://habr.com/ru/post/1347040/


All Articles