Skip to content

Clean up remaining opcodes for foreach([] as $x) #4949

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 1 commit into from

Conversation

TysonAndre
Copy link
Contributor

I'm not familiar with the data structures involved in the passes after dfa,
so I'm not sure how to safely improve on this (removing NOPs).

Two useless FE_RESET_R and FE_FREE would be left over whether the empty array
was from a literal, a variable, or a class constant.

@nikic
Copy link
Member

nikic commented Dec 5, 2019

Not quite sure what difficulties that would entail, but generally I think that this is something that should be handled by DCE.

@nikic
Copy link
Member

nikic commented Dec 5, 2019

Something along these lines: https://gist.github.com/nikic/58d367ad605e10299f5433d2d83a0b5b

This doesn't pick up the RESET_RW case due to a weakness in our "may throw" modeling.

Previously, two useless FE_RESET_R and FE_FREE would be left over whether the empty array
was from a literal, a variable, or a class constant.

This doesn't pick up the RESET_RW case due to a weakness in our "may throw"
modeling. (for foreach by reference).

Co-Authored-By: Nikita Popov <[email protected]>
using https://gist.github.com/nikic/58d367ad605e10299f5433d2d83a0b5b
@TysonAndre TysonAndre force-pushed the speed-up-empty-foreach branch from 7589192 to 725bbc7 Compare December 20, 2020 19:35
@php-pulls php-pulls closed this in df0fa5b Jan 7, 2021
@TysonAndre TysonAndre deleted the speed-up-empty-foreach branch November 25, 2021 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants