An Illustrated History of objc_msgSend

<<   Panther   |   index   |   Tiger i386   >>

PowerPC: Tiger, Leopard, Snow Leopard

Panther Tiger, Leopard, Snow Leopard
_objc_msgSend:                                                     
        cmplwi r3,  0         if (self == nil)                     
                                                                   
                                                                   
        beq    NIL                return zero                      
        lwz    r12, 0(r3)     class = self->isa                    
                                                                   
        lwz    r12, 32(r12)   cache = class->cache                 
        stw    r9,  48(r1)    save non-volatile register           
        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   r2,  r9,  r12  method = buckets[offset]             
        addi   r12, r12, 4    offset += 4                          
        cmplwi r2,  0         if (method == nil)                   
        beq    MISS               goto cache miss                  
        lwz    r0,  0(r2)     sel = method->sel                    
        and    r12, r12, r11  offset &= mask                       
        cmplw  r0,  r4        if (sel != _cmd)                     
        bne    LOOP               scan more                        
        lwz    r12, 8(r2)     imp = method->imp                    
        mtctr  r12            ctr = imp                            
        lwz    r9,  48(r1)    restore saved register               
                                                                   
        bctr                  jump to imp                          
_objc_msgSend:                                                             
        cmplwi r3,  0            if (self == nil)                          
        xoris  r11, r4,  0xfffe                                            
        cmplwi cr1, r11, 0xf010                     if (cmd == 0xfffef010) 
        beq    NIL                   return zero                           
        lwz    r12, 0(r3)        class = self->isa                         
        beqlr  cr1                                      return self        
        lwz    r2,  32(r12)      cache = class->cache                      
        stw    r9,  48(r1)       save non-volatile register                
        lwz    r11, 0(r2)        mask = cache->mask                        
        addi   r0,  r2,  8       buckets = cache->buckets                  
        slwi   r11, r11, 2                                                 
        and    r9,  r4,  r11     offset = (_cmd * 4) & mask                
 LOOP:  lwzx   r2,  r9,  r0      method = buckets[offset]                  
        addi   r9,  r9,  4       offset += 4                               
        cmplwi r2,  0            if (method == nil)                        
        beq    MISS                  goto cache miss                       
        lwz    r12, 0(r2)        sel = method->sel                         
        and    r9,  r9,  r11     offset &= mask                            
        cmplw  r12,   r4         if (sel != _cmd)                          
        bne    LOOP                  scan more                             
        lwz    r12, 8(r2)        imp = method->imp                         
                                                                           
        lwz    r9,  48(r1)       restore saved register                    
        mtctr  r12               ctr = imp                                 
        bctr                     jump to imp                               

Changes in Tiger:

The PowerPC code was unchanged after Tiger. The Intel architectures were the future. Leopard added support for 64-bit PowerPC; it was a direct transcription of the 32-bit code and is not reproduced here. PowerPC was supported on Snow Leopard in the Rosetta emulator only, and then it was gone.

<<   Panther   |   index   |   Tiger i386   >>