Fix R2R failure in one of ObjectStackAllocation tests.
authorEugene Rozenfeld <erozen@microsoft.com>
Sat, 19 Jan 2019 00:15:32 +0000 (16:15 -0800)
committerEugene Rozenfeld <erozen@microsoft.com>
Wed, 23 Jan 2019 19:32:56 +0000 (11:32 -0800)
AllocateSimpleClassAndCheckTypeNoHelper fails because
the object is allocated on the heap in R2R mode. The reason for that is
that we always use a helper for isinst in R2R mode and helper calls
cause us to assume the object escapes.

We don't have to use a helper in this case (even for R2R), #22086 tracks
fixing that.

For now the fix is not to check that the object was allocated on the stack
in this test case.

Fixes #22026.

tests/src/JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests.cs

index 7c524ba..d17a565 100644 (file)
@@ -126,14 +126,17 @@ namespace ObjectStackAllocation
 
             CallTestAndVerifyAllocation(AllocateClassWithNestedStructAndAddFields, 24, expectedAllocationKind);
 
-            CallTestAndVerifyAllocation(AllocateSimpleClassAndCheckTypeNoHelper, 1, expectedAllocationKind);
-
             CallTestAndVerifyAllocation(AllocateSimpleClassWithGCFieldAndAddFields, 12, expectedAllocationKind);
 
             CallTestAndVerifyAllocation(AllocateSimpleClassAndAssignRefToAField, 12, expectedAllocationKind);
 
             CallTestAndVerifyAllocation(TestMixOfReportingAndWriteBarriers, 34, expectedAllocationKind);
 
+            // The object is currently allocated on the stack when this method is jitted and on the heap when it's R2R-compiled.
+            // The reason is that we always do the type check via helper in R2R mode, which blocks stack allocation.
+            // We don't have to use a helper in this case (even for R2R), https://github.com/dotnet/coreclr/issues/22086 tracks fixing that.
+            CallTestAndVerifyAllocation(AllocateSimpleClassAndCheckTypeNoHelper, 1, AllocationKind.Undefined);
+
             // The remaining tests currently never allocate on the stack
             if (expectedAllocationKind == AllocationKind.Stack) {
                 expectedAllocationKind = AllocationKind.Heap;