Skip to content

JIT: Avoid object type check if the object is known to be a type - #24086

Open
ndossche wants to merge 1 commit into
php:masterfrom
ndossche:jit-recv-known-object
Open

ndossche wants to merge 1 commit into
php:masterfrom
ndossche:jit-recv-known-object

Conversation

@ndossche

@ndossche ndossche commented Oct 2, 2026

Copy link
Copy Markdown
Member

Follow-up for #24052

Before:

	mov    %r15,%r14
	lea    0x50(%r14),%rdi       ; &CV0($o)
	cmpb   $0x8,0x58(%r14)       ; Check IS_OBJECT
	jne    not_an_object         ; ...
	mov    (%rdi),%rax           ; Z_OBJ_P($o)
	lea    -0x77280f9(%rip),%rcx ; ce to compare against
	cmp    0x10(%rax),%rcx       ; Z_OBJ_P($o)->ce == ce
	je     wrong_ce
	...

After:

	mov    %r15,%r14
	lea    0x50(%r14),%rdi       ; &CV0($o)
	mov    (%rdi),%rax           ; Z_OBJ_P($o) (known to be an object)
	lea    -0x77280f9(%rip),%rcx ; ce to compare against
	cmp    0x10(%rax),%rcx       ; Z_OBJ_P($o)->ce == ce
	je     wrong_ce
	...

This also helps with an ?Foo type check: it can skip the IS_OBJECT and IS_NULL check.

This also simplifies zend_jit_verify_arg_type: the (type == IS_UNKNOWN || type == IS_OBJECT) check becomes always-true.

Before:
```asm
	mov    %r15,%r14
	lea    0x50(%r14),%rdi       ; &CV0($o)
	cmpb   $0x8,0x58(%r14)       ; Check IS_OBJECT
	jne    not_an_object         ; ...
	mov    (%rdi),%rax           ; Z_OBJ_P($o)
	lea    -0x77280f9(%rip),%rcx ; ce to compare against
	cmp    0x10(%rax),%rcx       ; Z_OBJ_P($o)->ce == ce
	je     wrong_ce
	...
```

After:
```asm
	mov    %r15,%r14
	lea    0x50(%r14),%rdi       ; &CV0($o)
	mov    (%rdi),%rax           ; Z_OBJ_P($o) (known to be an object)
	lea    -0x77280f9(%rip),%rcx ; ce to compare against
	cmp    0x10(%rax),%rcx       ; Z_OBJ_P($o)->ce == ce
	je     wrong_ce
	...
```

This also helps with an `?Foo` type check: it can skip the IS_OBJECT and IS_NULL check.

This also simplifies `zend_jit_verify_arg_type`: the
`(type == IS_UNKNOWN || type == IS_OBJECT)` check becomes always-true.
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

AWS x86_64 (c6id.metal)

Attribute Value
Environment aws
Instance type c6id.metal
Architecture x86_64
CPU Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz, 64 cores @ 2900 MHz
CPU settings disabled deeper C-states, disabled turbo boost, disabled hyper-threading
RAM 251 GB
Kernel 6.18.38-76.139.amzn2023.x86_64
OS Amazon Linux 2023.12.20260727
GCC 14.2.1
Binary layout strategy none
Time 2026-10-03 09:45:00 UTC
Job details https://github.com/php/php-src/actions/runs/37114074071 (Artifacts)
Changeset https://github.com/php/php-src/compare/cd8312e052..30f0cf6e6b

Laravel 12.11.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@cd8312e 0.38119 0.38301 0.00040 0.11% 0.38173 0.00% 0.38158 0.00% 1.493 0.000 1.000 25.90 MB
PHP - baseline@cd8312e (JIT) 0.35689 0.35776 0.00021 0.06% 0.35726 -6.41% 0.35723 -6.38% 0.576 8.614 0.000 25.98 MB
PHP - jit-recv-known-object 0.38100 0.38265 0.00029 0.08% 0.38145 -0.07% 0.38142 -0.04% 1.882 4.171 0.000 25.90 MB
PHP - jit-recv-known-object (JIT) 0.35705 0.35848 0.00027 0.08% 0.35747 -6.35% 0.35744 -6.33% 1.471 8.614 0.000 25.98 MB

Symfony 2.8.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@cd8312e 0.67723 0.67940 0.00049 0.07% 0.67779 0.00% 0.67762 0.00% 1.624 0.000 1.000 26.25 MB
PHP - baseline@cd8312e (JIT) 0.64253 0.64622 0.00066 0.10% 0.64323 -5.10% 0.64303 -5.11% 2.625 8.614 0.000 26.23 MB
PHP - jit-recv-known-object 0.67736 0.68170 0.00077 0.11% 0.67798 0.03% 0.67777 0.02% 3.152 -1.868 0.062 26.21 MB
PHP - jit-recv-known-object (JIT) 0.64236 0.67301 0.00562 0.87% 0.64395 -4.99% 0.64264 -5.16% 4.799 8.614 0.000 26.22 MB

Wordpress 6.9 main page - 50 iterations, 20 warmups, 20 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@cd8312e 0.59640 0.60098 0.00070 0.12% 0.59735 0.00% 0.59725 0.00% 3.010 0.000 1.000 26.28 MB
PHP - baseline@cd8312e (JIT) 0.52281 0.52599 0.00065 0.12% 0.52373 -12.33% 0.52355 -12.34% 2.096 8.614 0.000 26.33 MB
PHP - jit-recv-known-object 0.59642 0.60001 0.00094 0.16% 0.59755 0.03% 0.59733 0.01% 1.699 -0.465 0.642 26.25 MB
PHP - jit-recv-known-object (JIT) 0.52306 0.53413 0.00162 0.31% 0.52434 -12.22% 0.52395 -12.27% 4.817 8.614 0.000 26.33 MB

bench.php - 50 iterations, 20 warmups, 2 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@cd8312e 0.45144 0.45483 0.00078 0.17% 0.45291 0.00% 0.45289 0.00% 0.167 0.000 1.000 26.28 MB
PHP - baseline@cd8312e (JIT) 0.14386 0.14473 0.00022 0.15% 0.14431 -68.14% 0.14430 -68.14% -0.067 8.614 0.000 26.33 MB
PHP - jit-recv-known-object 0.45137 0.45542 0.00079 0.17% 0.45288 -0.01% 0.45283 -0.01% 0.669 0.358 0.720 26.25 MB
PHP - jit-recv-known-object (JIT) 0.14365 0.14517 0.00026 0.18% 0.14433 -68.13% 0.14432 -68.13% 0.461 8.614 0.000 26.33 MB

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.

1 participant