objective c - OBJC_PRINT_VTABLE_IMAGES and OBJC_PRINT_VTABLE_SETUP does not show any output -


i've tried use objc_print_vtable_images , objc_print_vtable_setup environmental variables on objective-c executable in order learn vtable mechanism in objective-c objects. unfortunately mentioned environment variables have no effect on console output, despite fact runtime acknowledged variables set:

» objc_print_options=1 objc_print_vtable_images=yes /applications/textedit.app/contents/macos/textedit objc[41098]: objc_print_options set objc[41098]: objc_print_vtable_images set 

i've tried use both variables on executables provided system (textedit) , own. no effect.

whole vtable mechanism in objective-c objects obscure. it's hard find information mechanism on apple pages. there info other sources, no official documentation: http://www.sealiesoftware.com/blog/archive/2011/06/17/objc_explain_objc_msgsend_vtable.html http://cocoasamurai.blogspot.com/2010/01/understanding-objective-c-runtime.html

why these variables not working? vtables in current version of objective-c deprecated?

in case, answer pretty straightforward - vtable dispatch no longer optimized in objective-c runtime, , bad idea in first place.

vtable-based dispatch 1 of first attempts speed frequent calls in objective-c runtime, note predates current method caching solution. problem using fixed set of selectors in vtable solution not means increased memory every class in runtime, means if you're using architecture doesn't result in isequaltostring: being called frequently, example, have wasted pointer every class in runtime overrides 1 of selectors. whoops.

also, note vtable dispatch design couldn't work on 32-bit architectures, meant once ios sdk released, , 32bit again reasonable target objective-c, optimization couldn't work.

the relevant documentation can find in objc-abi.h:

 #if target_os_osx  &&  defined(__x86_64__) // objc_msgsend_fixup() used vtable-dispatchable call sites. objc_export void objc_msgsend_fixup(void)     __osx_deprecated(10.5, 10.8, "fixup dispatch no longer optimized")      __ios_unavailable __tvos_unavailable __watchos_unavailable; 

nowadays, there aren't many vestigial fragments of vtable dispatch left in runtime. quick grep on codebase shows few places in objc-runtime-new.mm:

 #if support_fixup     // fix old objc_msgsend_fixup call sites     (each_header) {         message_ref_t *refs = _getobjc2messagerefs(hi, &count);         if (count == 0) continue;          if (printvtables) {             _objc_inform("vtables: repairing %zu unsupported vtable dispatch "                          "call sites in %s", count, hi->fname());         }         (i = 0; < count; i++) {             fixupmessageref(refs+i);         }     }      ts.log("image times: fix objc_msgsend_fixup"); #endif 

and

 ********************************************************************* * fixupmessageref * repairs old vtable dispatch call site.  * vtable dispatch not supported. **********************************************************************/ static void  fixupmessageref(message_ref_t *msg) 

which pretty indicates it's not supported.

see also, method stub (if without compiler generated call-site), found in objc-msg-x86_64.s:

 entry _objc_msgsend_fixup int3 end_entry _objc_msgsend_fixup 

where int3 sigtrap instruction, cause crash if debugger isn't attached (usually).

so, while vtable dispatch interesting note in history of objective-c, should looked little more experiment when weren't quite familiar best ways optimize common method calls.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -