[Tizen] Revert "Pass zero length array as null" https://github.com/dotnet/coreclr...
authorGleb Balykov <g.balykov@samsung.com>
Wed, 2 Mar 2022 19:37:30 +0000 (22:37 +0300)
committer이형주/Common Platform Lab(SR)/삼성전자 <leee.lee@samsung.com>
Thu, 17 Mar 2022 21:18:44 +0000 (06:18 +0900)
Without this revert two coreclr tests fail if they are compiled with inputbubble and IL_STUB saving in ni:
- Interop/PInvoke/Array/MarshalArrayAsParam/AsDefault/AsDefaultTest/AsDefaultTest.sh
- Interop/PInvoke/Array/MarshalArrayAsParam/AsLPArray/AsLPArrayTest/AsLPArrayTest.sh

For both tests problem is exactly with array with 0 length, which is passed as NULL to native function.
But it should be a pointer to the non-existing element, and IL_STUB generated at runtime does exactly this.

src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs

index 404f655..e34fd17 100644 (file)
@@ -1375,11 +1375,6 @@ namespace Internal.TypeSystem.Interop
                 ILLocalVariable vPinnedFirstElement = emitter.NewLocal(ManagedElementType.MakeByRefType(), true);
 
                 LoadManagedValue(codeStream);
-                codeStream.Emit(ILOpcode.ldlen);
-                codeStream.Emit(ILOpcode.conv_i4);
-                codeStream.Emit(ILOpcode.brfalse, lNullArray);
-
-                LoadManagedValue(codeStream);
                 codeStream.Emit(ILOpcode.call, emitter.NewToken(getArrayDataReferenceMethod));
                 codeStream.EmitStLoc(vPinnedFirstElement);