Skip to content

Commit d788e4f

Browse files
committed
Add failing test for php#11917
1 parent 62e2402 commit d788e4f

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

ext/opcache/tests/jit/bug11917.phpt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
--TEST--
2+
Bug #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+
opcache.protect_memory=1
7+
opcache.jit_buffer_size=64M
8+
opcache.jit=1255
9+
opcache.jit_max_root_traces=1000000
10+
opcache.jit_max_side_traces=1000000
11+
opcache.jit_max_exit_counters=1000000
12+
opcache.jit_hot_loop=1
13+
opcache.jit_hot_func=1
14+
opcache.jit_hot_return=1
15+
opcache.jit_hot_side_exit=1
16+
--EXTENSIONS--
17+
opcache
18+
--FILE--
19+
<?php
20+
$a = [2147483647,2147483647,2147483647,3,0,0,32,2147483584,127];
21+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
22+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
23+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
24+
echo crc32(json_encode(bitwise_small_split($a))) . "\n";
25+
26+
function bitwise_small_split($val)
27+
{
28+
$split = 8;
29+
$vals = [];
30+
31+
$mask = (1 << $split) - 1;
32+
33+
$i = $overflow = 0;
34+
$len = count($val);
35+
$val[] = 0;
36+
$remaining = 31;
37+
38+
while ($i != $len) {
39+
$digit = $val[$i] & $mask;
40+
41+
$val[$i] >>= $split;
42+
if (!$overflow) {
43+
$remaining -= $split;
44+
$overflow = $split <= $remaining ? 0 : $split - $remaining;
45+
46+
if (!$remaining) {
47+
$i++;
48+
$remaining = 31;
49+
$overflow = 0;
50+
}
51+
} elseif (++$i != $len) {
52+
$tempmask = (1 << $overflow) - 1;
53+
$digit |= ($val[$i] & $tempmask) << $remaining;
54+
$val[$i] >>= $overflow;
55+
$remaining = 31 - $overflow;
56+
$overflow = $split <= $remaining ? 0 : $split - $remaining;
57+
}
58+
59+
$vals[] = $digit;
60+
}
61+
62+
while ($vals[count($vals) - 1] == 0) {
63+
unset($vals[count($vals) - 1]);
64+
}
65+
66+
return array_reverse($vals);
67+
}
68+
?>
69+
--EXPECT--
70+
48207660
71+
48207660
72+
48207660
73+
48207660

0 commit comments

Comments
 (0)