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

[RFCs FS-1051, FS-1052, FS-1053] support for span, readonly refs, byref-like structs #4888

Merged
merged 73 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
f0512c1
initial support for span, readonly refs, byref-like structs
dsyme May 12, 2018
9a4fdae
fix proto build
dsyme May 12, 2018
e4744e9
make proto work with previous FSharp.Core
dsyme May 12, 2018
70df8f2
make proto work with previous FSharp.Core
dsyme May 12, 2018
016b8dd
update baselines
dsyme May 12, 2018
797040a
integrate code cleanup
dsyme May 12, 2018
35c2517
integrate code cleanup
dsyme May 12, 2018
e9cba69
integrate code cleanup
dsyme May 12, 2018
ead3008
integrate code cleanup
dsyme May 12, 2018
b812351
integrate code cleanup
dsyme May 12, 2018
87e48e9
fix build
dsyme May 12, 2018
4a3ecfc
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme May 12, 2018
7e1782b
fix build
dsyme May 12, 2018
5d19184
implicit deref of byref returns
dsyme May 12, 2018
fbebe24
add tests for Memory, ReadOnlySpan and ReadOnlyMemory
dsyme May 12, 2018
4811410
fix tests
dsyme May 12, 2018
bf66385
simplify diff
dsyme May 12, 2018
05c3ba0
simplify diff
dsyme May 12, 2018
5e22f01
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme May 12, 2018
0859a42
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme May 12, 2018
7dee3e7
remove duplicate error messages
dsyme May 12, 2018
bfcb9c8
fix build
dsyme May 12, 2018
a5218ef
test updates
dsyme May 13, 2018
091a103
fix build
dsyme May 13, 2018
88654e4
fix build
dsyme May 13, 2018
f29282f
update baselines
dsyme May 13, 2018
fb59345
fix uses of NativePtr.toByRef
dsyme May 14, 2018
c49bdc3
switch to inference using byref pointer capabilities
dsyme May 15, 2018
adae34a
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme May 15, 2018
47b83d9
fix proto build
dsyme May 15, 2018
b1a732b
integrate cleanup
dsyme May 15, 2018
fe4abce
update baselines, byref extension methods
dsyme May 15, 2018
35e1800
fix test errors
dsyme May 16, 2018
7b125d1
emit in,out,modreq attributes correctly
dsyme May 16, 2018
6ea92d6
update tests
dsyme May 16, 2018
c3fe071
fix build
dsyme May 16, 2018
c321ccb
fix build
dsyme May 17, 2018
7f98958
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme May 17, 2018
057b521
fix tests
dsyme May 17, 2018
45050eb
fix tests
dsyme May 17, 2018
9f95be8
get it right silly boy
dsyme May 17, 2018
e747a84
fix test
dsyme May 18, 2018
9a1efdb
minor cleanup
dsyme May 18, 2018
33aa5aa
add more tests
dsyme May 19, 2018
a44e9f3
add more tests
dsyme May 19, 2018
4e4921b
clarify overloading behaviour + test case
dsyme May 21, 2018
a640379
merge
dsyme May 25, 2018
19463a9
fix build break
dsyme May 25, 2018
75709d3
fix build of tests
dsyme May 25, 2018
520a919
update tests
dsyme May 25, 2018
37ccc1c
add more tests
dsyme May 25, 2018
6e4a1c3
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme May 29, 2018
bf940d1
byref fixes
dsyme May 31, 2018
9fdf5c7
merge byrefs3
dsyme May 31, 2018
50f2085
updates for subsumption calls, error message, assign-to-return-byref
dsyme Jun 1, 2018
e0de866
test updates, implicit deref on byref return for normal functions
dsyme Jun 1, 2018
49b2280
update baseline
dsyme Jun 1, 2018
a6e2b44
improve debug formatting, better error message on implicit deref, imp…
dsyme Jun 1, 2018
722a3c2
Merge branch 'master' of http://github.com/Microsoft/visualfsharp int…
dsyme Jun 1, 2018
74809bb
add more tests for recursive functions
dsyme Jun 1, 2018
4a61453
update baselines
dsyme Jun 1, 2018
36e59ab
fix baselines
dsyme Jun 1, 2018
2e36e58
updates for new test cases
dsyme Jun 2, 2018
a7e8e82
updates for new test cases
dsyme Jun 2, 2018
1bccfb6
test updates and byref-to-byreflike
dsyme Jun 2, 2018
3be2542
deal with 'M() <- expr'
dsyme Jun 2, 2018
b8f29fc
restrict addresses of immutable top-level things
dsyme Jun 2, 2018
e10c464
fix IsByRefLike on struct
dsyme Jun 2, 2018
937673d
update tests
dsyme Jun 2, 2018
d0cad1f
fix test
dsyme Jun 3, 2018
7453ab7
fix test
dsyme Jun 3, 2018
e1b4985
improve check for no-return-of-struct-field-addresses
dsyme Jun 4, 2018
0a9316f
fix test case
dsyme Jun 4, 2018
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
1 change: 0 additions & 1 deletion DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ To do this, build the non-buildfromsource version of FSharp.Compiler.Private (sr

.\build net40
copy /y src\fsharp\FSharp.Compiler.Private\obj\release\net40\FSComp.* src\buildfromsource\FSharp.Compiler.Private\


#### Configuring proxy server

Expand Down
5 changes: 5 additions & 0 deletions packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<package id="Microsoft.FSharp.TupleSample" version="1.0.0-alpha-161121"/>
<package id="Microsoft.VSSDK.BuildTools" version="15.1.192" />

<!-- Testing Span -->
<package id="System.Memory" version="4.5.0-rc1" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0-rc1" />
<package id="NETStandard.Library.NETFramework" version="2.0.0-preview2-25405-01" />

<!-- Annoyingly the build of FSharp.Compiler.Server.Shared references a Visual Studio-specific attribute -->
<!-- That DLL is logically part of the F# Compiler and F# Interactive but is shipped as part of the Visual F# IDE Tools -->
<package id="Microsoft.VisualStudio.Shell.Immutable.10.0" version="10.0.30319" targetFramework="net46" />
Expand Down
82 changes: 72 additions & 10 deletions src/absil/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Microsoft.FSharp.Compiler.AbstractIL.IL


open System
open System.Diagnostics
open System.IO
open System.Collections
open System.Collections.Generic
Expand Down Expand Up @@ -568,7 +569,7 @@ type ILBoxity =
| AsValue

// IL type references have a pre-computed hash code to enable quick lookup tables during binary generation.
[<CustomEquality; CustomComparison>]
[<CustomEquality; CustomComparison; StructuredFormatDisplay("{DebugText}")>]
type ILTypeRef =
{ trefScope: ILScopeRef
trefEnclosing: string list
Expand Down Expand Up @@ -637,11 +638,15 @@ type ILTypeRef =
member tref.QualifiedName =
tref.AddQualifiedNameExtension(tref.BasicQualifiedName)

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

/// For debugging
override x.ToString() = x.FullName


and
[<StructuralEquality; StructuralComparison>]
and [<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
ILTypeSpec =
{ tspecTypeRef: ILTypeRef
/// The type instantiation if the type is generic.
Expand Down Expand Up @@ -671,9 +676,13 @@ and

member x.FullName=x.TypeRef.FullName

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.TypeRef.ToString() + if isNil x.GenericArgs then "" else "<...>"

and [<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
and [<RequireQualifiedAccess; StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
ILType =
| Void
| Array of ILArrayShape * ILType
Expand Down Expand Up @@ -740,6 +749,10 @@ and [<RequireQualifiedAccess; StructuralEquality; StructuralComparison>]
match x with
| ILType.TypeVar _ -> true | _ -> false

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.QualifiedName

and [<StructuralEquality; StructuralComparison>]
Expand All @@ -756,6 +769,7 @@ let mkILCallSig (cc, args, ret) = { ArgTypes=args; CallingConv=cc; ReturnType=re

let mkILBoxedType (tspec:ILTypeSpec) = tspec.TypeRef.AsBoxedType tspec

[<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
type ILMethodRef =
{ mrefParent: ILTypeRef
mrefCallconv: ILCallingConv
Expand Down Expand Up @@ -783,26 +797,34 @@ type ILMethodRef =
static member Create(a, b, c, d, e, f) =
{ mrefParent= a;mrefCallconv=b;mrefName=c;mrefGenericArity=d; mrefArgs=e;mrefReturn=f }

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.DeclaringTypeRef.ToString() + "::" + x.Name + "(...)"


[<StructuralEquality; StructuralComparison>]
[<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
type ILFieldRef =
{ DeclaringTypeRef: ILTypeRef
Name: string
Type: ILType }

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.DeclaringTypeRef.ToString() + "::" + x.Name

[<StructuralEquality; StructuralComparison>]
[<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
type ILMethodSpec =
{ mspecMethodRef: ILMethodRef

mspecDeclaringType: ILType

mspecMethodInst: ILGenericArgs }

static member Create(a, b, c) = { mspecDeclaringType=a; mspecMethodRef =b; mspecMethodInst=c }
static member Create(a, b, c) = { mspecDeclaringType=a; mspecMethodRef=b; mspecMethodInst=c }

member x.MethodRef = x.mspecMethodRef

Expand All @@ -820,8 +842,13 @@ type ILMethodSpec =

member x.FormalReturnType = x.MethodRef.ReturnType

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.MethodRef.ToString() + "(...)"

[<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
type ILFieldSpec =
{ FieldRef: ILFieldRef
DeclaringType: ILType }
Expand All @@ -832,6 +859,10 @@ type ILFieldSpec =

member x.DeclaringTypeRef = x.FieldRef.DeclaringTypeRef

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.FieldRef.ToString()

// --------------------------------------------------------------------
Expand Down Expand Up @@ -865,6 +896,7 @@ type ILSourceDocument =

member x.File=x.sourceFile

[<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
type ILSourceMarker =
{ sourceDocument: ILSourceDocument
sourceLine: int
Expand All @@ -889,6 +921,10 @@ type ILSourceMarker =

member x.EndColumn=x.sourceEndColumn

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = sprintf "(%d, %d)-(%d, %d)" x.Line x.Column x.EndLine x.EndColumn

type ILAttribElem =
Expand All @@ -912,11 +948,16 @@ type ILAttribElem =

type ILAttributeNamedArg = (string * ILType * bool * ILAttribElem)

[<StructuralEquality; StructuralComparison; StructuredFormatDisplay("{DebugText}")>]
type ILAttribute =
{ Method: ILMethodSpec
Data: byte[]
Elements: ILAttribElem list }

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.Method.ToString() + "(...)"

[<NoEquality; NoComparison; Struct>]
Expand Down Expand Up @@ -1424,6 +1465,8 @@ type ILReturn =

member x.CustomAttrs = x.CustomAttrsStored.GetCustomAttrs x.MetadataIndex

member x.WithCustomAttrs(customAttrs) = { x with CustomAttrsStored = storeILCustomAttrs customAttrs }

type ILOverridesSpec =
| OverridesSpec of ILMethodRef * ILType

Expand Down Expand Up @@ -1475,6 +1518,7 @@ type ILGenericVariance =
| CoVariant
| ContraVariant

[<NoEquality; NoComparison; StructuredFormatDisplay("{DebugText}")>]
type ILGenericParameterDef =
{ Name: string
Constraints: ILTypes
Expand All @@ -1487,6 +1531,10 @@ type ILGenericParameterDef =

member x.CustomAttrs = x.CustomAttrsStored.GetCustomAttrs x.MetadataIndex

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = x.Name

type ILGenericParameterDefs = ILGenericParameterDef list
Expand Down Expand Up @@ -1665,7 +1713,7 @@ type ILMethodDefs(f : (unit -> ILMethodDef[])) =

member x.FindByNameAndArity (nm, arity) = x.FindByName nm |> List.filter (fun x -> List.length x.Parameters = arity)

[<NoComparison; NoEquality>]
[<NoComparison; NoEquality; StructuredFormatDisplay("{DebugText}")>]
type ILEventDef(eventType: ILType option, name: string, attributes: EventAttributes, addMethod: ILMethodRef, removeMethod: ILMethodRef, fireMethod: ILMethodRef option, otherMethods: ILMethodRef list, customAttrsStored: ILAttributesStored, metadataIndex: int32) =

new (eventType, name, attributes, addMethod, removeMethod, fireMethod, otherMethods, customAttrs) =
Expand Down Expand Up @@ -1695,6 +1743,10 @@ type ILEventDef(eventType: ILType option, name: string, attributes: EventAttribu
member x.IsSpecialName = (x.Attributes &&& EventAttributes.SpecialName) <> enum<_>(0)
member x.IsRTSpecialName = (x.Attributes &&& EventAttributes.RTSpecialName) <> enum<_>(0)

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = "event " + x.Name

[<NoEquality; NoComparison>]
Expand All @@ -1705,7 +1757,7 @@ type ILEventDefs =

member x.LookupByName s = let (ILEvents t) = x in t.[s]

[<NoComparison; NoEquality>]
[<NoComparison; NoEquality; StructuredFormatDisplay("{DebugText}")>]
type ILPropertyDef(name: string, attributes: PropertyAttributes, setMethod: ILMethodRef option, getMethod: ILMethodRef option, callingConv: ILThisConvention, propertyType: ILType, init: ILFieldInit option, args: ILTypes, customAttrsStored: ILAttributesStored, metadataIndex: int32) =

new (name, attributes, setMethod, getMethod, callingConv, propertyType, init, args, customAttrs) =
Expand Down Expand Up @@ -1737,6 +1789,11 @@ type ILPropertyDef(name: string, attributes: PropertyAttributes, setMethod: ILMe

member x.IsSpecialName = (x.Attributes &&& PropertyAttributes.SpecialName) <> enum<_>(0)
member x.IsRTSpecialName = (x.Attributes &&& PropertyAttributes.RTSpecialName) <> enum<_>(0)

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = "property " + x.Name

// Index table by name.
Expand Down Expand Up @@ -2469,7 +2526,7 @@ let tname_IntPtr = "System.IntPtr"
[<Literal>]
let tname_UIntPtr = "System.UIntPtr"

[<NoEquality; NoComparison>]
[<NoEquality; NoComparison; StructuredFormatDisplay("{DebugText}")>]
// This data structure needs an entirely delayed implementation
type ILGlobals(primaryScopeRef) =

Expand Down Expand Up @@ -2514,6 +2571,11 @@ type ILGlobals(primaryScopeRef) =
member x.typ_Double = m_typ_Double
member x.typ_Bool = m_typ_Bool
member x.typ_Char = m_typ_Char

/// For debugging
[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()

override x.ToString() = "<ILGlobals>"

let mkILGlobals primaryScopeRef = ILGlobals primaryScopeRef
Expand Down
2 changes: 2 additions & 0 deletions src/absil/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ type ILReturn =

member CustomAttrs: ILAttributes

member WithCustomAttrs: customAttrs: ILAttributes -> ILReturn

[<RequireQualifiedAccess>]
type ILSecurityAction =
| Request
Expand Down
Loading