1 // TEST_CFLAGS -framework Foundation
2 // TEST_CONFIG MEM=mrc ARCH=x86_64
4 // Stress-test nonpointer isa's side table retain count transfers.
6 // x86_64 only. arm64's side table limit is high enough that bugs
7 // are harder to reproduce.
10 #import <Foundation/Foundation.h>
16 # define RC_HALF (1ULL<<7)
20 #define RC_DELTA RC_HALF
22 static bool Deallocated = false;
23 @interface Deallocator : NSObject @end
24 @implementation Deallocator
31 // This is global to avoid extra retains by the dispatch block objects.
32 static Deallocator *obj;
35 dispatch_queue_t queue =
36 dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
38 for (size_t i = 0; i < OBJECTS; i++) {
39 obj = [Deallocator new];
41 dispatch_apply(THREADS, queue, ^(size_t i __unused) {
42 for (size_t a = 0; a < LOOPS; a++) {
43 for (size_t b = 0; b < RC_DELTA; b++) {
46 for (size_t b = 0; b < RC_DELTA; b++) {
52 testassert(!Deallocated);
54 testassert(Deallocated);