Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tstarling/e33509555d480910cb5d3ea6cb7a1352 to your computer and use it in GitHub Desktop.
Save tstarling/e33509555d480910cb5d3ea6cb7a1352 to your computer and use it in GitHub Desktop.
DOMDocument::getElementsByTagName() disassembly with and without fast ZPP
# With zend_parse_parameters():
$ objdump ext/dom/document.o --disassemble=zim_DOMDocument_getElementsByTagName
ext/dom/document.o: file format elf64-x86-64
Disassembly of section .text:
0000000000001360 <zim_DOMDocument_getElementsByTagName>:
1360: f3 0f 1e fa endbr64
1364: 41 54 push %r12
1366: 55 push %rbp
1367: 48 89 f5 mov %rsi,%rbp
136a: 48 8d 35 00 00 00 00 lea 0x0(%rip),%rsi # 1371 <zim_DOMDocument_getElementsByTagName+0x11>
1371: 53 push %rbx
1372: 48 89 fb mov %rdi,%rbx
1375: 48 83 ec 20 sub $0x20,%rsp
1379: 8b 7f 2c mov 0x2c(%rdi),%edi
137c: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
1383: 00 00
1385: 48 89 44 24 18 mov %rax,0x18(%rsp)
138a: 31 c0 xor %eax,%eax
138c: 48 8d 4c 24 08 lea 0x8(%rsp),%rcx
1391: 48 8d 54 24 10 lea 0x10(%rsp),%rdx
1396: e8 00 00 00 00 call 139b <zim_DOMDocument_getElementsByTagName+0x3b>
139b: 83 f8 ff cmp $0xffffffff,%eax
139e: 74 4d je 13ed <zim_DOMDocument_getElementsByTagName+0x8d>
13a0: 48 8b 43 20 mov 0x20(%rbx),%rax
13a4: 48 8b 50 e8 mov -0x18(%rax),%rdx
13a8: 4c 8d 60 e8 lea -0x18(%rax),%r12
13ac: 48 85 d2 test %rdx,%rdx
13af: 0f 84 00 00 00 00 je 13b5 <zim_DOMDocument_getElementsByTagName+0x55>
13b5: 48 83 3a 00 cmpq $0x0,(%rdx)
13b9: 0f 84 00 00 00 00 je 13bf <zim_DOMDocument_getElementsByTagName+0x5f>
13bf: 31 f6 xor %esi,%esi
13c1: 48 89 ef mov %rbp,%rdi
13c4: e8 00 00 00 00 call 13c9 <zim_DOMDocument_getElementsByTagName+0x69>
13c9: 6a 00 push $0x0
13cb: 48 8b 55 00 mov 0x0(%rbp),%rdx
13cf: 31 c9 xor %ecx,%ecx
13d1: 6a 00 push $0x0
13d3: 4c 8b 4c 24 18 mov 0x18(%rsp),%r9
13d8: 31 f6 xor %esi,%esi
13da: 4c 89 e7 mov %r12,%rdi
13dd: 4c 8b 44 24 20 mov 0x20(%rsp),%r8
13e2: 48 83 ea 18 sub $0x18,%rdx
13e6: e8 00 00 00 00 call 13eb <zim_DOMDocument_getElementsByTagName+0x8b>
13eb: 58 pop %rax
13ec: 5a pop %rdx
13ed: 48 8b 44 24 18 mov 0x18(%rsp),%rax
13f2: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
13f9: 00 00
13fb: 75 09 jne 1406 <zim_DOMDocument_getElementsByTagName+0xa6>
13fd: 48 83 c4 20 add $0x20,%rsp
1401: 5b pop %rbx
1402: 5d pop %rbp
1403: 41 5c pop %r12
1405: c3 ret
1406: e8 00 00 00 00 call 140b <zim_DOMDocument_getElementsByTagName+0xab>
# With ZEND_PARSE_PARAMETERS_START()
$ objdump --disassemble=zim_DOMDocument_getElementsByTagName ext/dom/document.o
ext/dom/document.o: file format elf64-x86-64
Disassembly of section .text:
0000000000001360 <zim_DOMDocument_getElementsByTagName>:
1360: f3 0f 1e fa endbr64
1364: 41 56 push %r14
1366: 41 55 push %r13
1368: 41 54 push %r12
136a: 55 push %rbp
136b: 53 push %rbx
136c: 48 83 ec 10 sub $0x10,%rsp
1370: 44 8b 67 2c mov 0x2c(%rdi),%r12d
1374: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax
137b: 00 00
137d: 48 89 44 24 08 mov %rax,0x8(%rsp)
1382: 31 c0 xor %eax,%eax
1384: 41 83 fc 01 cmp $0x1,%r12d
1388: 0f 85 00 00 00 00 jne 138e <zim_DOMDocument_getElementsByTagName+0x2e>
138e: 80 7f 58 06 cmpb $0x6,0x58(%rdi)
1392: 48 89 fb mov %rdi,%rbx
1395: 48 89 f5 mov %rsi,%rbp
1398: 75 76 jne 1410 <zim_DOMDocument_getElementsByTagName+0xb0>
139a: 48 8b 47 50 mov 0x50(%rdi),%rax
139e: 4c 8b 70 10 mov 0x10(%rax),%r14
13a2: 4c 8d 68 18 lea 0x18(%rax),%r13
13a6: 48 8b 43 20 mov 0x20(%rbx),%rax
13aa: 48 8b 50 e8 mov -0x18(%rax),%rdx
13ae: 4c 8d 60 e8 lea -0x18(%rax),%r12
13b2: 48 85 d2 test %rdx,%rdx
13b5: 0f 84 a5 00 00 00 je 1460 <zim_DOMDocument_getElementsByTagName+0x100>
13bb: 48 83 3a 00 cmpq $0x0,(%rdx)
13bf: 0f 84 00 00 00 00 je 13c5 <zim_DOMDocument_getElementsByTagName+0x65>
13c5: 31 f6 xor %esi,%esi
13c7: 48 89 ef mov %rbp,%rdi
13ca: e8 00 00 00 00 call 13cf <zim_DOMDocument_getElementsByTagName+0x6f>
13cf: 48 8b 55 00 mov 0x0(%rbp),%rdx
13d3: 6a 00 push $0x0
13d5: 4d 89 f1 mov %r14,%r9
13d8: 6a 00 push $0x0
13da: 4d 89 e8 mov %r13,%r8
13dd: 31 c9 xor %ecx,%ecx
13df: 31 f6 xor %esi,%esi
13e1: 48 83 ea 18 sub $0x18,%rdx
13e5: 4c 89 e7 mov %r12,%rdi
13e8: e8 00 00 00 00 call 13ed <zim_DOMDocument_getElementsByTagName+0x8d>
13ed: 58 pop %rax
13ee: 5a pop %rdx
13ef: 48 8b 44 24 08 mov 0x8(%rsp),%rax
13f4: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
13fb: 00 00
13fd: 75 5c jne 145b <zim_DOMDocument_getElementsByTagName+0xfb>
13ff: 48 83 c4 10 add $0x10,%rsp
1403: 5b pop %rbx
1404: 5d pop %rbp
1405: 41 5c pop %r12
1407: 41 5d pop %r13
1409: 41 5e pop %r14
140b: c3 ret
140c: 0f 1f 40 00 nopl 0x0(%rax)
1410: 4c 8d 6f 50 lea 0x50(%rdi),%r13
1414: 48 89 e6 mov %rsp,%rsi
1417: ba 01 00 00 00 mov $0x1,%edx
141c: 4c 89 ef mov %r13,%rdi
141f: e8 00 00 00 00 call 1424 <zim_DOMDocument_getElementsByTagName+0xc4>
1424: 84 c0 test %al,%al
1426: 74 10 je 1438 <zim_DOMDocument_getElementsByTagName+0xd8>
1428: 48 8b 04 24 mov (%rsp),%rax
142c: e9 6d ff ff ff jmp 139e <zim_DOMDocument_getElementsByTagName+0x3e>
1431: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
1438: bf 09 00 00 00 mov $0x9,%edi
143d: b9 04 00 00 00 mov $0x4,%ecx
1442: 48 8b 44 24 08 mov 0x8(%rsp),%rax
1447: 64 48 2b 04 25 28 00 sub %fs:0x28,%rax
144e: 00 00
1450: 0f 84 00 00 00 00 je 1456 <zim_DOMDocument_getElementsByTagName+0xf6>
1456: e9 00 00 00 00 jmp 145b <zim_DOMDocument_getElementsByTagName+0xfb>
145b: e8 00 00 00 00 call 1460 <zim_DOMDocument_getElementsByTagName+0x100>
1460: e9 00 00 00 00 jmp 1465 <zim_DOMDocument_getElementsByTagName+0x105>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment