summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/System.Private.CoreLib/System.Private.CoreLib.csproj1
-rw-r--r--src/System.Private.CoreLib/src/System/AppDomain.cs94
-rw-r--r--src/System.Private.CoreLib/src/System/ApplicationModel.Windows.cs20
-rw-r--r--src/System.Private.CoreLib/src/System/Environment.cs6
-rw-r--r--src/System.Private.CoreLib/src/System/Exception.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs10
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs17
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs16
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs9
-rw-r--r--src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs14
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs6
-rw-r--r--src/System.Private.CoreLib/src/System/String.CoreCLR.cs9
-rw-r--r--src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs4
-rw-r--r--src/System.Private.CoreLib/src/System/__ComObject.cs2
-rw-r--r--src/vm/appdomainnative.cpp116
-rw-r--r--src/vm/appdomainnative.hpp23
-rw-r--r--src/vm/assembly.hpp1
-rw-r--r--src/vm/ecalllist.h20
19 files changed, 102 insertions, 270 deletions
diff --git a/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
index 88f9062199..ca7e85f5e9 100644
--- a/src/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -483,6 +483,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="$(BclSourcesRoot)\Interop\Windows\Kernel32\Interop.GetSystemDirectoryW.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\ApplicationModel.Windows.cs" />
<Compile Include="$(BclSourcesRoot)\System\Diagnostics\DebugProvider.Windows.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\CultureInfo.Windows.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\GlobalizationMode.Windows.cs" />
diff --git a/src/System.Private.CoreLib/src/System/AppDomain.cs b/src/System.Private.CoreLib/src/System/AppDomain.cs
index c1c74d097d..53a26f52ac 100644
--- a/src/System.Private.CoreLib/src/System/AppDomain.cs
+++ b/src/System.Private.CoreLib/src/System/AppDomain.cs
@@ -104,37 +104,6 @@ namespace System
private IntPtr _pDomain; // this is an unmanaged pointer (AppDomain * m_pDomain)` used from the VM.
-#if FEATURE_APPX
- private static APPX_FLAGS s_flags;
-
- //
- // Keep in async with vm\appdomainnative.cpp
- //
- [Flags]
- private enum APPX_FLAGS
- {
- APPX_FLAGS_INITIALIZED = 0x01,
-
- APPX_FLAGS_APPX_MODEL = 0x02,
- }
-
- private static APPX_FLAGS Flags
- {
- get
- {
- if (s_flags == 0)
- s_flags = nGetAppXFlags();
-
- Debug.Assert(s_flags != 0);
- return s_flags;
- }
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [return: MarshalAs(UnmanagedType.I4)]
- private static extern APPX_FLAGS nGetAppXFlags();
-#endif
-
/// <summary>
/// If this AppDomain is configured to have an AppDomain manager then create the instance of it.
/// This method is also called from the VM to create the domain manager in the default domain.
@@ -152,66 +121,9 @@ namespace System
}
}
- /// <summary>
- /// Returns whether the current AppDomain follows the AppX rules.
- /// </summary>
- [Pure]
- internal static bool IsAppXModel()
- {
-#if FEATURE_APPX
- return (Flags & APPX_FLAGS.APPX_FLAGS_APPX_MODEL) != 0;
-#else
- return false;
-#endif
- }
-
- /// <summary>
- /// Checks (and throws on failure) if the domain supports Assembly.LoadFrom.
- /// </summary>
- [Pure]
- internal static void CheckLoadFromSupported()
- {
-#if FEATURE_APPX
- if (IsAppXModel())
- throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFrom"));
-#endif
- }
-
- /// <summary>
- /// Checks (and throws on failure) if the domain supports Assembly.LoadFile.
- /// </summary>
- [Pure]
- internal static void CheckLoadFileSupported()
- {
-#if FEATURE_APPX
- if (IsAppXModel())
- throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFile"));
-#endif
- }
-
- /// <summary>
- /// Checks (and throws on failure) if the domain supports Assembly.Load(byte[] ...).
- /// </summary>
- [Pure]
- internal static void CheckLoadByteArraySupported()
- {
-#if FEATURE_APPX
- if (IsAppXModel())
- throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.Load(byte[], ...)"));
-#endif
- }
-
public static AppDomain CurrentDomain => Thread.GetDomain();
[MethodImpl(MethodImplOptions.InternalCall)]
- private extern Assembly[] nGetAssemblies(bool forIntrospection);
-
- internal Assembly[] GetAssemblies(bool forIntrospection)
- {
- return nGetAssemblies(forIntrospection);
- }
-
- [MethodImpl(MethodImplOptions.InternalCall)]
internal static extern void PublishAnonymouslyHostedDynamicMethodsAssembly(RuntimeAssembly assemblyHandle);
[Obsolete("AppDomain.GetCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads). To get a stable identifier for a managed thread, use the ManagedThreadId property on Thread. http://go.microsoft.com/fwlink/?linkid=14202", false)]
@@ -418,12 +330,6 @@ namespace System
[MethodImpl(MethodImplOptions.InternalCall)]
private extern void nSetupFriendlyName(string friendlyName);
- [MethodImpl(MethodImplOptions.InternalCall)]
- internal extern string IsStringInterned(string str);
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- internal extern string GetOrInternString(string str);
-
public int Id => GetId();
[MethodImpl(MethodImplOptions.InternalCall)]
diff --git a/src/System.Private.CoreLib/src/System/ApplicationModel.Windows.cs b/src/System.Private.CoreLib/src/System/ApplicationModel.Windows.cs
new file mode 100644
index 0000000000..ea1e017424
--- /dev/null
+++ b/src/System.Private.CoreLib/src/System/ApplicationModel.Windows.cs
@@ -0,0 +1,20 @@
+// 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.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System
+{
+ internal static class ApplicationModel
+ {
+#if FEATURE_APPX
+ // Cache the value in readonly static that can be optimized out by the JIT
+ internal readonly static bool IsUap = IsAppXProcess();
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ private static extern bool IsAppXProcess();
+#endif
+ }
+}
diff --git a/src/System.Private.CoreLib/src/System/Environment.cs b/src/System.Private.CoreLib/src/System/Environment.cs
index a81805340d..e94f62c438 100644
--- a/src/System.Private.CoreLib/src/System/Environment.cs
+++ b/src/System.Private.CoreLib/src/System/Environment.cs
@@ -476,7 +476,7 @@ namespace System
return GetEnvironmentVariableCore(variable);
#if FEATURE_WIN32_REGISTRY
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
#endif
{
return null;
@@ -564,7 +564,7 @@ namespace System
internal static IEnumerable<KeyValuePair<string, string>> EnumerateEnvironmentVariablesFromRegistry(EnvironmentVariableTarget target)
{
#if FEATURE_WIN32_REGISTRY
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
#endif
{
// Without registry support we have nothing to return
@@ -640,7 +640,7 @@ namespace System
}
#if FEATURE_WIN32_REGISTRY
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
#endif
{
// other targets ignored
diff --git a/src/System.Private.CoreLib/src/System/Exception.cs b/src/System.Private.CoreLib/src/System/Exception.cs
index 0b1d39f143..911b1c5f78 100644
--- a/src/System.Private.CoreLib/src/System/Exception.cs
+++ b/src/System.Private.CoreLib/src/System/Exception.cs
@@ -489,7 +489,7 @@ namespace System
string tmpStackTraceString;
#if FEATURE_APPX
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
{
// Call our internal GetStackTrace in AppX so we can parse the result should
// we need to strip file/line info from it to make it PII-free. Calling the
diff --git a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs
index 107a08cf07..f354b1950f 100644
--- a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs
+++ b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs
@@ -127,7 +127,7 @@ namespace System.Globalization
get
{
#if FEATURE_APPX
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
{
CultureInfo culture = GetCultureInfoForUserPreferredLanguageInAppX();
if (culture != null)
@@ -160,9 +160,9 @@ namespace System.Globalization
{
throw new ArgumentNullException(nameof(value));
}
-
+
#if FEATURE_APPX
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
{
if (SetCultureInfoForUserPreferredLanguageInAppX(value))
{
@@ -184,7 +184,7 @@ namespace System.Globalization
get
{
#if FEATURE_APPX
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
{
CultureInfo culture = GetCultureInfoForUserPreferredLanguageInAppX();
if (culture != null)
@@ -203,7 +203,7 @@ namespace System.Globalization
CultureInfo.VerifyCultureName(value, true);
#if FEATURE_APPX
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
{
if (SetCultureInfoForUserPreferredLanguageInAppX(value))
{
diff --git a/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs
index 4703b8b0d5..0414de5e2e 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs
@@ -165,10 +165,14 @@ namespace System.Reflection
public static Assembly Load(byte[] rawAssembly,
byte[] rawSymbolStore)
{
- AppDomain.CheckLoadByteArraySupported();
-
if (rawAssembly == null)
throw new ArgumentNullException(nameof(rawAssembly));
+
+#if FEATURE_APPX
+ if (ApplicationModel.IsUap)
+ throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.Load(byte[], ...)"));
+#endif
+
AssemblyLoadContext alc = new IndividualAssemblyLoadContext();
MemoryStream assemblyStream = new MemoryStream(rawAssembly);
MemoryStream symbolStream = (rawSymbolStore != null) ? new MemoryStream(rawSymbolStore) : null;
@@ -179,12 +183,14 @@ namespace System.Reflection
public static Assembly LoadFile(string path)
{
- AppDomain.CheckLoadFileSupported();
-
- Assembly result = null;
if (path == null)
throw new ArgumentNullException(nameof(path));
+#if FEATURE_APPX
+ if (ApplicationModel.IsUap)
+ throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFile"));
+#endif
+
if (PathInternal.IsPartiallyQualified(path))
{
throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(path));
@@ -192,6 +198,7 @@ namespace System.Reflection
string normalizedPath = Path.GetFullPath(path);
+ Assembly result = null;
lock (s_loadfile)
{
if (s_loadfile.TryGetValue(normalizedPath, out result))
diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
index 0203244c10..e35c8da89e 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
@@ -164,8 +164,7 @@ namespace System.Reflection.Emit
#region Constructor
- internal AssemblyBuilder(AppDomain domain,
- AssemblyName name,
+ internal AssemblyBuilder(AssemblyName name,
AssemblyBuilderAccess access,
ref StackCrawlMark stackMark,
IEnumerable<CustomAttributeBuilder> unsafeAssemblyAttributes)
@@ -193,10 +192,9 @@ namespace System.Reflection.Emit
assemblyAttributes = new List<CustomAttributeBuilder>(unsafeAssemblyAttributes);
}
- _internalAssemblyBuilder = (InternalAssemblyBuilder)nCreateDynamicAssembly(domain,
- name,
- ref stackMark,
- access);
+ _internalAssemblyBuilder = (InternalAssemblyBuilder)nCreateDynamicAssembly(name,
+ ref stackMark,
+ access);
_assemblyData = new AssemblyBuilderData(_internalAssemblyBuilder, access);
@@ -261,8 +259,7 @@ namespace System.Reflection.Emit
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern Assembly nCreateDynamicAssembly(AppDomain domain,
- AssemblyName name,
+ private static extern Assembly nCreateDynamicAssembly(AssemblyName name,
ref StackCrawlMark stackMark,
AssemblyBuilderAccess access);
@@ -277,8 +274,7 @@ namespace System.Reflection.Emit
lock (typeof(AssemblyBuilderLock))
{
// We can only create dynamic assemblies in the current domain
- return new AssemblyBuilder(AppDomain.CurrentDomain,
- name,
+ return new AssemblyBuilder(name,
access,
ref stackMark,
unsafeAssemblyAttributes);
diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
index b43b0cc5ba..c0a8101355 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
@@ -329,10 +329,15 @@ namespace System.Reflection
if (assemblyRef == null)
throw new ArgumentNullException(nameof(assemblyRef));
- if (assemblyRef.CodeBase != null)
+#if FEATURE_APPX
+ if (ApplicationModel.IsUap)
{
- AppDomain.CheckLoadFromSupported();
+ if (assemblyRef.CodeBase != null)
+ {
+ throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFrom"));
+ }
}
+#endif
assemblyRef = (AssemblyName)assemblyRef.Clone();
if (assemblyRef.ProcessorArchitecture != ProcessorArchitecture.None)
diff --git a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs
index 7c94e121a8..9e4f463201 100644
--- a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs
+++ b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs
@@ -183,8 +183,6 @@ namespace System.Resources
internal const string ResFileExtension = ".resources";
internal const int ResFileExtensionLength = 10;
- private static volatile bool s_IsAppXModel;
-
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
private void Init()
{
@@ -713,7 +711,7 @@ namespace System.Resources
Debug.Assert(_bUsingModernResourceManagement);
Debug.Assert(_WinRTResourceManager != null);
Debug.Assert(_PRIonAppXInitialized);
- Debug.Assert(AppDomain.IsAppXModel());
+ Debug.Assert(ApplicationModel.IsUap);
if (stringName.Length == 0)
return null;
@@ -810,12 +808,8 @@ namespace System.Resources
{
if (resourcesAssembly != typeof(object).Assembly) // We are not loading resources for mscorlib
{
- // Cannot load the WindowsRuntimeResourceManager when in a compilation process, since it
- // lives in System.Runtime.WindowsRuntime and only mscorlib may be loaded for execution.
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
{
- s_IsAppXModel = true;
-
// If we have the type information from the ResourceManager(Type) constructor, we use it. Otherwise, we use BaseNameField.
string reswFilename = _locationInfo == null ? BaseNameField : _locationInfo.FullName;
@@ -928,7 +922,7 @@ namespace System.Resources
throw new ArgumentNullException(nameof(name));
#if FEATURE_APPX
- if (s_IsAppXModel)
+ if (ApplicationModel.IsUap)
{
// If the caller explictily passed in a culture that was obtained by calling CultureInfo.CurrentUICulture,
// null it out, so that we re-compute it. If we use modern resource lookup, we may end up getting a "better"
@@ -1037,7 +1031,7 @@ namespace System.Resources
throw new ArgumentNullException(nameof(name));
#if FEATURE_APPX
- if (s_IsAppXModel)
+ if (ApplicationModel.IsUap)
{
// If the caller explictily passed in a culture that was obtained by calling CultureInfo.CurrentUICulture,
// null it out, so that we re-compute it based on the Win32 value and not the AppX language list value.
diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
index ad04b25dd2..b240b9bcc3 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs
@@ -1125,7 +1125,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
internal static bool ReportUnhandledError(Exception e)
{
// Only report to the WinRT global exception handler in modern apps
- if (!AppDomain.IsAppXModel())
+ if (!ApplicationModel.IsUap)
{
return false;
}
diff --git a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs
index 971b6a4f48..8158b3fbd4 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs
@@ -134,10 +134,8 @@ namespace System.Runtime.Loader
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern void LoadFromPath(IntPtr ptrNativeAssemblyLoadContet, string ilPath, string niPath, ObjectHandleOnStack retAssembly);
- public static Assembly[] GetLoadedAssemblies()
- {
- return AppDomain.CurrentDomain.GetAssemblies(false);
- }
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern Assembly[] GetLoadedAssemblies();
// These methods load assemblies into the current AssemblyLoadContext
// They may be used in the implementation of an AssemblyLoadContext derivation
diff --git a/src/System.Private.CoreLib/src/System/String.CoreCLR.cs b/src/System.Private.CoreLib/src/System/String.CoreCLR.cs
index e81db4717d..b4a5019b4e 100644
--- a/src/System.Private.CoreLib/src/System/String.CoreCLR.cs
+++ b/src/System.Private.CoreLib/src/System/String.CoreCLR.cs
@@ -74,6 +74,11 @@ namespace System
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern bool TryGetTrailByte(out byte data);
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private extern string Intern();
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ private extern string IsInterned();
+
public static string Intern(string str)
{
if (str == null)
@@ -81,7 +86,7 @@ namespace System
throw new ArgumentNullException(nameof(str));
}
- return Thread.GetDomain().GetOrInternString(str);
+ return str.Intern();
}
public static string IsInterned(string str)
@@ -91,7 +96,7 @@ namespace System
throw new ArgumentNullException(nameof(str));
}
- return Thread.GetDomain().IsStringInterned(str);
+ return str.IsInterned();
}
// Copies the source String (byte buffer) to the destination IntPtr memory allocated with len bytes.
diff --git a/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs b/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs
index 7b7d06c10d..8cfd7ae387 100644
--- a/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs
+++ b/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs
@@ -152,7 +152,7 @@ namespace System.Threading
SynchronizationContext context = Thread.CurrentThread.SynchronizationContext;
#if FEATURE_APPX
- if (context == null && AppDomain.IsAppXModel())
+ if (context == null && ApplicationModel.IsUap)
context = GetWinRTContext();
#endif
@@ -164,7 +164,7 @@ namespace System.Threading
private static SynchronizationContext GetWinRTContext()
{
Debug.Assert(Environment.IsWinRTSupported);
- Debug.Assert(AppDomain.IsAppXModel());
+ Debug.Assert(ApplicationModel.IsUap);
//
// We call into the VM to get the dispatcher. This is because:
diff --git a/src/System.Private.CoreLib/src/System/__ComObject.cs b/src/System.Private.CoreLib/src/System/__ComObject.cs
index 509f7bbefb..167e40e821 100644
--- a/src/System.Private.CoreLib/src/System/__ComObject.cs
+++ b/src/System.Private.CoreLib/src/System/__ComObject.cs
@@ -33,7 +33,7 @@ namespace System
// Only do the IStringable cast when running under AppX for better compat
// Otherwise we could do a IStringable cast in classic apps which could introduce
// a thread transition which would lead to deadlock.
- if (AppDomain.IsAppXModel())
+ if (ApplicationModel.IsUap)
{
// Check whether the type implements IStringable.
if (this is IStringable stringableType)
diff --git a/src/vm/appdomainnative.cpp b/src/vm/appdomainnative.cpp
index da78874c74..c2cc06a748 100644
--- a/src/vm/appdomainnative.cpp
+++ b/src/vm/appdomainnative.cpp
@@ -133,8 +133,7 @@ void QCALLTYPE AppDomainNative::SetupBindingPaths(__in_z LPCWSTR wszTrustedPlatf
END_QCALL;
}
-
-FCIMPL4(Object*, AppDomainNative::CreateDynamicAssembly, AppDomainBaseObject* refThisUNSAFE, AssemblyNameBaseObject* assemblyNameUNSAFE, StackCrawlMark* stackMark, INT32 access)
+FCIMPL3(Object*, AppDomainNative::CreateDynamicAssembly, AssemblyNameBaseObject* assemblyNameUNSAFE, StackCrawlMark* stackMark, INT32 access)
{
FCALL_CONTRACT;
@@ -145,7 +144,6 @@ FCIMPL4(Object*, AppDomainNative::CreateDynamicAssembly, AppDomainBaseObject* re
//</TODO>
CreateDynamicAssemblyArgs args;
- args.refThis = (APPDOMAINREF) refThisUNSAFE;
args.assemblyName = (ASSEMBLYNAMEREF) assemblyNameUNSAFE;
args.loaderAllocator = NULL;
@@ -154,9 +152,7 @@ FCIMPL4(Object*, AppDomainNative::CreateDynamicAssembly, AppDomainBaseObject* re
HELPER_METHOD_FRAME_BEGIN_RET_PROTECT((CreateDynamicAssemblyArgsGC&)args);
- AppDomain* pAppDomain = ValidateArg(args.refThis);
-
- Assembly *pAssembly = Assembly::CreateDynamic(pAppDomain, &args);
+ Assembly *pAssembly = Assembly::CreateDynamic(GetAppDomain(), &args);
refRetVal = (ASSEMBLYREF) pAssembly->GetExposedObject();
@@ -166,56 +162,39 @@ FCIMPL4(Object*, AppDomainNative::CreateDynamicAssembly, AppDomainBaseObject* re
FCIMPLEND
#ifdef FEATURE_APPX
-
-//
-// Keep in sync with bcl\system\appdomain.cs
-//
-enum
-{
- APPX_FLAGS_INITIALIZED = 0x01,
-
- APPX_FLAGS_APPX_MODEL = 0x02,
-};
-
// static
-INT32 QCALLTYPE AppDomainNative::GetAppXFlags()
+BOOL QCALLTYPE AppDomainNative::IsAppXProcess()
{
QCALL_CONTRACT;
- UINT32 flags = APPX_FLAGS_INITIALIZED;
+ BOOL result;
BEGIN_QCALL;
- if (AppX::IsAppXProcess())
- {
- flags |= APPX_FLAGS_APPX_MODEL;
- }
+ result = AppX::IsAppXProcess();
END_QCALL;
- return flags;
+ return result;
}
-
#endif // FEATURE_APPX
-FCIMPL2(Object*, AppDomainNative::GetAssemblies, AppDomainBaseObject* refThisUNSAFE, CLR_BOOL forIntrospection);
+FCIMPL0(Object*, AppDomainNative::GetLoadedAssemblies)
{
FCALL_CONTRACT;
struct _gc
{
PTRARRAYREF AsmArray;
- APPDOMAINREF refThis;
} gc;
gc.AsmArray = NULL;
- gc.refThis = (APPDOMAINREF) refThisUNSAFE;
HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
MethodTable * pAssemblyClass = MscorlibBinder::GetClass(CLASS__ASSEMBLY);
- AppDomain * pApp = ValidateArg(gc.refThis);
+ AppDomain * pApp = GetAppDomain();
// Allocate an array with as many elements as there are assemblies in this
// appdomain. This will usually be correct, but there may be assemblies
@@ -294,22 +273,19 @@ FCIMPL1(INT32, AppDomainNative::GetId, AppDomainBaseObject* refThisUNSAFE)
}
FCIMPLEND
-FCIMPL2(Object*, AppDomainNative::IsStringInterned, AppDomainBaseObject* refThisUNSAFE, StringObject* pStringUNSAFE)
+FCIMPL1(Object*, AppDomainNative::IsStringInterned, StringObject* pStringUNSAFE)
{
FCALL_CONTRACT;
- APPDOMAINREF refThis = (APPDOMAINREF)ObjectToOBJECTREF(refThisUNSAFE);
STRINGREF refString = ObjectToSTRINGREF(pStringUNSAFE);
STRINGREF* prefRetVal = NULL;
- HELPER_METHOD_FRAME_BEGIN_RET_2(refThis, refString);
-
- ValidateArg(refThis);
+ HELPER_METHOD_FRAME_BEGIN_RET_1(refString);
if (refString == NULL)
COMPlusThrow(kArgumentNullException, W("ArgumentNull_String"));
- prefRetVal = refThis->GetDomain()->IsStringInterned(&refString);
+ prefRetVal = GetAppDomain()->IsStringInterned(&refString);
HELPER_METHOD_FRAME_END();
@@ -320,22 +296,19 @@ FCIMPL2(Object*, AppDomainNative::IsStringInterned, AppDomainBaseObject* refThis
}
FCIMPLEND
-FCIMPL2(Object*, AppDomainNative::GetOrInternString, AppDomainBaseObject* refThisUNSAFE, StringObject* pStringUNSAFE)
+FCIMPL1(Object*, AppDomainNative::GetOrInternString, StringObject* pStringUNSAFE)
{
FCALL_CONTRACT;
STRINGREF refRetVal = NULL;
- APPDOMAINREF refThis = (APPDOMAINREF) refThisUNSAFE;
STRINGREF pString = (STRINGREF) pStringUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_2(refThis, pString);
-
- ValidateArg(refThis);
+ HELPER_METHOD_FRAME_BEGIN_RET_1(pString);
if (pString == NULL)
COMPlusThrow(kArgumentNullException, W("ArgumentNull_String"));
- STRINGREF* stringVal = refThis->GetDomain()->GetOrInternString(&pString);
+ STRINGREF* stringVal = GetAppDomain()->GetOrInternString(&pString);
if (stringVal != NULL)
{
refRetVal = *stringVal;
@@ -346,65 +319,6 @@ FCIMPL2(Object*, AppDomainNative::GetOrInternString, AppDomainBaseObject* refThi
}
FCIMPLEND
-
-FCIMPL1(Object*, AppDomainNative::GetDynamicDir, AppDomainBaseObject* refThisUNSAFE)
-{
- FCALL_CONTRACT;
-
- STRINGREF str = NULL;
- return OBJECTREFToObject(str);
-}
-FCIMPLEND
-
-FCIMPL2(StringObject*, AppDomainNative::nApplyPolicy, AppDomainBaseObject* refThisUNSAFE, AssemblyNameBaseObject* refAssemblyNameUNSAFE)
-{
- FCALL_CONTRACT;
-
- struct _gc
- {
- APPDOMAINREF refThis;
- ASSEMBLYNAMEREF assemblyName;
- STRINGREF rv;
- } gc;
-
- gc.refThis = (APPDOMAINREF)refThisUNSAFE;
- gc.assemblyName = (ASSEMBLYNAMEREF) refAssemblyNameUNSAFE;
- gc.rv = NULL;
-
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc);
-
- AppDomain* pDomain;
- pDomain = ValidateArg(gc.refThis);
-
- if (gc.assemblyName == NULL)
- {
- COMPlusThrow(kArgumentNullException, W("ArgumentNull_AssemblyName"));
- }
- if( (gc.assemblyName->GetSimpleName() == NULL) )
- {
- COMPlusThrow(kArgumentException, W("Format_StringZeroLength"));
- }
- Thread *pThread = GetThread();
- CheckPointHolder cph(pThread->m_MarshalAlloc.GetCheckpoint()); //hold checkpoint for autorelease
-
- // Initialize spec
- AssemblySpec spec;
- spec.InitializeSpec(&(pThread->m_MarshalAlloc),
- &gc.assemblyName,
- FALSE /*fIsStringized*/
- );
-
- StackSString sDisplayName;
-
- spec.GetFileOrDisplayName(0,sDisplayName);
-
- gc.rv = StringObject::NewString(sDisplayName);
-
- HELPER_METHOD_FRAME_END();
- return (StringObject*)OBJECTREFToObject(gc.rv);
-}
-FCIMPLEND
-
FCIMPL1(UINT32, AppDomainNative::GetAppDomainId, AppDomainBaseObject* refThisUNSAFE)
{
FCALL_CONTRACT;
@@ -611,5 +525,3 @@ FCIMPL0(INT64, AppDomainNative::GetLastSurvivedProcessMemorySize)
}
FCIMPLEND
#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING
-
-
diff --git a/src/vm/appdomainnative.hpp b/src/vm/appdomainnative.hpp
index dc1b133d2d..464ced73e6 100644
--- a/src/vm/appdomainnative.hpp
+++ b/src/vm/appdomainnative.hpp
@@ -23,19 +23,12 @@ public:
static AppDomain *ValidateArg(APPDOMAINREF pThis);
static FCDECL2(void, SetupFriendlyName, AppDomainBaseObject* refThisUNSAFE, StringObject* strFriendlyNameUNSAFE);
- static FCDECL4(Object*, CreateDynamicAssembly, AppDomainBaseObject* refThisUNSAFE, AssemblyNameBaseObject* assemblyNameUNSAFE, StackCrawlMark* stackMark, INT32 access);
- static FCDECL2(Object*, GetAssemblies, AppDomainBaseObject* refThisUNSAFE, CLR_BOOL fForIntrospection);
- static FCDECL2(Object*, GetOrInternString, AppDomainBaseObject* refThisUNSAFE, StringObject* pStringUNSAFE);
- static FCDECL1(void, CreateContext, AppDomainBaseObject *refThisUNSAFE);
+ static FCDECL3(Object*, CreateDynamicAssembly, AssemblyNameBaseObject* assemblyNameUNSAFE, StackCrawlMark* stackMark, INT32 access);
+ static FCDECL0(Object*, GetLoadedAssemblies);
+ static FCDECL1(Object*, GetOrInternString, StringObject* pStringUNSAFE);
static void QCALLTYPE SetupBindingPaths(__in_z LPCWSTR wszTrustedPlatformAssemblies, __in_z LPCWSTR wszPlatformResourceRoots, __in_z LPCWSTR wszAppPaths, __in_z LPCWSTR wszAppNiPaths, __in_z LPCWSTR appLocalWinMD);
- static FCDECL1(Object*, GetDynamicDir, AppDomainBaseObject* refThisUNSAFE);
static FCDECL1(INT32, GetId, AppDomainBaseObject* refThisUNSAFE);
- static FCDECL1(void, ForceToSharedDomain, Object* pObjectUNSAFE);
- static FCDECL1(LPVOID, GetFusionContext, AppDomainBaseObject* refThis);
- static FCDECL2(Object*, IsStringInterned, AppDomainBaseObject* refThis, StringObject* pString);
- static FCDECL3(void, UpdateContextProperty, LPVOID fusionContext, StringObject* key, Object* value);
- static FCDECL2(StringObject*, nApplyPolicy, AppDomainBaseObject* refThisUNSAFE, AssemblyNameBaseObject* assemblyNameUNSAFE);
- static FCDECL2(FC_BOOL_RET, IsFrameworkAssembly, AppDomainBaseObject* refThisUNSAFE, AssemblyNameBaseObject* refAssemblyNameUNSAFE);
+ static FCDECL1(Object*, IsStringInterned, StringObject* pString);
static FCDECL1(UINT32, GetAppDomainId, AppDomainBaseObject* refThisUNSAFE);
static FCDECL1(void , PublishAnonymouslyHostedDynamicMethodsAssembly, AssemblyBaseObject * pAssemblyUNSAFE);
static void QCALLTYPE SetNativeDllSearchDirectories(__in_z LPCWSTR wszAssembly);
@@ -49,15 +42,9 @@ public:
static FCDECL0(INT64, GetLastSurvivedProcessMemorySize);
#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING
-private:
- static INT32 ExecuteAssemblyHelper(Assembly* pAssembly,
- BOOL bCreatedConsole,
- PTRARRAYREF *pStringArgs);
-
-public:
#ifdef FEATURE_APPX
static
- INT32 QCALLTYPE GetAppXFlags();
+ INT32 QCALLTYPE IsAppXProcess();
#endif
};
diff --git a/src/vm/assembly.hpp b/src/vm/assembly.hpp
index cd34c707f2..d55d31e88c 100644
--- a/src/vm/assembly.hpp
+++ b/src/vm/assembly.hpp
@@ -57,7 +57,6 @@ class FriendAssemblyDescriptor;
struct CreateDynamicAssemblyArgsGC
{
- APPDOMAINREF refThis;
ASSEMBLYNAMEREF assemblyName;
LOADERALLOCATORREF loaderAllocator;
};
diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h
index b056eb9e91..5ee6173137 100644
--- a/src/vm/ecalllist.h
+++ b/src/vm/ecalllist.h
@@ -112,6 +112,8 @@ FCFuncStart(gStringFuncs)
FCFuncElement("IsAscii", COMString::IsAscii)
FCFuncElement("SetTrailByte", COMString::FCSetTrailByte)
FCFuncElement("TryGetTrailByte", COMString::FCTryGetTrailByte)
+ FCFuncElement("IsInterned", AppDomainNative::IsStringInterned)
+ FCFuncElement("Intern", AppDomainNative::GetOrInternString)
FCFuncEnd()
FCFuncStart(gValueTypeFuncs)
@@ -432,22 +434,13 @@ FCFuncStart(gCOMClassWriter)
QCFuncElement("DefineCustomAttribute", COMDynamicWrite::DefineCustomAttribute)
FCFuncEnd()
-
FCFuncStart(gCompatibilitySwitchFuncs)
FCFuncElement("GetValueInternalCall", CompatibilitySwitch::GetValue)
FCFuncEnd()
-
FCFuncStart(gAppDomainFuncs)
- FCFuncElement("IsStringInterned", AppDomainNative::IsStringInterned)
-
-#ifdef FEATURE_APPX
- QCFuncElement("nGetAppXFlags", AppDomainNative::GetAppXFlags)
-#endif
FCFuncElement("nSetupFriendlyName", AppDomainNative::SetupFriendlyName)
- FCFuncElement("nGetAssemblies", AppDomainNative::GetAssemblies)
FCFuncElement("GetId", AppDomainNative::GetId)
- FCFuncElement("GetOrInternString", AppDomainNative::GetOrInternString)
QCFuncElement("nSetupBindingPaths", AppDomainNative::SetupBindingPaths)
QCFuncElement("nSetNativeDllSearchDirectories", AppDomainNative::SetNativeDllSearchDirectories)
FCFuncElement("PublishAnonymouslyHostedDynamicMethodsAssembly", AppDomainNative::PublishAnonymouslyHostedDynamicMethodsAssembly)
@@ -462,6 +455,11 @@ FCFuncStart(gAppDomainFuncs)
#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING
FCFuncEnd()
+#ifdef FEATURE_APPX
+FCFuncStart(gApplicationModelFuncs)
+ QCFuncElement("IsAppXProcess", AppDomainNative::IsAppXProcess)
+FCFuncEnd()
+#endif
FCFuncStart(gMdUtf8String)
FCFuncElement("EqualsCaseSensitive", MdUtf8String::EqualsCaseSensitive)
@@ -542,6 +540,7 @@ FCFuncStart(gAssemblyLoadContextFuncs)
QCFuncElement("InternalLoadUnmanagedDllFromPath", AssemblyNative::InternalLoadUnmanagedDllFromPath)
QCFuncElement("LoadFromStream", AssemblyNative::LoadFromStream)
QCFuncElement("GetLoadContextForAssembly", AssemblyNative::GetLoadContextForAssembly)
+ FCFuncElement("GetLoadedAssemblies", AppDomainNative::GetLoadedAssemblies)
#if defined(FEATURE_MULTICOREJIT)
QCFuncElement("InternalSetProfileRoot", MultiCoreJITNative::InternalSetProfileRoot)
QCFuncElement("InternalStartProfile", MultiCoreJITNative::InternalStartProfile)
@@ -1239,6 +1238,9 @@ FCFuncEnd()
// The sorting is case-sensitive
FCClassElement("AppDomain", "System", gAppDomainFuncs)
+#ifdef FEATURE_APPX
+FCClassElement("ApplicationModel", "System", gApplicationModelFuncs)
+#endif
FCClassElement("ArgIterator", "System", gVarArgFuncs)
FCClassElement("Array", "System", gArrayFuncs)
FCClassElement("ArrayWithOffset", "System.Runtime.InteropServices", gArrayWithOffsetFuncs)