diff options
author | Koundinya Veluri <kouvel@microsoft.com> | 2017-01-22 23:14:09 -0800 |
---|---|---|
committer | Koundinya Veluri <kouvel@microsoft.com> | 2017-01-25 19:56:12 -0800 |
commit | 1fd11a910fc7b2d7c5355047987cc8cff73fbae9 (patch) | |
tree | 22499950ff9b91ef0bbdf817f98264da40ecbd14 /src/vm/jitinterface.cpp | |
parent | 6f7baa9e1ec9a848c1b98a4af8d9d8c2851ef023 (diff) | |
download | coreclr-1fd11a910fc7b2d7c5355047987cc8cff73fbae9.tar.gz coreclr-1fd11a910fc7b2d7c5355047987cc8cff73fbae9.tar.bz2 coreclr-1fd11a910fc7b2d7c5355047987cc8cff73fbae9.zip |
Fix GC info for `ByReference<T>`
When `ByRefernece<T>` is directly on the stack, not inside a `Span<T>`, ComputeGCLayout was missing to include in the GC info. This was causing many span tests to fail in GCStress=c mode.
Diffstat (limited to 'src/vm/jitinterface.cpp')
-rw-r--r-- | src/vm/jitinterface.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index 0b3c9f2605..a28e7fb34b 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -2296,11 +2296,18 @@ static unsigned ComputeGCLayout(MethodTable * pMT, BYTE* gcPtrs) // TODO: TypedReference should ideally be implemented as a by-ref-like struct containing a ByReference<T> field, in which // case the check for g_TypedReferenceMT below would not be necessary - if (pMT == g_TypedReferenceMT) + if (pMT == g_TypedReferenceMT || pMT->HasSameTypeDefAs(g_pByReferenceClass)) { - gcPtrs[0] = TYPE_GC_BYREF; - gcPtrs[1] = TYPE_GC_NONE; - return 1; + if (gcPtrs[0] == TYPE_GC_NONE) + { + gcPtrs[0] = TYPE_GC_BYREF; + result++; + } + else if (gcPtrs[0] != TYPE_GC_BYREF) + { + COMPlusThrowHR(COR_E_BADIMAGEFORMAT); + } + return result; } ApproxFieldDescIterator fieldIterator(pMT, ApproxFieldDescIterator::INSTANCE_FIELDS); @@ -2326,22 +2333,7 @@ static unsigned ComputeGCLayout(MethodTable * pMT, BYTE* gcPtrs) else { MethodTable * pFieldMT = pFD->GetApproxFieldTypeHandleThrowing().AsMethodTable(); - if (pFieldMT->HasSameTypeDefAs(g_pByReferenceClass)) - { - if (gcPtrs[fieldStartIndex] == TYPE_GC_NONE) - { - gcPtrs[fieldStartIndex] = TYPE_GC_BYREF; - result++; - } - else if (gcPtrs[fieldStartIndex] != TYPE_GC_BYREF) - { - COMPlusThrowHR(COR_E_BADIMAGEFORMAT); - } - } - else - { - result += ComputeGCLayout(pFieldMT, gcPtrs + fieldStartIndex); - } + result += ComputeGCLayout(pFieldMT, gcPtrs + fieldStartIndex); } } return result; |