Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ PHP NEWS
. Fixed bug GH-24438 (Preserve indirect types in JIT side traces). (aasul)
. Fixed bug GH-24577 (CE-cache flag on interned class name visible before
map_ptr offset). (prateekbhujel)
. Fixed JIT segfault on switch over a string reference holding a
non-string value. (jorgsowa)

- PDO:
. Fixed invalid ATTR_ORACLE_NULLS values being accepted and truncated.
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -16234,7 +16234,7 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
if (fallback_label) {
jit_guard_Z_TYPE(jit, op1_addr, IS_REFERENCE, fallback_label);
} else {
ir_ref if_ref = jit_if_Z_TYPE(jit, op1_addr, IS_STRING);
ir_ref if_ref = jit_if_Z_TYPE(jit, op1_addr, IS_REFERENCE);
ir_IF_FALSE_cold(if_ref);
ir_refs_add(slow_inputs, ir_END());
ir_IF_TRUE(if_ref);
Expand All @@ -16244,7 +16244,7 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
op1_addr = ZEND_ADDR_REF_ZVAL(ref2);

if (fallback_label) {
jit_guard_Z_TYPE(jit, op1_addr, IS_LONG, fallback_label);
jit_guard_Z_TYPE(jit, op1_addr, IS_STRING, fallback_label);
} else {
if_string = jit_if_Z_TYPE(jit, op1_addr, IS_STRING);
ir_IF_FALSE_cold(if_string);
Expand Down
27 changes: 27 additions & 0 deletions ext/opcache/tests/jit/switch_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
JIT SWITCH_STRING on a reference holding a non-string value
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit=tracing
opcache.jit_hot_loop=1
--EXTENSIONS--
opcache
--FILE--
<?php
function test($a) {
$n = 0;
foreach ($a as &$x) {
switch ($x) {
case "a": case "b": $n++; break;
}
}
return $n;
}
var_dump(test(["a"]));
var_dump(test([1]));
?>
--EXPECT--
int(1)
int(0)
26 changes: 26 additions & 0 deletions ext/opcache/tests/jit/switch_003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
JIT SWITCH_STRING on a reference (function JIT)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit=function
--EXTENSIONS--
opcache
--FILE--
<?php
function test($a) {
$n = 0;
foreach ($a as &$x) {
switch ($x) {
case "a": case "b": $n++; break;
}
}
return $n;
}
var_dump(test(["a", "b", "c"]));
var_dump(test([1]));
?>
--EXPECT--
int(2)
int(0)
Loading