Bug 925016: Always use method_exchangeImplementations when swizzling methods on OS X. r=smichaud
authorJosh Aas <joshmoz@gmail.com>
Fri, 11 Oct 2013 13:58:35 -0500
changeset 164350 5dc3c476f55ef746d66d5e0d273961753cc5a82d
parent 164349 eb0f1d1bd9ca4ed2cf822d51c699571e350f6b41
child 164351 5397cf44cbca5fc0e28ecbd4cabc39e4cb613cbb
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs925016
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 925016: Always use method_exchangeImplementations when swizzling methods on OS X. r=smichaud
widget/cocoa/nsToolkit.mm
--- a/widget/cocoa/nsToolkit.mm
+++ b/widget/cocoa/nsToolkit.mm
@@ -285,20 +285,17 @@ nsToolkit* nsToolkit::GetToolkit()
 }
 
 // An alternative to [NSObject poseAsClass:] that isn't deprecated on OS X
 // Leopard and is available to 64-bit binaries on Leopard and above.  Based on
 // ideas and code from http://www.cocoadev.com/index.pl?MethodSwizzling.
 // Since the Method type becomes an opaque type as of Objective-C 2.0, we'll
 // have to switch to using accessor methods like method_exchangeImplementations()
 // when we build 64-bit binaries that use Objective-C 2.0 (on and for Leopard
-// and above).  But these accessor methods aren't available in Objective-C 1
-// (or on Tiger).  So we need to access Method's members directly for (Tiger-
-// capable) binaries (32-bit or 64-bit) that use Objective-C 1 (as long as we
-// keep supporting Tiger).
+// and above).
 //
 // Be aware that, if aClass doesn't have an orgMethod selector but one of its
 // superclasses does, the method substitution will (in effect) take place in
 // that superclass (rather than in aClass itself).  The substitution has
 // effect on the class where it takes place and all of that class's
 // subclasses.  In order for method swizzling to work properly, posedMethod
 // needs to be unique in the class where the substitution takes place and all
 // of its subclasses.
@@ -316,20 +313,14 @@ nsresult nsToolkit::SwizzleMethods(Class
   } else {
     original = class_getInstanceMethod(aClass, orgMethod);
     posed = class_getInstanceMethod(aClass, posedMethod);
   }
 
   if (!original || !posed)
     return NS_ERROR_FAILURE;
 
-#ifdef __LP64__
   method_exchangeImplementations(original, posed);
-#else
-  IMP aMethodImp = original->method_imp;
-  original->method_imp = posed->method_imp;
-  posed->method_imp = aMethodImp;
-#endif
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }