diff options
author | Morgan Brown <morganbr@users.noreply.github.com> | 2018-01-31 14:15:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-31 14:15:19 +0300 |
commit | 6bc23d91d55aa887998af7835970828c6d809ab5 (patch) | |
tree | ec0ad286677b55e1b08cca1ad8514a58e93858c7 /tests | |
parent | 32aa2c248cdddc20f76a81d627102e5dabfce2a2 (diff) |
Implement localloc for WebAssembly (#5298)
* Implements localloc and fixes other issues required to make Int32.ToString work (which relies on stack allocation, Spans and various value type special cases). Includes:
* Allocating localloc buffers on the C++ stack since they're guaranteed not to have GC references and LLVM might be able to optimize them a bit better
* Handling newobj for value types by allocating them in a spill slot
* Implementing the ByReference.get_Value intrinsic
* Fixing various shadow stack management bugs around calls. In particular, return values are now spilled to avoid the next call overwriting them.
* A few new tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/Simple/HelloWasm/Program.cs | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/tests/src/Simple/HelloWasm/Program.cs b/tests/src/Simple/HelloWasm/Program.cs index e3b16f9a2..66080a425 100644 --- a/tests/src/Simple/HelloWasm/Program.cs +++ b/tests/src/Simple/HelloWasm/Program.cs @@ -62,6 +62,18 @@ internal static class Program var boxedStruct = (object)new BoxStubTest { Value = "Boxed Stub Test: Ok." }; PrintLine(boxedStruct.ToString()); + int subResult = tempInt - 1; + if (subResult == 8) + { + PrintLine("Subtraction Test: Ok."); + } + + int divResult = tempInt / 3; + if (divResult == 3) + { + PrintLine("Division Test: Ok."); + } + var not = Not(0xFFFFFFFF) == 0x00000000; if (not) { @@ -159,12 +171,21 @@ internal static class Program PrintLine("Small array load/store test: Ok."); } + IntPtr returnedIntPtr = NewobjValueType(); + if (returnedIntPtr.ToInt32() == 3) + { + PrintLine("Newobj value type test: Ok."); + } + + StackallocTest(); + + IntToStringTest(); + PrintLine("Done"); } private static int StaticDelegateTarget() - { - + { return 7; } @@ -235,6 +256,30 @@ internal static class Program } } + private static IntPtr NewobjValueType() + { + return new IntPtr(3); + } + + private unsafe static void StackallocTest() + { + int* intSpan = stackalloc int[2]; + intSpan[0] = 3; + intSpan[1] = 7; + + if (intSpan[0] == 3 && intSpan[1] == 7) + { + PrintLine("Stackalloc test: Ok."); + } + } + + private static void IntToStringTest() + { + PrintLine("Int to String Test: Ok if next line says 42."); + string intString = 42.ToString(); + PrintLine(intString); + } + [DllImport("*")] private static unsafe extern int printf(byte* str, byte* unused); } |