-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove redundant exception check from VM #18730
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
Conversation
Whether an exception happened is already checked a few lines up.
The proper way to do it would be moving the ZEND_VM_NEXT_OPCODE_EX (which does not check EG(exception) itself in non-debug, just EX(opline) vs %r15) before the exception check. (As that avoids the branch completely on that path.) |
I don't see how that's better |
Seems less expensive to me to just load EX(opline) than checking if(EG(exception))? Or am I mistaken? |
I agree with this statement. |
Yes sure, but only for the case where there are actually args for the object construction. |
It clicked. Thanks for pointing it out |
I don't see how the new code is better. |
No, I had originally changed ZEND_VM_NEXT_OPCODE_EX so that check_exception is 0. And then undid that and swapped the checks. I suppose the first idea was better as it kept the exception code path the same cost and changed an EX(opline) access in just an online access. |
I think so. |
@dstogov I'm confused. ZEND_VM_NEXT_OPCODE_EX returns. The case with exception and arguments is slightly more expensive, yes. The case without arguments should be less expensive. And the case with arguments and no exceptions should be unchanged. Correct? |
No. The case without arguments becomes more expensive. A single |
The case without arguments and an exception. The case without arguments without exception is cheaper, right? And IIRC, we optimize for the happy path, not the exception? |
right.
right. I was wrong. |
Whether an exception happened is already checked a few lines up.