Skip to content

[JIT] Avoid generating fast property assign path for readonly properties #15260

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

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

iluuu1994
Copy link
Member

readonly properties will usually be IS_UNDEF on assignment, dodging the fast path anyway. The fast path does not handle the readonly scope check. The alternative would be handling scope there, but since there are some many variants that might be more trouble than it's worth.

@iluuu1994 iluuu1994 marked this pull request as ready for review August 6, 2024 20:53
@iluuu1994 iluuu1994 requested a review from dstogov as a code owner August 6, 2024 20:53
@iluuu1994
Copy link
Member Author

@dstogov I'm not sure if we need to handle if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { for this branch. If so, please let me know.

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.

Your patch looks right.

readonly properties will usually be IS_UNDEF on assignment, dodging the fast
path anyway. The fast path does not handle the readonly scope check. The
alternative would be handling scope there, but since there are some many
variants that might be more trouble than it's worth.
@iluuu1994 iluuu1994 force-pushed the jit-omit-readonly-fast-path branch from 8d305c8 to e806c4d Compare August 9, 2024 09:49
@iluuu1994 iluuu1994 merged commit 7a2d5ef into php:master Aug 9, 2024
8 of 10 checks passed
@iluuu1994
Copy link
Member Author

@dstogov Thank you for confirming!

@@ -14435,7 +14435,13 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit,
} else {
prop_ref = ir_ADD_OFFSET(obj_ref, prop_info->offset);
prop_addr = ZEND_ADDR_REF_ZVAL(prop_ref);
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set || (prop_info->flags & ZEND_ACC_READONLY)) {
/* With the exception of __clone(), readonly assignment always happens on IS_UNDEF, doding
Copy link

Choose a reason for hiding this comment

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

doding?

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