Skip to content

Instantly share code, notes, and snippets.

@toshok toshok/gist:7ac3e28e4ede26746165 Secret
Last active Aug 29, 2015

What would you like to do?

for the following python:

    import __pyston__

    class Foo(object):
        def foo(self):
            print "hi"


    f = Foo()

the callattr for the line:

expands to this IC slot:

; from getattrInternalEx
   0x7ffff7ff3244 <<module>_e1_0+12868>:	mov    (%rdi),%rax    			    ; load f->cls
   0x7ffff7ff3247 <<module>_e1_0+12871>:	cmpq   $0x0,0x38(%rax)			    ; addAttrGuard (f->cls->tp_getattr)
   0x7ffff7ff324f <<module>_e1_0+12879>:	jne    0x7ffff7ff34c3 <<module>_e1_0+13507>
   0x7ffff7ff3255 <<module>_e1_0+12885>:	cmpq   $0x850740,0x88(%rax)		    ; addAttrGuard (f->cls->tp_getattro)
   0x7ffff7ff3260 <<module>_e1_0+12896>:	jne    0x7ffff7ff34c3 <<module>_e1_0+13507>

; from typeLookup
   0x7ffff7ff3266 <<module>_e1_0+12902>:	mov    (%rdi),%rax			    ; load f->cls
   0x7ffff7ff3269 <<module>_e1_0+12905>:	movabs $0x12700037e8,%r8		    ; addAttrGuard (f->cls->total_shape)
   0x7ffff7ff3273 <<module>_e1_0+12915>:	cmp    0x1e8(%rax),%r8
   0x7ffff7ff327a <<module>_e1_0+12922>:	jne    0x7ffff7ff34c3 <<module>_e1_0+13507>
   0x7ffff7ff3280 <<module>_e1_0+12928>:	mov    0x150(%rax),%rax			    ; getAttr(f->cls->tp_mro)
   0x7ffff7ff3287 <<module>_e1_0+12935>:	mov    0x10(%rax),%rax			    ; getAttr(f->cls->tp_mro[0])
   0x7ffff7ff328b <<module>_e1_0+12939>:	mov    (%rax),%rax			    ; load class at tp_mro[0]
   0x7ffff7ff328e <<module>_e1_0+12942>:	mov    0x188(%rax),%rax			    ; load pointer to hcattr attr_vals
   0x7ffff7ff3295 <<module>_e1_0+12949>:	mov    0x18(%rax),%rax			    ; load pointer for 'foo' function

; from getattrInternalGeneric
   0x7ffff7ff3299 <<module>_e1_0+12953>:	movabs $0x2270010020,%r8                    ; addAttrGuard(foo->cls == function)
   0x7ffff7ff32a3 <<module>_e1_0+12963>:	cmp    (%rax),%r8			    ;
   0x7ffff7ff32a6 <<module>_e1_0+12966>:	jne    0x7ffff7ff34c3 <<module>_e1_0+13507>

; from getattr
   0x7ffff7ff32ac <<module>_e1_0+12972>:	movabs $0x22700c3020,%r8                    ; addAttrGuard(f->cls == Foo)
   0x7ffff7ff32b6 <<module>_e1_0+12982>:	cmp    (%rdi),%r8
   0x7ffff7ff32b9 <<module>_e1_0+12985>:	jne    0x7ffff7ff34c3 <<module>_e1_0+13507>
   0x7ffff7ff32bf <<module>_e1_0+12991>:	movabs $0x12700040e8,%r8                    ; addAttrGuard(hcattrs/hidden class)
   0x7ffff7ff32c9 <<module>_e1_0+13001>:	cmp    0x8(%rdi),%r8
   0x7ffff7ff32cd <<module>_e1_0+13005>:	jne    0x7ffff7ff34c3 <<module>_e1_0+13507>
   0x7ffff7ff32d3 <<module>_e1_0+13011>:	mov    (%rdi),%r8
											    ; normally the load from the instance attr
											    ; happens here, but we don't have an instance
											    ; attr named 'foo', so the above guards
											    ; are wasted.
; from callattrInternal
   0x7ffff7ff32d6 <<module>_e1_0+13014>:	movabs $0x1270085868,%r8                    ; addGuard(foo is the BoxedFunction we expect)
   0x7ffff7ff32e0 <<module>_e1_0+13024>:	cmp    %rax,%r8
   0x7ffff7ff32e3 <<module>_e1_0+13027>:	jne    0x7ffff7ff34c3 <<module>_e1_0+13507>

; from rewriter->call
   0x7ffff7ff32e9 <<module>_e1_0+13033>:	movabs $0x20fad0c,%rax			    ; increment "inside this slot"
   0x7ffff7ff32f3 <<module>_e1_0+13043>:	incl   (%rax)
   0x7ffff7ff32f5 <<module>_e1_0+13045>:	movabs $0x7ffff7fde000,%r11		    ; do the actual call to the jitted method
   0x7ffff7ff32ff <<module>_e1_0+13055>:	callq  *%r11
   0x7ffff7ff3302 <<module>_e1_0+13058>:	movabs $0x20fad0c,%rcx			    ; decrement "inside this slot"
   0x7ffff7ff330c <<module>_e1_0+13068>:	decl   (%rcx)
   0x7ffff7ff330e <<module>_e1_0+13070>:	jmpq   0x7ffff7ff3ca2 <<module>_e1_0+15522> ; jump to continue point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.