Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to release/dev16.9 #10236

Merged
merged 2 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,23 @@ type ResolveDependenciesResult (success: bool, stdOut: string array, stdError: s
/// The resolution error log (* process stderror *)
member _.StdError = stdError

/// The resolution paths
/// The resolution paths - the full paths to selected resolved dll's.
/// In scripts this is equivalent to #r @"c:\somepath\to\packages\ResolvedPackage\1.1.1\lib\netstandard2.0\ResolvedAssembly.dll"
member _.Resolutions = resolutions

/// The source code file paths
member _.SourceFiles = sourceFiles

/// The roots to package directories
/// This points to the root of each located package.
/// The layout of the package manager will be package manager specific.
/// however, the dependency manager dll understands the nuget package layout
/// and so if the package contains folders similar to the nuget layout then
/// the dependency manager will be able to probe and resolve any native dependencies
/// required by the nuget package.
///
/// This path is also equivalent to
/// #I @"c:\somepath\to\packages\ResolvedPackage\1.1.1\"
member _.Roots = roots

[<DependencyManagerAttribute>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ type ResolveDependenciesResult =
/// The resolution error log (process stderr)
member StdError: string[]

/// The resolution paths
/// The resolution paths - the full paths to selected resolved dll's.
/// In scripts this is equivalent to #r @"c:\somepath\to\packages\ResolvedPackage\1.1.1\lib\netstandard2.0\ResolvedAssembly.dll"
member Resolutions: seq<string>

/// The source code file paths
member SourceFiles: seq<string>

/// The roots to package directories
/// This points to the root of each located package.
/// The layout of the package manager will be package manager specific.
/// however, the dependency manager dll understands the nuget package layout
/// and so if the package contains folders similar to the nuget layout then
/// the dependency manager will be able to probe and resolve any native dependencies
/// required by the nuget package.
///
/// This path is also equivant to
/// #I @"c:\somepath\to\packages\ResolvedPackage\1.1.1\"
member Roots: seq<string>

[<DependencyManagerAttribute>]
Expand Down
10 changes: 5 additions & 5 deletions src/fsharp/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ let rec FirstEmittedCodeWillBeDebugPoint g sp expr =
| DebugPointAtSequential.StmtOnly -> true
| DebugPointAtSequential.ExprOnly -> false
| Expr.Match (DebugPointAtBinding _, _, _, _, _, _) -> true
| Expr.Op ((TOp.TryCatch (DebugPointAtTry.Yes _, _)
| Expr.Op ((TOp.TryWith (DebugPointAtTry.Yes _, _)
| TOp.TryFinally (DebugPointAtTry.Yes _, _)
| TOp.For (DebugPointAtFor.Yes _, _)
| TOp.While (DebugPointAtWhile.Yes _, _)), _, _, _) -> true
Expand Down Expand Up @@ -2184,7 +2184,7 @@ let EmitDebugPointForWholeExpr g sp expr =
// So since the 'let tmp = expr' has a sequence point, then no sequence point is needed for the 'match'. But the processing
// of the 'let' requests SPAlways for the body.
| Expr.Match _ -> false
| Expr.Op (TOp.TryCatch _, _, _, _) -> false
| Expr.Op (TOp.TryWith _, _, _, _) -> false
| Expr.Op (TOp.TryFinally _, _, _, _) -> false
| Expr.Op (TOp.For _, _, _, _) -> false
| Expr.Op (TOp.While _, _, _, _) -> false
Expand Down Expand Up @@ -2375,8 +2375,8 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel =
GenForLoop cenv cgbuf eenv (spStart, v, e1, dir, e2, e3, m) sequel
| TOp.TryFinally (spTry, spFinally), [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)], [resty] ->
GenTryFinally cenv cgbuf eenv (e1, e2, m, resty, spTry, spFinally) sequel
| TOp.TryCatch (spTry, spWith), [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [vf], ef, _, _);Expr.Lambda (_, _, _, [vh], eh, _, _)], [resty] ->
GenTryCatch cenv cgbuf eenv (e1, vf, ef, vh, eh, m, resty, spTry, spWith) sequel
| TOp.TryWith (spTry, spWith), [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [vf], ef, _, _);Expr.Lambda (_, _, _, [vh], eh, _, _)], [resty] ->
GenTryWith cenv cgbuf eenv (e1, vf, ef, vh, eh, m, resty, spTry, spWith) sequel
| TOp.ILCall (virt, _, valu, newobj, valUseFlags, _, isDllImport, ilMethRef, enclArgTys, methArgTys, returnTys), args, [] ->
GenILCall cenv cgbuf eenv (virt, valu, newobj, valUseFlags, isDllImport, ilMethRef, enclArgTys, methArgTys, args, returnTys, m) sequel
| TOp.RefAddrGet _readonly, [e], [ty] -> GenGetAddrOfRefCellField cenv cgbuf eenv (e, ty, m) sequel
Expand Down Expand Up @@ -3564,7 +3564,7 @@ and GenTry cenv cgbuf eenv scopeMarks (e1, m, resty, spTry) =
let tryMarks = (startTryMark.CodeLabel, endTryMark.CodeLabel)
whereToSave, eenvinner, stack, tryMarks, afterHandler, ilResultTy

and GenTryCatch cenv cgbuf eenv (e1, vf: Val, ef, vh: Val, eh, m, resty, spTry, spWith) sequel =
and GenTryWith cenv cgbuf eenv (e1, vf: Val, ef, vh: Val, eh, m, resty, spTry, spWith) sequel =
let g = cenv.g

// Save the stack - gross because IL flushes the stack at the exn. handler
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/InnerLambdasToTopLevelFuncs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ module Pass4_RewriteAssembly =
///
/// Top-level status ends when stepping inside a lambda, where a lambda is:
/// Expr.TyLambda, Expr.Lambda, Expr.Obj (and tmethods).
/// [... also, try_catch handlers, and switch targets...]
/// [... also, try_with handlers, and switch targets...]
///
/// Top* repr bindings already at top-level do not need moving...
/// [and should not be, since they may lift over unmoved defns on which they depend].
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/LexFilter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ let rec isIfBlockContinuator token =
| ODUMMY token -> isIfBlockContinuator token
| _ -> false

/// Determine the token that may align with the 'try' of a 'try/catch' or 'try/finally' without closing
/// Determine the token that may align with the 'try' of a 'try/with' or 'try/finally' without closing
/// the construct
let rec isTryBlockContinuator token =
match token with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,23 @@ type IResolveDependenciesResult =
/// The resolution error log (* process stderror *)
abstract StdError: string[]

/// The resolution paths
/// The resolution paths - the full paths to selcted resolved dll's.
/// In scripts this is equivalent to #r @"c:\somepath\to\packages\ResolvedPackage\1.1.1\lib\netstandard2.0\ResolvedAssembly.dll"
abstract Resolutions: seq<string>

/// The source code file paths
abstract SourceFiles: seq<string>

/// The roots to package directories
/// This points to the root of each located package.
/// The layout of the package manager will be package manager specific.
/// however, the dependency manager dll understands the nuget package layout
/// and so if the package contains folders similar to the nuget layout then
/// the dependency manager will be able to probe and resolve any native dependencies
/// required by the nuget package.
///
/// This path is also equivalent to
/// #I @"c:\somepath\to\packages\1.1.1\ResolvedPackage"
abstract Roots: seq<string>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ type IResolveDependenciesResult =
/// The resolution error log (process stderr)
abstract StdError: string array

/// The resolution paths
/// The resolution paths - the full paths to selected resolved dll's.
/// In scripts this is equivalent to #r @"c:\somepath\to\packages\ResolvedPackage\1.1.1\lib\netstandard2.0\ResolvedAssembly.dll"
abstract Resolutions: seq<string>

/// The source code file paths
abstract SourceFiles: seq<string>

/// The roots to package directories
/// This points to the root of each located package.
/// The layout of the package manager will be package manager specific.
/// however, the dependency manager dll understands the nuget package layout
/// and so if the package contains folders similar to the nuget layout then
/// the dependency manager will be able to probe and resolve any native dependencies
/// required by the nuget package.
///
/// This path is also equivalent to
/// #I @"c:\somepath\to\packages\1.1.1\ResolvedPackage"
abstract Roots: seq<string>

/// Wraps access to a DependencyManager implementation
Expand Down
30 changes: 15 additions & 15 deletions src/fsharp/Optimizer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ let [<Literal>] callSize = 1
/// size of a for/while loop
let [<Literal>] forAndWhileLoopSize = 5

/// size of a try/catch
let [<Literal>] tryCatchSize = 5
/// size of a try/with
let [<Literal>] tryWithSize = 5

/// size of a try/finally
let [<Literal>] tryFinallySize = 5
Expand Down Expand Up @@ -226,7 +226,7 @@ type Summary<'Info> =

/// Meaning: could mutate, could non-terminate, could raise exception
/// One use: an effect expr can not be eliminated as dead code (e.g. sequencing)
/// One use: an effect=false expr can not throw an exception? so try-catch is removed.
/// One use: an effect=false expr can not throw an exception? so try-with is removed.
HasEffect: bool

/// Indicates that a function may make a useful tailcall, hence when called should itself be tailcalled
Expand Down Expand Up @@ -356,7 +356,7 @@ type OptimizationSettings =
member x.EliminateUnusedBindings () = x.localOpt ()

/// eliminate try around expr with no effect
member x.EliminateTryCatchAndTryFinally () = false // deemed too risky, given tiny overhead of including try/catch. See https://github.com/Microsoft/visualfsharp/pull/376
member x.EliminateTryWithAndTryFinally () = false // deemed too risky, given tiny overhead of including try/with. See https://github.com/Microsoft/visualfsharp/pull/376

/// eliminate first part of seq if no effect
member x.EliminateSequential () = x.localOpt ()
Expand Down Expand Up @@ -1395,7 +1395,7 @@ and OpHasEffect g m op =
| TOp.Reraise
| TOp.For _
| TOp.While _
| TOp.TryCatch _ (* conservative *)
| TOp.TryWith _ (* conservative *)
| TOp.TryFinally _ (* conservative *)
| TOp.TraitCall _
| TOp.Goto _
Expand Down Expand Up @@ -2093,8 +2093,8 @@ and OptimizeExprOp cenv env (op, tyargs, args, m) =
| TOp.TryFinally (spTry, spFinally), [resty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)] ->
OptimizeTryFinally cenv env (spTry, spFinally, e1, e2, m, resty)

| TOp.TryCatch (spTry, spWith), [resty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [vf], ef, _, _); Expr.Lambda (_, _, _, [vh], eh, _, _)] ->
OptimizeTryCatch cenv env (e1, vf, ef, vh, eh, m, resty, spTry, spWith)
| TOp.TryWith (spTry, spWith), [resty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [vf], ef, _, _); Expr.Lambda (_, _, _, [vh], eh, _, _)] ->
OptimizeTryWith cenv env (e1, vf, ef, vh, eh, m, resty, spTry, spWith)

| TOp.TraitCall traitInfo, [], args ->
OptimizeTraitCall cenv env (traitInfo, args, m)
Expand Down Expand Up @@ -2183,7 +2183,7 @@ and OptimizeExprOpFallback cenv env (op, tyargs, argsR, m) arginfos valu =
| TOp.Bytes bytes -> bytes.Length/10, valu
| TOp.UInt16s bytes -> bytes.Length/10, valu
| TOp.ValFieldGetAddr _
| TOp.Array | TOp.For _ | TOp.While _ | TOp.TryCatch _ | TOp.TryFinally _
| TOp.Array | TOp.For _ | TOp.While _ | TOp.TryWith _ | TOp.TryFinally _
| TOp.ILCall _ | TOp.TraitCall _ | TOp.LValueOp _ | TOp.ValFieldSet _
| TOp.UnionCaseFieldSet _ | TOp.RefAddrGet _ | TOp.Coerce | TOp.Reraise
| TOp.UnionCaseFieldGetAddr _
Expand Down Expand Up @@ -2407,7 +2407,7 @@ and OptimizeTryFinally cenv env (spTry, spFinally, e1, e2, m, ty) =
MightMakeCriticalTailcall = false // no tailcalls from inside in try/finally
Info = UnknownValue }
// try-finally, so no effect means no exception can be raised, so just sequence the finally
if cenv.settings.EliminateTryCatchAndTryFinally () && not e1info.HasEffect then
if cenv.settings.EliminateTryWithAndTryFinally () && not e1info.HasEffect then
let sp =
match spTry with
| DebugPointAtTry.Yes _ -> DebugPointAtSequential.Both
Expand All @@ -2418,19 +2418,19 @@ and OptimizeTryFinally cenv env (spTry, spFinally, e1, e2, m, ty) =
mkTryFinally cenv.g (e1R, e2R, m, ty, spTry, spFinally),
info

/// Optimize/analyze a try/catch construct.
and OptimizeTryCatch cenv env (e1, vf, ef, vh, eh, m, ty, spTry, spWith) =
/// Optimize/analyze a try/with construct.
and OptimizeTryWith cenv env (e1, vf, ef, vh, eh, m, ty, spTry, spWith) =
let e1R, e1info = OptimizeExpr cenv env e1
// try-catch, so no effect means no exception can be raised, so discard the catch
if cenv.settings.EliminateTryCatchAndTryFinally () && not e1info.HasEffect then
// try-with, so no effect means no exception can be raised, so discard the with
if cenv.settings.EliminateTryWithAndTryFinally () && not e1info.HasEffect then
e1R, e1info
else
let envinner = BindInternalValToUnknown cenv vf (BindInternalValToUnknown cenv vh env)
let efR, efinfo = OptimizeExpr cenv envinner ef
let ehR, ehinfo = OptimizeExpr cenv envinner eh
let info =
{ TotalSize = e1info.TotalSize + efinfo.TotalSize+ ehinfo.TotalSize + tryCatchSize
FunctionSize = e1info.FunctionSize + efinfo.FunctionSize+ ehinfo.FunctionSize + tryCatchSize
{ TotalSize = e1info.TotalSize + efinfo.TotalSize+ ehinfo.TotalSize + tryWithSize
FunctionSize = e1info.FunctionSize + efinfo.FunctionSize+ ehinfo.FunctionSize + tryWithSize
HasEffect = e1info.HasEffect || efinfo.HasEffect || ehinfo.HasEffect
MightMakeCriticalTailcall = false
Info = UnknownValue }
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/PatternMatchCompilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ let CompilePatternBasic
mkInt g matchm 0

| Rethrow ->
// Rethrow unmatched try-catch exn. No sequence point at the target since its not real code.
// Rethrow unmatched try-with exn. No sequence point at the target since its not real code.
mkReraise matchm resultTy

| Throw ->
Expand All @@ -813,7 +813,7 @@ let CompilePatternBasic
)
)

// We use throw, or EDI.Capture(exn).Throw() when EDI is supported, instead of rethrow on unmatched try-catch in a computation expression.
// We use throw, or EDI.Capture(exn).Throw() when EDI is supported, instead of rethrow on unmatched try-with in a computation expression.
// But why? Because this isn't a real .NET exception filter/handler but just a function we're passing
// to a computation expression builder to simulate one.
let ediCaptureMethInfo, ediThrowMethInfo =
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ and CheckExprOp cenv env (op, tyargs, args, m) context expr =
CheckTypeInstNoByrefs cenv env m tyargs
CheckExprsNoByRefLike cenv env [e1;e2;e3]

| TOp.TryCatch _, [_], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], _e2, _, _); Expr.Lambda (_, _, _, [_], e3, _, _)] ->
| TOp.TryWith _, [_], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], _e2, _, _); Expr.Lambda (_, _, _, [_], e3, _, _)] ->
CheckTypeInstNoInnerByrefs cenv env m tyargs // result of a try/catch can be a byref
ctorLimitedZoneCheck()
let limit1 = CheckExpr cenv env e1 context // result of a try/catch can be a byref if in a position where the overall expression is can be a byref
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/QuotationTranslator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP.
| TOp.TryFinally _, [_resty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [_], e2, _, _)] ->
QP.mkTryFinally(ConvExpr cenv env e1, ConvExpr cenv env e2)

| TOp.TryCatch _, [_resty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [vf], ef, _, _); Expr.Lambda (_, _, _, [vh], eh, _, _)] ->
| TOp.TryWith _, [_resty], [Expr.Lambda (_, _, _, [_], e1, _, _); Expr.Lambda (_, _, _, [vf], ef, _, _); Expr.Lambda (_, _, _, [vh], eh, _, _)] ->
let vfR = ConvVal cenv env vf
let envf = BindVal env vf
let vhR = ConvVal cenv env vh
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5795,7 +5795,7 @@ and TcExprFlex cenv flex compat ty (env: TcEnv) tpenv (e: SynExpr) =

and TcExpr cenv ty (env: TcEnv) tpenv (expr: SynExpr) =
// Start an error recovery handler
// Note the try/catch can lead to tail-recursion problems for iterated constructs, e.g. let... in...
// Note the try/with can lead to tail-recursion problems for iterated constructs, e.g. let... in...
// So be careful!
try
TcExprNoRecover cenv ty env tpenv expr
Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/TypedTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4626,8 +4626,8 @@ type TOp =
/// An operation representing a lambda-encoded for loop
| For of DebugPointAtFor * ForLoopStyle (* count up or down? *)

/// An operation representing a lambda-encoded try/catch
| TryCatch of DebugPointAtTry * DebugPointAtWith
/// An operation representing a lambda-encoded try/with
| TryWith of DebugPointAtTry * DebugPointAtWith

/// An operation representing a lambda-encoded try/finally
| TryFinally of DebugPointAtTry * DebugPointAtFinally
Expand Down Expand Up @@ -4725,7 +4725,7 @@ type TOp =
| UInt16s _ -> "UInt16s(..)"
| While _ -> "While"
| For _ -> "For"
| TryCatch _ -> "TryCatch"
| TryWith _ -> "TryWith"
| TryFinally _ -> "TryFinally"
| Recd (_, tcref) -> "Recd(" + tcref.LogicalName + ")"
| ValFieldSet rfref -> "ValFieldSet(" + rfref.FieldName + ")"
Expand Down
Loading