diff options
author | Aditya Mandaleeka <adityam@microsoft.com> | 2017-03-31 17:12:03 -0700 |
---|---|---|
committer | Aditya Mandaleeka <adityam@microsoft.com> | 2017-03-31 19:30:25 -0700 |
commit | 958279de27e7f3c30ad53e35277653d1ec0f1e6e (patch) | |
tree | 9a57e3fa0f362e475f98c6ad2f407d57d83da310 /src/gc | |
parent | dab2f6b76a1ed088a871374189e2133db9c9accb (diff) | |
download | coreclr-958279de27e7f3c30ad53e35277653d1ec0f1e6e.tar.gz coreclr-958279de27e7f3c30ad53e35277653d1ec0f1e6e.tar.bz2 coreclr-958279de27e7f3c30ad53e35277653d1ec0f1e6e.zip |
Change how VM calls ObjectFromHandle.
Diffstat (limited to 'src/gc')
-rw-r--r-- | src/gc/gc.cpp | 6 | ||||
-rw-r--r-- | src/gc/gchandletable.cpp | 8 | ||||
-rw-r--r-- | src/gc/gchandletableimpl.h | 4 | ||||
-rw-r--r-- | src/gc/gcinterface.h | 12 | ||||
-rw-r--r-- | src/gc/handletable.h | 5 | ||||
-rw-r--r-- | src/gc/objecthandle.h | 3 | ||||
-rw-r--r-- | src/gc/sample/GCSample.cpp | 10 |
7 files changed, 21 insertions, 27 deletions
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index 9435357eeb..fa98c6e76d 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -34206,11 +34206,11 @@ bool GCHeap::StressHeap(gc_alloc_context * context) StringObject* str; // If the current string is used up - if (ObjectFromHandle(m_StressObjs[m_CurStressObj]) == 0) + if (HndFetchHandle(m_StressObjs[m_CurStressObj]) == 0) { // Populate handles with strings int i = m_CurStressObj; - while(ObjectFromHandle(m_StressObjs[i]) == 0) + while(HndFetchHandle(m_StressObjs[i]) == 0) { _ASSERTE(m_StressObjs[i] != 0); unsigned strLen = (LARGE_OBJECT_SIZE - 32) / sizeof(WCHAR); @@ -34242,7 +34242,7 @@ bool GCHeap::StressHeap(gc_alloc_context * context) } // Get the current string - str = (StringObject*) OBJECTREFToObject(ObjectFromHandle(m_StressObjs[m_CurStressObj])); + str = (StringObject*) OBJECTREFToObject(HndFetchHandle(m_StressObjs[m_CurStressObj])); if (str) { // Chop off the end of the string and form a new object out of it. diff --git a/src/gc/gchandletable.cpp b/src/gc/gchandletable.cpp index c096d9fbd6..f468bd300f 100644 --- a/src/gc/gchandletable.cpp +++ b/src/gc/gchandletable.cpp @@ -23,12 +23,12 @@ void GCHandleTable::Shutdown() Ref_Shutdown(); } -void* GCHandleTable::GetHandleTableContext(HHANDLETABLE hTable) +void* GCHandleTable::GetHandleTableContext(void* handleTable) { - return (void*)((uintptr_t)::HndGetHandleTableADIndex(hTable).m_dwIndex); + return (void*)((uintptr_t)::HndGetHandleTableADIndex((HHANDLETABLE)handleTable).m_dwIndex); } -HHANDLETABLE GCHandleTable::GetHandleTableForHandle(OBJECTHANDLE handle) +void* GCHandleTable::GetHandleTableForHandle(OBJECTHANDLE handle) { - return ::HndGetHandleTable(handle); + return (void*)::HndGetHandleTable(handle); } diff --git a/src/gc/gchandletableimpl.h b/src/gc/gchandletableimpl.h index eafb0a0398..11fa163df7 100644 --- a/src/gc/gchandletableimpl.h +++ b/src/gc/gchandletableimpl.h @@ -14,9 +14,9 @@ public: virtual void Shutdown(); - virtual void* GetHandleTableContext(HHANDLETABLE hTable); + virtual void* GetHandleTableContext(void* handleTable); - virtual HHANDLETABLE GetHandleTableForHandle(OBJECTHANDLE handle); + virtual void* GetHandleTableForHandle(OBJECTHANDLE handle); }; #endif // GCHANDLETABLE_H_ diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h index e1e7301247..b5a9e0e8f9 100644 --- a/src/gc/gcinterface.h +++ b/src/gc/gcinterface.h @@ -153,14 +153,6 @@ struct segment_info size_t ibReserved; // limit of reserved memory in the segment (>= commit) }; - -/* - * handle to handle table - */ -typedef DPTR(struct HandleTable) PTR_HandleTable; -typedef DPTR(PTR_HandleTable) PTR_PTR_HandleTable; -typedef PTR_HandleTable HHANDLETABLE; -typedef PTR_PTR_HandleTable PTR_HHANDLETABLE; #ifdef PROFILING_SUPPORTED #define GC_PROFILING //Turn on profiling #endif // PROFILING_SUPPORTED @@ -400,9 +392,9 @@ public: virtual void Shutdown() = 0; - virtual void* GetHandleTableContext(HHANDLETABLE hTable) = 0; + virtual void* GetHandleTableContext(void* handleTable) = 0; - virtual HHANDLETABLE GetHandleTableForHandle(OBJECTHANDLE handle) = 0; + virtual void* GetHandleTableForHandle(OBJECTHANDLE handle) = 0; }; // IGCHeap is the interface that the VM will use when interacting with the GC. diff --git a/src/gc/handletable.h b/src/gc/handletable.h index 2e847659f3..5b0299fe02 100644 --- a/src/gc/handletable.h +++ b/src/gc/handletable.h @@ -177,8 +177,11 @@ BOOL HndFirstAssignHandle(OBJECTHANDLE handle, OBJECTREF objref); /* * inline handle dereferencing + * + * NOTE: Changes to this implementation should be kept in sync with ObjectFromHandle + * on the VM side. + * */ - FORCEINLINE OBJECTREF HndFetchHandle(OBJECTHANDLE handle) { WRAPPER_NO_CONTRACT; diff --git a/src/gc/objecthandle.h b/src/gc/objecthandle.h index b86572b276..386c5d4512 100644 --- a/src/gc/objecthandle.h +++ b/src/gc/objecthandle.h @@ -27,7 +27,6 @@ * non-NULL. In other words, if this handle is being initialized for the first * time. */ -#define ObjectFromHandle(handle) HndFetchHandle(handle) #define StoreObjectInHandle(handle, object) HndAssignHandle(handle, object) #define InterlockedCompareExchangeObjectInHandle(handle, object, oldObj) HndInterlockedCompareExchangeHandle(handle, object, oldObj) #define StoreFirstObjectInHandle(handle, object) HndFirstAssignHandle(handle, object) @@ -119,7 +118,7 @@ inline OBJECTHANDLE CreateDuplicateHandle(OBJECTHANDLE handle) { WRAPPER_NO_CONTRACT; // Create a new STRONG handle in the same table as an existing handle. - return HndCreateHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, ObjectFromHandle(handle)); + return HndCreateHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, HndFetchHandle(handle)); } diff --git a/src/gc/sample/GCSample.cpp b/src/gc/sample/GCSample.cpp index 5d5371c76e..45915c0d04 100644 --- a/src/gc/sample/GCSample.cpp +++ b/src/gc/sample/GCSample.cpp @@ -207,24 +207,24 @@ int __cdecl main(int argc, char* argv[]) for (int i = 0; i < 1000000; i++) { - Object * pBefore = ((My *)ObjectFromHandle(oh))->m_pOther1; + Object * pBefore = ((My *)HndFetchHandle(oh))->m_pOther1; // Allocate more instances of the same object Object * p = AllocateObject(pMyMethodTable); if (p == NULL) return -1; - Object * pAfter = ((My *)ObjectFromHandle(oh))->m_pOther1; + Object * pAfter = ((My *)HndFetchHandle(oh))->m_pOther1; // Uncomment this assert to see how GC triggered inside AllocateObject moved objects around // assert(pBefore == pAfter); // Store the newly allocated object into a field using WriteBarrier - WriteBarrier(&(((My *)ObjectFromHandle(oh))->m_pOther1), p); + WriteBarrier(&(((My *)HndFetchHandle(oh))->m_pOther1), p); } // Create weak handle that points to our object - OBJECTHANDLE ohWeak = CreateGlobalWeakHandle(ObjectFromHandle(oh)); + OBJECTHANDLE ohWeak = CreateGlobalWeakHandle(HndFetchHandle(oh)); if (ohWeak == NULL) return -1; @@ -235,7 +235,7 @@ int __cdecl main(int argc, char* argv[]) pGCHeap->GarbageCollect(); // Verify that the weak handle got cleared by the GC - assert(ObjectFromHandle(ohWeak) == NULL); + assert(HndFetchHandle(ohWeak) == NULL); printf("Done\n"); |