

The purpose of adding two braces here is to form Local scope, so that the naming doesn’t want to conflict. The above method is obviously found from the method list of the class IMP.Log_and_fill_cache(cls, meth->imp, sel, inst, cls) Method meth = getMethodNoSuper_nolock(cls, sel) Determine the current location to search clsWhether the preparatory work has been completed, if not, you need to do the following class design realize。Ĥ.2 find from current class // Try this class's method lists.If cacheby YESThen call the cache_getImpCome from clsIn the cache of selCorresponding IMP, and return if found.We’re going to move on to lookUpImpOrForwardSource code: IMP lookUpImpOrForward(Class cls, SEL sel, id inst,īool initialize, bool cache, bool resolver)įrom the parameters of this method, we can know that, lookUpImpOrForwardIt should be a public method, initializeand cacheThey represent whether to avoid or not +initializeAnd whether to look it up from the cache. YES/*initialize*/, NO/*cache*/, YES/*resolver*/) Īnd then we went in lookUpImpOrForwardNotice here, cacheIt’s a biography NOBecause it has been explained here that the cache does not exist, we need to find the method. We’re going directly to _class_lookupMethodAndLoadCache3Source code: IMP _class_lookupMethodAndLoadCache3(id obj, SEL sel, Class cls)
#SHROUDED IN SANITY FATAL MEMORY ERROR CODE#
Class method – does not have its own – does not have a parent class – finds the parent class of the parent class – does not have nsobject – but has object methodĤ、 Source code analysis method search process.Class method – does not have its own parent class – does not find the parent class of the parent class – nor does the nsobject – crash.Class method – does not have its own parent class – does not find the parent class of the parent class – nsobject.Class method – does not have its own – finds the.Object’s instance method – it doesn’t have its own parent class – it doesn’t find the parent class of the parent class – nor does the nsobject – crash.Object’s instance method – does not have its own – does not have a parent class – finds the parent class of the parent class – nsobject.Object’s instance method – does not have its own – finds the.3、 Code analysis method search process 3.1 object method test We will come _class_lookupMethodAndLoadCache3This is the real method lookup implementation. But we know that we have to enter the C / C + + process, so we can also assemble to locate.Īnd then we go in _objc_msgSend_uncachedInside of We’re exploring objc_msgSendWhen the cache is not found, it will come to a place called objc_msgSend_uncachedAnd then it will come MethodTableLookupAnd then there’s a core search method _class_lookupMethodAndLoadCache3. _objc_msgSend_uncachedCache not found impĢ、 Find the next process through assembly.If you can’t find it, jump to it junpMiss.Go back when you find it = *bucket->imp\.GetClassFromIsa_p16Isa pointer processingĬache_thandle bucketAnd memory hash processing.Judge and deal with the message receiver (ID, self, self)_ cmd).Because C can’t write a function to keep unknown parameters and jump to an arbitrary function pointer.We know that the reason why we use assembly is that objc_msgSendThere are two reasons IOS bottom layer exploration – message search.Exploration of IOS bottom layer – calloc and ISA.IOS bottom layer exploration – alloc & init.
