Skip to content

Commit 7a2d5ef

Browse files
authored
[JIT] Avoid generating fast property assign path for readonly properties (#15260)
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.
1 parent 42c9963 commit 7a2d5ef

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14435,7 +14435,13 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit,
1443514435
} else {
1443614436
prop_ref = ir_ADD_OFFSET(obj_ref, prop_info->offset);
1443714437
prop_addr = ZEND_ADDR_REF_ZVAL(prop_ref);
14438-
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set || (prop_info->flags & ZEND_ACC_READONLY)) {
14438+
/* With the exception of __clone(), readonly assignment always happens on IS_UNDEF, doding
14439+
* the fast path. Thus, the fast path is not useful. */
14440+
if (prop_info->flags & ZEND_ACC_READONLY) {
14441+
ZEND_ASSERT(slow_inputs == IR_UNUSED);
14442+
goto slow_path;
14443+
}
14444+
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set) {
1443914445
// Undefined property with magic __get()/__set()
1444014446
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1444114447
int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM);
@@ -14527,6 +14533,8 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit,
1452714533
ir_ref arg3, arg5;
1452814534

1452914535
ir_MERGE_list(slow_inputs);
14536+
14537+
slow_path:
1453014538
jit_SET_EX_OPLINE(jit, opline);
1453114539

1453214540
if (Z_MODE(val_addr) == IS_REG) {

0 commit comments

Comments
 (0)