Skip to content
Merged
1 change: 1 addition & 0 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ if '%TEST_VS_IDEUNIT_SUITE%' == '1' (
)
)

goto :success
REM ------ upload test results procedure -------------------------------------

:UPLOAD_TEST_RESULTS
Expand Down
674 changes: 111 additions & 563 deletions src/absil/il.fs

Large diffs are not rendered by default.

191 changes: 30 additions & 161 deletions src/absil/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module internal Microsoft.FSharp.Compiler.AbstractIL.IL
open Internal.Utilities
open System.Collections.Generic

[<RequireQualifiedAccess>]
type PrimaryAssembly =
| Mscorlib
| DotNetCore
Expand Down Expand Up @@ -1474,29 +1475,6 @@ val isTypeNameForGlobalFunctions: string -> bool

val ungenericizeTypeName: string -> string (* e.g. List`1 --> List *)

/// Represents the capabilities of target framework profile.
/// Different profiles may omit some types or contain them in different assemblies.
type IPrimaryAssemblyTraits =

abstract TypedReferenceTypeScopeRef : ILScopeRef option
abstract RuntimeArgumentHandleTypeScopeRef : ILScopeRef option
abstract SerializationInfoTypeScopeRef : ILScopeRef option
abstract SecurityPermissionAttributeTypeScopeRef : ILScopeRef option
abstract IDispatchConstantAttributeScopeRef : ILScopeRef option
abstract IUnknownConstantAttributeScopeRef : ILScopeRef option
abstract ArgIteratorTypeScopeRef : ILScopeRef option
abstract MarshalByRefObjectScopeRef : ILScopeRef option
abstract ThreadStaticAttributeScopeRef : ILScopeRef option
abstract SpecialNameAttributeScopeRef : ILScopeRef option
abstract ContextStaticAttributeScopeRef : ILScopeRef option
abstract NonSerializedAttributeScopeRef : ILScopeRef option

abstract SystemRuntimeInteropServicesScopeRef : Lazy<ILScopeRef option>
abstract SystemLinqExpressionsScopeRef : Lazy<ILScopeRef>
abstract SystemCollectionsScopeRef : Lazy<ILScopeRef>
abstract SystemReflectionScopeRef : Lazy<ILScopeRef>
abstract SystemDiagnosticsDebugScopeRef : Lazy<ILScopeRef>
abstract ScopeRef : ILScopeRef

// ====================================================================
// PART 2
Expand All @@ -1509,103 +1487,34 @@ type IPrimaryAssemblyTraits =
/// A table of common references to items in primary assebly (System.Runtime or mscorlib).
/// If a particular version of System.Runtime.dll has been loaded then you should
/// reference items from it via an ILGlobals for that specific version built using mkILGlobals.
[<NoEquality; NoComparison>]
[<NoEquality; NoComparison; Class>]
type ILGlobals =
{
traits : IPrimaryAssemblyTraits
primaryAssemblyName: string
noDebugData: bool
tref_Object: ILTypeRef
tspec_Object: ILTypeSpec
typ_Object: ILType
tref_String: ILTypeRef
typ_String: ILType
typ_StringBuilder: ILType
typ_AsyncCallback: ILType
typ_IAsyncResult: ILType
typ_IComparable: ILType
tref_Type: ILTypeRef
typ_Type: ILType
typ_Missing: Lazy<ILType>
typ_Activator: ILType
typ_Delegate: ILType
typ_ValueType: ILType
typ_Enum: ILType
tspec_TypedReference: ILTypeSpec option
typ_TypedReference: ILType option
typ_MulticastDelegate: ILType
typ_Array: ILType
tspec_Int64: ILTypeSpec
tspec_UInt64: ILTypeSpec
tspec_Int32: ILTypeSpec
tspec_UInt32: ILTypeSpec
tspec_Int16: ILTypeSpec
tspec_UInt16: ILTypeSpec
tspec_SByte: ILTypeSpec
tspec_Byte: ILTypeSpec
tspec_Single: ILTypeSpec
tspec_Double: ILTypeSpec
tspec_IntPtr: ILTypeSpec
tspec_UIntPtr: ILTypeSpec
tspec_Char: ILTypeSpec
tspec_Bool: ILTypeSpec
typ_int8: ILType
typ_int16: ILType
typ_int32: ILType
typ_int64: ILType
typ_uint8: ILType
typ_uint16: ILType
typ_uint32: ILType
typ_uint64: ILType
typ_float32: ILType
typ_float64: ILType
typ_bool: ILType
typ_char: ILType
typ_IntPtr: ILType
typ_UIntPtr: ILType
typ_RuntimeArgumentHandle: ILType option
typ_RuntimeTypeHandle: ILType
typ_RuntimeMethodHandle: ILType
typ_RuntimeFieldHandle: ILType
typ_Byte: ILType
typ_Int16: ILType
typ_Int32: ILType
typ_Int64: ILType
typ_SByte: ILType
typ_UInt16: ILType
typ_UInt32: ILType
typ_UInt64: ILType
typ_Single: ILType
typ_Double: ILType
typ_Bool: ILType
typ_Char: ILType
typ_SerializationInfo: ILType option
typ_StreamingContext: ILType
tref_SecurityPermissionAttribute : ILTypeRef option
tspec_Exception: ILTypeSpec
typ_Exception: ILType
mutable generatedAttribsCache: ILAttribute list
mutable debuggerBrowsableNeverAttributeCache : ILAttribute option
mutable debuggerTypeProxyAttributeCache : ILAttribute option }

with
member mkDebuggableAttribute: bool (* disable JIT optimizations *) -> ILAttribute
/// Some commonly used custom attibutes
member mkDebuggableAttributeV2 : bool (* jitTracking *) * bool (* ignoreSymbolStoreSequencePoints *) * bool (* disable JIT optimizations *) * bool (* enable EnC *) -> ILAttribute
member mkCompilerGeneratedAttribute : unit -> ILAttribute
member mkDebuggerNonUserCodeAttribute : unit -> ILAttribute
member mkDebuggerStepThroughAttribute : unit -> ILAttribute
member mkDebuggerHiddenAttribute : unit -> ILAttribute
member mkDebuggerDisplayAttribute : string -> ILAttribute
member mkDebuggerTypeProxyAttribute : ILType -> ILAttribute
member mkDebuggerBrowsableNeverAttribute : unit -> ILAttribute

/// Build the table of commonly used references given an <c>ILScopeRef</c> for system runtime assembly.
val mkILGlobals : IPrimaryAssemblyTraits -> string option -> bool -> ILGlobals

val mkMscorlibBasedTraits : ILScopeRef -> IPrimaryAssemblyTraits

val EcmaILGlobals : ILGlobals
member primaryAssemblyScopeRef : ILScopeRef
member primaryAssemblyName : string
member typ_Object: ILType
member typ_String: ILType
member typ_Type: ILType
member typ_Array: ILType
member typ_IntPtr: ILType
member typ_UIntPtr: ILType
member typ_Byte: ILType
member typ_Int16: ILType
member typ_Int32: ILType
member typ_Int64: ILType
member typ_SByte: ILType
member typ_UInt16: ILType
member typ_UInt32: ILType
member typ_UInt64: ILType
member typ_Single: ILType
member typ_Double: ILType
member typ_Bool: ILType
member typ_Char: ILType


/// Build the table of commonly used references given functions to find types in system assemblies
val mkILGlobals: ILScopeRef -> ILGlobals

val EcmaMscorlibILGlobals : ILGlobals

/// When writing a binary the fake "toplevel" type definition (called <Module>)
/// must come first. This function puts it first, and creates it in the returned
Expand Down Expand Up @@ -1784,7 +1693,7 @@ val mkILTypeDefForGlobalFunctions: ILGlobals -> ILMethodDefs * ILFieldDefs -> IL
/// ldtoken field valuetype '<PrivateImplementationDetails>'/'$$struct0x6000127-1' '<PrivateImplementationDetails>'::'$$method0x6000127-1'
/// call void System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class System.Array,valuetype System.RuntimeFieldHandle)
/// idiom.
val mkRawDataValueTypeDef: ILGlobals -> string * size:int32 * pack:uint16 -> ILTypeDef
val mkRawDataValueTypeDef: ILType -> string * size:int32 * pack:uint16 -> ILTypeDef

/// Injecting code into existing code blocks. A branch will
/// be added from the given instructions to the (unique) entry of
Expand All @@ -1804,7 +1713,7 @@ val mkILStorageCtor: ILSourceMarker option * ILInstr list * ILType * (string * I
val mkILSimpleStorageCtor: ILSourceMarker option * ILTypeSpec option * ILType * (string * ILType) list * ILMemberAccess -> ILMethodDef
val mkILSimpleStorageCtorWithParamNames: ILSourceMarker option * ILTypeSpec option * ILType * (string * string * ILType) list * ILMemberAccess -> ILMethodDef

val mkILDelegateMethods: ILGlobals -> ILParameter list * ILReturn -> ILMethodDef list
val mkILDelegateMethods: ILGlobals -> ILType * ILType -> ILParameter list * ILReturn -> ILMethodDef list

/// Given a delegate type definition which lies in a particular scope,
/// make a reference to its constructor.
Expand Down Expand Up @@ -1926,38 +1835,10 @@ val rescopeILMethodRef: ILScopeRef -> ILMethodRef -> ILMethodRef
/// the new scope.
val rescopeILFieldRef: ILScopeRef -> ILFieldRef -> ILFieldRef


//-----------------------------------------------------------------------
// The ILCode Builder utility.
//----------------------------------------------------------------------


/// buildILCode: Build code from a sequence of instructions.
///
/// e.g. "buildILCode meth resolver instrs exns locals"
///
/// This makes the basic block structure of code from more primitive
/// information, i.e. an array of instructions.
/// [meth]: for debugging and should give the name of the method.
/// [resolver]: should return the instruction indexes referred to
/// by code-label strings in the instruction stream.
/// [instrs]: the instructions themselves, perhaps with attributes giving
/// debugging information
/// [exns]: the table of exception-handling specifications
/// for the method. These are again given with respect to labels which will
/// be mapped to pc's by [resolver].
/// [locals]: the table of specifications of when local variables are live and
/// should appear in the debug info.
///
/// If the input code is well-formed, the function will returns the
/// chop up the instruction sequence into basic blocks as required for
/// the exception handlers and then return the tree-structured code
/// corresponding to the instruction stream.
/// A new set of code labels will be used throughout the resulting code.
///
/// The input can be badly formed in many ways: exception handlers might
/// overlap, or scopes of local variables may overlap badly with
/// exception handlers.
val buildILCode: string -> lab2pc: Dictionary<ILCodeLabel,int> -> instrs:ILInstr[] -> ILExceptionSpec list -> ILLocalDebugInfo list -> ILCode

// --------------------------------------------------------------------
Expand All @@ -1977,18 +1858,6 @@ val instILType: ILGenericArgs -> ILType -> ILType
/// This is a 'vendor neutral' way of referencing mscorlib.
val ecmaPublicKey: PublicKey

/// Some commonly used methods.
val mkInitializeArrayMethSpec: ILGlobals -> ILMethodSpec

val mkPrimaryAssemblyExnNewobj: ILGlobals -> string -> ILInstr

val addMethodGeneratedAttrs : ILGlobals -> ILMethodDef -> ILMethodDef
val addPropertyGeneratedAttrs : ILGlobals -> ILPropertyDef -> ILPropertyDef
val addFieldGeneratedAttrs : ILGlobals -> ILFieldDef -> ILFieldDef

val addPropertyNeverAttrs : ILGlobals -> ILPropertyDef -> ILPropertyDef
val addFieldNeverAttrs : ILGlobals -> ILFieldDef -> ILFieldDef

/// Discriminating different important built-in types.
val isILObjectTy: ILType -> bool
val isILStringTy: ILType -> bool
Expand Down
2 changes: 1 addition & 1 deletion src/absil/ilascii.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types
open Microsoft.FSharp.Compiler.AbstractIL.IL

// set to the proper value at CompileOps.fs (BuildFrameworkTcImports)
let parseILGlobals = ref EcmaILGlobals
let parseILGlobals = ref EcmaMscorlibILGlobals

// --------------------------------------------------------------------
// Table of parsing and pretty printing data for instructions.
Expand Down
34 changes: 17 additions & 17 deletions src/absil/ilpars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let resolveCurrentMethodSpecScope obj =


let findSystemRuntimeAssemblyRef() =
match (!parseILGlobals).traits.ScopeRef with
match (!parseILGlobals).primaryAssemblyScopeRef with
| ILScopeRef.Assembly aref -> aref
| _ -> pfailwith "systemRuntimeScopeRef not set to valid assembly reference in parseILGlobals"

Expand Down Expand Up @@ -330,39 +330,39 @@ typ: STRING
| typ STAR
{ resolveMethodSpecScopeThen $1 (fun ty -> noMethodSpecScope (ILType.Ptr ty)) }
| CHAR
{ noMethodSpecScope (!parseILGlobals).typ_char }
{ noMethodSpecScope (!parseILGlobals).typ_Char }
| VOID
{ noMethodSpecScope ILType.Void }
| BOOL
{ noMethodSpecScope (!parseILGlobals).typ_bool }
{ noMethodSpecScope (!parseILGlobals).typ_Bool }
| INT8
{ noMethodSpecScope (!parseILGlobals).typ_int8 }
{ noMethodSpecScope (!parseILGlobals).typ_SByte }
| INT16
{ noMethodSpecScope (!parseILGlobals).typ_int16 }
{ noMethodSpecScope (!parseILGlobals).typ_Int16 }
| INT32
{ noMethodSpecScope (!parseILGlobals).typ_int32 }
{ noMethodSpecScope (!parseILGlobals).typ_Int32 }
| INT64
{ noMethodSpecScope (!parseILGlobals).typ_int64 }
{ noMethodSpecScope (!parseILGlobals).typ_Int64 }
| FLOAT32
{ noMethodSpecScope (!parseILGlobals).typ_float32 }
{ noMethodSpecScope (!parseILGlobals).typ_Single }
| FLOAT64
{ noMethodSpecScope (!parseILGlobals).typ_float64 }
{ noMethodSpecScope (!parseILGlobals).typ_Double }
| UNSIGNED INT8
{ noMethodSpecScope (!parseILGlobals).typ_uint8 }
{ noMethodSpecScope (!parseILGlobals).typ_Byte }
| UNSIGNED INT16
{ noMethodSpecScope (!parseILGlobals).typ_uint16 }
{ noMethodSpecScope (!parseILGlobals).typ_UInt16 }
| UNSIGNED INT32
{ noMethodSpecScope (!parseILGlobals).typ_uint32 }
{ noMethodSpecScope (!parseILGlobals).typ_UInt32 }
| UNSIGNED INT64
{ noMethodSpecScope (!parseILGlobals).typ_uint64 }
{ noMethodSpecScope (!parseILGlobals).typ_UInt64 }
| UINT8
{ noMethodSpecScope (!parseILGlobals).typ_uint8 }
{ noMethodSpecScope (!parseILGlobals).typ_Byte }
| UINT16
{ noMethodSpecScope (!parseILGlobals).typ_uint16 }
{ noMethodSpecScope (!parseILGlobals).typ_UInt16 }
| UINT32
{ noMethodSpecScope (!parseILGlobals).typ_uint32 }
{ noMethodSpecScope (!parseILGlobals).typ_UInt32 }
| UINT64
{ noMethodSpecScope (!parseILGlobals).typ_uint64 }
{ noMethodSpecScope (!parseILGlobals).typ_UInt64 }
| NATIVE INT
{ noMethodSpecScope (!parseILGlobals).typ_IntPtr }
| NATIVE UNSIGNED INT
Expand Down
37 changes: 18 additions & 19 deletions src/absil/ilprint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,20 @@ and goutput_typ env os ty =

| ILType.Byref typ -> goutput_typ env os typ; output_string os "&"
| ILType.Ptr typ -> goutput_typ env os typ; output_string os "*"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_SByte.Name -> output_string os "int8"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Int16.Name -> output_string os "int16"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Int32.Name -> output_string os "int32"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Int64.Name -> output_string os "int64"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_IntPtr.Name -> output_string os "native int"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Byte.Name -> output_string os "unsigned int8"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_UInt16.Name -> output_string os "unsigned int16"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_UInt32.Name -> output_string os "unsigned int32"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_UInt64.Name -> output_string os "unsigned int64"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_UIntPtr.Name -> output_string os "native unsigned int"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Double.Name -> output_string os "float64"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Single.Name -> output_string os "float32"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Bool.Name -> output_string os "bool"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_Char.Name -> output_string os "char"
| ILType.Value tspec when tspec.Name = EcmaILGlobals.tspec_TypedReference.Value.Name -> output_string os "refany"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_SByte.TypeSpec.Name -> output_string os "int8"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int16.TypeSpec.Name -> output_string os "int16"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int32.TypeSpec.Name -> output_string os "int32"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Int64.TypeSpec.Name -> output_string os "int64"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_IntPtr.TypeSpec.Name -> output_string os "native int"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Byte.TypeSpec.Name -> output_string os "unsigned int8"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt16.TypeSpec.Name -> output_string os "unsigned int16"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt32.TypeSpec.Name -> output_string os "unsigned int32"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UInt64.TypeSpec.Name -> output_string os "unsigned int64"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_UIntPtr.TypeSpec.Name -> output_string os "native unsigned int"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Double.TypeSpec.Name -> output_string os "float64"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Single.TypeSpec.Name -> output_string os "float32"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Bool.TypeSpec.Name -> output_string os "bool"
| ILType.Value tspec when tspec.Name = EcmaMscorlibILGlobals.typ_Char.TypeSpec.Name -> output_string os "char"
| ILType.Value tspec ->
output_string os "value class ";
goutput_tref env os tspec.TypeRef;
Expand Down Expand Up @@ -703,7 +702,7 @@ let rec goutput_instr env os inst =
goutput_dlocref env os (mkILArrTy(typ,shape));
output_string os ".ctor";
let rank = shape.Rank
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaILGlobals.typ_int32))
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaMscorlibILGlobals.typ_Int32))
| I_stelem_any (shape,dt) ->
if shape = ILArrayShape.SingleDimensional then
output_string os "stelem.any "; goutput_typ env os dt
Expand All @@ -712,7 +711,7 @@ let rec goutput_instr env os inst =
goutput_dlocref env os (mkILArrTy(dt,shape));
output_string os "Set";
let rank = shape.Rank
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaILGlobals.typ_int32) @ [dt])
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaMscorlibILGlobals.typ_Int32) @ [dt])
| I_ldelem_any (shape,tok) ->
if shape = ILArrayShape.SingleDimensional then
output_string os "ldelem.any "; goutput_typ env os tok
Expand All @@ -723,7 +722,7 @@ let rec goutput_instr env os inst =
goutput_dlocref env os (mkILArrTy(tok,shape));
output_string os "Get";
let rank = shape.Rank
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaILGlobals.typ_int32))
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaMscorlibILGlobals.typ_Int32))
| I_ldelema (ro,_,shape,tok) ->
if ro = ReadonlyAddress then output_string os "readonly. ";
if shape = ILArrayShape.SingleDimensional then
Expand All @@ -735,7 +734,7 @@ let rec goutput_instr env os inst =
goutput_dlocref env os (mkILArrTy(tok,shape));
output_string os "Address";
let rank = shape.Rank
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaILGlobals.typ_int32))
output_parens (output_seq "," (goutput_typ env)) os (Array.toList (Array.create ( rank) EcmaMscorlibILGlobals.typ_Int32))

| I_box tok -> output_string os "box "; goutput_typ env os tok
| I_unbox tok -> output_string os "unbox "; goutput_typ env os tok
Expand Down
Loading