summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-02-10 01:10:23 -0800
committerJan Kotas <jkotas@microsoft.com>2017-02-10 14:18:33 -0800
commit49d2d8f711286bf4ab3ffcd7b9f89a2ec80725bd (patch)
treebdff29fd2b624e647c32b6288db2441e00d2ec30
parentab98635befe574626e9ebb65e33fec3a060b4db6 (diff)
downloadcoreclr-49d2d8f711286bf4ab3ffcd7b9f89a2ec80725bd.tar.gz
coreclr-49d2d8f711286bf4ab3ffcd7b9f89a2ec80725bd.tar.bz2
coreclr-49d2d8f711286bf4ab3ffcd7b9f89a2ec80725bd.zip
Use DynamicSecurityMethod attribute to mark methods with StackCrawlMark
CoreCLR does not have CAS, and so we can conveniently use it to mark methods with StackCrawlMark to decouple it from NoInlining. The original purpose of DynamicSecurityMethod was to disable inlining of the caller and to insert CAS security checks, so we are basically just keeping the first part. Fixes #8102
-rw-r--r--src/mscorlib/src/System/Activator.cs12
-rw-r--r--src/mscorlib/src/System/AppDomain.cs1
-rw-r--r--src/mscorlib/src/System/Delegate.cs4
-rw-r--r--src/mscorlib/src/System/Environment.cs16
-rw-r--r--src/mscorlib/src/System/Reflection/Assembly.cs44
-rw-r--r--src/mscorlib/src/System/Reflection/ConstructorInfo.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs12
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs18
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBase.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/MethodInfo.cs2
-rw-r--r--src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs4
-rw-r--r--src/mscorlib/src/System/Resources/ResourceManager.cs14
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs4
-rw-r--r--src/mscorlib/src/System/Security/Attributes.cs2
-rw-r--r--src/mscorlib/src/System/Threading/Thread.cs4
-rw-r--r--src/mscorlib/src/System/Threading/ThreadPool.cs16
-rw-r--r--src/mscorlib/src/System/ThrowHelper.cs24
-rw-r--r--src/mscorlib/src/System/Type.cs14
-rw-r--r--src/vm/jitinterface.cpp210
20 files changed, 88 insertions, 322 deletions
diff --git a/src/mscorlib/src/System/Activator.cs b/src/mscorlib/src/System/Activator.cs
index 323fbba9cc..b3dd4a780f 100644
--- a/src/mscorlib/src/System/Activator.cs
+++ b/src/mscorlib/src/System/Activator.cs
@@ -52,7 +52,7 @@ namespace System {
return CreateInstance(type, bindingAttr, binder, args, culture, null);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
static public Object CreateInstance(Type type,
BindingFlags bindingAttr,
Binder binder,
@@ -116,7 +116,7 @@ namespace System {
* types to be created remotely without having to load the type locally.
*/
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
static public ObjectHandle CreateInstance(String assemblyName,
String typeName)
{
@@ -133,7 +133,7 @@ namespace System {
ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
static public ObjectHandle CreateInstance(String assemblyName,
String typeName,
Object[] activationAttributes)
@@ -152,7 +152,7 @@ namespace System {
ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
static public Object CreateInstance(Type type, bool nonPublic)
{
if ((object)type == null)
@@ -168,7 +168,7 @@ namespace System {
return rt.CreateInstanceDefaultCtor(!nonPublic, false, true, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
static public T CreateInstance<T>()
{
RuntimeType rt = typeof(T) as RuntimeType;
@@ -206,7 +206,7 @@ namespace System {
activationAttributes);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static ObjectHandle CreateInstance(string assemblyName,
string typeName,
bool ignoreCase,
diff --git a/src/mscorlib/src/System/AppDomain.cs b/src/mscorlib/src/System/AppDomain.cs
index c6987392d5..8e66871a12 100644
--- a/src/mscorlib/src/System/AppDomain.cs
+++ b/src/mscorlib/src/System/AppDomain.cs
@@ -1148,7 +1148,6 @@ namespace System
};
} // PrepareDataForSetup
- [MethodImplAttribute(MethodImplOptions.NoInlining)]
private static Object Setup(Object arg)
{
Contract.Requires(arg != null && arg is Object[]);
diff --git a/src/mscorlib/src/System/Delegate.cs b/src/mscorlib/src/System/Delegate.cs
index fb9dc4b110..eefccd26d5 100644
--- a/src/mscorlib/src/System/Delegate.cs
+++ b/src/mscorlib/src/System/Delegate.cs
@@ -431,7 +431,7 @@ namespace System {
}
// V1 API.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Delegate CreateDelegate(Type type, MethodInfo method, bool throwOnBindFailure)
{
// Validate the parameters.
@@ -481,7 +481,7 @@ namespace System {
}
// V2 API.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Delegate CreateDelegate(Type type, Object firstArgument, MethodInfo method, bool throwOnBindFailure)
{
// Validate the parameters.
diff --git a/src/mscorlib/src/System/Environment.cs b/src/mscorlib/src/System/Environment.cs
index 8fa4ce4ff5..e39b38c928 100644
--- a/src/mscorlib/src/System/Environment.cs
+++ b/src/mscorlib/src/System/Environment.cs
@@ -596,8 +596,6 @@ namespace System {
// if you change this method's signature then you must change the code that calls it
// in excep.cpp and probably you will have to visit mscorlib.h to add the new signature
// as well as metasig.h to create the new signature type
- // NoInlining causes the caller and callee to not be inlined in mscorlib as it is an assumption of StackCrawlMark use
- [MethodImpl(MethodImplOptions.NoInlining)]
internal static String GetResourceStringLocal(String key) {
if (m_resHelper == null)
InitResourceHelper();
@@ -614,40 +612,38 @@ namespace System {
// thrown, we want the code size to be as small as possible.
// Using the params object[] overload works against this since the
// initialization of the array is done inline in the caller at the IL
- // level. So we have overloads that simply wrap the params one, and
- // the methods they call through to are tagged as NoInlining.
- // In mscorlib NoInlining causes the caller and callee to not be inlined
- // as it is an assumption of StackCrawlMark use so it is not added
- // directly to these methods, but to the ones they call.
- // That way they do not bloat either the IL or the generated asm.
+ // level. So we have overloads that simply wrap the params one.
+ [MethodImpl(MethodImplOptions.NoInlining)]
internal static string GetResourceString(string key, object val0)
{
return GetResourceStringFormatted(key, new object[] { val0 });
}
+ [MethodImpl(MethodImplOptions.NoInlining)]
internal static string GetResourceString(string key, object val0, object val1)
{
return GetResourceStringFormatted(key, new object[] { val0, val1 });
}
+ [MethodImpl(MethodImplOptions.NoInlining)]
internal static string GetResourceString(string key, object val0, object val1, object val2)
{
return GetResourceStringFormatted(key, new object[] { val0, val1, val2 });
}
+ [MethodImpl(MethodImplOptions.NoInlining)]
internal static string GetResourceString(string key, object val0, object val1, object val2, object val3)
{
return GetResourceStringFormatted(key, new object[] { val0, val1, val2, val3 });
}
+ [MethodImpl(MethodImplOptions.NoInlining)]
internal static String GetResourceString(string key, params object[] values)
{
return GetResourceStringFormatted(key, values);
}
- // NoInlining causes the caller and callee to not be inlined in mscorlib as it is an assumption of StackCrawlMark use
- [MethodImpl(MethodImplOptions.NoInlining)]
private static String GetResourceStringFormatted(string key, params object[] values)
{
string rs = GetResourceString(key);
diff --git a/src/mscorlib/src/System/Reflection/Assembly.cs b/src/mscorlib/src/System/Reflection/Assembly.cs
index eaedc6ded4..4bb1708ac0 100644
--- a/src/mscorlib/src/System/Reflection/Assembly.cs
+++ b/src/mscorlib/src/System/Reflection/Assembly.cs
@@ -102,7 +102,7 @@ namespace System.Reflection
}
// Locate an assembly for reflection by the name of the file containing the manifest.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly ReflectionOnlyLoadFrom(String assemblyFile)
{
if (assemblyFile == null)
@@ -114,7 +114,7 @@ namespace System.Reflection
// Evidence is protected in Assembly.Load()
[Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of LoadFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal static Assembly LoadFrom(String assemblyFile,
Evidence securityEvidence)
{
@@ -131,7 +131,7 @@ namespace System.Reflection
ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly LoadFrom(String assemblyFile,
byte[] hashValue,
AssemblyHashAlgorithm hashAlgorithm)
@@ -146,7 +146,7 @@ namespace System.Reflection
// Locate an assembly by the long form of the assembly name.
// eg. "Toolbox.dll, version=1.1.10.1220, locale=en, publickey=1234567890123456789012345678901234567890"
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(String assemblyString)
{
Contract.Ensures(Contract.Result<Assembly>() != null);
@@ -160,7 +160,7 @@ namespace System.Reflection
// Calls Type.GetType for WinRT types.
// Note: Type.GetType fails for assembly names that start with weird characters like '['. By calling it for managed types we would
// break AppCompat.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal static Type GetType_Compat(String assemblyString, String typeName)
{
// Normally we would get the stackMark only in public APIs. This is internal API, but it is AppCompat replacement of public API
@@ -189,7 +189,7 @@ namespace System.Reflection
// Locate an assembly for reflection by the long form of the assembly name.
// eg. "Toolbox.dll, version=1.1.10.1220, locale=en, publickey=1234567890123456789012345678901234567890"
//
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly ReflectionOnlyLoad(String assemblyString)
{
if (assemblyString == null)
@@ -201,7 +201,7 @@ namespace System.Reflection
// Locate an assembly by its name. The name can be strong or
// weak. The assembly is loaded into the domain of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(AssemblyName assemblyRef)
{
Contract.Ensures(Contract.Result<Assembly>() != null);
@@ -218,7 +218,7 @@ namespace System.Reflection
// Locate an assembly by its name. The name can be strong or
// weak. The assembly is loaded into the domain of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
{
Contract.Ensures(Contract.Result<Assembly>() != null);
@@ -244,7 +244,7 @@ namespace System.Reflection
// Loads the assembly with a COFF based IMAGE containing
// an emitted assembly. The assembly is loaded into the domain
// of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(byte[] rawAssembly)
{
Contract.Ensures(Contract.Result<Assembly>() != null);
@@ -258,7 +258,7 @@ namespace System.Reflection
// Loads the assembly for reflection with a COFF based IMAGE containing
// an emitted assembly. The assembly is loaded into the domain
// of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly ReflectionOnlyLoad(byte[] rawAssembly)
{
if (rawAssembly == null)
@@ -270,7 +270,7 @@ namespace System.Reflection
// an emitted assembly. The assembly is loaded into the domain
// of the caller. The second parameter is the raw bytes
// representing the symbol store that matches the assembly.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly Load(byte[] rawAssembly,
byte[] rawSymbolStore)
{
@@ -321,14 +321,14 @@ namespace System.Reflection
/*
* Get the assembly that the current code is running from.
*/
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly GetExecutingAssembly()
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeAssembly.GetExecutingAssembly(ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly GetCallingAssembly()
{
// LookForMyCallersCaller is not guarantee to return the correct stack frame
@@ -993,14 +993,14 @@ namespace System.Reflection
}
// Load a resource based on the NameSpace of the type.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Stream GetManifestResourceStream(Type type, String name)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return GetManifestResourceStream(type, name, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Stream GetManifestResourceStream(String name)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -1069,7 +1069,7 @@ namespace System.Reflection
return CustomAttributeData.GetCustomAttributesInternal(this);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal static RuntimeAssembly InternalLoadFrom(String assemblyFile,
Evidence securityEvidence,
byte[] hashValue,
@@ -1098,7 +1098,7 @@ namespace System.Reflection
return InternalLoad(assemblyString, assemblySecurity, ref stackMark, IntPtr.Zero, forIntrospection);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal static RuntimeAssembly InternalLoad(String assemblyString,
Evidence assemblySecurity,
ref StackCrawlMark stackMark,
@@ -1332,7 +1332,7 @@ namespace System.Reflection
StringHandleOnStack retFileName,
StackCrawlMarkHandle stackMark);
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override ManifestResourceInfo GetManifestResourceInfo(String resourceName)
{
RuntimeAssembly retAssembly = null;
@@ -1584,7 +1584,7 @@ namespace System.Reflection
return null;
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -1592,14 +1592,14 @@ namespace System.Reflection
}
// Useful for binding to a very specific version of a satellite assembly
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture, Version version)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return InternalGetSatelliteAssembly(culture, version, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal Assembly InternalGetSatelliteAssembly(CultureInfo culture,
Version version,
ref StackCrawlMark stackMark)
@@ -1613,7 +1613,7 @@ namespace System.Reflection
return InternalGetSatelliteAssembly(name, culture, version, true, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal RuntimeAssembly InternalGetSatelliteAssembly(String name,
CultureInfo culture,
Version version,
diff --git a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs b/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
index c8d71bc1f9..c3198ae82d 100644
--- a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
+++ b/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
@@ -457,7 +457,7 @@ namespace System.Reflection
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Object Invoke(
Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
@@ -542,7 +542,7 @@ namespace System.Reflection
#region ConstructorInfo Overrides
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
INVOCATION_FLAGS invocationFlags = InvocationFlags;
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
index 5575e28917..3deef219de 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
@@ -351,7 +351,7 @@ namespace System.Reflection.Emit
* to have a strong name and a hash will be computed when the assembly
* is saved.
**********************************************/
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
AssemblyBuilderAccess access)
@@ -363,7 +363,7 @@ namespace System.Reflection.Emit
null, ref stackMark, null, SecurityContextSource.CurrentAssembly);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
AssemblyBuilderAccess access,
@@ -425,7 +425,7 @@ namespace System.Reflection.Emit
* a transient module.
*
**********************************************/
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public ModuleBuilder DefineDynamicModule(
String name)
{
@@ -435,7 +435,7 @@ namespace System.Reflection.Emit
return DefineDynamicModuleInternal(name, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public ModuleBuilder DefineDynamicModule(
String name,
bool emitSymbolInfo) // specify if emit symbol info or not
@@ -721,7 +721,7 @@ namespace System.Reflection.Emit
return InternalAssembly.GetLoadedModules(getResourceModules);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -729,7 +729,7 @@ namespace System.Reflection.Emit
}
// Useful for binding to a very specific version of a satellite assembly
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture, Version version)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
index f1d99d3c2c..b7f76b90aa 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
@@ -65,7 +65,7 @@ namespace System.Reflection.Emit
private DynamicMethod() { }
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes)
@@ -84,7 +84,7 @@ namespace System.Reflection.Emit
ref stackMark); // transparentMethod
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes,
@@ -104,7 +104,7 @@ namespace System.Reflection.Emit
ref stackMark); // transparentMethod
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes,
@@ -123,7 +123,7 @@ namespace System.Reflection.Emit
ref stackMark); // transparentMethod
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes,
@@ -143,7 +143,7 @@ namespace System.Reflection.Emit
ref stackMark); // transparentMethod
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
MethodAttributes attributes,
CallingConventions callingConvention,
@@ -165,7 +165,7 @@ namespace System.Reflection.Emit
ref stackMark); // transparentMethod
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes,
@@ -184,7 +184,7 @@ namespace System.Reflection.Emit
ref stackMark); // transparentMethod
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes,
@@ -204,7 +204,7 @@ namespace System.Reflection.Emit
ref stackMark); // transparentMethod
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public DynamicMethod(string name,
MethodAttributes attributes,
CallingConventions callingConvention,
@@ -247,7 +247,7 @@ namespace System.Reflection.Emit
// We create a transparent assembly to host DynamicMethods. Since the assembly does not have any
// non-public fields (or any fields at all), it is a safe anonymous assembly to host DynamicMethods
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
private static RuntimeModule GetDynamicMethodsModule()
{
if (s_anonymouslyHostedDynamicMethodsModule != null)
diff --git a/src/mscorlib/src/System/Reflection/MethodBase.cs b/src/mscorlib/src/System/Reflection/MethodBase.cs
index 3109821ac9..0d3de972a4 100644
--- a/src/mscorlib/src/System/Reflection/MethodBase.cs
+++ b/src/mscorlib/src/System/Reflection/MethodBase.cs
@@ -74,8 +74,7 @@ namespace System.Reflection
return RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo());
}
- [System.Security.DynamicSecurityMethod] // Specify DynamicSecurityMethod attribute to prevent inlining of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static MethodBase GetCurrentMethod()
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
diff --git a/src/mscorlib/src/System/Reflection/MethodInfo.cs b/src/mscorlib/src/System/Reflection/MethodInfo.cs
index 5ce124614c..06c661a157 100644
--- a/src/mscorlib/src/System/Reflection/MethodInfo.cs
+++ b/src/mscorlib/src/System/Reflection/MethodInfo.cs
@@ -586,7 +586,7 @@ namespace System.Reflection
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
object[] arguments = InvokeArgumentsCheck(obj, invokeAttr, binder, parameters, culture);
diff --git a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
index 78e961a7f9..39bd5062e4 100644
--- a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
+++ b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
@@ -52,7 +52,6 @@ namespace System.Resources {
_mediator = mediator;
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary<String, ResourceSet> localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark)
{
Debug.Assert(culture != null, "culture shouldn't be null; check caller");
@@ -362,7 +361,7 @@ namespace System.Resources {
// case-insensitive lookup rules. Yes, this is slow. The metadata
// dev lead refuses to make all assembly manifest resource lookups case-insensitive,
// even optionally case-insensitive.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, String name)
{
Contract.Requires(satellite != null, "satellite shouldn't be null; check caller");
@@ -412,7 +411,6 @@ namespace System.Resources {
return satellite.GetManifestResourceStream(canonicalName, ref stackMark, canSkipSecurityCheck);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
private RuntimeAssembly GetSatelliteAssembly(CultureInfo lookForCulture, ref StackCrawlMark stackMark)
{
if (!_mediator.LookedForSatelliteContractVersion)
diff --git a/src/mscorlib/src/System/Resources/ResourceManager.cs b/src/mscorlib/src/System/Resources/ResourceManager.cs
index f17a7c8f8e..a672f45e22 100644
--- a/src/mscorlib/src/System/Resources/ResourceManager.cs
+++ b/src/mscorlib/src/System/Resources/ResourceManager.cs
@@ -249,7 +249,7 @@ namespace System.Resources {
private static volatile bool s_IsAppXModel;
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
private void Init()
{
m_callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly();
@@ -296,7 +296,7 @@ namespace System.Resources {
resourceGroveler = new FileBasedResourceGroveler(mediator);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public ResourceManager(String baseName, Assembly assembly)
{
if (null==baseName)
@@ -327,7 +327,7 @@ namespace System.Resources {
}
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public ResourceManager(String baseName, Assembly assembly, Type usingResourceSet)
{
if (null==baseName)
@@ -356,7 +356,7 @@ namespace System.Resources {
m_callingAssembly = null;
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public ResourceManager(Type resourceSource)
{
if (null==resourceSource)
@@ -574,7 +574,7 @@ namespace System.Resources {
return null;
}
-
+
// Looks up a set of resources for a particular CultureInfo. This is
// not useful for most users of the ResourceManager - call
// GetString() or GetObject() instead.
@@ -583,7 +583,7 @@ namespace System.Resources {
// if it hasn't yet been loaded and if parent CultureInfos should be
// loaded as well for resource inheritance.
//
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var have to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public virtual ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents) {
if (null==culture)
throw new ArgumentNullException(nameof(culture));
@@ -626,7 +626,7 @@ namespace System.Resources {
// for getting a resource set lives. Access to it is controlled by
// threadsafe methods such as GetResourceSet, GetString, & GetObject.
// This will take a minimal number of locks.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
protected virtual ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
{
Debug.Assert(culture != null, "culture != null");
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
index 9e9103b9c2..3ed5265931 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs
@@ -849,7 +849,7 @@ namespace System.Runtime.InteropServices
// Creates a new instance of "structuretype" and marshals data from a
// native memory block to it.
//====================================================================
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Object PtrToStructure(IntPtr ptr, Type structureType)
{
if (ptr == IntPtr.Zero) return null;
diff --git a/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs b/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs
index 28abe0cb3b..4ad0957900 100644
--- a/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs
+++ b/src/mscorlib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs
@@ -29,13 +29,9 @@ namespace System.Runtime.InteropServices
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern String GetModuleFileName();
- [MethodImpl (MethodImplOptions.NoInlining)]
public static String GetSystemVersion()
{
return Assembly.GetExecutingAssembly().ImageRuntimeVersion;
}
-
-#if FEATURE_COMINTEROP
-#endif // FEATURE_COMINTEROP
}
}
diff --git a/src/mscorlib/src/System/Security/Attributes.cs b/src/mscorlib/src/System/Security/Attributes.cs
index f67a9f0ad1..9594013e02 100644
--- a/src/mscorlib/src/System/Security/Attributes.cs
+++ b/src/mscorlib/src/System/Security/Attributes.cs
@@ -10,7 +10,7 @@ namespace System.Security
// Indicates that calling the target method requires space for a security
// object to be allocated on the callers stack. This attribute is only ever
// set on certain security methods defined within mscorlib.
- [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false )]
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = true, Inherited = false )]
sealed internal class DynamicSecurityMethodAttribute : System.Attribute
{
}
diff --git a/src/mscorlib/src/System/Threading/Thread.cs b/src/mscorlib/src/System/Threading/Thread.cs
index d28002729a..6211a09328 100644
--- a/src/mscorlib/src/System/Threading/Thread.cs
+++ b/src/mscorlib/src/System/Threading/Thread.cs
@@ -237,14 +237,14 @@ namespace System.Threading {
**
** Exceptions: ThreadStateException if the thread has already been started.
=========================================================================*/
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public new void Start()
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
Start(ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public new void Start(object parameter)
{
//In the case of a null delegate (second call to start on same thread)
diff --git a/src/mscorlib/src/System/Threading/ThreadPool.cs b/src/mscorlib/src/System/Threading/ThreadPool.cs
index adf0615819..ccd528d620 100644
--- a/src/mscorlib/src/System/Threading/ThreadPool.cs
+++ b/src/mscorlib/src/System/Threading/ThreadPool.cs
@@ -1112,7 +1112,7 @@ namespace System.Threading
}
[CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException
WaitHandle waitObject,
WaitOrTimerCallback callBack,
@@ -1126,7 +1126,7 @@ namespace System.Threading
}
[CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( // throws RegisterWaitException
WaitHandle waitObject,
WaitOrTimerCallback callBack,
@@ -1176,7 +1176,7 @@ namespace System.Threading
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException
WaitHandle waitObject,
WaitOrTimerCallback callBack,
@@ -1192,7 +1192,7 @@ namespace System.Threading
return RegisterWaitForSingleObject(waitObject,callBack,state,(UInt32)millisecondsTimeOutInterval,executeOnlyOnce,ref stackMark,true);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( // throws RegisterWaitException
WaitHandle waitObject,
WaitOrTimerCallback callBack,
@@ -1208,7 +1208,7 @@ namespace System.Threading
return RegisterWaitForSingleObject(waitObject,callBack,state,(UInt32)millisecondsTimeOutInterval,executeOnlyOnce,ref stackMark,false);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException
WaitHandle waitObject,
WaitOrTimerCallback callBack,
@@ -1224,7 +1224,7 @@ namespace System.Threading
return RegisterWaitForSingleObject(waitObject,callBack,state,(UInt32)millisecondsTimeOutInterval,executeOnlyOnce,ref stackMark,true);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( // throws RegisterWaitException
WaitHandle waitObject,
WaitOrTimerCallback callBack,
@@ -1240,7 +1240,7 @@ namespace System.Threading
return RegisterWaitForSingleObject(waitObject,callBack,state,(UInt32)millisecondsTimeOutInterval,executeOnlyOnce,ref stackMark,false);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle RegisterWaitForSingleObject(
WaitHandle waitObject,
WaitOrTimerCallback callBack,
@@ -1258,7 +1258,7 @@ namespace System.Threading
return RegisterWaitForSingleObject(waitObject,callBack,state,(UInt32)tm,executeOnlyOnce,ref stackMark,true);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(
WaitHandle waitObject,
WaitOrTimerCallback callBack,
diff --git a/src/mscorlib/src/System/ThrowHelper.cs b/src/mscorlib/src/System/ThrowHelper.cs
index 1ed8317633..c425bb5864 100644
--- a/src/mscorlib/src/System/ThrowHelper.cs
+++ b/src/mscorlib/src/System/ThrowHelper.cs
@@ -267,18 +267,8 @@ namespace System {
}
// This function will convert an ExceptionArgument enum value to the argument name string.
- private static string GetArgumentName(ExceptionArgument argument) {
- // This is indirected through a second NoInlining function it has a special meaning
- // in System.Private.CoreLib of indicatating it takes a StackMark which cause
- // the caller to also be not inlined; so we can't mark it directly.
- // So is the effect of marking this function as non-inlining in a regular situation.
- return GetArgumentNameInner(argument);
- }
-
- // This function will convert an ExceptionArgument enum value to the argument name string.
- // Second function in chain so as to not propergate the non-inlining to outside caller
[MethodImpl(MethodImplOptions.NoInlining)]
- private static string GetArgumentNameInner(ExceptionArgument argument) {
+ private static string GetArgumentName(ExceptionArgument argument) {
Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument),
"The enum value is not defined, please check the ExceptionArgument Enum.");
@@ -286,18 +276,8 @@ namespace System {
}
// This function will convert an ExceptionResource enum value to the resource string.
- private static string GetResourceString(ExceptionResource resource) {
- // This is indirected through a second NoInlining function it has a special meaning
- // in System.Private.CoreLib of indicatating it takes a StackMark which cause
- // the caller to also be not inlined; so we can't mark it directly.
- // So is the effect of marking this function as non-inlining in a regular situation.
- return GetResourceStringInner(resource);
- }
-
- // This function will convert an ExceptionResource enum value to the resource string.
- // Second function in chain so as to not propergate the non-inlining to outside caller
[MethodImpl(MethodImplOptions.NoInlining)]
- private static string GetResourceStringInner(ExceptionResource resource) {
+ private static string GetResourceString(ExceptionResource resource) {
Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), resource),
"The enum value is not defined, please check the ExceptionResource Enum.");
diff --git a/src/mscorlib/src/System/Type.cs b/src/mscorlib/src/System/Type.cs
index 3647451445..192760830b 100644
--- a/src/mscorlib/src/System/Type.cs
+++ b/src/mscorlib/src/System/Type.cs
@@ -77,25 +77,25 @@ namespace System
// case-sensitive by default).
////
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Type GetType(String typeName, bool throwOnError, bool ignoreCase) {
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeType.GetType(typeName, throwOnError, ignoreCase, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Type GetType(String typeName, bool throwOnError) {
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeType.GetType(typeName, throwOnError, false, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Type GetType(String typeName) {
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeType.GetType(typeName, false, false, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Type GetType(
string typeName,
Func<AssemblyName, Assembly> assemblyResolver,
@@ -105,7 +105,7 @@ namespace System
return TypeNameParser.GetType(typeName, assemblyResolver, typeResolver, false, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Type GetType(
string typeName,
Func<AssemblyName, Assembly> assemblyResolver,
@@ -116,7 +116,7 @@ namespace System
return TypeNameParser.GetType(typeName, assemblyResolver, typeResolver, throwOnError, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Type GetType(
string typeName,
Func<AssemblyName, Assembly> assemblyResolver,
@@ -128,7 +128,7 @@ namespace System
return TypeNameParser.GetType(typeName, assemblyResolver, typeResolver, throwOnError, ignoreCase, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Type ReflectionOnlyGetType(String typeName, bool throwIfNotFound, bool ignoreCase)
{
if (typeName == null)
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp
index 5afb89bd4b..e0c714363d 100644
--- a/src/vm/jitinterface.cpp
+++ b/src/vm/jitinterface.cpp
@@ -112,8 +112,6 @@ GARY_IMPL(VMHELPDEF, hlpDynamicFuncTable, DYNAMIC_CORINFO_HELP_COUNT);
LARGE_INTEGER g_lastTimeInJitCompilation;
#endif
-BOOL canReplaceMethodOnStack(MethodDesc* pReplaced, MethodDesc* pDeclaredReplacer, MethodDesc* pExactReplacer);
-
/*********************************************************************/
inline CORINFO_MODULE_HANDLE GetScopeHandle(MethodDesc* method)
@@ -6741,10 +6739,9 @@ DWORD CEEInfo::getMethodAttribsInternal (CORINFO_METHOD_HANDLE ftn)
/* Function marked as not inlineable */
result |= CORINFO_FLG_DONT_INLINE;
- if (pMD->IsIL() && (IsMdRequireSecObject(attribs) ||
- (pMD->GetModule()->IsSystem() && IsMiNoInlining(pMD->GetImplAttrs()))))
+ if (pMD->IsIL() && IsMdRequireSecObject(attribs))
{
- // Assume all methods marked as NoInline inside mscorlib are
+ // Assume all methods marked as DynamicSecurity inside mscorlib are
// marked that way because they use StackCrawlMark to identify
// the caller (not just the security info).
// See comments in canInline or canTailCall
@@ -6758,15 +6755,6 @@ DWORD CEEInfo::getMethodAttribsInternal (CORINFO_METHOD_HANDLE ftn)
result |= CORINFO_FLG_FORCEINLINE;
}
-
- if (!pMD->IsRuntimeSupplied())
- {
- if (IsMdRequireSecObject(attribs))
- {
- result |= CORINFO_FLG_SECURITYCHECK;
- }
- }
-
if (pMT->IsDelegate() && ((DelegateEEClass*)(pMT->GetClass()))->m_pInvokeMethod == pMD)
{
// This is now used to emit efficient invoke code for any delegate invoke,
@@ -7641,28 +7629,6 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
_ASSERTE(!(CORINFO_FLG_DONT_INLINE & getMethodAttribsInternal(hCallee)));
#endif
- // Returns TRUE: if caller and callee are from the same assembly or the callee
- // is part of the system assembly.
- //
- // If the caller and callee have the same Critical state and the same Grant (and refuse) sets, then the
- // callee may always be inlined into the caller.
- //
- // If they differ, then the callee is marked as INLINE_RESPECT_BOUNDARY. The Jit may only inline the
- // callee when any of the following are true.
- // 1) the callee is a leaf method.
- // 2) the callee does not call any Boundary Methods.
- //
- // Conceptually, a Boundary method is a method that needs to accurately find the permissions of its
- // caller. Boundary methods are:
- //
- // 1) A method that calls anything that creates a StackCrawlMark to look for its caller. In this code
- // this is approximated as "in mscorlib and is marked as NoInlining".
- // 2) A method that calls a method which calls Demand. These methods must be marked as
- // IsMdRequireSecObject.
- // 3) Calls anything that is virtual. This is because the virtual method could be #1 or #2.
- //
- // In CoreCLR, all public Critical methods of mscorlib are considered Boundary Method
-
MethodDesc* pCaller = GetMethod(hCaller);
MethodDesc* pCallee = GetMethod(hCallee);
@@ -7726,7 +7692,7 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
if (IsMdRequireSecObject(pCallee->GetAttrs()))
{
result = INLINE_NEVER;
- szFailReason = "Inlinee requires a security object (calls Demand/Assert/Deny)";
+ szFailReason = "Inlinee requires a security object (or contains StackCrawlMark)";
goto exit;
}
@@ -7757,7 +7723,7 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
#ifdef _DEBUG
//
- // Make sure that all methods with StackCrawlMark are marked as non-inlineable
+ // Make sure that all methods with StackCrawlMark are marked as IsMdRequireSecObject
//
if (pCalleeAssembly->IsSystem())
{
@@ -7800,11 +7766,6 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
}
#endif // FEATURE_PREJIT
- if (!canReplaceMethodOnStack(pCallee, NULL, pCaller))
- {
- dwRestrictions |= INLINE_RESPECT_BOUNDARY;
- }
-
// TODO: We can probably be smarter here if the caller is jitted, as we will
// know for sure if the inlinee has really no string interning active (currently
// it's only on in the ngen case (besides requiring the attribute)), but this is getting
@@ -8183,159 +8144,6 @@ CorInfoInstantiationVerification
return result;
}
-// This function returns true if we can replace pReplaced on the stack with
-// pReplacer. In the case of inlining this means that pReplaced is the inlinee
-// and pReplacer is the inliner. In the case of tail calling, pReplacer is the
-// tail callee and pReplaced is the tail caller.
-//
-// It's possible for pReplacer to be NULL. This means that it's an unresolved
-// callvirt for a tail call. This is legal, but we make the static decision
-// based on pReplaced only (assuming that pReplacer is from a different
-// assembly that is a different partial trust).
-//
-// The general logic is this:
-// 1) You can replace anything that is full trust (since full trust doesn't
-// cause a demand to fail).
-// 2) You can coalesce all stack frames that have the same permission set
-// down to a single stack frame.
-//
-// You'll see three patterns in the code below:
-// 1) There is only one permission set per assembly
-// 2) Comparing grant sets is prohibitively expensive. Therefore we use the
-// the fact that, "a homogenous app domain has only one partial trust
-// permission set" to infer that two grant sets are equal.
-// 3) Refuse sets are rarely used and too complex to handle correctly, so
-// they generally just torpedo all of the logic in here.
-//
-BOOL canReplaceMethodOnStack(MethodDesc* pReplaced, MethodDesc* pDeclaredReplacer, MethodDesc* pExactReplacer)
-{
- CONTRACTL {
- THROWS;
- GC_TRIGGERS;
- MODE_PREEMPTIVE; //Called from PREEMPTIVE functions
- } CONTRACTL_END;
-
- OBJECTREF refused = NULL;
- Assembly * pReplacedAssembly = pReplaced->GetAssembly();
-
- _ASSERTE(Security::IsResolved(pReplacedAssembly));
-
- // The goal of this code is to ensure that we never allow a unique non-full
- // trust grant set to be eliminated from the stack.
-
- Assembly * pReplacerAssembly = NULL;
- if (pExactReplacer != NULL)
- {
- pReplacerAssembly = pExactReplacer->GetAssembly();
- _ASSERTE(Security::IsResolved(pReplacerAssembly));
-
- // If two methods are from the same assembly, they must have the same grant set.
- if (pReplacerAssembly == pReplacedAssembly)
- {
- // When both methods are in the same assembly, then it is always safe to
- // coalesce them for the purposes of security.
- return TRUE;
- }
- }
-
- if ( pDeclaredReplacer != NULL &&
- pReplacedAssembly->GetDomainAssembly() == GetAppDomain()->GetAnonymouslyHostedDynamicMethodsAssembly() &&
- SystemDomain::IsReflectionInvocationMethod(pDeclaredReplacer) )
- {
- // When an anonymously hosted dynamic method invokes a method through reflection invocation,
- // the dynamic method is the true caller. If we replace it on the stack we would be doing
- // security check against its caller rather than the dynamic method itself.
- // We should do this check against pDeclaredReplacer rather than pExactReplacer because the
- // latter is NULL is the former if virtual, e.g. MethodInfo.Invoke(...).
- return FALSE;
- }
-
- // It is always safe to remove a full trust stack frame from the stack.
- IAssemblySecurityDescriptor * pReplacedDesc = pReplacedAssembly->GetSecurityDescriptor();
-
-#ifdef FEATURE_APTCA
- if (GetAppDomain()->IsCompilationDomain())
- {
- // If we're NGENing assemblies, we don't want to inline code out of a conditionally APTCA assembly,
- // since we need to ensure that the dependency is loaded and checked to ensure that it is condtional
- // APTCA. We only need to do this if the replaced caller is transparent, since a critical caller
- // will be allowed to use the conditional APTCA disabled assembly anyway.
- if (pReplacedAssembly != pReplacerAssembly && Security::IsMethodTransparent(pReplaced))
- {
- ModuleSecurityDescriptor *pReplacedMSD = ModuleSecurityDescriptor::GetModuleSecurityDescriptor(pReplacedAssembly);
- if (pReplacedMSD->GetTokenFlags() & TokenSecurityDescriptorFlags_ConditionalAPTCA)
- {
- return FALSE;
- }
- }
- }
-#endif // FEATURE_APTCA
-
- if (pReplacedDesc->IsFullyTrusted())
- {
- GCX_COOP(); // Required for GetGrantedPermissionSet
- (void)pReplacedDesc->GetGrantedPermissionSet(&refused);
- if (refused != NULL)
- {
- // This is full trust with a Refused set. That means that it is partial
- // trust. However, even in a homogeneous app domain, it could be a
- // different partial trust from any other partial trust, and since
- // pExactReplacer is either unknown or from a different assembly, we assume
- // the worst: that is is a different partial trust.
- return FALSE;
- }
- return TRUE;
- }
-
- // pReplaced is partial trust and pExactReplacer is either unknown or from a
- // different assembly than pReplaced.
-
- if (pExactReplacer == NULL)
- {
- // This is the unresolved callvirt case. Since we're partial trust,
- // we can't tail call.
- return FALSE;
- }
-
- // We're replacing a partial trust stack frame. We can only do this with a
- // matching grant set. We know pReplaced is partial trust. Make sure both
- // pExactReplacer and pReplaced are the same partial trust.
- IAssemblySecurityDescriptor * pReplacerDesc = pReplacerAssembly->GetSecurityDescriptor();
- if (pReplacerDesc->IsFullyTrusted())
- {
- return FALSE; // Replacing partial trust with full trust.
- }
-
- // At this point both pExactReplacer and pReplaced are partial trust. We can
- // only do this if the grant sets are equal. Since comparing grant sets
- // requires calling up into managed code, we will infer that the two grant
- // sets are equal if the domain is homogeneous.
- IApplicationSecurityDescriptor * adSec = GetAppDomain()->GetSecurityDescriptor();
- if (adSec->IsHomogeneous())
- {
- // We're homogeneous, but the two descriptors could have refused sets.
- // Bail if they do.
- GCX_COOP(); // Required for GetGrantedPermissionSet
- (void)pReplacedDesc->GetGrantedPermissionSet(&refused);
- if (refused != NULL)
- {
- return FALSE;
- }
-
- (void)pReplacerDesc->GetGrantedPermissionSet(&refused);
- if (refused != NULL)
- return FALSE;
-
- return TRUE;
- }
-
- // pExactReplacer and pReplaced are from 2 different assemblies. Both are partial
- // trust, and the app domain is not homogeneous, so we just have to
- // assume that they have different grant or refuse sets, and thus cannot
- // safely be replaced.
- return FALSE;
-}
-
/*************************************************************
* Similar to above, but perform check for tail call
* eligibility. The callee can be passed as NULL if not known
@@ -8392,16 +8200,6 @@ bool CEEInfo::canTailCall (CORINFO_METHOD_HANDLE hCaller,
goto exit;
}
- // The jit already checks and doesn't allow the tail caller to use imperative security.
- _ASSERTE(pCaller->IsRuntimeSupplied() || !IsMdRequireSecObject(pCaller->GetAttrs()));
-
- if (!canReplaceMethodOnStack(pCaller, pDeclaredCallee, pExactCallee))
- {
- result = false;
- szFailReason = "Different security";
- goto exit;
- }
-
if (!fIsTailPrefix)
{
mdMethodDef callerToken = pCaller->GetMemberDef();