Skip to content

Add runtime type inference verification #12930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

iluuu1994
Copy link
Member

@iluuu1994 iluuu1994 commented Dec 11, 2023

TODO:

  • Move zend_execute.c/zend_vm_gen.php into separate file
  • Re-add COMMUNTIY to push to verify

@iluuu1994 iluuu1994 force-pushed the verify-type-inference branch from bb8507f to e759ef5 Compare December 11, 2023 12:31
@iluuu1994 iluuu1994 marked this pull request as ready for review December 11, 2023 13:11
@TimWolla TimWolla removed their request for review December 11, 2023 13:23
@dstogov
Copy link
Member

dstogov commented Dec 11, 2023

Do you see any existing failures now?
Are you going to check JIT and PHP built with DZEND_VERIFY_TYPE_INFERENCE together? ZEND_VERIFY_INFERENCE_DEF and ZEND_VERIFY_INFERENCE_USE are not going to be called with JIT.

@iluuu1994
Copy link
Member Author

iluuu1994 commented Dec 11, 2023

Do you see any existing failures now?

No, I didn't see any more failures the last time I checked.

ZEND_VERIFY_INFERENCE_DEF and ZEND_VERIFY_INFERENCE_USE are not going to be called with JIT.

Hmm, I did not think about this. That makes the flag less useful for the COMMUNTIY build. Do you think it would be possible to add some hook to the JIT?

@dstogov
Copy link
Member

dstogov commented Dec 11, 2023

ZEND_VERIFY_INFERENCE_DEF and ZEND_VERIFY_INFERENCE_USE are not going to be called with JIT.

Hmm, I did not think about this. That makes the flag less useful for the COMMUNTIY build.

Do you mean COMMUNIT tests? We may run them with ZEND_VERIFY_TYPE_INFERENCE without JIT and then with JIT but without ZEND_VERIFY_TYPE_INFERENCE.

Do you think it would be possible to add some hook to the JIT?

No :)
JIT keeps some values in CPU register and doesn't always maintain consistent VM stack on purpose.

@iluuu1994
Copy link
Member Author

@dstogov Right. Running community build twice is certainly an option. It significantly increases nightly runtime which I'm generally trying to avoid. But if verification in JIT is not an option then let's do that.

@dstogov
Copy link
Member

dstogov commented Dec 11, 2023

@dstogov Right. Running community build twice is certainly an option. It significantly increases nightly runtime which I'm generally trying to avoid. But if verification in JIT is not an option then let's do that.

It may be better to have a single nightly task for PHP master with ZEND_VERIFY_TYPE_INFERENCE that run make test and few community tests. Just not to pollute the other tasks.

@danog
Copy link
Contributor

danog commented Dec 23, 2023

Btw, my PR at #12406 can help with greatly reducing execution time for nightly tests by parallelizing them :)

@iluuu1994
Copy link
Member Author

I'm not too concerned about execution time (by the time I wake up nightly is usually done), but CI time as a whole (i.e. load on the planet). The community build is very slow partly because it's run with a debug build and ASAN. This isn't necessary for type inference at all, so another strategy might be to use a release build for this.

@iluuu1994 iluuu1994 force-pushed the verify-type-inference branch 2 times, most recently from c964452 to f2168e0 Compare January 4, 2024 16:06
iluuu1994 added a commit to iluuu1994/php-src that referenced this pull request Jan 10, 2024
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes phpGH-12930
@iluuu1994 iluuu1994 force-pushed the verify-type-inference branch from f2168e0 to a9fb8ce Compare January 10, 2024 14:17
@iluuu1994 iluuu1994 requested a review from bukka as a code owner January 10, 2024 14:17
iluuu1994 added a commit to iluuu1994/php-src that referenced this pull request Jan 10, 2024
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes phpGH-12930
@iluuu1994 iluuu1994 force-pushed the verify-type-inference branch from a9fb8ce to a670153 Compare January 10, 2024 17:09
iluuu1994 added a commit to iluuu1994/php-src that referenced this pull request Jan 10, 2024
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes phpGH-12930
@iluuu1994 iluuu1994 force-pushed the verify-type-inference branch from a670153 to 9860fda Compare January 10, 2024 18:52
@danog
Copy link
Contributor

danog commented Jan 10, 2024

@iluuu1994 you think you could also add my Psalm/phpstan entries for the community tests? (at least to test them temporarily in this PR)

@iluuu1994
Copy link
Member Author

@dstogov I changed this PR to use the VM_TRACE mechanism instead, which I found more reliable than hooking into ZEND_VM_NEXT_OPCODE_EX. This included an additional VM_TRACE_OP_END hook. Please let me know if you're ok with this approach.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

I don't see any serious problems.

It would be great to separate ""debug info"" from zend_op, but this will complicate and slow down the patch.

Another related idea - it's possible to support ZEND_VERIFY_TYPE_INFERENCE only for CALL VM. This should significantly reduce the amount of the debugging code.

Anyway, I think this may be merged as is.

Comment on lines -41 to +43
env:
CC: ccache gcc
CXX: ccache g++
# env:
# CC: ccache gcc
# CXX: ccache g++
Copy link
Member

Choose a reason for hiding this comment

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

What is a problem with ccache?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just for debugging. All changes from push.yml will be reverted before merging.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes phpGH-12930
@iluuu1994 iluuu1994 force-pushed the verify-type-inference branch from 9860fda to fdbb850 Compare January 17, 2024 14:51
@iluuu1994 iluuu1994 requested a review from kocsismate as a code owner January 17, 2024 14:51
@iluuu1994 iluuu1994 closed this in ffc250d Jan 19, 2024
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.

3 participants