inline Class
objc_object::changeIsa(Class newCls)
{
// This is almost always true but there are
// enough edge cases that we can't assert it.
// assert(newCls->isFuture() ||
// newCls->isInitializing() || newCls->isInitialized()); assert(!isTaggedPointer()); isa_t oldisa;
isa_t newisa;+构建新对象体 isa_t bool sideTableLocked = false;
bool transcribeToSideTable = false; do {
transcribeToSideTable = false;
oldisa = LoadExclusive(&isa.bits);
if ((oldisa.bits == || oldisa.nonpointer) &&
!newCls->isFuture() && newCls->canAllocNonpointer())
{
// 0 -> nonpointer
// nonpointer -> nonpointer
#if SUPPORT_INDEXED_ISA
if (oldisa.bits == ) newisa.bits = ISA_INDEX_MAGIC_VALUE;
else newisa = oldisa;
// isa.magic is part of ISA_MAGIC_VALUE
// isa.nonpointer is part of ISA_MAGIC_VALUE
newisa.has_cxx_dtor = newCls->hasCxxDtor();
assert(newCls->classArrayIndex() > );
newisa.indexcls = (uintptr_t)newCls->classArrayIndex();
#else
        
        
if (oldisa.bits == ) newisa.bits = ISA_MAGIC_VALUE;
else newisa = oldisa;
// isa.magic is part of ISA_MAGIC_VALUE
// isa.nonpointer is part of ISA_MAGIC_VALUE
newisa.has_cxx_dtor = newCls->hasCxxDtor();
newisa.shiftcls = (uintptr_t)newCls >> ;+改变类型的指针,存储的时候清除低位没用的3位
#endif } else if (oldisa.nonpointer) { // nonpointer -> raw pointer // Need to copy retain count et al to side table. // Acquire side table lock before setting isa to // prevent races such as concurrent -release.
        +如果是TargetPoint对象,标记为需要转移其他数据
if (!sideTableLocked) sidetable_lock();
sideTableLocked = true;
transcribeToSideTable = true;
newisa.cls = newCls;
}
else {
// raw pointer -> raw pointer
newisa.cls = newCls;
}
      +上面在为新对象体转移数据
} while (!StoreExclusive(&isa.bits, oldisa.bits, newisa.bits));+将数据覆盖对象体,内部原子的比较并交换 if (transcribeToSideTable) {
// Copy oldisa's retain count et al to side table.
// oldisa.has_assoc: nothing to do
// oldisa.has_cxx_dtor: nothing to do
      +被标记为转移其他数据,转移引用计数器-1标识,转移是否正在dealloc的标识,转移所引用标识
sidetable_moveExtraRC_nolock(oldisa.extra_rc,
oldisa.deallocating,
oldisa.weakly_referenced);
} if (sideTableLocked) sidetable_unlock(); if (oldisa.nonpointer) {
#if SUPPORT_INDEXED_ISA
return classForIndex(oldisa.indexcls);
#else
return (Class)((uintptr_t)oldisa.shiftcls << );
#endif
}
else {
return oldisa.cls;
}
}

最新文章

  1. uploadify前台上传文件,java后台处理的例子
  2. 使用VIM插件ctags来阅读C代码
  3. 响应性web设计实战总结
  4. 有趣的BAT
  5. HDU 1176免费馅饼 DP数塔问题转化
  6. iOS多线程总结
  7. MM32 RTC学习(兼容STM32)
  8. Oracle User Management FAQ翻译及学习笔记
  9. mongo db 启动停止
  10. AngularJS &lt;a&gt; 超链接标签不起作用?
  11. hdu_1030(数学题+找规律)
  12. 手把手教你用.NET Core写爬虫
  13. @OnetoOne @OnetoMany @ManyToOne(2)
  14. centos 7 安装nvidia显卡驱动
  15. Suricata之outputs(输出选项)
  16. java中Long的比较
  17. 关于爬取数据保存到json文件,中文是unicode解决方式
  18. php返回上一页
  19. [转]如何在 Git 里撤销(几乎)任何操作
  20. Microsoft Visual Studio International Pack

热门文章

  1. nginx反向代理 和部分优化
  2. Xcode编译引用Framework
  3. Codeforce612C
  4. DRF Django REST framework 之 频率,响应器与分页器组件(六)
  5. Python之Flask项目开发【入门必学】
  6. ARTS-S anaconda常用命令
  7. CC1605&amp;CC1604 usb3.0+FPGA 高速视频采集 双目相机测评
  8. js如何判断一个对象是数组(函数)
  9. dev gridcontrol简单的动态设置动态表头
  10. AQS系列(四)- ReentrantReadWriteLock读写锁的释放锁