]> git.saurik.com Git - apple/objc4.git/commitdiff
objc4-493.11.tar.gz mac-os-x-1073 mac-os-x-1074 mac-os-x-1075 v493.11
authorApple <opensource@apple.com>
Thu, 2 Feb 2012 16:16:01 +0000 (16:16 +0000)
committerApple <opensource@apple.com>
Thu, 2 Feb 2012 16:16:01 +0000 (16:16 +0000)
runtime/objc-arr.mm
runtime/objc-os.h
runtime/objc-private.h
runtime/objc-runtime-new.mm
runtime/objc-runtime-old.m
runtime/objc-weak.mm

index 0bcd995f255a36dd9585edfc828770bc9c4491d3..89a039ecb57e77adff8dbfba10d871b462af95a6 100644 (file)
@@ -130,6 +130,19 @@ public:
             new (&table_buf[i * SIDE_TABLE_SIZE]) SideTable;
         }
     }
             new (&table_buf[i * SIDE_TABLE_SIZE]) SideTable;
         }
     }
+    
+    static bool noLocksHeld(void) {
+        bool gotAll = true;
+        for (int i = 0; i < SIDE_TABLE_STRIPE && gotAll; i++) {
+            SideTable *s = (SideTable *)(&table_buf[i * SIDE_TABLE_SIZE]);
+            if (OSSpinLockTry(&s->slock)) {
+                OSSpinLockUnlock(&s->slock);
+            } else {
+                gotAll = false;
+            }
+        }
+        return gotAll;
+    }
 };
 
 STATIC_ASSERT(sizeof(SideTable) <= SIDE_TABLE_SIZE);
 };
 
 STATIC_ASSERT(sizeof(SideTable) <= SIDE_TABLE_SIZE);
@@ -142,6 +155,10 @@ SideTable::table_buf[SIDE_TABLE_STRIPE * SIDE_TABLE_SIZE];
 // anonymous namespace
 };
 
 // anonymous namespace
 };
 
+bool noSideTableLocksHeld(void)
+{
+    return SideTable::noLocksHeld();
+}
 
 //
 // The -fobjc-arr flag causes the compiler to issue calls to objc_{retain/release/autorelease/retain_block}
 
 //
 // The -fobjc-arr flag causes the compiler to issue calls to objc_{retain/release/autorelease/retain_block}
index f6b2bf64e9f2c49bfcf475b4455f8abe3384e1bc..58667992e6e822bb778a34be92f4f3ea33963844 100644 (file)
@@ -599,7 +599,7 @@ typedef pthread_mutex_t mutex_t;
 extern int DebuggerMode;
 extern void gdb_objc_debuggerModeFailure(void);
 extern BOOL isManagedDuringDebugger(void *lock);
 extern int DebuggerMode;
 extern void gdb_objc_debuggerModeFailure(void);
 extern BOOL isManagedDuringDebugger(void *lock);
-extern BOOL isLockedDuringDebugger(mutex_t *lock);
+extern BOOL isLockedDuringDebugger(void *lock);
 
 static inline int _mutex_lock_nodebug(mutex_t *m) { 
     if (DebuggerMode  &&  isManagedDuringDebugger(m)) {
 
 static inline int _mutex_lock_nodebug(mutex_t *m) { 
     if (DebuggerMode  &&  isManagedDuringDebugger(m)) {
index 837d4e1f4c0ffea1f2797ed7f16fc88a0c4d18b0..36f49ce2578e5723b0b5f139d8c315b77dd1489e 100644 (file)
@@ -359,6 +359,8 @@ extern void _rwlock_assert_unlocked_debug(rwlock_t *l, const char *name);
 
 #endif
 
 
 #endif
 
+extern bool noSideTableLocksHeld(void);
+
 #define rwlock_unlock(m, s)                           \
     do {                                              \
         if ((s) == RDONLY) rwlock_unlock_read(m);     \
 #define rwlock_unlock(m, s)                           \
     do {                                              \
         if ((s) == RDONLY) rwlock_unlock_read(m);     \
index 296df91aef36ef38afebc3c5db69612f8603a751..abf133c82d552383de9c786da48cbf9a75b1f1a1 100644 (file)
@@ -122,6 +122,14 @@ PRIVATE_EXTERN int startDebuggerMode(void)
         return DEBUGGER_OFF;
     }
 
         return DEBUGGER_OFF;
     }
 
+    // side table locks are not optional
+    if (!noSideTableLocksHeld()) {
+        rwlock_unlock(&runtimeLock, debugger_runtimeLock);
+        mutex_unlock(&cacheUpdateLock);
+        debugger_runtimeLock = 0;
+        return DEBUGGER_OFF;
+    }
+    
     // selLock is optional
     if (rwlock_try_write(&selLock)) {
         debugger_selLock = RDWR;
     // selLock is optional
     if (rwlock_try_write(&selLock)) {
         debugger_selLock = RDWR;
@@ -188,7 +196,7 @@ PRIVATE_EXTERN BOOL isManagedDuringDebugger(void *lock)
 * Locking a managed mutex during debugger mode causes a trap unless 
 *   this returns YES.
 **********************************************************************/
 * Locking a managed mutex during debugger mode causes a trap unless 
 *   this returns YES.
 **********************************************************************/
-PRIVATE_EXTERN BOOL isLockedDuringDebugger(mutex_t *lock)
+PRIVATE_EXTERN BOOL isLockedDuringDebugger(void *lock)
 {
     assert(DebuggerMode);
 
 {
     assert(DebuggerMode);
 
index f0ac76d4ab9a1aff6084f72a097542d86585ae70..9d53fdcd2218e5c5ee9f69644691941e4abe9472 100644 (file)
@@ -3340,6 +3340,14 @@ PRIVATE_EXTERN int startDebuggerMode(void)
         return DEBUGGER_OFF;
     }
 
         return DEBUGGER_OFF;
     }
 
+    // side table locks are not optional because we're being conservative
+    if (!noSideTableLocksHeld()) {
+        mutex_unlock(&cacheUpdateLock);
+        mutex_unlock(&methodListLock);
+        mutex_unlock(&classLock);
+        return DEBUGGER_OFF;
+    }
+    
     // selLock is optional
     if (rwlock_try_write(&selLock)) {
         debugger_selLock = RDWR;
     // selLock is optional
     if (rwlock_try_write(&selLock)) {
         debugger_selLock = RDWR;
@@ -3400,7 +3408,7 @@ PRIVATE_EXTERN BOOL isManagedDuringDebugger(void *lock)
 * Locking a managed mutex during debugger mode causes a trap unless 
 *   this returns YES.
 **********************************************************************/
 * Locking a managed mutex during debugger mode causes a trap unless 
 *   this returns YES.
 **********************************************************************/
-PRIVATE_EXTERN BOOL isLockedDuringDebugger(mutex_t *lock)
+PRIVATE_EXTERN BOOL isLockedDuringDebugger(void *lock)
 {
     assert(DebuggerMode);
 
 {
     assert(DebuggerMode);
 
index 77443304c6397c0bb3daa4ac48f312ba7f1e3666..f8a34b4dfe6ae6204fbc718a206821a343b59ab2 100644 (file)
@@ -463,7 +463,7 @@ arr_clear_deallocating(weak_table_t *weak_table, id referent) {
 
 
 PRIVATE_EXTERN id weak_register_no_lock(weak_table_t *weak_table, id referent, id *referrer) {
 
 
 PRIVATE_EXTERN id weak_register_no_lock(weak_table_t *weak_table, id referent, id *referrer) {
-    if (referent) {
+    if (referent && !OBJC_IS_TAGGED_PTR(referent)) {
         // ensure that the referenced object is viable
         BOOL (*allowsWeakReference)(id, SEL) = (BOOL(*)(id, SEL))
         class_getMethodImplementation(object_getClass(referent), 
         // ensure that the referenced object is viable
         BOOL (*allowsWeakReference)(id, SEL) = (BOOL(*)(id, SEL))
         class_getMethodImplementation(object_getClass(referent), 
@@ -509,6 +509,7 @@ arr_read_weak_reference(weak_table_t *weak_table, id *referrer) {
     // find entry and mark that it needs retaining
     {
         referent = *referrer;
     // find entry and mark that it needs retaining
     {
         referent = *referrer;
+        if (OBJC_IS_TAGGED_PTR(referent)) return referent;
         weak_entry_t *entry;
         if (referent == NULL || !(entry = weak_entry_for_referent(weak_table, referent))) {
             *referrer = NULL;
         weak_entry_t *entry;
         if (referent == NULL || !(entry = weak_entry_for_referent(weak_table, referent))) {
             *referrer = NULL;