[php-src] PHP-8.2: Fix GH-13508: JITed QM_ASSIGN may be optimized out when op1 is null (#13610)

From: Date: Mon, 11 Mar 2024 14:24:02 +0000
Subject: [php-src] PHP-8.2: Fix GH-13508: JITed QM_ASSIGN may be optimized out when op1 is null (#13610)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-127697@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Committer: GitHub (web-flow) Pusher: arnaud-lb Date: 2024-03-11T15:10:12+01:00 Commit: https://github.com/php/php-src/commit/0ea80126ead6951def2b1dbc28fda024a226fa27 Raw diff: https://github.com/php/php-src/commit/0ea80126ead6951def2b1dbc28fda024a226fa27.diff Fix GH-13508: JITed QM_ASSIGN may be optimized out when op1 is null (#13610) Co-authored-by: Dmitry Stogov <dmitry@zend.com> Changed paths: A ext/opcache/tests/jit/qm_assign_004.phpt M ext/opcache/jit/zend_jit_trace.c Diff: diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index f6da28375b74d..c1ed5d80a666a 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -5070,8 +5070,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par CHECK_OP1_TRACE_TYPE(); res_info = RES_INFO(); res_use_info = zend_jit_trace_type_to_info( - STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var))) - & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE); + STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var))); res_addr = RES_REG_ADDR(); if (Z_MODE(res_addr) != IS_REG && STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var)) != diff --git a/ext/opcache/tests/jit/qm_assign_004.phpt b/ext/opcache/tests/jit/qm_assign_004.phpt new file mode 100644 index 0000000000000..975d46be41cec --- /dev/null +++ b/ext/opcache/tests/jit/qm_assign_004.phpt @@ -0,0 +1,39 @@ +--TEST-- +JIT QM_ASSIGN: 004 missing type store +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- +<?php + +function getPropertyScopes($props, $flags): array +{ + $propertyScopes = []; + foreach ($props as $prop) { + $tmp = 'x'.$flags; + $propertyScopes[] = $propertyScopes[] = ($flags & 1 ? false : null) . ''; + } + + return $propertyScopes; +} + +var_dump(getPropertyScopes(['a'], 0)); +var_dump(getPropertyScopes(['a'], 0)); +?> +DONE +--EXPECT-- +array(2) { + [0]=> + string(0) "" + [1]=> + string(0) "" +} +array(2) { + [0]=> + string(0) "" + [1]=> + string(0) "" +} +DONE

« previous php.cvs (#127697) next »