diff options
author | mikedn <onemihaid@hotmail.com> | 2018-01-28 20:58:58 +0200 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-01-28 10:58:58 -0800 |
commit | e3562c9bcc92ec04eec97cf1a945e7ea6d5234d2 (patch) | |
tree | ebda9d8f4bd5b3bd17eb49da0fda64e920923c06 /src/vm | |
parent | 256b05fae0d8e7a95235212064463b2ebbcc8f0f (diff) | |
download | coreclr-e3562c9bcc92ec04eec97cf1a945e7ea6d5234d2.tar.gz coreclr-e3562c9bcc92ec04eec97cf1a945e7ea6d5234d2.tar.bz2 coreclr-e3562c9bcc92ec04eec97cf1a945e7ea6d5234d2.zip |
Improve Interlocked.Exchange<T> (#16058)
Replace TypedReference with Unsafe.As, it generates far less code and, with the help of AggresiveInlining, it allows Exchange<T> to inline.
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/comutilnative.cpp | 40 | ||||
-rw-r--r-- | src/vm/comutilnative.h | 2 | ||||
-rw-r--r-- | src/vm/ecalllist.h | 3 |
3 files changed, 0 insertions, 45 deletions
diff --git a/src/vm/comutilnative.cpp b/src/vm/comutilnative.cpp index f9f159a61a..c4563992b7 100644 --- a/src/vm/comutilnative.cpp +++ b/src/vm/comutilnative.cpp @@ -1807,46 +1807,6 @@ FCIMPL2(LPVOID,COMInterlocked::ExchangeObject, LPVOID*location, LPVOID value) } FCIMPLEND -FCIMPL2_VV(void,COMInterlocked::ExchangeGeneric, FC_TypedByRef location, FC_TypedByRef value) -{ - FCALL_CONTRACT; - - LPVOID* loc = (LPVOID*)location.data; - if( NULL == loc) { - FCThrowVoid(kNullReferenceException); - } - - LPVOID val = *(LPVOID*)value.data; - *(LPVOID*)value.data = FastInterlockExchangePointer(loc, val); -#ifdef _DEBUG - Thread::ObjectRefAssign((OBJECTREF *)loc); -#endif - ErectWriteBarrier((OBJECTREF*) loc, ObjectToOBJECTREF((Object*) val)); -} -FCIMPLEND - -FCIMPL3_VVI(void,COMInterlocked::CompareExchangeGeneric, FC_TypedByRef location, FC_TypedByRef value, LPVOID comparand) -{ - FCALL_CONTRACT; - - LPVOID* loc = (LPVOID*)location.data; - LPVOID val = *(LPVOID*)value.data; - if( NULL == loc) { - FCThrowVoid(kNullReferenceException); - } - - LPVOID ret = FastInterlockCompareExchangePointer(loc, val, comparand); - *(LPVOID*)value.data = ret; - if(ret == comparand) - { -#ifdef _DEBUG - Thread::ObjectRefAssign((OBJECTREF *)loc); -#endif - ErectWriteBarrier((OBJECTREF*) loc, ObjectToOBJECTREF((Object*) val)); - } -} -FCIMPLEND - FCIMPL3(LPVOID,COMInterlocked::CompareExchangeObject, LPVOID *location, LPVOID value, LPVOID comparand) { FCALL_CONTRACT; diff --git a/src/vm/comutilnative.h b/src/vm/comutilnative.h index b1e47bef21..617785de94 100644 --- a/src/vm/comutilnative.h +++ b/src/vm/comutilnative.h @@ -193,8 +193,6 @@ public: static FCDECL3(LPVOID, CompareExchangeObject, LPVOID* location, LPVOID value, LPVOID comparand); static FCDECL2(INT32, ExchangeAdd32, INT32 *location, INT32 value); static FCDECL2_IV(INT64, ExchangeAdd64, INT64 *location, INT64 value); - static FCDECL2_VV(void, ExchangeGeneric, FC_TypedByRef location, FC_TypedByRef value); - static FCDECL3_VVI(void, CompareExchangeGeneric, FC_TypedByRef location, FC_TypedByRef value, LPVOID comparand); static FCDECL0(void, FCMemoryBarrier); static void QCALLTYPE MemoryBarrierProcessWide(); diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h index 7cd6889c47..525227b7c3 100644 --- a/src/vm/ecalllist.h +++ b/src/vm/ecalllist.h @@ -982,9 +982,6 @@ FCFuncStart(gInterlockedFuncs) FCIntrinsicSig("ExchangeAdd", &gsig_SM_RefInt_Int_RetInt, COMInterlocked::ExchangeAdd32, CORINFO_INTRINSIC_InterlockedXAdd32) FCIntrinsicSig("ExchangeAdd", &gsig_SM_RefLong_Long_RetLong, COMInterlocked::ExchangeAdd64, CORINFO_INTRINSIC_InterlockedXAdd64) - FCFuncElement("_Exchange", COMInterlocked::ExchangeGeneric) - FCFuncElement("_CompareExchange", COMInterlocked::CompareExchangeGeneric) - FCIntrinsic("MemoryBarrier", COMInterlocked::FCMemoryBarrier, CORINFO_INTRINSIC_MemoryBarrier) QCFuncElement("_MemoryBarrierProcessWide", COMInterlocked::MemoryBarrierProcessWide) FCFuncEnd() |