From 3c59a84ad15fa4f2228aca900de3a62715c595c1 Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Wed, 19 Apr 2017 16:39:23 +0000 Subject: [PATCH] Change ICLRRuntimeHost2 to ICLRRuntimeHost4 for Windows corerun. (dotnet/coreclr#10967) * Change ICLRRuntimeHost2 to ICLRRuntimeHost4 for Windows corerun. Since we've introduced ICLRRuntimeHost4 in PR dotnet/coreclr#10842 for Unix, we apply it for Windows corerun as well. Fix dotnet/coreclr#10960 Commit migrated from https://github.com/dotnet/coreclr/commit/1399794fd221fc97bce1a3b1f1fe4dbb03c8686d --- .../src/coreclr/hosts/coreconsole/coreconsole.cpp | 24 ++++++++++++---------- src/coreclr/src/coreclr/hosts/corerun/corerun.cpp | 24 ++++++++++++---------- src/coreclr/src/inc/MSCOREE.IDL | 18 ++++++++++++++++ 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/coreclr/src/coreclr/hosts/coreconsole/coreconsole.cpp b/src/coreclr/src/coreclr/hosts/coreconsole/coreconsole.cpp index ea4e2e7..e3813d4 100644 --- a/src/coreclr/src/coreclr/hosts/coreconsole/coreconsole.cpp +++ b/src/coreclr/src/coreclr/hosts/coreconsole/coreconsole.cpp @@ -71,7 +71,7 @@ class HostEnvironment // The list of paths to the assemblies that will be trusted by CoreCLR StringBuffer m_tpaList; - ICLRRuntimeHost2* m_CLRRuntimeHost; + ICLRRuntimeHost4* m_CLRRuntimeHost; HMODULE m_coreCLRModule; @@ -326,8 +326,8 @@ public: return m_hostExeName; } - // Returns the ICLRRuntimeHost2 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure. - ICLRRuntimeHost2* GetCLRRuntimeHost() { + // Returns the ICLRRuntimeHost4 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure. + ICLRRuntimeHost4* GetCLRRuntimeHost() { if (!m_CLRRuntimeHost) { if (!m_coreCLRModule) { @@ -347,9 +347,9 @@ public: *m_log << W("Calling GetCLRRuntimeHost(...)") << Logger::endl; - HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost2, (IUnknown**)&m_CLRRuntimeHost); + HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost4, (IUnknown**)&m_CLRRuntimeHost); if (FAILED(hr)) { - *m_log << W("Failed to get ICLRRuntimeHost2 interface. ERRORCODE: ") << hr << Logger::endl; + *m_log << W("Failed to get ICLRRuntimeHost4 interface. ERRORCODE: ") << hr << Logger::endl; return nullptr; } } @@ -405,14 +405,14 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo // Start the CoreCLR - ICLRRuntimeHost2 *host = hostEnvironment.GetCLRRuntimeHost(); + ICLRRuntimeHost4 *host = hostEnvironment.GetCLRRuntimeHost(); if (!host) { return false; } HRESULT hr; - log << W("Setting ICLRRuntimeHost2 startup flags") << Logger::endl; + log << W("Setting ICLRRuntimeHost4 startup flags") << Logger::endl; // Default startup flags hr = host->SetStartupFlags((STARTUP_FLAGS) @@ -424,7 +424,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo return false; } - log << W("Starting ICLRRuntimeHost2") << Logger::endl; + log << W("Starting ICLRRuntimeHost4") << Logger::endl; hr = host->Start(); if (FAILED(hr)) { @@ -541,15 +541,17 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo log << W("Unloading the AppDomain") << Logger::endl; - hr = host->UnloadAppDomain( + hr = host->UnloadAppDomain2( domainId, - true); // Wait until done + true, + (int *)&exitCode); // Wait until done if (FAILED(hr)) { log << W("Failed to unload the AppDomain. ERRORCODE: ") << hr << Logger::endl; return false; } + log << W("App domain unloaded exit value = ") << exitCode << Logger::endl; //------------------------------------------------------------- @@ -568,7 +570,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo // Release the reference to the host - log << W("Releasing ICLRRuntimeHost2") << Logger::endl; + log << W("Releasing ICLRRuntimeHost4") << Logger::endl; host->Release(); diff --git a/src/coreclr/src/coreclr/hosts/corerun/corerun.cpp b/src/coreclr/src/coreclr/hosts/corerun/corerun.cpp index dfbb79c..c65c626 100644 --- a/src/coreclr/src/coreclr/hosts/corerun/corerun.cpp +++ b/src/coreclr/src/coreclr/hosts/corerun/corerun.cpp @@ -47,7 +47,7 @@ class HostEnvironment // The list of paths to the assemblies that will be trusted by CoreCLR SString m_tpaList; - ICLRRuntimeHost2* m_CLRRuntimeHost; + ICLRRuntimeHost4* m_CLRRuntimeHost; HMODULE m_coreCLRModule; @@ -298,8 +298,8 @@ public: return m_hostExeName; } - // Returns the ICLRRuntimeHost2 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure. - ICLRRuntimeHost2* GetCLRRuntimeHost() { + // Returns the ICLRRuntimeHost4 instance, loading it from CoreCLR.dll if necessary, or nullptr on failure. + ICLRRuntimeHost4* GetCLRRuntimeHost() { if (!m_CLRRuntimeHost) { if (!m_coreCLRModule) { @@ -319,9 +319,9 @@ public: *m_log << W("Calling GetCLRRuntimeHost(...)") << Logger::endl; - HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost2, (IUnknown**)&m_CLRRuntimeHost); + HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost4, (IUnknown**)&m_CLRRuntimeHost); if (FAILED(hr)) { - *m_log << W("Failed to get ICLRRuntimeHost2 interface. ERRORCODE: ") << Logger::hresult << hr << Logger::endl; + *m_log << W("Failed to get ICLRRuntimeHost4 interface. ERRORCODE: ") << Logger::hresult << hr << Logger::endl; return nullptr; } } @@ -442,7 +442,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo // Start the CoreCLR - ICLRRuntimeHost2 *host = hostEnvironment.GetCLRRuntimeHost(); + ICLRRuntimeHost4 *host = hostEnvironment.GetCLRRuntimeHost(); if (!host) { return false; } @@ -451,7 +451,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo STARTUP_FLAGS flags = CreateStartupFlags(); - log << W("Setting ICLRRuntimeHost2 startup flags") << Logger::endl; + log << W("Setting ICLRRuntimeHost4 startup flags") << Logger::endl; log << W("Server GC enabled: ") << HAS_FLAG(flags, STARTUP_FLAGS::STARTUP_SERVER_GC) << Logger::endl; log << W("Concurrent GC enabled: ") << HAS_FLAG(flags, STARTUP_FLAGS::STARTUP_CONCURRENT_GC) << Logger::endl; @@ -462,7 +462,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo return false; } - log << W("Starting ICLRRuntimeHost2") << Logger::endl; + log << W("Starting ICLRRuntimeHost4") << Logger::endl; hr = host->Start(); if (FAILED(hr)) { @@ -581,15 +581,17 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo log << W("Unloading the AppDomain") << Logger::endl; - hr = host->UnloadAppDomain( + hr = host->UnloadAppDomain2( domainId, - true); // Wait until done + true, + (int *)&exitCode); // Wait until done if (FAILED(hr)) { log << W("Failed to unload the AppDomain. ERRORCODE: ") << Logger::hresult << hr << Logger::endl; return false; } + log << W("App domain unloaded exit value = ") << exitCode << Logger::endl; //------------------------------------------------------------- @@ -608,7 +610,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo // Release the reference to the host - log << W("Releasing ICLRRuntimeHost2") << Logger::endl; + log << W("Releasing ICLRRuntimeHost4") << Logger::endl; host->Release(); diff --git a/src/coreclr/src/inc/MSCOREE.IDL b/src/coreclr/src/inc/MSCOREE.IDL index 97e2f2a..53d4ce3 100644 --- a/src/coreclr/src/inc/MSCOREE.IDL +++ b/src/coreclr/src/inc/MSCOREE.IDL @@ -86,6 +86,9 @@ cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost, 0x90F1A06C, 0x7712, 0x4762, 0x86, 0x // IID ICLRRuntimeHost2: uuid(712AB73F-2C22-4807-AD7E-F501D7B72C2D) cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost2, 0x712AB73F, 0x2C22, 0x4807, 0xAD, 0x7E, 0xF5, 0x01, 0xD7, 0xb7, 0x2C, 0x2D);") +// IID ICLRRuntimeHost4: uuid(64F6D366-D7C2-4F1F-B4B2-E8160CAC43AF) +cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost4, 0x64F6D366, 0xD7C2, 0x4F1F, 0xB4, 0xB2, 0xE8, 0x16, 0x0C, 0xAC, 0x43, 0xAF);") + // IID IID_ICLRExecutionManager: uuid(1000A3E7-B420-4620-AE30-FB19B587AD1D) cpp_quote("EXTERN_GUID(IID_ICLRExecutionManager, 0x1000A3E7, 0xB420, 0x4620, 0xAE, 0x30, 0xFB, 0x19, 0xB5, 0x87, 0xAD, 0x1D);") @@ -848,6 +851,21 @@ interface ICLRRuntimeHost2 : ICLRRuntimeHost }; [ + object, + uuid(64F6D366-D7C2-4F1F-B4B2-E8160CAC43AF), + version(4.0), + helpstring("Common Language Runtime Hosting Interface"), + pointer_default(unique), + local +] +interface ICLRRuntimeHost4 : ICLRRuntimeHost2 +{ + HRESULT UnloadAppDomain2([in] DWORD dwAppDomainId, + [in] BOOL fWaitUntilDone, + [out] int *pLatchedExitCode); +}; + +[ uuid(1000A3E7-B420-4620-AE30-FB19B587AD1D), version(1.0), helpstring("Pause and Resume Interface"), -- 2.7.4