Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #5559 from dotnet/nmirror
Browse files Browse the repository at this point in the history
Merge nmirror to master
  • Loading branch information
jkotas committed Mar 17, 2018
2 parents 953ea41 + f76c663 commit f485eff
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 48 deletions.
19 changes: 13 additions & 6 deletions src/ILCompiler.Compiler/src/Compiler/UtcNameMangler.cs
Expand Up @@ -44,13 +44,15 @@ public class UTCNameMangler : NameMangler

private bool HasImport { get; set; }
private bool HasExport { get; set; }
private bool BuildingClassLib { get; }

public UTCNameMangler(bool hasImport, bool hasExport, ImportExportOrdinals ordinals, TypeSystemContext context, List<EcmaModule> inputModules) : base(new UtcNodeMangler())
public UTCNameMangler(bool hasImport, bool hasExport, ImportExportOrdinals ordinals, TypeSystemContext context, List<EcmaModule> inputModules, bool buildingClassLib) : base(new UtcNodeMangler())
{
// Do not support both imports and exports for one module
Debug.Assert(!hasImport || !hasExport);
HasImport = hasImport;
HasExport = hasExport;
BuildingClassLib = buildingClassLib;

if (hasImport)
{
Expand Down Expand Up @@ -185,7 +187,7 @@ public override string SanitizeName(string s, bool typeName = false)

if (sb != null)
{
if (c == '[' || c == ']' || c == ',' || c == '&' || c == '*' || c == '$' || c == '<' || c == '>')
if (c == '[' || c == ']' || c == '&' || c == '*' || c == '$' || c == '<' || c == '>')
{
sb.Append(c);
continue;
Expand Down Expand Up @@ -298,9 +300,14 @@ protected string NestMangledName(string name)

private string ComputeMangledModuleName(EcmaAssembly module)
{
int index;
if (_inputModuleIndices.TryGetValue(module, out index))
return "$" + index;
// Do not prepend the module prefix when building pntestcl because the prefix is unknown
// when building an app against pntestcl.
if (!BuildingClassLib)
{
int index;
if (_inputModuleIndices.TryGetValue(module, out index))
return "$" + index;
}

return SanitizeName(module.GetName().Name);
}
Expand Down Expand Up @@ -373,7 +380,7 @@ private string ComputeMangledTypeName(TypeDesc type)

if (type.IsMdArray)
{
mangledName += "[" + new string(',', ((ArrayType)type).Rank) + "]";
mangledName += "[md" + ((ArrayType)type).Rank.ToString() + "]";
}
else
{
Expand Down
Expand Up @@ -120,7 +120,7 @@ private void AppendAssemblyName(StringBuilder sb, IAssemblyDesc assembly)

protected override void AppendNameForNestedType(StringBuilder sb, DefType nestedType, DefType containingType)
{
AppendNameForNamespaceType(sb, containingType);
AppendName(sb, containingType);

sb.Append('+');

Expand Down
6 changes: 5 additions & 1 deletion src/Runtime.Base/src/System/Runtime/ExceptionHandling.cs
Expand Up @@ -728,7 +728,11 @@ private static void DispatchEx(ref StackFrameIterator frameIter, ref ExInfo exIn
Debug.Assert(isValid, "second-pass EH unwind failed unexpectedly");
DebugScanCallFrame(exInfo._passNumber, frameIter.ControlPC, frameIter.SP);

if (frameIter.SP == handlingFrameSP)
if ((frameIter.SP == handlingFrameSP)
#if ARM64
&& (frameIter.ControlPC == prevControlPC)
#endif
)
{
// invoke only a partial second-pass here...
InvokeSecondPass(ref exInfo, startIdx, catchingTryRegionIdx);
Expand Down
Expand Up @@ -44,10 +44,6 @@ namespace Internal.Reflection.Execution
//==========================================================================================================
internal sealed partial class ExecutionEnvironmentImplementation : ExecutionEnvironment
{
private struct MethodTargetAndDictionary { public IntPtr TargetPointer; public IntPtr DictionaryPointer; }

private LowLevelDictionary<IntPtr, MethodTargetAndDictionary> _callConverterWrappedMethodEntrypoints = new LowLevelDictionary<IntPtr, MethodTargetAndDictionary>();

private RuntimeTypeHandle GetOpenTypeDefinition(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle[] typeArgumentsHandles)
{
if (RuntimeAugments.IsGenericType(typeHandle))
Expand Down Expand Up @@ -603,22 +599,6 @@ private static RuntimeTypeHandle[] GetTypeSequence(ref ExternalReferencesTable e
methodHandle.NativeFormatHandle);
}

if (methodInvokeMetadata.MethodEntryPoint != methodInvokeMetadata.RawMethodEntryPoint &&
!FunctionPointerOps.IsGenericMethodPointer(methodInvokeMetadata.MethodEntryPoint))
{
// Keep track of the raw method entrypoints for the cases where they get wrapped into a calling convention converter thunk.
// This is needed for reverse lookups, like in TryGetMethodForOriginalLdFtnResult
Debug.Assert(canonFormKind == CanonicalFormKind.Universal);
lock (_callConverterWrappedMethodEntrypoints)
{
_callConverterWrappedMethodEntrypoints.LookupOrAdd(methodInvokeMetadata.MethodEntryPoint, new MethodTargetAndDictionary
{
TargetPointer = methodInvokeMetadata.RawMethodEntryPoint,
DictionaryPointer = methodInvokeMetadata.DictionaryComponent
});
}
}

RuntimeTypeHandle[] dynInvokeMethodArgs = GetDynamicInvokeInstantiationArguments(methodInfo);

IntPtr dynamicInvokeMethod;
Expand Down Expand Up @@ -913,26 +893,11 @@ internal unsafe void GetFunctionPointerAndInstantiationArgumentForOriginalLdFtnR
}
else
{
bool isCallConverterWrappedEntrypoint;
MethodTargetAndDictionary callConverterWrappedEntrypoint;
lock (_callConverterWrappedMethodEntrypoints)
// The thunk could have been created by the TypeLoader as a dictionary slot for USG code
if (!CallConverterThunk.TryGetCallConversionTargetPointerAndInstantiatingArg(originalLdFtnResult, out canonOriginalLdFtnResult, out instantiationArgument))
{
isCallConverterWrappedEntrypoint = _callConverterWrappedMethodEntrypoints.TryGetValue(originalLdFtnResult, out callConverterWrappedEntrypoint);
}

if (isCallConverterWrappedEntrypoint)
{
canonOriginalLdFtnResult = callConverterWrappedEntrypoint.TargetPointer;
instantiationArgument = callConverterWrappedEntrypoint.DictionaryPointer;
}
else
{
// The thunk could have been created by the TypeLoader as a dictionary slot for USG code
if (!CallConverterThunk.TryGetCallConversionTargetPointerAndInstantiatingArg(originalLdFtnResult, out canonOriginalLdFtnResult, out instantiationArgument))
{
canonOriginalLdFtnResult = RuntimeAugments.GetCodeTarget(originalLdFtnResult);
instantiationArgument = IntPtr.Zero;
}
canonOriginalLdFtnResult = RuntimeAugments.GetCodeTarget(originalLdFtnResult);
instantiationArgument = IntPtr.Zero;
}
}
}
Expand Down
Expand Up @@ -9,6 +9,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;

using Internal.LowLevelLinq;
using Internal.Reflection.Core;
Expand Down Expand Up @@ -91,10 +92,18 @@ public static RuntimeAssemblyName ToRuntimeAssemblyName(this AssemblyReferenceHa
publicKeyOrTokenByteArray = Array.Empty<byte>();
}

string cultureName = culture.GetString(reader);
if (!String.IsNullOrEmpty(cultureName))
{
// Canonicalize spelling and force a CultureNotFoundException if not a valid culture
CultureInfo cultureInfo = CultureInfo.GetCultureInfo(cultureName);
cultureName = cultureInfo.Name;
}

return new RuntimeAssemblyName(
name.GetString(reader),
version,
culture.GetString(reader),
cultureName,
assemblyNameFlags,
publicKeyOrTokenByteArray
);
Expand Down

0 comments on commit f485eff

Please sign in to comment.