From ad3c0f1de336eef69795f1228101cd0486ec0a4c Mon Sep 17 00:00:00 2001 From: "shess@chromium.org" Date: Thu, 3 Jun 2010 19:56:43 +0000 Subject: [Mac] Tighten up objc zombie dealloc implementation. Enabling the zombie code in release causes Perf(2) to regress. Reviewing |ZombieDealloc()|, I notice that object_setClass() is implemented with a memory barrier. The objc runtime doesn't use it in deallocation, so move to direct access. BUG=none TEST=none Review URL: http://codereview.chromium.org/2605004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48857 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/objc_zombie.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/cocoa/objc_zombie.mm b/chrome/browser/cocoa/objc_zombie.mm index a9d9063..9a7c963 100644 --- a/chrome/browser/cocoa/objc_zombie.mm +++ b/chrome/browser/cocoa/objc_zombie.mm @@ -144,12 +144,17 @@ void ZombieDealloc(id self, SEL _cmd) { memset(self, '!', size); // If the instance is big enough, make it into a fat zombie and have - // it remember the old isa. Otherwise make it a regular zombie. + // it remember the old |isa|. Otherwise make it a regular zombie. + // Setting |isa| rather than using |object_setClass()| because that + // function is implemented with a memory barrier. The runtime's + // |_internal_object_dispose()| (in objc-class.m) does this, so it + // should be safe (messaging free'd objects shouldn't be expected to + // be thread-safe in the first place). if (size >= g_fatZombieSize) { - object_setClass(self, g_fatZombieClass); + self->isa = g_fatZombieClass; static_cast(self)->wasa = wasa; } else { - object_setClass(self, g_zombieClass); + self->isa = g_zombieClass; } // The new record to swap into |g_zombies|. If |g_zombieCount| is -- cgit v1.1