diff options
author | Jan Kotas <jkotas@microsoft.com> | 2019-06-18 14:17:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-18 14:17:18 -0700 |
commit | 20b4bdd1fe553b8751a2a908cc748b0346808023 (patch) | |
tree | 843089888071535b6222af15d631304374192ce2 | |
parent | 342327afd528c9e5d199a78e84793cbd916aadfd (diff) | |
download | coreclr-20b4bdd1fe553b8751a2a908cc748b0346808023.tar.gz coreclr-20b4bdd1fe553b8751a2a908cc748b0346808023.tar.bz2 coreclr-20b4bdd1fe553b8751a2a908cc748b0346808023.zip |
Relax signed/unsigned checks in Array.Copy to match other places (#25209)
Disable failing tests. Also enable tests for changes that propagated through the system.
Fixes dotnet/corefx#38535
-rw-r--r-- | src/classlibnative/bcltype/arraynative.cpp | 3 | ||||
-rw-r--r-- | src/vm/array.cpp | 42 | ||||
-rw-r--r-- | src/vm/array.h | 4 | ||||
-rw-r--r-- | src/vm/typedesc.cpp | 17 | ||||
-rw-r--r-- | tests/CoreFX/CoreFX.issues.rsp | 30 |
5 files changed, 37 insertions, 59 deletions
diff --git a/src/classlibnative/bcltype/arraynative.cpp b/src/classlibnative/bcltype/arraynative.cpp index 605cd2905b..3d2d5b2e3d 100644 --- a/src/classlibnative/bcltype/arraynative.cpp +++ b/src/classlibnative/bcltype/arraynative.cpp @@ -332,8 +332,9 @@ ArrayNative::AssignArrayEnum ArrayNative::CanAssignArrayTypeNoGC(const BASEARRAY // Copying primitives from one type to another if (CorTypeInfo::IsPrimitiveType_NoThrow(srcElType) && CorTypeInfo::IsPrimitiveType_NoThrow(destElType)) { - if (srcElType == destElType) + if (GetNormalizedIntegralArrayElementType(srcElType) == GetNormalizedIntegralArrayElementType(destElType)) return AssignWillWork; + if (InvokeUtil::CanPrimitiveWiden(destElType, srcElType)) return AssignPrimitiveWiden; else diff --git a/src/vm/array.cpp b/src/vm/array.cpp index 2c0c936d94..5f585e73e7 100644 --- a/src/vm/array.cpp +++ b/src/vm/array.cpp @@ -32,15 +32,9 @@ #include "typestring.h" #include "sigbuilder.h" -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4244) -#endif // _MSC_VER - #define MAX_SIZE_FOR_VALUECLASS_IN_ARRAY 0xffff #define MAX_PTRS_FOR_VALUECLASSS_IN_ARRAY 0xffff - /*****************************************************************************************/ LPCUTF8 ArrayMethodDesc::GetMethodName() { @@ -430,12 +424,12 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy pClass->SetMethodTable (pMT); // Fill In the method table - pClass->SetNumMethods(numVirtuals + numNonVirtualSlots); + pClass->SetNumMethods(static_cast<WORD>(numVirtuals + numNonVirtualSlots)); - pClass->SetNumNonVirtualSlots(numNonVirtualSlots); + pClass->SetNumNonVirtualSlots(static_cast<WORD>(numNonVirtualSlots)); } - pMT->SetNumVirtuals(numVirtuals); + pMT->SetNumVirtuals(static_cast<WORD>(numVirtuals)); pMT->SetParentMethodTable(pParentClass); @@ -741,7 +735,7 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy CGCDesc::GetCGCDescFromMT(pMT)->InitValueClassSeries(pMT, 1); pSeries = CGCDesc::GetCGCDescFromMT(pMT)->GetHighestSeries(); pSeries->SetSeriesOffset(ArrayBase::GetDataPtrOffset(pMT)); - pSeries->val_serie[0].set_val_serie_item (0, pMT->GetComponentSize()); + pSeries->val_serie[0].set_val_serie_item (0, static_cast<HALF_SIZE_T>(pMT->GetComponentSize())); } #endif @@ -1409,7 +1403,27 @@ MethodDesc* GetActualImplementationForArrayGenericIListOrIReadOnlyListMethod(Met } #endif // DACCESS_COMPILE -#ifdef _MSC_VER -#pragma warning(pop) -#pragma warning(disable:4244) -#endif // _MSC_VER: warning C4244 +CorElementType GetNormalizedIntegralArrayElementType(CorElementType elementType) +{ + LIMITED_METHOD_CONTRACT; + + _ASSERTE(CorTypeInfo::IsPrimitiveType_NoThrow(elementType)); + + // Array Primitive types such as E_T_I4 and E_T_U4 are interchangeable + // Enums with interchangeable underlying types are interchangable + // BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2 + + switch (elementType) + { + case ELEMENT_TYPE_U1: + case ELEMENT_TYPE_U2: + case ELEMENT_TYPE_U4: + case ELEMENT_TYPE_U8: + case ELEMENT_TYPE_U: + return (CorElementType)(elementType - 1); // normalize to signed type + default: + break; + } + + return elementType; +} diff --git a/src/vm/array.h b/src/vm/array.h index ed064c5d7f..35b927ee41 100644 --- a/src/vm/array.h +++ b/src/vm/array.h @@ -106,8 +106,8 @@ Stub *GenerateArrayOpStub(ArrayMethodDesc* pMD); BOOL IsImplicitInterfaceOfSZArray(MethodTable *pIntfMT); BOOL ArraySupportsBizarreInterface(ArrayTypeDesc *pArrayTypeDesc, MethodTable *pInterfaceMT); - MethodDesc* GetActualImplementationForArrayGenericIListOrIReadOnlyListMethod(MethodDesc *pItfcMeth, TypeHandle theT); -#endif// _ARRAY_H_ +CorElementType GetNormalizedIntegralArrayElementType(CorElementType elementType); +#endif// _ARRAY_H_ diff --git a/src/vm/typedesc.cpp b/src/vm/typedesc.cpp index a19551cea1..74be17ad05 100644 --- a/src/vm/typedesc.cpp +++ b/src/vm/typedesc.cpp @@ -505,23 +505,8 @@ BOOL TypeDesc::CanCastParam(TypeHandle fromParam, TypeHandle toParam, TypeHandle CorElementType toParamCorType = toParam.GetVerifierCorElementType(); if(CorTypeInfo::IsPrimitiveType(toParamCorType)) { - if (toParamCorType == fromParamCorType) + if (GetNormalizedIntegralArrayElementType(toParamCorType) == GetNormalizedIntegralArrayElementType(fromParamCorType)) return TRUE; - - // Primitive types such as E_T_I4 and E_T_U4 are interchangeable - // Enums with interchangeable underlying types are interchangable - // BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2 - if((toParamCorType != ELEMENT_TYPE_BOOLEAN) - &&(fromParamCorType != ELEMENT_TYPE_BOOLEAN) - &&(toParamCorType != ELEMENT_TYPE_CHAR) - &&(fromParamCorType != ELEMENT_TYPE_CHAR)) - { - if ((CorTypeInfo::Size(toParamCorType) == CorTypeInfo::Size(fromParamCorType)) - && (CorTypeInfo::IsFloat(toParamCorType) == CorTypeInfo::IsFloat(fromParamCorType))) - { - return TRUE; - } - } } // end if(CorTypeInfo::IsPrimitiveType(toParamCorType)) } // end if(CorTypeInfo::IsPrimitiveType(fromParamCorType)) diff --git a/tests/CoreFX/CoreFX.issues.rsp b/tests/CoreFX/CoreFX.issues.rsp index 25fe581002..8a35ea39f6 100644 --- a/tests/CoreFX/CoreFX.issues.rsp +++ b/tests/CoreFX/CoreFX.issues.rsp @@ -41,37 +41,15 @@ -nonamespace System.ComponentModel.TypeConverterTests -nonamespace Tests.Integration -# https://github.com/dotnet/coreclr/pull/24604 +# https://github.com/dotnet/corefx/issues/37886 -nomethod System.Security.Cryptography.Rsa.Tests.RSAXml.FromNonsenseXml -# Temporarily disabled tests waiting for CoreCLR/CoreFX changes to propagate --nomethod System.Tests.AppDomainTests.MonitoringIsEnabled --nomethod System.Tests.AppDomainTests.MonitoringSurvivedMemorySize --nomethod System.Tests.AppDomainTests.MonitoringSurvivedProcessMemorySize --nomethod System.Tests.AppDomainTests.MonitoringTotalAllocatedMemorySize --nomethod System.Tests.AppDomainTests.MonitoringTotalProcessorTime --nomethod System.Text.Tests.StringBuilderTests.AppendFormat +# requires corefx test updates -nomethod System.Diagnostics.Tests.DebugTestsNoListeners.Print -nomethod System.Diagnostics.Tests.DebugTestsUsingListeners.Print +-nomethod System.Tests.ArrayTests.Copy_SourceAndDestinationNeverConvertible_ThrowsArrayTypeMismatchException -# requires corefx test updates --nomethod System.Tests.EnvironmentTests.FailFast_ExceptionStackTrace_StackOverflowException --nomethod System.Tests.EnvironmentTests.FailFast_ExceptionStackTrace_InnerException --nomethod System.Tests.EnvironmentTests.FailFast_ExceptionStackTrace_ArgumentException - -# requires corefx test updates: https://github.com/dotnet/corefx/pull/38269 --nomethod System.Reflection.Emit.Tests.DynamicMethodctor1.String_Type_TypeArray_Module --nomethod System.Reflection.Emit.Tests.DynamicMethodctor1.String_Type_TypeArray_Type --nomethod System.Reflection.Emit.Tests.MethodBuilderGetGenericArguments.GetGenericArguments_NonGenericMethod_ReturnsNull --nomethod System.Reflection.Emit.Tests.MethodBuilderSetReturnType.SetReturnType_NullReturnType_ReturnsVoid --nomethod System.Reflection.Emit.Tests.MethodBuilderSetSignature.SetSignature_AllParametersNull --nomethod System.Reflection.Emit.Tests.MethodBuilderSetSignature.SetSignature_NullReturnType_CustomModifiersSetToWrongTypes --nomethod System.Reflection.Emit.Tests.TypeBuilderDefineMethodTests.DefineMethod --nomethod System.Tests.StringTests.CasingNegativeTest --nomethod System.Tests.StringTests.CompareNegativeTest --nomethod System.Tests.StringTests.ToLowerNullCulture --nomethod System.Tests.StringTests.ToUpperNullCulture - +# # # Temporarily disable tests while bringing more CoreFX job configurations online. # |