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
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-01-17 20:52:11 +0300
committerGitHub <noreply@github.com>2017-01-17 20:52:11 +0300
commit82464aaa3404fc48ed8f0a5cf6c299c5d135afe9 (patch)
tree7bf2896dbd5526d792181f0463d80b001daf7d86
parent63cc02771ecd502794340b826671b4f90d214b0f (diff)
Fix handling of parametrized types in CppCodeGen (#2517)
- Use NameMangler.GetMangledTypeName directly to get the EEType name - Delete filtering of IsPointer and IsByRef during type emission since it works fine now - Add bigobj compiler switch to allow large auto generated .cpp files Fix #2486
-rw-r--r--Documentation/how-to-build-and-run-ilcompiler-in-visual-studio-2015.md2
-rw-r--r--src/BuildIntegration/Microsoft.NETCore.Native.Windows.props2
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs4
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/NameMangler.cs6
-rw-r--r--src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs23
-rw-r--r--src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs29
-rw-r--r--src/ILCompiler/reproNative/reproNativeCpp.vcxproj2
7 files changed, 31 insertions, 37 deletions
diff --git a/Documentation/how-to-build-and-run-ilcompiler-in-visual-studio-2015.md b/Documentation/how-to-build-and-run-ilcompiler-in-visual-studio-2015.md
index 108027363..e5d430f5b 100644
--- a/Documentation/how-to-build-and-run-ilcompiler-in-visual-studio-2015.md
+++ b/Documentation/how-to-build-and-run-ilcompiler-in-visual-studio-2015.md
@@ -52,7 +52,7 @@ _Note: The size of NuGet packages is approximately 2.75 GB, so download might ta
- Set startup command line to:
`@c:\corert\bin\obj\Windows_NT.x64.Debug\cpp.rsp`
- - `--nolinenumbers` command line option can be used to suppress generation of line number mappings in C++ files - useful for debugging
+ - `--codegenopt:nolinenumbers` command line option can be used to suppress generation of line number mappings in C++ files - useful for debugging
- Build & run using **F5**
- This will run the compiler. The output is `c:\corert\bin\obj\Windows_NT.x64.Debug\repro\native\repro.cpp` file.
diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.Windows.props b/src/BuildIntegration/Microsoft.NETCore.Native.Windows.props
index d36383bcc..edf33355c 100644
--- a/src/BuildIntegration/Microsoft.NETCore.Native.Windows.props
+++ b/src/BuildIntegration/Microsoft.NETCore.Native.Windows.props
@@ -25,7 +25,7 @@ See the LICENSE file in the project root for more information.
<CppCompilerAndLinkerArg Include="/I$(IlcPath)\inc" />
<CppCompilerAndLinkerArg Condition="'$(Configuration)' == 'Debug'" Include="/Od" />
<CppCompilerAndLinkerArg Condition="'$(Configuration)' != 'Debug'" Include="/O2" />
- <CppCompilerAndLinkerArg Include="/c /nologo /W3 /GS /DCPPCODEGEN /EHs /Zi" />
+ <CppCompilerAndLinkerArg Include="/c /nologo /W3 /GS /DCPPCODEGEN /EHs /Zi /bigobj" />
<CppCompilerAndLinkerArg Condition="'$(UseDebugCrt)' == 'true'" Include="/MTd" />
<CppCompilerAndLinkerArg Condition="'$(UseDebugCrt)' != 'true'" Include="/MT" />
<CppCompilerAndLinkerArg Include="$(AdditionalCppCompilerFlags)" />
diff --git a/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs b/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs
index eb3a3c07b..42b942ce2 100644
--- a/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/LibraryInitializers.cs
@@ -42,11 +42,11 @@ namespace ILCompiler
// We should not care which code-gen is being used, however currently CppCodeGen cannot
// handle code pulled in by all explicit cctors.
//
- // See https://github.com/dotnet/corert/issues/2486
+ // See https://github.com/dotnet/corert/issues/2518
//
_isCppCodeGen = isCppCodeGen;
}
-
+
public IList<MethodDesc> LibraryInitializerMethods
{
get
diff --git a/src/ILCompiler.Compiler/src/Compiler/NameMangler.cs b/src/ILCompiler.Compiler/src/Compiler/NameMangler.cs
index 4ebb2df61..c6f2e6335 100644
--- a/src/ILCompiler.Compiler/src/Compiler/NameMangler.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/NameMangler.cs
@@ -87,14 +87,14 @@ namespace ILCompiler
sb.Append("_");
}
- string santizedName = (sb != null) ? sb.ToString() : s;
+ string sanitizedName = (sb != null) ? sb.ToString() : s;
// The character sequences denoting generic instantiations, arrays, byrefs, or pointers must be
// restricted to that use only. Replace them if they happened to be used in any identifiers in
// the compilation input.
return _mangleForCplusPlus
- ? santizedName.Replace(EnterNameScopeSequence, "_AA_").Replace(ExitNameScopeSequence, "_VV_")
- : santizedName;
+ ? sanitizedName.Replace(EnterNameScopeSequence, "_AA_").Replace(ExitNameScopeSequence, "_VV_")
+ : sanitizedName;
}
/// <summary>
diff --git a/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs b/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs
index f4fc041f7..413f5db33 100644
--- a/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs
+++ b/src/ILCompiler.Compiler/src/CppCodeGen/CppWriter.cs
@@ -268,7 +268,7 @@ namespace ILCompiler.CppCodeGen
/// <returns>C++ declaration name for <param name="methodName"/>.</returns>
public string GetCppMethodDeclarationName(TypeDesc owningType, string methodName)
{
- var s = GetCppTypeName(owningType);
+ var s = _compilation.NameMangler.GetMangledTypeName(owningType);
if (s.StartsWith("::"))
{
// For a Method declaration we do not need the starting ::
@@ -297,10 +297,10 @@ namespace ILCompiler.CppCodeGen
public string SanitizeCppVarName(string varName)
{
// TODO: name mangling robustness
- if (varName == "errno") // some names collide with CRT headers
- varName += "_";
+ if (varName == "errno" || varName == "environ" || varName == "template" || varName == "typename") // some names collide with CRT headers
+ return "_" + varName + "_";
- return varName;
+ return _compilation.NameMangler.SanitizeName(varName);
}
private void CompileExternMethod(CppMethodCodeNode methodCodeNodeNeedingCode, string importName)
@@ -1023,15 +1023,14 @@ namespace ILCompiler.CppCodeGen
{
_emittedTypes = new HashSet<TypeDesc>();
}
+
TypeDesc nodeType = typeNode.Type;
- if (nodeType.IsPointer || nodeType.IsByRef || _emittedTypes.Contains(nodeType))
+ if (_emittedTypes.Contains(nodeType))
return;
-
_emittedTypes.Add(nodeType);
-
// Create Namespaces
- string mangledName = GetCppTypeName(nodeType);
+ string mangledName = _compilation.NameMangler.GetMangledTypeName(nodeType);
int nesting = 0;
int current = 0;
@@ -1074,7 +1073,6 @@ namespace ILCompiler.CppCodeGen
// TODO: Enable once the dependencies are tracked for arrays
// if (((DependencyNode)_compilation.NodeFactory.ConstructedTypeSymbol(t)).Marked)
- if (!nodeType.IsPointer && !nodeType.IsByRef)
{
typeDefinitions.AppendLine();
typeDefinitions.Append("static MethodTable * __getMethodTable();");
@@ -1140,11 +1138,8 @@ namespace ILCompiler.CppCodeGen
typeDefinitions.AppendEmptyLine();
// declare method table
- if (!nodeType.IsPointer && !nodeType.IsByRef)
- {
- methodTable.Append(GetCodeForObjectNode(typeNode as ObjectNode, factory));
- methodTable.AppendEmptyLine();
- }
+ methodTable.Append(GetCodeForObjectNode(typeNode as ObjectNode, factory));
+ methodTable.AppendEmptyLine();
}
private String GetCodeForReadyToRunHeader(ReadyToRunHeaderNode headerNode, NodeFactory factory)
diff --git a/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs b/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs
index 78e225be6..7aa132b61 100644
--- a/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs
+++ b/src/ILCompiler.Compiler/src/CppCodeGen/ILToCppImporter.cs
@@ -149,10 +149,10 @@ namespace Internal.IL
var localSlotToInfoMap = new Dictionary<int, ILLocalVariable>();
foreach (var v in localVariables)
{
- string sanitizedName = _compilation.NameMangler.SanitizeName(v.Name);
- if (!names.Add(v.Name))
+ string sanitizedName = _writer.SanitizeCppVarName(v.Name);
+ if (!names.Add(sanitizedName))
{
- sanitizedName = string.Format("{0}_local{1}", v.Name, v.Slot);
+ sanitizedName = string.Format("{0}_local{1}", sanitizedName, v.Slot);
names.Add(sanitizedName);
}
@@ -172,7 +172,7 @@ namespace Internal.IL
int index = 0;
foreach (var p in parameters)
{
- parameterIndexToNameMap[index] = p;
+ parameterIndexToNameMap[index] = _writer.SanitizeCppVarName(p);
++index;
}
@@ -422,7 +422,7 @@ namespace Internal.IL
if (_parameterIndexToNameMap != null && argument && _parameterIndexToNameMap.ContainsKey(index))
{
- return _writer.SanitizeCppVarName(_parameterIndexToNameMap[index]);
+ return _parameterIndexToNameMap[index];
}
return (argument ? "_a" : "_l") + index.ToStringInvariant();
@@ -2417,7 +2417,7 @@ namespace Internal.IL
"::",
_writer.GetCppMethodName(helper),
"((intptr_t)",
- _writer.GetCppTypeName((TypeDesc)ldtokenValue),
+ _compilation.NameMangler.GetMangledTypeName((TypeDesc)ldtokenValue),
"::__getMethodTable())");
value = new LdTokenEntry<TypeDesc>(StackValueKind.ValueType, name, (TypeDesc)ldtokenValue, GetWellKnownType(ldtokenKind));
@@ -2493,7 +2493,7 @@ namespace Internal.IL
GetSignatureTypeNameAndAddReference(type);
- PushExpression(StackValueKind.Int32, "sizeof(" + _writer.GetCppTypeName(type) + ")");
+ PushExpression(StackValueKind.Int32, "(int32_t)sizeof(" + _writer.GetCppTypeName(type) + ")");
}
private void ImportRefAnyType()
@@ -2575,9 +2575,12 @@ namespace Internal.IL
AddTypeDependency(type, constructed);
- foreach (var field in type.GetFields())
+ if (!type.IsGenericDefinition)
{
- AddTypeDependency(field.FieldType, false);
+ foreach (var field in type.GetFields())
+ {
+ AddTypeDependency(field.FieldType, false);
+ }
}
}
private void AddTypeDependency(TypeDesc type, bool constructed)
@@ -2586,14 +2589,8 @@ namespace Internal.IL
{
return;
}
- else if (type.IsPointer || type.IsByRef)
- {
- Debug.Assert(type is ParameterizedType);
- AddTypeDependency((type as ParameterizedType).ParameterType, constructed);
- return;
- }
- Object node;
+ Object node;
if (constructed)
node = _nodeFactory.ConstructedTypeSymbol(type);
else
diff --git a/src/ILCompiler/reproNative/reproNativeCpp.vcxproj b/src/ILCompiler/reproNative/reproNativeCpp.vcxproj
index a6ff763be..eb8789560 100644
--- a/src/ILCompiler/reproNative/reproNativeCpp.vcxproj
+++ b/src/ILCompiler/reproNative/reproNativeCpp.vcxproj
@@ -59,6 +59,7 @@
<AdditionalIncludeDirectories>..\..\Native\gc;..\..\Native\gc\env;..\..\Native\Bootstrap</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4477</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <AdditionalOptions>/bigobj</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -79,6 +80,7 @@
<AdditionalIncludeDirectories>..\..\Native\gc;..\..\Native\gc\env</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4477</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <AdditionalOptions>/bigobj</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>