Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@@ -19,7 +19,7 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup>
<NuGetTargetMoniker>.NETCore,Version=v5.0</NuGetTargetMoniker>
<NuGetTargetMoniker>UAP,Version=v10.1</NuGetTargetMoniker>
<NuGetRuntimeIdentifier>win8-aot</NuGetRuntimeIdentifier>
</PropertyGroup>
</Project>

View File

@@ -1,30 +1,30 @@
{
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1",
"System.Runtime": "4.0.20",
"System.Reflection.Primitives":"4.0.0",
"System.Runtime.Extensions": "4.0.10",
"System.Diagnostics.Tracing": "4.0.20",
"System.Collections": "4.0.10",
"System.Resources.ResourceManager": "4.0.0",
"System.Console": "4.0.0",
"Microsoft.NETCore.Platforms": "1.2.0-beta-24906-01",
"System.Runtime": "4.4.0-beta-24906-01",
"System.Reflection.Primitives":"4.4.0-beta-24906-01",
"System.Runtime.Extensions": "4.4.0-beta-24906-01",
"System.Diagnostics.Tracing": "4.4.0-beta-24906-01",
"System.Collections": "4.4.0-beta-24906-01",
"System.Resources.ResourceManager": "4.4.0-beta-24906-01",
"System.Console": "4.4.0-beta-24906-01",
"System.Threading.Tasks": "4.0.10",
"System.Text.Encoding.Extensions": "4.0.10",
"System.Reflection.TypeExtensions": "4.0.0",
"System.Runtime.InteropServices": "4.0.20",
"System.Private.Uri": "4.0.0",
"System.IO": "4.0.10",
"System.Globalization": "4.0.10",
"System.ObjectModel": "4.0.10",
"System.Collections.Concurrent": "4.0.10",
"System.Reflection.Metadata": "1.4.1-beta-24227-04",
"System.Collections.Immutable": "1.2.0"
"System.Threading.Tasks": "4.4.0-beta-24906-01",
"System.Text.Encoding.Extensions": "4.4.0-beta-24906-01",
"System.Reflection.TypeExtensions": "4.4.0-beta-24906-01",
"System.Runtime.InteropServices": "4.4.0-beta-24906-01",
"System.Private.Uri": "4.4.0-beta-24906-01",
"System.IO": "4.4.0-beta-24906-01",
"System.Globalization": "4.4.0-beta-24906-01",
"System.ObjectModel": "4.4.0-beta-24906-01",
"System.Collections.Concurrent": "4.4.0-beta-24906-01",
"System.Reflection.Metadata": "1.4.2",
"System.Collections.Immutable": "1.3.1"
},
"frameworks": {
"netcore50": {}
"uap10.1": { }
},
"runtimes" : {
"win8-aot": { }
"win8-aot": { }
}
}

View File

@@ -1,13 +1,18 @@
<Project ToolsVersion="14.0" DefaultTargets="BuildAllFrameworkLibraries" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="CreateLib" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IlcCompileDependsOn>BuildOneFrameworkLibrary</IlcCompileDependsOn>
<CreateLibDependsOn>BuildAllFrameworkLibrariesAsSingleLib</CreateLibDependsOn>
<IlcMultiModule>true</IlcMultiModule>
<NativeIntermediateOutputPath Condition="'$(FrameworkObjPath)' != ''">$(FrameworkObjPath)\</NativeIntermediateOutputPath>
<BuildingFrameworkLibrary>true</BuildingFrameworkLibrary>
</PropertyGroup>
<Import Project="Microsoft.NETCore.Native.targets" />
<Target Name="BuildAllFrameworkLibraries">
<Target Name="BuildAllFrameworkLibraries"
Inputs="@(IlcReference)"
Outputs="@(IlcReference->'$(NativeIntermediateOutputPath)\%(Filename)$(NativeObjectExt)')">
<ItemGroup>
<ProjectToBuild Include="$(MSBuildProjectFullPath)">
<AdditionalProperties>
@@ -18,9 +23,18 @@
<MSBuild Projects="@(ProjectToBuild)" Targets="IlcCompile" BuildInParallel="true" />
</Target>
<Target Name="BuildAllFrameworkLibrariesAsSingleLib"
DependsOnTargets="BuildAllFrameworkLibraries">
<ItemGroup>
<LibInputs Include="$(NativeIntermediateOutputPath)\*$(NativeObjectExt)" />
</ItemGroup>
</Target>
<Target Name="BuildOneFrameworkLibrary">
<ItemGroup>
<ManagedBinary Include="$(LibraryToCompile)" />
<IlcCompileInput Include="@(ManagedBinary)" />
</ItemGroup>
</Target>

View File

@@ -20,17 +20,19 @@ See the LICENSE file in the project root for more information.
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang-3.9</CppCompilerAndLinker>
<CppCompiler>$(CppCompilerAndLinker)</CppCompiler>
<CppLinker>$(CppCompilerAndLinker)</CppLinker>
<CppLibCreator>ar</CppLibCreator>
</PropertyGroup>
<ItemGroup>
<CppCompilerAndLinkerArg Include="-I $(IlcPath)/inc" />
<CppCompilerAndLinkerArg Condition="'$(Configuration)' == 'Debug'" Include="-O0" />
<CppCompilerAndLinkerArg Condition="'$(Configuration)' == 'Debug'" Include="-g -O0" />
<CppCompilerAndLinkerArg Condition="'$(Configuration)' != 'Debug'" Include="-O2" />
<CppCompilerAndLinkerArg Include="-c -Wno-invalid-offsetof" />
<CppCompilerAndLinkerArg Include="$(AdditionalCppCompilerFlags)" />
</ItemGroup>
<ItemGroup>
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true' and $(NativeCodeGen) == ''" Include="$(SharedLibrary)" />
<NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)/sdk/libbootstrapper.a" />
<NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)/sdk/libRuntime.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)/sdk/libbootstrappercpp.a" />
@@ -40,6 +42,7 @@ See the LICENSE file in the project root for more information.
<ItemGroup>
<AdditionalNativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Native.a" />
<AdditionalNativeLibrary Include="$(IlcPath)/framework/libSystem.Globalization.Native.a" />
</ItemGroup>
<ItemGroup>
@@ -51,5 +54,6 @@ See the LICENSE file in the project root for more information.
<LinkerArg Include="-ldl" />
<LinkerArg Include="-lm" />
<LinkerArg Include="-lrt" Condition="'$(TargetOS)' != 'OSX'" />
<LinkerArg Include="-licucore" Condition="'$(TargetOS)' == 'OSX'" />
</ItemGroup>
</Project>

View File

@@ -19,6 +19,7 @@ See the LICENSE file in the project root for more information.
<PropertyGroup>
<CppCompiler>cl</CppCompiler>
<CppLinker>link</CppLinker>
<CppLibCreator>lib</CppLibCreator>
</PropertyGroup>
<ItemGroup>
@@ -36,6 +37,7 @@ See the LICENSE file in the project root for more information.
<NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)\sdk\Runtime.lib" />
<NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)\sdk\bootstrappercpp.lib" />
<NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)\sdk\PortableRuntime.lib" />
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true' and $(NativeCodeGen) == ''" Include="$(SharedLibrary)" />
</ItemGroup>
<ItemGroup>
@@ -50,6 +52,7 @@ See the LICENSE file in the project root for more information.
<AdditionalNativeLibrary Include="oleaut32.lib" />
<AdditionalNativeLibrary Include="uuid.lib" />
<AdditionalNativeLibrary Include="bcrypt.lib" />
<AdditionalNativeLibrary Include="normaliz.lib" />
</ItemGroup>
<ItemGroup>

View File

@@ -28,6 +28,8 @@ See the LICENSE file in the project root for more information.
<PropertyGroup>
<NativeObjectExt Condition="'$(TargetOS)' == 'Windows_NT'">.obj</NativeObjectExt>
<NativeObjectExt Condition="'$(TargetOS)' != 'Windows_NT'">.o</NativeObjectExt>
<LibFileExt Condition="'$(TargetOS)' == 'Windows_NT'">.lib</LibFileExt>
<LibFileExt Condition="'$(TargetOS)' != 'Windows_NT'">.a</LibFileExt>
<IlcOutputFileExt>$(NativeObjectExt)</IlcOutputFileExt>
<IlcOutputFileExt Condition="$(NativeCodeGen) == 'cpp'">.cpp</IlcOutputFileExt>
@@ -46,39 +48,59 @@ See the LICENSE file in the project root for more information.
<IlcCompileOutput Condition="$(NativeCodeGen) == 'cpp'">$(NativeIntermediateOutputPath)$(TargetName).cpp</IlcCompileOutput>
<LinkNativeDependsOn Condition="$(NativeCodeGen) == ''">IlcCompile</LinkNativeDependsOn>
<LinkNativeDependsOn Condition="$(NativeCodeGen) == 'cpp'">CppCompile</LinkNativeDependsOn>
<FrameworkLibPath Condition="'$(FrameworkLibPath)' == ''">$(NativeOutputPath)</FrameworkLibPath>
<FrameworkObjPath Condition="'$(FrameworkObjPath)' == ''">$(NativeIntermediateOutputPath)</FrameworkObjPath>
<SharedLibrary Condition="'$(OS)' == 'Windows_NT'">$(FrameworkLibPath)\Framework$(LibFileExt)</SharedLibrary>
<SharedLibrary Condition="'$(OS)' != 'Windows_NT'">$(FrameworkLibPath)\libframework$(LibFileExt)</SharedLibrary>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="$(BuildingFrameworkLibrary) != 'true'">
<ManagedBinary Include="$(IntermediateOutputPath)$(TargetName)$(TargetExt)" />
</ItemGroup>
<ItemGroup>
<IlcCompileInput Include="@(ManagedBinary)" />
<IlcReference Include="$(IlcPath)\sdk\*.dll" />
<IlcReference Include="$(IlcPath)\framework\*.dll" />
</ItemGroup>
<PropertyGroup>
<IlcCompileDependsOn Condition="'$(IlcCompileDependsOn)'==''">Compile</IlcCompileDependsOn>
<PropertyGroup Condition="'$(IlcCompileDependsOn)'==''">
<IlcCompileDependsOn Condition="'$(BuildingFrameworkLibrary)' != 'true'">Compile</IlcCompileDependsOn>
<IlcCompileDependsOn Condition="'$(IlcMultiModule)' == 'true' and '$(BuildingFrameworkLibrary)' != 'true'">$(IlcCompileDependsOn);BuildFrameworkLib</IlcCompileDependsOn>
</PropertyGroup>
<Target Name="IlcFramework">
<!--
BuildFrameworkLib is invoked before IlcCompile in multi-module builds to
produce the shared framework library on demand
-->
<Target Name="BuildFrameworkLib" Condition="'$(DisableFrameworkLibGeneration)' != 'true'">
<ItemGroup>
<ManagedBinary Include="@(IlcReference)" />
<ProjectToBuild Include="$(MSBuildThisFileDirectory)\BuildFrameworkNativeObjects.proj">
<AdditionalProperties>
IntermediateOutputPath=$(IntermediateOutputPath);
FrameworkLibPath=$(FrameworkLibPath);
FrameworkObjPath=$(FrameworkObjPath)
</AdditionalProperties>
</ProjectToBuild>
</ItemGroup>
<MSBuild Projects="@(ProjectToBuild)" BuildInParallel="true" />
</Target>
<Target Name="IlcCompile"
Inputs="@(ManagedBinary)"
Outputs="$(NativeIntermediateOutputPath)%(Filename)$(IlcOutputFileExt)"
Inputs="@(IlcCompileInput)"
Outputs="$(NativeIntermediateOutputPath)%(ManagedBinary.Filename)$(IlcOutputFileExt)"
DependsOnTargets="$(IlcCompileDependsOn)">
<ItemGroup>
<IlcArg Include="@(ManagedBinary)" />
<IlcArg Include="-o:$(NativeIntermediateOutputPath)%(Filename)$(IlcOutputFileExt)" />
<IlcArg Include="@(IlcCompileInput)" />
<IlcArg Include="-o:$(NativeIntermediateOutputPath)%(ManagedBinary.Filename)$(IlcOutputFileExt)" />
<IlcArg Include="@(IlcReference->'-r:%(Identity)')" />
<IlcArg Condition="$(NativeCodeGen) != ''" Include="--$(NativeCodeGen)" />
<IlcArg Condition="$(IlcMultiModule) == 'true'" Include="--multifile" />
<IlcArg Condition="$(Optimize) == 'true'" Include="-O" />
<IlcArg Condition="$(DebugSymbols) == 'true'" Include="-g" />
</ItemGroup>
<MakeDir Directories="$(NativeIntermediateOutputPath)" />
@@ -118,7 +140,7 @@ See the LICENSE file in the project root for more information.
</Target>
<Target Name="LinkNative"
Inputs="$(NativeObject)"
Inputs="$(NativeObject);@(NativeLibrary)"
Outputs="$(NativeBinary)"
DependsOnTargets="$(LinkNativeDependsOn)">
@@ -134,4 +156,20 @@ See the LICENSE file in the project root for more information.
<WriteLinesToFile File="$(NativeIntermediateOutputPath)link.rsp" Lines="@(CustomLinkerArg)" Overwrite="true" Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="$(CppLinker) @&quot;$(NativeIntermediateOutputPath)link.rsp&quot;" Condition="'$(OS)' == 'Windows_NT'" />
</Target>
<Target Name="CreateLib"
Inputs="@(LibInputs)"
Outputs="$(SharedLibrary)"
DependsOnTargets="$(CreateLibDependsOn)">
<ItemGroup>
<CustomLibArg Include="/out:$(SharedLibrary)" Condition="'$(OS)' == 'Windows_NT'" />
<CustomLibArg Include="-crs $(SharedLibrary)" Condition="'$(OS)' != 'Windows_NT'" />
<CustomLibArg Include="@(LibInputs->'%(Identity)')" />
</ItemGroup>
<WriteLinesToFile File="$(NativeIntermediateOutputPath)lib.rsp" Lines="@(CustomLibArg)" Overwrite="true" Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="$(CppLibCreator) @&quot;$(NativeIntermediateOutputPath)lib.rsp&quot;" Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="$(CppLibCreator) @(CustomLibArg, ' ')" Condition="'$(OS)' != 'Windows_NT'" />
</Target>
</Project>

View File

@@ -76,12 +76,6 @@ class MdBinaryReaderGen : CsWriter
private void EmitReadPrimitiveCollection(string typeName)
{
if (typeName == "String")
{
EmitReadCollection(typeName);
return;
}
string collectionTypeName = $"{typeName}Collection";
OpenScope($"public static unsafe uint Read(this NativeReader reader, uint offset, out {collectionTypeName} values)");

View File

@@ -10,7 +10,6 @@
<RootNamespace>NativeFormatGen</RootNamespace>
<AssemblyName>NativeFormatGen</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View File

@@ -200,7 +200,6 @@ class SchemaDef
{
new PrimitiveType("bool", "Boolean"),
new PrimitiveType("char", "Char"),
new PrimitiveType("string", "String"),
new PrimitiveType("byte", "Byte"),
new PrimitiveType("sbyte", "SByte"),
new PrimitiveType("short", "Int16"),
@@ -305,6 +304,12 @@ class SchemaDef
members: new MemberDef[] {
new MemberDef(name: "Value", typeName: "Object", flags: MemberDefFlags.NotPersisted)
}
),
new RecordDef(
name: "ConstantStringValue",
members: new MemberDef[] {
new MemberDef(name: "Value", typeName: "string")
}
)
}
)
@@ -333,6 +338,12 @@ class SchemaDef
members: new MemberDef[] {
new MemberDef(name: "Value", flags: MemberDefFlags.RecordRef | MemberDefFlags.List)
}
),
new RecordDef(
name: "ConstantStringArray",
members: new MemberDef[] {
new MemberDef(name: "Value", typeName: new string[] { "ConstantStringValue", "ConstantReferenceValue" }, flags: MemberDefFlags.RecordRef | MemberDefFlags.List)
}
)
}
)
@@ -602,7 +613,7 @@ class SchemaDef
name: "ConstantBoxedEnumValue",
members: new MemberDef[] {
new MemberDef("Value", EnumConstantValue, MemberDefFlags.RecordRef | MemberDefFlags.Child),
new MemberDef("Type", TypeDefOrRef, MemberDefFlags.RecordRef)
new MemberDef("Type", TypeDefOrRefOrSpec, MemberDefFlags.RecordRef)
}
),
new RecordDef(

View File

@@ -35,18 +35,6 @@ namespace Internal.Metadata.NativeFormat
return offset;
} // Read
public static uint Read(this NativeReader reader, uint offset, out StringCollection values)
{
values = new StringCollection(reader, offset);
uint count;
offset = reader.DecodeUnsigned(offset, out count);
for (uint i = 0; i < count; ++i)
{
offset = reader.SkipInteger(offset);
}
return offset;
} // Read
public static unsafe uint Read(this NativeReader reader, uint offset, out ByteCollection values)
{
values = new ByteCollection(reader, offset);

View File

@@ -1 +1 @@
a62ecf1b6c73cedce7888a0876388aafc95acfdf
f428223f966844c92e4f2308c31994590b74a6df

View File

@@ -98,6 +98,8 @@ namespace Internal.NativeFormat
NonGenericConstrainedMethod = 0x16,
GenericConstrainedMethod = 0x17,
NonGenericDirectConstrainedMethod = 0x18,
PointerToOtherSlot = 0x19,
IntValue = 0x20,
NotYetSupported = 0xee,
}

View File

@@ -433,6 +433,30 @@ namespace Internal.NativeFormat
return Unify(sig);
}
public Vertex GetFieldSignature(Vertex containingType, string name)
{
FieldSignature sig = new FieldSignature(containingType, name);
return Unify(sig);
}
public Vertex GetFixupSignature(FixupSignatureKind kind, Vertex signature)
{
FixupSignature sig = new FixupSignature(kind, signature);
return Unify(sig);
}
public Vertex GetStaticDataSignature(Vertex type, StaticDataKind staticDataKind)
{
StaticDataSignature sig = new StaticDataSignature(type, staticDataKind);
return Unify(sig);
}
public Vertex GetMethodSlotSignature(Vertex type, uint slot)
{
MethodSlotSignature sig = new MethodSlotSignature(type, slot);
return Unify(sig);
}
public Vertex GetMethodSigSignature(uint callingConvention, uint genericArgCount, Vertex returnType, Vertex[] parameters)
{
MethodSigSignature sig = new MethodSigSignature(callingConvention, genericArgCount, returnType, parameters);
@@ -462,6 +486,12 @@ namespace Internal.NativeFormat
MDArrayTypeSignature sig = new MDArrayTypeSignature(elementType, rank, bounds, lowerBounds);
return Unify(sig);
}
public Vertex GetCallingConventionConverterSignature(uint flags, Vertex signature)
{
CallingConventionConverterSignature sig = new CallingConventionConverterSignature(flags, GetRelativeOffsetSignature(signature));
return Unify(sig);
}
}
class PlacedVertex : Vertex
@@ -549,6 +579,98 @@ namespace Internal.NativeFormat
}
}
//
// Bag of <id, data> pairs. Good for extensible information (e.g. type info)
//
// Data can be either relative offset of another vertex, or arbitrary integer.
//
#if NATIVEFORMAT_PUBLICWRITER
public
#else
internal
#endif
class VertexBag : Vertex
{
enum EntryType { Vertex, Unsigned, Signed }
struct Entry
{
internal BagElementKind _id;
internal EntryType _type;
internal object _value;
internal Entry(BagElementKind id, Vertex value)
{
_id = id;
_type = EntryType.Vertex;
_value = value;
}
internal Entry(BagElementKind id, uint value)
{
_id = id;
_type = EntryType.Unsigned;
_value = value;
}
internal Entry(BagElementKind id, int value)
{
_id = id;
_type = EntryType.Signed;
_value = value;
}
}
private List<Entry> _elements;
public VertexBag()
{
_elements = new List<Entry>();
}
public void Append(BagElementKind id, Vertex value)
{
_elements.Add(new Entry(id, value));
}
public void AppendUnsigned(BagElementKind id, uint value)
{
_elements.Add(new Entry(id, value));
}
public void AppendSigned(BagElementKind id, int value)
{
_elements.Add(new Entry(id, value));
}
internal override void Save(NativeWriter writer)
{
foreach (var elem in _elements)
{
writer.WriteUnsigned((uint)elem._id);
switch (elem._type)
{
case EntryType.Vertex:
writer.WriteRelativeOffset((Vertex)elem._value);
break;
case EntryType.Unsigned:
writer.WriteUnsigned((uint)elem._value);
break;
case EntryType.Signed:
writer.WriteSigned((int)elem._value);
break;
}
}
writer.WriteUnsigned((uint)BagElementKind.End);
}
public int ElementsCount => _elements.Count;
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else
@@ -872,6 +994,183 @@ namespace Internal.NativeFormat
}
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else
internal
#endif
class FieldSignature : Vertex
{
private Vertex _containingType;
private string _name;
public FieldSignature(Vertex containingType, string name)
{
_containingType = containingType;
_name = name;
}
internal override void Save(NativeWriter writer)
{
_containingType.Save(writer);
writer.WriteString(_name);
}
public override int GetHashCode()
{
int hash = 113 + 97 * _containingType.GetHashCode();
foreach (char c in _name)
hash += (hash << 5) + c * 19;
return hash;
}
public override bool Equals(object obj)
{
var other = obj as FieldSignature;
if (other == null)
return false;
if (!Object.Equals(other._containingType, _containingType))
return false;
if (!Object.Equals(other._name, _name))
return false;
return true;
}
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else
internal
#endif
class FixupSignature : Vertex
{
private FixupSignatureKind _kind;
private Vertex _signature;
public FixupSignature(FixupSignatureKind kind, Vertex signature)
{
_kind = kind;
_signature = signature;
}
internal override void Save(NativeWriter writer)
{
writer.WriteUnsigned((uint)_kind);
if (_signature != null)
_signature.Save(writer);
}
public override int GetHashCode()
{
return 53345 + 97 * (int)_kind + ((_signature != null) ? _signature.GetHashCode() : 0);
}
public override bool Equals(object obj)
{
var other = obj as FixupSignature;
if (other == null)
return false;
if (other._kind != _kind)
return false;
if (!Object.Equals(other._signature, _signature))
return false;
return true;
}
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else
internal
#endif
class StaticDataSignature : Vertex
{
private Vertex _type;
private StaticDataKind _staticDataKind;
public StaticDataSignature(Vertex type, StaticDataKind staticDataKind)
{
_type = type;
_staticDataKind = staticDataKind;
}
internal override void Save(NativeWriter writer)
{
_type.Save(writer);
writer.WriteUnsigned((uint)_staticDataKind);
}
public override int GetHashCode()
{
return 456789 + 101 * (int)_staticDataKind + _type.GetHashCode();
}
public override bool Equals(object obj)
{
var other = obj as StaticDataSignature;
if (other == null)
return false;
if (!Object.Equals(other._type, _type))
return false;
if (other._staticDataKind != _staticDataKind)
return false;
return true;
}
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else
internal
#endif
class MethodSlotSignature : Vertex
{
private Vertex _type;
private uint _slot;
public MethodSlotSignature(Vertex type, uint slot)
{
_type = type;
_slot = slot;
}
internal override void Save(NativeWriter writer)
{
_type.Save(writer);
writer.WriteUnsigned(_slot);
}
public override int GetHashCode()
{
return 124121 + 47 * (int)_slot + _type.GetHashCode();
}
public override bool Equals(object obj)
{
var other = obj as MethodSlotSignature;
if (other == null)
return false;
if (!Object.Equals(other._type, _type))
return false;
if (other._slot != _slot)
return false;
return true;
}
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else
@@ -1154,6 +1453,49 @@ namespace Internal.NativeFormat
}
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else
internal
#endif
class CallingConventionConverterSignature : Vertex
{
private uint _flags;
private Vertex _signature;
public CallingConventionConverterSignature(uint flags, Vertex signature)
{
_flags = flags;
_signature = signature;
}
internal override void Save(NativeWriter writer)
{
writer.WriteUnsigned(_flags);
_signature.Save(writer);
}
public override int GetHashCode()
{
return 509 * 197 + ((int)_flags) * 23 + 647 * _signature.GetHashCode();
}
public override bool Equals(object obj)
{
CallingConventionConverterSignature other = obj as CallingConventionConverterSignature;
if (other == null)
return false;
if (_flags != other._flags)
return false;
if (!_signature.Equals(other._signature))
return false;
return true;
}
}
#if NATIVEFORMAT_PUBLICWRITER
public
#else

View File

@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.IO;
namespace Internal.NativeFormat
{
#if NATIVEFORMAT_PUBLICWRITER
public
#else
internal
#endif
static class NativeFormatWriterExtensions
{
public static byte[] Save(this NativeWriter writer)
{
MemoryStream ms = new MemoryStream();
writer.Save(ms);
return ms.ToArray();
}
}
}

View File

@@ -12,17 +12,23 @@ using Debug = Internal.Runtime.CompilerHelpers.StartupDebug;
namespace Internal.Runtime.CompilerHelpers
{
[McgIntrinsics]
internal static partial class StartupCodeHelpers
public static partial class StartupCodeHelpers
{
public static IntPtr[] Modules
public static IntPtr[] OSModules
{
get; private set;
}
public static TypeManagerHandle[] Modules
{
get; private set;
}
[NativeCallable(EntryPoint = "InitializeModules", CallingConvention = CallingConvention.Cdecl)]
internal static void InitializeModules(IntPtr moduleHeaders, int count)
internal static void InitializeModules(IntPtr osModule, IntPtr moduleHeaders, int count)
{
IntPtr[] modules = CreateTypeManagers(moduleHeaders, count);
RuntimeImports.RhpRegisterOsModule(osModule);
TypeManagerHandle[] modules = CreateTypeManagers(osModule, moduleHeaders, count);
for (int i = 0; i < modules.Length; i++)
{
@@ -32,6 +38,7 @@ namespace Internal.Runtime.CompilerHelpers
// We are now at a stage where we can use GC statics - publish the list of modules
// so that the eager constructors can access it.
Modules = modules;
OSModules = new IntPtr[] { osModule };
// These two loops look funny but it's important to initialize the global tables before running
// the first class constructor to prevent them calling into another uninitialized module
@@ -41,7 +48,7 @@ namespace Internal.Runtime.CompilerHelpers
}
}
private static unsafe IntPtr[] CreateTypeManagers(IntPtr moduleHeaders, int count)
private static unsafe TypeManagerHandle[] CreateTypeManagers(IntPtr osModule, IntPtr moduleHeaders, int count)
{
// Count the number of modules so we can allocate an array to hold the TypeManager objects.
// At this stage of startup, complex collection classes will not work.
@@ -55,12 +62,12 @@ namespace Internal.Runtime.CompilerHelpers
moduleCount++;
}
IntPtr[] modules = new IntPtr[moduleCount];
TypeManagerHandle[] modules = new TypeManagerHandle[moduleCount];
int moduleIndex = 0;
for (int i = 0; i < count; i++)
{
if (((IntPtr*)moduleHeaders)[i] != IntPtr.Zero)
modules[moduleIndex++] = CreateTypeManager(((IntPtr*)moduleHeaders)[i]);
modules[moduleIndex++] = RuntimeImports.RhpCreateTypeManager(osModule, ((IntPtr*)moduleHeaders)[i]);
}
return modules;
@@ -71,7 +78,7 @@ namespace Internal.Runtime.CompilerHelpers
/// statics, etc that need initializing. InitializeGlobalTables walks through the modules
/// and offers each a chance to initialize its global tables.
/// </summary>
private static unsafe void InitializeGlobalTablesForModule(IntPtr typeManager, int moduleIndex)
private static unsafe void InitializeGlobalTablesForModule(TypeManagerHandle typeManager, int moduleIndex)
{
// Configure the module indirection cell with the newly created TypeManager. This allows EETypes to find
// their interface dispatch map tables.
@@ -80,6 +87,7 @@ namespace Internal.Runtime.CompilerHelpers
section->TypeManager = typeManager;
section->ModuleIndex = moduleIndex;
#if CORERT
// Initialize statics if any are present
IntPtr staticsSection = RuntimeImports.RhGetModuleSection(typeManager, ReadyToRunSectionType.GCStaticRegion, out length);
if (staticsSection != IntPtr.Zero)
@@ -87,6 +95,7 @@ namespace Internal.Runtime.CompilerHelpers
Debug.Assert(length % IntPtr.Size == 0);
InitializeStatics(staticsSection, length);
}
#endif
// Initialize frozen object segment with GC present
IntPtr frozenObjectSection = RuntimeImports.RhGetModuleSection(typeManager, ReadyToRunSectionType.FrozenObjectRegion, out length);
@@ -106,7 +115,7 @@ namespace Internal.Runtime.CompilerHelpers
}
}
private static unsafe void InitializeEagerClassConstructorsForModule(IntPtr typeManager)
private static unsafe void InitializeEagerClassConstructorsForModule(TypeManagerHandle typeManager)
{
int length;
@@ -158,16 +167,12 @@ namespace Internal.Runtime.CompilerHelpers
for (; str[len] != 0; len++) { }
return len;
}
[RuntimeImport(".", "RhpCreateTypeManager")]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern unsafe IntPtr CreateTypeManager(IntPtr moduleHeader);
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct TypeManagerSlot
{
public IntPtr TypeManager;
public TypeManagerHandle TypeManager;
public Int32 ModuleIndex;
}
}

View File

@@ -184,6 +184,16 @@ namespace Internal.Runtime
/// This EEType contains a pointer to dynamic module information
/// </summary>
HasDynamicModuleFlag = 0x00002000,
/// <summary>
/// This EEType is an abstract class (but not an interface).
/// </summary>
IsAbstractClassFlag = 0x00004000,
/// <summary>
/// This EEType is for a Byref-like class (TypedReference, Span&lt;T&gt;,...)
/// </summary>
IsByRefLikeFlag = 0x00008000,
}
internal enum EETypeField

View File

@@ -178,10 +178,9 @@ namespace Internal.Runtime
private UInt16 _usNumInterfaces;
private UInt32 _uHashCode;
#if CORERT
#if EETYPE_TYPE_MANAGER
private IntPtr _ppTypeManager;
#endif
// vtable follows
// These masks and paddings have been chosen so that the ValueTypePadding field can always fit in a byte of data.
@@ -500,6 +499,22 @@ namespace Internal.Runtime
}
}
internal bool IsAbstract
{
get
{
return IsInterface || (RareFlags & EETypeRareFlags.IsAbstractClassFlag) != 0;
}
}
internal bool IsByRefLike
{
get
{
return (RareFlags & EETypeRareFlags.IsByRefLikeFlag) != 0;
}
}
internal bool IsDynamicType
{
get
@@ -543,6 +558,12 @@ namespace Internal.Runtime
{
return _uBaseSize;
}
#if TYPE_LOADER_IMPLEMENTATION
set
{
_uBaseSize = value;
}
#endif
}
internal bool IsRelatedTypeViaIAT
@@ -1093,18 +1114,24 @@ namespace Internal.Runtime
#endif
}
#if CORERT
#if EETYPE_TYPE_MANAGER
internal IntPtr TypeManager
{
get
{
// This is always a pointer to a pointer to a module manager
// This is always a pointer to a pointer to a type manager
return *(IntPtr*)_ppTypeManager;
}
}
#if TYPE_LOADER_IMPLEMENTATION
internal IntPtr PointerToTypeManager
{
get
{
// This is always a pointer to a pointer to a type manager
return _ppTypeManager;
}
set
{
_ppTypeManager = value;

View File

@@ -88,17 +88,20 @@ namespace Internal.Runtime
flags |= (UInt16)EETypeFlags.HasFinalizerFlag;
}
if (type.IsDefType && ((DefType)type).ContainsGCPointers)
if (!type.IsCanonicalSubtype(CanonicalFormKind.Universal))
{
flags |= (UInt16)EETypeFlags.HasPointersFlag;
}
else if (type.IsArray)
{
var elementType = ((ArrayType)type).ElementType;
if ((elementType.IsValueType && ((DefType)elementType).ContainsGCPointers) || elementType.IsGCPointer)
if (type.IsDefType && ((DefType)type).ContainsGCPointers)
{
flags |= (UInt16)EETypeFlags.HasPointersFlag;
}
else if (type.IsArray)
{
var elementType = ((ArrayType)type).ElementType;
if ((elementType.IsValueType && ((DefType)elementType).ContainsGCPointers) || elementType.IsGCPointer)
{
flags |= (UInt16)EETypeFlags.HasPointersFlag;
}
}
}
if (type.HasInstantiation)
@@ -148,12 +151,12 @@ namespace Internal.Runtime
if (type.IsArray)
{
var elementType = ((ArrayType)type).ElementType;
if ((elementType.IsValueType) && ((DefType)elementType).InstanceByteAlignment > 4)
if ((elementType.IsValueType) && ((DefType)elementType).InstanceByteAlignment.AsInt > 4)
{
return true;
}
}
else if (type.IsDefType && ((DefType)type).InstanceByteAlignment > 4)
else if (type.IsDefType && ((DefType)type).InstanceByteAlignment.AsInt > 4)
{
return true;
}

View File

@@ -76,7 +76,7 @@ namespace Internal.Runtime
if (type.IsMdArray)
{
// Multi-dim arrays include upper and lower bounds for each rank
baseSize += 2 * type.Context.GetWellKnownType(WellKnownType.Int32).GetElementSize() * ((ArrayType)type).Rank;
baseSize += 2 * sizeof(int) * ((ArrayType)type).Rank;
}
if (elementType.IsGCPointer)
@@ -109,7 +109,7 @@ namespace Internal.Runtime
int offs = defType.IsValueType ? builder.TargetPointerSize : 0;
// Include syncblock
int objectSize = defType.InstanceByteCount + offs + builder.TargetPointerSize;
int objectSize = defType.InstanceByteCount.AsInt + offs + builder.TargetPointerSize;
EncodeStandardGCDesc(ref builder, GCPointerMap.FromInstanceLayout(defType), objectSize, offs);
}

View File

@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Internal.Runtime
{
//
// The low 2 bits of the interface dispatch cell's cache pointer are treated specially so that we can avoid the
// need for extra fields on the type.
//
// Keep these in sync with the native copy in src\Native\Runtime\inc\rhbinder.h
//
public enum InterfaceDispatchCellCachePointerFlags
{
CachePointerPointsAtCache = 0x0,
CachePointerIsInterfacePointerOrMetadataToken = 0x1,
CachePointerIsIndirectedInterfaceRelativePointer = 0x2,
CachePointerIsInterfaceRelativePointer = 0x3,
CachePointerMask = 0x3,
CachePointerMaskShift = 0x2,
MaxVTableOffsetPlusOne = 0x1000
}
}

Some files were not shown because too many files have changed in this diff Show More