From 55cf8ff0278f33a4b1a71b018ce549f63c173fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 25 Jan 2021 09:58:19 +0100 Subject: [PATCH 1/3] Add test coverage for SzArray constructors I couldn't find a single occurence of `[]::` in the test tree, so I assume we don't have any coverage for this. Arrays are normally allocated with the dedicated `newarr` IL instruction. The ECMA-335 specification says "All zero-based, one-dimensional arrays are created using newarr, not newobj.". Nevertheless, they do have a constructor and apparently code out there uses it. Also adding coverage for the constructor that creates a jagged array. Regression test for https://github.com/dotnet/runtimelab/issues/578. --- .../Regressions/coreclr/Runtimelab_578/arr.il | 69 +++++++++++++++++++ .../coreclr/Runtimelab_578/arr.ilproj | 10 +++ 2 files changed, 79 insertions(+) create mode 100644 src/tests/Regressions/coreclr/Runtimelab_578/arr.il create mode 100644 src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj diff --git a/src/tests/Regressions/coreclr/Runtimelab_578/arr.il b/src/tests/Regressions/coreclr/Runtimelab_578/arr.il new file mode 100644 index 00000000000000..803aa6711f8f78 --- /dev/null +++ b/src/tests/Regressions/coreclr/Runtimelab_578/arr.il @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +.assembly extern mscorlib { } +.assembly 'arr' { } + +.method static int32[] alloc() cil managed +{ + ldc.i4.8 + ldc.i4.8 + newobj instance void int32[]::.ctor(int32,int32) + ret +} + +.method static int32 negative() cil managed +{ + .try + { + call int32[] alloc() + leave bad + } + catch [mscorlib]System.MissingMethodException + { + pop + leave good + } + + good: + ldc.i4.1 + ret + + bad: + ldc.i4.0 + ret +} + +.method public static int32 main() cil managed +{ + .locals init (int32[][] a) + .entrypoint + + ldc.i4.7 + newobj instance void int32[]::.ctor(int32) + ldlen + + ldc.i4.2 + ldc.i4.3 + newobj instance void int32[][]::.ctor(int32,int32) + dup + stloc a + ldlen + ldc.i4 40 + mul // 2 * 40 = 80 + add // 7 + 80 = 87 + + ldloc a + ldc.i4.0 + ldelem int32[] + ldlen + ldc.i4.4 + mul // 3 * 4 = 12 + + add // 87 + 12 = 99 + + call int32 negative() + add // 99 + 1 = 100 + + ret +} \ No newline at end of file diff --git a/src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj b/src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj new file mode 100644 index 00000000000000..67dc1ba31ebe64 --- /dev/null +++ b/src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj @@ -0,0 +1,10 @@ + + + Exe + BuildAndRun + 0 + + + + + From b4e1352498a4a5f1260c37d6033ea75fd8c19889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 26 Jan 2021 14:03:03 +0100 Subject: [PATCH 2/3] Of course it doesn't work on Mono --- src/tests/issues.targets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index aa5a4c9ef356b2..fd32bc59b4d1c7 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -976,6 +976,9 @@ https://github.com/dotnet/runtime/issues/46174 + + https://github.com/dotnet/runtime/issues/47458 + https://github.com/dotnet/runtime/issues/43676 From 58826fe290aad2aa0b6676f16e6989b90c062a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 26 Jan 2021 19:43:06 +0100 Subject: [PATCH 3/3] Bump to pri-1 --- src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj b/src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj index 67dc1ba31ebe64..41dbc4c32b573d 100644 --- a/src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj +++ b/src/tests/Regressions/coreclr/Runtimelab_578/arr.ilproj @@ -2,7 +2,7 @@ Exe BuildAndRun - 0 + 1