Skip to content

Conversation

@ndossche
Copy link
Member

@ndossche ndossche commented Nov 22, 2025

This reduces the assembly size of e.g. ZEND_FRAMELESS_ICALL_0_SPEC_UNUSED_UNUSED_HANDLER from 52 to 46 bytes on x86-64 with GCC 15.2.1, strangely. Removes a redundant load.

Before:

<+0>:	sub    $0x8,%rsp
<+4>:	movslq 0x10(%r15),%rax
<+8>:	movslq 0x10(%r15),%rdi
<+12>:	mov    %r15,(%r14)
<+15>:	mov    0x14(%r15),%edx
<+19>:	movl   $0x1,0x8(%r14,%rax,1)
<+28>:	mov    0x140695d(%rip),%rax        # 0x1addfe0 <zend_flf_handlers>
<+35>:	add    %r14,%rdi
<+38>:	call   *(%rax,%rdx,8)
<+41>:	mov    (%r14),%r15
<+44>:	add    $0x8,%rsp
<+48>:	add    $0x20,%r15
<+52>:	ret

After:

<+0>:	sub    $0x8,%rsp
<+4>:	movslq 0x10(%r15),%rdi
<+8>:	mov    0x14(%r15),%edx
<+12>:	mov    %r15,(%r14)
<+15>:	mov    0xace58a(%rip),%rax        # 0x10d9840 <zend_flf_handlers>
<+22>:	add    %r14,%rdi
<+25>:	movl   $0x1,0x8(%rdi)
<+32>:	call   *(%rax,%rdx,8)
<+35>:	mov    (%r14),%r15
<+38>:	add    $0x8,%rsp
<+42>:	add    $0x20,%r15
<+46>:	ret

This reduces the assembly size from 52 to 46 bytes on x86-64 with GCC
15.2.1, strangely.

Before:
```
<+0>:	sub    $0x8,%rsp
<+4>:	movslq 0x10(%r15),%rax
<+8>:	movslq 0x10(%r15),%rdi
<+12>:	mov    %r15,(%r14)
<+15>:	mov    0x14(%r15),%edx
<+19>:	movl   $0x1,0x8(%r14,%rax,1)
<+28>:	mov    0x140695d(%rip),%rax        # 0x1addfe0 <zend_flf_handlers>
<+35>:	add    %r14,%rdi
<+38>:	call   *(%rax,%rdx,8)
<+41>:	mov    (%r14),%r15
<+44>:	add    $0x8,%rsp
<+48>:	add    $0x20,%r15
<+52>:	ret
```

After:
```
<+0>:	sub    $0x8,%rsp
<+4>:	movslq 0x10(%r15),%rdi
<+8>:	mov    0x14(%r15),%edx
<+12>:	mov    %r15,(%r14)
<+15>:	mov    0xace58a(%rip),%rax        # 0x10d9840 <zend_flf_handlers>
<+22>:	add    %r14,%rdi
<+25>:	movl   $0x1,0x8(%rdi)
<+32>:	call   *(%rax,%rdx,8)
<+35>:	mov    (%r14),%r15
<+38>:	add    $0x8,%rsp
<+42>:	add    $0x20,%r15
<+46>:	ret
```
Copy link
Member

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple. The other functions do it, but icall_0 doesn't, for reasons.

@ndossche ndossche marked this pull request as ready for review November 22, 2025 15:18
@ndossche ndossche requested a review from dstogov as a code owner November 22, 2025 15:18
@ndossche ndossche merged commit 3abdef2 into php:master Nov 22, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants