summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2019-02-05 04:43:10 +0100
committerJan Kotas <jkotas@microsoft.com>2019-02-04 19:43:10 -0800
commit382dbe4ba82f57a138484e0c5052c3b8606c1294 (patch)
tree4e220d0a0e3198678829836df034e8039e1697a2 /src/vm
parent7e20b6fa7b2253511b6f0a7d76c955360e040df6 (diff)
downloadcoreclr-382dbe4ba82f57a138484e0c5052c3b8606c1294.tar.gz
coreclr-382dbe4ba82f57a138484e0c5052c3b8606c1294.tar.bz2
coreclr-382dbe4ba82f57a138484e0c5052c3b8606c1294.zip
Move SynchronizationContext to shared partition (#22389)
* Move SynchronizationContext to shared partition * Move WaitHelperNative to WaitHandle
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/comwaithandle.cpp26
-rw-r--r--src/vm/comwaithandle.h1
-rw-r--r--src/vm/ecalllist.h2
-rw-r--r--src/vm/mscorlib.h2
-rw-r--r--src/vm/object.h9
-rw-r--r--src/vm/synchronizationcontextnative.cpp29
-rw-r--r--src/vm/synchronizationcontextnative.h2
7 files changed, 32 insertions, 39 deletions
diff --git a/src/vm/comwaithandle.cpp b/src/vm/comwaithandle.cpp
index 935a8f031a..48dab31fcd 100644
--- a/src/vm/comwaithandle.cpp
+++ b/src/vm/comwaithandle.cpp
@@ -311,3 +311,29 @@ FCIMPL5(INT32, WaitHandleNative::CorSignalAndWaitOneNative, SafeHandle* safeWait
return retVal;
}
FCIMPLEND
+
+FCIMPL3(DWORD, WaitHandleNative::WaitHelper, PTRArray *handleArrayUNSAFE, CLR_BOOL waitAll, DWORD millis)
+{
+ FCALL_CONTRACT;
+
+ DWORD ret = 0;
+
+ PTRARRAYREF handleArrayObj = (PTRARRAYREF) handleArrayUNSAFE;
+ HELPER_METHOD_FRAME_BEGIN_RET_1(handleArrayObj);
+
+ CQuickArray<HANDLE> qbHandles;
+ int cHandles = handleArrayObj->GetNumComponents();
+
+ // Since DoAppropriateWait could cause a GC, we need to copy the handles to an unmanaged block
+ // of memory to ensure they aren't relocated during the call to DoAppropriateWait.
+ qbHandles.AllocThrows(cHandles);
+ memcpy(qbHandles.Ptr(), handleArrayObj->GetDataPtr(), cHandles * sizeof(HANDLE));
+
+ Thread * pThread = GetThread();
+ ret = pThread->DoAppropriateWait(cHandles, qbHandles.Ptr(), waitAll, millis,
+ (WaitMode)(WaitMode_Alertable | WaitMode_IgnoreSyncCtx));
+
+ HELPER_METHOD_FRAME_END();
+ return ret;
+}
+FCIMPLEND
diff --git a/src/vm/comwaithandle.h b/src/vm/comwaithandle.h
index 9c27460080..df08a10733 100644
--- a/src/vm/comwaithandle.h
+++ b/src/vm/comwaithandle.h
@@ -22,5 +22,6 @@ public:
static FCDECL4(INT32, CorWaitOneNative, SafeHandle* safeWaitHandleUNSAFE, INT32 timeout, CLR_BOOL hasThreadAffinity, CLR_BOOL exitContext);
static FCDECL4(INT32, CorWaitMultipleNative, Object* waitObjectsUNSAFE, INT32 timeout, CLR_BOOL exitContext, CLR_BOOL waitForAll);
static FCDECL5(INT32, CorSignalAndWaitOneNative, SafeHandle* safeWaitHandleSignalUNSAFE, SafeHandle* safeWaitHandleWaitUNSAFE, INT32 timeout, CLR_BOOL hasThreadAffinity, CLR_BOOL exitContext);
+ static FCDECL3(DWORD, WaitHelper, PTRArray *handleArrayUNSAFE, CLR_BOOL waitAll, DWORD millis);
};
#endif
diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h
index bef2de9674..9a1d6922e8 100644
--- a/src/vm/ecalllist.h
+++ b/src/vm/ecalllist.h
@@ -716,6 +716,7 @@ FCFuncStart(gWaitHandleFuncs)
FCFuncElement("WaitOneNative", WaitHandleNative::CorWaitOneNative)
FCFuncElement("WaitMultiple", WaitHandleNative::CorWaitMultipleNative)
FCFuncElement("SignalAndWaitOne", WaitHandleNative::CorSignalAndWaitOneNative)
+ FCFuncElement("WaitMultipleIgnoringSyncContext", WaitHandleNative::WaitHelper)
FCFuncEnd()
#ifdef FEATURE_COMINTEROP
@@ -949,7 +950,6 @@ FCFuncStart(gRuntimeHelpers)
FCFuncEnd()
FCFuncStart(gContextSynchronizationFuncs)
- FCFuncElement("WaitHelperNative", SynchronizationContextNative::WaitHelper)
#ifdef FEATURE_APPX
QCFuncElement("GetWinRTDispatcherForCurrentThread", SynchronizationContextNative::GetWinRTDispatcherForCurrentThread)
#endif
diff --git a/src/vm/mscorlib.h b/src/vm/mscorlib.h
index 81c21f2bde..56aa94fb62 100644
--- a/src/vm/mscorlib.h
+++ b/src/vm/mscorlib.h
@@ -821,7 +821,7 @@ DEFINE_METHOD(STRING_BUILDER, REPLACE_BUFFER_ANSI_INTERNAL,ReplaceBufferAn
DEFINE_CLASS(STRONG_NAME_KEY_PAIR, Reflection, StrongNameKeyPair)
DEFINE_CLASS_U(Threading, SynchronizationContext, SynchronizationContextObject)
-DEFINE_FIELD_U(_props, SynchronizationContextObject, _props)
+DEFINE_FIELD_U(_requireWaitNotification, SynchronizationContextObject, _requireWaitNotification)
DEFINE_CLASS(SYNCHRONIZATION_CONTEXT, Threading, SynchronizationContext)
DEFINE_METHOD(SYNCHRONIZATION_CONTEXT, INVOKE_WAIT_METHOD_HELPER, InvokeWaitMethodHelper, SM_SyncCtx_ArrIntPtr_Bool_Int_RetInt)
diff --git a/src/vm/object.h b/src/vm/object.h
index 54ccd4c650..d3a3af3cd9 100644
--- a/src/vm/object.h
+++ b/src/vm/object.h
@@ -1334,7 +1334,6 @@ typedef SafeHandle * SAFEHANDLEREF;
-#define SYNCCTXPROPS_REQUIRESWAITNOTIFICATION 0x1 // Keep in sync with SynchronizationContext.cs SynchronizationContextFlags
class ThreadBaseObject;
class SynchronizationContextObject: public Object
{
@@ -1344,14 +1343,12 @@ private:
// add or change these field you must also change the managed code so that
// it matches these. This is necessary so that the object is the proper
// size.
- INT32 _props;
+ CLR_BOOL _requireWaitNotification;
public:
- BOOL IsWaitNotificationRequired()
+ BOOL IsWaitNotificationRequired() const
{
LIMITED_METHOD_CONTRACT;
- if ((_props & SYNCCTXPROPS_REQUIRESWAITNOTIFICATION) != 0)
- return TRUE;
- return FALSE;
+ return _requireWaitNotification;
}
};
diff --git a/src/vm/synchronizationcontextnative.cpp b/src/vm/synchronizationcontextnative.cpp
index 03b289fc95..654f69e3ab 100644
--- a/src/vm/synchronizationcontextnative.cpp
+++ b/src/vm/synchronizationcontextnative.cpp
@@ -18,37 +18,8 @@
#include <roapi.h>
#include <windows.ui.core.h>
#include "winrtdispatcherqueue.h"
-#endif
#include "synchronizationcontextnative.h"
-
-FCIMPL3(DWORD, SynchronizationContextNative::WaitHelper, PTRArray *handleArrayUNSAFE, CLR_BOOL waitAll, DWORD millis)
-{
- FCALL_CONTRACT;
-
- DWORD ret = 0;
-
- PTRARRAYREF handleArrayObj = (PTRARRAYREF) handleArrayUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_1(handleArrayObj);
-
- CQuickArray<HANDLE> qbHandles;
- int cHandles = handleArrayObj->GetNumComponents();
-
- // Since DoAppropriateWait could cause a GC, we need to copy the handles to an unmanaged block
- // of memory to ensure they aren't relocated during the call to DoAppropriateWait.
- qbHandles.AllocThrows(cHandles);
- memcpy(qbHandles.Ptr(), handleArrayObj->GetDataPtr(), cHandles * sizeof(HANDLE));
-
- Thread * pThread = GetThread();
- ret = pThread->DoAppropriateWait(cHandles, qbHandles.Ptr(), waitAll, millis,
- (WaitMode)(WaitMode_Alertable | WaitMode_IgnoreSyncCtx));
-
- HELPER_METHOD_FRAME_END();
- return ret;
-}
-FCIMPLEND
-#ifdef FEATURE_APPX
-
Volatile<ABI::Windows::UI::Core::ICoreWindowStatic*> g_pICoreWindowStatic;
void* QCALLTYPE SynchronizationContextNative::GetWinRTDispatcherForCurrentThread()
diff --git a/src/vm/synchronizationcontextnative.h b/src/vm/synchronizationcontextnative.h
index 917d3a0afb..a89579ff61 100644
--- a/src/vm/synchronizationcontextnative.h
+++ b/src/vm/synchronizationcontextnative.h
@@ -19,8 +19,6 @@ class SynchronizationContextNative
{
public:
- static FCDECL3(DWORD, WaitHelper, PTRArray *handleArrayUNSAFE, CLR_BOOL waitAll, DWORD millis);
-
#ifdef FEATURE_APPX
static void* QCALLTYPE GetWinRTDispatcherForCurrentThread();
static void Cleanup();