Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: chrome/common/mac/objc_zombie.mm

Issue 11428147: Revert 167021, info lead to bug-fix. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/common/mac/objc_zombie.h" 5 #import "chrome/common/mac/objc_zombie.h"
6 6
7 #include <AvailabilityMacros.h> 7 #include <AvailabilityMacros.h>
8 8
9 #include <execinfo.h> 9 #include <execinfo.h>
10 #import <objc/runtime.h> 10 #import <objc/runtime.h>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 Class wasa = object_getClass(self); 109 Class wasa = object_getClass(self);
110 const size_t size = class_getInstanceSize(wasa); 110 const size_t size = class_getInstanceSize(wasa);
111 111
112 // Destroy the instance by calling C++ destructors and clearing it 112 // Destroy the instance by calling C++ destructors and clearing it
113 // to something unlikely to work well if someone references it. 113 // to something unlikely to work well if someone references it.
114 // NOTE(shess): |object_dispose()| will call this again when the 114 // NOTE(shess): |object_dispose()| will call this again when the
115 // zombie falls off the treadmill! But by then |isa| will be a 115 // zombie falls off the treadmill! But by then |isa| will be a
116 // class without C++ destructors or associative references, so it 116 // class without C++ destructors or associative references, so it
117 // won't hurt anything. 117 // won't hurt anything.
118 objc_destructInstance(self); 118 objc_destructInstance(self);
119 // TODO(shess): Temporarily disable clearing the object to debug
120 // http://crbug.com/154483
121 #if 0
122 memset(self, '!', size); 119 memset(self, '!', size);
123 #endif
124 120
125 // If the instance is big enough, make it into a fat zombie and have 121 // If the instance is big enough, make it into a fat zombie and have
126 // it remember the old |isa|. Otherwise make it a regular zombie. 122 // it remember the old |isa|. Otherwise make it a regular zombie.
127 // Setting |isa| rather than using |object_setClass()| because that 123 // Setting |isa| rather than using |object_setClass()| because that
128 // function is implemented with a memory barrier. The runtime's 124 // function is implemented with a memory barrier. The runtime's
129 // |_internal_object_dispose()| (in objc-class.m) does this, so it 125 // |_internal_object_dispose()| (in objc-class.m) does this, so it
130 // should be safe (messaging free'd objects shouldn't be expected to 126 // should be safe (messaging free'd objects shouldn't be expected to
131 // be thread-safe in the first place). 127 // be thread-safe in the first place).
132 #pragma clang diagnostic push // clang warns about direct access to isa. 128 #pragma clang diagnostic push // clang warns about direct access to isa.
133 #pragma clang diagnostic ignored "-Wdeprecated-objc-isa-usage" 129 #pragma clang diagnostic ignored "-Wdeprecated-objc-isa-usage"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (oldZombies) { 428 if (oldZombies) {
433 for (size_t i = 0; i < oldCount; ++i) { 429 for (size_t i = 0; i < oldCount; ++i) {
434 if (oldZombies[i].object) 430 if (oldZombies[i].object)
435 object_dispose(oldZombies[i].object); 431 object_dispose(oldZombies[i].object);
436 } 432 }
437 free(oldZombies); 433 free(oldZombies);
438 } 434 }
439 } 435 }
440 436
441 } // namespace ObjcEvilDoers 437 } // namespace ObjcEvilDoers
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698