Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Urban-Forster <lewurm@gmail.com>2020-04-29 11:58:13 +0300
committerBernhard Urban-Forster <lewurm@gmail.com>2020-04-29 11:58:13 +0300
commit5fed14e09b3064c102ab80d19c148a08e522ff57 (patch)
treed6959e69a839a41c368867f88ace18dfd2084a8e
parent37a588097e075f86918dcfc50d86d56fb595ae2f (diff)
[enc] add OnStackMethodThread
-rw-r--r--mono/tests/enc/Makefile.am1
-rw-r--r--mono/tests/enc/OnStackMethodThread.cs55
-rw-r--r--mono/tests/enc/OnStackMethodThread_v1.cs52
3 files changed, 108 insertions, 0 deletions
diff --git a/mono/tests/enc/Makefile.am b/mono/tests/enc/Makefile.am
index 4df272a348f..35ffdadbbe9 100644
--- a/mono/tests/enc/Makefile.am
+++ b/mono/tests/enc/Makefile.am
@@ -13,6 +13,7 @@ TESTS_REGULAR := \
CallExisting.dll \
LambdaFunc.dll \
OnStackMethod.dll \
+ OnStackMethodThread.dll \
ReplaceMethod.dll \
ReplaceMethodOften.dll \
ReplacePrivateVirtualMethod.dll \
diff --git a/mono/tests/enc/OnStackMethodThread.cs b/mono/tests/enc/OnStackMethodThread.cs
new file mode 100644
index 00000000000..ea6bd45cfc4
--- /dev/null
+++ b/mono/tests/enc/OnStackMethodThread.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using MonoEnc;
+
+public class OnStackMethod {
+ public static EncHelper replacer = null;
+ public static Assembly assm = null;
+ public static int state = 0;
+
+ public static int Main (string []args) {
+ assm = typeof (OnStackMethod).Assembly;
+ replacer = EncHelper.Make ();
+
+ int res = DiffTestMethod1 ();
+ if (res != 1)
+ return 1;
+
+ res = DiffTestMethod1 ();
+ if (res != 2)
+ return 2;
+
+ return 0;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static int DiffTestMethod1 () {
+ Console.WriteLine ("Hello old World");
+ DoTheUpdate ();
+ Console.WriteLine ("Hello old World #2");
+ Console.WriteLine ("Hello old World #3");
+ return 1;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void Wrapper () {
+ int ret = DiffTestMethod1 ();
+ if (ret != 2)
+ Environment.Exit (5);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void DoTheUpdate () {
+ if (state == 0) {
+ replacer.Update (assm);
+ state++;
+
+ Thread thread = new Thread(new ThreadStart(Wrapper));
+ thread.Start();
+ thread.Join ();
+ }
+ }
+}
+
diff --git a/mono/tests/enc/OnStackMethodThread_v1.cs b/mono/tests/enc/OnStackMethodThread_v1.cs
new file mode 100644
index 00000000000..6db05b25762
--- /dev/null
+++ b/mono/tests/enc/OnStackMethodThread_v1.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using MonoEnc;
+
+public class OnStackMethod {
+ public static EncHelper replacer = null;
+ public static Assembly assm = null;
+ public static int state = 0;
+
+ public static int Main (string []args) {
+ assm = typeof (OnStackMethod).Assembly;
+ replacer = EncHelper.Make ();
+
+ int res = DiffTestMethod1 ();
+ if (res != 1)
+ return 1;
+
+ res = DiffTestMethod1 ();
+ if (res != 2)
+ return 2;
+
+ return 0;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static int DiffTestMethod1 () {
+ Console.WriteLine ("Hello NEW World");
+ return 2;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void Wrapper () {
+ int ret = DiffTestMethod1 ();
+ if (ret != 2)
+ Environment.Exit (5);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void DoTheUpdate () {
+ if (state == 0) {
+ replacer.Update (assm);
+ state++;
+
+ Thread thread = new Thread(new ThreadStart(Wrapper));
+ thread.Start();
+ thread.Join ();
+ }
+ }
+}
+