Created
March 24, 2026 21:08
-
-
Save synopse/726a4706d95905101b4de87c4719329f to your computer and use it in GitHub Desktop.
FPC and Delphi for Linux asm Comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _ZN6Mormot4Core10Interfaces8FindGuidEPPNS1_17TInterfaceFactoryEiyy PROC | |
| ; WEAK _ZN6Mormot4Core10Interfaces8FindGuidEPPNS1_17TInterfaceFactoryEiyy | |
| push rbp ; 0000 _ 55 | |
| mov rbp, rsp ; 0001 _ 48: 89. E5 | |
| mov qword ptr [rbp-20H], rcx ; 0004 _ 48: 89. 4D, E0 | |
| mov qword ptr [rbp-18H], rdx ; 0008 _ 48: 89. 55, E8 | |
| mov dword ptr [rbp-0CH], esi ; 000C _ 89. 75, F4 | |
| mov qword ptr [rbp-8H], rdi ; 000F _ 48: 89. 7D, F8 | |
| ; Note: Immediate operand could be made smaller by sign extension | |
| cmp dword ptr [rbp-0CH], 0 ; 0013 _ 81. 7D, F4, 00000000 | |
| jle ?_1806 ; 001A _ 7E, 5F | |
| jmp ?_1804 ; 001C _ EB, 00 | |
| ?_1804: mov rax, qword ptr [rbp-8H] ; 001E _ 48: 8B. 45, F8 | |
| mov rax, qword ptr [rax] ; 0022 _ 48: 8B. 00 | |
| mov qword ptr [rbp-28H], rax ; 0025 _ 48: 89. 45, D8 | |
| mov rax, qword ptr [rbp-28H] ; 0029 _ 48: 8B. 45, D8 | |
| mov rax, qword ptr [rax+8H] ; 002D _ 48: 8B. 40, 08 | |
| mov rax, qword ptr [rax+28H] ; 0031 _ 48: 8B. 40, 28 | |
| mov qword ptr [rbp-30H], rax ; 0035 _ 48: 89. 45, D0 | |
| mov rax, qword ptr [rbp-30H] ; 0039 _ 48: 8B. 45, D0 | |
| mov rax, qword ptr [rax] ; 003D _ 48: 8B. 00 | |
| cmp rax, qword ptr [rbp-18H] ; 0040 _ 48: 3B. 45, E8 | |
| jnz ?_1805 ; 0044 _ 75, 10 | |
| mov rax, qword ptr [rbp-30H] ; 0046 _ 48: 8B. 45, D0 | |
| mov rax, qword ptr [rax+8H] ; 004A _ 48: 8B. 40, 08 | |
| cmp rax, qword ptr [rbp-20H] ; 004E _ 48: 3B. 45, E0 | |
| jnz ?_1805 ; 0052 _ 75, 02 | |
| jmp ?_1807 ; 0054 _ EB, 2D | |
| ?_1805: mov rax, qword ptr [rbp-8H] ; 0056 _ 48: 8B. 45, F8 | |
| ; Note: Immediate operand could be made smaller by sign extension | |
| add rax, 8 ; 005A _ 48: 05, 00000008 | |
| mov qword ptr [rbp-8H], rax ; 0060 _ 48: 89. 45, F8 | |
| mov ecx, dword ptr [rbp-0CH] ; 0064 _ 8B. 4D, F4 | |
| ; Note: Immediate operand could be made smaller by sign extension | |
| sub ecx, 1 ; 0067 _ 81. E9, 00000001 | |
| mov dword ptr [rbp-0CH], ecx ; 006D _ 89. 4D, F4 | |
| ; Note: Immediate operand could be made smaller by sign extension | |
| cmp dword ptr [rbp-0CH], 0 ; 0070 _ 81. 7D, F4, 00000000 | |
| jnz ?_1804 ; 0077 _ 75, A5 | |
| jmp ?_1806 ; 0079 _ EB, 00 | |
| ?_1806: mov qword ptr [rbp-28H], 0 ; 007B _ 48: C7. 45, D8, 00000000 | |
| ?_1807: mov rax, qword ptr [rbp-28H] ; 0083 _ 48: 8B. 45, D8 | |
| pop rbp ; 0087 _ 5D | |
| ret ; 0088 _ C3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .text.n_mormot.core.interfaces_$$_findguid$pinterfacefactory$longint$qword$qword$$tinterfacefactory SEGMENT PARA 'CODE' ; section number 49 | |
| MORMOT.CORE.INTERFACES_$$_FINDGUID$PINTERFACEFACTORY$LONGINT$QWORD$QWORD$$TINTERFACEFACTORY LABEL NEAR | |
| test esi, esi ; 0000 _ 85. F6 | |
| jle ?_0283 ; 0002 _ 7E, 23 | |
| ; Filling space: 4H | |
| ; Filler type: Multi-byte NOP | |
| ; db 0FH, 1FH, 40H, 00H | |
| ALIGN 8 | |
| ?_0281: mov rax, qword ptr [rdi] ; 0008 _ 48: 8B. 07 | |
| mov r8, qword ptr [rax+8H] ; 000B _ 4C: 8B. 40, 08 | |
| mov r8, qword ptr [r8+28H] ; 000F _ 4D: 8B. 40, 28 | |
| cmp rdx, qword ptr [r8] ; 0013 _ 49: 3B. 10 | |
| jnz ?_0282 ; 0016 _ 75, 06 | |
| cmp rcx, qword ptr [r8+8H] ; 0018 _ 49: 3B. 48, 08 | |
| jz ?_0284 ; 001C _ 74, 0B | |
| ?_0282: add rdi, 8 ; 001E _ 48: 83. C7, 08 | |
| sub esi, 1 ; 0022 _ 83. EE, 01 | |
| jnz ?_0281 ; 0025 _ 75, E1 | |
| ?_0283: xor eax, eax ; 0027 _ 31. C0 | |
| ?_0284: ret ; 0029 _ C3 | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To be faire, dcc64 is not really worse than FPC. It is almost the same. FPC just get rid of a not-needed "test edx, edx" instruction, but in practice, the CPU would just ignore this and optimized it at micro-op level.
Both Delphi dcc32 and dcc64 generates FPC-like code for this function.
The issue is the LLVM backend usage in Delphi.