An Illustrated History of objc_msgSend

<<   Cheetah   |   index   |   Panther   >>

PowerPC: Jaguar

Cheetah, Puma Jaguar
_objc_msgSend:                                                     
        cmplwi r3,  0         if (self == nil)                     
        beq    NIL                return zero                      
        stw    r8,  44(r1)                                         
        stw    r9,  48(r1)    save non-volatile registers          
        stw    r10, 52(r1)                                         
        lwz    r12, 0(r3)     class = self->isa                    
        lwz    r12, 32(r12)   cache = class->cache                 
        lwz    r11, 0(r12)    mask = cache->mask                   
        addi   r9,  r12, 8    buckets = cache->buckets             
                                                                   
        and    r12, r4,  r11  index = _cmd & mask                  
 LOOP:  slwi   r0,  r12, 2    offset = index * 4                   
        lwzx   r10, r9,  r0   method = buckets[offset]             
                                                                   
        cmplwi r10, 0         if (method == nil)                   
        beq    MISS               goto cache miss                  
        addi   r12, r12, 1    index++                              
        lwz    r8,  0(r10)    sel = method->sel                    
        and    r12, r12, r11  index &= mask                        
        lwz    r10, 8(r10)    imp = method->imp                    
        cmplw  r8,  r4        if (sel != _cmd)                     
        bne    LOOP               scan more                        
                                                                   
        mr     r12, r10       r12 = imp                            
        mtctr  r10            ctr = imp                            
        lwz    r8,  44(r1)                                         
        lwz    r9,  48(r1)    restore saved registers              
        lwz    r10, 52(r1)                                         
        li     r11, 0         set non-struct return for forwarding 
        bctr                  jump to imp                          

_objc_msgSend:                                                     
        cmplwi r3,  0         if (self == nil)                     
        beq    NIL                return zero                      
                                                                   
        stw    r9,  48(r1)    save non-volatile registers          
        stw    r10, 52(r1)                                         
        lwz    r12, 0(r3)     class = self->isa                    
        lwz    r12, 32(r12)   cache = class->cache                 
        lwz    r11, 0(r12)    mask = cache->mask                   
        addi   r9,  r12, 8    buckets = cache->buckets             
        slwi   r11, r11, 2                                         
        and    r12, r4,  r11  offset = (_cmd * 4) & mask           
 LOOP:                                                             
        lwzx   r10, r9,  r12  method = buckets[offset]             
        addi   r12, r12, 4    offset += 4                          
        cmplwi r10, 0         if (method == nil)                   
        beq    MISS               goto cache miss                  
                                                                   
        lwz    r0,  0(r10)    sel = method->sel                    
        and    r12, r12, r11  offset &= mask                       
                                                                   
        cmplw  r0,  r4        if (sel != _cmd)                     
        bne    LOOP               scan more                        
        lwz    r10, 8(r10)    imp = method->imp                    
        mr     r12, r10       r12 = imp                            
        mtctr  r10            ctr = imp                            
                                                                   
        lwz    r9,  48(r1)    restore saved registers              
        lwz    r10, 52(r1)                                         
        li     r11, 0         set non-struct return for forwarding 
        bctr                  jump to imp                          

Changes in Jaguar:

<<   Cheetah   |   index   |   Panther   >>