Giter Site home page Giter Site logo

Comments (2)

BiBoyang avatar BiBoyang commented on July 18, 2024

isInitialized这个方法是+initialized的判断方法,来判断当前类是否初始化过。
因为+initialize方法实际上是在alloc方法之前调用的。很有可能会发生+initialize 中调用了 storeWeak 方法,而在 storeWeak 方法中 weak_register_no_lock 方法中用到对象的 isa 还没有初始化完成的情况

from ios-source-probe.

wxiubin avatar wxiubin commented on July 18, 2024

isInitialized这个方法是+initialized的判断方法,来判断当前类是否初始化过。
因为+initialize方法实际上是在alloc方法之前调用的。很有可能会发生+initialize 中调用了 storeWeak 方法,而在 storeWeak 方法中 weak_register_no_lock 方法中用到对象的 isa 还没有初始化完成的情况

但是源码是这样的:

Class cls = newObj->getIsa();
if (cls != previouslyInitializedClass  &&  
    !((objc_class *)cls)->isInitialized()) 
{
    SideTable::unlockTwo<haveOld, haveNew>(oldTable, newTable);
    _class_initialize(_class_getNonMetaClass(cls, (id)newObj));
    previouslyInitializedClass = cls;
    goto retry;
}

newObj 是一个类的实例对象, 已经都有调用 alloc 方法了, 又如何会出现 很有可能会发生+initialize 中调用了 storeWeak 方法,而在 storeWeak 方法中 weak_register_no_lock 方法中用到对象的 isa 还没有初始化完成的情况 这种情况呢? 即对象都已经被初始化, 为什么还会有 对象的 isa 还没有初始化完成的情况 这种情况.

from ios-source-probe.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.