Skip to content

JIT: implement empty($cv) fast path in function & tracing JIT - #24239

Open
ndossche wants to merge 1 commit into
php:masterfrom
ndossche:jit-empty-cv
Open

ndossche wants to merge 1 commit into
php:masterfrom
ndossche:jit-empty-cv

Conversation

@ndossche

Copy link
Copy Markdown
Member

We can simply defer to zend_jit_bool_jmpznz() which already generates optimized paths for many types.

Example PHP:

function f(int $i) {
    if (empty($i)) return 1;
    return 2;
}

Before (function JIT):

.L1:
	movl $0x414d88a0, %r15d          ; opline = ISSET_ISEMPTY_CV
	movabsq $0x55a80140fe00, %rax
	callq *%rax                      ; Call VM handler
	cmpl $0x414d88e0, %r15d          ; check if the handler branched
	jne .L2
	movq 0x10(%r14), %rax            ; return 1
	...
.L2:                                     ; return 2
	...

After (function JIT):

.L1:
	cmpq $0, 0x50(%r14)              ; empty($i) check
	je .L3
	movq 0x10(%r14), %rax            ; return 2
	...
.L3:                                     ; return 1
	...

We can simply defer to zend_jit_bool_jmpznz() which already generates
optimized paths for many types.

Example PHP:
```php
function f(int $i) {
    if (empty($i)) return 1;
    return 2;
}
```

Before (function JIT):
```asm
.L1:
	movl $0x414d88a0, %r15d          ; opline = ISSET_ISEMPTY_CV
	movabsq $0x55a80140fe00, %rax
	callq *%rax                      ; Call VM handler
	cmpl $0x414d88e0, %r15d          ; check if the handler branched
	jne .L2
	movq 0x10(%r14), %rax            ; return 1
	...
.L2:                                     ; return 2
	...
```

After (function JIT):
```asm
.L1:
	cmpq $0, 0x50(%r14)              ; empty($i) check
	je .L3
	movq 0x10(%r14), %rax            ; return 2
	...
.L3:                                     ; return 1
	...
```
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