记录/objc2/object_setClass做了啥
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;
}
}
记录/objc2/object_setClass做了啥的更多相关文章
- WebAPI 用ExceptionFilterAttribute实现错误(异常)日志的记录(log4net做写库操作)
WebAPI 用ExceptionFilterAttribute实现错误(异常)日志的记录(log4net做写库操作) 好吧,还是那个社区APP,非管理系统,用户行为日志感觉不是很必要的,但是,错误日 ...
- 记录一下我做Udacity 的Data Scientist Nano Degree Project
做项目的时候看了别人的blog,决定自己也随手记录下在做项目中遇到的好的小知识点. 最近在做Udacity的Data Scientist Nano Degree Project的Customer_Se ...
- .NET WebAPI 用ExceptionFilterAttribute实现错误(异常)日志的记录(log4net做写库操作)
好吧,还是那个社区APP,非管理系统,用户行为日志感觉不是很必要的,但是,错误日志咱还是得记录则个.总不能上线后报bug了让自己手足无措吧,虽然不管有木有错误日志报bug都是件很头疼的事... 我们知 ...
- thinkphp5高亮当前页(仅针对个人项目记录,不做通用参考)
<div class="navbg"> <ul class="menu"> <li> <a href="/& ...
- 比较难的sql面试题--记录下来晚上做
一组通话记录(总共500万条):ID 主叫号码 被叫号码 通话起始时间 通话结束时间 通话时长1 98290000 0215466546656 2007-02-01 09:4 ...
- 好吧,不说闲言碎语,不抱怨,好好工作,好好学习,多总结。记录一下昨天做vuejs的心得
1.做了两个bat文件,一个是直接定位到vuejs项目并且运行,另一个就是打包 run.bat d:cd wwwcd vuecd dtbpmcnpm run devpause build.bat cd ...
- 【做题记录】Codeforces做题记录
最近决定写一些CF Div.1的题,练习一下速度和代码能力. 暂定从中考后的Codeforces Round #572开始. 大部分比较简单的题直接把题解写在这里,不单独开文章了. Codeforce ...
- Delphi中记录体做为属性的赋值方法
1. 起源 此问题源于[秋风人事档案管理系统]用Delphi XE重编译中所发现. 快十年了,当初Delphi 7所编写项目,想用Delphi XE重新编译,并打算做为Free软件发布,编译错误中发现 ...
- (转)解释一下SQLSERVER事务日志记录
本文转载自桦仔的博客http://www.cnblogs.com/lyhabc/archive/2013/07/16/3194220.html 解释一下SQLSERVER事务日志记录 大家知道在完整恢 ...
随机推荐
- vue 各种打包坑
1,报错 Refused to load the image 'http://localhost:8080/favicon.ico' because it violates the following ...
- mac eclipse Android开发环境搭建
http://www.cnblogs.com/macro-cheng/archive/2011/09/30/android-001.html
- ios instancetype与id区别
我们都知道未知类型的的对象可以用id关键字表示,那为什么还会再有一个instancetype呢? instancetype能返回相关联的类型(使那些非关联返回类型的方法返回所在类的类型):而id 返回 ...
- [TimLinux] JavaScript 模态框可拖动功能实现——节流版
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- java中List、Map、Set、Stack、Queue、Collections等的使用
java中List.Map.Set.Stack.Queue.Collections等的使用 List 创建方法: List<String> list=new ArrayList<&g ...
- 强化学习七 - Policy Gradient Methods
一.前言 之前我们讨论的所有问题都是先学习action value,再根据action value 来选择action(无论是根据greedy policy选择使得action value 最大的ac ...
- B.Beautiful Numbers
题意:你被给予了一个序列 p = [p1, p2, ..., pn](1 ~ n的整数),如果存在l, r左右端点(1 <= l <= r <= n),使得[pl, pl+1,... ...
- MySQL 04
目录 python操作mysql mysql sql注入问题 问题描述 解决办法 增/删/改 查询 索引 基本概念 索引的原理 mysql索引种类 普通索引 唯一索引 联合索引 创建索引 正确使用索引 ...
- 【MySql】使用学习
[MySql]使用学习 =================================================== 1.太多的连接 Too many connections ======= ...
- java动态编译运行代码
import java.io.BufferedReader;import java.io.InputStreamReader;import java.net.URI;import java.util. ...