xref: /PHP-8.0/ext/opcache/tests/jit/bug80802.phpt (revision 957cb13a)
1--TEST--
2Bug #80802: zend_jit_fetch_indirect_var assert failure with tracing JIT
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.jit_buffer_size=1M
7opcache.jit=tracing
8--SKIPIF--
9<?php require_once('skipif.inc'); ?>
10--FILE--
11<?php
12abstract class AsyncTask{
13        private static $threadLocalStorage = null;
14
15        protected function storeLocal(string $key, $complexData) : void{
16                if(self::$threadLocalStorage === null){
17                        self::$threadLocalStorage = new \ArrayObject();
18                }
19                self::$threadLocalStorage[spl_object_id($this)][$key] = $complexData;
20        }
21
22        final public function __destruct(){
23                $this->reallyDestruct();
24                if(self::$threadLocalStorage !== null and isset(self::$threadLocalStorage[$h = spl_object_id($this)])){
25                        unset(self::$threadLocalStorage[$h]);
26                        if(self::$threadLocalStorage->count() === 0){
27                                self::$threadLocalStorage = null;
28                        }
29                }
30        }
31
32        protected function reallyDestruct() : void{
33
34        }
35}
36
37class Task extends AsyncTask{
38        public function __construct(){
39                $this->storeLocal("thing1", new stdClass);
40        }
41}
42
43for($i = 0; $i < 10000; ++$i){
44        new Task;
45}
46echo "OK\n";
47?>
48--EXPECT--
49OK
50