Skip to content

Commit ef91794

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fixed GH-11917: primitives seem to be passed via reference instead of by value under some conditions when JIT is enabled on windows (#12451)
2 parents 0c6999c + 89eb1c6 commit ef91794

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5171,7 +5171,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
51715171
result_reg = ZREG_R0;
51725172
} else {
51735173
/* ASSIGN_DIM_OP */
5174-
if (sizeof(void*) == 4
5174+
if (ZREG_FCARG1 == ZREG_RCX
51755175
&& (opcode == ZEND_SL || opcode == ZEND_SR)
51765176
&& Z_MODE(op2_addr) != IS_CONST_ZVAL) {
51775177
result_reg = ZREG_R2;

ext/opcache/tests/jit/gh11917.phpt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
--TEST--
2+
GH-11917: primitives seem to be passed via reference instead of by value under some conditions when JIT is enabled on windows
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--FILE--
7+
<?php
8+
$a = [2147483647,2147483647,2147483647,3,0,0,32,2147483584,127];
9+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
10+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
11+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
12+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
13+
14+
function bitwise_small_split($val)
15+
{
16+
$split = 8;
17+
$vals = [];
18+
19+
$mask = (1 << $split) - 1;
20+
21+
$i = $overflow = 0;
22+
$len = count($val);
23+
$val[] = 0;
24+
$remaining = 31;
25+
26+
while ($i != $len) {
27+
$digit = $val[$i] & $mask;
28+
29+
$val[$i] >>= $split;
30+
if (!$overflow) {
31+
$remaining -= $split;
32+
$overflow = $split <= $remaining ? 0 : $split - $remaining;
33+
34+
if (!$remaining) {
35+
$i++;
36+
$remaining = 31;
37+
$overflow = 0;
38+
}
39+
} elseif (++$i != $len) {
40+
$tempmask = (1 << $overflow) - 1;
41+
$digit |= ($val[$i] & $tempmask) << $remaining;
42+
$val[$i] >>= $overflow;
43+
$remaining = 31 - $overflow;
44+
$overflow = $split <= $remaining ? 0 : $split - $remaining;
45+
}
46+
47+
$vals[] = $digit;
48+
}
49+
50+
while ($vals[count($vals) - 1] == 0) {
51+
unset($vals[count($vals) - 1]);
52+
}
53+
54+
return array_reverse($vals);
55+
}
56+
?>
57+
--EXPECT--
58+
48207660
59+
48207660
60+
48207660
61+
48207660

0 commit comments

Comments
 (0)