Permalink
Browse files

Add a CAS regalloc test.

  • Loading branch information...
1 parent 76b8500 commit 10b55da9e1e84991cae375947d089ad39ad3cb52 @vargaz vargaz committed Aug 23, 2010
Showing with 16 additions and 0 deletions.
  1. +16 −0 mono/tests/interlocked.cs
View
@@ -61,11 +61,27 @@ public class InterlockTest
Thread.MemoryBarrier ();
+ interlocked_regalloc1 ();
+
Console.WriteLine ("done!");
return 0;
}
+ public static object[] buckets;
+ public static object segmentCache;
+
+ public static int interlocked_regalloc1 () {
+ int segment = 0;
+ buckets = new object [10];
+
+ if (buckets[segment] == null) {
+ object newSegment = new Object ();
+ segmentCache = Interlocked.CompareExchange (ref buckets[segment], newSegment, null) == null ? null : newSegment;
+ }
+ return 0;
+ }
+
public static string IncTest () {
return "A" + Interlocked.Increment (ref s_test);
}

0 comments on commit 10b55da

Please sign in to comment.