◐ Shell
clean mode source ↗

[WIP] bpo-39465: _PyUnicode_FromId() now uses an hash table by vstinner · Pull Request #20048 · python/cpython

_Py_hashtable_get() in _PyUnicode_FormId() calls ht->get_func(ht, pkey, data) which is:

(gdb) disassemble _Py_hashtable_get_ptr 
Dump of assembler code for function _Py_hashtable_get_ptr:
   0x00000000004303b0 <+0>:	mov    rax,QWORD PTR [rdi]
   0x00000000004303b3 <+3>:	mov    rcx,rdx
   0x00000000004303b6 <+6>:	mov    rdx,QWORD PTR [rsi]
   0x00000000004303b9 <+9>:	sub    rax,0x1
   0x00000000004303bd <+13>:	ror    rdx,0x4
   0x00000000004303c1 <+17>:	and    rax,rdx
   0x00000000004303c4 <+20>:	mov    rdx,QWORD PTR [rdi+0x10]
   0x00000000004303c8 <+24>:	mov    rax,QWORD PTR [rdx+rax*8]
   0x00000000004303cc <+28>:	test   rax,rax
   0x00000000004303cf <+31>:	jne    0x4303e0 <_Py_hashtable_get_ptr+48>

   0x00000000004303d1 <+33>:	jmp    0x430401 <_Py_hashtable_get_ptr+81>

   0x00000000004303d3 <+35>:	nop    DWORD PTR [rax+rax*1+0x0]
   0x00000000004303d8 <+40>:	mov    rax,QWORD PTR [rax]
   0x00000000004303db <+43>:	test   rax,rax
   0x00000000004303de <+46>:	je     0x430400 <_Py_hashtable_get_ptr+80>

   0x00000000004303e0 <+48>:	mov    rdx,QWORD PTR [rsi]
   0x00000000004303e3 <+51>:	cmp    QWORD PTR [rax+0x10],rdx
   0x00000000004303e7 <+55>:	jne    0x4303d8 <_Py_hashtable_get_ptr+40>

   0x00000000004303e9 <+57>:	mov    rdx,QWORD PTR [rdi+0x18]
   0x00000000004303ed <+61>:	mov    rax,QWORD PTR [rax+rdx*1+0x10]
   0x00000000004303f2 <+66>:	mov    QWORD PTR [rcx],rax
   0x00000000004303f5 <+69>:	mov    eax,0x1
   0x00000000004303fa <+74>:	ret    

   0x00000000004303fb <+75>:	nop    DWORD PTR [rax+rax*1+0x0]
   0x0000000000430400 <+80>:	ret    

   0x0000000000430401 <+81>:	xor    eax,eax
   0x0000000000430403 <+83>:	ret    
End of assembler dump.

Machine code on x86-64 on Fedora 32 with gcc (GCC) 10.0.1 20200430 (Red Hat 10.0.1-0.14), compilation using LTO. It contains many NOP, likely for better code placement :-)