Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2017-05-19 02:20:48 +0300
committerGitHub <noreply@github.com>2017-05-19 02:20:48 +0300
commitca3766137cd79eb34c016f057ab1f7f85b7f0459 (patch)
tree15ddeac503bd2eadb6d401498bd9e0fcb41bb683 /src
parent5965b5f6980ecb2620bb0db25c0073c80079a3e4 (diff)
CV Array type (#3639)
* update ObjectWriter * small types fixes * CodeView: ArrayType * Use mangled names CV has unique indexes and use them to link types inside, but somehow not-unique names create conflicts. Use mangled names to avoid them. * Use an Object Initializer
Diffstat (limited to 'src')
-rw-r--r--src/Common/src/TypeSystem/TypesDebugInfoWriter/TypesDebugInfoWriter.cs21
-rw-r--r--src/Common/src/TypeSystem/TypesDebugInfoWriter/UserDefinedTypeDescriptor.cs77
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs13
-rw-r--r--src/packaging/packages.targets2
-rw-r--r--src/packaging/project.json2
5 files changed, 90 insertions, 25 deletions
diff --git a/src/Common/src/TypeSystem/TypesDebugInfoWriter/TypesDebugInfoWriter.cs b/src/Common/src/TypeSystem/TypesDebugInfoWriter/TypesDebugInfoWriter.cs
index a44a79457..e51df2b6e 100644
--- a/src/Common/src/TypeSystem/TypesDebugInfoWriter/TypesDebugInfoWriter.cs
+++ b/src/Common/src/TypeSystem/TypesDebugInfoWriter/TypesDebugInfoWriter.cs
@@ -12,7 +12,11 @@ namespace Internal.TypeSystem.TypesDebugInfo
uint GetClassTypeIndex(ClassTypeDescriptor classTypeDescriptor);
- uint GetCompleteClassTypeIndex(ClassTypeDescriptor classTypeDescriptor, ClassFieldsTypeDescriptor classFieldsTypeDescriptior, DataFieldDescriptor[] fields);
+ uint GetCompleteClassTypeIndex(ClassTypeDescriptor classTypeDescriptor, ClassFieldsTypeDescriptor classFieldsTypeDescriptor, DataFieldDescriptor[] fields);
+
+ uint GetArrayTypeIndex(ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayTypeDescriprtor);
+
+ string GetMangledName(TypeDesc type);
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -25,7 +29,7 @@ namespace Internal.TypeSystem.TypesDebugInfo
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct EnumTypeDescriptor
{
- public ulong ElementType;
+ public uint ElementType;
public ulong ElementCount;
public string Name;
public string UniqueName;
@@ -44,14 +48,23 @@ namespace Internal.TypeSystem.TypesDebugInfo
public struct DataFieldDescriptor
{
public uint FieldTypeIndex;
- public int Offset;
+ public ulong Offset;
public string Name;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ClassFieldsTypeDescriptor
{
- public int Size;
+ public ulong Size;
public int FieldsCount;
}
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ public struct ArrayTypeDescriptor
+ {
+ public uint Rank;
+ public uint ElementType;
+ public uint Size;
+ public int IsMultiDimensional;
+ }
}
diff --git a/src/Common/src/TypeSystem/TypesDebugInfoWriter/UserDefinedTypeDescriptor.cs b/src/Common/src/TypeSystem/TypesDebugInfoWriter/UserDefinedTypeDescriptor.cs
index 9feab0fe3..d79434d46 100644
--- a/src/Common/src/TypeSystem/TypesDebugInfoWriter/UserDefinedTypeDescriptor.cs
+++ b/src/Common/src/TypeSystem/TypesDebugInfoWriter/UserDefinedTypeDescriptor.cs
@@ -51,6 +51,10 @@ namespace Internal.TypeSystem.TypesDebugInfo
{
return GetEnumTypeIndex(type);
}
+ else if (type.IsArray)
+ {
+ return GetArrayTypeIndex(type);
+ }
else if (type.IsDefType)
{
return GetClassTypeIndex(type, needsCompleteType);
@@ -63,7 +67,6 @@ namespace Internal.TypeSystem.TypesDebugInfo
System.Diagnostics.Debug.Assert(type.IsEnum, "GetEnumTypeIndex was called with wrong type");
DefType defType = type as DefType;
System.Diagnostics.Debug.Assert(defType != null, "GetEnumTypeIndex was called with non def type");
- EnumTypeDescriptor enumTypeDescriptor = new EnumTypeDescriptor();
List<FieldDesc> fieldsDescriptors = new List<FieldDesc>();
foreach (var field in defType.GetFields())
{
@@ -72,10 +75,13 @@ namespace Internal.TypeSystem.TypesDebugInfo
fieldsDescriptors.Add(field);
}
}
- enumTypeDescriptor.ElementCount = (ulong)fieldsDescriptors.Count;
- enumTypeDescriptor.ElementType = PrimitiveTypeDescriptor.GetPrimitiveTypeIndex(defType.UnderlyingType);
- enumTypeDescriptor.Name = defType.Name;
- enumTypeDescriptor.UniqueName = defType.GetFullName();
+ EnumTypeDescriptor enumTypeDescriptor = new EnumTypeDescriptor
+ {
+ ElementCount = (ulong)fieldsDescriptors.Count,
+ ElementType = PrimitiveTypeDescriptor.GetPrimitiveTypeIndex(defType.UnderlyingType),
+ Name = _objectWriter.GetMangledName(type),
+ UniqueName = defType.GetFullName()
+ };
EnumRecordTypeDescriptor[] typeRecords = new EnumRecordTypeDescriptor[enumTypeDescriptor.ElementCount];
for (int i = 0; i < fieldsDescriptors.Count; ++i)
{
@@ -91,6 +97,31 @@ namespace Internal.TypeSystem.TypesDebugInfo
return typeIndex;
}
+ public uint GetArrayTypeIndex(TypeDesc type)
+ {
+ System.Diagnostics.Debug.Assert(type.IsArray, "GetArrayTypeIndex was called with wrong type");
+ ArrayType arrayType = (ArrayType)type;
+ ArrayTypeDescriptor arrayTypeDescriptor = new ArrayTypeDescriptor
+ {
+ Rank = (uint)arrayType.Rank,
+ ElementType = GetVariableTypeIndex(arrayType.ElementType, false),
+ Size = (uint)arrayType.GetElementSize().AsInt,
+ IsMultiDimensional = arrayType.IsMdArray ? 1 : 0
+ };
+
+ ClassTypeDescriptor classDescriptor = new ClassTypeDescriptor
+ {
+ IsStruct = 0,
+ Name = _objectWriter.GetMangledName(type),
+ BaseClassId = GetVariableTypeIndex(arrayType.BaseType, false)
+ };
+
+ uint typeIndex = _objectWriter.GetArrayTypeIndex(classDescriptor, arrayTypeDescriptor);
+ _knownTypes[type] = typeIndex;
+ _completeKnownTypes[type] = typeIndex;
+ return typeIndex;
+ }
+
public ulong GetEnumRecordValue(FieldDesc field)
{
var ecmaField = field as EcmaField;
@@ -139,27 +170,33 @@ namespace Internal.TypeSystem.TypesDebugInfo
{
DefType defType = type as DefType;
System.Diagnostics.Debug.Assert(defType != null, "GetClassTypeIndex was called with non def type");
- ClassTypeDescriptor classTypeDescriptor = new ClassTypeDescriptor();
- classTypeDescriptor.IsStruct = type.IsValueType ? 1 : 0;
- classTypeDescriptor.Name = defType.Name;
- classTypeDescriptor.UniqueName = defType.GetFullName();
- classTypeDescriptor.BaseClassId = 0;
+ ClassTypeDescriptor classTypeDescriptor = new ClassTypeDescriptor
+ {
+ IsStruct = type.IsValueType ? 1 : 0,
+ Name = _objectWriter.GetMangledName(type),
+ UniqueName = defType.GetFullName(),
+ BaseClassId = 0
+ };
+
+ uint typeIndex = _objectWriter.GetClassTypeIndex(classTypeDescriptor);
+ _knownTypes[type] = typeIndex;
+
if (type.HasBaseType && !type.IsValueType)
{
classTypeDescriptor.BaseClassId = GetVariableTypeIndex(defType.BaseType, false);
}
- uint typeIndex = _objectWriter.GetClassTypeIndex(classTypeDescriptor);
- _knownTypes[type] = typeIndex;
List<DataFieldDescriptor> fieldsDescs = new List<DataFieldDescriptor>();
foreach (var fieldDesc in defType.GetFields())
{
if (fieldDesc.HasRva || fieldDesc.IsLiteral)
continue;
- DataFieldDescriptor field = new DataFieldDescriptor();
- field.FieldTypeIndex = GetVariableTypeIndex(fieldDesc.FieldType, false);
- field.Offset = fieldDesc.Offset.AsInt;
- field.Name = fieldDesc.Name;
+ DataFieldDescriptor field = new DataFieldDescriptor
+ {
+ FieldTypeIndex = GetVariableTypeIndex(fieldDesc.FieldType, false),
+ Offset = (ulong)fieldDesc.Offset.AsInt,
+ Name = fieldDesc.Name
+ };
fieldsDescs.Add(field);
}
@@ -168,9 +205,11 @@ namespace Internal.TypeSystem.TypesDebugInfo
{
fields[i] = fieldsDescs[i];
}
- ClassFieldsTypeDescriptor fieldsDescriptor = new ClassFieldsTypeDescriptor();
- fieldsDescriptor.FieldsCount = fieldsDescs.Count;
- fieldsDescriptor.Size = defType.GetElementSize().AsInt;
+ ClassFieldsTypeDescriptor fieldsDescriptor = new ClassFieldsTypeDescriptor
+ {
+ Size = (ulong)defType.GetElementSize().AsInt,
+ FieldsCount = fieldsDescs.Count
+ };
uint completeTypeIndex = _objectWriter.GetCompleteClassTypeIndex(classTypeDescriptor, fieldsDescriptor, fields);
_completeKnownTypes[type] = completeTypeIndex;
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs
index 0d7856cc2..f223bb8ef 100644
--- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/ObjectWriter.cs
@@ -276,6 +276,19 @@ namespace ILCompiler.DependencyAnalysis
}
[DllImport(NativeObjectWriterFileName)]
+ private static extern uint GetArrayTypeIndex(IntPtr objWriter, ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayTypeDescriptor);
+
+ public uint GetArrayTypeIndex(ClassTypeDescriptor classDescriptor, ArrayTypeDescriptor arrayTypeDescriptor)
+ {
+ return GetArrayTypeIndex(_nativeObjectWriter, classDescriptor, arrayTypeDescriptor);
+ }
+
+ public string GetMangledName(TypeDesc type)
+ {
+ return _nodeFactory.NameMangler.GetMangledTypeName(type);
+ }
+
+ [DllImport(NativeObjectWriterFileName)]
private static extern void EmitDebugVar(IntPtr objWriter, string name, UInt32 typeIndex, bool isParam, Int32 rangeCount, NativeVarInfo[] range);
public void EmitDebugVar(DebugVarInfo debugVar)
diff --git a/src/packaging/packages.targets b/src/packaging/packages.targets
index be4c18c82..4eca706c3 100644
--- a/src/packaging/packages.targets
+++ b/src/packaging/packages.targets
@@ -32,7 +32,7 @@
<MicrosoftNetCoreNativePackageVersion>2.0.0-beta-25021-03</MicrosoftNetCoreNativePackageVersion>
- <ObjectWriterPackageVersion>1.0.17-prerelease-00002</ObjectWriterPackageVersion>
+ <ObjectWriterPackageVersion>1.0.18-prerelease-00001</ObjectWriterPackageVersion>
<ObjectWriterNuPkgRid Condition="'$(OSGroup)'=='Linux'">ubuntu.14.04-x64</ObjectWriterNuPkgRid>
<ObjectWriterNuPkgRid Condition="'$(ObjectWriterNuPkgRid)'==''">$(NuPkgRid)</ObjectWriterNuPkgRid>
</PropertyGroup>
diff --git a/src/packaging/project.json b/src/packaging/project.json
index 76fb2b9bb..9bf0d8e27 100644
--- a/src/packaging/project.json
+++ b/src/packaging/project.json
@@ -1,7 +1,7 @@
{
"dependencies": {
"Microsoft.NETCore.Jit": "2.0.0-preview2-25311-01",
- "Microsoft.DotNet.ObjectWriter": "1.0.17-prerelease-00002"
+ "Microsoft.DotNet.ObjectWriter": "1.0.18-prerelease-00001"
},
"frameworks": {
"dnxcore50": { }