{"id":8853,"date":"2014-05-21T15:33:18","date_gmt":"2014-05-21T19:33:18","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=8853"},"modified":"2016-03-08T09:47:22","modified_gmt":"2016-03-08T14:47:22","slug":"why-objc_autoreleasereturnvalue-differs-for-x86_64-and-arm","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/05\/21\/why-objc_autoreleasereturnvalue-differs-for-x86_64-and-arm\/","title":{"rendered":"Why objc_autoreleaseReturnValue Differs for x86_64 and ARM"},"content":{"rendered":"<p><a href=\"http:\/\/stackoverflow.com\/questions\/23764271\/why-the-implementation-of-arcs-objc-autoreleasereturnvalue-differs-for-x86-64-a\/\">duhanebel<\/a>:<\/p>\r\n<blockquote cite=\"http:\/\/stackoverflow.com\/questions\/23764271\/why-the-implementation-of-arcs-objc-autoreleasereturnvalue-differs-for-x86-64-a\/\"><p>The implementation for x86_64 on NSObject.mm is quite straightforward. The code analyses the assembler located after the return address of <code>objc_autoreleaseReturnValue<\/code> for the presence of a call to <code>objc_retainAutoreleasedReturnValue<\/code>.<\/p>\r\n<\/blockquote>\r\n<p>But for ARM:<\/p>\r\n<blockquote cite=\"http:\/\/stackoverflow.com\/questions\/23764271\/why-the-implementation-of-arcs-objc-autoreleasereturnvalue-differs-for-x86-64-a\/\"><p>It looks like the code is identifying the presence of <code>objc_retainAutoreleasedReturnValue<\/code> not by looking up the presence of a call to that specific function, but by looking instead for a special no-op operation <code>mov r7, r7<\/code>.<\/p>\r\n<\/blockquote>\r\n<p><a href=\"http:\/\/stackoverflow.com\/a\/23765612\/6311\">Bill Bumgarner<\/a>:<\/p>\r\n<blockquote cite=\"http:\/\/stackoverflow.com\/a\/23765612\/6311\"><p>ARM&rsquo;s addressing modes don&rsquo;t really allow for direct addressing across the full address space. The instructions used to do addressing -- loads, stores, etc&#8230; -- don&rsquo;t support direct access to the full address space as they are limited in bit width.<\/p><\/blockquote>\r\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/23764271\/why-the-implementation-of-arcs-objc-autoreleasereturnvalue-differs-for-x86-64-a\/#comment36546874_23765612\">Greg Parker<\/a>:<\/p>\r\n<blockquote cite=\"http:\/\/stackoverflow.com\/questions\/23764271\/why-the-implementation-of-arcs-objc-autoreleasereturnvalue-differs-for-x86-64-a\/#comment36546874_23765612\"><p>A resolved dyld stub is simple on Intel: it&rsquo;s just a branch to a branch. On ARM the instruction sequences for the branch to the stub and the branch from the stub can take many different forms depending on how long the branches are. Checking for each combination would be slow.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>duhanebel: The implementation for x86_64 on NSObject.mm is quite straightforward. The code analyses the assembler located after the return address of objc_autoreleaseReturnValue for the presence of a call to objc_retainAutoreleasedReturnValue. But for ARM: It looks like the code is identifying the presence of objc_retainAutoreleasedReturnValue not by looking up the presence of a call to that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[55,54,138,71],"class_list":["post-8853","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-arc","tag-objective-c","tag-optimization","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=8853"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8853\/revisions"}],"predecessor-version":[{"id":13789,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8853\/revisions\/13789"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=8853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=8853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=8853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}