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.
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);