briantkelley / apple-rs

Idiomatic Rust bindings for iOS and macOS system libraries and frameworks.
Apache License 2.0
7 stars 0 forks source link

Support for objc_retainAutoreleasedReturnValue() #3

Open briantkelley opened 2 years ago

briantkelley commented 2 years ago

The Objective-C runtime has return value optimizations for callers that execute specific instruction sequences upon return of the callee. Without these optimizations, the runtime performs retain/autorelease operations on the object, which incur a performance penalty.

briantkelley commented 1 year ago

This is implemented in clang using the operand bundle clang.arc.attachedcall. Quick testing with inline assembly seemed to indicate the magic nop is persisted through release optimizations on arm64, but additional testing and x86_64 investigation is still required.