From ec23ebd1c51c2cd0e72b00e1a67f9a7a41d5f46b Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Wed, 17 Mar 2021 20:50:24 +0700 Subject: [PATCH] Fix workerAutoreleasePool test on macos_arm64 using __autoreleasing Also merge `createAutorelease` and `create. There is no need in such separation since it was originally added to prevent optimization `result`'s lifetime. Turned out, it was still happening on Apple Silicon, and only addition of __autoreleasing attribute solves the problem. --- .../tests/interop/objc/tests/workerAutoreleasePool.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kotlin-native/backend.native/tests/interop/objc/tests/workerAutoreleasePool.m b/kotlin-native/backend.native/tests/interop/objc/tests/workerAutoreleasePool.m index 5fa2797d994..24de2a771ea 100644 --- a/kotlin-native/backend.native/tests/interop/objc/tests/workerAutoreleasePool.m +++ b/kotlin-native/backend.native/tests/interop/objc/tests/workerAutoreleasePool.m @@ -6,14 +6,12 @@ @implementation CreateAutorelease { CreateAutoreleaseDeallocated* deallocated; } -+(instancetype)create:(CreateAutoreleaseDeallocated*)deallocated { - CreateAutorelease* result = [self new]; - result->deallocated = deallocated; - return result; -} +(void)createAutorelease:(CreateAutoreleaseDeallocated*)deallocated { - [self create:deallocated]; + // __autoreleasing attribute prevents from early deallocation + // and thus makes test behaviour identical on Intel and ARM CPUs. + __autoreleasing CreateAutorelease* result = [self new]; + result->deallocated = deallocated; } -(void)dealloc {