Skip to content

Commit

Permalink
Added more gc test #12
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Dec 15, 2018
1 parent 3059f15 commit 1df42c3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion supported-runtime-system-features.md
Expand Up @@ -8,6 +8,6 @@ Feature | Test | Descrition
| EnumTypes | [Test [18]](tests/IL2C.Core.Test.Target/RuntimeSystems/EnumTypes) | The enum types have the underlying primitive integer types. These tests are verified the IL2C can manage enum underlying types at the boxing-unboxing conversion with narrowing-widing combinations. |
| ExceptionHandling | [Test [31]](tests/IL2C.Core.Test.Target/RuntimeSystems/ExceptionHandling) | These tests are verified the IL2C translates with simple and/or complext exception handling. |
| ExceptionThrownByCLI | [Test [33]](tests/IL2C.Core.Test.Target/RuntimeSystems/ExceptionThrownByCLI) | These tests are verified the IL2C throw some exceptions from the internal runtimes by ECMA-335 I.12.4.2.1. |
| GarbageCollection | [Test [4]](tests/IL2C.Core.Test.Target/RuntimeSystems/GarbageCollection) | These tests are verified the IL2C manages tracing the object references and collect garbages from the heap memory. |
| GarbageCollection | [Test [7]](tests/IL2C.Core.Test.Target/RuntimeSystems/GarbageCollection) | These tests are verified the IL2C manages tracing the object references and collect garbages from the heap memory. |
| TypeRelations | [Test [95]](tests/IL2C.Core.Test.Target/RuntimeSystems/TypeRelations) | CLR type system contains single-inheritance class types and multiple-implementation interface types. These tests are verified the IL2C can handle the member methods both simple instance methods and complex overriden virtual methods. |
| ValueTypes | [Test [18]](tests/IL2C.Core.Test.Target/RuntimeSystems/ValueTypes) | Value types are specialized types at the .NET type system. Because the type inherited from the System.ValueType (objref type), all method has the managed pointer at the arg0 and these instances will box and apply the pseudo vptrs. These tests are verified the IL2C can handle value types. |
Expand Up @@ -36,11 +36,28 @@ public struct ObjRefInsideObjRefInsideValueTypeType
this.Value = new ObjRefInsideObjRefType(value);
}

public struct MultipleInsideValueTypeType
{
public string Value1;
public ObjRefInsideValueTypeType Value2;
public ObjRefInsideObjRefType Value3;

public MultipleInsideValueTypeType(string value1, string value2, string value3)
{
this.Value1 = value1;
this.Value2 = new ObjRefInsideValueTypeType(value2);
this.Value3 = new ObjRefInsideObjRefType(value3);
}
}

[Description("These tests are verified the IL2C manages tracing the object references and collect garbages from the heap memory.")]
[TestCase("ABCDEF", "ObjRefInsideObjRef", IncludeTypes = new[] { typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF", "ObjRefInsideValueType", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeType) })]
[TestCase("ABCDEF", "ObjRefInsideValueTypeInsideObjRef", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeInsideObjRefType), typeof(ObjRefInsideValueTypeType) })]
[TestCase("ABCDEF", "ObjRefInsideObjRefInsideValueType", IncludeTypes = new[] { typeof(ObjRefInsideObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF1", "MultipleInsideValueType", 0, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF2", "MultipleInsideValueType", 1, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF3", "MultipleInsideValueType", 2, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
public sealed class GarbageCollection
{
[MethodImpl(MethodImplOptions.ForwardRef)]
Expand All @@ -54,5 +71,8 @@ public sealed class GarbageCollection

[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern string ObjRefInsideObjRefInsideValueType();

[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern string MultipleInsideValueType(int index);
}
}
Expand Up @@ -105,4 +105,58 @@
ldfld string IL2C.RuntimeSystems.ObjRefInsideObjRefType::Value
ret
}

.method public static string MultipleInsideValueType(int32 index) cil managed
{
.maxstack 5
.locals init (
[0] valuetype IL2C.RuntimeSystems.MultipleInsideValueTypeType
)

ldloca.s 0
ldstr "ABC"
ldstr "DEF1"
call string [mscorlib]System.String::Concat(string, string)
ldstr "ABC"
ldstr "DEF2"
call string [mscorlib]System.String::Concat(string, string)
ldstr "ABC"
ldstr "DEF3"
call string [mscorlib]System.String::Concat(string, string)
call instance void IL2C.RuntimeSystems.MultipleInsideValueTypeType::.ctor(string, string, string)

// Release concat string from the evaluation stack
ldstr "dummy1"
ldstr "dummy2"
ldstr "dummy3"
ldstr "dummy4"
pop
pop
pop
pop

call void [mscorlib]System.GC::Collect()

ldarg.0
ldc.i4.0
ceq
brfalse.s L1
ldloca.s 0
ldfld string IL2C.RuntimeSystems.MultipleInsideValueTypeType::Value1
ret

L1: ldarg.0
ldc.i4.1
ceq
brfalse.s L2
ldloca.s 0
ldflda valuetype IL2C.RuntimeSystems.ObjRefInsideValueTypeType IL2C.RuntimeSystems.MultipleInsideValueTypeType::Value2
ldfld string IL2C.RuntimeSystems.ObjRefInsideValueTypeType::Value
ret

L2: ldloca.s 0
ldfld class IL2C.RuntimeSystems.ObjRefInsideObjRefType IL2C.RuntimeSystems.MultipleInsideValueTypeType::Value3
ldfld string IL2C.RuntimeSystems.ObjRefInsideObjRefType::Value
ret
}
}

0 comments on commit 1df42c3

Please sign in to comment.