Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit03d67e5

Browse files
jackpappasKevinRansom
jackpappas
authored andcommitted
Applied the [<Literal>] attribute to some values within opt.fs so that when it is itself compiled and optimized, the compiler may be better able to perform dead-code elimination and also eliminate some field accesses.
1 parent4f18868 commit03d67e5

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

‎src/fsharp/opt.fs‎

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,24 @@ open Microsoft.FSharp.Compiler.Infos
3636

3737
openSystem.Collections.Generic
3838

39-
40-
41-
letverboseOptimizationInfo=
4239
#if BUILDING_PROTO
40+
letverboseOptimizationInfo=
4341
trynot(System.String.IsNullOrEmpty(System.Environment.GetEnvironmentVariable"FSHARP_verboseOptimizationInfo"))with_->false
44-
#else
45-
false
46-
#endif
4742
letverboseOptimizations=
48-
#if BUILDING_PROTO
4943
trynot(System.String.IsNullOrEmpty(System.Environment.GetEnvironmentVariable"FSHARP_verboseOptimizations"))with_->false
5044
#else
51-
false
45+
let [<Literal>]verboseOptimizationInfo=false
46+
let [<Literal>]verboseOptimizations=false
5247
#endif
5348

5449
leti_ldlen=[ I_ldlen;(AI_conv DT_I4)]
5550

56-
letcallSize=1// size of a function call
57-
letforAndWhileLoopSize=5// size of a for/while loop
58-
lettryCatchSize=5// size of a try/catch
59-
lettryFinallySize=5// size of a try/finally
60-
letclosureTotalSize=10// Total cost of a closure. Each closure adds a class definition
61-
letmethodDefnTotalSize=1// Total cost of a method definition
51+
let[<Literal>]callSize=1// size of a function call
52+
let[<Literal>]forAndWhileLoopSize=5// size of a for/while loop
53+
let[<Literal>]tryCatchSize=5// size of a try/catch
54+
let[<Literal>]tryFinallySize=5// size of a try/finally
55+
let[<Literal>]closureTotalSize=10// Total cost of a closure. Each closure adds a class definition
56+
let[<Literal>]methodDefnTotalSize=1// Total cost of a method definition
6257

6358
//-------------------------------------------------------------------------
6459
// Partial information about an expression.
@@ -244,9 +239,9 @@ let BoundValueInfoBySize vinfo =
244239
// What we know about the world
245240
//-------------------------------------------------------------------------
246241

247-
letjitOptDefault=true
248-
letlocalOptDefault=true
249-
letcrossModuleOptDefault=true
242+
let[<Literal>]jitOptDefault=true
243+
let[<Literal>]localOptDefault=true
244+
let[<Literal>]crossModuleOptDefault=true
250245

251246
typeOptimizationSettings=
252247
{ abstractBigTargets:bool;
@@ -933,7 +928,7 @@ let mkAssemblyCodeValueInfo g instrs argvals tys =
933928
// Size constants and combinators
934929
//-------------------------------------------------------------------------
935930

936-
letlocalVarSize=1
931+
let[<Literal>]localVarSize=1
937932

938933
let recAddTotalSizesAux acc l=match lwith[]-> acc| h::t-> AddTotalSizesAux(h.TotalSize+ acc) t
939934
letAddTotalSizes l= AddTotalSizesAux0 l
@@ -1209,7 +1204,7 @@ let AbstractAndRemapModulInfo msg g m (repackage,hidden) info =
12091204
//-------------------------------------------------------------------------
12101205

12111206
// Mark some variables (the ones we introduce via abstractBigTargets) as don't-eliminate
1212-
letsuffixForVariablesThatMayNotBeEliminated="$cont"
1207+
let[<Literal>]suffixForVariablesThatMayNotBeEliminated="$cont"
12131208

12141209
/// Type applications of F# "type functions" may cause side effects, e.g.
12151210
/// let x<'a> = printfn "hello"; typeof<'a>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp