Message328416
| Author |
vstinner |
| Recipients |
Aaron Hall, benjamin.peterson, vstinner |
| Date |
2018年10月25日.07:09:00 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1540451341.08.0.788709270274.issue35059@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I tested PR 10079 using gdb on Fedora 28 with GCC 8.1.1 to check if Py_INCREF/Py_DECREF functions are inlined.
I understand that "static inline void Py_INCREF()" is *not* inline by gcc -O0, but it *is* inlined using gcc -Og which is the *default* optimization level of ./configure --with-debug.
To develop on Python, I force -O0, because the compilation time matters more than runtime performance for me :-) Compilation on my laptop using MAKEFLAGS=-j9:
* -O0: 21s
* -0g: 36s (1.7x slower)
... But Py_INCREF/DECREF are always inlined, even with -O0, when using __attribute__((always_inline))! I will work on a change to use that.
== gcc -O0 ==
(gdb) disassemble Py_IncRef
Dump of assembler code for function Py_IncRef:
...
0x000000000047276a <+20>: cmpq 0ドルx0,-0x8(%rbp)
0x000000000047276f <+25>: je 0x47277d <Py_IncRef+39>
0x0000000000472771 <+27>: mov -0x8(%rbp),%rax
0x0000000000472775 <+31>: mov %rax,%rdi
0x0000000000472778 <+34>: callq 0x472523 <_Py_INCREF>
0x000000000047277d <+39>: nop
0x000000000047277e <+40>: leaveq
0x000000000047277f <+41>: retq
(gdb) disassemble Py_DecRef
Dump of assembler code for function Py_DecRef:
...
0x0000000000472794 <+20>: cmpq 0ドルx0,-0x8(%rbp)
0x0000000000472799 <+25>: je 0x4727b1 <Py_DecRef+49>
0x000000000047279b <+27>: mov -0x8(%rbp),%rax
0x000000000047279f <+31>: mov %rax,%rdx
0x00000000004727a2 <+34>: mov 0ドルxe1,%esi
0x00000000004727a7 <+39>: mov 0ドルx65c550,%edi
0x00000000004727ac <+44>: callq 0x472554 <_Py_DECREF>
0x00000000004727b1 <+49>: nop
0x00000000004727b2 <+50>: leaveq
0x00000000004727b3 <+51>: retq
== gcc -Og ==
(gdb) disassemble Py_IncRef
Dump of assembler code for function Py_IncRef:
0x0000000000462de2 <+0>: test %rdi,%rdi
0x0000000000462de5 <+3>: je 0x462dfb <Py_IncRef+25>
0x0000000000462de7 <+5>: addq 0ドルx1,0x4bfc09(%rip) # 0x9229f8 <_Py_RefTotal>
0x0000000000462def <+13>: mov 0x10(%rdi),%rax
0x0000000000462df3 <+17>: add 0ドルx1,%rax
0x0000000000462df7 <+21>: mov %rax,0x10(%rdi)
0x0000000000462dfb <+25>: retq
(gdb) disassemble Py_DecRef
Dump of assembler code for function Py_DecRef:
0x0000000000463b2e <+0>: test %rdi,%rdi
0x0000000000463b31 <+3>: je 0x463b6f <Py_DecRef+65>
0x0000000000463b33 <+5>: sub 0ドルx8,%rsp
0x0000000000463b37 <+9>: subq 0ドルx1,0x4beeb9(%rip) # 0x9229f8 <_Py_RefTotal>
0x0000000000463b3f <+17>: mov 0x10(%rdi),%rax
0x0000000000463b43 <+21>: sub 0ドルx1,%rax
0x0000000000463b47 <+25>: mov %rax,0x10(%rdi)
0x0000000000463b4b <+29>: je 0x463b68 <Py_DecRef+58>
0x0000000000463b4d <+31>: js 0x463b54 <Py_DecRef+38>
0x0000000000463b4f <+33>: add 0ドルx8,%rsp
0x0000000000463b53 <+37>: retq
0x0000000000463b54 <+38>: mov %rdi,%rdx
0x0000000000463b57 <+41>: mov 0ドルxe1,%esi
0x0000000000463b5c <+46>: mov 0ドルx5e1120,%edi
0x0000000000463b61 <+51>: callq 0x462da4 <_Py_NegativeRefcount>
0x0000000000463b66 <+56>: jmp 0x463b4f <Py_DecRef+33>
0x0000000000463b68 <+58>: callq 0x463b0c <_Py_Dealloc>
0x0000000000463b6d <+63>: jmp 0x463b4f <Py_DecRef+33>
0x0000000000463b6f <+65>: retq |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2018年10月25日 07:09:01 | vstinner | set | recipients:
+ vstinner, benjamin.peterson, Aaron Hall |
| 2018年10月25日 07:09:01 | vstinner | set | messageid: <1540451341.08.0.788709270274.issue35059@psf.upfronthosting.co.za> |
| 2018年10月25日 07:09:01 | vstinner | link | issue35059 messages |
| 2018年10月25日 07:09:00 | vstinner | create |
|